14#include "arcane/cartesianmesh/NodeDirectionMng.h"
16#include "arcane/utils/FatalErrorException.h"
17#include "arcane/utils/ArgumentException.h"
18#include "arcane/utils/ITraceMng.h"
19#include "arcane/utils/Real3.h"
20#include "arcane/utils/PlatformUtils.h"
22#include "arcane/core/IItemFamily.h"
23#include "arcane/core/ItemGroup.h"
24#include "arcane/core/IMesh.h"
25#include "arcane/core/VariableTypes.h"
26#include "arcane/core/UnstructuredMeshConnectivity.h"
28#include "arcane/cartesianmesh/ICartesianMesh.h"
29#include "arcane/cartesianmesh/CellDirectionMng.h"
30#include "arcane/cartesianmesh/internal/ICartesianMeshInternal.h"
85 m_p->m_cartesian_mesh = cm;
86 m_p->m_patch_index = patch_index;
105 m_p->m_infos.resize(new_size);
106 m_infos_view = m_p->m_infos.view();
119 Integer mesh_dim = m_p->m_cartesian_mesh->mesh()->dimension();
133 m_infos_view[node_previous_left].m_next_lid = node_next_left;
134 m_infos_view[node_next_left].m_previous_lid = node_previous_left;
136 m_infos_view[node_previous_right].m_next_lid = node_next_right;
137 m_infos_view[node_next_right].m_previous_lid = node_previous_right;
146 m_infos_view[top_node_previous_left].m_next_lid = top_node_next_left;
147 m_infos_view[top_node_next_left].m_previous_lid = top_node_previous_left;
149 m_infos_view[top_node_previous_right].m_next_lid = top_node_next_right;
150 m_infos_view[top_node_next_right].m_previous_lid = top_node_previous_right;
158 Int32 lid = iitem.itemLocalId();
159 Int32 i1 = m_infos_view[lid].m_next_lid;
160 Int32 i2 = m_infos_view[lid].m_previous_lid;
161 if (i1 == NULL_ITEM_LOCAL_ID || i2 == NULL_ITEM_LOCAL_ID)
166 int dir = (int)m_direction;
168 if (m_p->m_patch_index>=0)
169 base_group_name = base_group_name +
String(
"AMRPatch")+m_p->m_patch_index;
170 m_p->m_inner_all_items = family->
createGroup(
String(
"AllInner")+base_group_name,inner_lids,
true);
171 m_p->m_outer_all_items = family->
createGroup(
String(
"AllOuter")+base_group_name,outer_lids,
true);
172 m_p->m_all_items = all_nodes;
179 mesh_connectivity.setMesh(m_p->m_cartesian_mesh->mesh());
180 m_node_cell_view = mesh_connectivity.nodeCell();
190 m_infos_view.fill(ItemDirectionInfo());
200 NodeLocalId node_next_left = cn.nextLeftId();
201 NodeLocalId node_next_right = cn.nextRightId();
203 NodeLocalId node_previous_left = cn.previousLeftId();
204 NodeLocalId node_previous_right = cn.previousRightId();
206 m_infos_view[node_previous_left].m_next_lid = node_next_left;
207 m_infos_view[node_next_left].m_previous_lid = node_previous_left;
209 m_infos_view[node_previous_right].m_next_lid = node_next_right;
210 m_infos_view[node_next_right].m_previous_lid = node_previous_right;
213 NodeLocalId top_node_next_left = cn.topNextLeftId();
214 NodeLocalId top_node_next_right = cn.topNextRightId();
216 NodeLocalId top_node_previous_left = cn.topPreviousLeftId();
217 NodeLocalId top_node_previous_right = cn.topPreviousRightId();
219 m_infos_view[top_node_previous_left].m_next_lid = top_node_next_left;
220 m_infos_view[top_node_next_left].m_previous_lid = top_node_previous_left;
222 m_infos_view[top_node_previous_right].m_next_lid = top_node_next_right;
223 m_infos_view[top_node_next_right].m_previous_lid = top_node_previous_right;
227 UniqueArray<Int32> inner_cells_lid;
228 UniqueArray<Int32> outer_cells_lid;
232 UniqueArray<Int32> inner_lids;
233 UniqueArray<Int32> outer_lids;
238 Int32 lid = inode.itemLocalId();
241 for (
Cell cell : inode->cells()) {
242 if (inner_cells_lid.contains(cell.
localId())) {
245 else if (outer_cells_lid.contains(cell.
localId())) {
249 if (nb_inner_cells + nb_outer_cells == inode->nbCell()) {
252 else if (nb_outer_cells != 0) {
263 int dir = (int)m_direction;
264 String base_group_name = String(
"Direction") + dir;
265 if (m_p->m_patch_index >= 0)
266 base_group_name = base_group_name + String(
"AMRPatch") + m_p->m_patch_index;
267 m_p->m_inner_all_items = family->
createGroup(String(
"AllInner") + base_group_name, inner_lids,
true);
268 m_p->m_outer_all_items = family->createGroup(String(
"AllOuter") + base_group_name, outer_lids,
true);
273 m_p->m_all_items = all_nodes;
279 UnstructuredMeshConnectivityView mesh_connectivity;
280 mesh_connectivity.setMesh(m_p->m_cartesian_mesh->mesh());
281 m_node_cell_view = mesh_connectivity.nodeCell();
296 std::set<NodeLocalId> nodes_set;
298 nodes_set.insert(NodeLocalId(inode.itemLocalId()));
303 Int32 next_lid = idi.m_next_lid;
304 if (next_lid!=NULL_ITEM_LOCAL_ID)
305 if (nodes_set.find(NodeLocalId(next_lid))==nodes_set.end())
306 idi.m_next_lid = NodeLocalId{};
309 Int32 prev_lid = idi.m_previous_lid;
310 if (prev_lid!=NULL_ITEM_LOCAL_ID)
311 if (nodes_set.find(NodeLocalId(prev_lid))==nodes_set.end())
312 idi.m_previous_lid = NodeLocalId{};
323void NodeDirectionMng::
327 IndexType indexes_ptr[8];
333 IMesh*
mesh = m_p->m_cartesian_mesh->mesh();
336 if (mesh_dim!=2 && mesh_dim!=3)
337 ARCANE_FATAL(
"Invalid mesh dimension '{0}'. Valid dimensions are 2 or 3",mesh_dim);
341 std::set<CellLocalId> inside_cells;
343 inside_cells.insert(CellLocalId(icell.itemLocalId()));
350 indexes.
fill(DirNode::NULL_CELL);
351 for(
Integer i=0; i<nb_cell; ++i ){
352 const IndexType bi = (IndexType)i;
354 if (inside_cells.find(CellLocalId(cell.
localId()))==inside_cells.end())
357 Real3 center = cells_center[cell];
358 Real3 wanted_cell_pos;
359 Real3 wanted_node_pos;
361 wanted_cell_pos = center;
362 wanted_node_pos = node_pos;
364 wanted_cell_pos =
Real3(center.
y, -center.
x, center.
z);
365 wanted_node_pos =
Real3(node_pos.
y, -node_pos.
x, node_pos.
z);
368 wanted_cell_pos =
Real3(center.
z, -center.
y, center.
x);
369 wanted_node_pos =
Real3(node_pos.
z, -node_pos.
y, node_pos.
x);
371 bool is_top = ((wanted_cell_pos.
z > wanted_node_pos.
z) && mesh_dim==3);
373 if (wanted_cell_pos.
x > wanted_node_pos.
x ){
374 if (wanted_cell_pos.
y > wanted_node_pos.
y )
375 indexes_ptr[CNP_NextLeft] = bi;
377 indexes_ptr[CNP_NextRight] = bi;
380 if (wanted_cell_pos.
y > wanted_node_pos.
y )
381 indexes_ptr[CNP_PreviousLeft] = bi;
383 indexes_ptr[CNP_PreviousRight] = bi;
387 if (wanted_cell_pos.
x > wanted_node_pos.
x ){
388 if (wanted_cell_pos.
y > wanted_node_pos.
y )
389 indexes_ptr[CNP_TopNextLeft] = bi;
391 indexes_ptr[CNP_TopNextRight] = bi;
394 if (wanted_cell_pos.
y > wanted_node_pos.
y )
395 indexes_ptr[CNP_TopPreviousLeft] = bi;
397 indexes_ptr[CNP_TopPreviousRight] = bi;
401 m_infos_view[
node.localId()].setCellIndexes(indexes_ptr);
408void NodeDirectionMng::
409_computeNodeCellInfos()
const
413 IndexType indexes_ptr[8];
422 constexpr Integer nb_cells_max = 4;
424 Int64 uids[nb_cells_max];
443 constexpr Int32 dir_x_pos_2d[nb_cells_max] = { CNP_PreviousRight, CNP_NextRight, CNP_PreviousLeft, CNP_NextLeft };
444 constexpr Int32 dir_y_pos_2d[nb_cells_max] = { CNP_PreviousLeft, CNP_PreviousRight, CNP_NextLeft, CNP_NextRight };
448 numbering->cellUniqueIdsAroundNode(
node, av_uids);
451 indexes.fill(DirNode::NULL_CELL);
453 for (
Integer i = 0; i < nb_cell; ++i) {
456 for (; pos < nb_cells_max; ++pos) {
457 if (cell.uniqueId() == av_uids[pos])
460 if (pos == nb_cells_max)
463 const IndexType bi = (IndexType)i;
465 indexes[dir_x_pos_2d[pos]] = bi;
468 indexes[dir_y_pos_2d[pos]] = bi;
471 m_infos_view[
node.localId()].setCellIndexes(indexes_ptr);
474 else if (mesh_dim == 3) {
475 constexpr Integer nb_cells_max = 8;
477 Int64 uids[nb_cells_max];
478 ArrayView av_uids(nb_cells_max, uids);
498 constexpr Int32 dir_x_pos_3d[nb_cells_max] = { CNP_PreviousRight, CNP_NextRight, CNP_PreviousLeft, CNP_NextLeft, CNP_TopPreviousRight, CNP_TopNextRight, CNP_TopPreviousLeft, CNP_TopNextLeft };
499 constexpr Int32 dir_y_pos_3d[nb_cells_max] = { CNP_PreviousLeft, CNP_PreviousRight, CNP_NextLeft, CNP_NextRight, CNP_TopPreviousLeft, CNP_TopPreviousRight, CNP_TopNextLeft, CNP_TopNextRight };
500 constexpr Int32 dir_z_pos_3d[nb_cells_max] = { CNP_PreviousLeft, CNP_PreviousRight, CNP_TopPreviousLeft, CNP_TopPreviousRight, CNP_NextLeft, CNP_NextRight, CNP_TopNextLeft, CNP_TopNextRight };
504 numbering->cellUniqueIdsAroundNode(
node, av_uids);
507 indexes.fill(DirNode::NULL_CELL);
509 for (
Integer i = 0; i < nb_cell; ++i) {
512 for (; pos < nb_cells_max; ++pos) {
513 if (cell.uniqueId() == av_uids[pos])
516 if (pos == nb_cells_max)
519 const IndexType bi = (IndexType)i;
522 indexes[dir_x_pos_3d[pos]] = bi;
525 indexes[dir_y_pos_3d[pos]] = bi;
528 indexes[dir_z_pos_3d[pos]] = bi;
531 m_infos_view[
node.localId()].setCellIndexes(indexes_ptr);
536 ARCANE_FATAL(
"Invalid mesh dimension '{0}'. Valid dimensions are 2 or 3", mesh_dim);
546 return m_p->m_all_items;
555 return m_p->m_overlap_all_items;
564 return m_p->m_inpatch_all_items;
573 return m_p->m_inner_all_items;
582 return m_p->m_outer_all_items;
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Vue modifiable d'un tableau d'un type T.
void fill(const T &o) noexcept
Remplit le tableau avec la valeur o.
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.
CellGroup overlapCells() const
Groupe de toutes les mailles de recouvrement dans la direction.
DirCellNode cellNode(Cell c) const
Maille avec infos directionnelles aux noeuds correspondant à la maille c.
CellGroup innerCells() const
Groupe de toutes les mailles internes dans la direction.
CellGroup inPatchCells() const
Groupe de toutes les mailles du patch dans la direction.
Maille avec info directionnelle des noeuds.
NodeLocalId topNextLeftId() const
Noeud devant à gauche dans la direction.
NodeLocalId nextRightId() const
Noeud devant à droite dans la direction.
NodeLocalId topNextRightId() const
Noeud devant à droite dans la direction.
NodeLocalId nextLeftId() const
Noeud devant à gauche dans la direction.
NodeLocalId topPreviousLeftId() const
Noeud derrière à gauche dans la direction.
NodeLocalId topPreviousRightId() const
Noeud derrière à droite dans la direction.
NodeLocalId previousLeftId() const
Noeud derrière à gauche dans la direction.
NodeLocalId previousRightId() const
Noeud derrière à droite 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 IMesh * mesh() const =0
Maillage associé à ce 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 IItemFamily * nodeFamily()=0
Retourne la famille des noeuds.
virtual Integer dimension()=0
Dimension du maillage (1D, 2D ou 3D).
NodeGroup nodeGroup() const
Groupe des noeuds des éléments de ce groupe.
ItemVectorView view() const
Vue sur les entités du groupe.
IItemFamily * itemFamily() const
Famille d'entité à laquelle appartient ce groupe (0 pour le group nul)
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.
void _internalComputeInfos(const CellDirectionMng &cell_dm, const NodeGroup &all_nodes, const VariableCellReal3 &cells_center)
Calcule les informations sur les noeuds associées aux mailles de la direction cell_dm....
NodeGroup innerNodes() const
Groupe de tous les noeuds internes dans la direction.
void _filterNodes()
Filtre les noeuds devant/derrière pour ne garder que les noeuds de notre patch.
NodeDirectionMng()
Créé une instance vide.
NodeGroup outerNodes() const
Groupe de tous les noeuds externes dans la direction.
void _internalInit(ICartesianMesh *cm, eMeshDirection dir, Integer patch_index)
void _computeNodeCellInfos(const CellDirectionMng &cell_dm, const VariableCellReal3 &cells_center)
Calcul des connectivités noeuds/mailles par direction.
NodeGroup overlapNodes() const
Groupe de tous les noeuds de recouvrement dans la direction.
NodeGroup allNodes() const
Groupe de tous les noeuds dans la direction.
DirNode node(Node n) const
Noeud direction correspondant au noeud n.
NodeGroup inPatchNodes() const
Groupe de tous les noeuds du patch dans la direction.
void _internalResizeInfos(Int32 new_size)
Redimensionne le conteneur contenant les ItemDirectionInfo.
Vue sur les informations des noeuds.
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).
Vue sur les connectivités standards d'un maillage non structuré.
ItemGroupT< Node > NodeGroup
Groupe de noeuds.
MeshVariableScalarRefT< Cell, Real3 > VariableCellReal3
Grandeur au centre des mailles de type coordonnées.
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Grandeur au noeud 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.
eMeshDirection
Type de la direction pour un maillage structuré
@ MD_DirInvalid
Direction invalide ou non initialisée.
UniqueArray< Int32 > Int32UniqueArray
Tableau dynamique à une dimension d'entiers 32 bits.
@ 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