|
DOLFINx 0.12.0.0
DOLFINx C++
|
Distribution of a global index range [0, N) across MPI ranks. More...
#include <IndexMap.h>
Public Member Functions | |
| IndexMap (MPI_Comm comm, std::int32_t local_size) | |
| Create a non-overlapping index map. | |
| IndexMap (MPI_Comm comm, std::int32_t local_size, std::span< const std::int64_t > ghosts, std::span< const int > owners, int tag=static_cast< int >(dolfinx::MPI::tag::consensus_nbx)) | |
| Create an overlapping (ghosted) index map. | |
| IndexMap (MPI_Comm comm, std::int32_t local_size, const std::array< std::vector< int >, 2 > &src_dest, std::span< const std::int64_t > ghosts, std::span< const int > owners) | |
| Create an overlapping (ghosted) index map. | |
| IndexMap (const IndexMap &map)=delete | |
| IndexMap (IndexMap &&map)=default | |
| Move constructor. | |
| ~IndexMap ()=default | |
| Destructor. | |
| IndexMap & | operator= (const IndexMap &map)=delete |
| IndexMap & | operator= (IndexMap &&map)=default |
| Move assignment. | |
| std::array< std::int64_t, 2 > | local_range () const noexcept |
| Return the global range of owned indices. | |
| std::int32_t | num_ghosts () const noexcept |
| Return the number of ghost indices. | |
| std::int32_t | size_local () const noexcept |
| Return the number of owned indices. | |
| std::int64_t | size_global () const noexcept |
| Return the total number of indices across the communicator. | |
| std::span< const std::int64_t > | ghosts () const noexcept |
| Return global indices of ghosts in local ghost-index order. | |
| MPI_Comm | comm () const |
| Return the communicator that the map is defined on. | |
| void | local_to_global (std::span< const std::int32_t > local, std::span< std::int64_t > global) const |
| Compute global indices for local indices. | |
| void | global_to_local (std::span< const std::int64_t > global, std::span< std::int32_t > local) const |
| Compute local indices for global indices. | |
| std::vector< std::int64_t > | global_indices () const |
| Return global indices for all local entries, including ghosts. | |
| std::span< const int > | owners () const noexcept |
| Return ranks that own ghost entries. | |
| std::pair< std::vector< int >, std::vector< std::int32_t > > | index_to_dest_ranks (int tag=static_cast< int >(dolfinx::MPI::tag::consensus_nbx)) const |
| Compute sharing ranks for each local index. | |
| std::vector< std::int32_t > | shared_indices () const |
| Return owned indices ghosted by another rank. | |
| std::span< const int > | src () const noexcept |
| Return sorted unique ranks that own the caller's ghosts. | |
| std::span< const int > | dest () const noexcept |
| Return sorted unique ranks that ghost entries owned by the caller. | |
| std::vector< std::int32_t > | weights_src () const |
| Count the caller's ghosts owned by each source rank. | |
| std::vector< std::int32_t > | weights_dest () const |
| Count the caller's owned entries ghosted by each destination rank. | |
| std::array< std::vector< int >, 2 > | rank_type (int split_type) const |
| Return neighbours in the caller's MPI split-type group. | |
Distribution of a global index range [0, N) across MPI ranks.
Each rank owns a contiguous global range. Local indices in [0, size_local()) address owned entries; remaining local indices address ghost entries.
| IndexMap | ( | MPI_Comm | comm, |
| std::int32_t | local_size ) |
Create a non-overlapping index map.
For example, if rank 0 has local_size = 2 and rank 1 has local_size = 3, the layout is:
| [in] | comm | Communicator that the index map is distributed across. |
| [in] | local_size | Number of owned entries. Must be non-negative. |
| std::invalid_argument | If local_size is negative. |
| IndexMap | ( | MPI_Comm | comm, |
| std::int32_t | local_size, | ||
| std::span< const std::int64_t > | ghosts, | ||
| std::span< const int > | owners, | ||
| int | tag = static_cast<int>(dolfinx::MPI::tag::consensus_nbx) ) |
Create an overlapping (ghosted) index map.
Uses a consensus algorithm to determine ranks that ghost entries owned by the caller. Use the explicit source/destination constructor when these ranks are known.
For example, a two-rank map with one ghost on each rank has layout: Here, | separates owned and ghost entries.
| [in] | comm | Communicator that the index map is distributed across. |
| [in] | local_size | Number of owned entries. Must be non-negative. |
| [in] | ghosts | Unique global indices of ghost entries. |
| [in] | owners | Non-self rank (on comm) that owns each entry in ghosts. |
| [in] | tag | Tag used in non-blocking MPI calls in the consensus algorithm. |
| IndexMap | ( | MPI_Comm | comm, |
| std::int32_t | local_size, | ||
| const std::array< std::vector< int >, 2 > & | src_dest, | ||
| std::span< const std::int64_t > | ghosts, | ||
| std::span< const int > | owners ) |
Create an overlapping (ghosted) index map.
Use this constructor when source ranks (owners of the caller's ghosts) and destination ranks (ranks ghosting the caller's entries) are known.
For example, a two-rank map with one ghost on each rank has layout: Here, | separates owned and ghost entries.
Rank 0 has source rank 1 and destination rank 1, and conversely for rank 1.
| [in] | comm | Communicator that the index map is distributed across. |
| [in] | local_size | Number of owned entries. Must be non-negative. |
| [in] | src_dest | Lists of (0) source and (1) destination ranks. Both lists must be sorted, unique and contain valid ranks. Source ranks must be exactly the unique owners of ghosts; destination ranks must be the ranks that ghost entries owned by the caller. |
| [in] | ghosts | Unique global indices of ghost entries. |
| [in] | owners | Non-self rank (on comm) that owns each entry in ghosts. |
| MPI_Comm comm | ( | ) | const |
Return the communicator that the map is defined on.
| void global_to_local | ( | std::span< const std::int64_t > | global, |
| std::span< std::int32_t > | local ) const |
Compute local indices for global indices.
| [in] | global | Global indices. |
| [out] | local | Local indices. Must have the same size as global. Entries without a local index are set to -1. |
| std::invalid_argument | If global and local differ in size. |
| std::pair< std::vector< int >, std::vector< std::int32_t > > index_to_dest_ranks | ( | int | tag = static_cast<int>(dolfinx::MPI::tag::consensus_nbx) | ) | const |
Compute sharing ranks for each local index.
| [in] | tag | Tag to pass to MPI calls. |
| void local_to_global | ( | std::span< const std::int32_t > | local, |
| std::span< std::int64_t > | global ) const |
Compute global indices for local indices.
| [in] | local | Local indices in [0, size_local() + num_ghosts()). |
| [out] | global | Global indices. Must have at least the size of local. |
| std::invalid_argument | If global is smaller than local. |
| std::out_of_range | If the local precondition is violated in a Developer build. |
|
inlinenoexcept |
Return ranks that own ghost entries.
| std::array< std::vector< int >, 2 > rank_type | ( | int | split_type | ) | const |
Return neighbours in the caller's MPI split-type group.
Forms a communicator with MPI_Comm_split_type and restricts the caller's destination and source ranks to the resulting group. The destination ranks ghost entries owned by the caller; the source ranks own ghosts held by the caller. For example, with MPI_COMM_TYPE_SHARED, this identifies neighbouring ranks on the same shared-memory domain.
| [in] | split_type | MPI split type passed to MPI_Comm_split_type, e.g. MPI_COMM_TYPE_SHARED. |
| std::vector< std::int32_t > shared_indices | ( | ) | const |
Return owned indices ghosted by another rank.
| std::vector< std::int32_t > weights_dest | ( | ) | const |
Count the caller's owned entries ghosted by each destination rank.
The returned vector is aligned with dest(). Each value is the number of local owned entries ghosted by the corresponding destination rank.
| std::vector< std::int32_t > weights_src | ( | ) | const |
Count the caller's ghosts owned by each source rank.
The returned vector is aligned with src(). Each value is the number of local ghost entries whose owner is the corresponding source rank.