30 if (indices.size() != values.size())
31 throw std::runtime_error(
"Cannot sort two arrays of different lengths");
33 using T =
typename std::pair<typename U::value_type, typename V::value_type>;
34 std::vector<T> data(indices.size());
35 std::transform(indices.begin(), indices.end(), values.begin(), data.begin(),
36 [](
auto& idx,
auto& v) -> T { return {idx, v}; });
39 std::sort(data.begin(), data.end());
40 auto it = std::unique(data.begin(), data.end(),
41 [](
auto& a,
auto& b) { return a.first == b.first; });
43 std::vector<typename U::value_type> indices_new;
44 std::vector<typename V::value_type> values_new;
45 indices_new.reserve(data.size());
46 values_new.reserve(data.size());
47 std::transform(data.begin(), it, std::back_inserter(indices_new),
48 [](
auto& d) { return d.first; });
49 std::transform(data.begin(), it, std::back_inserter(values_new),
50 [](
auto& d) { return d.second; });
52 return {std::move(indices_new), std::move(values_new)};
88 int err = MPI_Gather(&local_hash, 1, dolfinx::MPI::mpi_type<std::size_t>(),
90 dolfinx::MPI::mpi_type<std::size_t>(), 0, comm);
94 boost::hash<std::vector<std::size_t>> hash;
95 std::size_t global_hash = hash(all_hashes);
98 err = MPI_Bcast(&global_hash, 1, dolfinx::MPI::mpi_type<std::size_t>(), 0,
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