Arcane  4.2.3.0
Developer documentation
Loading...
Searching...
No Matches
Arcane::mesh::FaceUniqueIdBuilder Class Reference

Construction of ghost layers. More...

#include <arcane/mesh/FaceUniqueIdBuilder.h>

Inheritance diagram for Arcane::mesh::FaceUniqueIdBuilder:
Collaboration diagram for Arcane::mesh::FaceUniqueIdBuilder:

Public Types

using BoundaryInfosMap = HashTableMapT<Int32, SharedArray<Int64>>
using BoundaryInfosMapEnumerator = HashTableMapEnumeratorT<Int32, SharedArray<Int64>>

Public Member Functions

 FaceUniqueIdBuilder (DynamicMeshIncrementalBuilder *mesh_builder)
 Constructs an instance for the mesh.
void computeFacesUniqueIds ()
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

Private Member Functions

void _computeFacesUniqueIdsSequential ()
 Calculates the unique IDs for each face sequentially.
void _computeFacesUniqueIdsParallelV1 ()
 Calculates the unique numbers for each face in parallel.
void _v1Distributed ()
 Distributed computation of the face numbering of version 1.
void _v1CheckAndDump (Int64ConstArrayView faces_new_uid, Int64ConstArrayView faces_opposite_cell_uid)
 Checks that every face has been numbered and, in verbose mode, writes one line per (cell, face) to faces_uid.<rank>.
void _v1CellBlockSizes (Int64ConstArrayView faces_opposite_cell_uid, IntegerArray &my_cells_nb_back_face, Array< T_CellFaceInfo > &my_cells_faces_info)
 Sizes every cell's block of face ids: its back faces plus its faces of the domain boundary.
void _v1ByAllGather (Int64ArrayView faces_opposite_cell_uid, IntegerArrayView faces_opposite_cell_index, IntegerArrayView faces_opposite_cell_owner, HashTableMapT< Int64, Int64 > &cells_first_face_uid, IntegerArray &my_cells_nb_back_face, Array< T_CellFaceInfo > &my_cells_faces_info)
 The all-gather: every rank receives every boundary face, then every cell of the mesh, and keeps what concerns it.
void _v1AssignFaceUniqueIds (Int64ConstArrayView faces_opposite_cell_uid, IntegerConstArrayView faces_opposite_cell_index, IntegerConstArrayView faces_opposite_cell_owner, HashTableMapT< Int64, Int64 > &cells_first_face_uid, IntegerConstArrayView my_cells_nb_back_face)
 Gives every face its uniqueId and its owner from the block starts.
void _computeFacesUniqueIdsParallelV2 ()
 Calculates the unique IDs for each face in parallel V2.
void _exchangeData (IParallelExchanger *exchanger, BoundaryInfosMap &boundary_infos_to_send)
void _checkNoDuplicate ()
 Checks that there are no duplicate uniqueIds.

Private Attributes

DynamicMesh * m_mesh = nullptr
DynamicMeshIncrementalBuilder * m_mesh_builder = nullptr
bool m_is_v1_distributed = false
 Distribute the face numbering of version 1 (ARCANE_DISTRIBUTED_FACE_NUMBERING=1).

Additional Inherited Members

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

Detailed Description

Construction of ghost layers.

Definition at line 38 of file FaceUniqueIdBuilder.h.

Member Typedef Documentation

◆ BoundaryInfosMap

using Arcane::mesh::FaceUniqueIdBuilder::BoundaryInfosMap = HashTableMapT<Int32, SharedArray<Int64>>

Definition at line 43 of file FaceUniqueIdBuilder.h.

◆ BoundaryInfosMapEnumerator

using Arcane::mesh::FaceUniqueIdBuilder::BoundaryInfosMapEnumerator = HashTableMapEnumeratorT<Int32, SharedArray<Int64>>

Definition at line 44 of file FaceUniqueIdBuilder.h.

Constructor & Destructor Documentation

◆ FaceUniqueIdBuilder()

