Loading...
Searching...
No Matches
dolfinx::common Namespace Reference

Miscellaneous classes, functions and types. More...

## Classes

class | IndexMap
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...

## Enumerations

enum class | IndexMapOrder : bool { preserve = true , any = false }

## Functions

std::vector< int32_t > | compute_owned_indices (std::span< const std::int32_t > indices, const IndexMap &map)
| Given a sorted list of indices (local indexing, owned or ghost) and an index map, this function returns the indices owned by this process, including indices that might have been in the list of indices on another processes.
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 and ghost indices for a stacked (concatenated) index map, i.e. 'splice' multiple maps into one.
std::pair< IndexMap, std::vector< std::int32_t > > | create_sub_index_map (const IndexMap &imap, std::span< const std::int32_t > indices, IndexMapOrder order=IndexMapOrder::any, bool allow_owner_change=false)
| Create a new index map from a subset of indices in an existing index map.
template<typename U, typename 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.
std::string | comm_to_json (const graph::AdjacencyList< std::tuple< int, std::size_t, std::int8_t >, std::pair< std::int32_t, std::int32_t > > &g)
| Build communication graph data as a JSON string.

## Detailed Description

Miscellaneous classes, functions and types.

Generic tools.

This namespace provides utility type functions for managing subsystems, convenience classes and library-wide typedefs.

## Enumeration Type Documentation

## IndexMapOrder

enum class IndexMapOrder : bool

strong

Enum to control preservation of ghost index ordering in sub-IndexMaps.

Enumerator
preserve | Preserve the ordering of ghost indices.
any | Allow arbitrary ordering of ghost indices in sub-maps.

## Function Documentation

## comm_to_json()

std::string comm_to_json | ( | const graph::AdjacencyList< std::tuple< int, std::size_t, std::int8_t >, std::pair< std::int32_t, std::int32_t > > & | g | ) |

Build communication graph data as a JSON string.

The data string can be decoded (loaded) to create a Python object from which a NetworkX graph can be constructed.

See ::comm_graph for a description of the data.

Parameters

  [in] | g | Communication graph.

Returns
  JSON string representing the communication graph. Edge data is data volume (weight) and local/remote memory indicator (local==1 is an edge to an shared memory process/rank, other wise the target node is a remote memory rank).

## compute_owned_indices()

std::vector< int32_t > compute_owned_indices | ( | std::span< const std::int32_t > | indices,
|  | const IndexMap & | map )

Given a sorted list of indices (local indexing, owned or ghost) and an index map, this function returns the indices owned by this process, including indices that might have been in the list of indices on another processes.

Parameters

  [in] | indices | List of indices.
  [in] | map | The index map.

Returns
  Indices owned by the calling process.

## create_sub_index_map()

std::pair< IndexMap, std::vector< std::int32_t > > create_sub_index_map | ( | const IndexMap & | imap,
|  | std::span< const std::int32_t > | indices,
|  | IndexMapOrder | order = IndexMapOrder::any,
|  | bool | allow_owner_change = false )

Create a new index map from a subset of indices in an existing index map.

Parameters

  [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.
  [in] | allow_owner_change | If true, indices that are not included in indices by their owning process can be included in indices by processes that ghost the indices to be included in the new submap. These indices will be owned by one of the sharing processes in the submap. If false, and exception is raised if an index is included by a sharing process and not by the owning process.

Returns
  The (i) new index map and (ii) a map from local indices in the submap to local indices in the original (this) map.

Precondition
  indices must be sorted and must not contain duplicates.

## hash_global()

template<class T>

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.

Note
  Collective

Parameters

  [in] | comm | The communicator on which to compute the hash.
  [in] | x | The object to compute a hash of.

Returns
  The hash values.

## hash_local()

template<class T>

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

Parameters

  [in] | x | The object to compute a hash of.

Returns
  The hash values.

## sort_unique()

template<typename U, typename 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.

Any duplicate indices and the corresponding value are removed. In the case of duplicates, the entry with the smallest value is retained.

Parameters

  [in] | indices | Array of indices.
  [in] | values | Array of values.

Returns
  Sorted (indices, values), with sorting based on indices.

## stack_index_maps()

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 and ghost indices for a stacked (concatenated) index map, i.e. 'splice' multiple maps into one.

The input maps are concatenated, with indices in maps and owned by the caller remaining owned by the caller. Ghost data is stored at the end of the local range as normal, with the ghosts in blocks in the order of the index maps in maps.

Note
  Index maps with a block size are unrolled in the data for the concatenated index map.
  Communication is required to compute the new ghost indices.

Parameters

  [in] | maps | List of (index map, block size) pairs

Returns
  The (0) global offset of a concatenated map for the calling rank, (1) local offset for the owned indices of each submap in the concatenated map, (2) new indices for the ghosts for each submap, and (3) owner rank of each ghost entry for each submap.