14#include "arcane/utils/NotSupportedException.h"
16#include "arcane/cartesianmesh/CartesianConnectivity.h"
17#include "arcane/cartesianmesh/ICartesianMesh.h"
19#include "arcane/core/IMesh.h"
20#include "arcane/core/IItemFamily.h"
21#include "arcane/core/VariableTypes.h"
23#include "arcane/cartesianmesh/internal/ICartesianMeshInternal.h"
24#include "arcane/cartesianmesh/internal/ICartesianMeshNumberingMngInternal.h"
39 m_nodes_to_cell = nodes_to_cell;
40 m_cells_to_node = cells_to_node;
41 m_permutation = permutation;
59 if (
mesh->dimension() == 2 ||
mesh->dimension() == 1)
60 _computeInfos2D(
mesh, nodes_coord, cells_coord);
61 else if (
mesh->dimension() == 3)
62 _computeInfos3D(
mesh, nodes_coord, cells_coord);
77 _computeInfos2D(cmesh);
79 _computeInfos3D(cmesh);
87void CartesianConnectivity::
91 CartesianConnectivity& cc = *
this;
92 IItemFamily* node_family = mesh->nodeFamily();
93 IItemFamily* cell_family = mesh->cellFamily();
97 Real3 node_coord = nodes_coord[inode];
98 Index& idx = cc._index(node);
99 idx.fill(NULL_ITEM_LOCAL_ID);
100 Integer nb_cell = node.nbCell();
101 for (
Integer i = 0; i < nb_cell; ++i) {
102 Cell cell = node.cell(i);
103 Int32 cell_lid = cell.localId();
104 Real3 cell_coord = cells_coord[cell];
105 if (cell_coord.y > node_coord.y) {
106 if (cell_coord.x > node_coord.x)
107 idx.v[P_UpperRight] = cell_lid;
109 idx.v[P_UpperLeft] = cell_lid;
112 if (cell_coord.x > node_coord.x)
113 idx.v[P_LowerRight] = cell_lid;
115 idx.v[P_LowerLeft] = cell_lid;
122 Real3 cell_coord = cells_coord[cell];
123 Index& idx = _index(cell);
124 idx.fill(NULL_ITEM_LOCAL_ID);
125 Integer nb_node = cell.nbNode();
126 for (
Integer i = 0; i < nb_node; ++i) {
127 Node node = cell.node(i);
128 Int32 node_lid = node.localId();
129 Real3 node_coord = nodes_coord[node];
130 if (node_coord.y > cell_coord.y) {
131 if (node_coord.x > cell_coord.x)
132 idx.v[P_UpperRight] = node_lid;
134 idx.v[P_UpperLeft] = node_lid;
137 if (node_coord.x > cell_coord.x)
138 idx.v[P_LowerRight] = node_lid;
140 idx.v[P_LowerLeft] = node_lid;
149void CartesianConnectivity::
152 Ref<ICartesianMeshNumberingMngInternal> numbering = cmesh->_internalApi()->cartesianMeshNumberingMngInternal();
154 CartesianConnectivity& cc = *
this;
155 IItemFamily* node_family = cmesh->mesh()->nodeFamily();
156 IItemFamily* cell_family = cmesh->mesh()->cellFamily();
159 constexpr Integer nb_cell_around_node_max = 4;
160 Int64 cells_around[nb_cell_around_node_max];
161 ArrayView av_cells_around(nb_cell_around_node_max, cells_around);
173 constexpr Int32 pos_2d[nb_cell_around_node_max] = { P_LowerLeft, P_LowerRight, P_UpperLeft, P_UpperRight };
175 ENUMERATE_ (Node, inode, node_family->allItems()) {
177 numbering->cellUniqueIdsAroundNode(av_cells_around, node);
179 Index& idx = cc._index(node);
180 idx.fill(NULL_ITEM_LOCAL_ID);
182 const Integer nb_cell = node.nbCell();
183 for (
Integer i = 0; i < nb_cell; ++i) {
184 Cell cell = node.cell(i);
186 for (; pos < nb_cell_around_node_max; ++pos) {
187 if (cell.uniqueId() == av_cells_around[pos])
190 if (pos == nb_cell_around_node_max)
193 const Int32 cell_lid = cell.localId();
194 idx.v[pos_2d[pos]] = cell_lid;
199 constexpr Integer nb_node_in_cell_max = 4;
200 Int64 nodes_in_cell[nb_node_in_cell_max];
201 ArrayView av_nodes_in_cell(nb_node_in_cell_max, nodes_in_cell);
213 constexpr Int32 pos_2d[nb_node_in_cell_max] = { P_LowerLeft, P_LowerRight, P_UpperRight, P_UpperLeft };
217 numbering->cellNodeUniqueIds(av_nodes_in_cell, cell);
219 Index& idx = _index(cell);
220 idx.fill(NULL_ITEM_LOCAL_ID);
222 const Integer nb_node = cell.nbNode();
223 for (
Integer i = 0; i < nb_node; ++i) {
224 Node node = cell.node(i);
226 for (; pos < nb_node_in_cell_max; ++pos) {
227 if (node.uniqueId() == av_nodes_in_cell[pos])
230 if (pos == nb_node_in_cell_max)
233 const Int32 node_lid = node.localId();
234 idx.v[pos_2d[pos]] = node_lid;
243void CartesianConnectivity::
247 CartesianConnectivity& cc = *
this;
248 IItemFamily* node_family = mesh->nodeFamily();
249 IItemFamily* cell_family = mesh->cellFamily();
253 Real3 node_coord = nodes_coord[inode];
254 Index& idx = cc._index(node);
255 idx.fill(NULL_ITEM_LOCAL_ID);
256 Integer nb_cell = node.nbCell();
257 for (
Integer i = 0; i < nb_cell; ++i) {
258 Cell cell = node.cell(i);
259 Int32 cell_lid = cell.localId();
260 Real3 cell_coord = cells_coord[cell];
262 if (cell_coord.z > node_coord.z) {
263 if (cell_coord.y > node_coord.y) {
264 if (cell_coord.x > node_coord.x)
265 idx.v[P_TopZUpperRight] = cell_lid;
267 idx.v[P_TopZUpperLeft] = cell_lid;
270 if (cell_coord.x > node_coord.x)
271 idx.v[P_TopZLowerRight] = cell_lid;
273 idx.v[P_TopZLowerLeft] = cell_lid;
277 if (cell_coord.y > node_coord.y) {
278 if (cell_coord.x > node_coord.x)
279 idx.v[P_UpperRight] = cell_lid;
281 idx.v[P_UpperLeft] = cell_lid;
284 if (cell_coord.x > node_coord.x)
285 idx.v[P_LowerRight] = cell_lid;
287 idx.v[P_LowerLeft] = cell_lid;
295 Real3 cell_coord = cells_coord[cell];
296 Index& idx = _index(cell);
297 idx.fill(NULL_ITEM_LOCAL_ID);
298 Integer nb_node = cell.nbNode();
299 for (
Integer i = 0; i < nb_node; ++i) {
300 Node node = cell.node(i);
301 Int32 node_lid = node.localId();
302 Real3 node_coord = nodes_coord[node];
304 if (node_coord.z > cell_coord.z) {
305 if (node_coord.y > cell_coord.y) {
306 if (node_coord.x > cell_coord.x)
307 idx.v[P_TopZUpperRight] = node_lid;
309 idx.v[P_TopZUpperLeft] = node_lid;
312 if (node_coord.x > cell_coord.x)
313 idx.v[P_TopZLowerRight] = node_lid;
315 idx.v[P_TopZLowerLeft] = node_lid;
319 if (node_coord.y > cell_coord.y) {
320 if (node_coord.x > cell_coord.x)
321 idx.v[P_UpperRight] = node_lid;
323 idx.v[P_UpperLeft] = node_lid;
326 if (node_coord.x > cell_coord.x)
327 idx.v[P_LowerRight] = node_lid;
329 idx.v[P_LowerLeft] = node_lid;
339void CartesianConnectivity::
342 Ref<ICartesianMeshNumberingMngInternal> numbering = cmesh->_internalApi()->cartesianMeshNumberingMngInternal();
344 CartesianConnectivity& cc = *
this;
345 IItemFamily* node_family = cmesh->mesh()->nodeFamily();
346 IItemFamily* cell_family = cmesh->mesh()->cellFamily();
349 constexpr Integer nb_cell_around_node_max = 8;
350 Int64 cells_around[nb_cell_around_node_max];
351 ArrayView av_cells_around(nb_cell_around_node_max, cells_around);
364 constexpr Int32 pos_3d[nb_cell_around_node_max] = { P_LowerLeft, P_LowerRight, P_UpperLeft, P_UpperRight, P_TopZLowerLeft, P_TopZLowerRight, P_TopZUpperLeft, P_TopZUpperRight };
366 ENUMERATE_ (Node, inode, node_family->allItems()) {
368 numbering->cellUniqueIdsAroundNode(av_cells_around, node);
370 Index& idx = cc._index(node);
371 idx.fill(NULL_ITEM_LOCAL_ID);
373 const Integer nb_cell = node.nbCell();
374 for (
Integer i = 0; i < nb_cell; ++i) {
375 Cell cell = node.cell(i);
377 for (; pos < nb_cell_around_node_max; ++pos) {
378 if (cell.uniqueId() == av_cells_around[pos])
381 if (pos == nb_cell_around_node_max)
384 const Int32 cell_lid = cell.localId();
385 idx.v[pos_3d[pos]] = cell_lid;
390 constexpr Integer nb_node_in_cell_max = 8;
391 Int64 nodes_in_cell[nb_node_in_cell_max];
392 ArrayView av_nodes_in_cell(nb_node_in_cell_max, nodes_in_cell);
405 constexpr Int32 pos_3d[nb_node_in_cell_max] = { P_LowerLeft, P_LowerRight, P_UpperRight, P_UpperLeft, P_TopZLowerLeft, P_TopZLowerRight, P_TopZUpperRight, P_TopZUpperLeft };
409 numbering->cellNodeUniqueIds(av_nodes_in_cell, cell);
411 Index& idx = _index(cell);
412 idx.fill(NULL_ITEM_LOCAL_ID);
414 const Integer nb_node = cell.nbNode();
415 for (
Integer i = 0; i < nb_node; ++i) {
416 Node node = cell.node(i);
418 for (; pos < nb_node_in_cell_max; ++pos) {
419 if (node.uniqueId() == av_nodes_in_cell[pos])
422 if (pos == nb_node_in_cell_max)
425 const Int32 node_lid = node.localId();
426 idx.v[pos_3d[pos]] = node_lid;
444 { 0, 1, 2, 3, 4, 5, 6, 7 },
445 { 3, 0, 1, 2, 7, 4, 5, 6 },
446 { 1, 5, 6, 2, 0, 4, 7, 3 }
449 for (
Int32 i = 0; i < 3; ++i)
450 for (
Int32 j = 0; j < 8; ++j)
451 permutation[i][j] =
static_cast<ePosition>(p[i][j]);
Vue modifiable d'un tableau d'un type T.
void _computeInfos(IMesh *mesh, VariableNodeReal3 &nodes_coord, VariableCellReal3 &cells_coord)
Calcule les infos de connectivité.
ePosition
Type énuméré indiquant la position.
void _setStorage(ArrayView< Index > nodes_to_cell, ArrayView< Index > cells_to_node, const Permutation *permutation)
Positionne les tableaux contenant les infos de connectivité
Vue sur les informations des mailles.
Interface d'un maillage cartésien.
virtual IMesh * mesh() const =0
Maillage associé à ce maillage cartésien.
virtual IItemFamily * nodeFamily()=0
Retourne la famille des noeuds.
virtual Integer dimension()=0
Dimension du maillage (1D, 2D ou 3D).
virtual IItemFamily * cellFamily()=0
Retourne la famille des mailles.
Vue sur les informations des noeuds.
Exception lorsqu'une opération n'est pas supportée.
MeshVariableScalarRefT< Cell, Real3 > VariableCellReal3
Grandeur au centre des mailles de type coordonnées.
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Grandeur au noeud de type coordonnées.
-*- 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.
@ Cell
Le maillage est AMR par maille.
std::int32_t Int32
Type entier signé sur 32 bits.
Liste des 8 entités autout d'une autre entité
Permutation dans Index pour chaque direction.
void compute()
Calcule les permutations des 8 ePosition pour chaque direction.