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"
80 m_p->m_cartesian_mesh = cm;
81 m_p->m_patch_index = patch_index;
100 m_p->m_infos.resize(new_size);
101 m_infos_view = m_p->m_infos.view();
111 IMesh*
mesh = m_p->m_cartesian_mesh->mesh();
114 int dir = (int)m_direction;
116 if (m_p->m_patch_index >= 0)
117 base_group_name = base_group_name +
String(
"AMRPatch") + m_p->m_patch_index;
128 std::set<Int32> done_faces;
136 if (done_faces.find(prev_lid) == done_faces.end()) {
137 faces_lid.
add(prev_lid);
138 done_faces.insert(prev_lid);
141 if (done_faces.find(next_lid) == done_faces.end()) {
142 faces_lid.
add(next_lid);
143 done_faces.insert(next_lid);
149 all_faces.
setItems(faces_lid,
true);
154 Int32 lid = iitem.itemLocalId();
157 if (
face.nbCell() == 1)
162 m_p->m_inner_all_items = face_family->
createGroup(
String(
"AllInner") + base_group_name, inner_lids,
true);
163 m_p->m_outer_all_items = face_family->
createGroup(
String(
"AllOuter") + base_group_name, outer_lids,
true);
164 m_p->m_all_items = all_faces;
176 IMesh*
mesh = m_p->m_cartesian_mesh->mesh();
179 int dir = (int)m_direction;
181 if (m_p->m_patch_index >= 0)
182 base_group_name = base_group_name +
String(
"AMRPatch") + m_p->m_patch_index;
193 std::set<Int32> done_faces;
201 if (done_faces.find(prev_lid) == done_faces.end()) {
202 faces_lid.
add(prev_lid);
203 done_faces.insert(prev_lid);
206 if (done_faces.find(next_lid) == done_faces.end()) {
207 faces_lid.
add(next_lid);
208 done_faces.insert(next_lid);
214 all_faces.
setItems(faces_lid,
true);
226 Int32 lid = iface.itemLocalId();
228 if (
face.nbCell() == 1) {
231 inpatch_lids.
add(lid);
233 else if (outer_cells_lid.
contains(
face.cell(0).localId())) {
235 inpatch_lids.
add(lid);
238 overlap_lids.
add(lid);
242 bool c0_inner_cell = inner_cells_lid.
contains(
face.cell(0).localId());
243 bool c1_inner_cell = inner_cells_lid.
contains(
face.cell(1).localId());
244 if (c0_inner_cell || c1_inner_cell) {
246 inpatch_lids.
add(lid);
249 bool c0_outer_cell = outer_cells_lid.
contains(
face.cell(0).localId());
250 bool c1_outer_cell = outer_cells_lid.
contains(
face.cell(1).localId());
251 if (c0_outer_cell || c1_outer_cell) {
253 inpatch_lids.
add(lid);
256 overlap_lids.
add(lid);
261 m_p->m_inner_all_items = face_family->
createGroup(
String(
"AllInner") + base_group_name, inner_lids,
true);
262 m_p->m_outer_all_items = face_family->
createGroup(
String(
"AllOuter") + base_group_name, outer_lids,
true);
263 m_p->m_inpatch_all_items = face_family->
createGroup(
String(
"AllInPatch") + base_group_name, inpatch_lids,
true);
264 m_p->m_overlap_all_items = face_family->
createGroup(
String(
"AllOverlap") + base_group_name, overlap_lids,
true);
265 m_p->m_all_items = all_faces;
274bool FaceDirectionMng::
275_hasFace(
Cell cell,
Int32 face_local_id)
const
277 for (FaceLocalId iface_lid : cell.
faceIds()) {
278 if (iface_lid == face_local_id)
301 std::set<Int32> patch_cells_set;
303 patch_cells_set.insert(icell.itemLocalId());
308 Int32 face_lid = iface.itemLocalId();
309 Real3 face_coord = faces_center[iface];
314 if (!front_cell.
null())
315 if (patch_cells_set.find(front_cell.
localId()) == patch_cells_set.end())
317 if (!back_cell.
null())
318 if (patch_cells_set.find(back_cell.
localId()) == patch_cells_set.end())
321 bool is_inverse =
false;
322 if (!front_cell.
null()) {
323 Real3 front_coord = cells_center[front_cell];
325 if (front_coord.
x < face_coord.
x)
329 if (front_coord.
y < face_coord.
y)
333 if (front_coord.
z < face_coord.
z)
338 Real3 back_coord = cells_center[back_cell];
340 if (back_coord.
x > face_coord.
x)
344 if (back_coord.
y > face_coord.
y)
348 if (back_coord.
z > face_coord.
z)
355 if (!back_cell.
null() && !front_cell.
null()) {
358 if (back_level != front_level) {
362 if (!_hasFace(back_cell, face_lid))
364 if (!_hasFace(front_cell, face_lid))
369 m_infos_view[face_lid] = ItemDirectionInfo(back_cell, front_cell);
371 m_infos_view[face_lid] = ItemDirectionInfo(front_cell, back_cell);
395 bool is_inverse =
false;
396 if (!front_cell.
null() && !back_cell.
null()) {
403 if (front_cell_level != back_cell_level) {
404 Int32 face_level = numbering->faceLevel(
face.uniqueId());
405 if (front_cell_level != face_level) {
419 if (back_cell.
null()) {
421 ArrayView av_uids(numbering->nbFaceByCell(), uids);
422 numbering->cellFaceUniqueIds(front_cell, av_uids);
423 if (m_p->m_cartesian_mesh->mesh()->dimension() == 2) {
425 if (
face.uniqueId() == av_uids[1])
427 else if (
face.uniqueId() != av_uids[3])
428 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[3],
face.uniqueId());
431 if (
face.uniqueId() == av_uids[2])
433 else if (
face.uniqueId() != av_uids[0])
434 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[0],
face.uniqueId());
437 else if (m_p->m_cartesian_mesh->mesh()->dimension() == 3) {
439 if (
face.uniqueId() == av_uids[4])
441 else if (
face.uniqueId() != av_uids[1])
442 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[1],
face.uniqueId());
445 if (
face.uniqueId() == av_uids[5])
447 else if (
face.uniqueId() != av_uids[2])
448 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[2],
face.uniqueId());
451 if (
face.uniqueId() == av_uids[3])
453 else if (
face.uniqueId() != av_uids[0])
454 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[0],
face.uniqueId());
458 else if (front_cell.
null()) {
460 ArrayView av_uids(numbering->nbFaceByCell(), uids);
461 numbering->cellFaceUniqueIds(back_cell, av_uids);
462 if (m_p->m_cartesian_mesh->mesh()->dimension() == 2) {
464 if (
face.uniqueId() == av_uids[3])
466 else if (
face.uniqueId() != av_uids[1])
467 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[1],
face.uniqueId());
470 if (
face.uniqueId() == av_uids[0])
472 else if (
face.uniqueId() != av_uids[2])
473 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[2],
face.uniqueId());
476 else if (m_p->m_cartesian_mesh->mesh()->dimension() == 3) {
478 if (
face.uniqueId() == av_uids[1])
480 else if (
face.uniqueId() != av_uids[4])
481 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[4],
face.uniqueId());
484 if (
face.uniqueId() == av_uids[2])
486 else if (
face.uniqueId() != av_uids[5])
487 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[5],
face.uniqueId());
490 if (
face.uniqueId() == av_uids[0])
492 else if (
face.uniqueId() != av_uids[3])
493 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[3],
face.uniqueId());
504 m_infos_view[iface.itemLocalId()] = ItemDirectionInfo(back_cell, front_cell);
506 m_infos_view[iface.itemLocalId()] = ItemDirectionInfo(front_cell, back_cell);
516 return m_p->m_all_items;
525 return m_p->m_overlap_all_items;
534 return m_p->m_inpatch_all_items;
543 return m_p->m_inner_all_items;
552 return m_p->m_outer_all_items;
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
bool contains(ConstReferenceType v) const
True if the array contains the value element v.
void add(ConstReferenceType val)
Adds element val to the end of the array.
void reserve(Int64 new_capacity)
Reserves memory for new_capacity elements.
Info about the cells in a specific X, Y, or Z direction of a structured mesh.
CellGroup outerCells() const
Group of all outer cells in the direction.
CellGroup allCells() const
Group of all cells in the direction.
DirCellFace cellFace(Cell c) const
cell with directional info at faces corresponding to cell c.
CellGroup innerCells() const
Group of all inner cells in the direction.
View of cell information.
FaceLocalIdView faceIds() const
List of faces of the cell.
Cell with directional face information.
Face next() const
Face connected to the cell after the current cell in the direction.
Face previous() const
Face connected to the cell before the current cell in the direction.
FaceGroup inPatchFaces() const
Group of all faces within the patch in the direction.
DirFace face(Face f) const
Direction face corresponding to face f.
void _computeCellInfos(const CellDirectionMng &cell_dm, const VariableCellReal3 &cells_center, const VariableFaceReal3 &faces_center)
Calculates the cells before and after a face, in a given direction.
void _internalComputeInfos(const CellDirectionMng &cell_dm, const VariableCellReal3 &cells_center, const VariableFaceReal3 &faces_center)
Calculates the information on faces associated with the cells in the direction cell_dm....
FaceGroup overlapFaces() const
Group of all overlap faces in the direction.
FaceDirectionMng()
Creates an empty instance.
FaceGroup innerFaces() const
Group of all internal faces in the direction.
void _internalInit(ICartesianMesh *cm, eMeshDirection dir, Integer patch_index)
FaceGroup outerFaces() const
Group of all external faces in the direction.
void _internalResizeInfos(Int32 new_size)
Resizes the container holding the ItemDirectionInfo.
FaceGroup allFaces() const
Group of all faces in the direction.
virtual Ref< ICartesianMeshNumberingMngInternal > cartesianMeshNumberingMngInternal()=0
Method allowing retrieval of the CartesianMeshNumberingMngInternal instance.
Interface of a Cartesian mesh.
virtual ICartesianMeshInternal * _internalApi()=0
Internal Arcane API.
Interface of an entity family.
virtual ItemGroup createGroup(const String &name, Int32ConstArrayView local_ids, bool do_override=false)=0
Creates an entity group named name containing the entities local_ids.
ItemVectorView view() const
View of the group entities.
Integer size() const
Number of elements in the group.
void setItems(Int32ConstArrayView items_local_id)
Sets the entities of the group.
void fillLocalIds(Array< Int32 > &ids) const
Adds the list of localIds() of the vector to ids.
constexpr Int32 localId() const
Local identifier of the entity in the processor subdomain.
ItemUniqueId uniqueId() const
Unique identifier across all domains.
constexpr bool null() const
true if the entity is null (i.e. not connected to the mesh)
Class managing a 3-dimensional real vector.
Reference to an instance.
Unicode character string.
1D data vector with value semantics (STL style).
ItemGroupT< Cell > CellGroup
Group of cells.
ItemGroupT< Face > FaceGroup
Group of faces.
MeshVariableScalarRefT< Cell, Real3 > VariableCellReal3
Coordinate type quantity at cell center.
MeshVariableScalarRefT< Face, Real3 > VariableFaceReal3
Coordinate type quantity at face.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
eMeshDirection
Direction type for a structured mesh.
@ MD_DirInvalid
Invalid or uninitialized direction.
@ Cell
The mesh is AMR by cell.
std::int32_t Int32
Signed integer type of 32 bits.
Real y
second component of the triplet
Real z
third component of the triplet
Real x
first component of the triplet