85 : _dim(dim), _mpi_comm(comm)
88 std::vector<std::vector<std::size_t> > send_indices;
89 std::vector<std::vector<T> > send_v;
95 const std::size_t num_processes = MPI::size(_mpi_comm.comm());
96 send_indices.resize(num_processes);
97 send_v.resize(num_processes);
99 const std::map<std::pair<std::size_t, std::size_t>, T>& vals
101 for (std::size_t p = 0; p < num_processes; p++)
103 const std::pair<std::size_t, std::size_t> local_range
104 = MPI::local_range(_mpi_comm.comm(), p, vals.size());
105 typename std::map<std::pair<std::size_t,
106 std::size_t>, T>::const_iterator it = vals.begin();
107 std::advance(it, local_range.first);
108 for (std::size_t i = local_range.first; i < local_range.second; ++i)
110 send_indices[p].push_back(it->first.first);
111 send_indices[p].push_back(it->first.second);
112 send_v[p].push_back(it->second);
119 std::vector<std::size_t> indices;
123 dolfin_assert(2*v.size() == indices.size());
126 for (std::size_t i = 0; i < v.size(); ++i)
128 const std::size_t cell_index = indices[2*i];
129 const std::size_t local_entity_index = indices[2*i + 1];
130 const T value = v[i];
131 _values.push_back({{cell_index, local_entity_index}, value});
LocalMeshValueCollection(MPI_Comm comm, const MeshValueCollection< T > &values, std::size_t dim)
Create local mesh data for given LocalMeshValueCollection.
Definition LocalMeshValueCollection.h:82
static void scatter(MPI_Comm comm, const std::vector< std::vector< T > > &in_values, std::vector< T > &out_value, unsigned int sending_process=0)
Scatter vector in_values[i] to process i.
Definition MPI.h:499