Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Arcane::UnstructuredMeshUtilities Class Reference

Utility functions for a mesh. More...

#include <arcane/mesh/UnstructuredMeshUtilities.h>

Inheritance diagram for Arcane::UnstructuredMeshUtilities:
Collaboration diagram for Arcane::UnstructuredMeshUtilities:

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.
TraceAccessoroperator= (const TraceAccessor &rhs)
 Copy assignment operator.
virtual ~TraceAccessor ()
 Frees resources.
ITraceMngtraceMng () 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

IMeshm_mesh = nullptr
BasicItemPairGroupComputeFunctorm_compute_adjacency_functor = nullptr

Additional Inherited Members

Protected Member Functions inherited from Arcane::TraceAccessor
void _setLocalVerboseLevel (Int32 v)
Int32 _localVerboseLevel () const

Detailed Description

Utility functions for a mesh.

Definition at line 40 of file UnstructuredMeshUtilities.h.

Constructor & Destructor Documentation

◆ UnstructuredMeshUtilities()

Arcane::UnstructuredMeshUtilities::UnstructuredMeshUtilities ( IMesh * mesh)
explicit

Definition at line 68 of file UnstructuredMeshUtilities.cc.

◆ ~UnstructuredMeshUtilities()

Arcane::UnstructuredMeshUtilities::~UnstructuredMeshUtilities ( )
override

Frees resources.

Definition at line 79 of file UnstructuredMeshUtilities.cc.

Member Function Documentation

◆ _broadcastFarthestNode()

Real3 Arcane::UnstructuredMeshUtilities::_broadcastFarthestNode ( Real distance,
const Node & node,
const VariableNodeReal3 & nodes_coord )
private

Definition at line 722 of file UnstructuredMeshUtilities.cc.

◆ _round()

Real3 Arcane::UnstructuredMeshUtilities::_round ( Real3 value)
private

Definition at line 399 of file UnstructuredMeshUtilities.cc.

◆ changeOwnersFromCells()

void Arcane::UnstructuredMeshUtilities::changeOwnersFromCells ( )
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.

Note
This method requires that the synchronization information be valid. If you want to determine the owners of entities without prior information, you must use computeAndSetOwnersForNodes() or computeAndSetOwnersForFaces().

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ computeAdjency()

void Arcane::UnstructuredMeshUtilities::computeAdjency ( ItemPairGroup adjacency_array,
eItemKind link_kind,
Integer nb_layer )
overridevirtual

Calculates adjacencies, stored in adjacency_array.

Implements Arcane::IMeshUtilities.

Definition at line 766 of file UnstructuredMeshUtilities.cc.

◆ computeAndSetOwnersForEdges()

void Arcane::UnstructuredMeshUtilities::computeAndSetOwnersForEdges ( )
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.

◆ computeAndSetOwnersForFaces()

void Arcane::UnstructuredMeshUtilities::computeAndSetOwnersForFaces ( )
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.

◆ computeAndSetOwnersForNodes()

void Arcane::UnstructuredMeshUtilities::computeAndSetOwnersForNodes ( )
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.

◆ computeDirection()

Real3 Arcane::UnstructuredMeshUtilities::computeDirection ( const NodeGroup & node_group,
const VariableNodeReal3 & nodes_coord,
Real3 * n1,
Real3 * n2 )
overridevirtual

The algorithm used is as follows:

  1. calculates the barycenter of the set of nodes.
  2. determines the node farthest from this barycenter, denoted n1
  3. determines the node farthest from n1, denoted n2.
  4. determines the direction from the coordinates of n1 and n2.

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.

Here is the call graph for this function:

◆ computeNormal()

Real3 Arcane::UnstructuredMeshUtilities::computeNormal ( const FaceGroup & face_group,
const VariableNodeReal3 & nodes_coord )
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.

Here is the call graph for this function:

◆ getFacesLocalIdFromConnectivity()

void Arcane::UnstructuredMeshUtilities::getFacesLocalIdFromConnectivity ( ConstArrayView< ItemTypeId > items_type,
ConstArrayView< Int64 > items_connectivity,
ArrayView< Int32 > local_ids,
bool allow_null )
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.

Parameters
items_typearray of ItemTypeId of the entities
items_connectivityarray containing the unique indices of the entities' nodes.
local_idsin 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().

Here is the call graph for this function:

◆ localIdsFromConnectivity()

void Arcane::UnstructuredMeshUtilities::localIdsFromConnectivity ( eItemKind item_kind,
IntegerConstArrayView items_nb_node,
Int64ConstArrayView items_connectivity,
Int32ArrayView local_ids,
bool allow_null )
overridevirtual

Searches for the local IDs of entities based on their connectivity.

This method is only implemented for order 1 faces.

Deprecated
Use getFacesLocalIdFromConnectivity() instead.

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().

Here is the call graph for this function:

◆ mergeNodes()

void Arcane::UnstructuredMeshUtilities::mergeNodes ( Int32ConstArrayView nodes_local_id,
Int32ConstArrayView nodes_to_merge_local_id,
bool allow_non_corresponding_face )
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().

Here is the call graph for this function:

◆ partitionAndExchangeMeshWithReplication()

void Arcane::UnstructuredMeshUtilities::partitionAndExchangeMeshWithReplication ( IMeshPartitionerBase * partitioner,
bool initial_partition )
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:

  • only the master replica performs the repartitioning by calling IMeshPartitioner::partitionMesh() with partitioner as the partitioner
  • the values of IItemFamily::itemsNewOwner() are then synchronized with the other replicas.
  • entity exchanges are performed via IPrimaryMesh::exchangeItems().

This method is collective across all replicas.

Precondition
All replicas must have the same mesh, meaning that all entity families must be identical except for particle families which are not concerned.
The mesh must be an instance of IPrimaryMesh.
Postcondition
All replicas have the same mesh except for particle families.
Parameters
partitionerInstance of the partitioner to be used
initial_partitionIndicates 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().

Here is the call graph for this function:

◆ recomputeItemsUniqueIdFromNodesUniqueId()

void Arcane::UnstructuredMeshUtilities::recomputeItemsUniqueIdFromNodesUniqueId ( )
overridevirtual

Recalculates the uniqueId() of edges, faces, and cells based on the uniqueId() of the nodes.

Warning
This method is experimental and should only be used within Arcane. It assumes that the uniqueId() of the entities are constructed from generateHashUniqueId().

Implements Arcane::IMeshUtilities.

Definition at line 930 of file UnstructuredMeshUtilities.cc.

References ARCANE_CHECK_POINTER, and Arcane::ITraceMng::info().

Here is the call graph for this function:

◆ writeToFile()

bool Arcane::UnstructuredMeshUtilities::writeToFile ( const String & file_name,
const String & service_name )
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.

Return values
trueif the specified service is not available.
falseif 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().

Here is the call graph for this function:

Member Data Documentation

◆ m_compute_adjacency_functor

BasicItemPairGroupComputeFunctor* Arcane::UnstructuredMeshUtilities::m_compute_adjacency_functor = nullptr
private

Definition at line 110 of file UnstructuredMeshUtilities.h.

◆ m_mesh

IMesh* Arcane::UnstructuredMeshUtilities::m_mesh = nullptr
private

Definition at line 109 of file UnstructuredMeshUtilities.h.


The documentation for this class was generated from the following files: