9 #include <boost/functional/hash.hpp>
11 #include <dolfinx/common/MPI.h>
28 template <
typename U,
typename V>
29 std::pair<U, V>
sort_unique(
const U& indices,
const V& values)
31 if (indices.size() != values.size())
32 throw std::runtime_error(
"Cannot sort two arrays of different lengths");
34 std::vector<std::pair<typename U::value_type, typename V::value_type>> data(
36 for (std::size_t i = 0; i < indices.size(); ++i)
37 data[i] = {indices[i], values[i]};
40 std::sort(data.begin(), data.end());
41 auto it = std::unique(data.begin(), data.end(),
42 [](
auto& a,
auto& b) { return a.first == b.first; });
46 indices_new.reserve(data.size());
47 values_new.reserve(data.size());
48 for (
auto d = data.begin(); d != it; ++d)
50 indices_new.push_back(d->first);
51 values_new.push_back(d->second);
54 return {std::move(indices_new), std::move(values_new)};
58 std::string
indent(std::string block);
66 s.precision(precision);
68 for (std::size_t i = 0; i < (std::size_t)x.size(); ++i)
70 if ((i + 1) % linebreak == 0 && linebreak != 0)
71 s << x.data()[i] << std::endl;
73 s << x.data()[i] <<
" ";
97 MPI_Gather(&local_hash, 1, MPI_INT64_T, all_hashes.data(), 1, MPI_INT64_T, 0,
101 boost::hash<std::vector<int64_t>> hash;
102 int64_t global_hash = hash(all_hashes);
105 MPI_Bcast(&global_hash, 1, MPI_INT64_T, 0, comm);