31  if (indices.size() != values.size())
 
   32    throw std::runtime_error(
"Cannot sort two arrays of different lengths");
 
   34  using T = 
typename std::pair<typename U::value_type, typename V::value_type>;
 
   35  std::vector<T> data(indices.size());
 
   36  std::transform(indices.begin(), indices.end(), values.begin(), data.begin(),
 
   37                 [](
auto& idx, 
auto& v) -> T {
 
   42  std::sort(data.begin(), data.end());
 
   43  auto it = std::unique(data.begin(), data.end(),
 
   44                        [](
auto& a, 
auto& b) { return a.first == b.first; });
 
   46  std::vector<typename U::value_type> indices_new;
 
   47  std::vector<typename V::value_type> values_new;
 
   48  indices_new.reserve(data.size());
 
   49  values_new.reserve(data.size());
 
   50  std::transform(data.begin(), it, std::back_inserter(indices_new),
 
   51                 [](
auto& d) { return d.first; });
 
   52  std::transform(data.begin(), it, std::back_inserter(values_new),
 
   53                 [](
auto& d) { return d.second; });
 
   55  return {std::move(indices_new), std::move(values_new)};
 
 
   91  int err = MPI_Gather(&local_hash, 1, dolfinx::MPI::mpi_type<std::size_t>(),
 
   93                       dolfinx::MPI::mpi_type<std::size_t>(), 0, comm);
 
   97  boost::hash<std::vector<std::size_t>> hash;
 
   98  std::size_t global_hash = hash(all_hashes);
 
  101  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
 
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 val...
Definition utils.h:29