14#include "arcane/cartesianmesh/internal/CartesianMeshPatch.h"
16#include "arcane/IMesh.h"
17#include "arcane/ItemPrinter.h"
19#include "arcane/cartesianmesh/ICartesianMesh.h"
20#include "arcane/cartesianmesh/CartesianConnectivity.h"
38, m_amr_patch_index(patch_index)
41 Integer nb_dir = cmesh->mesh()->dimension();
42 for (Integer i = 0; i < nb_dir; ++i) {
44 m_cell_directions[i]._internalInit(cmesh, dir, patch_index);
45 m_face_directions[i]._internalInit(cmesh, dir, patch_index);
46 m_node_directions[i]._internalInit(cmesh, dir, patch_index);
54CartesianMeshPatch(ICartesianMesh* cmesh,Integer patch_index)
55: CartesianMeshPatch(cmesh, patch_index, {})
65 for( Integer i=0; i<3; ++i ){
66 m_cell_directions[i]._internalDestroy();
67 m_face_directions[i]._internalDestroy();
68 m_node_directions[i]._internalDestroy();
82 return cellDirection(MD_DirX).allCells();
91 return cellDirection(MD_DirX).inPatchCells();
100void CartesianMeshPatch::
101_computeNodeCellInformations2D(Cell cell0,Real3 cell0_coord,VariableNodeReal3& nodes_coord)
103 using Int8 = std::int8_t;
104 Int8 nodes_indirection_i[CellDirectionMng::MAX_NB_NODE];
105 ArrayView<Int8> nodes_indirection(CellDirectionMng::MAX_NB_NODE,nodes_indirection_i);
106 Int32 nb_node = cell0.nbNode();
108 ARCANE_FATAL(
"Number of nodes should be '4' (v={0})",nb_node);
110 Real3 cell_coord = cell0_coord;
111 bool is_2d = m_mesh->mesh()->dimension()==2;
113 ARCANE_FATAL(
"Invalid call. This mesh is not a 2D mesh");
116 nodes_indirection.fill(-1);
117 for( Int8 i=0; i<i8_nb_node; ++i ){
118 Node node = cell0.node(i);
119 Real3 node_coord = nodes_coord[node];
120 if (node_coord.x>cell_coord.x){
121 if (node_coord.y>cell_coord.y)
122 nodes_indirection[CNP_NextLeft] = i;
124 nodes_indirection[CNP_NextRight] = i;
127 if (node_coord.y>cell_coord.y)
128 nodes_indirection[CNP_PreviousLeft] = i;
130 nodes_indirection[CNP_PreviousRight] = i;
133 cellDirection(MD_DirX).setNodesIndirection(nodes_indirection);
136 nodes_indirection.fill(-1);
137 for( Int8 i=0; i<i8_nb_node; ++i ){
138 Node node = cell0.node(i);
139 Real3 node_coord = nodes_coord[node];
140 if (node_coord.y>cell_coord.y){
141 if (node_coord.x>cell_coord.x)
142 nodes_indirection[CNP_NextRight] = i;
144 nodes_indirection[CNP_NextLeft] = i;
147 if (node_coord.x>cell_coord.x)
148 nodes_indirection[CNP_PreviousRight] = i;
150 nodes_indirection[CNP_PreviousLeft] = i;
153 cellDirection(MD_DirY).setNodesIndirection(nodes_indirection);
162void CartesianMeshPatch::
163_computeNodeCellInformations3D(Cell cell0,Real3 cell0_coord,VariableNodeReal3& nodes_coord)
165 using Int8 = std::int8_t;
166 Int8 nodes_indirection_i[CellDirectionMng::MAX_NB_NODE];
167 ArrayView<Int8> nodes_indirection(CellDirectionMng::MAX_NB_NODE,nodes_indirection_i);
168 Integer nb_node = cell0.nbNode();
170 ARCANE_FATAL(
"Number of nodes should be '8' (v={0})",nb_node);
172 Real3 cell_coord = cell0_coord;
173 bool is_3d = m_mesh->mesh()->dimension()==3;
175 ARCANE_FATAL(
"Invalid call. This mesh is not a 3D mesh");
178 nodes_indirection.fill(-1);
179 for( Int8 i=0; i<i8_nb_node; ++i ){
180 Node node = cell0.node(i);
181 Real3 node_coord = nodes_coord[node];
182 if (node_coord.z>cell_coord.z){
183 if (node_coord.x>cell_coord.x){
184 if (node_coord.y>cell_coord.y)
185 nodes_indirection[CNP_TopNextLeft] = i;
187 nodes_indirection[CNP_TopNextRight] = i;
190 if (node_coord.y>cell_coord.y)
191 nodes_indirection[CNP_TopPreviousLeft] = i;
193 nodes_indirection[CNP_TopPreviousRight] = i;
197 if (node_coord.x>cell_coord.x){
198 if (node_coord.y>cell_coord.y)
199 nodes_indirection[CNP_NextLeft] = i;
201 nodes_indirection[CNP_NextRight] = i;
204 if (node_coord.y>cell_coord.y)
205 nodes_indirection[CNP_PreviousLeft] = i;
207 nodes_indirection[CNP_PreviousRight] = i;
211 cellDirection(MD_DirX).setNodesIndirection(nodes_indirection);
214 nodes_indirection.fill(-1);
215 for( Int8 i=0; i<i8_nb_node; ++i ){
216 Node node = cell0.node(i);
217 Real3 node_coord = nodes_coord[node];
218 if (node_coord.z>cell_coord.z){
219 if (node_coord.y>cell_coord.y){
220 if (node_coord.x>cell_coord.x)
221 nodes_indirection[CNP_TopNextRight] = i;
223 nodes_indirection[CNP_TopNextLeft] = i;
226 if (node_coord.x>cell_coord.x)
227 nodes_indirection[CNP_TopPreviousRight] = i;
229 nodes_indirection[CNP_TopPreviousLeft] = i;
233 if (node_coord.y>cell_coord.y){
234 if (node_coord.x>cell_coord.x)
235 nodes_indirection[CNP_NextRight] = i;
237 nodes_indirection[CNP_NextLeft] = i;
240 if (node_coord.x>cell_coord.x)
241 nodes_indirection[CNP_PreviousRight] = i;
243 nodes_indirection[CNP_PreviousLeft] = i;
247 cellDirection(MD_DirY).setNodesIndirection(nodes_indirection);
249 nodes_indirection.fill(-1);
250 for( Int8 i=0; i<i8_nb_node; ++i ){
251 Node node = cell0.node(i);
252 Real3 node_coord = nodes_coord[node];
253 if (node_coord.y>cell_coord.y){
254 if (node_coord.z>cell_coord.z){
255 if (node_coord.x>cell_coord.x)
256 nodes_indirection[CNP_TopNextRight] = i;
258 nodes_indirection[CNP_TopNextLeft] = i;
261 if (node_coord.x>cell_coord.x)
262 nodes_indirection[CNP_TopPreviousRight] = i;
264 nodes_indirection[CNP_TopPreviousLeft] = i;
268 if (node_coord.z>cell_coord.z){
269 if (node_coord.x>cell_coord.x)
270 nodes_indirection[CNP_NextRight] = i;
272 nodes_indirection[CNP_NextLeft] = i;
275 if (node_coord.x>cell_coord.x)
276 nodes_indirection[CNP_PreviousRight] = i;
278 nodes_indirection[CNP_PreviousLeft] = i;
282 cellDirection(MD_DirZ).setNodesIndirection(nodes_indirection);
288void CartesianMeshPatch::
289_internalComputeNodeCellInformations(Cell cell0,Real3 cell0_coord,VariableNodeReal3& nodes_coord)
291 int dim = m_mesh->mesh()->dimension();
293 _computeNodeCellInformations3D(cell0,cell0_coord,nodes_coord);
295 _computeNodeCellInformations2D(cell0,cell0_coord,nodes_coord);
297 ARCANE_THROW(NotImplementedException,
"this method is implemented only for 2D and 3D mesh (dim={0})",dim);
303void CartesianMeshPatch::
304_internalComputeNodeCellInformations()
306 int dim = m_mesh->mesh()->dimension();
307 Int8 nodes_indirection[CellDirectionMng::MAX_NB_NODE];
308 ArrayView av_nodes_indirection(CellDirectionMng::MAX_NB_NODE, nodes_indirection);
310 av_nodes_indirection.fill(-1);
311 av_nodes_indirection[CNP_NextLeft] = 2;
312 av_nodes_indirection[CNP_NextRight] = 1;
313 av_nodes_indirection[CNP_PreviousRight] = 0;
314 av_nodes_indirection[CNP_PreviousLeft] = 3;
316 av_nodes_indirection[CNP_TopNextLeft] = 6;
317 av_nodes_indirection[CNP_TopNextRight] = 5;
318 av_nodes_indirection[CNP_TopPreviousRight] = 4;
319 av_nodes_indirection[CNP_TopPreviousLeft] = 7;
321 cellDirection(MD_DirX).setNodesIndirection(av_nodes_indirection);
324 av_nodes_indirection.fill(-1);
325 av_nodes_indirection[CNP_NextLeft] = 3;
326 av_nodes_indirection[CNP_NextRight] = 2;
327 av_nodes_indirection[CNP_PreviousRight] = 1;
328 av_nodes_indirection[CNP_PreviousLeft] = 0;
330 av_nodes_indirection[CNP_TopNextLeft] = 7;
331 av_nodes_indirection[CNP_TopNextRight] = 6;
332 av_nodes_indirection[CNP_TopPreviousRight] = 5;
333 av_nodes_indirection[CNP_TopPreviousLeft] = 4;
335 cellDirection(MD_DirY).setNodesIndirection(av_nodes_indirection);
339 av_nodes_indirection.fill(-1);
340 av_nodes_indirection[CNP_NextLeft] = 4;
341 av_nodes_indirection[CNP_NextRight] = 5;
342 av_nodes_indirection[CNP_PreviousRight] = 1;
343 av_nodes_indirection[CNP_PreviousLeft] = 0;
344 av_nodes_indirection[CNP_TopNextLeft] = 7;
345 av_nodes_indirection[CNP_TopNextRight] = 6;
346 av_nodes_indirection[CNP_TopPreviousRight] = 2;
347 av_nodes_indirection[CNP_TopPreviousLeft] = 3;
348 cellDirection(MD_DirZ).setNodesIndirection(av_nodes_indirection);
355void CartesianMeshPatch::
360 Integer nb_dir = m_mesh->mesh()->dimension();
361 for( Integer i=0; i<nb_dir; ++i ){
362 CellDirectionMng dm = m_cell_directions[i];
363 FaceDirectionMng face_dm = m_face_directions[i];
364 std::set<Int32> cells_ids;
366 info(4) <<
"PATCH i=" << m_amr_patch_index <<
" nb_cell=" << dm_cells.
size();
368 cells_ids.insert(icell.itemLocalId());
370 Int64 nb_null_face_cell = 0;
373 DirCell cc(dm.cell(cell));
374 Cell next_cell = cc.next();
375 if (!next_cell.null()){
376 if (cells_ids.find(next_cell.localId())==cells_ids.end())
377 ARCANE_FATAL(
"Bad next cell dir={0} cell={1} next={2}",i,ItemPrinter(cell),ItemPrinter(next_cell));
379 Cell previous_cell = cc.previous();
380 if (!previous_cell.null()){
381 if (cells_ids.find(previous_cell.localId())==cells_ids.end())
382 ARCANE_FATAL(
"Bad previous cell dir={0} cell={1} previous={2}",i,ItemPrinter(cell),ItemPrinter(previous_cell));
386 DirCellFace cell_face(dm.cellFace(cell));
387 Face prev_face = cell_face.previous();
388 Face next_face = cell_face.next();
389 DirFace dir_face_prev(face_dm[prev_face]);
390 Cell face_cell_prev = dir_face_prev.previousCell();
391 if (face_cell_prev.null())
393 DirFace dir_face_next(face_dm[next_face]);
394 Cell face_cell_next = dir_face_next.nextCell();
395 if (face_cell_next.null())
398 info(4) <<
"PATCH i=" << m_amr_patch_index <<
" nb_null_face_cell=" << nb_null_face_cell;
#define ARCANE_THROW(exception_class,...)
Macro pour envoyer une exception avec formattage.
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Classe permettant de définir la position d'un patch dans le maillage cartésien.
Interface d'un maillage cartésien.
Integer size() const
Nombre d'éléments du groupe.
Classe d'accès aux traces.
ItemGroupT< Cell > CellGroup
Groupe de mailles.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
std::int8_t Int8
Type entier signé sur 8 bits.
Int32 Integer
Type représentant un entier.
eMeshDirection
Type de la direction pour un maillage structuré
@ Cell
Le maillage est AMR par maille.