mpi_scatter_map.h
Go to the documentation of this file.
#ifndef _RHEOLEF_MPI_SCATTER_MAP_H
#define _RHEOLEF_MPI_SCATTER_MAP_H
#include "rheolef/mpi_scatter_init.h"
#include "rheolef/mpi_scatter_begin.h"
#include "rheolef/mpi_scatter_end.h"
namespace rheolef {
/*F:
NAME: mpi_scatter_map -- gather/scatter and build map (@PACKAGE@ @VERSION@)
DESCRIPTION:
This is a high-level communication function for application
to finite-element problems.
The input is a stl::set of external degrees of freedom (e.g. vertices, edges, faces)
referenced by localy managed elements and required by the local processor.
These degrees of freedom are on the boundary of the mesh partition
and are managed by a neighbour processor.
The ouput is the same index set, but associated with the required values, in
a stl::map associative container.
The input also furnish an iterator to the locally managed data and
the distributor associated to these data.
COMPLEXITY:
Time, communication and memory complexity is O(nidx+nproc).
For finite-element problems in d dimenion
@example
nidx ~ N^((d-1)/d)
@end example
where N is the number of degrees of freedom (vertices or elements).
AUTHORS: Pierre.Saramito@imag.fr
DATE: 23 march 1999
END:
*/
//<verbatim:
template <class InputIterator, class InputSet, class OutputMap>
void
mpi_scatter_map (
// input:
const distributor& ownership,
InputIterator local_data,
const InputSet& ext_idx_set,
// output:
OutputMap& ext_idx_map)
//>verbatim:
{
typedef typename std::iterator_traits<InputIterator>::value_type data_type;
typedef typename distributor::size_type size_type;
// 0) declare the local context
distributor::tag_type tag = distributor::get_new_tag();
scatter_message<std::vector<data_type> > from;
scatter_message<std::vector<data_type> > to;
// 1) convert set to vector, for direct acess:
std::vector<size_type> ext_idx (ext_idx_set.size());
std::copy (ext_idx_set.begin(), ext_idx_set.end(), ext_idx.begin());
// 2) declare id[i]=i for scatter
std::vector<size_type> id (ext_idx.size());
for (size_type i = 0; i < id.size(); i++) id[i] = i;
// 3) init scatter
mpi_scatter_init(
ext_idx.size(),
ext_idx.begin().operator->(),
id.size(),
id.begin().operator->(),
ownership.dis_size(),
ownership.begin().operator->(),
tag,
ownership.comm(),
from,
to);
// 4) begin scatter: send local data to others and get ask for missing data
std::vector<data_type> buffer (ext_idx.size());
mpi_scatter_begin (
get_pointer_from_iterator(local_data),
buffer.begin().operator->(),
from,
to,
set_op<data_type,data_type>(),
tag,
ownership.comm());
// 5) end scatter: receive missing data
mpi_scatter_end (
get_pointer_from_iterator(local_data),
buffer.begin(),
from,
to,
set_op<data_type,data_type>(),
tag,
ownership.comm());
// 6) build the associative container: pair (ext_idx ; data)
ext_idx_map.clear();
for (size_type i = 0; i < buffer.size(); i++) {
ext_idx_map.insert (std::make_pair (ext_idx[i], buffer[i]));
}
}
} // namespace rheolef
#endif // _RHEOLEF_MPI_SCATTER_MAP_H
rheolef::distributor::get_new_tag
static tag_type get_new_tag()
returns a new tag
Definition: distributor.cc:133
rheolef::distributor::comm
const communicator_type & comm() const
Definition: distributor.h:145
rheolef::distributor
see the distributor page for the full documentation
Definition: distributor.h:62
rheolef::scatter_message
Definition: scatter_message.h:33
rheolef::mpi_scatter_begin
void mpi_scatter_begin(InputIterator x, OutputIterator y, Message &from, Message &to, SetOp op, Tag tag, Comm comm)
Definition: mpi_scatter_begin.h:196
rheolef::size_type
size_t size_type
Definition: basis_get.cc:76
rheolef::mpi_scatter_init
void mpi_scatter_init(Size nidx, SizeRandomIterator1 idx, Size nidy, SizeRandomIterator2 idy, Size idy_maxval, SizeRandomIterator3 ownership, Tag tag, const distributor::communicator_type &comm, Message &from, Message &to)
Definition: mpi_scatter_init.h:67
rheolef::get_pointer_from_iterator
std::iterator_traits< Iterator >::pointer get_pointer_from_iterator(Iterator iter)
Definition: get_pointer_from_iterator.h:26
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::distributor::dis_size
size_type dis_size() const
global and local sizes
Definition: distributor.h:207
rheolef::Vector::begin
iterator begin()
Definition: Vector.h:217
size_type
field::size_type size_type
Definition: branch.cc:425
rheolef::mpi_scatter_map
void mpi_scatter_map(const distributor &ownership, InputIterator local_data, const InputSet &ext_idx_set, OutputMap &ext_idx_map)
Definition: mpi_scatter_map.h:57
rheolef::set_op
Definition: msg_util.h:56
rheolef::mpi_scatter_end
void mpi_scatter_end(InputIterator x, OutputIterator y, Message &from, Message &to, SetOp op, Tag tag, Comm comm)
Definition: mpi_scatter_end.h:54
rheolef::distributor::tag_type
int tag_type
Definition: distributor.h:71
rheolef::distributor::size_type
std::allocator< int >::size_type size_type
Definition: distributor.h:67