Arcane  4.2.3.0
Developer documentation
Loading...
Searching...
No Matches
OneMeshItemAdder.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/* OneMeshItemAdder.h (C) 2000-2025 */
9/* */
10/* Cell creation utility */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_MESH_ONEITEMADDER_H
13#define ARCANE_MESH_ONEITEMADDER_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/TraceAccessor.h"
18
19#include "arcane/core/Item.h"
20#include "arcane/core/NodesOfItemReorderer.h"
21
22#include "arcane/mesh/MeshGlobal.h"
23#include "arcane/mesh/FullItemInfo.h"
24#include "arcane/mesh/CellFamily.h"
25#include "arcane/mesh/NodeFamily.h"
26#include "arcane/mesh/FaceFamily.h"
27#include "arcane/mesh/EdgeFamily.h"
28#include "arcane/mesh/MeshInfos.h"
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
33namespace Arcane::mesh
34{
35
36/*---------------------------------------------------------------------------*/
37/*---------------------------------------------------------------------------*/
38
39class DynamicMesh;
41
42/*---------------------------------------------------------------------------*/
43/*---------------------------------------------------------------------------*/
44
45class OneMeshItemAdder
46: public TraceAccessor
47{
48 private:
49
50 // Class used to make FullCellInfo data
51 // and fragmented cell description data compatible
52 class CellInfoProxy;
53
54 public:
55
56 explicit OneMeshItemAdder(DynamicMeshIncrementalBuilder* mesh_builder);
57 ~OneMeshItemAdder() {}
58
59 public:
60
61 ItemInternal* addOneNode(Int64 node_uid, Int32 owner);
62
64 Int64 face_uid,
65 Int32 owner_rank,
66 Int64ConstArrayView nodes_uid);
67
68 ItemInternal* addOneEdge(Int64 edge_uid,
69 Int32 sub_domain_id,
70 Int64ConstArrayView nodes_uid);
71
72 ItemInternal* addOneCell(ItemTypeId type_id,
73 Int64 cell_uid,
74 Int32 sub_domain_id,
75 Int64ConstArrayView nodes_uid,
76 bool allow_build_face);
77
79 const eItemKind submesh_kind,
80 const bool fatal_on_existing_item = true);
81
82 ItemInternal* addOneCell(const FullCellInfo& cell_info);
83
84 // NOTE GG: Previously more used
85 ARCANE_DEPRECATED_REASON("Y2022: Use addOneItem2() instead")
86 ItemInternal* addOneItem(IItemFamily* family,
87 IItemFamilyModifier* family_modifier,
88 ItemTypeId type_id,
89 Int64 item_uid,
90 Int32 item_owner,
91 Int32 sub_domain_id,
92 Integer nb_connected_family,
93 Int64ConstArrayView connectivity_info);
94
95 ItemInternal* addOneItem2(IItemFamily* family,
96 IItemFamilyModifier* family_modifier,
97 ItemTypeId type_id,
98 Int64 item_uid,
99 Int32 item_owner,
100 Int32 sub_domain_id,
101 Integer nb_connected_family,
102 Int64ConstArrayView connectivity_info);
103
104 Integer nbNode() const { return m_mesh_info.getNbNode(); }
105 Integer nbFace() const { return m_mesh_info.getNbFace(); }
106 Integer nbCell() const { return m_mesh_info.getNbCell(); }
107 Integer nbEdge() const { return m_mesh_info.getNbEdge(); }
108
110 void addBulkMeshInfos(Integer nb_node, Integer nb_edge, Integer nb_face, Integer nb_cell)
111 {
112 m_mesh_info.nbNode() += nb_node;
113 m_mesh_info.nbEdge() += nb_edge;
114 m_mesh_info.nbFace() += nb_face;
115 m_mesh_info.nbCell() += nb_cell;
116 }
117
118 void setNextFaceUid(Int64 face_uid) { m_next_face_uid = face_uid; }
119 void setNextEdgeUid(Int64 edge_uid) { m_next_edge_uid = edge_uid; }
120
121 Int64 nextFaceUid() const { return m_next_face_uid; }
122 Int64 nextEdgeUid() const { return m_next_edge_uid; }
123
126
133 bool isUseNodeUniqueIdToGenerateEdgeAndFaceUniqueId() const { return m_use_hash_for_edge_and_face_unique_id; }
134
135 private:
136
137 template <typename CellInfo>
138 ItemInternal* _addOneCell(const CellInfo& cell_info);
139
140 ItemInternal* _addOnePolyhedron(Int64 cell_uid, ConstArrayView<Int64> connectivity_infos,
141 Int32 owner, bool allow_build_face);
142
143 template <typename CellInfo>
144 void _addNodesToCell(Cell cell, const CellInfo& cell_info);
145
146 template <typename CellInfo>
147 bool _isReorder(Integer i_face,
148 const ItemTypeInfo::LocalFace& lf,
149 const CellInfo& cell_info);
150
151 template <typename CellInfo>
152 Face _findInternalFace(Integer i_face,
153 const CellInfo& cell_info,
154 bool& is_add);
155
156 template <typename CellInfo>
157 Edge _findInternalEdge(Integer i_edge,
158 const CellInfo& cell_info,
159 Int64 first_node,
160 Int64 second_node,
161 bool& is_add);
162 template <typename CellInfo>
163 void _AMR_Patch(Cell cell, const CellInfo& cell_info);
164
165 void _clearConnectivity(ItemLocalId item, IIncrementalItemConnectivity* connectivity);
166 void _clearReverseConnectivity(ItemLocalId item, IIncrementalItemConnectivity* connectivity, IIncrementalItemConnectivity* reverse_connectivity);
167 void _printRelations(ItemInternal* item);
168 void _checkSameItemCoherency(ItemWithNodes item, ConstArrayView<Int64> nodes_uid);
169 Int64 _checkGenerateFaceUniqueId(Int64 uid, ConstArrayView<Int64> nodes_uid);
170
171 private:
172
173 DynamicMesh* m_mesh = nullptr;
174 DynamicMeshIncrementalBuilder* m_mesh_builder = nullptr;
175
176 CellFamily& m_cell_family;
177 NodeFamily& m_node_family;
178 FaceFamily& m_face_family;
179 EdgeFamily& m_edge_family;
180
181 ItemTypeMng* m_item_type_mng = nullptr;
182
184
187
190 //UniqueArray<Int64> m_work_face_sorted_nodes;
191 UniqueArray<Int64> m_work_face_orig_nodes_uid;
192 UniqueArray<Int64> m_work_edge_sorted_nodes;
193 UniqueArray<Int64> m_work_edge_orig_nodes_uid;
194
197};
198
199/*---------------------------------------------------------------------------*/
200/*---------------------------------------------------------------------------*/
201
202} // End namespace Arcane::mesh
203
204/*---------------------------------------------------------------------------*/
205/*---------------------------------------------------------------------------*/
206
207#endif
Interface for modifying a family.
Interface of an entity family.
Definition IItemFamily.h:85
Internal structure of a mesh entity.
Type of an entity (Item).
Definition ItemTypeId.h:33
Base class for a mesh element.
Definition Item.h:84
Utility class to reorder the nodes of an entity.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
1D data vector with value semantics (STL style).
Implementation of a mesh.
Definition DynamicMesh.h:98
Info to create/serialize a cell knowing the uniqueId() and owner() of all these sub-entities (cells,...
Class containing mesh information.
Definition MeshInfos.h:36
void _checkSameItemCoherency(ItemWithNodes item, ConstArrayView< Int64 > nodes_uid)
Checks the coherence of nodes for an already added item.
void _addNodesToCell(Cell cell, const CellInfo &cell_info)
Adds the nodes nodes_uid to the cell cell.
NodesOfItemReorderer m_face_reorderer
Work arrays.
ItemInternal * _addOneCell(const CellInfo &cell_info)
Adds a cell.
void addBulkMeshInfos(Integer nb_node, Integer nb_edge, Integer nb_face, Integer nb_cell)
Adds the counts of a batch built outside of this class.
MeshInfos m_mesh_info
General information about the mesh (sub-domain number, number of items...).
Int64 _checkGenerateFaceUniqueId(Int64 uid, ConstArrayView< Int64 > nodes_uid)
Generates a uniqueId() for the face if uid is null.
Int64 m_next_edge_uid
Next uniqueId() number used for generating edges.
void setUseNodeUniqueIdToGenerateEdgeAndFaceUniqueId(bool v)
Positions the uniqueId() numbering mechanism.
void resetAfterDeallocate()
Resets the structures to allow for re-allocation.
bool m_use_hash_for_edge_and_face_unique_id
If true, generates face uniqueIds from node uniqueIds.
Int64 m_next_face_uid
Next uniqueId() number used for generating faces.
ItemInternal * addOneParentItem(const Item &item, const eItemKind submesh_kind, const bool fatal_on_existing_item=true)
Adds a parent item.
ItemInternal * addOneFace(ItemTypeId type_id, Int64 face_uid, Int32 owner_rank, Int64ConstArrayView nodes_uid)
Adds a face.
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:474
eItemKind
Mesh entity type.
@ Cell
The mesh is AMR by cell.
Definition MeshKind.h:53
std::int32_t Int32
Signed integer type of 32 bits.