LevelCommunicationPattern< dim > Class Template Reference

Developer Documentation: MeltPoolDG::LevelCommunicationPattern< dim > Class Template Reference
Developer Documentation
MeltPoolDG::LevelCommunicationPattern< dim > Class Template Reference

Computes and stores the MPI communication pattern for a given level of a distributed triangulation. More...

#include <triangulation_utils.hpp>

Public Member Functions

 LevelCommunicationPattern (const dealii::Triangulation< dim > &tria)
 
void build_pattern (const unsigned int level)
 
std::map< unsigned int, std::vector< dealii::CellId > > cells_to_send () const
 
std::map< unsigned int, std::vector< dealii::CellId > > cells_to_receive () const
 
unsigned n_processes_to_send_to () const
 
unsigned n_processes_to_receive_from () const
 
unsigned int n_send_ranks () const
 
unsigned int n_receive_ranks () const
 
std::vector< unsigned int > send_ranks () const
 
std::vector< unsigned int > receive_ranks () const
 

Private Member Functions

std::vector< dealii::CellId > owned_active_cells_ancestors () const
 
std::vector< std::pair< unsigned, std::vector< dealii::CellId > > > gather_ancestors (const std::vector< dealii::CellId > &local_ancestor_cells) const
 
std::vector< dealii::CellId > adjacent_relevant_cells (const dealii::CellId &cell_id, const std::vector< dealii::CellId > &owned_active_cell_ancestors, const LevelAdjacentCellsCache< dim > &adjacent_cells_cache) const
 
std::vector< std::pair< unsigned, std::vector< dealii::CellId > > > relevant_cells_for_ranks (const std::vector< std::pair< unsigned, std::vector< dealii::CellId > > > &requested_cells_by_rank, const std::vector< dealii::CellId > &owned_active_cell_ancestors) const
 
std::vector< std::pair< unsigned, std::vector< dealii::CellId > > > exchange_relevant_cells (const std::vector< std::pair< unsigned, std::vector< dealii::CellId > > > &cells_to_send) const
 
void store_rank_cell_maps (const std::vector< std::pair< unsigned, std::vector< dealii::CellId > > > &data_to_receive, const std::vector< std::pair< unsigned, std::vector< dealii::CellId > > > &data_to_send)
 
void build_communication_pattern ()
 
void assert_pattern_built () const
 

Private Attributes

std::map< unsigned int, std::vector< dealii::CellId > > rank_to_cells_send
 
std::map< unsigned int, std::vector< dealii::CellId > > rank_to_cells_receive
 
const dealii::Triangulation< dim > & triangulation
 Reference to the triangulation for which the communication pattern is built.
 
unsigned int partition_level = 0
 The cell level on which the communication pattern is built.
 
const MPI_Comm mpi_communicator
 
bool is_pattern_built = false
 A boolean indicating whether the communication pattern has been built, i.e., whether.
 

Detailed Description

template<int dim>
class MeltPoolDG::LevelCommunicationPattern< dim >

Computes and stores the MPI communication pattern for a given level of a distributed triangulation.

The pattern implemented in this class is designed such that each rank that owns an active cell being a descendant of a cell on the specified level gets the information about that cell and its adjacent cells on the same level from the rank owning the corresponding cell on the specified level. Hereby, adjacency is defined as vertex-sharing, i.e., two cells are considered adjacent if they share at least one vertex.

This class is strictly designed to analyze the triangulation and determine the communication pattern (i.e., which cell IDs need to be sent to which ranks and which cell IDs are expected to be received from which ranks). It does not perform the actual data communication itself. Instead, it exposes this metadata blueprint via getter functions so that the actual communication can be implemented elsewhere in the user-code.

To understand the functionality of the different member functions, it is beneficial to familiarize yourself with the following definitions:

  • Partition-level: The refinement level on the triangulation for which the communication pattern is built. This level is specified by the user when calling the build_pattern() function.
  • Descendant cells: The active cells on the triangulation that aredescendants of a cell on the partition-level.
  • Ancestor cells: The cells on the partition-level that contain at least one locally owned active descendant cell.
  • Adjacent cells: Cells on the same level that share at least one vertex with a given cell.
  • Relevant cells: Depend on the context of the cell being queried: For an ancestor cell on the partition-level relevant cells are the ancestor cell itself and all adjacent cells on the same level. For an active cell on the triangulation, the relevant cells are the ancestor cell of that active cell and all adjacent cells on the same level.
