Arcane  4.1.11.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ParallelAMRConsistency.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 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/* ParallelAMRConsistency.h (C) 2000-2024 */
9/* */
10/* Management of AMR consistency in parallel. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_MESH_PARALLELAMRCONSISTENCY_H
13#define ARCANE_MESH_PARALLELAMRCONSISTENCY_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/String.h"
18#include "arcane/utils/HashTableMap.h"
19#include "arcane/utils/Real3.h"
20
21#include "arcane/core/IMesh.h"
22#include "arcane/core/ItemGroup.h"
23#include "arcane/core/Item.h"
24#include "arcane/core/VariableTypes.h"
25
26#include "arcane/mesh/DynamicMeshKindInfos.h"
27
28#include "arcane/utils/PerfCounterMng.h"
29
30#include <unordered_set>
31#include <unordered_map>
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
36namespace Arcane::mesh
37{
38
39/*---------------------------------------------------------------------------*/
40/*---------------------------------------------------------------------------*/
42
44{
45 public:
46
47 Integer size() const
48 {
49 return m_nodes_unique_id.size();
50 }
51 void add(ItemUniqueId node_unique_id)
52 {
53 m_nodes_unique_id.add(node_unique_id);
54 }
55 void set(Integer i, ItemUniqueId node_unique_id)
56 {
57 m_nodes_unique_id[i] = node_unique_id;
58 }
59
60 public:
61
62 SharedArray<ItemUniqueId> m_nodes_unique_id;
63};
64
65/*---------------------------------------------------------------------------*/
66/*---------------------------------------------------------------------------*/
67
68class NodeInfo
69{
70 public:
71
72 NodeInfo()
73 : m_unique_id(NULL_ITEM_ID)
74 , m_owner(A_NULL_RANK)
75 {
76 }
77 NodeInfo(ItemUniqueId node_uid, Integer aowner)
78 : m_unique_id(node_uid)
79 , m_owner(aowner)
80 {
81 }
82
83 public:
84
85 ItemUniqueId uniqueId() const
86 {
87 return m_unique_id;
88 }
89 void addConnectedFace(ItemUniqueId uid)
90 {
91 for (Integer i = 0, is = m_connected_active_faces.size(); i < is; ++i)
92 if (m_connected_active_faces[i] == uid)
93 return;
95 }
96 void setCoord(Real3 coord)
97 {
98 m_coord = coord;
99 }
100 Real3 getCoord() const
101 {
102 return m_coord;
103 }
104 Integer owner() const
105 {
106 return m_owner;
107 }
108
109 private:
110
117
118 public:
119
122};
123
124/*---------------------------------------------------------------------------*/
125/*---------------------------------------------------------------------------*/
132class FaceInfo
133{
134 public:
135
136 FaceInfo()
137 : m_unique_id(NULL_ITEM_ID)
138 , m_owner(A_NULL_RANK)
139 , m_nb_node(0)
140 , m_data_index(-1)
141 , m_mng(0)
142 {
143 }
144 FaceInfo(
145 ItemUniqueId unique_id,
146 ItemUniqueId cell_unique_id,
147 Integer nb_node,
148 Integer owner,
149 Integer data_index,
150 FaceInfoMng* mng)
151 : m_unique_id(unique_id)
152 , m_cell_unique_id(cell_unique_id)
153 , m_owner(owner)
154 , m_nb_node(nb_node)
155 , m_data_index(data_index)
156 , m_mng(mng)
157 {
158 }
159
160 public:
161
162 ItemUniqueId uniqueId() const
163 {
164 return m_unique_id;
165 }
166 ItemUniqueId cellUniqueId() const
167 {
168 return m_cell_unique_id;
169 }
170 Integer nbNode() const
171 {
172 return m_nb_node;
173 }
174 ItemUniqueId nodeUniqueId(Integer i) const
175 {
176 return m_mng->m_nodes_unique_id[m_data_index + i];
177 }
178 void setNodeUniqueId(Integer i, const ItemUniqueId& uid)
179 {
180 m_mng->m_nodes_unique_id[m_data_index + i] = uid;
181 }
182 Integer owner() const
183 {
184 return m_owner;
185 }
186 void setCenter(Real3 center)
187 {
188 m_center = center;
189 }
190 Real3 center() const
191 {
192 return m_center;
193 }
194 Integer getDataIndex()
195 {
196 return m_data_index;
197 }
198
199 private:
200
201 ItemUniqueId m_unique_id;
202 ItemUniqueId m_cell_unique_id;
203 Integer m_owner;
204 Integer m_nb_node;
205 Real3 m_center;
206
207 public:
208
209 Integer m_data_index;
210 FaceInfoMng* m_mng;
211};
212
213/*---------------------------------------------------------------------------*/
214/*---------------------------------------------------------------------------*/
221class FaceInfo2
222{
223 public:
224
225 FaceInfo2()
226 : m_unique_id(NULL_ITEM_ID)
227 , m_owner(A_NULL_RANK)
228 {}
229 FaceInfo2(ItemUniqueId unique_id, Integer aowner)
230 : m_unique_id(unique_id)
231 , m_owner(aowner)
232 {}
233
234 public:
235
236 ItemUniqueId uniqueId() const
237 {
238 return m_unique_id;
239 }
240 Integer owner() const
241 {
242 return m_owner;
243 }
244 void setCenter(Real3 center)
245 {
246 m_center = center;
247 }
248 Real3 center() const
249 {
250 return m_center;
251 }
252
253 private:
254
255 ItemUniqueId m_unique_id;
256 Int32 m_owner;
257 Real3 m_center;
258};
259
260/*---------------------------------------------------------------------------*/
261/*---------------------------------------------------------------------------*/
262
264: public TraceAccessor
265{
266 public:
267
268 typedef HashTableMapT<ItemUniqueId, NodeInfo> NodeInfoList;
269 typedef HashTableMapT<ItemUniqueId, FaceInfo> FaceInfoMap;
270 typedef HashTableMapT<ItemUniqueId, FaceInfo2> FaceInfoMap2;
271 typedef HashTableMapEnumeratorT<ItemUniqueId, NodeInfo> NodeInfoListEnumerator;
272 typedef HashTableMapEnumeratorT<ItemUniqueId, FaceInfo2> FaceInfo2MapEnumerator;
273
274 typedef std::unordered_set<Int64> ItemUidSet;
275 typedef std::unordered_map<Int64, Item> ItemMap;
276 typedef std::pair<Int64, Item> ItemMapValue;
277
278#ifdef ACTIVATE_PERF_COUNTER
279 struct PerfCounter
280 {
281 typedef enum
282 {
283 INIT,
284 COMPUTE,
285 GATHERFACE,
286 UPDATE,
287 REHASH,
288 ENDUPDATE,
289 NbCounters
290 } eType;
291
292 static const std::string m_names[NbCounters];
293 };
294#endif
295 public:
296
298
299 public:
300
301 void init();
302 void invalidate();
303 bool isUpdated() const
304 {
305 return m_is_updated;
306 }
307 void update()
308 {
309 if (!m_is_updated)
310 init();
311 }
312 void makeNewItemsConsistent(NodeMapCoordToUid& node_finder, FaceMapCoordToUid& face_finder);
313 void makeNewItemsConsistent2(MapCoordToUid& node_finder, MapCoordToUid& face_finder);
314 void changeOwners(Int64UniqueArray linked_cells, Int32UniqueArray linked_owers);
315 void changeOwnersOld();
316
317#ifdef ACTIVATE_PERF_COUNTER
318 PerfCounterMng<PerfCounter>& getPerfCounter()
319 {
320 return m_perf_counter;
321 }
322#endif
323 private:
324
325 IMesh* m_mesh;
326 VariableNodeReal3 m_nodes_coord;
327 FaceInfoMng m_face_info_mng;
328 NodeInfoList m_nodes_info;
329 NodeInfoList m_active_nodes;
330 FaceInfoMap m_active_faces;
331 FaceInfoMap2 m_active_faces2;
332 String m_active_face_name;
333 FaceGroup m_active_face_group;
334
335 bool m_is_updated;
336 UniqueArray<Int64> m_shared_face_uids;
337 UniqueArray<Int64> m_connected_shared_face_uids;
338
339#ifdef ACTIVATE_PERF_COUNTER
340 PerfCounterMng<PerfCounter> m_perf_counter;
341#endif
342 private:
343
344 bool _isInsideFace(const FaceInfo& face, Real3 point);
345
347 ConstArrayView<ItemUniqueId> nodes_to_send,
348 FaceInfoMap& face_map,
349 MapCoordToUid& node_finder,
350 MapCoordToUid& face_finder,
351 ItemUidSet& updated_face_uids,
352 ItemUidSet& updated_node_uids);
353
354 void _update(Array<ItemUniqueId>& nodes_unique_id, NodeInfoList const& nodes_info);
355
357 ConstArrayView<ItemUniqueId> faces_to_send,
358 NodeInfoList& node_map,
359 FaceInfoMap2& face_map,
360 MapCoordToUid& node_finder,
361 MapCoordToUid& face_finder);
362
363 void _gatherAllNodesInfo();
364
365 void _printFaces(std::ostream& o, FaceInfoMap& face_map);
366
367 void _addFaceToList(Face face, FaceInfoMap& face_map);
368
369 void _addFaceToList2(Face face, FaceInfoMap2& face_map);
370 void _addNodeToList(Node node, NodeInfoList& node_map);
371 bool _hasSharedNodes(Face face);
372};
373
374/*---------------------------------------------------------------------------*/
375/*---------------------------------------------------------------------------*/
376
377} // End namespace Arcane::mesh
378
379/*---------------------------------------------------------------------------*/
380/*---------------------------------------------------------------------------*/
381
382#endif
Tableau d'items de types quelconques.
Vue constante d'un tableau de type T.
Face d'une maille.
Definition Item.h:964
Enumerateur sur un HashTableMap.
Table de hachage pour tableaux associatifs.
Identifiant unique d'une entité.
Noeud d'un maillage.
Definition Item.h:582
Classe gérant un vecteur de réel de dimension 3.
Definition Real3.h:132
Vecteur 1D de données avec sémantique par référence.
Chaîne de caractères unicode.
TraceAccessor(ITraceMng *m)
Construit un accesseur via le gestionnaire de trace m.
Vecteur 1D de données avec sémantique par valeur (style STL).
Info on an active Face.
structure for searching for a node based on its coordinates The hashing key is the geometric position...
Integer m_owner
owner of the node
ItemUniqueId m_unique_id
Node unique ID.
Real3 m_coord
Coordinates of the node.
SharedArray< ItemUniqueId > m_connected_active_faces
List of uniqueId() of active faces to which this node can be connected.
void makeNewItemsConsistent2(MapCoordToUid &node_finder, MapCoordToUid &face_finder)
Determines the faces to send to neighbors.
void makeNewItemsConsistent(NodeMapCoordToUid &node_finder, FaceMapCoordToUid &face_finder)
Determines the faces to send to neighbors.
void _gatherFaces(ConstArrayView< ItemUniqueId > faces_to_send, ConstArrayView< ItemUniqueId > nodes_to_send, FaceInfoMap &face_map, MapCoordToUid &node_finder, MapCoordToUid &face_finder, ItemUidSet &updated_face_uids, ItemUidSet &updated_node_uids)
void _gatherItems(ConstArrayView< ItemUniqueId > nodes_to_send, ConstArrayView< ItemUniqueId > faces_to_send, NodeInfoList &node_map, FaceInfoMap2 &face_map, MapCoordToUid &node_finder, MapCoordToUid &face_finder)
ItemGroupT< Face > FaceGroup
Groupe de faces.
Definition ItemTypes.h:178
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Grandeur au noeud de type coordonnées.
UniqueArray< Int64 > Int64UniqueArray
Tableau dynamique à une dimension d'entiers 64 bits.
Definition UtilsTypes.h:339
Int32 Integer
Type représentant un entier.
UniqueArray< Int32 > Int32UniqueArray
Tableau dynamique à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:341
std::int32_t Int32
Type entier signé sur 32 bits.