11#include <boost/functional/hash.hpp>
12#include <dolfinx/graph/AdjacencyList.h>
31template <
typename U,
typename V>
32std::pair<std::vector<typename U::value_type>,
33 std::vector<typename V::value_type>>
36 if (indices.size() != values.size())
37 throw std::runtime_error(
"Cannot sort two arrays of different lengths");
39 using T =
typename std::pair<typename U::value_type, typename V::value_type>;
40 std::vector<T> data(indices.size());
41 std::ranges::transform(indices, values, data.begin(),
42 [](
auto& idx,
auto& v) -> T { return {idx, v}; });
45 std::ranges::sort(data);
46 auto it = std::ranges::unique(data, [](
auto& a,
auto& b)
47 {
return a.first == b.first; })
50 std::vector<typename U::value_type> indices_new;
51 std::vector<typename V::value_type> values_new;
52 indices_new.reserve(data.size());
53 values_new.reserve(data.size());
54 std::transform(data.begin(), it, std::back_inserter(indices_new),
55 [](
auto& d) { return d.first; });
56 std::transform(data.begin(), it, std::back_inserter(values_new),
57 [](
auto& d) { return d.second; });
59 return {std::move(indices_new), std::move(values_new)};
101 boost::hash<std::vector<std::size_t>> hash;
102 std::size_t global_hash = hash(all_hashes);
126 std::pair<std::int32_t, std::int32_t>>& g);
This class provides a static adjacency list data structure.
Definition AdjacencyList.h:38
MPI_Datatype mpi_t
Retrieves the MPI data type associated to the provided type.
Definition MPI.h:280
void check_error(MPI_Comm comm, int code)
Check MPI error code. If the error code is not equal to MPI_SUCCESS, then std::abort is called.
Definition MPI.cpp:80
int size(MPI_Comm comm)
Definition MPI.cpp:72
Miscellaneous classes, functions and types.
Definition dolfinx_common.h:8
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.
Definition utils.h:34
std::size_t hash_global(MPI_Comm comm, const T &x)
Compute a hash for a distributed (MPI) object.
Definition utils.h:88
std::size_t hash_local(const T &x)
Compute a hash of a given object.
Definition utils.h:70
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.