14#include "arcane/core/NodesOfItemReorderer.h"
16#include "arcane/utils/NotImplementedException.h"
18#include "arcane/core/ItemTypeId.h"
31bool NodesOfItemReorderer::
34 [[maybe_unused]]
bool has_center_node)
39 Int32 nb_node = nodes_uid.size();
43 ARCANE_THROW(NotImplementedException,
"Node reordering for 2D type of order 3 or more");
45 if (nodes_uid[0] < nodes_uid[1]) {
47 sorted_nodes_uid[0] = nodes_uid[0];
48 sorted_nodes_uid[1] = nodes_uid[1];
49 sorted_nodes_uid[2] = nodes_uid[2];
50 sorted_nodes_uid[3] = nodes_uid[3];
53 sorted_nodes_uid[0] = nodes_uid[1];
54 sorted_nodes_uid[1] = nodes_uid[0];
55 sorted_nodes_uid[2] = nodes_uid[3];
56 sorted_nodes_uid[3] = nodes_uid[2];
63bool NodesOfItemReorderer::
69 bool need_swap_orientation =
false;
70 Int32 min_node_index = 0;
72 Int32 nb_node = nodes_uid.size();
76 if (nodes_uid[0] < nodes_uid[1]) {
77 sorted_nodes_uid[0] = nodes_uid[0];
78 sorted_nodes_uid[1] = nodes_uid[1];
79 sorted_nodes_uid[2] = nodes_uid[2];
82 sorted_nodes_uid[0] = nodes_uid[1];
83 sorted_nodes_uid[1] = nodes_uid[0];
84 sorted_nodes_uid[2] = nodes_uid[2];
91 sorted_nodes_uid[nb_node - 1] = nodes_uid[nb_node - 1];
95 nb_node = nb_node / 2;
110 Int64 min_node = INT64_MAX;
111 for (
Integer k = 0; k < nb_node; ++k) {
112 Int64 id = nodes_uid[k];
118 Int64 next_node = nodes_uid[(min_node_index + 1) % nb_node];
119 Int64 prev_node = nodes_uid[(min_node_index + (nb_node - 1)) % nb_node];
126 if (next_node == min_node) {
127 next_node = nodes_uid[(min_node_index + (nb_node + 2)) % nb_node];
130 if (prev_node == min_node) {
131 prev_node = nodes_uid[(min_node_index + (nb_node - 2)) % nb_node];
135 if (next_node > prev_node)
136 need_swap_orientation =
true;
137 if (need_swap_orientation) {
138 for (
Integer k = 0; k < nb_node; ++k) {
139 Integer index = (nb_node - k + min_node_index + incr) % nb_node;
140 Int32 index2 = ((2*nb_node-1) + incr + min_node_index - k) % nb_node;
141 sorted_nodes_uid[k] = nodes_uid[index];
142 sorted_nodes_uid[k + nb_node] = nodes_uid[index2 + nb_node];
146 for (
Integer k = 0; k < nb_node; ++k) {
147 Integer index = (k + min_node_index + incr2) % nb_node;
148 sorted_nodes_uid[k] = nodes_uid[index];
149 sorted_nodes_uid[k + nb_node] = nodes_uid[index + nb_node];
152 return need_swap_orientation;
158bool NodesOfItemReorderer::
161 ItemTypeInfo* iti = m_item_type_mng->typeFromId(type_id);
162 Int32 order = iti->order();
163 Int32 nb_node = nodes_uids.size();
164 m_work_sorted_nodes.resize(nb_node);
166 ARCANE_THROW(NotImplementedException,
"Node reordering for type of order 4 or more");
168 return _reorderOrder3(nodes_uids, m_work_sorted_nodes, iti->hasCenterNode());
170 return _reorderOrder2(nodes_uids, m_work_sorted_nodes, iti->hasCenterNode());
171 return MeshUtils::reorderNodesOfFace(nodes_uids, m_work_sorted_nodes);
#define ARCANE_THROW(exception_class,...)
Macro pour envoyer une exception avec formattage.
Fonctions utilitaires sur le maillage.
Vue modifiable d'un tableau d'un type T.
Vue constante d'un tableau de type T.
Type d'une entité (Item).
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
std::int64_t Int64
Type entier signé sur 64 bits.
Int32 Integer
Type représentant un entier.
std::int32_t Int32
Type entier signé sur 32 bits.