Arcane::mesh::FaceUniqueIdBuilder::FaceUniqueIdBuilder ( DynamicMeshIncrementalBuilder * mesh_builder)
explicit

Constructs an instance for the mesh.

Definition at line 61 of file FaceUniqueIdBuilder.cc.

References m_is_v1_distributed, Arcane::TraceAccessor::TraceAccessor(), and Arcane::TraceAccessor::traceMng().

Here is the call graph for this function:

Member Function Documentation

◆ _checkNoDuplicate()

void Arcane::mesh::FaceUniqueIdBuilder::_checkNoDuplicate ( )
private

Checks that there are no duplicate uniqueIds.

Definition at line 150 of file FaceUniqueIdBuilder.cc.

References ARCANE_FATAL, Arcane::mesh::ItemInternalMap::eachItem(), Arcane::TraceAccessor::info(), Arcane::TraceAccessor::pwarning(), and Arcane::Item::uniqueId().

Here is the call graph for this function:

◆ _computeFacesUniqueIdsParallelV1()

void Arcane::mesh::FaceUniqueIdBuilder::_computeFacesUniqueIdsParallelV1 ( )
private

Calculates the unique numbers for each face in parallel.

In addition to numbering, it determines the owning sub-domain of each face, considering that a face belongs to the same sub-domain as the cell behind it (or to the current sub-domain for a boundary cell).

A face is numbered from its back cell: the cells, in increasing uniqueId, each own a contiguous block of face ids, one per face they are behind plus one per face of the domain boundary they hold, and a face takes its position in the block. This is a global computation: a face's uniqueId depends on the cells of every sub-domain with a smaller uniqueId.

By default every rank performs that computation whole: it gathers the sub-domain boundary faces and then the cells of the entire mesh, and numbers the mesh sequentially to keep its own share (_v1ByAllGather()). With ARCANE_DISTRIBUTED_FACE_NUMBERING=1 the computation itself is distributed over the ranks (_v1Distributed()), with the same uniqueIds.

Definition at line 349 of file FaceUniqueIdBuilder.cc.

References _v1AssignFaceUniqueIds(), _v1ByAllGather(), _v1Distributed(), Arcane::Array< T >::fill(), and m_is_v1_distributed.

Here is the call graph for this function:

◆ _computeFacesUniqueIdsParallelV2()

void Arcane::mesh::FaceUniqueIdBuilder::_computeFacesUniqueIdsParallelV2 ( )
private

Calculates the unique IDs for each face in parallel V2.

Note
This version is used for testing but has never been put into service and is now replaced by ...

Definition at line 1393 of file FaceUniqueIdBuilder.cc.

References _exchangeData(), Arcane::Array< T >::add(), ARCANE_FATAL, Arcane::Face::backCell(), Arcane::IParallelMng::barrier(), Arcane::Array< T >::clear(), Arcane::IParallelMng::commRank(), Arcane::IParallelMng::commSize(), Arcane::ParallelMngUtils::createExchangerRef(), Arcane::TraceAccessor::debug(), Arcane::mesh::ItemInternalMap::eachItem(), Arcane::Array< T >::fill(), Arcane::ITraceMng::flush(), Arcane::Face::frontCell(), Arcane::RefImpl< InstanceType, RefClassType, ImplTagId >::get(), Arcane::ISerializer::getInt64(), Arcane::ISerializer::getSpan(), Arcane::TraceAccessor::info(), Arcane::Item::localId(), Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::lookupAdd(), Arcane::math::max(), Arcane::IItemFamily::maxLocalId(), Arcane::ISerializer::ModeGet, Arcane::Face::nbCell(), Arcane::ItemTypeInfo::nbLocalNode(), Arcane::ItemWithNodes::nbNode(), Arcane::ItemWithNodes::node(), Arcane::ItemWithNodes::nodes(), Arcane::Item::null(), Arcane::ItemBase::null(), Arcane::IParallelMng::reduce(), Arcane::MessagePassing::ReduceMax, Arcane::Array< T >::reserve(), Arcane::Array< T >::resize(), Arcane::MessagePassing::ISerializeMessage::serializer(), Arcane::ISerializer::setMode(), Arcane::MutableItemBase::setOwner(), Arcane::TraceAccessor::traceMng(), Arcane::mesh::ItemInternalMap::tryFind(), Arcane::Item::type(), Arcane::ItemTypeMng::typeFromId(), and Arcane::Item::uniqueId().

