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"
73 m_p->m_cartesian_mesh = cm;
74 m_p->m_patch_index = patch_index;
93 m_p->m_infos.resize(new_size);
94 m_infos_view = m_p->m_infos.view();
104 IMesh*
mesh = m_p->m_cartesian_mesh->mesh();
107 int dir = (int)m_direction;
109 if (m_p->m_patch_index>=0)
110 base_group_name = base_group_name +
String(
"AMRPatch")+m_p->m_patch_index;
129 if (!done_faces[prev_lid]) {
130 faces_lid.
add(prev_lid);
131 done_faces[prev_lid] =
true;
134 if (!done_faces[next_lid]) {
135 faces_lid.
add(next_lid);
136 done_faces[next_lid] =
true;
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;
169 IMesh*
mesh = m_p->m_cartesian_mesh->mesh();
172 int dir = (int)m_direction;
174 if (m_p->m_patch_index >= 0)
175 base_group_name = base_group_name +
String(
"AMRPatch") + m_p->m_patch_index;
194 if (!done_faces[prev_lid]) {
195 faces_lid.
add(prev_lid);
196 done_faces[prev_lid] =
true;
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);
219 Int32 lid = iface.itemLocalId();
221 if (
face.nbCell() == 1) {
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;
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)
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()){
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);
388 bool is_inverse =
false;
389 if (!front_cell.
null() && !back_cell.
null()) {
396 if (front_cell_level != back_cell_level) {
397 Int32 face_level = numbering->faceLevel(
face.uniqueId());
398 if (front_cell_level != face_level) {
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.
bool contains(ConstReferenceType v) const
Vrai si le tableau contient l'élément de valeur v.
void reserve(Int64 new_capacity)
Réserve le mémoire pour new_capacity éléments.
void add(ConstReferenceType val)
Ajoute l'élément val à la fin du tableau.
Infos sur les mailles d'une direction spécifique X,Y ou Z d'un maillage structuré.
CellGroup outerCells() const
Groupe de toutes les mailles externes dans la direction.
CellGroup allCells() const
Groupe de toutes les mailles dans la direction.
DirCellFace cellFace(Cell c) const
Maille avec infos directionnelles aux faces correspondant à la maille c.
CellGroup innerCells() const
Groupe de toutes les mailles internes dans la direction.
Vue sur les informations des mailles.
FaceLocalIdView faceIds() const
Liste des faces de la maille.
Maille avec info directionnelle des faces.
Face next() const
Face connectée à la maille d'après la maille courante dans la direction.
Face previous() const
Face connectée à la maille d'avant la maille courante dans la direction.
FaceGroup inPatchFaces() const
Groupe de toutes les faces du patch dans la direction.
DirFace face(Face f) const
Face direction correspondant à la face f.
void _computeCellInfos(const CellDirectionMng &cell_dm, const VariableCellReal3 &cells_center, const VariableFaceReal3 &faces_center)
Calcule des mailles avant et après une face, dans une direction donnée.
void _internalComputeInfos(const CellDirectionMng &cell_dm, const VariableCellReal3 &cells_center, const VariableFaceReal3 &faces_center)
Calcule les informations sur les faces associées aux mailles de la direction cell_dm....
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.
void _internalInit(ICartesianMesh *cm, eMeshDirection dir, Integer patch_index)
FaceGroup outerFaces() const
Groupe de toutes les faces externes dans la direction.
void _internalResizeInfos(Int32 new_size)
Redimensionne le conteneur contenant les ItemDirectionInfo.
FaceGroup allFaces() const
Groupe de toutes les faces dans la direction.
virtual Ref< ICartesianMeshNumberingMngInternal > cartesianMeshNumberingMngInternal()=0
Méthode permettant de récupérer l'instance de CartesianMeshNumberingMngInternal.
Interface d'un maillage cartésien.
virtual ICartesianMeshInternal * _internalApi()=0
API interne à Arcane.
Interface d'une famille d'entités.
virtual ItemGroup createGroup(const String &name, Int32ConstArrayView local_ids, bool do_override=false)=0
Créé un groupe d'entités de nom name contenant les entités local_ids.
virtual Int32 maxLocalId() const =0
ItemVectorView view() const
Vue sur les entités du groupe.
Integer size() const
Nombre d'éléments du groupe.
IItemFamily * itemFamily() const
Famille d'entité à laquelle appartient ce groupe (0 pour le group nul).
void setItems(Int32ConstArrayView items_local_id)
Positionne les entités du groupe.
void fillLocalIds(Array< Int32 > &ids) const
Ajoute à ids la liste des localIds() du vecteur.
constexpr Int32 localId() const
Identifiant local de l'entité dans le sous-domaine du processeur.
ItemUniqueId uniqueId() const
Identifiant unique sur tous les domaines.
constexpr bool null() const
true si l'entité est nul (i.e. non connecté au maillage)
Classe gérant un vecteur réel de 3 dimensions.
Référence à une instance.
Chaîne de caractères unicode.
Vecteur 1D de données avec sémantique par valeur (style STL).
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.
Real y
deuxième composante du triplet
Real z
troisième composante du triplet
Real x
première composante du triplet