Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
DynamicMeshIncrementalBuilder.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/* DynamicMeshIncrementalBuilder.h (C) 2000-2025 */
9/* */
10/* Construction of a mesh incrementally. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_MESH_DYNAMICMESHINCREMENTALBUILDER_H
13#define ARCANE_MESH_DYNAMICMESHINCREMENTALBUILDER_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/HashTableMap.h"
18#include "arcane/utils/TraceAccessor.h"
19
20#include "arcane/core/IItemFamilyNetwork.h"
22#include "arcane/core/ItemInternal.h"
23
24#include "arcane/mesh/DynamicMeshKindInfos.h"
25#include "arcane/mesh/ItemData.h"
26#include "arcane/mesh/FullItemInfo.h"
27
28#include <list>
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
33namespace Arcane
34{
35class SerializeBuffer;
36}
37
38namespace Arcane::mesh
39{
40
41/*---------------------------------------------------------------------------*/
42/*---------------------------------------------------------------------------*/
43
44class DynamicMesh;
49
50/*---------------------------------------------------------------------------*/
51/*---------------------------------------------------------------------------*/
56: public TraceAccessor
57{
58 public:
59
63
64 public:
65
66 // Add list of mesh and graph items
67
68 void addCells(Integer nb_cell, Int64ConstArrayView cell_infos,
69 Integer sub_domain_id, Int32ArrayView cells,
70 bool allow_build_face = true);
71 void addCells2(Integer nb_cell, Int64ConstArrayView cell_infos,
72 Integer sub_domain_id, Int32ArrayView cells,
73 bool allow_build_face = true);
74 void addCells3(Integer nb_cell, Int64ConstArrayView cell_infos,
75 Integer sub_domain_id, Int32ArrayView cells,
76 bool allow_build_face = true);
77 void addFaces(Integer nb_face, Int64ConstArrayView face_infos,
78 Integer sub_domain_id, Int32ArrayView faces);
79 void addFaces2(Integer nb_face, Int64ConstArrayView face_infos,
80 Integer sub_domain_id, Int32ArrayView faces);
81 void addFaces3(Integer nb_face, Int64ConstArrayView face_infos,
82 Integer sub_domain_id, Int32ArrayView faces);
83 void addEdges(Integer nb_edge, Int64ConstArrayView edge_infos,
84 Integer sub_domain_id, Int32ArrayView edges);
85 void addEdges2(Integer nb_edge, Int64ConstArrayView edge_infos,
86 Integer sub_domain_id, Int32ArrayView edges);
87 void addEdges3(Integer nb_edge, Int64ConstArrayView edge_infos,
88 Integer sub_domain_id, Int32ArrayView edges);
89 void addNodes(Int64ConstArrayView nodes_uid,
90 Integer sub_domain_id, Int32ArrayView nodes);
91 void addNodes2(Int64ConstArrayView nodes_uid,
92 Integer sub_domain_id, Int32ArrayView nodes);
93
94 void addItems(ItemDataList& item_info_list);
95 void addItems(ItemDataList& item_info_list, ItemDataList& item_relation_info_list);
96 void addRelations(ItemDataList& item_relation_list);
97
98 void addFamilyItems(ItemData& item_info);
99
101 void addParentCells(const ItemVectorView& items);
103 void addParentItems(const ItemVectorView& items, const eItemKind submesh_kind);
106 void addHChildrenCells(Cell hParent_cell, Integer nb_cell, Int64ConstArrayView cells_infos,
107 Int32 sub_domain_id, Int32ArrayView cells,
108 bool allow_build_face);
110 void addGhostLayers(bool is_allocate);
112 void addGhostChildFromParent(Array<Int64>& ghost_cell_to_refine);
113
114 void removeGhostCells();
115 void removeNeedRemoveMarkedCells();
116
117 public:
118
120
121 void readFromDump();
122
124
125 void setConnectivity(Integer c);
126
129
130 public:
131
132 void printInfos();
133 void printStats(Int32 level = TraceMessage::DEFAULT_LEVEL);
134
135 public:
136
137 ItemInternalMap& itemsMap(eItemKind ik);
138 DynamicMesh* mesh() { return m_mesh; }
139 bool isVerbose() const { return m_verbose; }
140 bool hasEdge() const { return m_has_edge; }
141
142 OneMeshItemAdder* oneMeshItemAdder() const { return m_one_mesh_item_adder; }
143
144 private:
145
146 struct NodeInFace;
147
148 struct NodeInFacePtr
149 {
150 NodeInFacePtr(const Int64& node_uid)
151 : m_ptr(std::make_shared<NodeInFace>(node_uid))
152 {}
153 bool operator<(const NodeInFacePtr& a) const { return (*m_ptr) < (*a.m_ptr); }
154 NodeInFace* operator->() { return m_ptr.operator->(); }
155 const NodeInFace* operator->() const { return m_ptr.operator->(); }
156 bool operator==(const NodeInFacePtr& a) const { return (*m_ptr) == (*a.m_ptr); }
157 std::shared_ptr<NodeInFace> m_ptr;
158 };
159
160 struct NodeInFace
161 {
162 // typedef std::shared_ptr<NodeInFace> NodeInFacePtr;
163 // typedef std::set<NodeInFacePtr, std::function<bool(const NodeInFacePtr&, const NodeInFacePtr&)>> NodeInFaceSet; // Does not work bad function call exception (gcc 4.7.2 pb ?). Need to define NodeInFacePtr class
164 // typedef std::set<NodeInFacePtr> NodeInFaceSet;
165 typedef std::list<NodeInFacePtr> NodeInFaceSet;
166
167 NodeInFace(const Int64& node_uid)
168 : m_uid(node_uid)
169 , m_face_uid(NULL_ITEM_ID)
170 {}
171 // , m_next_node_set([](const NodeInFacePtr& a, const NodeInFacePtr& b){return (*a) < (*b);}){} // Does not work (gcc 4.7.2 pb ?). Need to define NodeInFacePtr class
172
173 friend bool operator<(const NodeInFace& a, const NodeInFace& nif)
174 {
175 return a.m_uid < nif.m_uid;
176 }
177 friend bool operator==(const NodeInFace& a, const NodeInFace& b)
178 {
179 return a.m_uid == b.m_uid;
180 }
181
182 Int64 faceUid() const { return m_face_uid; }
183 void setFaceUid(Int64 face_uid) { m_face_uid = face_uid; }
184
185 const NodeInFaceSet& nextNodeSet() const { return m_next_node_set; }
186 NodeInFaceSet& nextNodeSet() { return m_next_node_set; }
187 // void setNextNode(const NodeInFacePtr & next_node) {m_next_node_set.push_back(next_node);}
188
189 void print()
190 {
191 std::cout << "Node " << m_uid << " has set " << &m_next_node_set << " containing nodes : " << std::endl;
192 for (auto node : m_next_node_set) {
193 node->print();
194 }
195 }
196
197 public: //for DEBUG
198
199 // private:
200 Int64 m_uid;
201 Int64 m_face_uid;
202 NodeInFaceSet m_next_node_set;
203 };
204 // typedef NodeInFace::NodeInFacePtr NodeInFacePtr;
205 typedef NodeInFace::NodeInFaceSet NodeInFaceSet;
206
207 private:
208
209 void _printCellFaceInfos(ItemInternal* cell, const String& str);
210
211 void _removeNeedRemoveMarkedItems(ItemInternalMap& map, UniqueArray<Int32>& items_local_id);
212
213 void _fillFaceInfo(Integer& nb_face, Integer nb_cell, Int64Array& faces_infos, Int64ConstArrayView cells_infos, std::map<Int64, Int64SharedArray>& cell_to_face_connectivity_info);
214 void _fillEdgeInfo(Integer& nb_edge, Integer nb_face, Int64Array& edges_infos, Int64ConstArrayView faces_infos, std::map<std::pair<Int64, Int64>, Int64>& edge_uid_map);
215 void _fillNodeInfo(Integer& nb_node, Integer nb_face, Int64Array& nodes_infos, Int64ConstArrayView faces_infos);
216 void _fillNodeInfoFromEdge(Integer& nb_node, Integer nb_edge, Int64Array& nodes_infos, Int64ConstArrayView edges_infos);
217
218 void _fillCellInfo2(Integer nb_cell, Int64ConstArrayView cells_infos, Int64Array& cell_infos2, Integer& nb_face, Int64Array& faces_infos, Int64Array& node_uids, bool allow_build_face);
219 void _fillFaceInfo2(Integer nb_face, Int64ConstArrayView faces_infos, Int64ArrayView face_info2, Int64Array& node_uids);
220 void _fillEdgeInfo2(Integer nb_edge, Int64ConstArrayView edges_infos, Int64ArrayView edge_info2, Int64Array& node_uids);
221
222 void _fillEdgeNewInfoNew(Integer nb_edge, Int64ConstArrayView edges_infos, Int64ArrayView edge_new_infos);
223 void _fillNodeNewInfo(Int64ConstArrayView node_uids, Int64ArrayView node_infos2);
224 void _fillCellNewInfoNew(Integer nb_cell, Int64ConstArrayView cells_infos, Int64Array& cell_infos2, const std::map<Int64, Int64SharedArray>& cell_to_face_connectivity_info, const std::map<std::pair<Int64, Int64>, Int64>& edge_uid_map);
225 void _fillFaceNewInfoNew(Integer nb_face, Int64ConstArrayView faces_infos, Int64Array& face_infos2, const std::map<std::pair<Int64, Int64>, Int64>& edge_uid_map);
226 void _fillItemInfo2(ItemDataList& item_data_list, Int64ConstArrayView cells_infos);
227
228 void _initNodeRelationInfo(ItemData& source_item_relation_data, const ItemData& target_item_dependencies_data, Int64ConstArrayView faces_info);
229 void _initEdgeRelationInfo(ItemData& source_item_relation_data, const ItemData& target_item_dependencies_data, Int64ConstArrayView faces_info);
230 void _initFaceRelationInfo(ItemData& source_item_relation_data, const ItemData& target_item_dependencies_data, Int64ConstArrayView faces_info);
231 void _appendNodeRelationInfo(ItemData& source_item_relation_data, const ItemData& target_item_dependencies_data, Int64ConstArrayView faces_info);
232 void _appendEdgeRelationInfo(ItemData& source_item_relation_data, const ItemData& target_item_dependencies_data, Int64ConstArrayView faces_info);
233 void _appendFaceRelationInfo(ItemData& source_item_relation_data, const ItemData& target_item_dependencies_data, Int64ConstArrayView faces_info);
234 void _fillNodeRelationInfo(ItemData& source_item_relation_data, const ItemData& target_item_dependencies_data, Int64ConstArrayView nodes_info, bool is_source_item_relation_data_emtpy);
235 void _fillEdgeRelationInfo(ItemData& source_item_relation_data, const ItemData& target_item_dependencies_data, Int64ConstArrayView edges_info, bool is_source_item_relation_data_emtpy);
236 void _fillFaceRelationInfo(ItemData& source_item_relation_data, const ItemData& target_item_dependencies_data, Int64ConstArrayView faces_info, bool is_source_item_relation_data_emtpy);
237 void _fillItemRelationInfo(ItemData& source_item_relation_data, const ItemData& target_item_dependencies_data, Int64ConstArrayView source_item_types, bool is_source_item_relation_data_emtpy);
238 void _initEmptyRelationInfo(Int64Array& source_relation_info, std::map<Int64, Int64SharedArray>& source_to_target_uids, Int64ConstArrayView source_item_uids_and_types,
239 Integer approx_relation_size,
240 IItemFamily const* target_family);
241 void _appendInitializedRelationInfo(Int64Array& source_relation_info, std::map<Int64, Int64SharedArray>& source_to_target_uids, Int64ConstArrayView source_item_uids_and_types,
242 Integer approx_relation_size,
243 IItemFamily const* target_family);
244
245 Int64 _findFaceUniqueId(Int64ConstArrayView work_face_sorted_nodes, NodeInFaceSet& face_nodes_set);
246 Int64 _findFaceInFaceNodesSet(const NodeInFaceSet& face_nodes_set, Integer index, Int64ConstArrayView face_nodes, NodeInFacePtr node);
247 void _addFaceNodes(NodeInFaceSet& face_nodes_set, Int64ConstArrayView face_nodes, Int64 face_uid);
248 void _addFaceInFaceNodesSet(NodeInFaceSet& face_nodes_set, Integer index, Int64ConstArrayView face_nodes, NodeInFacePtr node, Int64 face_uid);
249 NodeInFacePtr& _insertNode(NodeInFaceSet& face_nodes_set, Int64 inserted_node_uid);
250 void _addItemsOrRelations(ItemDataList& info_list, IItemFamilyNetwork::eSchedulingOrder family_graph_traversal_order);
251
252 private:
253
255 ItemTypeMng* m_item_type_mng = nullptr;
256
258 bool m_has_edge = false;
259
262
263 bool m_verbose = false;
264
268 FaceUniqueIdBuilder* m_face_unique_id_builder = nullptr;
269 EdgeUniqueIdBuilder* m_edge_unique_id_builder = nullptr;
270
273};
274
275/*---------------------------------------------------------------------------*/
276/*---------------------------------------------------------------------------*/
277
278} // End namespace Arcane::mesh
279
280/*---------------------------------------------------------------------------*/
281/*---------------------------------------------------------------------------*/
282
283#endif
Declarations of Arcane's general types.
Base class for 1D data vectors.
Cell of a mesh.
Definition Item.h:1300
Interface of an entity family.
Definition IItemFamily.h:83
Internal structure of a mesh entity.
Mesh entity type manager.
Definition ItemTypeMng.h:66
View on a vector of entities.
Implementation of a buffer for serialization.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
1D data vector with value semantics (STL style).
void addNodes2(Int64ConstArrayView nodes_uid, Integer sub_domain_id, Int32ArrayView nodes)
Ajoute des noeuds au maillage actuel. Utilise l'ajout d'item générique basé sur dépendances entre fam...
void computeFacesUniqueIds()
Calculates the unique IDs for each face.
void setConnectivity(Integer c)
Sets the active connectivity for the associated mesh.
void addParentCells(const ItemVectorView &items)
Add to the current mesh items coming from a parent mesh.
void addCells(Integer nb_cell, Int64ConstArrayView cell_infos, Integer sub_domain_id, Int32ArrayView cells, bool allow_build_face=true)
Adds cells to the current mesh.
void _initFaceRelationInfo(ItemData &source_item_relation_data, const ItemData &target_item_dependencies_data, Int64ConstArrayView faces_info)
Initializes face relation info.
void addParentItems(const ItemVectorView &items, const eItemKind submesh_kind)
Add to the current mesh items coming from a parent mesh.
OneMeshItemAdder * m_one_mesh_item_adder
Mesh building utilities.
void _fillFaceInfo(Integer &nb_face, Integer nb_cell, Int64Array &faces_infos, Int64ConstArrayView cells_infos, std::map< Int64, Int64SharedArray > &cell_to_face_connectivity_info)
Adds cells to the current mesh.
Int64 m_face_uid_pool
uniqueId() number used for generating faces
void resetAfterDeallocate()
Resets the structures to allow for a new allocation.
void addGhostChildFromParent(Array< Int64 > &ghost_cell_to_refine)
AMR.
void addEdges2(Integer nb_edge, Int64ConstArrayView edge_infos, Integer sub_domain_id, Int32ArrayView edges)
Adds edges to the current mesh. Uses generic item addition based on family dependencies.
Int64 m_edge_uid_pool
uniqueId() number used for generating edges
void addItems(ItemDataList &item_info_list)
Ajout générique d'items d'un ensemble de famille pour lesquelles on fournit un ItemData.
void addNodes(Int64ConstArrayView nodes_uid, Integer sub_domain_id, Int32ArrayView nodes)
Ajoute des noeuds au maillage actuel.
void addFaces(Integer nb_face, Int64ConstArrayView face_infos, Integer sub_domain_id, Int32ArrayView faces)
Ajoute des faces au maillage actuel.
void addEdges(Integer nb_edge, Int64ConstArrayView edge_infos, Integer sub_domain_id, Int32ArrayView edges)
Adds edges to the current mesh.
GhostLayerBuilder * m_ghost_layer_builder
Utility to build ghost elements.
void addHChildrenCells(Cell hParent_cell, Integer nb_cell, Int64ConstArrayView cells_infos, Int32 sub_domain_id, Int32ArrayView cells, bool allow_build_face)
Ajoute des mailles au maillage actuel.
bool m_has_edge
Info on the presence of an edge (accelerates access to general connectivity).
void addFamilyItems(ItemData &item_info)
Ajout générique d'items d'une famille, décrite par son ItemInfo.
DynamicMeshIncrementalBuilder(DynamicMesh *mesh)
Constructs an instance for the mesh mesh.
void addCells3(Integer nb_cell, Int64ConstArrayView cell_infos, Integer sub_domain_id, Int32ArrayView cells, bool allow_build_face=true)
Adds cells to the current mesh. Uses generic item addition based on family dependencies.
void addFaces2(Integer nb_face, Int64ConstArrayView face_infos, Integer sub_domain_id, Int32ArrayView faces)
Ajoute des faces au maillage actuel. Utilise l'ajout d'item générique basé sur dépendances entre fami...
Integer m_connectivity
Connectivity info of the current mesh.
Implementation of a mesh.
Definition DynamicMesh.h:98
Construction of ghost layers.
Construction of ghost layers.
Construction of ghost layers.
Associative array of ItemInternal.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Array< Int64 > Int64Array
Dynamic one-dimensional array of 64-bit integers.
Definition UtilsTypes.h:125
ArrayView< Int64 > Int64ArrayView
C equivalent of a 1D array of 64-bit integers.
Definition UtilsTypes.h:451
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
ConstArrayView< Int64 > Int64ConstArrayView
C equivalent of a 1D array of 64-bit integers.
Definition UtilsTypes.h:480
ArrayView< Int32 > Int32ArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:453
eItemKind
Mesh entity type.
std::int32_t Int32
Signed integer type of 32 bits.