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"
66void FaceDirectionMng::
73 m_p->m_cartesian_mesh = cm;
74 m_p->m_patch_index = patch_index;
80void FaceDirectionMng::
90void FaceDirectionMng::
91_internalResizeInfos(
Int32 new_size)
93 m_p->m_infos.
resize(new_size);
94 m_infos_view = m_p->m_infos.view();
100void FaceDirectionMng::
104 IMesh* mesh = m_p->m_cartesian_mesh->mesh();
105 IItemFamily* face_family = mesh->faceFamily();
106 IItemFamily* cell_family = mesh->cellFamily();
107 int dir = (int)m_direction;
108 String base_group_name = String(
"Direction")+dir;
109 if (m_p->m_patch_index>=0)
110 base_group_name = base_group_name + String(
"AMRPatch")+m_p->m_patch_index;
116 UniqueArray<Int32> faces_lid;
118 CellGroup all_cells = cell_dm.allCells();
119 faces_lid.reserve(all_cells.size());
121 UniqueArray<bool> done_faces(face_family->maxLocalId(),
false);
123 DirCellFace dcf(cell_dm.cellFace(*icell));
124 Face next_face = dcf.next();
125 Face prev_face = dcf.previous();
128 Int32 prev_lid = prev_face.localId();
129 if (!done_faces[prev_lid]) {
130 faces_lid.add(prev_lid);
131 done_faces[prev_lid] =
true;
133 Int32 next_lid = next_face.localId();
134 if (!done_faces[next_lid]) {
135 faces_lid.add(next_lid);
136 done_faces[next_lid] =
true;
144 UniqueArray<Int32> inner_lids;
145 UniqueArray<Int32> outer_lids;
147 Int32 lid = iitem.itemLocalId();
150 if (
face.nbCell() == 1)
155 m_p->m_inner_all_items = face_family->createGroup(String(
"AllInner")+base_group_name,inner_lids,
true);
156 m_p->m_outer_all_items = face_family->createGroup(String(
"AllOuter")+base_group_name,outer_lids,
true);
157 m_p->m_all_items = all_faces;
158 m_cells = CellInfoListView(cell_family);
160 _computeCellInfos(cell_dm,cells_center,faces_center);
166void FaceDirectionMng::
169 IMesh* mesh = m_p->m_cartesian_mesh->mesh();
170 IItemFamily* face_family = mesh->faceFamily();
171 IItemFamily* cell_family = mesh->cellFamily();
172 int dir = (int)m_direction;
173 String base_group_name = String(
"Direction") + dir;
174 if (m_p->m_patch_index >= 0)
175 base_group_name = base_group_name + String(
"AMRPatch") + m_p->m_patch_index;
181 UniqueArray<Int32> faces_lid;
183 CellGroup all_cells = cell_dm.allCells();
184 faces_lid.reserve(all_cells.size());
186 UniqueArray<bool> done_faces(face_family->maxLocalId(),
false);
188 DirCellFace dcf(cell_dm.cellFace(*icell));
189 Face next_face = dcf.next();
190 Face prev_face = dcf.previous();
193 Int32 prev_lid = prev_face.localId();
194 if (!done_faces[prev_lid]) {
195 faces_lid.add(prev_lid);
196 done_faces[prev_lid] =
true;
198 Int32 next_lid = next_face.localId();
199 if (!done_faces[next_lid]) {
200 faces_lid.add(next_lid);
201 done_faces[next_lid] =
true;
207 all_faces.
setItems(faces_lid,
true);
209 UniqueArray<Int32> inner_cells_lid;
210 UniqueArray<Int32> outer_cells_lid;
211 cell_dm.innerCells().view().fillLocalIds(inner_cells_lid);
212 cell_dm.outerCells().view().fillLocalIds(outer_cells_lid);
214 UniqueArray<Int32> inner_lids;
215 UniqueArray<Int32> outer_lids;
216 UniqueArray<Int32> inpatch_lids;
217 UniqueArray<Int32> overlap_lids;
219 Int32 lid = iface.itemLocalId();
221 if (
face.nbCell() == 1) {
222 if (inner_cells_lid.contains(
face.cell(0).localId())) {
224 inpatch_lids.add(lid);
226 else if (outer_cells_lid.contains(
face.cell(0).localId())) {
228 inpatch_lids.add(lid);
231 overlap_lids.add(lid);
235 bool c0_inner_cell = inner_cells_lid.contains(
face.cell(0).localId());
236 bool c1_inner_cell = inner_cells_lid.contains(
face.cell(1).localId());
237 if (c0_inner_cell || c1_inner_cell) {
239 inpatch_lids.add(lid);
242 bool c0_outer_cell = outer_cells_lid.contains(
face.cell(0).localId());
243 bool c1_outer_cell = outer_cells_lid.contains(
face.cell(1).localId());
244 if (c0_outer_cell || c1_outer_cell) {
246 inpatch_lids.add(lid);
249 overlap_lids.add(lid);
254 m_p->m_inner_all_items = face_family->createGroup(String(
"AllInner") + base_group_name, inner_lids,
true);
255 m_p->m_outer_all_items = face_family->createGroup(String(
"AllOuter") + base_group_name, outer_lids,
true);
256 m_p->m_inpatch_all_items = face_family->createGroup(String(
"AllInPatch") + base_group_name, inpatch_lids,
true);
257 m_p->m_overlap_all_items = face_family->createGroup(String(
"AllOverlap") + base_group_name, overlap_lids,
true);
258 m_p->m_all_items = all_faces;
259 m_cells = CellInfoListView(cell_family);
267bool FaceDirectionMng::
268_hasFace(
Cell cell,
Int32 face_local_id)
const
270 for( FaceLocalId iface_lid : cell.faceIds() ){
271 if (iface_lid==face_local_id)
285void FaceDirectionMng::
294 UniqueArray<bool> is_patch_cell(cell_dm.allCells().itemFamily()->maxLocalId(),
false);
296 is_patch_cell[icell.itemLocalId()] =
true;
301 Int32 face_lid = iface.itemLocalId();
302 Real3 face_coord = faces_center[iface];
307 if (!front_cell.null())
308 if (!is_patch_cell[front_cell.localId()])
310 if (!back_cell.null())
311 if (!is_patch_cell[back_cell.localId()])
314 bool is_inverse =
false;
315 if (!front_cell.null()){
316 Real3 front_coord = cells_center[front_cell];
318 if (front_coord.x<face_coord.x)
322 if (front_coord.y<face_coord.y)
326 if (front_coord.z<face_coord.z)
331 Real3 back_coord = cells_center[back_cell];
333 if (back_coord.x>face_coord.x)
337 if (back_coord.y>face_coord.y)
341 if (back_coord.z>face_coord.z)
348 if (!back_cell.null() && !front_cell.null()){
349 Int32 back_level = back_cell.level();
350 Int32 front_level = front_cell.level();
351 if (back_level!=front_level){
355 if (!_hasFace(back_cell,face_lid))
357 if (!_hasFace(front_cell,face_lid))
362 m_infos_view[face_lid] = ItemDirectionInfo(back_cell, front_cell);
364 m_infos_view[face_lid] = ItemDirectionInfo(front_cell, back_cell);
371void FaceDirectionMng::
372_computeCellInfos()
const
374 Ref<ICartesianMeshNumberingMngInternal> numbering = m_p->m_cartesian_mesh->_internalApi()->cartesianMeshNumberingMngInternal();
388 bool is_inverse =
false;
389 if (!front_cell.null() && !back_cell.null()) {
394 Int32 front_cell_level = front_cell.level();
395 Int32 back_cell_level = back_cell.level();
396 if (front_cell_level != back_cell_level) {
397 Int32 face_level = numbering->faceLevel(
face.uniqueId());
398 if (front_cell_level != face_level) {
406 if (back_cell.uniqueId() > front_cell.uniqueId()) {
412 if (back_cell.null()) {
414 ArrayView av_uids(numbering->nbFaceByCell(), uids);
415 numbering->cellFaceUniqueIds(front_cell, av_uids);
416 if (m_p->m_cartesian_mesh->mesh()->dimension() == 2) {
418 if (
face.uniqueId() == av_uids[1])
420 else if (
face.uniqueId() != av_uids[3])
421 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[3],
face.uniqueId());
424 if (
face.uniqueId() == av_uids[2])
426 else if (
face.uniqueId() != av_uids[0])
427 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[0],
face.uniqueId());
430 else if (m_p->m_cartesian_mesh->mesh()->dimension() == 3) {
432 if (
face.uniqueId() == av_uids[4])
434 else if (
face.uniqueId() != av_uids[1])
435 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[1],
face.uniqueId());
438 if (
face.uniqueId() == av_uids[5])
440 else if (
face.uniqueId() != av_uids[2])
441 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[2],
face.uniqueId());
444 if (
face.uniqueId() == av_uids[3])
446 else if (
face.uniqueId() != av_uids[0])
447 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[0],
face.uniqueId());
451 else if (front_cell.null()) {
453 ArrayView av_uids(numbering->nbFaceByCell(), uids);
454 numbering->cellFaceUniqueIds(back_cell, av_uids);
455 if (m_p->m_cartesian_mesh->mesh()->dimension() == 2) {
457 if (
face.uniqueId() == av_uids[3])
459 else if (
face.uniqueId() != av_uids[1])
460 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[1],
face.uniqueId());
463 if (
face.uniqueId() == av_uids[0])
465 else if (
face.uniqueId() != av_uids[2])
466 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[2],
face.uniqueId());
469 else if (m_p->m_cartesian_mesh->mesh()->dimension() == 3) {
471 if (
face.uniqueId() == av_uids[1])
473 else if (
face.uniqueId() != av_uids[4])
474 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[4],
face.uniqueId());
477 if (
face.uniqueId() == av_uids[2])
479 else if (
face.uniqueId() != av_uids[5])
480 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[5],
face.uniqueId());
483 if (
face.uniqueId() == av_uids[0])
485 else if (
face.uniqueId() != av_uids[3])
486 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[3],
face.uniqueId());
497 m_infos_view[iface.itemLocalId()] = ItemDirectionInfo(back_cell, front_cell);
499 m_infos_view[iface.itemLocalId()] = ItemDirectionInfo(front_cell, back_cell);
509 return m_p->m_all_items;
518 return m_p->m_overlap_all_items;
527 return m_p->m_inpatch_all_items;
536 return m_p->m_inner_all_items;
545 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.