Here is the call graph for this function:

◆ _computeFacesUniqueIdsSequential()

void Arcane::mesh::FaceUniqueIdBuilder::_computeFacesUniqueIdsSequential ( )
private

Calculates the unique IDs for each face sequentially.

See also
computeFacesUniqueIds()

Definition at line 1629 of file FaceUniqueIdBuilder.cc.

References Arcane::mesh::ItemInternalMap::eachItem(), Arcane::Cell::faces(), Arcane::TraceAccessor::info(), and Arcane::Item::uniqueId().

Here is the call graph for this function:

◆ _exchangeData()

◆ _v1AssignFaceUniqueIds()

void Arcane::mesh::FaceUniqueIdBuilder::_v1AssignFaceUniqueIds ( Int64ConstArrayView faces_opposite_cell_uid,
IntegerConstArrayView faces_opposite_cell_index,
IntegerConstArrayView faces_opposite_cell_owner,
HashTableMapT< Int64, Int64 > & cells_first_face_uid,
IntegerConstArrayView my_cells_nb_back_face )
private

Gives every face its uniqueId and its owner from the block starts.

Definition at line 998 of file FaceUniqueIdBuilder.cc.

References _v1CheckAndDump(), Arcane::IParallelMng::commRank(), Arcane::mesh::ItemInternalMap::eachItem(), Arcane::Cell::faces(), Arcane::TraceAccessor::fatal(), Arcane::Array< T >::fill(), Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::hasKey(), Arcane::Item::localId(), and Arcane::Item::uniqueId().

Referenced by _computeFacesUniqueIdsParallelV1().

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

◆ _v1ByAllGather()

void Arcane::mesh::FaceUniqueIdBuilder::_v1ByAllGather ( Int64ArrayView faces_opposite_cell_uid,
IntegerArrayView faces_opposite_cell_index,
IntegerArrayView faces_opposite_cell_owner,
HashTableMapT< Int64, Int64 > & cells_first_face_uid,
IntegerArray & my_cells_nb_back_face,
Array< T_CellFaceInfo > & my_cells_faces_info )
private

The all-gather: every rank receives every boundary face, then every cell of the mesh, and keeps what concerns it.

Todo
optimize the algorithm so as not to have to create an array sized to the total number of cells in the mesh (by proceeding in several steps)

Definition at line 1067 of file FaceUniqueIdBuilder.cc.

References _v1CellBlockSizes(), Arcane::Array< T >::add(), Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::add(), Arcane::MutableItemBase::addFlags(), Arcane::IParallelMng::allGatherVariable(), Arcane::Face::cell(), Arcane::Array< T >::clear(), Arcane::IParallelMng::commRank(), Arcane::IParallelMng::commSize(), Arcane::Array< T >::data(), Arcane::TraceAccessor::debug(), Arcane::mesh::ItemInternalMap::eachItem(), Arcane::Cell::faces(), Arcane::mesh::ItemTools::findFaceInNode2(), Arcane::ItemBase::flags(), Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::hasKey(), Arcane::mesh::ItemInternalMap::hasKey(), Arcane::ItemFlags::II_HasBackCell, Arcane::ItemFlags::II_Shared, Arcane::ItemFlags::II_SubDomainBoundary, Arcane::TraceAccessor::info(), Arcane::Face::isSubDomainBoundary(), Arcane::Item::itemBase(), Arcane::Item::localId(), Arcane::Item::mutableItemBase(), Arcane::ItemTypeInfo::nbLocalNode(), Arcane::ItemWithNodes::nodes(), Arcane::Item::null(), Arcane::Item::owner(), Arcane::IParallelMng::reduce(), Arcane::MessagePassing::ReduceMax, Arcane::MessagePassing::ReduceSum, Arcane::Array< T >::reserve(), Arcane::AbstractArray< T >::size(), Arcane::mesh::ItemInternalMap::tryFind(), Arcane::Item::type(), Arcane::ItemTypeMng::typeFromId(), and Arcane::Item::uniqueId().

