Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
mpi_scatter_map.h
Go to the documentation of this file.
1#ifndef _RHEOLEF_MPI_SCATTER_MAP_H
2#define _RHEOLEF_MPI_SCATTER_MAP_H
23#include "rheolef/mpi_scatter_init.h"
24#include "rheolef/mpi_scatter_begin.h"
25#include "rheolef/mpi_scatter_end.h"
26
27namespace rheolef {
28
29/*F:
30NAME: mpi_scatter_map -- gather/scatter and build map (@PACKAGE@ @VERSION@)
31DESCRIPTION:
32 This is a high-level communication function for application
33 to finite-element problems.
34 The input is a stl::set of external degrees of freedom (e.g. vertices, edges, faces)
35 referenced by localy managed elements and required by the local processor.
36 These degrees of freedom are on the boundary of the mesh partition
37 and are managed by a neighbour processor.
38 The ouput is the same index set, but associated with the required values, in
39 a stl::map associative container.
40 The input also furnish an iterator to the locally managed data and
41 the distributor associated to these data.
42COMPLEXITY:
43 Time, communication and memory complexity is O(nidx+nproc).
44 For finite-element problems in d dimenion
45 @example
46 nidx ~ N^((d-1)/d)
47 @end example
48 where N is the number of degrees of freedom (vertices or elements).
49
50AUTHORS: Pierre.Saramito@imag.fr
51DATE: 23 march 1999
52END:
53*/
54//<verbatim:
55template <class InputIterator, class InputSet, class OutputMap>
56void
58// input:
59 const distributor& ownership,
60 InputIterator local_data,
61 const InputSet& ext_idx_set,
62// output:
63 OutputMap& ext_idx_map)
64//>verbatim:
65{
66 typedef typename std::iterator_traits<InputIterator>::value_type data_type;
67 typedef typename distributor::size_type size_type;
68
69 // 0) declare the local context
73
74 // 1) convert set to vector, for direct acess:
75 std::vector<size_type> ext_idx (ext_idx_set.size());
76 std::copy (ext_idx_set.begin(), ext_idx_set.end(), ext_idx.begin());
77
78 // 2) declare id[i]=i for scatter
79 std::vector<size_type> id (ext_idx.size());
80 for (size_type i = 0; i < id.size(); i++) id[i] = i;
81
82 // 3) init scatter
84 ext_idx.size(),
85 ext_idx.begin().operator->(),
86 id.size(),
87 id.begin().operator->(),
88 ownership.dis_size(),
89 ownership.begin().operator->(),
90 tag,
91 ownership.comm(),
92 from,
93 to);
94
95 // 4) begin scatter: send local data to others and get ask for missing data
96 std::vector<data_type> buffer (ext_idx.size());
98 get_pointer_from_iterator(local_data),
99 buffer.begin().operator->(),
100 from,
101 to,
102 details::generic_set_op(),
103 tag,
104 ownership.comm());
105
106 // 5) end scatter: receive missing data
108 get_pointer_from_iterator(local_data),
109 buffer.begin(),
110 from,
111 to,
112 details::generic_set_op(),
113 tag,
114 ownership.comm());
115
116 // 6) build the associative container: pair (ext_idx ; data)
117 ext_idx_map.clear();
118 for (size_type i = 0; i < buffer.size(); i++) {
119 ext_idx_map.insert (std::make_pair (ext_idx[i], buffer[i]));
120 }
121}
122
123} // namespace rheolef
124#endif // _RHEOLEF_MPI_SCATTER_MAP_H
field::size_type size_type
Definition branch.cc:430
see the distributor page for the full documentation
Definition distributor.h:69
size_type dis_size() const
global and local sizes
static tag_type get_new_tag()
returns a new tag
std::allocator< int >::size_type size_type
Definition distributor.h:74
const communicator_type & comm() const
This file is part of Rheolef.
void mpi_scatter_map(const distributor &ownership, InputIterator local_data, const InputSet &ext_idx_set, OutputMap &ext_idx_map)
void mpi_scatter_end(InputIterator x, OutputIterator y, Message &from, Message &to, SetOp op, Tag tag, Comm comm)
void mpi_scatter_begin(InputIterator x, OutputIterator y, Message &from, Message &to, SetOp op, Tag tag, Comm comm)
std::iterator_traits< Iterator >::pointer get_pointer_from_iterator(Iterator iter)
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)
iterator begin()
Definition Vector.h:217