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/IItemFamily.h"
23#include "arcane/ItemGroup.h"
24#include "arcane/IMesh.h"
25#include "arcane/VariableTypes.h"
26#include "arcane/UnstructuredMeshConnectivity.h"
28#include "arcane/cartesianmesh/ICartesianMesh.h"
29#include "arcane/cartesianmesh/CellDirectionMng.h"
54 Integer m_patch_index = -1;
74void NodeDirectionMng::
82 m_p->m_cartesian_mesh = cm;
83 m_p->m_patch_index = patch_index;
89void NodeDirectionMng::
102 m_p->m_infos.
resize(new_size);
103 m_infos_view = m_p->m_infos.
view();
109void NodeDirectionMng::
114 m_infos_view.
fill(NodeDirectionMng::ItemDirectionInfo());
116 Integer mesh_dim = m_p->m_cartesian_mesh->
mesh()->
dimension();
127 NodeLocalId node_previous_left = cn.previousLeftId();
128 NodeLocalId node_previous_right = cn.previousRightId();
130 m_infos_view[node_previous_left].m_next_lid = node_next_left;
131 m_infos_view[node_next_left].m_previous_lid = node_previous_left;
133 m_infos_view[node_previous_right].m_next_lid = node_next_right;
134 m_infos_view[node_next_right].m_previous_lid = node_previous_right;
137 NodeLocalId top_node_next_left = cn.topNextLeftId();
138 NodeLocalId top_node_next_right = cn.topNextRightId();
140 NodeLocalId top_node_previous_left = cn.topPreviousLeftId();
141 NodeLocalId top_node_previous_right = cn.topPreviousRightId();
143 m_infos_view[top_node_previous_left].m_next_lid = top_node_next_left;
144 m_infos_view[top_node_next_left].m_previous_lid = top_node_previous_left;
146 m_infos_view[top_node_previous_right].m_next_lid = top_node_next_right;
147 m_infos_view[top_node_next_right].m_previous_lid = top_node_previous_right;
155 Int32 lid = iitem.itemLocalId();
156 Int32 i1 = m_infos_view[lid].m_next_lid;
157 Int32 i2 = m_infos_view[lid].m_previous_lid;
158 if (i1==NULL_ITEM_LOCAL_ID || i2==NULL_ITEM_LOCAL_ID)
163 int dir = (int)m_direction;
164 String base_group_name = String(
"Direction")+dir;
165 if (m_p->m_patch_index>=0)
166 base_group_name = base_group_name + String(
"AMRPatch")+m_p->m_patch_index;
167 m_p->m_inner_all_items = family->createGroup(String(
"AllInner")+base_group_name,inner_lids,
true);
168 m_p->m_outer_all_items = family->createGroup(String(
"AllOuter")+base_group_name,outer_lids,
true);
169 m_p->m_all_items = all_nodes;
172 _computeNodeCellInfos(cell_dm,cells_center);
175 UnstructuredMeshConnectivityView mesh_connectivity;
176 mesh_connectivity.setMesh(m_p->m_cartesian_mesh->
mesh());
177 m_node_cell_view = mesh_connectivity.nodeCell();
187void NodeDirectionMng::
191 std::set<NodeLocalId> nodes_set;
193 nodes_set.insert(NodeLocalId(inode.itemLocalId()));
196 for( ItemDirectionInfo& idi : m_infos_view ){
198 Int32 next_lid = idi.m_next_lid;
199 if (next_lid!=NULL_ITEM_LOCAL_ID)
200 if (nodes_set.find(NodeLocalId(next_lid))==nodes_set.end())
201 idi.m_next_lid = NodeLocalId{};
204 Int32 prev_lid = idi.m_previous_lid;
205 if (prev_lid!=NULL_ITEM_LOCAL_ID)
206 if (nodes_set.find(NodeLocalId(prev_lid))==nodes_set.end())
207 idi.m_previous_lid = NodeLocalId{};
217void NodeDirectionMng::
218_computeNodeCellInfos(
const CellDirectionMng& cell_dm,
const VariableCellReal3& cells_center)
221 IndexType indexes_ptr[8];
222 ArrayView<IndexType> indexes(8,indexes_ptr);
225 NodeGroup dm_all_nodes = node_dm.allNodes();
227 IMesh* mesh = m_p->m_cartesian_mesh->
mesh();
228 Integer mesh_dim = mesh->dimension();
230 if (mesh_dim!=2 && mesh_dim!=3)
231 ARCANE_FATAL(
"Invalid mesh dimension '{0}'. Valid dimensions are 2 or 3",mesh_dim);
235 std::set<CellLocalId> inside_cells;
237 inside_cells.insert(CellLocalId(icell.itemLocalId()));
243 Real3 node_pos = nodes_coord[
node];
244 indexes.fill(DirNode::NULL_CELL);
245 for( Integer i=0; i<nb_cell; ++i ){
246 const IndexType bi = (IndexType)i;
248 if (inside_cells.find(CellLocalId(cell.localId()))==inside_cells.end())
251 Real3 center = cells_center[cell];
252 Real3 wanted_cell_pos;
253 Real3 wanted_node_pos;
255 wanted_cell_pos = center;
256 wanted_node_pos = node_pos;
258 wanted_cell_pos = Real3(center.y, -center.x, center.z);
259 wanted_node_pos = Real3(node_pos.y, -node_pos.x, node_pos.z);
262 wanted_cell_pos = Real3(center.z, -center.y, center.x);
263 wanted_node_pos = Real3(node_pos.z, -node_pos.y, node_pos.x);
265 bool is_top = ((wanted_cell_pos.z > wanted_node_pos.z) && mesh_dim==3);
267 if (wanted_cell_pos.x > wanted_node_pos.x ){
268 if (wanted_cell_pos.y > wanted_node_pos.y )
269 indexes_ptr[CNP_NextLeft] = bi;
271 indexes_ptr[CNP_NextRight] = bi;
274 if (wanted_cell_pos.y > wanted_node_pos.y )
275 indexes_ptr[CNP_PreviousLeft] = bi;
277 indexes_ptr[CNP_PreviousRight] = bi;
281 if (wanted_cell_pos.x > wanted_node_pos.x ){
282 if (wanted_cell_pos.y > wanted_node_pos.y )
283 indexes_ptr[CNP_TopNextLeft] = bi;
285 indexes_ptr[CNP_TopNextRight] = bi;
288 if (wanted_cell_pos.y > wanted_node_pos.y )
289 indexes_ptr[CNP_TopPreviousLeft] = bi;
291 indexes_ptr[CNP_TopPreviousRight] = bi;
295 m_infos_view[
node.localId()].setCellIndexes(indexes_ptr);
305 return m_p->m_all_items;
314 return m_p->m_inner_all_items;
323 return m_p->m_outer_all_items;
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Infos sur les mailles d'une direction spécifique X,Y ou Z d'un maillage structuré.
CellGroup allCells() const
Groupe de toutes les mailles dans la direction.
DirCellNode cellNode(Cell c) const
Maille avec infos directionnelles aux noeuds correspondant à la maille c.
Maille avec info directionnelle des noeuds.
Cell cell(Int32 position) const
Maille en fonction de sa position par rapport à ce noeud.
Interface d'un maillage cartésien.
virtual IMesh * mesh() const =0
Maillage associé à ce maillage cartésien.
virtual IItemFamily * nodeFamily()=0
Retourne la famille des noeuds.
virtual Integer dimension()=0
Dimension du maillage (1D, 2D ou 3D).
IItemFamily * itemFamily() const
Famille d'entité à laquelle appartient ce groupe (0 pour le group nul)
NodeGroup innerNodes() const
Groupe de tous les noeuds internes dans la direction.
NodeDirectionMng()
Créé une instance vide.
NodeGroup outerNodes() const
Groupe de tous les noeuds externes 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.
void _internalResizeInfos(Int32 new_size)
Redimensionne le conteneur contenant les ItemDirectionInfo.
Vue sur les informations des noeuds.
void resize(Int64 s)
Change le nombre d'éléments du tableau à s.
ArrayView< T > view() const
Vue mutable sur ce tableau.
__host__ __device__ void fill(T o)
Remplit le tableau avec la valeur o.
Vecteur 1D de données avec sémantique par valeur (style STL).
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 -*-
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.
Int32 Integer
Type représentant un entier.