Arcane  v4.1.1.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
src/arcane/cartesianmesh/NodeDirectionMng.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* NodeDirectionMng.cc (C) 2000-2025 */
9/* */
10/* Infos sur les noeuds d'une direction X Y ou Z d'un maillage structuré. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CARTESIANMESH_NODEDIRECTIONMNG_H
13#define ARCANE_CARTESIANMESH_NODEDIRECTIONMNG_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/ArcaneTypes.h"
18#include "arcane/Item.h"
19#include "arcane/ItemEnumerator.h"
20#include "arcane/VariableTypedef.h"
21#include "arcane/IndexedItemConnectivityView.h"
22
23#include "arcane/cartesianmesh/CartesianMeshGlobal.h"
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28namespace Arcane
29{
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33/*!
34 * \ingroup ArcaneCartesianMesh
35 * \brief Noeud avant et après un noeud suivant une direction.
36 *
37 * Les instances de cette classe sont temporaires et construites via
38 * NodeDirectionMng::node().
39 */
40class ARCANE_CARTESIANMESH_EXPORT DirNode
41{
42 friend NodeDirectionMng;
43 friend class DirNodeLocalId;
44
45 private:
46
47 typedef signed char IndexType;
48 static constexpr IndexType NULL_CELL = -1;
49
50 struct DirNodeCellIndex
51 {
52 public:
53
54 ARCCORE_HOST_DEVICE IndexType operator[](Int32 i) const
55 {
56 ARCANE_CHECK_AT(i, 8);
57 return m_indexes[i];
58 }
59
60 public:
61
62 IndexType m_indexes[8];
63 };
64
65 private:
66
67 // Seul NodeDirectionMng à le droit de construire un DirNode.
68 DirNode(Node current, Node next, Node prev, DirNodeCellIndex idx)
69 : m_current(current)
70 , m_previous(prev)
71 , m_next(next)
72 , m_cell_index(idx)
73 {}
74
75 public:
76
77 //! Maille avant
78 Node previous() const { return m_previous; }
79 //! Maille avant
80 NodeLocalId previousId() const { return m_previous.itemLocalId(); }
81 //! Maille après
82 Node next() const { return m_next; }
83 //! Maille après
84 NodeLocalId nextId() const { return m_next.itemLocalId(); }
85 /*!
86 * \brief Indice dans la liste des mailles de ce noeud d'une
87 * maille en fonction de sa position.
88 *
89 * Les valeurs possibles pour \a position sont données par l'énumération
90 * eCellNodePosition.
91 */
92 Int32 cellIndex(Int32 position) const { return m_cell_index[position]; }
93 /*!
94 * \brief Indice local d'une maille en fonction de sa position par rapport à ce noeud.
95 *
96 * Les valeurs possibles pour \a position sont données par l'énumération
97 * eCellNodePosition.
98 */
99 CellLocalId cellId(Int32 position) const
100 {
101 Int32 x = cellIndex(position);
102 return (x == NULL_CELL) ? CellLocalId(NULL_ITEM_LOCAL_ID) : CellLocalId(m_current.cellId(x));
103 }
104 /*!
105 * \brief Maille en fonction de sa position par rapport à ce noeud.
106 *
107 * Les valeurs possibles pour \a position sont données par l'énumération
108 * eCellNodePosition.
109 */
110 Cell cell(Int32 position) const
111 {
112 Int32 x = cellIndex(position);
113 return (x == NULL_CELL) ? Cell() : Cell(m_current.cell(x));
114 }
115
116 //! Noeud devant à gauche dans la direction
117 Cell nextLeftCell() const { return cell(CNP_NextLeft); }
118 //! Noeud devant à droite dans la direction
119 Cell nextRightCell() const { return cell(CNP_NextRight); }
120 //! Noeud derrière à droite dans la direction
121 Cell previousRightCell() const { return cell(CNP_PreviousRight); }
122 //! Noeud derrière à gauche dans la direction
123 Cell previousLeftCell() const { return cell(CNP_PreviousLeft); }
124
125 //! Noeud devant à gauche dans la direction
126 CellLocalId nextLeftCellId() const { return cellId(CNP_NextLeft); }
127 //! Noeud devant à droite dans la direction
128 CellLocalId nextRightCellId() const { return cellId(CNP_NextRight); }
129 //! Noeud derrière à droite dans la direction
130 CellLocalId previousRightCellId() const { return cellId(CNP_PreviousRight); }
131 //! Noeud derrière à gauche dans la direction
132 CellLocalId previousLeftCellId() const { return cellId(CNP_PreviousLeft); }
133
134 //! Noeud devant à gauche dans la direction
135 Cell topNextLeftCell() const { return cell(CNP_TopNextLeft); }
136 //! Noeud devant à droite dans la direction
137 Cell topNextRightCell() const { return cell(CNP_TopNextRight); }
138 //! Noeud derrière à droite dans la direction
139 Cell topPreviousRightCell() const { return cell(CNP_TopPreviousRight); }
140 //! Noeud derrière à gauche dans la direction
141 Cell topPreviousLeftCell() const { return cell(CNP_TopPreviousLeft); }
142
143 //! Noeud devant à gauche dans la direction
144 CellLocalId topNextLeftCellId() const { return cellId(CNP_TopNextLeft); }
145 //! Noeud devant à droite dans la direction
146 CellLocalId topNextRightCellId() const { return cellId(CNP_TopNextRight); }
147 //! Noeud derrière à droite dans la direction
148 CellLocalId topPreviousRightCellId() const { return cellId(CNP_TopPreviousRight); }
149 //! Noeud derrière à gauche dans la direction
150 CellLocalId topPreviousLeftCellId() const { return cellId(CNP_TopPreviousLeft); }
151
152 private:
153
154 Node m_current;
155 Node m_previous;
156 Node m_next;
157 DirNodeCellIndex m_cell_index;
158};
159
160/*---------------------------------------------------------------------------*/
161/*---------------------------------------------------------------------------*/
162/*!
163 * \ingroup ArcaneCartesianMesh
164 * \brief Noeud avant et après un noeud suivant une direction.
165 *
166 * Les instances de cette classe sont temporaires et construites via
167 * NodeDirectionMng::dirNodeId().
168 */
169class ARCANE_CARTESIANMESH_EXPORT DirNodeLocalId
170{
171 friend NodeDirectionMng;
172
173 private:
174
175 typedef signed char IndexType;
176 static constexpr IndexType NULL_CELL = -1;
177
178 private:
179
180 // Seul NodeDirectionMng à le droit de construire un DirNode.
181 ARCCORE_HOST_DEVICE DirNodeLocalId(NodeLocalId current, NodeLocalId next, NodeLocalId prev,
182 DirNode::DirNodeCellIndex idx,
183 IndexedNodeCellConnectivityView view)
184 : m_current(current)
185 , m_previous(prev)
186 , m_next(next)
187 , m_cell_index(idx)
188 , m_view(view)
189 {}
190
191 public:
192
193 //! Maille avant
194 ARCCORE_HOST_DEVICE NodeLocalId previous() const { return m_previous; }
195 //! Maille avant
196 ARCCORE_HOST_DEVICE NodeLocalId previousId() const { return m_previous; }
197 //! Maille après
198 ARCCORE_HOST_DEVICE NodeLocalId next() const { return m_next; }
199 //! Maille après
200 ARCCORE_HOST_DEVICE NodeLocalId nextId() const { return m_next; }
201 /*!
202 * \brief Indice dans la liste des mailles de ce noeud d'une
203 * maille en fonction de sa position.
204 *
205 * Les valeurs possibles pour \a position sont données par l'énumération
206 * eCellNodePosition.
207 */
208 ARCCORE_HOST_DEVICE Int32 cellIndex(Int32 position) const { return m_cell_index[position]; }
209 /*!
210 * \brief Indice local d'une maille en fonction de sa position par rapport à ce noeud.
211 *
212 * Les valeurs possibles pour \a position sont données par l'énumération
213 * eCellNodePosition.
214 */
215 ARCCORE_HOST_DEVICE CellLocalId cellId(Int32 position) const
216 {
217 Int32 x = cellIndex(position);
218 return (x == NULL_CELL) ? CellLocalId(NULL_ITEM_LOCAL_ID) : m_view.cellId(m_current, x);
219 }
220
221 //! Noeud devant à gauche dans la direction
222 ARCCORE_HOST_DEVICE CellLocalId nextLeftCellId() const { return cellId(CNP_NextLeft); }
223 //! Noeud devant à droite dans la direction
224 ARCCORE_HOST_DEVICE CellLocalId nextRightCellId() const { return cellId(CNP_NextRight); }
225 //! Noeud derrière à droite dans la direction
226 ARCCORE_HOST_DEVICE CellLocalId previousRightCellId() const { return cellId(CNP_PreviousRight); }
227 //! Noeud derrière à gauche dans la direction
228 ARCCORE_HOST_DEVICE CellLocalId previousLeftCellId() const { return cellId(CNP_PreviousLeft); }
229
230 //! Noeud devant à gauche dans la direction
231 ARCCORE_HOST_DEVICE CellLocalId topNextLeftCellId() const { return cellId(CNP_TopNextLeft); }
232 //! Noeud devant à droite dans la direction
233 ARCCORE_HOST_DEVICE CellLocalId topNextRightCellId() const { return cellId(CNP_TopNextRight); }
234 //! Noeud derrière à droite dans la direction
235 ARCCORE_HOST_DEVICE CellLocalId topPreviousRightCellId() const { return cellId(CNP_TopPreviousRight); }
236 //! Noeud derrière à gauche dans la direction
237 ARCCORE_HOST_DEVICE CellLocalId topPreviousLeftCellId() const { return cellId(CNP_TopPreviousLeft); }
238
239 private:
240
241 NodeLocalId m_current;
242 NodeLocalId m_previous;
243 NodeLocalId m_next;
244 DirNode::DirNodeCellIndex m_cell_index;
245 IndexedNodeCellConnectivityView m_view;
246};
247
248/*---------------------------------------------------------------------------*/
249/*---------------------------------------------------------------------------*/
250/*!
251 * \ingroup ArcaneCartesianMesh
252 * \brief Infos sur les noeuds d'une direction spécifique X,Y ou Z
253 * d'un maillage structuré.
254 */
255class ARCANE_CARTESIANMESH_EXPORT NodeDirectionMng
256{
257 friend CartesianMeshImpl;
258 friend CartesianMeshPatch;
259 class Impl;
260 using IndexType = DirNode::IndexType;
261 using DirNodeCellIndex = DirNode::DirNodeCellIndex;
262
263 private:
264
265 struct ItemDirectionInfo
266 {
267 public:
268
269 /*!
270 * \brief Constructeur par défaut.
271 * \warning Les valeurs m_next_item et m_previous_item sont initialisées
272 * à nullptr.
273 */
274 ItemDirectionInfo() = default;
275 ItemDirectionInfo(Int32 next_lid, Int32 prev_lid)
276 : m_next_lid(next_lid)
277 , m_previous_lid(prev_lid)
278 {}
279
280 public:
281
282 //! entité après l'entité courante dans la direction
283 NodeLocalId m_next_lid;
284 //! entité avant l'entité courante dans la direction
285 NodeLocalId m_previous_lid;
286
287 public:
288
289 void setCellIndexes(IndexType idx[8])
290 {
291 for (int i = 0; i < 8; ++i)
292 m_cell_index.m_indexes[i] = idx[i];
293 }
294 DirNodeCellIndex m_cell_index;
295 };
296
297 public:
298
299 /*!
300 * \brief Créé une instance vide.
301 *
302 * L'instance n'est pas valide tant que _internalInit() n'a pas été appelé.
303 */
305
306 public:
307
308 //! Noeud direction correspondant au noeud \a n
310 {
311 return _node(n.localId());
312 }
313
314 //! Noeud direction correspondant au noeud \a n
315 DirNode node(NodeLocalId n) const
316 {
317 return _node(n.localId());
318 }
319
320 //! Noeud direction correspondant au noeud \a n
321 DirNode dirNode(NodeLocalId n) const
322 {
323 return _node(n.localId());
324 }
325
326 //! Noeud direction correspondant au noeud \a n
327 ARCCORE_HOST_DEVICE DirNodeLocalId dirNodeId(NodeLocalId n) const
328 {
329 return _dirNodeId(n);
330 }
331
332 //! Groupe de tous les noeuds dans la direction.
333 NodeGroup allNodes() const;
334
335 /*!
336 * \brief Groupe de tous les noeuds de recouvrement dans la direction.
337 *
338 * Un noeud de recouvrement est un noeud qui possède uniquement des mailles
339 * de recouvrement autour de lui.
340 *
341 * 0 1 2 3 4
342 * ┌───┬──┬──┬──┬──┐
343 * │ │ │ │ │ │
344 * │ ├──┼──┼──┼──┤
345 * │ │ │ │ │ │
346 * └───┴──┴──┴──┴──┘
347 *
348 * 0 : level -1
349 * 1 et 2 : Mailles de recouvrements (overallCells)
350 * 3 : Mailles externes (outerCells)
351 * 4 : Mailles internes (innerCells)
352 *
353 * La couche de mailles de recouvrements désigne la couche de mailles de même
354 * niveau autour du patch. Ces mailles peuvent appartenir à un ou plusieurs
355 * patchs.
356 */
357 NodeGroup overallNodes() const;
358
359 /*!
360 * \brief Groupe de tous les noeuds du patch dans la direction.
361 *
362 * Les noeuds du patch sont les noeuds n'ayant pas toutes ces mailles qui
363 * soient de recouvrement. TODO reformuler
364 * (`innerNodes() + outerNodes()` ou simplement `!overallNodes()`)
365 *
366 * \warning Les noeuds au bord du domaine (donc ayant que des mailles
367 * "outer") sont inclus dans ce groupe.
368 */
369 NodeGroup inPatchNodes() const;
370
371 /*!
372 * \brief Groupe de tous les noeuds internes dans la direction.
373 *
374 * Un noeud est considéré comme interne si son noeud
375 * avant ou après n'est pas nul.
376 */
377 NodeGroup innerNodes() const;
378
379 /*!
380 * \brief Groupe de tous les noeuds externes dans la direction.
381 *
382 * Un noeud est considéré comme externe si son noeud
383 * avant ou après est de recouvrement ou est nul (si l'on est au bord du
384 * domaine ou s'il n'y a pas de couches de mailles de recouvrements).
385 *
386 * \note Les noeuds entre patchs ne sont pas dupliquées. Donc certains noeuds
387 * de ce groupe peuvent être aussi dans un outerNodes() d'un autre patch.
388 */
389 NodeGroup outerNodes() const;
390
391 //! Noeud direction correspondant au noeud \a n.
393 {
394 return _node(n.localId());
395 }
396
397 //! Noeud direction correspondant au noeud \a n.
398 DirNode operator[](NodeLocalId n) const
399 {
400 return _node(n.localId());
401 }
402
403 //! Noeud direction correspondant à l'itérateur du noeud \a inode.
405 {
406 return _node(inode.itemLocalId());
407 }
408
409 //! Valeur de la direction
411 {
412 return m_direction;
413 }
414
415 protected:
416
417 /*!
418 * \internal
419 * \brief Calcule les informations sur les noeuds associées aux mailles de
420 * la direction \a cell_dm. \a all_nodes est le groupe de tous les noeuds des mailles
421 * gérées par \a cell_dm.
422 * Suppose que init() a été appelé.
423 */
424 void _internalComputeInfos(const CellDirectionMng& cell_dm, const NodeGroup& all_nodes,
425 const VariableCellReal3& cells_center);
426
427 void _internalComputeInfos(const CellDirectionMng& cell_dm, const NodeGroup& all_nodes);
428
429 /*!
430 * \internal
431 * Initialise l'instance.
432 */
433 void _internalInit(ICartesianMesh* cm, eMeshDirection dir, Integer patch_index);
434
435 /*!
436 * \internal
437 * Détruit les ressources associées à l'instance.
438 */
439 void _internalDestroy();
440
441 /*!
442 * \brief Redimensionne le conteneur contenant les \a ItemDirectionInfo.
443 *
444 * Cela invalide les instances courantes de NodeDirectionMng.
445 */
446 void _internalResizeInfos(Int32 new_size);
447
448 private:
449
450 SmallSpan<ItemDirectionInfo> m_infos_view;
451 NodeInfoListView m_nodes;
452 eMeshDirection m_direction;
453 IndexedNodeCellConnectivityView m_node_cell_view;
454 Impl* m_p;
455
456 private:
457
458 //! Noeud direction correspondant au noeud de numéro local \a local_id
459 DirNode _node(Int32 local_id) const
460 {
461 ItemDirectionInfo d = m_infos_view[local_id];
462 return DirNode(m_nodes[local_id], m_nodes[d.m_next_lid], m_nodes[d.m_previous_lid], d.m_cell_index);
463 }
464
465 //! Noeud direction correspondant au noeud de numéro local \a local_id
466 ARCCORE_HOST_DEVICE DirNodeLocalId _dirNodeId(NodeLocalId local_id) const
467 {
468 ItemDirectionInfo d = m_infos_view[local_id.localId()];
469 return DirNodeLocalId(local_id, d.m_next_lid, d.m_previous_lid, d.m_cell_index, m_node_cell_view);
470 }
471
472 void _computeNodeCellInfos(const CellDirectionMng& cell_dm,
473 const VariableCellReal3& cells_center);
474 void _computeNodeCellInfos() const;
475 void _filterNodes();
476};
477
478/*---------------------------------------------------------------------------*/
479/*---------------------------------------------------------------------------*/
480
481} // End namespace Arcane
482
483/*---------------------------------------------------------------------------*/
484/*---------------------------------------------------------------------------*/
485
486#endif
487
Infos sur les mailles d'une direction spécifique X,Y ou Z d'un maillage structuré.
Maille d'un maillage.
Definition Item.h:1214
Noeud avant et après un noeud suivant une direction.
__host__ __device__ CellLocalId nextLeftCellId() const
Noeud devant à gauche dans la direction.
__host__ __device__ CellLocalId topPreviousRightCellId() const
Noeud derrière à droite dans la direction.
__host__ __device__ NodeLocalId previousId() const
Maille avant.
__host__ __device__ CellLocalId topNextRightCellId() const
Noeud devant à droite dans la direction.
__host__ __device__ CellLocalId cellId(Int32 position) const
Indice local d'une maille en fonction de sa position par rapport à ce noeud.
__host__ __device__ CellLocalId topPreviousLeftCellId() const
Noeud derrière à gauche dans la direction.
__host__ __device__ Int32 cellIndex(Int32 position) const
Indice dans la liste des mailles de ce noeud d'une maille en fonction de sa position.
__host__ __device__ NodeLocalId nextId() const
Maille après.
__host__ __device__ NodeLocalId previous() const
Maille avant.
__host__ __device__ CellLocalId previousLeftCellId() const
Noeud derrière à gauche dans la direction.
__host__ __device__ CellLocalId topNextLeftCellId() const
Noeud devant à gauche dans la direction.
__host__ __device__ CellLocalId nextRightCellId() const
Noeud devant à droite dans la direction.
__host__ __device__ CellLocalId previousRightCellId() const
Noeud derrière à droite dans la direction.
__host__ __device__ NodeLocalId next() const
Maille après.
Noeud avant et après un noeud suivant une direction.
CellLocalId topNextRightCellId() const
Noeud devant à droite dans la direction.
NodeLocalId previousId() const
Maille avant.
CellLocalId previousLeftCellId() const
Noeud derrière à gauche dans la direction.
Cell cell(Int32 position) const
Maille en fonction de sa position par rapport à ce noeud.
CellLocalId previousRightCellId() const
Noeud derrière à droite dans la direction.
NodeLocalId nextId() const
Maille après.
CellLocalId topPreviousRightCellId() const
Noeud derrière à droite dans la direction.
CellLocalId topNextLeftCellId() const
Noeud devant à gauche dans la direction.
Cell previousLeftCell() const
Noeud derrière à gauche dans la direction.
Cell previousRightCell() const
Noeud derrière à droite dans la direction.
CellLocalId cellId(Int32 position) const
Indice local d'une maille en fonction de sa position par rapport à ce noeud.
CellLocalId nextLeftCellId() const
Noeud devant à gauche dans la direction.
CellLocalId nextRightCellId() const
Noeud devant à droite dans la direction.
Cell nextRightCell() const
Noeud devant à droite dans la direction.
Cell topNextLeftCell() const
Noeud devant à gauche dans la direction.
Cell topPreviousRightCell() const
Noeud derrière à droite dans la direction.
Cell topPreviousLeftCell() const
Noeud derrière à gauche dans la direction.
Int32 cellIndex(Int32 position) const
Indice dans la liste des mailles de ce noeud d'une maille en fonction de sa position.
Cell topNextRightCell() const
Noeud devant à droite dans la direction.
CellLocalId topPreviousLeftCellId() const
Noeud derrière à gauche dans la direction.
Cell nextLeftCell() const
Noeud devant à gauche dans la direction.
Interface d'un maillage cartésien.
Int32 itemLocalId() const
localId() de l'entité courante.
constexpr Int32 localId() const
Identifiant local de l'entité dans le sous-domaine du processeur.
Definition Item.h:219
DirNode operator[](NodeLocalId n) const
Noeud direction correspondant au noeud n.
DirNode dirNode(NodeLocalId n) const
Noeud direction correspondant au noeud n.
DirNode operator[](NodeEnumerator inode) const
Noeud direction correspondant à l'itérateur du noeud inode.
NodeDirectionMng()
Créé une instance vide.
DirNode operator[](Node n)
Noeud direction correspondant au noeud n.
DirNode node(NodeLocalId n) const
Noeud direction correspondant au noeud n.
eMeshDirection direction() const
Valeur de la direction.
DirNode node(Node n) const
Noeud direction correspondant au noeud n.
__host__ __device__ DirNodeLocalId dirNodeId(NodeLocalId n) const
Noeud direction correspondant au noeud n.
Vue sur les informations des noeuds.
Noeud d'un maillage.
Definition Item.h:582
Vue d'un tableau d'éléments de type T.
Definition Span.h:801
ItemEnumeratorT< Node > NodeEnumerator
Enumérateurs sur des noeuds.
Definition ItemTypes.h:254
ItemGroupT< Node > NodeGroup
Groupe de noeuds.
Definition ItemTypes.h:167
MeshVariableScalarRefT< Cell, Real3 > VariableCellReal3
Grandeur au centre des mailles de type coordonnées.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 Integer
Type représentant un entier.
eMeshDirection
Type de la direction pour un maillage structuré
std::int32_t Int32
Type entier signé sur 32 bits.