Note
This class assumes that the relevant partition-level cells are available at least as artificial cells on the current MPI rank, which is guaranteed if the triangulation was created with the multigrid hierarchy enabled.

Constructor & Destructor Documentation

◆ LevelCommunicationPattern()

template<int dim>
MeltPoolDG::LevelCommunicationPattern< dim >::LevelCommunicationPattern ( const dealii::Triangulation< dim > &  tria)

Member Function Documentation

◆ adjacent_relevant_cells()

template<int dim>
std::vector< dealii::CellId > MeltPoolDG::LevelCommunicationPattern< dim >::adjacent_relevant_cells ( const dealii::CellId &  cell_id,
const std::vector< dealii::CellId > &  owned_active_cell_ancestors,
const LevelAdjacentCellsCache< dim > &  adjacent_cells_cache 
) const
private

Given a partition-level cell, determine all adjacent cells which are a rank local ancestor cell.

Parameters
cell_idCell id of the partition-level cell whose adjacent relevant cells should be determined.
owned_active_cell_ancestorsCell ids of the partition-level cells containing locally owned active descendant cells.
adjacent_cells_cacheThe cache of adjacent cells for the partition-level cells to allow for efficient lookup of adjacent cells.
Returns
Cell ids of the adjacent relevant cells.

◆ assert_pattern_built()

template<int dim>
void MeltPoolDG::LevelCommunicationPattern< dim >::assert_pattern_built ( ) const
private

Assert that the communication pattern has been built before accessing it. If the pattern has not been built, an exception is thrown.

◆ build_communication_pattern()

template<int dim>
void MeltPoolDG::LevelCommunicationPattern< dim >::build_communication_pattern ( )
private

Build the MPI communication pattern for the current partition level.

◆ build_pattern()

template<int dim>
void MeltPoolDG::LevelCommunicationPattern< dim >::build_pattern ( const unsigned int  level)

Build the communication pattern for the given level. This includes determining which cells on the partition level are relevant for the local process and which other processes need to receive data from or send data to the local process based on the adjacency of cells on the partition level. The communication pattern is stored internally in the class and can be accessed via the provided getter functions.

Parameters
levelThe level for which the communication pattern should be built.

◆ cells_to_receive()

template<int dim>
std::map< unsigned int, std::vector< dealii::CellId > > MeltPoolDG::LevelCommunicationPattern< dim >::cells_to_receive ( ) const

Get a map that assigns to each MPI rank the cell ids of locally available cells for which the current process needs to receive data from the corresponding other rank.

◆ cells_to_send()

template<int dim>
std::map< unsigned int, std::vector< dealii::CellId > > MeltPoolDG::LevelCommunicationPattern< dim >::cells_to_send ( ) const

Get a map that assigns to each MPI rank the cell ids of the locally available cells for which the current process needs to send data to the corresponding other rank.

◆ exchange_relevant_cells()

template<int dim>
std::vector< std::pair< unsigned, std::vector< dealii::CellId > > > MeltPoolDG::LevelCommunicationPattern< dim >::exchange_relevant_cells ( const std::vector< std::pair< unsigned, std::vector< dealii::CellId > > > &  cells_to_send) const
private

Exchange relevant cells with other MPI processes. Each process sends the relevant cells adjacent to the requested partition-level cells to the corresponding MPI rank and receives the relevant cells adjacent to the requested partition-level cells from the other MPI ranks

Parameters
cells_to_sendA vector of pairs with the first element being the MPI rank and the second element being the corresponding relevant cells for which the corresponding MPI process will receive data from the current process.
Returns
A vector of pairs with the first element being the MPI rank and the second element being the corresponding relevant cells for which the current MPI process will receive data from the corresponding MPI process.

◆ gather_ancestors()

template<int dim>
std::vector< std::pair< unsigned, std::vector< dealii::CellId > > > MeltPoolDG::LevelCommunicationPattern< dim >::gather_ancestors ( const std::vector< dealii::CellId > &  local_ancestor_cells) const
private

Gather the relevant partition-level cells from all MPI ranks.

Parameters
local_ancestor_cellsCell ids of the partition-level cells relevant to the current MPI rank.
Returns
A vector containing, for each MPI rank, the corresponding relevant partition-level cell ids.

◆ n_processes_to_receive_from()

template<int dim>
unsigned MeltPoolDG::LevelCommunicationPattern< dim >::n_processes_to_receive_from ( ) const
inline

Return the number of processes from which the current process needs to receive data.

