Utility functions for a mesh. More...
#include <arcane/mesh/UnstructuredMeshUtilities.h>
Public Member Functions | |
| UnstructuredMeshUtilities (IMesh *mesh) | |
| ~UnstructuredMeshUtilities () override | |
| Frees resources. | |
| void | changeOwnersFromCells () override |
| Positions the new owners of nodes, edges, and faces based on the cells. | |
| void | localIdsFromConnectivity (eItemKind item_kind, IntegerConstArrayView items_nb_node, Int64ConstArrayView items_connectivity, Int32ArrayView local_ids, bool allow_null) override |
| Searches for the local IDs of entities based on their connectivity. | |
| void | getFacesLocalIdFromConnectivity (ConstArrayView< ItemTypeId > items_type, ConstArrayView< Int64 > items_connectivity, ArrayView< Int32 > local_ids, bool allow_null) override |
| Searches for the local IDs of faces based on their connectivity. | |
| Real3 | computeNormal (const FaceGroup &face_group, const VariableNodeReal3 &nodes_coord) override |
| Calculates the normal of a face group. | |
| Real3 | computeDirection (const NodeGroup &node_group, const VariableNodeReal3 &nodes_coord, Real3 *n1, Real3 *n2) override |
| void | computeAdjency (ItemPairGroup adjency_array, eItemKind link_kind, Integer nb_layer) override |
| Calculates adjacencies, stored in adjacency_array. | |
| bool | writeToFile (const String &file_name, const String &service_name) override |
| Writes the mesh to a file. | |
| void | partitionAndExchangeMeshWithReplication (IMeshPartitionerBase *partitioner, bool initial_partition) override |
| Repartitions and exchanges the mesh while managing replication. | |
| void | mergeNodes (Int32ConstArrayView nodes_local_id, Int32ConstArrayView nodes_to_merge_local_id, bool allow_non_corresponding_face) override |
| Merges nodes. | |
| void | computeAndSetOwnersForNodes () override |
| Determines the owners of the nodes. | |
| void | computeAndSetOwnersForEdges () override |
| Determines the owners of the edges. | |
| void | computeAndSetOwnersForFaces () override |
| Determines the owners of the faces. | |
| void | recomputeItemsUniqueIdFromNodesUniqueId () override |
| Recalculates the uniqueId() of edges, faces, and cells based on the uniqueId() of the nodes. | |
| Public Member Functions inherited from Arcane::TraceAccessor | |
| TraceAccessor (ITraceMng *m) | |
| Constructs an accessor via the trace manager m. | |
| TraceAccessor (const TraceAccessor &rhs) | |
| Copy constructor. | |
| TraceAccessor & | operator= (const TraceAccessor &rhs) |
| Copy assignment operator. | |
| virtual | ~TraceAccessor () |
| Frees resources. | |
| ITraceMng * | traceMng () const |
| Trace manager. | |
| TraceMessage | info () const |
| Flow for an information message. | |
| TraceMessage | pinfo () const |
| Flow for a parallel information message. | |
| TraceMessage | info (char category) const |
| Flow for an information message of a given category. | |
| TraceMessage | pinfo (char category) const |
| Flow for a parallel information message of a given category. | |
| TraceMessage | info (bool v) const |
| Flow for an information message. | |
| TraceMessage | warning () const |
| Flow for a warning message. | |
| TraceMessage | pwarning () const |
| TraceMessage | error () const |
| Flow for an error message. | |
| TraceMessage | perror () const |
| TraceMessage | log () const |
| Flow for a log message. | |
| TraceMessage | plog () const |
| Flow for a log message. | |
| TraceMessage | logdate () const |
| Flow for a log message preceded by the date. | |
| TraceMessage | fatal () const |
| Flow for a fatal error message. | |
| TraceMessage | pfatal () const |
| Flow for a parallel fatal error message. | |
| TraceMessageDbg | debug (Trace::eDebugLevel=Trace::Medium) const |
| Flow for a debug message. | |
| Trace::eDebugLevel | configDbgLevel () const |
| Debug level of the configuration file. | |
| TraceMessage | info (Int32 verbose_level) const |
| Flow for an information message of a given level. | |
| TraceMessage | linfo () const |
| Flow for an information message with the local information level of this instance. | |
| TraceMessage | linfo (Int32 relative_level) const |
| Flow for an information message with the local information level of this instance. | |
| void | fatalMessage (const StandaloneTraceMessage &o) const |
| Public Member Functions inherited from Arcane::IMeshUtilities | |
| virtual | ~IMeshUtilities ()=default |
| Frees resources. | |
| virtual void | computeAdjacency (const ItemPairGroup &adjacency_array, eItemKind link_kind, Integer nb_layer) |
| Calculates adjacencies, stored in adjacency_array. | |
| virtual void | mergeNodes (Int32ConstArrayView nodes_local_id, Int32ConstArrayView nodes_to_merge_local_id) |
| Merges nodes. | |
Private Member Functions | |
| Real3 | _round (Real3 value) |
| Real3 | _broadcastFarthestNode (Real distance, const Node &node, const VariableNodeReal3 &nodes_coord) |
Private Attributes | |
| IMesh * | m_mesh = nullptr |
| BasicItemPairGroupComputeFunctor * | m_compute_adjacency_functor = nullptr |
Additional Inherited Members | |
| Protected Member Functions inherited from Arcane::TraceAccessor | |
| void | _setLocalVerboseLevel (Int32 v) |
| Int32 | _localVerboseLevel () const |
Utility functions for a mesh.
Definition at line 40 of file UnstructuredMeshUtilities.h.
|
explicit |
Definition at line 68 of file UnstructuredMeshUtilities.cc.
|
override |
Frees resources.
Definition at line 79 of file UnstructuredMeshUtilities.cc.
|
private |
Definition at line 722 of file UnstructuredMeshUtilities.cc.
Definition at line 399 of file UnstructuredMeshUtilities.cc.
|
overridevirtual |
Positions the new owners of nodes, edges, and faces based on the cells.
Assuming the new owners of the cells are known (and synchronized), it determines the new owners of other entities and synchronizes them.
This method is collective.
Implements Arcane::IMeshUtilities.
Definition at line 88 of file UnstructuredMeshUtilities.cc.
References Arcane::IItemFamily::allItems(), Arcane::Particle::cell(), Arcane::ConnectivityItemVector::connectedItems(), ENUMERATE_EDGE, ENUMERATE_FACE, ENUMERATE_ITEM, ENUMERATE_NODE, ENUMERATE_PARTICLE, Arcane::IK_Cell, Arcane::IK_DoF, Arcane::IK_Edge, Arcane::IK_Face, Arcane::IK_Node, Arcane::IK_Particle, Arcane::TraceAccessor::info(), Arcane::IItemFamily::itemsNewOwner(), Arcane::ItemGroup::own(), and Arcane::Item::owner().
Referenced by partitionAndExchangeMeshWithReplication().
|
overridevirtual |
Calculates adjacencies, stored in adjacency_array.
Implements Arcane::IMeshUtilities.
Definition at line 766 of file UnstructuredMeshUtilities.cc.
|
overridevirtual |
Determines the owners of the edges.
The determination is based on the owners of the cells. There must be no ghost cell layers.
This operation is collective.
Implements Arcane::IMeshUtilities.
Definition at line 888 of file UnstructuredMeshUtilities.cc.
|
overridevirtual |
Determines the owners of the faces.
The determination is based on the owners of the cells. There must be no ghost cell layers.
This operation is collective.
Implements Arcane::IMeshUtilities.
Definition at line 898 of file UnstructuredMeshUtilities.cc.
|
overridevirtual |
Determines the owners of the nodes.
The determination is based on the owners of the cells. There must be no ghost cell layers.
This operation is collective.
Implements Arcane::IMeshUtilities.
Definition at line 878 of file UnstructuredMeshUtilities.cc.
|
overridevirtual |
The algorithm used is as follows:
Implements Arcane::IMeshUtilities.
Definition at line 651 of file UnstructuredMeshUtilities.cc.
References ARCANE_FATAL, Arcane::IParallelMng::barrier(), Arcane::TraceAccessor::debug(), ENUMERATE_NODE, Arcane::math::isZero(), Arcane::ItemGroup::name(), Arcane::Real3::normL2(), Arcane::IParallelMng::reduce(), Arcane::MessagePassing::ReduceSum, Arcane::Real3POD::x, Arcane::Real3POD::y, and Arcane::Real3POD::z.
|
overridevirtual |
Calculates the normal of a face group.
This method calculates the normal of a face group assuming that this surface is a plane. For the calculation, the algorithm tries to determine the nodes at the ends of this surface, and calculates a normal from these nodes. The orientation of the normal is undefined.
If the surface is not planar, the result is undefined.
The current algorithm does not always work on a surface composed solely of triangles.
This method is collective. The algorithm used guarantees the same results in sequential and parallel modes.
The variable nodes_coord is used as coordinates for the nodes. Generally, it is IMesh::nodesCoordinates().
Implements Arcane::IMeshUtilities.
Definition at line 431 of file UnstructuredMeshUtilities.cc.
References Arcane::Array< T >::add(), Arcane::IParallelMng::allGatherVariable(), ARCANE_FATAL, Arcane::Face::boundaryCell(), Arcane::IParallelMng::commRank(), Arcane::IParallelMng::computeMinMaxSum(), Arcane::math::cross(), ENUMERATE_FACE, Arcane::Face::frontCell(), Arcane::TraceAccessor::info(), Arcane::math::isNearlyEqual(), Arcane::Item::isOwn(), Arcane::Face::isSubDomainBoundary(), Arcane::math::isZero(), Arcane::ItemGroup::name(), Arcane::ItemWithNodes::nbNode(), Arcane::ItemWithNodes::node(), Arcane::ItemWithNodes::nodeIds(), Arcane::Real3::normL2(), Arcane::Item::null(), Arcane::Item::owner(), Arcane::IParallelMng::reduce(), Arcane::MessagePassing::ReduceSum, Arcane::math::scaMul(), Arcane::AbstractArray< T >::size(), Arcane::Real3::squareNormL2(), Arcane::math::vecMul(), Arcane::Real3POD::x, Arcane::Real3POD::y, and Arcane::Real3POD::z.
|
overridevirtual |
Searches for the local IDs of faces based on their connectivity.
Takes as input a list of entities described by the unique IDs (Item::uniqueId()) of their nodes and searches for the local IDs (Item::localId()) of these entities.
| items_type | array of ItemTypeId of the entities |
| items_connectivity | array containing the unique indices of the entities' nodes. |
| local_ids | in return, contains the local IDs of the entities. The number of elements in local_ids must be equal to that of items_nb_node. |
The array items_connectivity contains the node IDs of the faces, listed consecutively. For example, if items_type[0]==IT_Triangle3 and items_type[1]==IT_Quad4, then items_connectivity[0..2] will contain the nodes of entity 0, and items_connectivity[3..6] those of entity 1.
If allow_null is false, a fatal error is generated if an entity is not found; otherwise, NULL_ITEM_LOCAL_ID is returned for the corresponding entity.
Implements Arcane::IMeshUtilities.
Definition at line 325 of file UnstructuredMeshUtilities.cc.
References ARCANE_FATAL, Arcane::ConstArrayView< T >::data(), Arcane::IK_Node, Arcane::Item::localId(), Arcane::ItemTypeInfo::nbLocalNode(), Arcane::Item::null(), Arcane::ArrayView< T >::size(), Arcane::ConstArrayView< T >::size(), Arcane::StringBuilder::toString(), and Arcane::ItemTypeMng::typeFromId().
|
overridevirtual |
Searches for the local IDs of entities based on their connectivity.
This method is only implemented for order 1 faces.
Implements Arcane::IMeshUtilities.
Definition at line 244 of file UnstructuredMeshUtilities.cc.
References ARCANE_FATAL, Arcane::ConstArrayView< T >::data(), Arcane::IK_Cell, Arcane::IK_Face, Arcane::IK_Node, Arcane::Item::localId(), Arcane::Item::null(), Arcane::Array< T >::reserve(), Arcane::Array< T >::resize(), Arcane::ArrayView< T >::size(), Arcane::ConstArrayView< T >::size(), and Arcane::StringBuilder::toString().
|
overridevirtual |
Merges nodes.
Merges nodes in pairs from nodes_to_merge_local_id with those from nodes_local_id. Each node nodes_to_merge_local_id[i] is merged with nodes_local_id[i].
The nodes nodes_to_merge_local_id are destroyed after merging. Entities entirely resting on these merged nodes are also destroyed.
It is forbidden to merge two nodes from the same cell or the same face (after merging, a face or a cell cannot have the same node twice).
Once the merge is performed, the faces containing the merged nodes (nodes_to_merge_local_id) are destroyed. If allow_non_corresponding_face is false, then for each destroyed face, there must correspond an existing face with the merged nodes (nodes_local_id).
Implements Arcane::IMeshUtilities.
Definition at line 866 of file UnstructuredMeshUtilities.cc.
References Arcane::mesh::MeshNodeMerger::mergeNodes().
|
overridevirtual |
Repartitions and exchanges the mesh while managing replication.
This method performs a mesh repartitioning via the call to IMeshPartitioner::partitionMesh(bool) and proceeds to exchange entities via IPrimaryMesh::exchangeItems().
It also manages replication by ensuring that all replicas have the same mesh. The principle is as follows:
This method is collective across all replicas.
| partitioner | Instance of the partitioner to be used |
| initial_partition | Indicates if it is the initial partitioning. |
Implements Arcane::IMeshUtilities.
Definition at line 796 of file UnstructuredMeshUtilities.cc.
References Arcane::IParallelMng::barrier(), changeOwnersFromCells(), Arcane::IPrimaryMesh::exchangeItems(), Arcane::platform::getCurrentDateTime(), Arcane::IParallelReplication::hasReplication(), Arcane::TraceAccessor::info(), Arcane::IParallelReplication::isMasterRank(), Arcane::IParallelReplication::masterReplicationRank(), Arcane::IMeshPartitionerBase::notifyEndPartition(), Arcane::IMeshPartitionerBase::partitionMesh(), Arcane::IMeshPartitionerBase::primaryMesh(), Arcane::IParallelReplication::replicaParallelMng(), Arcane::IParallelMng::replication(), and Arcane::IParallelMng::timeStats().
|
overridevirtual |
Recalculates the uniqueId() of edges, faces, and cells based on the uniqueId() of the nodes.
Implements Arcane::IMeshUtilities.
Definition at line 930 of file UnstructuredMeshUtilities.cc.
References ARCANE_CHECK_POINTER, and Arcane::ITraceMng::info().
|
overridevirtual |
Writes the mesh to a file.
Writes the mesh to the file file_name using the service implementing the 'IMeshWriter' interface and named service_name.
| true | if the specified service is not available. |
| false | if everything is ok. |
Implements Arcane::IMeshUtilities.
Definition at line 775 of file UnstructuredMeshUtilities.cc.
References Arcane::ServiceBuilder< InterfaceType >::createReference(), Arcane::ServiceBuilder< InterfaceType >::getServicesNames(), Arcane::SB_AllowNull, and Arcane::TraceAccessor::warning().
|
private |
Definition at line 110 of file UnstructuredMeshUtilities.h.
|
private |
Definition at line 109 of file UnstructuredMeshUtilities.h.