Arcane  4.1.12.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
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
109 void setNextFaceUid(Int64 face_uid) { m_next_face_uid = face_uid; }
110 void setNextEdgeUid(Int64 edge_uid) { m_next_edge_uid = edge_uid; }
111
112 Int64 nextFaceUid() const { return m_next_face_uid; }
113 Int64 nextEdgeUid() const { return m_next_edge_uid; }
114
117
124
125 private:
126
127 template <typename CellInfo>
128 ItemInternal* _addOneCell(const CellInfo& cell_info);
129
130 template <typename CellInfo>
131 void _addNodesToCell(Cell cell, const CellInfo& cell_info);
132
133 template <typename CellInfo>
134 bool _isReorder(Integer i_face,
135 const ItemTypeInfo::LocalFace& lf,
136 const CellInfo& cell_info);
137
138 template <typename CellInfo>
139 Face _findInternalFace(Integer i_face,
140 const CellInfo& cell_info,
141 bool& is_add);
142
143 template <typename CellInfo>
144 Edge _findInternalEdge(Integer i_edge,
145 const CellInfo& cell_info,
146 Int64 first_node,
147 Int64 second_node,
148 bool& is_add);
149 template <typename CellInfo>
150 void _AMR_Patch(Cell cell, const CellInfo& cell_info);
151
152 void _clearConnectivity(ItemLocalId item, IIncrementalItemConnectivity* connectivity);
153 void _clearReverseConnectivity(ItemLocalId item, IIncrementalItemConnectivity* connectivity, IIncrementalItemConnectivity* reverse_connectivity);
154 void _printRelations(ItemInternal* item);
157
158 private:
159
160 DynamicMesh* m_mesh = nullptr;
161 DynamicMeshIncrementalBuilder* m_mesh_builder = nullptr;
162
163 CellFamily& m_cell_family;
164 NodeFamily& m_node_family;
165 FaceFamily& m_face_family;
166 EdgeFamily& m_edge_family;
167
168 ItemTypeMng* m_item_type_mng = nullptr;
169
171
174
177 //UniqueArray<Int64> m_work_face_sorted_nodes;
178 UniqueArray<Int64> m_work_face_orig_nodes_uid;
179 UniqueArray<Int64> m_work_edge_sorted_nodes;
180 UniqueArray<Int64> m_work_edge_orig_nodes_uid;
181
184};
185
186/*---------------------------------------------------------------------------*/
187/*---------------------------------------------------------------------------*/
188
189} // End namespace Arcane::mesh
190
191/*---------------------------------------------------------------------------*/
192/*---------------------------------------------------------------------------*/
193
194#endif
Cell of a mesh.
Definition Item.h:1300
Constant view of an array of type T.
Edge of a cell.
Definition Item.h:875
Face of a cell.
Definition Item.h:1032
Interface for managing an incremental connectivity.
Interface for modifying a family.
Interface of an entity family.
Definition IItemFamily.h:83
Internal structure of a mesh entity.
Index of an Item in a variable.
Definition ItemLocalId.h:42
Type of an entity (Item).
Definition ItemTypeId.h:33
Local information about a cell face.
Mesh entity type manager.
Definition ItemTypeMng.h:66
Mesh element based on nodes (Edge,Face,Cell).
Definition Item.h:773
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.
ItemInternal * addOneCell(ItemTypeId type_id, Int64 cell_uid, Int32 sub_domain_id, Int64ConstArrayView nodes_uid, bool allow_build_face)
Adds a cell.
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:480
eItemKind
Mesh entity type.
std::int32_t Int32
Signed integer type of 32 bits.