◆ n_processes_to_send_to()

template<int dim>
unsigned MeltPoolDG::LevelCommunicationPattern< dim >::n_processes_to_send_to ( ) const
inline

Return the number of processes to which the current process needs to send data.

◆ n_receive_ranks()

template<int dim>
unsigned int MeltPoolDG::LevelCommunicationPattern< dim >::n_receive_ranks ( ) const

Number of ranks from which data is received.

◆ n_send_ranks()

template<int dim>
unsigned int MeltPoolDG::LevelCommunicationPattern< dim >::n_send_ranks ( ) const

Number of ranks to which data is sent.

◆ owned_active_cells_ancestors()

template<int dim>
std::vector< dealii::CellId > MeltPoolDG::LevelCommunicationPattern< dim >::owned_active_cells_ancestors ( ) const
private

Return the cells on the partition level that contain at least one locally owned active descendant cell. The returned cells may be locally owned, ghost, or artificial cells.

Returns
Cell ids of the relevant cells on the partition level.
Note
This function assumes that the relevant partition-level cells are available at least as artificial cells on the current MPI rank. This is guaranteed if the triangulation was created with the multigrid hierarchy enabled.

◆ receive_ranks()

template<int dim>
std::vector< unsigned int > MeltPoolDG::LevelCommunicationPattern< dim >::receive_ranks ( ) const

MPI ranks from which data is received.

◆ relevant_cells_for_ranks()

template<int dim>
std::vector< std::pair< unsigned, std::vector< dealii::CellId > > > MeltPoolDG::LevelCommunicationPattern< dim >::relevant_cells_for_ranks ( const std::vector< std::pair< unsigned, std::vector< dealii::CellId > > > &  requested_cells_by_rank,
const std::vector< dealii::CellId > &  owned_active_cell_ancestors 
) const
private

For each MPI rank, determine the relevant rank local cells adjacent to the cells requested by that rank. In this case adjacent cells include the cell itself and all cells on the same level sharing at least one vertex with it.

Parameters
requested_cells_by_rankVector containing, for each MPI rank, the corresponding relevant partition-level cells they need to know about.
owned_active_cell_ancestorsCell ids of the partition-level cells containing locally owned active descendant cells.
Returns
A vector whose entries contain an MPI rank together with the corresponding adjacent relevant local cells.

◆ send_ranks()

template<int dim>
std::vector< unsigned int > MeltPoolDG::LevelCommunicationPattern< dim >::send_ranks ( ) const

MPI ranks to which data is sent.

◆ store_rank_cell_maps()

template<int dim>
void MeltPoolDG::LevelCommunicationPattern< dim >::store_rank_cell_maps ( const std::vector< std::pair< unsigned, std::vector< dealii::CellId > > > &  data_to_receive,
const std::vector< std::pair< unsigned, std::vector< dealii::CellId > > > &  data_to_send 
)
private

Store the computed send and receive communication pattern.

Member Data Documentation

◆ is_pattern_built

template<int dim>
bool MeltPoolDG::LevelCommunicationPattern< dim >::is_pattern_built = false
private

A boolean indicating whether the communication pattern has been built, i.e., whether.

◆ mpi_communicator

template<int dim>
const MPI_Comm MeltPoolDG::LevelCommunicationPattern< dim >::mpi_communicator
private

MPI communicator for the communication within the communication pattern. This is typically the same as the one of the triangulation, but it is stored here separately for better readability.

◆ partition_level

template<int dim>
unsigned int MeltPoolDG::LevelCommunicationPattern< dim >::partition_level = 0
private

The cell level on which the communication pattern is built.

◆ rank_to_cells_receive

template<int dim>
std::map<unsigned int, std::vector<dealii::CellId> > MeltPoolDG::LevelCommunicationPattern< dim >::rank_to_cells_receive
private

Map that assigns to each MPI rank the cell ids of locally available partition-level cells for which the current process needs to receive data from the corresponding other rank.

◆ rank_to_cells_send

template<int dim>
std::map<unsigned int, std::vector<dealii::CellId> > MeltPoolDG::LevelCommunicationPattern< dim >::rank_to_cells_send
private

Map that assigns to each MPI rank the cell ids of the locally available partition-level cells for which the current process needs to send data to the corresponding other rank.

◆ triangulation

template<int dim>
const dealii::Triangulation<dim>& MeltPoolDG::LevelCommunicationPattern< dim >::triangulation
private

Reference to the triangulation for which the communication pattern is built.


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