Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
IMeshModifier.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/* IMeshModifier.h (C) 2000-2025 */
9/* */
10/* Mesh modification interface. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_IMESHMODIFIER_H
13#define ARCANE_CORE_IMESHMODIFIER_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18#include "arcane/core/Item.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29class IMesh;
33class IMeshModifierInternal;
34class IMeshModifier;
35
36/*---------------------------------------------------------------------------*/
37/*---------------------------------------------------------------------------*/
38
39/*!
40 * \brief Arguments for IMeshModifier::addCells().
41 *
42 * The format of cellsInfos() is identical to that of the
43 * IMesh::allocateCells() method. If \a cellsLocalIds() is not empty, it
44 * will contain the local IDs of the created cells.
45 *
46 * If an added cell has the same uniqueId() as an existing cell, the
47 * existing cell is kept as is and nothing happens.
48 *
49 * The created cells are considered to belong to this subdomain.
50 * If this is not the case, their ownership must be modified afterwards.
51 *
52 * By default, when adding cells, if the associated faces do not exist,
53 * they are created automatically. This is only possible in sequential mode.
54 * It is possible to disable this by calling setAllowBuildFaces().
55 * In parallel, the value of isAllowBuildFaces() is ignored.
56 */
57class MeshModifierAddCellsArgs
58{
59 public:
60
61 MeshModifierAddCellsArgs(Integer nb_cell, Int64ConstArrayView cell_infos)
62 : m_nb_cell(nb_cell)
63 , m_cell_infos(cell_infos)
64 {}
65
66 MeshModifierAddCellsArgs(Integer nb_cell, Int64ConstArrayView cell_infos,
67 Int32ArrayView cell_lids)
68 : MeshModifierAddCellsArgs(nb_cell, cell_infos)
69 {
70 m_cell_lids = cell_lids;
71 }
72
73 public:
74
75 Int32 nbCell() const { return m_nb_cell; }
76 Int64ConstArrayView cellInfos() const { return m_cell_infos; }
77 Int32ArrayView cellLocalIds() const { return m_cell_lids; }
78
79 //! Indicates whether associated faces are allowed to be built
80 void setAllowBuildFaces(bool v) { m_is_allow_build_faces = v; }
81 bool isAllowBuildFaces() const { return m_is_allow_build_faces; }
82
83 private:
84
85 Int32 m_nb_cell = 0;
86 Int64ConstArrayView m_cell_infos;
87 //! Returns, list of localIds() of the created cells
88 Int32ArrayView m_cell_lids;
89 bool m_is_allow_build_faces = true;
90};
91
92/*---------------------------------------------------------------------------*/
93/*---------------------------------------------------------------------------*/
94
95/*!
96 * \brief Arguments for IMeshModifier::addFaces().
97 */
98class MeshModifierAddFacesArgs
99{
100 public:
101
102 MeshModifierAddFacesArgs(Int32 nb_face, Int64ConstArrayView face_infos)
103 : m_nb_face(nb_face)
104 , m_face_infos(face_infos)
105 {}
106
107 MeshModifierAddFacesArgs(Int32 nb_face, Int64ConstArrayView face_infos,
108 Int32ArrayView face_lids)
109 : MeshModifierAddFacesArgs(nb_face, face_infos)
110 {
111 m_face_lids = face_lids;
112 }
113
114 public:
115
116 Int32 nbFace() const { return m_nb_face; }
117 Int64ConstArrayView faceInfos() const { return m_face_infos; }
118 Int32ArrayView faceLocalIds() const { return m_face_lids; }
119
120 private:
121
122 Int32 m_nb_face = 0;
123 Int64ConstArrayView m_face_infos;
124 //! Returns, list of localIds() of the created faces
125 Int32ArrayView m_face_lids;
126};
127
128/*---------------------------------------------------------------------------*/
129/*---------------------------------------------------------------------------*/
130
131/*!
132 * \brief Mesh modification interface.
133 *
134 * This interface provides the services for modifying a mesh.
135 * Mesh manipulation is a complex mechanism and is reserved for experienced
136 * users. Some manipulations may leave the mesh in an inconsistent state.
137 *
138 * The supported operations depend on the mesh type. For performance reasons,
139 * adding and deleting entities do not directly update the entity variables
140 * or groups. For this to be taken into account, the endUpdate() method must
141 * be called. In parallel, this also triggers the update of ghost entities.
142 */
143class ARCANE_CORE_EXPORT IMeshModifier
144{
145 public:
146
147 virtual ~IMeshModifier() {} //<! Releases resources
148
149 public:
150
151 virtual void build() = 0;
152
153 public:
154
155 //! Associated mesh
156 virtual IMesh* mesh() = 0;
157
158 public:
159
160 /*!
161 * \brief Sets the property indicating whether the mesh can evolve.
162 *
163 * This property must be set to true if you wish to modify the mesh,
164 * for example by exchanging entities via the exchangeItems() call.
165 * This only concerns nodes, edges, faces, and cells, but not particles,
166 * which can still be created and destroyed.
167 *
168 * By default, isDynamic() is false.
169 *
170 * The property setting can only be done during initialization.
171 */
172 virtual void setDynamic(bool v) = 0;
173
174 /*!
175 * \brief Adds cells.
176 *
177 * Adds cells. The format of \a cells_infos is identical to that of
178 * the IMesh::allocateCells() method. If \a cells_lid is not empty,
179 * it will contain the local IDs of the created cells. It is possible
180 * to perform multiple successive additions. Once the additions are
181 * complete, the endUpdate() method must be called. If an added cell
182 * has the same uniqueId() as an existing cell, the existing cell is
183 * kept as is and nothing happens.
184 *
185 * The created cells are considered to belong to this subdomain.
186 * If this is not the case, their ownership must be modified afterwards.
187 *
188 * This method is collective. If a subdomain does not wish to add cells,
189 * it is possible to pass an empty array.
190 */
191 virtual void addCells(Integer nb_cell, Int64ConstArrayView cell_infos,
192 Int32ArrayView cells_lid = Int32ArrayView()) = 0;
193
194 //! Adds cells
195 virtual void addCells(const MeshModifierAddCellsArgs& args);
196
197 /*!
198 * \brief Adds faces.
199 *
200 * \sa addFaces(const MeshModifierAddFacesArgs&)
201 */
202 virtual void addFaces(Integer nb_face, Int64ConstArrayView face_infos,
203 Int32ArrayView face_lids = Int32ArrayView()) = 0;
204
205 /*!
206 * \brief Adds faces.
207 *
208 * Adds faces. The format of \a face_infos is identical to that of the
209 * IMesh::allocateCells() method. If \a face_lids is not empty, it will
210 * contain the local IDs of the created faces. It is possible to perform
211 * multiple successive additions. Once the additions are complete, the
212 * endUpdate() method must be called. If an added face has the same uniqueId()
213 * as an existing face, the existing face is kept as is and nothing happens.
214 *
215 * The created faces are considered to belong to this subdomain.
216 * If this is not the case, their ownership must be modified afterwards.
217 */
218 virtual void addFaces(const MeshModifierAddFacesArgs& args);
219
220 /*!
221 * \brief Adds edges.
222 *
223 * Adds edges. The format of \a edge_infos is identical to that of the
224 * IMesh::allocateCells() method. If \a edge_lids is not empty, it will
225 * contain the local IDs of the created edges. It is possible to perform
226 * multiple successive additions. Once the additions are complete, the
227 * endUpdate() method must be called. If an added edge has the same uniqueId()
228 * as an existing edge, the existing edge is kept as is and nothing happens.
229 *
230 * The created edges are considered to belong to this subdomain.
231 * If this is not the case, their ownership must be modified afterwards.
232 *
233 * This method is collective. If a subdomain does not wish to add edges,
234 * it is possible to pass an empty array.
235 */
236 virtual void addEdges(Integer nb_edge, Int64ConstArrayView edge_infos,
237 Int32ArrayView edge_lids = Int32ArrayView()) = 0;
238
239 /*!
240 * \brief Adds nodes.
241 *
242 * Adds nodes with unique identifiers being the values of the
243 * \a nodes_uid array. If \a nodes_lid is not empty, it will contain the
244 * local IDs of the created nodes. It is possible to perform multiple
245 * successive additions. Once the additions are complete, the endUpdate()
246 * method must be called. It is possible to specify an already existing
247 * uniqueId(). In this case, the node is simply ignored.
248 *
249 * The created nodes are considered to belong to this subdomain.
250 * If this is not the case, their ownership must be modified afterwards.
251 *
252 * This method is collective. If a subdomain does not wish to add nodes,
253 * it is possible to pass an empty array.
254 */
255 virtual void addNodes(Int64ConstArrayView nodes_uid,
256 Int32ArrayView nodes_lid = Int32ArrayView()) = 0;
257
258 /*!
259 * \brief Removes cells.
260 *
261 * Removes the cells whose local IDs are provided in \a cells_local_id.
262 * It is possible to perform multiple successive removals. Once the removals
263 * are complete, the endUpdate() method must be called.
264 */
265 virtual void removeCells(Int32ConstArrayView cells_local_id) = 0;
266
267 virtual void removeCells(Int32ConstArrayView cells_local_id, bool update_ghost) = 0;
268
269 /*!
270 * \brief Detaches cells from the mesh.
271 *
272 * The detached cells are disconnected from the mesh. The nodes, edges,
273 * and faces of these cells no longer reference them, and the uniqueId()
274 * of these cells can be reused. To permanently destroy these cells, the
275 * removeDetachedCells() method must be called.
276 */
277 virtual void detachCells(Int32ConstArrayView cells_local_id) = 0;
278
279 /*!
280 * \brief Removes detached cells
281 *
282 * Removes detached cells via detachCells().
283 * It is possible to perform multiple successive removals. Once the removals
284 * are complete, the endUpdate() method must be called.
285 */
286 virtual void removeDetachedCells(Int32ConstArrayView cells_local_id) = 0;
287
288 //! AMR
289 virtual void flagCellToRefine(Int32ConstArrayView cells_lids) = 0;
290 virtual void flagCellToCoarsen(Int32ConstArrayView cells_lids) = 0;
291 virtual void refineItems() = 0;
292 virtual void coarsenItems() = 0;
293 virtual void coarsenItemsV2(bool update_parent_flag) = 0;
294 virtual bool adapt() = 0;
295 virtual void registerCallBack(IAMRTransportFunctor* f) = 0;
296 virtual void unRegisterCallBack(IAMRTransportFunctor* f) = 0;
297 virtual void addHChildrenCells(Cell parent_cell, Integer nb_cell,
298 Int64ConstArrayView cells_infos, Int32ArrayView cells_lid = Int32ArrayView()) = 0;
299
300 virtual void addParentCellToCell(Cell child, Cell parent) = 0;
301 virtual void addChildCellToCell(Cell parent, Cell child) = 0;
302
303 virtual void addParentFaceToFace(Face child, Face parent) = 0;
304 virtual void addChildFaceToFace(Face parent, Face child) = 0;
305
306 virtual void addParentNodeToNode(Node child, Node parent) = 0;
307 virtual void addChildNodeToNode(Node parent, Node child) = 0;
308
309 //! Deletes all entities of all families in this mesh.
310 virtual void clearItems() = 0;
311
312 /*!
313 * \brief Adds cells from the data contained in \a buffer.
314 *
315 * \a buffer must contain serialized cells, for example by
316 * calling IMesh::serializeCells().
317 *
318 * \deprecated Use IMesh::cellFamily()->policyMng()->createSerializer() instead.
319 */
320 ARCANE_DEPRECATED_240 virtual void addCells(ISerializer* buffer) = 0;
321
322 /*!
323 * \brief Adds cells from the data contained in \a buffer.
324 *
325 * \a buffer must contain serialized cells, for example by
326 * calling IMesh::serializeCells(). In return, \a cells_local_id
327 * contains the list of localIds() of the deserialized cells. A cell may
328 * appear multiple times in this list if it appears multiple times in \a buffer.
329 *
330 * \deprecated Use IMesh::cellFamily()->policyMng()->createSerializer() instead.
331 */
332 ARCANE_DEPRECATED_240 virtual void addCells(ISerializer* buffer, Int32Array& cells_local_id) = 0;
333
334 /*!
335 * \brief Notifies the instance that mesh modification is finished.
336 *
337 * This method is collective.
338 */
339 virtual void endUpdate() = 0;
340
341 virtual void endUpdate(bool update_ghost_layer, bool remove_old_ghost) = 0; // SDC: this signature is needed @IFPEN.
342
343 public:
344
345 /*!
346 * \brief Updates the ghost layer.
347 *
348 * This operation is collective.
349 */
350 virtual void updateGhostLayers() = 0;
351
352 //! AMR
353 virtual void updateGhostLayerFromParent(Array<Int64>& ghost_cell_to_refine,
354 Array<Int64>& ghost_cell_to_coarsen,
355 bool remove_old_ghost) = 0;
356
357 //! addition of the "extraordinary" ghost cells addition algorithm.
359
360 //! Removes the association with the \a builder instance.
362
363 //! Addition of the "extraordinary" ghost particle addition algorithm
365
366 //! Removes the association with the \a builder instance.
368
369 public:
370
371 //! Merges the meshes of \a meshes with the current mesh.
372 virtual void mergeMeshes(ConstArrayView<IMesh*> meshes) = 0;
373
374 public:
375
376 //! Internal API for Arcane
377 virtual IMeshModifierInternal* _modifierInternalApi() = 0;
378};
379
380/*---------------------------------------------------------------------------*/
381/*---------------------------------------------------------------------------*/
382
383} // End namespace Arcane
384
385/*---------------------------------------------------------------------------*/
386/*---------------------------------------------------------------------------*/
387
388#endif
Declarations of Arcane's general types.
Base class for 1D data vectors.
Cell of a mesh.
Definition Item.h:1300
Constant view of an array of type T.
Face of a cell.
Definition Item.h:1032
Interface of a functor with argument.
Interface of a builder for "extraordinary" ghost cells.
Interface of a builder for "extraordinary" ghost cells.
Mesh modification interface.
virtual void updateGhostLayers()=0
Updates the ghost layer.
virtual void setDynamic(bool v)=0
Sets the property indicating whether the mesh can evolve.
virtual ARCANE_DEPRECATED_240 void addCells(ISerializer *buffer, Int32Array &cells_local_id)=0
Adds cells from the data contained in buffer.
virtual void removeCells(Int32ConstArrayView cells_local_id)=0
Removes cells.
virtual void addExtraGhostParticlesBuilder(IExtraGhostParticlesBuilder *builder)=0
Addition of the "extraordinary" ghost particle addition algorithm.
virtual void flagCellToRefine(Int32ConstArrayView cells_lids)=0
AMR.
virtual IMesh * mesh()=0
Associated mesh.
virtual void addNodes(Int64ConstArrayView nodes_uid, Int32ArrayView nodes_lid=Int32ArrayView())=0
Adds nodes.
virtual void addFaces(Integer nb_face, Int64ConstArrayView face_infos, Int32ArrayView face_lids=Int32ArrayView())=0
Adds faces.
virtual void removeExtraGhostParticlesBuilder(IExtraGhostParticlesBuilder *builder)=0
Removes the association with the builder instance.
virtual void removeDetachedCells(Int32ConstArrayView cells_local_id)=0
Removes detached cells.
virtual IMeshModifierInternal * _modifierInternalApi()=0
Internal API for Arcane.
virtual void detachCells(Int32ConstArrayView cells_local_id)=0
Detaches cells from the mesh.
virtual void addCells(Integer nb_cell, Int64ConstArrayView cell_infos, Int32ArrayView cells_lid=Int32ArrayView())=0
Adds cells.
virtual ARCANE_DEPRECATED_240 void addCells(ISerializer *buffer)=0
Adds cells from the data contained in buffer.
virtual void mergeMeshes(ConstArrayView< IMesh * > meshes)=0
Merges the meshes of meshes with the current mesh.
virtual void endUpdate()=0
Notifies the instance that mesh modification is finished.
virtual void addExtraGhostCellsBuilder(IExtraGhostCellsBuilder *builder)=0
addition of the "extraordinary" ghost cells addition algorithm.
virtual void clearItems()=0
Deletes all entities of all families in this mesh.
virtual void removeExtraGhostCellsBuilder(IExtraGhostCellsBuilder *builder)=0
Removes the association with the builder instance.
virtual void updateGhostLayerFromParent(Array< Int64 > &ghost_cell_to_refine, Array< Int64 > &ghost_cell_to_coarsen, bool remove_old_ghost)=0
AMR.
virtual void addEdges(Integer nb_edge, Int64ConstArrayView edge_infos, Int32ArrayView edge_lids=Int32ArrayView())=0
Adds edges.
Arguments for IMeshModifier::addCells().
void setAllowBuildFaces(bool v)
Indicates whether associated faces are allowed to be built.
Arguments for IMeshModifier::addFaces().
Node of a mesh.
Definition Item.h:598
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
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
Array< Int32 > Int32Array
Dynamic one-dimensional array of 32-bit integers.
Definition UtilsTypes.h:127
std::int32_t Int32
Signed integer type of 32 bits.