12#ifndef ARCANE_MESH_DYNAMICMESH_H
13#define ARCANE_MESH_DYNAMICMESH_H
17#include "arcane/utils/TraceAccessor.h"
18#include "arcane/utils/PerfCounterMng.h"
19#include "arcane/utils/ArgumentException.h"
20#include "arcane/utils/List.h"
22#include "arcane/core/IMeshModifier.h"
23#include "arcane/core/IPrimaryMesh.h"
24#include "arcane/core/IItemFamily.h"
25#include "arcane/core/IItemFamilyModifier.h"
26#include "arcane/core/ObserverPool.h"
27#include "arcane/core/MeshPartInfo.h"
28#include "arcane/core/IItemFamilyNetwork.h"
29#include "arcane/core/MeshHandle.h"
30#include "arcane/core/IMeshInitialAllocator.h"
31#include "arcane/core/MeshKind.h"
33#include "arcane/mesh/SubMeshTools.h"
34#include "arcane/mesh/MeshVariables.h"
35#include "arcane/mesh/NewWithLegacyConnectivity.h"
36#include "arcane/mesh/MeshEventsImpl.h"
67class ItemMemoryReferenceMng;
68class MeshTiedInterface;
91class ARCANE_MESH_EXPORT DynamicMesh
101 friend DynamicMeshInternal;
104 friend DynamicMeshMergerHelper;
111 class InitialAllocator
116 InitialAllocator(DynamicMesh* m)
133#ifdef ACTIVATE_PERF_COUNTER
148 static const std::string m_names[NbCounters];
153 void _checkKindRange(eItemKind ik)
const
161 throw ArgumentException(A_FUNCINFO,
"Invalid Range");
166 DynamicMesh(ISubDomain* sd,
const MeshBuildInfo& mbi,
bool is_submesh);
171 void build()
override;
181 void setDimension(
Integer dim)
override;
205 void setEstimatedCells(
Integer nb_cell);
209 void exchangeItems()
override;
210 void clearItems()
override;
216 void updateGhostLayers()
override;
217 void updateGhostLayers(
bool remove_old_ghost)
override;
219 void updateGhostLayerFromParent(
Array<Int64>& ghost_cell_to_refine,
221 bool remove_old_ghost)
override;
232 Int32 meshRank() {
return m_mesh_part_info.partRank(); }
234 void checkValidMesh()
override;
235 void checkValidMeshFull()
override;
236 void checkValidConnectivity();
242 void reloadMesh()
override;
244 void deallocate()
override;
246 void endAllocate()
override;
259 removeCells(cells_local_id,
true);
266 void refineItems()
override;
267 void coarsenItems()
override;
268 void coarsenItemsV2(
bool update_parent_flag)
override;
270 bool adapt()
override;
273 void addHChildrenCells(
Cell parent_cell,
Integer nb_cell,
276 void addParentCellToCell(
Cell child,
Cell parent)
override;
277 void addChildCellToCell(
Cell parent,
Cell child)
override;
279 void addParentFaceToFace(
Face child,
Face parent)
override;
280 void addChildFaceToFace(
Face parent,
Face child)
override;
282 void addParentNodeToNode(
Node child,
Node parent)
override;
283 void addChildNodeToNode(
Node parent,
Node child)
override;
285 void endUpdate()
override;
288 bool isPrimaryMesh()
const override;
345 IMesh* m_parent_mesh;
351 NodeFamily& trueNodeFamily() {
return *m_node_family; }
352 EdgeFamily& trueEdgeFamily() {
return *m_edge_family; }
353 FaceFamily& trueFaceFamily() {
return *m_face_family; }
354 CellFamily& trueCellFamily() {
return *m_cell_family; }
366 _checkKindRange(kind);
367 return m_item_families[kind]->allItems();
378 _checkKindRange(kind);
379 return m_item_families[kind]->allItems().own();
415 return &m_item_internal_list;
420 ISubDomain* subDomain()
override {
return m_sub_domain; }
421 IParallelMng* parallelMng()
override;
426 void prepareForDump()
override;
427 void initializeVariables(
const XmlNode& init_node)
override;
430 void destroyGroups()
override;
434 return findGroup(aname,
IK_Node,
false);
438 return findGroup(aname,
IK_Edge,
false);
440 FaceGroup findFaceGroup(
const String& aname)
442 return findGroup(aname, IK_Face,
false);
444 CellGroup findCellGroup(
const String& aname)
446 return findGroup(aname, IK_Cell,
false);
449 ItemGroup createGroup(
const String& aname,
const ItemGroup& parent);
450 ItemGroup createGroup(
const String& aname, eItemKind ik);
462 IItemFamily* findItemFamily(
eItemKind ik,
const String& name,
bool create_if_needed,
bool register_modifier_if_created)
override;
463 IItemFamily* findItemFamily(
const String& name,
bool throw_exception =
true)
override;
479 return m_item_families;
494 void setCheckLevel(
Integer level)
override;
496 Integer checkLevel()
const override;
500 void computeTiedInterfaces(
const XmlNode& xml_node)
override;
501 bool hasTiedInterface()
override;
511 void synchronizeGroupsAndVariables()
override;
516 IMesh* parentMesh()
const override;
518 void addChildMesh(
IMesh* sub_mesh)
override;
525 return m_connectivity_policy;
531 MeshRefinement* meshRefinement() {
return m_mesh_refinement; }
532 void endUpdate(
bool update_ghost_layer,
bool remove_old_ghost)
override;
546 void computeSynchronizeInfos()
override;
558 return m_mesh_events.eventObservable(
type);
586 std::unique_ptr<DynamicMeshInternal> m_internal_api;
594 bool m_is_dynamic =
false;
608 bool m_is_sub_connectivity_set =
false;
609 bool m_tied_interface_need_prepare_dump =
false;
617#ifdef ACTIVATE_PERF_COUNTER
618 PerfCounterMng<PerfCounter> m_perf_counter;
624 bool m_use_mesh_item_family_dependencies =
false;
627 std::unique_ptr<IIndexedIncrementalItemConnectivityMng> m_indexed_connectivity_mng;
629 bool m_do_not_save_need_compact =
false;
635 void _printMesh(std::ostream& ostr);
636 void _allocateCells(
Integer mesh_nb_cell,
639 bool allow_build_face =
true);
641 const char* _className()
const {
return "Mesh"; }
645 void _prepareForDump();
646 void _prepareForDumpReal();
647 void _readFromDump();
649 void _setOwnersFromCells();
651 void _synchronizeGroupsAndVariables();
652 void _synchronizeGroups();
653 void _synchronizeVariables();
654 void _writeMesh(
const String& base_name);
655 void _removeGhostItems();
657 void _removeGhostChildItems();
658 void _removeGhostChildItems2(
Array<Int64>& cells_to_coarsen);
659 void _checkAMR()
const;
661 void _sortInternalReferences();
662 void _finalizeMeshChanged();
663 void _compactItemInternalReferences();
664 void _compactItems(
bool do_sort,
bool compact_variables_and_groups);
667 void _computeSynchronizeInfos();
668 void _computeFamilySynchronizeInfos();
669 void _computeGroupSynchronizeInfos();
670 void _exchangeItems(
bool do_compact);
671 void _exchangeItemsNew();
672 void _checkDimension()
const;
673 void _checkConnectivity();
674 void _writeCells(
const String& filename);
676 void _prepareTiedInterfacesForDump();
677 void _readTiedInterfacesFromDump();
678 void _applyTiedInterfaceStructuration(
TiedInterface* tied_interface);
679 void _deleteTiedInterfaces();
681 void _multipleExchangeItems(
Integer nb_exchange,
Integer version,
bool do_compact);
683 void _setSubConnectivity();
684 void _setDimension(
Integer dim);
685 void _internalUpdateGhost(
bool update_ghost_layer,
bool remove_old_ghost);
686 void _internalEndUpdateInit(
bool update_sync_info);
687 void _internalEndUpdateResizeVariables();
688 void _internalEndUpdateFinal(
bool print_stat);
690 void _computeExtraGhostCells();
691 void _computeExtraGhostParticles();
693 void _notifyEndUpdateForFamilies();
696 void _saveProperties();
697 void _loadProperties();
702 void _applyCompactPolicy(
const String& timer_name,
704 void _updateGroupsAfterRemove();
705 void _printConnectivityPolicy();
709 template <
class SourceFamily,
class TargetFamily>
710 void _addDependency(SourceFamily* source_family, TargetFamily* target_family)
712 typedef typename NewWithLegacyConnectivityType<SourceFamily, TargetFamily>::type CType;
713 String name = String::format(
"{0}{1}", source_family->name(), target_family->name());
714 auto connectivity =
new CType(source_family, target_family, name);
715 m_item_family_network->
addDependency(source_family, target_family, connectivity);
719 template <
class SourceFamily,
class TargetFamily>
720 void _addRelation(SourceFamily* source_family, TargetFamily* target_family)
722 typedef typename NewWithLegacyConnectivityType<SourceFamily, TargetFamily>::type CType;
723 String name = String::format(
"{0}{1}", source_family->name(), target_family->name());
724 auto connectivity =
new CType(source_family, target_family, name);
725 m_item_family_network->
addRelation(source_family, target_family, connectivity);
729 void _updateItemFamilyDependencies(VariableScalarInteger connectivity);
732 void _serializeItems(ISerializer* buffer, Int32ConstArrayView item_local_ids, IItemFamily* item_family);
733 void _deserializeItems(ISerializer* buffer, Int32Array* item_local_ids, IItemFamily* item_family);
734 void _fillSerializer(ISerializer* buffer, std::map<String, Int32UniqueArray>& serializedItems);
Modifiable view of an array of type T.
Base class for 1D data vectors.
Information for allocating entities of an unstructured mesh.
Constant view of an array of type T.
Base class for an event handler.
Interface of a functor with argument.
Allocator for Cartesian meshes.
Interface of a builder for "extraordinary" ghost cells.
Interface of the manager for indexed incremental item connectivities.
Entity compaction policy.
Interface for modifying a family.
virtual void addDependency(IItemFamily *master_family, IItemFamily *slave_family, IIncrementalItemConnectivity *slave_to_master_connectivity, bool is_deep_connectivity=true)=0
Adds a dependency between two families; an element of master_family is composed of elements of slave_...
virtual void addRelation(IItemFamily *source_family, IItemFamily *target_family, IIncrementalItemConnectivity *source_to_target_connectivity)=0
Adds a relation between two families; an element of source_family is connected to one or more element...
Interface for entity family policies.
Interface of an entity family.
Interface for mesh verification methods.
Interface for managing the compaction of mesh families.
Interface for managing mesh exchanges between subdomains.
Interface for allocating mesh entities.
Internal part of IMeshModifier.
Mesh modification interface.
Interface of a mesh partitioning constraint manager.
Interface of a class providing utility functions on meshes.
Interface of the parallelism manager for a subdomain.
Interface of the subdomain manager.
Allocator for unstructured meshes.
Interface of a list that manages user data.
Variable manager interface.
Brief: Implementation of a mesh entity group.
Internal structure of a mesh entity.
Mesh entity type manager.
View on a vector of entities.
Implementation of a collection of elements in vector form.
Indirection tables for mesh entities.
Characteristics of a mesh.
Arguments for IMeshModifier::addCells().
Arguments for IMeshModifier::addFaces().
Information about a partitioned mesh.
Unicode character string.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
ITraceMng * traceMng() const
Trace manager.
1D data vector with value semantics (STL style).
Information for allocating entities of an unstructured mesh.
Construction of a mesh incrementally.
ICartesianMeshInitialAllocator * cartesianMeshAllocator() override
Allocator for Cartesian meshes.
IUnstructuredMeshInitialAllocator * unstructuredMeshAllocator() override
Allocator for unstructured meshes.
bool useMeshItemFamilyDependencies() const override
check if the network itemFamily dependencies is activated
VariableItemInt32 & itemsNewOwner(eItemKind ik) override
Variable containing the identifier of the owning subdomain.
IMeshCompactMng * _compactMng() override
String factoryName() const override
Name of the factory used to create the mesh.
FaceGroup allFaces() override
Group of all faces.
bool isDynamic() const override
Indicates if the mesh is dynamic (can evolve).
UniqueArray< ItemFamily * > m_true_item_families
List of entity family implementations.
bool isAmrActivated() const override
AMR.
ITraceMng * traceMng() override
Associated message manager.
IItemFamily * itemFamily(eItemKind ik) override
Returns the entity family of type ik.
IMesh * mesh() override
Associated mesh.
String name() const override
Mesh name.
IMeshMng * meshMng() const override
Associated mesh manager.
NodeGroup ownNodes() override
Group of all domain-specific nodes.
EdgeGroup ownEdges() override
Group of all domain-specific edges.
IIndexedIncrementalItemConnectivityMng * indexedConnectivityMng() override
Interface of the indexed incremental connectivity manager.
ItemInternalArrayView itemsInternal(eItemKind ik) override
Internal array of mesh elements of type type.
Int64 timestamp() override
Counter indicating the time of the last mesh modification.
IMeshModifier * modifier() override
Associated modifier interface.
const IUserDataList * userDataList() const override
Associated user data manager.
VariableScalarInteger connectivity() override
Connectivity descriptor.
Integer dimension() override
Mesh dimension (1D, 2D, or 3D).
void setDynamic(bool v) override
Sets the property indicating whether the mesh can evolve.
ItemFamilyList m_item_families
List of entity family interfaces.
EdgeGroup allEdges() override
Group of all edges.
const MeshPartInfo & meshPartInfo() const override
Information about mesh parts.
ItemTypeMng * itemTypeMng() const override
Associated entity type manager.
CellGroup allCells() override
Group of all cells.
bool isAllocated() override
True if the mesh is allocated.
IVariableMng * variableMng() const override
Associated variable manager.
IGhostLayerMng * ghostLayerMng() const override
Associated ghost layer manager.
InternalConnectivityPolicy _connectivityPolicy() const override
Connectivity usage policy.
void removeCells(Int32ConstArrayView cells_local_id) override
Removes cells.
FaceGroup ownFaces() override
Group of all domain-specific faces.
Integer nbItem(eItemKind ik) override
Number of elements of type ik.
IMeshInitialAllocator * initialAllocator() override
Specific initial allocator.
const MeshKind meshKind() const override
Mesh characteristics.
Properties * properties() override
Properties associated with this mesh.
CellGroup ownCells() override
Group of all domain-specific cells.
IItemFamilyNetwork * itemFamilyNetwork() override
Family network interface (connected families).
void setOwnersFromCells() override
Positions entity owners based on the cell owner.
IMeshUniqueIdMng * meshUniqueIdMng() const override
Unique ID numbering manager.
NodeGroup allNodes() override
Group of all nodes.
MeshHandle handle() const override
Handle on this mesh.
ItemGroupList m_all_groups
List of entity groups.
bool m_is_amr_activated
AMR.
MeshRefinement * m_mesh_refinement
AMR.
EventObservable< const MeshEventArgs & > & eventObservable(eMeshEventType type) override
Observable for an event.
IUserDataList * userDataList() override
Associated user data manager.
Construction of extra ghost cells.
Associative array of ItemInternal.
Implementation of mesh events.
Mesh partitioning constraint manager.
Implementation of unstructured mesh refinement adaptation algorithms.
VariableScalarInteger m_mesh_connectivity
Mesh connectivity.
VariableScalarInteger m_mesh_dimension
Mesh dimension.
Implementation of the tied interface manager.
Information on mesh semi-conformities.
ItemGroupT< Cell > CellGroup
Group of cells.
ItemGroupT< Face > FaceGroup
Group of faces.
ItemGroupT< Edge > EdgeGroup
Group of edges.
ItemGroupT< Node > NodeGroup
Group of nodes.
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Coordinate type quantity at node.
ItemVariableScalarRefT< Int32 > VariableItemInt32
32-bit integer type quantity
VariableRefScalarT< Integer > VariableScalarInteger
Scalar variable of integer type.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Collection< ItemGroup > ItemGroupCollection
Collection of mesh item groups.
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
List< ItemGroup > ItemGroupList
Array of mesh item groups.
Collection< IItemFamily * > IItemFamilyCollection
Collection of item families.
ConstArrayView< Int64 > Int64ConstArrayView
C equivalent of a 1D array of 64-bit integers.
eMeshEventType
Events generated by IMesh.
ArrayView< Int32 > Int32ArrayView
C equivalent of a 1D array of 32-bit integers.
SharedMeshVariableScalarRefT< Node, Real3 > SharedVariableNodeReal3
Quantity at the node of coordinate type.
eItemKind
Mesh entity type.
@ IK_Node
Node mesh entity.
@ IK_Cell
Cell mesh entity.
@ IK_Face
Face mesh entity.
@ IK_Edge
Edge mesh entity.
Array< Int32 > Int32Array
Dynamic one-dimensional array of 32-bit integers.
Collection< IMesh * > IMeshCollection
Collection of meshes.
InternalConnectivityPolicy
Connectivity usage policy.
eMeshAMRKind
AMR mesh type.
Collection< ITiedInterface * > TiedInterfaceCollection
Collection of tied interfaces.
std::int32_t Int32
Signed integer type of 32 bits.