Referenced by _computeFacesUniqueIdsParallelV1().

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

◆ _v1CellBlockSizes()

void Arcane::mesh::FaceUniqueIdBuilder::_v1CellBlockSizes ( Int64ConstArrayView faces_opposite_cell_uid,
IntegerArray & my_cells_nb_back_face,
Array< T_CellFaceInfo > & my_cells_faces_info )
private

Sizes every cell's block of face ids: its back faces plus its faces of the domain boundary.

Definition at line 875 of file FaceUniqueIdBuilder.cc.

References Arcane::Array< T >::add(), Arcane::Array< T >::clear(), Arcane::mesh::ItemInternalMap::eachItem(), Arcane::Array< T >::fill(), Arcane::Item::localId(), Arcane::Array< T >::reserve(), Arcane::Array< T >::resize(), and Arcane::Item::uniqueId().

Referenced by _v1ByAllGather().

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

◆ _v1CheckAndDump()

void Arcane::mesh::FaceUniqueIdBuilder::_v1CheckAndDump ( Int64ConstArrayView faces_new_uid,
Int64ConstArrayView faces_opposite_cell_uid )
private

Checks that every face has been numbered and, in verbose mode, writes one line per (cell, face) to faces_uid.<rank>.

faces_opposite_cell_uid is NULL_ITEM_ID for a face of the domain boundary, the cell on the other side for a shared face, or a negative value when that cell is not known here (it is then not written).

Definition at line 919 of file FaceUniqueIdBuilder.cc.

References ARCANE_FATAL, Arcane::mesh::ItemInternalMap::eachItem(), Arcane::TraceAccessor::error(), Arcane::Cell::faces(), Arcane::TraceAccessor::info(), Arcane::String::localstr(), and Arcane::Item::uniqueId().

Referenced by _v1AssignFaceUniqueIds(), and _v1Distributed().

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

◆ _v1Distributed()

void Arcane::mesh::FaceUniqueIdBuilder::_v1Distributed ( )
private

Distributed computation of the face numbering of version 1.

Each rank computes a share of the numbering instead of all of it, and holds O(N/P + B) data instead of O(N), for N cells, P ranks and B faces on the boundary of its sub-domain; the number of collectives does not depend on N.

