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"
78 m_p->m_cartesian_mesh = cm;
79 m_p->m_patch_index = patch_index;
98 m_p->m_infos.resize(new_size);
99 m_infos_view = m_p->m_infos.view();
109 IMesh*
mesh = m_p->m_cartesian_mesh->mesh();
112 int dir = (int)m_direction;
114 if (m_p->m_patch_index >= 0)
115 base_group_name = base_group_name +
String(
"AMRPatch") + m_p->m_patch_index;
134 if (!done_faces[prev_lid]) {
135 faces_lid.
add(prev_lid);
136 done_faces[prev_lid] =
true;
139 if (!done_faces[next_lid]) {
140 faces_lid.
add(next_lid);
141 done_faces[next_lid] =
true;
147 all_faces.
setItems(faces_lid,
true);
152 Int32 lid = iitem.itemLocalId();
155 if (
face.nbCell() == 1)
160 m_p->m_inner_all_items = face_family->
createGroup(
String(
"AllInner") + base_group_name, inner_lids,
true);
161 m_p->m_outer_all_items = face_family->
createGroup(
String(
"AllOuter") + base_group_name, outer_lids,
true);
162 m_p->m_all_items = all_faces;
174 IMesh*
mesh = m_p->m_cartesian_mesh->mesh();
177 int dir = (int)m_direction;
179 if (m_p->m_patch_index >= 0)
180 base_group_name = base_group_name +
String(
"AMRPatch") + m_p->m_patch_index;
199 if (!done_faces[prev_lid]) {
200 faces_lid.
add(prev_lid);
201 done_faces[prev_lid] =
true;
204 if (!done_faces[next_lid]) {
205 faces_lid.
add(next_lid);
206 done_faces[next_lid] =
true;
212 all_faces.
setItems(faces_lid,
true);
224 Int32 lid = iface.itemLocalId();
226 if (
face.nbCell() == 1) {
229 inpatch_lids.
add(lid);
231 else if (outer_cells_lid.
contains(
face.cell(0).localId())) {
233 inpatch_lids.
add(lid);
236 overlap_lids.
add(lid);
240 bool c0_inner_cell = inner_cells_lid.
contains(
face.cell(0).localId());
241 bool c1_inner_cell = inner_cells_lid.
contains(
face.cell(1).localId());
242 if (c0_inner_cell || c1_inner_cell) {
244 inpatch_lids.
add(lid);
247 bool c0_outer_cell = outer_cells_lid.
contains(
face.cell(0).localId());
248 bool c1_outer_cell = outer_cells_lid.
contains(
face.cell(1).localId());
249 if (c0_outer_cell || c1_outer_cell) {
251 inpatch_lids.
add(lid);
254 overlap_lids.
add(lid);
259 m_p->m_inner_all_items = face_family->
createGroup(
String(
"AllInner") + base_group_name, inner_lids,
true);
260 m_p->m_outer_all_items = face_family->
createGroup(
String(
"AllOuter") + base_group_name, outer_lids,
true);
261 m_p->m_inpatch_all_items = face_family->
createGroup(
String(
"AllInPatch") + base_group_name, inpatch_lids,
true);
262 m_p->m_overlap_all_items = face_family->
createGroup(
String(
"AllOverlap") + base_group_name, overlap_lids,
true);
263 m_p->m_all_items = all_faces;
272bool FaceDirectionMng::
273_hasFace(
Cell cell,
Int32 face_local_id)
const
275 for (FaceLocalId iface_lid : cell.
faceIds()) {
276 if (iface_lid == face_local_id)
301 is_patch_cell[icell.itemLocalId()] =
true;
306 Int32 face_lid = iface.itemLocalId();
307 Real3 face_coord = faces_center[iface];
312 if (!front_cell.
null())
313 if (!is_patch_cell[front_cell.
localId()])
315 if (!back_cell.
null())
316 if (!is_patch_cell[back_cell.
localId()])
319 bool is_inverse =
false;
320 if (!front_cell.
null()) {
321 Real3 front_coord = cells_center[front_cell];
323 if (front_coord.
x < face_coord.
x)
327 if (front_coord.
y < face_coord.
y)
331 if (front_coord.
z < face_coord.
z)
336 Real3 back_coord = cells_center[back_cell];
338 if (back_coord.
x > face_coord.
x)
342 if (back_coord.
y > face_coord.
y)
346 if (back_coord.
z > face_coord.
z)
353 if (!back_cell.
null() && !front_cell.
null()) {
356 if (back_level != front_level) {
360 if (!_hasFace(back_cell, face_lid))
362 if (!_hasFace(front_cell, face_lid))
367 m_infos_view[face_lid] = ItemDirectionInfo(back_cell, front_cell);
369 m_infos_view[face_lid] = ItemDirectionInfo(front_cell, back_cell);
393 bool is_inverse =
false;
394 if (!front_cell.
null() && !back_cell.
null()) {
401 if (front_cell_level != back_cell_level) {
402 Int32 face_level = numbering->faceLevel(
face.uniqueId());
403 if (front_cell_level != face_level) {
417 if (back_cell.
null()) {
419 ArrayView av_uids(numbering->nbFaceByCell(), uids);
420 numbering->cellFaceUniqueIds(front_cell, av_uids);
421 if (m_p->m_cartesian_mesh->mesh()->dimension() == 2) {
423 if (
face.uniqueId() == av_uids[1])
425 else if (
face.uniqueId() != av_uids[3])
426 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[3],
face.uniqueId());
429 if (
face.uniqueId() == av_uids[2])
431 else if (
face.uniqueId() != av_uids[0])
432 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[0],
face.uniqueId());
435 else if (m_p->m_cartesian_mesh->mesh()->dimension() == 3) {
437 if (
face.uniqueId() == av_uids[4])
439 else if (
face.uniqueId() != av_uids[1])
440 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[1],
face.uniqueId());
443 if (
face.uniqueId() == av_uids[5])
445 else if (
face.uniqueId() != av_uids[2])
446 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[2],
face.uniqueId());
449 if (
face.uniqueId() == av_uids[3])
451 else if (
face.uniqueId() != av_uids[0])
452 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[0],
face.uniqueId());
456 else if (front_cell.
null()) {
458 ArrayView av_uids(numbering->nbFaceByCell(), uids);
459 numbering->cellFaceUniqueIds(back_cell, av_uids);
460 if (m_p->m_cartesian_mesh->mesh()->dimension() == 2) {
462 if (
face.uniqueId() == av_uids[3])
464 else if (
face.uniqueId() != av_uids[1])
465 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[1],
face.uniqueId());
468 if (
face.uniqueId() == av_uids[0])
470 else if (
face.uniqueId() != av_uids[2])
471 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[2],
face.uniqueId());
474 else if (m_p->m_cartesian_mesh->mesh()->dimension() == 3) {
476 if (
face.uniqueId() == av_uids[1])
478 else if (
face.uniqueId() != av_uids[4])
479 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[4],
face.uniqueId());
482 if (
face.uniqueId() == av_uids[2])
484 else if (
face.uniqueId() != av_uids[5])
485 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[5],
face.uniqueId());
488 if (
face.uniqueId() == av_uids[0])
490 else if (
face.uniqueId() != av_uids[3])
491 ARCANE_FATAL(
"Bad connectivity, did you call computeDirection() ? -- Expected : {0} -- Found : {1}", av_uids[3],
face.uniqueId());
502 m_infos_view[iface.itemLocalId()] = ItemDirectionInfo(back_cell, front_cell);
504 m_infos_view[iface.itemLocalId()] = ItemDirectionInfo(front_cell, back_cell);
514 return m_p->m_all_items;
523 return m_p->m_overlap_all_items;
532 return m_p->m_inpatch_all_items;
541 return m_p->m_inner_all_items;
550 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.
virtual Int32 maxLocalId() const =0
ItemVectorView view() const
View of the group entities.
Integer size() const
Number of elements in the group.
IItemFamily * itemFamily() const
Entity family to which this group belongs (0 for the null 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