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"
75 m_p->m_cartesian_mesh = cm;
76 m_p->m_patch_index = patch_index;
95 m_p->m_infos.resize(new_size);
96 m_infos_view = m_p->m_infos.view();
106 IMesh*
mesh = m_p->m_cartesian_mesh->mesh();
109 int dir = (int)m_direction;
111 if (m_p->m_patch_index>=0)
112 base_group_name = base_group_name +
String(
"AMRPatch")+m_p->m_patch_index;
123 std::set<Int32> done_faces;
131 if (done_faces.find(prev_lid)==done_faces.end()){
132 faces_lid.
add(prev_lid);
133 done_faces.insert(prev_lid);
136 if (done_faces.find(next_lid)==done_faces.end()){
137 faces_lid.
add(next_lid);
138 done_faces.insert(next_lid);
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;
171 IMesh*
mesh = m_p->m_cartesian_mesh->mesh();
174 int dir = (int)m_direction;
176 if (m_p->m_patch_index >= 0)
177 base_group_name = base_group_name +
String(
"AMRPatch") + m_p->m_patch_index;
188 std::set<Int32> done_faces;
196 if (done_faces.find(prev_lid) == done_faces.end()) {
197 faces_lid.
add(prev_lid);
198 done_faces.insert(prev_lid);
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);
221 Int32 lid = iface.itemLocalId();
223 if (
face.nbCell() == 1) {
226 inpatch_lids.
add(lid);
229 overall_lids.
add(lid);
233 bool c0_inner_cell = inner_cells_lid.
contains(
face.cell(0).localId());
234 bool c1_inner_cell = inner_cells_lid.
contains(
face.cell(1).localId());
235 if (c0_inner_cell || c1_inner_cell) {
237 inpatch_lids.
add(lid);
240 bool c0_outer_cell = outer_cells_lid.
contains(
face.cell(0).localId());
241 bool c1_outer_cell = outer_cells_lid.
contains(
face.cell(1).localId());
242 if (c0_outer_cell || c1_outer_cell) {
244 inpatch_lids.
add(lid);
247 overall_lids.
add(lid);
252 m_p->m_inner_all_items = face_family->
createGroup(
String(
"AllInner") + base_group_name, inner_lids,
true);
253 m_p->m_outer_all_items = face_family->
createGroup(
String(
"AllOuter") + base_group_name, outer_lids,
true);
254 m_p->m_inpatch_all_items = face_family->
createGroup(
String(
"AllInPatch") + base_group_name, inpatch_lids,
true);
255 m_p->m_overall_all_items = face_family->
createGroup(
String(
"AllOverall") + base_group_name, overall_lids,
true);
256 m_p->m_all_items = all_faces;
265bool FaceDirectionMng::
266_hasFace(
Cell cell,
Int32 face_local_id)
const
268 for( FaceLocalId iface_lid : cell.
faceIds() ){
269 if (iface_lid==face_local_id)
283void FaceDirectionMng::
292 std::set<Int32> patch_cells_set;
294 patch_cells_set.insert(icell.itemLocalId());
299 Int32 face_lid = iface.itemLocalId();
300 Real3 face_coord = faces_center[iface];
305 if (!front_cell.
null())
306 if (patch_cells_set.find(front_cell.
localId()) == patch_cells_set.end())
308 if (!back_cell.
null())
309 if (patch_cells_set.find(back_cell.
localId()) == patch_cells_set.end())
312 bool is_inverse =
false;
313 if (!front_cell.
null()){
314 Real3 front_coord = cells_center[front_cell];
316 if (front_coord.
x<face_coord.
x)
320 if (front_coord.
y<face_coord.
y)
324 if (front_coord.
z<face_coord.
z)
329 Real3 back_coord = cells_center[back_cell];
331 if (back_coord.
x>face_coord.
x)
335 if (back_coord.
y>face_coord.
y)
339 if (back_coord.
z>face_coord.
z)
346 if (!back_cell.
null() && !front_cell.
null()){
349 if (back_level!=front_level){
353 if (!_hasFace(back_cell,face_lid))
355 if (!_hasFace(front_cell,face_lid))
360 m_infos_view[face_lid] = ItemDirectionInfo(back_cell, front_cell);
362 m_infos_view[face_lid] = ItemDirectionInfo(front_cell, back_cell);
369void FaceDirectionMng::
370_computeCellInfos()
const
386 bool is_inverse =
false;
387 if (!front_cell.
null() && !back_cell.
null()) {
394 if (front_cell_level != back_cell_level) {
395 Int32 face_level = numbering->faceLevel(
face.uniqueId());
396 if (front_cell_level != face_level) {
410 if (back_cell.
null()) {
412 ArrayView av_uids(numbering->nbFaceByCell(), uids);
413 numbering->cellFaceUniqueIds(front_cell, av_uids);
414 if (m_p->m_cartesian_mesh->mesh()->dimension() == 2) {
416 if (
face.uniqueId() == av_uids[1])
418 else if (
face.uniqueId() != av_uids[3])
419 ARCANE_FATAL(
"Bad connectivity -- Expected : {0} -- Found : {1}", av_uids[3],
face.uniqueId());
422 if (
face.uniqueId() == av_uids[2])
424 else if (
face.uniqueId() != av_uids[0])
425 ARCANE_FATAL(
"Bad connectivity -- Expected : {0} -- Found : {1}", av_uids[0],
face.uniqueId());
428 else if (m_p->m_cartesian_mesh->mesh()->dimension() == 3) {
430 if (
face.uniqueId() == av_uids[4])
432 else if (
face.uniqueId() != av_uids[1])
433 ARCANE_FATAL(
"Bad connectivity -- Expected : {0} -- Found : {1}", av_uids[1],
face.uniqueId());
436 if (
face.uniqueId() == av_uids[5])
438 else if (
face.uniqueId() != av_uids[2])
439 ARCANE_FATAL(
"Bad connectivity -- Expected : {0} -- Found : {1}", av_uids[2],
face.uniqueId());
442 if (
face.uniqueId() == av_uids[3])
444 else if (
face.uniqueId() != av_uids[0])
445 ARCANE_FATAL(
"Bad connectivity -- Expected : {0} -- Found : {1}", av_uids[0],
face.uniqueId());
449 else if (front_cell.
null()) {
451 ArrayView av_uids(numbering->nbFaceByCell(), uids);
452 numbering->cellFaceUniqueIds(back_cell, av_uids);
453 if (m_p->m_cartesian_mesh->mesh()->dimension() == 2) {
455 if (
face.uniqueId() == av_uids[3])
457 else if (
face.uniqueId() != av_uids[1])
458 ARCANE_FATAL(
"Bad connectivity -- Expected : {0} -- Found : {1}", av_uids[1],
face.uniqueId());
461 if (
face.uniqueId() == av_uids[0])
463 else if (
face.uniqueId() != av_uids[2])
464 ARCANE_FATAL(
"Bad connectivity -- Expected : {0} -- Found : {1}", av_uids[2],
face.uniqueId());
467 else if (m_p->m_cartesian_mesh->mesh()->dimension() == 3) {
469 if (
face.uniqueId() == av_uids[1])
471 else if (
face.uniqueId() != av_uids[4])
472 ARCANE_FATAL(
"Bad connectivity -- Expected : {0} -- Found : {1}", av_uids[4],
face.uniqueId());
475 if (
face.uniqueId() == av_uids[2])
477 else if (
face.uniqueId() != av_uids[5])
478 ARCANE_FATAL(
"Bad connectivity -- Expected : {0} -- Found : {1}", av_uids[5],
face.uniqueId());
481 if (
face.uniqueId() == av_uids[0])
483 else if (
face.uniqueId() != av_uids[3])
484 ARCANE_FATAL(
"Bad connectivity -- Expected : {0} -- Found : {1}", av_uids[3],
face.uniqueId());
495 m_infos_view[iface.itemLocalId()] = ItemDirectionInfo(back_cell, front_cell);
497 m_infos_view[iface.itemLocalId()] = ItemDirectionInfo(front_cell, back_cell);
507 return m_p->m_all_items;
516 return m_p->m_overall_all_items;
525 return m_p->m_inpatch_all_items;
534 return m_p->m_inner_all_items;
543 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....
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 overallFaces() const
Groupe de toutes les faces de recouvrement dans la direction.
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.
ItemVectorView view() const
Vue sur les entités du groupe.
Integer size() const
Nombre d'éléments du groupe.
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 de réel de dimension 3.
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