Two facts come from the other sub-domains: for a face with one cell here, whether a cell is on the other side and on which rank (if not, the face is on the boundary of the domain); and where every cell's block starts, which is the sum of the block sizes of all the cells of smaller uniqueId, a prefix sum over the whole mesh. Only the rank in front of a shared face needs both: the rank behind it numbers it from its own cell's block.

  1. Matching the faces, by a rendezvous. Each face with one cell here is sent to a rank that every holder of the face computes from the face alone, a hash of its smallest node uniqueId. The two halves of a shared face meet there and each learns the rank of the other. A face that arrives alone is on the domain boundary and gets no answer, but when its cell is in front of it (it then counts in that cell's block) the cell is passed on to the rank that computes the start of that cell's block.
  2. The block starts, by a parallel prefix sum over the cells in uniqueId order. The uniqueId range is cut in one slice per rank, at bounds taken from a histogram so that the slices hold the same amount of work. The cells of a rank form runs of consecutive uniqueIds, inside which no cell of another rank can sit, so a run travels as one record (first, count, back faces) to the rank of its slice. The totals of the slices are summed over the ranks while step 1 completes, which gives every slice its offset; a slice orders its runs, adds the boundary faces of step 1 and answers each run with its start, from which the owner of the run deduces the start of each of its cells.
  3. The shared faces. The rank behind a shared face sends its uniqueId to the rank in front; both list the faces they share in node order, so no key travels with the uniqueIds.

Step 2 is sent while step 1 travels. A mesh the numbering cannot describe (a face held by more than two sub-domains or behind on both, a cell held by two ranks or by none) is a fatal error: the gathering version numbers it inconsistently without a word.

Step 1 is inspired by the rendezvous algorithm of Plimpton, Hendrickson and Stewart (J. Parallel Distrib. Comput., 2004).

Definition at line 418 of file FaceUniqueIdBuilder.cc.

References _v1CheckAndDump(), Arcane::Array< T >::add(), Arcane::MutableItemBase::addFlags(), Arcane::IParallelNonBlockingCollective::allReduce(), ARCANE_FATAL, Arcane::Face::backCell(), Arcane::Array< T >::begin(), Arcane::Array< T >::clear(), Arcane::IParallelMng::commRank(), Arcane::IParallelMng::commSize(), Arcane::Array< T >::copy(), Arcane::mesh::ItemInternalMap::count(), Arcane::Array< T >::data(), Arcane::SpanImpl< T, SizeType, Extent >::data(), Arcane::mesh::ItemInternalMap::eachItem(), Arcane::Array< T >::end(), Arcane::mesh::Int64AllToAll::exchangeCounts(), Arcane::Cell::faces(), Arcane::Array< T >::fill(), Arcane::mesh::Int64AllToAll::from(), Arcane::ItemFlags::II_HasBackCell, Arcane::ItemFlags::II_Shared, Arcane::ItemFlags::II_SubDomainBoundary, Arcane::TraceAccessor::info(), Arcane::Face::isSubDomainBoundary(), Arcane::Item::localId(), Arcane::Item::mutableItemBase(), Arcane::Face::nbCell(), Arcane::ItemWithNodes::nbNode(), Arcane::ItemWithNodes::nodes(), Arcane::IParallelMng::nonBlockingCollective(), Arcane::Item::owner(), Arcane::mesh::Int64AllToAll::received(), Arcane::IParallelMng::reduce(), Arcane::MessagePassing::ReduceMax, Arcane::MessagePassing::ReduceSum, Arcane::Array< T >::reserve(), Arcane::Array< T >::resize(), Arcane::MutableItemBase::setOwner(), Arcane::AbstractArray< T >::size(), Arcane::SpanImpl< T, SizeType, Extent >::size(), Arcane::mesh::Int64AllToAll::start(), Arcane::Array< T >::subConstView(), Arcane::Item::uniqueId(), Arcane::mesh::Int64AllToAll::wait(), and Arcane::IParallelMng::waitAllRequests().

Referenced by _computeFacesUniqueIdsParallelV1().

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

◆ computeFacesUniqueIds()

void Arcane::mesh::FaceUniqueIdBuilder::computeFacesUniqueIds ( )

Definition at line 76 of file FaceUniqueIdBuilder.cc.

Member Data Documentation

◆ m_is_v1_distributed

bool Arcane::mesh::FaceUniqueIdBuilder::m_is_v1_distributed = false
private

Distribute the face numbering of version 1 (ARCANE_DISTRIBUTED_FACE_NUMBERING=1).

Definition at line 60 of file FaceUniqueIdBuilder.h.

Referenced by _computeFacesUniqueIdsParallelV1(), and FaceUniqueIdBuilder().

◆ m_mesh

DynamicMesh* Arcane::mesh::FaceUniqueIdBuilder::m_mesh = nullptr
private

Definition at line 57 of file FaceUniqueIdBuilder.h.

◆ m_mesh_builder

DynamicMeshIncrementalBuilder* Arcane::mesh::FaceUniqueIdBuilder::m_mesh_builder = nullptr
private

Definition at line 58 of file FaceUniqueIdBuilder.h.


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