27 #ifndef __LOCAL_MESH_VALUE_COLLECTION_H 28 #define __LOCAL_MESH_VALUE_COLLECTION_H 33 #include <dolfin/common/MPI.h> 34 #include <dolfin/log/log.h> 39 template <
typename T>
class MeshValueCollection;
57 std::size_t
dim ()
const 61 const std::vector<std::pair<std::pair<std::size_t,
68 const std::size_t _dim;
71 std::vector<std::pair<std::pair<std::size_t, std::size_t>, T> > _values;
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
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
std::map< std::pair< std::size_t, std::size_t >, T > & values()
Definition: MeshValueCollection.h:521
static unsigned int size(MPI_Comm comm)
Definition: MPI.cpp:154
std::size_t dim() const
Return dimension of cell entity.
Definition: LocalMeshValueCollection.h:57
MPI_Comm comm() const
Return the underlying MPI_Comm object.
Definition: MPI.cpp:117
const std::vector< std::pair< std::pair< std::size_t, std::size_t >, T > > & values() const
Return data.
Definition: LocalMeshValueCollection.h:62
static bool is_broadcaster(MPI_Comm comm)
Definition: MPI.cpp:166
~LocalMeshValueCollection()
Destructor.
Definition: LocalMeshValueCollection.h:54
Definition: GenericFile.h:38
static std::pair< std::int64_t, std::int64_t > local_range(MPI_Comm comm, std::int64_t N)
Definition: MPI.cpp:201
Definition: LocalMeshValueCollection.h:45