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"
34CartesianMeshPatch(ICartesianMesh* cmesh,Integer patch_index)
35: TraceAccessor(cmesh->traceMng())
37, m_amr_patch_index(patch_index)
39 Integer nb_dir = cmesh->mesh()->dimension();
40 for( Integer i=0; i<nb_dir; ++i ){
42 m_cell_directions[i]._internalInit(cmesh,dir,patch_index);
43 m_face_directions[i]._internalInit(cmesh,dir,patch_index);
44 m_node_directions[i]._internalInit(cmesh,dir,patch_index);
54 for( Integer i=0; i<3; ++i ){
55 m_cell_directions[i]._internalDestroy();
56 m_face_directions[i]._internalDestroy();
57 m_node_directions[i]._internalDestroy();
71 return cellDirection(MD_DirX).allCells();
80void CartesianMeshPatch::
81_computeNodeCellInformations2D(Cell cell0,Real3 cell0_coord,VariableNodeReal3& nodes_coord)
83 using Int8 = std::int8_t;
84 Int8 nodes_indirection_i[CellDirectionMng::MAX_NB_NODE];
85 ArrayView<Int8> nodes_indirection(CellDirectionMng::MAX_NB_NODE,nodes_indirection_i);
86 Int32 nb_node = cell0.nbNode();
88 ARCANE_FATAL(
"Number of nodes should be '4' (v={0})",nb_node);
90 Real3 cell_coord = cell0_coord;
91 bool is_2d = m_mesh->mesh()->dimension()==2;
93 ARCANE_FATAL(
"Invalid call. This mesh is not a 2D mesh");
96 nodes_indirection.fill(-1);
97 for( Int8 i=0; i<i8_nb_node; ++i ){
98 Node node = cell0.node(i);
99 Real3 node_coord = nodes_coord[node];
100 if (node_coord.x>cell_coord.x){
101 if (node_coord.y>cell_coord.y)
102 nodes_indirection[CNP_NextLeft] = i;
104 nodes_indirection[CNP_NextRight] = i;
107 if (node_coord.y>cell_coord.y)
108 nodes_indirection[CNP_PreviousLeft] = i;
110 nodes_indirection[CNP_PreviousRight] = i;
113 cellDirection(MD_DirX).setNodesIndirection(nodes_indirection);
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.y>cell_coord.y){
121 if (node_coord.x>cell_coord.x)
122 nodes_indirection[CNP_NextRight] = i;
124 nodes_indirection[CNP_NextLeft] = i;
127 if (node_coord.x>cell_coord.x)
128 nodes_indirection[CNP_PreviousRight] = i;
130 nodes_indirection[CNP_PreviousLeft] = i;
133 cellDirection(MD_DirY).setNodesIndirection(nodes_indirection);
142void CartesianMeshPatch::
143_computeNodeCellInformations3D(Cell cell0,Real3 cell0_coord,VariableNodeReal3& nodes_coord)
145 using Int8 = std::int8_t;
146 Int8 nodes_indirection_i[CellDirectionMng::MAX_NB_NODE];
147 ArrayView<Int8> nodes_indirection(CellDirectionMng::MAX_NB_NODE,nodes_indirection_i);
148 Integer nb_node = cell0.nbNode();
150 ARCANE_FATAL(
"Number of nodes should be '8' (v={0})",nb_node);
152 Real3 cell_coord = cell0_coord;
153 bool is_3d = m_mesh->mesh()->dimension()==3;
155 ARCANE_FATAL(
"Invalid call. This mesh is not a 3D mesh");
158 nodes_indirection.fill(-1);
159 for( Int8 i=0; i<i8_nb_node; ++i ){
160 Node node = cell0.node(i);
161 Real3 node_coord = nodes_coord[node];
162 if (node_coord.z>cell_coord.z){
163 if (node_coord.x>cell_coord.x){
164 if (node_coord.y>cell_coord.y)
165 nodes_indirection[CNP_TopNextLeft] = i;
167 nodes_indirection[CNP_TopNextRight] = i;
170 if (node_coord.y>cell_coord.y)
171 nodes_indirection[CNP_TopPreviousLeft] = i;
173 nodes_indirection[CNP_TopPreviousRight] = i;
177 if (node_coord.x>cell_coord.x){
178 if (node_coord.y>cell_coord.y)
179 nodes_indirection[CNP_NextLeft] = i;
181 nodes_indirection[CNP_NextRight] = i;
184 if (node_coord.y>cell_coord.y)
185 nodes_indirection[CNP_PreviousLeft] = i;
187 nodes_indirection[CNP_PreviousRight] = i;
191 cellDirection(MD_DirX).setNodesIndirection(nodes_indirection);
194 nodes_indirection.fill(-1);
195 for( Int8 i=0; i<i8_nb_node; ++i ){
196 Node node = cell0.node(i);
197 Real3 node_coord = nodes_coord[node];
198 if (node_coord.z>cell_coord.z){
199 if (node_coord.y>cell_coord.y){
200 if (node_coord.x>cell_coord.x)
201 nodes_indirection[CNP_TopNextRight] = i;
203 nodes_indirection[CNP_TopNextLeft] = i;
206 if (node_coord.x>cell_coord.x)
207 nodes_indirection[CNP_TopPreviousRight] = i;
209 nodes_indirection[CNP_TopPreviousLeft] = i;
213 if (node_coord.y>cell_coord.y){
214 if (node_coord.x>cell_coord.x)
215 nodes_indirection[CNP_NextRight] = i;
217 nodes_indirection[CNP_NextLeft] = i;
220 if (node_coord.x>cell_coord.x)
221 nodes_indirection[CNP_PreviousRight] = i;
223 nodes_indirection[CNP_PreviousLeft] = i;
227 cellDirection(MD_DirY).setNodesIndirection(nodes_indirection);
229 nodes_indirection.fill(-1);
230 for( Int8 i=0; i<i8_nb_node; ++i ){
231 Node node = cell0.node(i);
232 Real3 node_coord = nodes_coord[node];
233 if (node_coord.y>cell_coord.y){
234 if (node_coord.z>cell_coord.z){
235 if (node_coord.x>cell_coord.x)
236 nodes_indirection[CNP_TopNextRight] = i;
238 nodes_indirection[CNP_TopNextLeft] = i;
241 if (node_coord.x>cell_coord.x)
242 nodes_indirection[CNP_TopPreviousRight] = i;
244 nodes_indirection[CNP_TopPreviousLeft] = i;
248 if (node_coord.z>cell_coord.z){
249 if (node_coord.x>cell_coord.x)
250 nodes_indirection[CNP_NextRight] = i;
252 nodes_indirection[CNP_NextLeft] = i;
255 if (node_coord.x>cell_coord.x)
256 nodes_indirection[CNP_PreviousRight] = i;
258 nodes_indirection[CNP_PreviousLeft] = i;
262 cellDirection(MD_DirZ).setNodesIndirection(nodes_indirection);
268void CartesianMeshPatch::
269_internalComputeNodeCellInformations(Cell cell0,Real3 cell0_coord,VariableNodeReal3& nodes_coord)
271 int dim = m_mesh->mesh()->dimension();
273 _computeNodeCellInformations3D(cell0,cell0_coord,nodes_coord);
275 _computeNodeCellInformations2D(cell0,cell0_coord,nodes_coord);
277 ARCANE_THROW(NotImplementedException,
"this method is implemented only for 2D and 3D mesh (dim={0})",dim);
283void CartesianMeshPatch::
288 Integer nb_dir = m_mesh->mesh()->dimension();
289 for( Integer i=0; i<nb_dir; ++i ){
290 CellDirectionMng dm = m_cell_directions[i];
291 FaceDirectionMng face_dm = m_face_directions[i];
292 std::set<Int32> cells_ids;
294 info(4) <<
"PATCH i=" << m_amr_patch_index <<
" nb_cell=" << dm_cells.
size();
296 cells_ids.insert(icell.itemLocalId());
298 Int64 nb_null_face_cell = 0;
301 DirCell cc(dm.cell(cell));
302 Cell next_cell = cc.next();
303 if (!next_cell.null()){
304 if (cells_ids.find(next_cell.localId())==cells_ids.end())
305 ARCANE_FATAL(
"Bad next cell dir={0} cell={1} next={2}",i,ItemPrinter(cell),ItemPrinter(next_cell));
307 Cell previous_cell = cc.previous();
308 if (!previous_cell.null()){
309 if (cells_ids.find(previous_cell.localId())==cells_ids.end())
310 ARCANE_FATAL(
"Bad previous cell dir={0} cell={1} previous={2}",i,ItemPrinter(cell),ItemPrinter(previous_cell));
314 DirCellFace cell_face(dm.cellFace(cell));
315 Face prev_face = cell_face.previous();
316 Face next_face = cell_face.next();
317 DirFace dir_face_prev(face_dm[prev_face]);
318 Cell face_cell_prev = dir_face_prev.previousCell();
319 if (face_cell_prev.null())
321 DirFace dir_face_next(face_dm[next_face]);
322 Cell face_cell_next = dir_face_next.nextCell();
323 if (face_cell_next.null())
326 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.
Integer size() const
Nombre d'éléments du groupe.
ItemGroupT< Cell > CellGroup
Groupe de mailles.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Arccore::Int8 Int8
Type représentant un entier sur 8 bits.
eMeshDirection
Type de la direction pour un maillage structuré
Int32 Integer
Type représentant un entier.