14#include "arcane/core/NodesOfItemReorderer.h"
16#include "arcane/utils/NotImplementedException.h"
18#include "arcane/core/ItemTypeId.h"
32bool NodesOfItemReorderer::
35 [[maybe_unused]]
bool has_center_node)
40 Int32 nb_node = nodes_uid.size();
44 ARCANE_THROW(NotImplementedException,
"Node reordering for 2D type of order 3 or more");
46 if (nodes_uid[0] < nodes_uid[1]) {
48 sorted_nodes_uid[0] = nodes_uid[0];
49 sorted_nodes_uid[1] = nodes_uid[1];
50 sorted_nodes_uid[2] = nodes_uid[2];
51 sorted_nodes_uid[3] = nodes_uid[3];
54 sorted_nodes_uid[0] = nodes_uid[1];
55 sorted_nodes_uid[1] = nodes_uid[0];
56 sorted_nodes_uid[2] = nodes_uid[3];
57 sorted_nodes_uid[3] = nodes_uid[2];
65bool NodesOfItemReorderer::
71 bool need_swap_orientation =
false;
72 Int32 min_node_index = 0;
74 Int32 nb_node = nodes_uid.size();
78 if (nodes_uid[0] < nodes_uid[1]) {
79 sorted_nodes_uid[0] = nodes_uid[0];
80 sorted_nodes_uid[1] = nodes_uid[1];
81 sorted_nodes_uid[2] = nodes_uid[2];
84 sorted_nodes_uid[0] = nodes_uid[1];
85 sorted_nodes_uid[1] = nodes_uid[0];
86 sorted_nodes_uid[2] = nodes_uid[2];
93 sorted_nodes_uid[nb_node - 1] = nodes_uid[nb_node - 1];
97 nb_node = nb_node / 2;
112 Int64 min_node = INT64_MAX;
113 for (
Integer k = 0; k < nb_node; ++k) {
114 Int64 id = nodes_uid[k];
120 Int64 next_node = nodes_uid[(min_node_index + 1) % nb_node];
121 Int64 prev_node = nodes_uid[(min_node_index + (nb_node - 1)) % nb_node];
128 if (next_node == min_node) {
129 next_node = nodes_uid[(min_node_index + (nb_node + 2)) % nb_node];
132 if (prev_node == min_node) {
133 prev_node = nodes_uid[(min_node_index + (nb_node - 2)) % nb_node];
137 if (next_node > prev_node)
138 need_swap_orientation =
true;
139 if (need_swap_orientation) {
140 for (
Integer k = 0; k < nb_node; ++k) {
141 Integer index = (nb_node - k + min_node_index + incr) % nb_node;
142 Int32 index2 = ((2 * nb_node - 1) + incr + min_node_index - k) % nb_node;
143 sorted_nodes_uid[k] = nodes_uid[index];
144 sorted_nodes_uid[k + nb_node] = nodes_uid[index2 + nb_node];
148 for (
Integer k = 0; k < nb_node; ++k) {
149 Integer index = (k + min_node_index + incr2) % nb_node;
150 sorted_nodes_uid[k] = nodes_uid[index];
151 sorted_nodes_uid[k + nb_node] = nodes_uid[index + nb_node];
154 return need_swap_orientation;
160bool NodesOfItemReorderer::
163 ItemTypeInfo* iti = m_item_type_mng->typeFromId(type_id);
164 Int32 order = iti->order();
165 Int32 nb_node = nodes_uids.size();
166 m_work_sorted_nodes.resize(nb_node);
168 ARCANE_THROW(NotImplementedException,
"Node reordering for type of order 4 or more");
170 return _reorderOrder3(nodes_uids, m_work_sorted_nodes, iti->hasCenterNode());
172 return _reorderOrder2(nodes_uids, m_work_sorted_nodes, iti->hasCenterNode());
173 return MeshUtils::reorderNodesOfFace(nodes_uids, m_work_sorted_nodes);
#define ARCANE_THROW(exception_class,...)
Macro for throwing an exception with formatting.
Utility functions for the mesh.
Modifiable view of an array of type T.
Constant view of an array of type T.
Type of an entity (Item).
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
std::int32_t Int32
Signed integer type of 32 bits.