14#include "arcane/cartesianmesh/FaceDirectionMng.h"
16#include "arcane/utils/FatalErrorException.h"
17#include "arcane/utils/Real3.h"
18#include "arcane/utils/PlatformUtils.h"
20#include "arcane/core/IItemFamily.h"
21#include "arcane/core/ItemGroup.h"
22#include "arcane/core/IMesh.h"
23#include "arcane/core/VariableTypes.h"
25#include "arcane/cartesianmesh/ICartesianMesh.h"
26#include "arcane/cartesianmesh/CellDirectionMng.h"
27#include "arcane/cartesianmesh/internal/ICartesianMeshInternal.h"
68void FaceDirectionMng::
75 m_p->m_cartesian_mesh = cm;
76 m_p->m_patch_index = patch_index;
82void FaceDirectionMng::
92void FaceDirectionMng::
93_internalResizeInfos(
Int32 new_size)
95 m_p->m_infos.
resize(new_size);
96 m_infos_view = m_p->m_infos.view();
102void FaceDirectionMng::
106 IMesh* mesh = m_p->m_cartesian_mesh->mesh();
107 IItemFamily* face_family = mesh->faceFamily();
108 IItemFamily* cell_family = mesh->cellFamily();
109 int dir = (int)m_direction;
110 String base_group_name = String(
"Direction")+dir;
111 if (m_p->m_patch_index>=0)
112 base_group_name = base_group_name + String(
"AMRPatch")+m_p->m_patch_index;
118 UniqueArray<Int32> faces_lid;
120 CellGroup all_cells = cell_dm.allCells();
121 faces_lid.reserve(all_cells.size());
123 std::set<Int32> done_faces;
125 DirCellFace dcf(cell_dm.cellFace(*icell));
126 Face next_face = dcf.next();
127 Face prev_face = dcf.previous();
130 Int32 prev_lid = prev_face.localId();
131 if (done_faces.find(prev_lid)==done_faces.end()){
132 faces_lid.add(prev_lid);
133 done_faces.insert(prev_lid);
135 Int32 next_lid = next_face.localId();
136 if (done_faces.find(next_lid)==done_faces.end()){
137 faces_lid.add(next_lid);
138 done_faces.insert(next_lid);
146 UniqueArray<Int32> inner_lids;
147 UniqueArray<Int32> outer_lids;
149 Int32 lid = iitem.itemLocalId();
152 if (
face.nbCell() == 1)
157 m_p->m_inner_all_items = face_family->createGroup(String(
"AllInner")+base_group_name,inner_lids,
true);
158 m_p->m_outer_all_items = face_family->createGroup(String(
"AllOuter")+base_group_name,outer_lids,
true);
159 m_p->m_all_items = all_faces;
160 m_cells = CellInfoListView(cell_family);
162 _computeCellInfos(cell_dm,cells_center,faces_center);
168void FaceDirectionMng::
171 IMesh* mesh = m_p->m_cartesian_mesh->mesh();
172 IItemFamily* face_family = mesh->faceFamily();
173 IItemFamily* cell_family = mesh->cellFamily();
174 int dir = (int)m_direction;
175 String base_group_name = String(
"Direction") + dir;
176 if (m_p->m_patch_index >= 0)
177 base_group_name = base_group_name + String(
"AMRPatch") + m_p->m_patch_index;
183 UniqueArray<Int32> faces_lid;
185 CellGroup all_cells = cell_dm.allCells();
186 faces_lid.reserve(all_cells.size());
188 std::set<Int32> done_faces;
190 DirCellFace dcf(cell_dm.cellFace(*icell));
191 Face next_face = dcf.next();
192 Face prev_face = dcf.previous();
195 Int32 prev_lid = prev_face.localId();
196 if (done_faces.find(prev_lid) == done_faces.end()) {
197 faces_lid.add(prev_lid);
198 done_faces.insert(prev_lid);
200 Int32 next_lid = next_face.localId();
201 if (done_faces.find(next_lid) == done_faces.end()) {
202 faces_lid.add(next_lid);
203 done_faces.insert(next_lid);
209 all_faces.
setItems(faces_lid,
true);
211 UniqueArray<Int32> inner_cells_lid;
212 UniqueArray<Int32> outer_cells_lid;
213 cell_dm.innerCells().view().fillLocalIds(inner_cells_lid);
214 cell_dm.outerCells().view().fillLocalIds(outer_cells_lid);
216 UniqueArray<Int32> inner_lids;
217 UniqueArray<Int32> outer_lids;
218 UniqueArray<Int32> inpatch_lids;
219 UniqueArray<Int32> overlap_lids;
221 Int32 lid = iface.itemLocalId();
223 if (
face.nbCell() == 1) {
224 if (inner_cells_lid.contains(
face.cell(0).localId())) {
226 inpatch_lids.add(lid);
228 else if (outer_cells_lid.contains(
face.cell(0).localId())) {
230 inpatch_lids.add(lid);
233 overlap_lids.add(lid);
237 bool c0_inner_cell = inner_cells_lid.contains(
face.cell(0).localId());
238 bool c1_inner_cell = inner_cells_lid.contains(
face.cell(1).localId());
239 if (c0_inner_cell || c1_inner_cell) {
241 inpatch_lids.add(lid);
244 bool c0_outer_cell = outer_cells_lid.contains(
face.cell(0).localId());
245 bool c1_outer_cell = outer_cells_lid.contains(
face.cell(1).localId());
246 if (c0_outer_cell || c1_outer_cell) {
248 inpatch_lids.add(lid);
251 overlap_lids.add(lid);
256 m_p->m_inner_all_items = face_family->createGroup(String(
"AllInner") + base_group_name, inner_lids,
true);
257 m_p->m_outer_all_items = face_family->createGroup(String(
"AllOuter") + base_group_name, outer_lids,
true);
258 m_p->m_inpatch_all_items = face_family->createGroup(String(
"AllInPatch") + base_group_name, inpatch_lids,
true);
259 m_p->m_overlap_all_items = face_family->createGroup(String(
"AllOverlap") + base_group_name, overlap_lids,
true);
260 m_p->m_all_items = all_faces;
261 m_cells = CellInfoListView(cell_family);
269bool FaceDirectionMng::
270_hasFace(
Cell cell,
Int32 face_local_id)
const
272 for( FaceLocalId iface_lid : cell.faceIds() ){
273 if (iface_lid==face_local_id)
287void FaceDirectionMng::
296 std::set<Int32> patch_cells_set;
298 patch_cells_set.insert(icell.itemLocalId());
303 Int32 face_lid = iface.itemLocalId();
304 Real3 face_coord = faces_center[iface];
309 if (!front_cell.null())
310 if (patch_cells_set.find(front_cell.localId()) == patch_cells_set.end())
312 if (!back_cell.null())
313 if (patch_cells_set.find(back_cell.localId()) == patch_cells_set.end())
316 bool is_inverse =
false;
317 if (!front_cell.null()){
318 Real3 front_coord = cells_center[front_cell];
320 if (front_coord.x<face_coord.x)
324 if (front_coord.y<face_coord.y)
328 if (front_coord.z<face_coord.z)
333 Real3 back_coord = cells_center[back_cell];
335 if (back_coord.x>face_coord.x)
339 if (back_coord.y>face_coord.y)
343 if (back_coord.z>face_coord.z)
350 if (!back_cell.null() && !front_cell.null()){
351 Int32 back_level = back_cell.level();
352 Int32 front_level = front_cell.level();
353 if (back_level!=front_level){
357 if (!_hasFace(back_cell,face_lid))
359 if (!_hasFace(front_cell,face_lid))
364 m_infos_view[face_lid] = ItemDirectionInfo(back_cell, front_cell);
366 m_infos_view[face_lid] = ItemDirectionInfo(front_cell, back_cell);
373void FaceDirectionMng::
374_computeCellInfos()
const
376 Ref<ICartesianMeshNumberingMngInternal> numbering = m_p->m_cartesian_mesh->_internalApi()->cartesianMeshNumberingMngInternal();
390 bool is_inverse =
false;
391 if (!front_cell.null() && !back_cell.null()) {
396 Int32 front_cell_level = front_cell.level();
397 Int32 back_cell_level = back_cell.level();
398 if (front_cell_level != back_cell_level) {
399 Int32 face_level = numbering->faceLevel(
face.uniqueId());
400 if (front_cell_level != face_level) {
408 if (back_cell.uniqueId() > front_cell.uniqueId()) {
414 if (back_cell.null()) {
416 ArrayView av_uids(numbering->nbFaceByCell(), uids);
417 numbering->cellFaceUniqueIds(front_cell, av_uids);
418 if (m_p->m_cartesian_mesh->mesh()->dimension() == 2) {
420 if (
face.uniqueId() == av_uids[1])
422 else if (
face.uniqueId() != av_uids[3])
423 ARCANE_FATAL(
"Bad connectivity -- Expected : {0} -- Found : {1}", av_uids[3],
face.uniqueId());
426 if (
face.uniqueId() == av_uids[2])
428 else if (
face.uniqueId() != av_uids[0])
429 ARCANE_FATAL(
"Bad connectivity -- Expected : {0} -- Found : {1}", av_uids[0],
face.uniqueId());
432 else if (m_p->m_cartesian_mesh->mesh()->dimension() == 3) {
434 if (
face.uniqueId() == av_uids[4])
436 else if (
face.uniqueId() != av_uids[1])
437 ARCANE_FATAL(
"Bad connectivity -- Expected : {0} -- Found : {1}", av_uids[1],
face.uniqueId());
440 if (
face.uniqueId() == av_uids[5])
442 else if (
face.uniqueId() != av_uids[2])
443 ARCANE_FATAL(
"Bad connectivity -- Expected : {0} -- Found : {1}", av_uids[2],
face.uniqueId());
446 if (
face.uniqueId() == av_uids[3])
448 else if (
face.uniqueId() != av_uids[0])
449 ARCANE_FATAL(
"Bad connectivity -- Expected : {0} -- Found : {1}", av_uids[0],
face.uniqueId());
453 else if (front_cell.null()) {
455 ArrayView av_uids(numbering->nbFaceByCell(), uids);
456 numbering->cellFaceUniqueIds(back_cell, av_uids);
457 if (m_p->m_cartesian_mesh->mesh()->dimension() == 2) {
459 if (
face.uniqueId() == av_uids[3])
461 else if (
face.uniqueId() != av_uids[1])
462 ARCANE_FATAL(
"Bad connectivity -- Expected : {0} -- Found : {1}", av_uids[1],
face.uniqueId());
465 if (
face.uniqueId() == av_uids[0])
467 else if (
face.uniqueId() != av_uids[2])
468 ARCANE_FATAL(
"Bad connectivity -- Expected : {0} -- Found : {1}", av_uids[2],
face.uniqueId());
471 else if (m_p->m_cartesian_mesh->mesh()->dimension() == 3) {
473 if (
face.uniqueId() == av_uids[1])
475 else if (
face.uniqueId() != av_uids[4])
476 ARCANE_FATAL(
"Bad connectivity -- Expected : {0} -- Found : {1}", av_uids[4],
face.uniqueId());
479 if (
face.uniqueId() == av_uids[2])
481 else if (
face.uniqueId() != av_uids[5])
482 ARCANE_FATAL(
"Bad connectivity -- Expected : {0} -- Found : {1}", av_uids[5],
face.uniqueId());
485 if (
face.uniqueId() == av_uids[0])
487 else if (
face.uniqueId() != av_uids[3])
488 ARCANE_FATAL(
"Bad connectivity -- Expected : {0} -- Found : {1}", av_uids[3],
face.uniqueId());
499 m_infos_view[iface.itemLocalId()] = ItemDirectionInfo(back_cell, front_cell);
501 m_infos_view[iface.itemLocalId()] = ItemDirectionInfo(front_cell, back_cell);
511 return m_p->m_all_items;
520 return m_p->m_overlap_all_items;
529 return m_p->m_inpatch_all_items;
538 return m_p->m_inner_all_items;
547 return m_p->m_outer_all_items;
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Infos sur les mailles d'une direction spécifique X,Y ou Z d'un maillage structuré.
FaceGroup inPatchFaces() const
Groupe de toutes les faces du patch dans la direction.
DirFace face(Face f) const
Face direction correspondant à la face f.
FaceGroup overlapFaces() const
Groupe de toutes les faces de recouvrement dans la direction.
FaceDirectionMng()
Créé une instance vide.
FaceGroup innerFaces() const
Groupe de toutes les faces internes dans la direction.
FaceGroup outerFaces() const
Groupe de toutes les faces externes dans la direction.
FaceGroup allFaces() const
Groupe de toutes les faces dans la direction.
Interface d'un maillage cartésien.
void setItems(Int32ConstArrayView items_local_id)
Positionne les entités du groupe.
Vecteur 1D de données avec sémantique par valeur (style STL).
void resize(Int64 s)
Change le nombre d'éléments du tableau à s.
ItemGroupT< Cell > CellGroup
Groupe de mailles.
ItemGroupT< Face > FaceGroup
Groupe de faces.
MeshVariableScalarRefT< Cell, Real3 > VariableCellReal3
Grandeur au centre des mailles de type coordonnées.
MeshVariableScalarRefT< Face, Real3 > VariableFaceReal3
Grandeur aux faces 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.
ConstArrayView< Int32 > Int32ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
eMeshDirection
Type de la direction pour un maillage structuré
@ MD_DirInvalid
Direction invalide ou non initialisée.
@ Cell
Le maillage est AMR par maille.
std::int32_t Int32
Type entier signé sur 32 bits.