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"
37, m_amr_patch_index(patch_index)
40 Integer nb_dir = cmesh->mesh()->dimension();
41 for( Integer i=0; i<nb_dir; ++i ){
43 m_cell_directions[i]._internalInit(cmesh,dir,patch_index);
44 m_face_directions[i]._internalInit(cmesh,dir,patch_index);
45 m_node_directions[i]._internalInit(cmesh,dir,patch_index);
55 for( Integer i=0; i<3; ++i ){
56 m_cell_directions[i]._internalDestroy();
57 m_face_directions[i]._internalDestroy();
58 m_node_directions[i]._internalDestroy();
72 return cellDirection(MD_DirX).allCells();
81void CartesianMeshPatch::
82_computeNodeCellInformations2D(Cell cell0,Real3 cell0_coord,VariableNodeReal3& nodes_coord)
84 using Int8 = std::int8_t;
85 Int8 nodes_indirection_i[CellDirectionMng::MAX_NB_NODE];
86 ArrayView<Int8> nodes_indirection(CellDirectionMng::MAX_NB_NODE,nodes_indirection_i);
87 Int32 nb_node = cell0.nbNode();
89 ARCANE_FATAL(
"Number of nodes should be '4' (v={0})",nb_node);
91 Real3 cell_coord = cell0_coord;
92 bool is_2d = m_mesh->mesh()->dimension()==2;
94 ARCANE_FATAL(
"Invalid call. This mesh is not a 2D mesh");
97 nodes_indirection.fill(-1);
98 for( Int8 i=0; i<i8_nb_node; ++i ){
99 Node node = cell0.node(i);
100 Real3 node_coord = nodes_coord[node];
101 if (node_coord.x>cell_coord.x){
102 if (node_coord.y>cell_coord.y)
103 nodes_indirection[CNP_NextLeft] = i;
105 nodes_indirection[CNP_NextRight] = i;
108 if (node_coord.y>cell_coord.y)
109 nodes_indirection[CNP_PreviousLeft] = i;
111 nodes_indirection[CNP_PreviousRight] = i;
114 cellDirection(MD_DirX).setNodesIndirection(nodes_indirection);
117 nodes_indirection.fill(-1);
118 for( Int8 i=0; i<i8_nb_node; ++i ){
119 Node node = cell0.node(i);
120 Real3 node_coord = nodes_coord[node];
121 if (node_coord.y>cell_coord.y){
122 if (node_coord.x>cell_coord.x)
123 nodes_indirection[CNP_NextRight] = i;
125 nodes_indirection[CNP_NextLeft] = i;
128 if (node_coord.x>cell_coord.x)
129 nodes_indirection[CNP_PreviousRight] = i;
131 nodes_indirection[CNP_PreviousLeft] = i;
134 cellDirection(MD_DirY).setNodesIndirection(nodes_indirection);
143void CartesianMeshPatch::
144_computeNodeCellInformations3D(Cell cell0,Real3 cell0_coord,VariableNodeReal3& nodes_coord)
146 using Int8 = std::int8_t;
147 Int8 nodes_indirection_i[CellDirectionMng::MAX_NB_NODE];
148 ArrayView<Int8> nodes_indirection(CellDirectionMng::MAX_NB_NODE,nodes_indirection_i);
149 Integer nb_node = cell0.nbNode();
151 ARCANE_FATAL(
"Number of nodes should be '8' (v={0})",nb_node);
153 Real3 cell_coord = cell0_coord;
154 bool is_3d = m_mesh->mesh()->dimension()==3;
156 ARCANE_FATAL(
"Invalid call. This mesh is not a 3D mesh");
159 nodes_indirection.fill(-1);
160 for( Int8 i=0; i<i8_nb_node; ++i ){
161 Node node = cell0.node(i);
162 Real3 node_coord = nodes_coord[node];
163 if (node_coord.z>cell_coord.z){
164 if (node_coord.x>cell_coord.x){
165 if (node_coord.y>cell_coord.y)
166 nodes_indirection[CNP_TopNextLeft] = i;
168 nodes_indirection[CNP_TopNextRight] = i;
171 if (node_coord.y>cell_coord.y)
172 nodes_indirection[CNP_TopPreviousLeft] = i;
174 nodes_indirection[CNP_TopPreviousRight] = i;
178 if (node_coord.x>cell_coord.x){
179 if (node_coord.y>cell_coord.y)
180 nodes_indirection[CNP_NextLeft] = i;
182 nodes_indirection[CNP_NextRight] = i;
185 if (node_coord.y>cell_coord.y)
186 nodes_indirection[CNP_PreviousLeft] = i;
188 nodes_indirection[CNP_PreviousRight] = i;
192 cellDirection(MD_DirX).setNodesIndirection(nodes_indirection);
195 nodes_indirection.fill(-1);
196 for( Int8 i=0; i<i8_nb_node; ++i ){
197 Node node = cell0.node(i);
198 Real3 node_coord = nodes_coord[node];
199 if (node_coord.z>cell_coord.z){
200 if (node_coord.y>cell_coord.y){
201 if (node_coord.x>cell_coord.x)
202 nodes_indirection[CNP_TopNextRight] = i;
204 nodes_indirection[CNP_TopNextLeft] = i;
207 if (node_coord.x>cell_coord.x)
208 nodes_indirection[CNP_TopPreviousRight] = i;
210 nodes_indirection[CNP_TopPreviousLeft] = i;
214 if (node_coord.y>cell_coord.y){
215 if (node_coord.x>cell_coord.x)
216 nodes_indirection[CNP_NextRight] = i;
218 nodes_indirection[CNP_NextLeft] = i;
221 if (node_coord.x>cell_coord.x)
222 nodes_indirection[CNP_PreviousRight] = i;
224 nodes_indirection[CNP_PreviousLeft] = i;
228 cellDirection(MD_DirY).setNodesIndirection(nodes_indirection);
230 nodes_indirection.fill(-1);
231 for( Int8 i=0; i<i8_nb_node; ++i ){
232 Node node = cell0.node(i);
233 Real3 node_coord = nodes_coord[node];
234 if (node_coord.y>cell_coord.y){
235 if (node_coord.z>cell_coord.z){
236 if (node_coord.x>cell_coord.x)
237 nodes_indirection[CNP_TopNextRight] = i;
239 nodes_indirection[CNP_TopNextLeft] = i;
242 if (node_coord.x>cell_coord.x)
243 nodes_indirection[CNP_TopPreviousRight] = i;
245 nodes_indirection[CNP_TopPreviousLeft] = i;
249 if (node_coord.z>cell_coord.z){
250 if (node_coord.x>cell_coord.x)
251 nodes_indirection[CNP_NextRight] = i;
253 nodes_indirection[CNP_NextLeft] = i;
256 if (node_coord.x>cell_coord.x)
257 nodes_indirection[CNP_PreviousRight] = i;
259 nodes_indirection[CNP_PreviousLeft] = i;
263 cellDirection(MD_DirZ).setNodesIndirection(nodes_indirection);
269void CartesianMeshPatch::
270_internalComputeNodeCellInformations(Cell cell0,Real3 cell0_coord,VariableNodeReal3& nodes_coord)
272 int dim = m_mesh->mesh()->dimension();
274 _computeNodeCellInformations3D(cell0,cell0_coord,nodes_coord);
276 _computeNodeCellInformations2D(cell0,cell0_coord,nodes_coord);
278 ARCANE_THROW(NotImplementedException,
"this method is implemented only for 2D and 3D mesh (dim={0})",dim);
284void CartesianMeshPatch::
289 Integer nb_dir = m_mesh->mesh()->dimension();
290 for( Integer i=0; i<nb_dir; ++i ){
291 CellDirectionMng dm = m_cell_directions[i];
292 FaceDirectionMng face_dm = m_face_directions[i];
293 std::set<Int32> cells_ids;
295 info(4) <<
"PATCH i=" << m_amr_patch_index <<
" nb_cell=" << dm_cells.
size();
297 cells_ids.insert(icell.itemLocalId());
299 Int64 nb_null_face_cell = 0;
302 DirCell cc(dm.cell(cell));
303 Cell next_cell = cc.next();
304 if (!next_cell.null()){
305 if (cells_ids.find(next_cell.localId())==cells_ids.end())
306 ARCANE_FATAL(
"Bad next cell dir={0} cell={1} next={2}",i,ItemPrinter(cell),ItemPrinter(next_cell));
308 Cell previous_cell = cc.previous();
309 if (!previous_cell.null()){
310 if (cells_ids.find(previous_cell.localId())==cells_ids.end())
311 ARCANE_FATAL(
"Bad previous cell dir={0} cell={1} previous={2}",i,ItemPrinter(cell),ItemPrinter(previous_cell));
315 DirCellFace cell_face(dm.cellFace(cell));
316 Face prev_face = cell_face.previous();
317 Face next_face = cell_face.next();
318 DirFace dir_face_prev(face_dm[prev_face]);
319 Cell face_cell_prev = dir_face_prev.previousCell();
320 if (face_cell_prev.null())
322 DirFace dir_face_next(face_dm[next_face]);
323 Cell face_cell_next = dir_face_next.nextCell();
324 if (face_cell_next.null())
327 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.
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é