|
DOLFINx 0.12.0.0
DOLFINx C++
|
Miscellaneous classes, functions and types. More...
Namespaces | |
| namespace | petsc |
| PETSc error handling helpers shared across DOLFINx's PETSc wrappers. | |
Classes | |
| class | IndexMap |
| Distribution of a global index range [0, N) across MPI ranks. More... | |
| class | Scatterer |
| A Scatterer supports the scattering and gathering of distributed data that is associated with a common::IndexMap, using MPI. More... | |
| class | TimeLogger |
| Time logger maintaining data collected by Timer, if registered. More... | |
| class | Timer |
| Timer for measuring and logging elapsed time durations. More... | |
Concepts | |
| concept | LocalIndexRange |
| Concept for a contiguous list of process-local indices, e.g. the row or column indices passed to a matrix set function. | |
Enumerations | |
| enum class | IndexMapOrder : bool { preserve = true , any = false } |
| Control ghost-index ordering in sub-index maps. More... | |
Functions | |
| std::vector< std::int32_t > | compute_owned_indices (std::span< const std::int32_t > indices, const IndexMap &map) |
| Return selected indices owned by the calling rank. | |
| std::tuple< std::int64_t, std::vector< std::int32_t >, std::vector< std::vector< std::int64_t > >, std::vector< std::vector< int > > > | stack_index_maps (const std::vector< std::pair< std::reference_wrapper< const IndexMap >, int > > &maps) |
| Compute layout data for a concatenated index map. | |
| std::vector< std::int32_t > | num_sharing_ranks (const IndexMap &map, std::span< const std::int32_t > indices, int bs) |
| Number of ranks that share each of the given local indices. | |
| std::tuple< IndexMap, std::vector< std::int32_t >, bool > | create_sub_index_map (const IndexMap &imap, std::span< const std::int32_t > indices, IndexMapOrder order=IndexMapOrder::any) |
| Create an index map from a subset of an existing map. | |
| std::tuple< std::vector< int >, std::vector< int >, std::vector< std::int32_t > > | compute_sharing_neighbourhood (const IndexMap &imap) |
| Compute the symmetric neighbourhood of ranks that share an owned or ghost index with the caller. | |
| constexpr std::array< std::int64_t, 2 > | local_range (int index, std::int64_t N, int size) |
| Partition a global range [0, N - 1] across callers into non-overlapping sub-partitions of almost equal size. Returns the local partition for the caller. The local partition range. | |
| template<class Container> | |
| std::vector< std::int32_t > | num_sharing_ranks (const IndexMap &map, const Scatterer< Container > &sc, std::span< const std::int32_t > indices, int bs) |
| Number of ranks that share each of the given local indices, reusing an existing Scatterer. | |
| template<std::ranges::input_range U, std::ranges::input_range V> | |
| std::pair< std::vector< typename U::value_type >, std::vector< typename V::value_type > > | sort_unique (const U &indices, const V &values) |
| Sort two arrays based on the values in array indices. | |
| template<class T> | |
| std::size_t | hash_local (const T &x) |
| Compute a hash of a given object. | |
| template<class T> | |
| std::size_t | hash_global (MPI_Comm comm, const T &x) |
| Compute a hash for a distributed (MPI) object. | |
Miscellaneous classes, functions and types.
Generic tools.
This namespace provides utility type functions for managing subsystems, convenience classes and library-wide typedefs.
|
strong |
| std::vector< int32_t > compute_owned_indices | ( | std::span< const std::int32_t > | indices, |
| const IndexMap & | map ) |
Return selected indices owned by the calling rank.
Includes locally owned entries in indices and entries selected as ghosts on other ranks.
For example, on two ranks, suppose rank 0 owns global indices [0, 1] and has global index 2 as local ghost index 2, while rank 1 owns global indices [2, 3] and has global index 1 as local ghost index 2. If both ranks pass local index [2], the results are [1] on rank 0 and [0] on rank 1: each owns the global index selected as a ghost by the other rank.
| [in] | indices | Sorted unique local indices (owned or ghost) in [0, map.size_local() + map.num_ghosts()). |
| [in] | map | The index map. |
| std::invalid_argument | If the indices precondition is violated in a Developer build. |
| std::tuple< std::vector< int >, std::vector< int >, std::vector< std::int32_t > > compute_sharing_neighbourhood | ( | const IndexMap & | imap | ) |
Compute the symmetric neighbourhood of ranks that share an owned or ghost index with the caller.
A rank shares a local index with the caller if it also holds the index, as owner or ghost. For an owned index, the sharing ranks are the ranks that ghost it. For a ghost index, they are its owner and the other ranks that ghost it; the latter need not be in IndexMap::src or IndexMap::dest.
The in-neighbourhood IndexMap::src (owners of the caller's ghosts) and the out-neighbourhood IndexMap::dest (ranks ghosting the caller's owned indices) differ in general. Sharing is symmetric: rank a shares an index with rank b if and only if b shares it with a. The returned ranks can therefore be both the sources and the destinations of a neighbourhood communicator.
Example on four ranks, where | separates owned and ghost entries:
The return values are:
Ranks 0 and 2 share global index 2, which both ghost, although neither is in the other's IndexMap::src or IndexMap::dest. Rank 3 is in IndexMap::dest of ranks 0 and 2, but its own IndexMap::dest is empty. On rank 0, local index 1 occupies entry [offsets[1], offsets[2]) = [0, 1) of data, whose value 2 is the position of rank 3 in unique_ranks.
| [in] | imap | Index map. |
| std::tuple< IndexMap, std::vector< std::int32_t >, bool > create_sub_index_map | ( | const IndexMap & | imap, |
| std::span< const std::int32_t > | indices, | ||
| IndexMapOrder | order = IndexMapOrder::any ) |
Create an index map from a subset of an existing map.
| [in] | imap | Parent map to create a new sub-map from. |
| [in] | indices | Local indices in imap (owned and ghost) to include in the new index map. |
| [in] | order | Control the order in which ghost indices appear in the new map. |
| std::invalid_argument | If the indices precondition is violated in a Developer build. |
| std::size_t hash_global | ( | MPI_Comm | comm, |
| const T & | x ) |
Compute a hash for a distributed (MPI) object.
A hash is computed on each process for the local part of the object. Then, a hash of the std::vector containing each local hash key in rank order is returned.
| [in] | comm | The communicator on which to compute the hash. |
| [in] | x | The object to compute a hash of. |
| std::size_t hash_local | ( | const T & | x | ) |
Compute a hash of a given object.
The hash is computed using Boost container hash (https://www.boost.org/doc/libs/release/libs/container_hash/).
| [in] | x | The object to compute a hash of. |
|
constexpr |
Partition a global range [0, N - 1] across callers into non-overlapping sub-partitions of almost equal size. Returns the local partition for the caller. The local partition range.
Partitions [0, N) into size non-overlapping partitions [n_(i0}, n_(i1)), where i is index and n_(i1) == n_((i+1)0).
| [in] | index | Index of the partition to compute. |
| [in] | N | Global range to partition. |
| [in] | size | Number of partitions into which to partition N. |
| std::vector< std::int32_t > num_sharing_ranks | ( | const IndexMap & | map, |
| const Scatterer< Container > & | sc, | ||
| std::span< const std::int32_t > | indices, | ||
| int | bs ) |
Number of ranks that share each of the given local indices, reusing an existing Scatterer.
Equivalent to the IndexMap overload, but avoids building a Scatterer, which duplicates MPI communicators.
| [in] | map | Index map describing the parallel layout. |
| [in] | sc | Scatterer for map. |
| [in] | indices | Local indices, which may include ghosts. An index refers to block i / bs of map. |
| [in] | bs | Block size relating indices to the blocks of map. |
| std::invalid_argument | If bs is less than one. |
| std::out_of_range | If an entry of indices is not a local index of map. |
| std::vector< std::int32_t > num_sharing_ranks | ( | const IndexMap & | map, |
| std::span< const std::int32_t > | indices, | ||
| int | bs ) |
Number of ranks that share each of the given local indices.
A rank shares an index if it owns it or ghosts it, so the count is one for an index that is not on a subdomain boundary, and the sum of the counts over all ranks that hold an index is the same on each of them.
| [in] | map | Index map describing the parallel layout. |
| [in] | indices | Local indices, which may include ghosts. An index refers to block i / bs of map. |
| [in] | bs | Block size relating indices to the blocks of map. |
| std::invalid_argument | If bs is less than one. |
| std::out_of_range | If an entry of indices is not a local index of map. |
| std::pair< std::vector< typename U::value_type >, std::vector< typename V::value_type > > sort_unique | ( | const U & | indices, |
| const V & | values ) |
Sort two arrays based on the values in array indices.
Any duplicate indices and the corresponding value are removed. In the case of duplicates, the entry with the smallest value is retained.
| [in] | indices | Array of indices. |
| [in] | values | Array of values. |
| std::tuple< std::int64_t, std::vector< std::int32_t >, std::vector< std::vector< std::int64_t > >, std::vector< std::vector< int > > > stack_index_maps | ( | const std::vector< std::pair< std::reference_wrapper< const IndexMap >, int > > & | maps | ) |
Compute layout data for a concatenated index map.
Locally owned entries remain owned by the caller. Ghost entries are grouped by input map in maps.
| [in] | maps | Non-empty pairs of index maps and positive block sizes. All maps must use the same communicator. |