rheolef  6.5
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
3 #include "rheolef/mpi_scatter_init.h"
4 #include "rheolef/mpi_scatter_begin.h"
5 #include "rheolef/mpi_scatter_end.h"
6 
7 namespace rheolef {
8 
34 template <class InputIterator, class InputSet, class OutputMap>
35 void
37  const distributor& ownership,
38  InputIterator local_data,
39  const InputSet& ext_idx_set,
40  OutputMap& ext_idx_map)
41 @endcode
42 {
43  typedef typename std::iterator_traits<InputIterator>::value_type data_type;
44  typedef typename distributor::size_type size_type;
45 
47  scatter_message<std::vector<data_type> > from;
48  scatter_message<std::vector<data_type> > to;
49 
50  std::vector<size_type> ext_idx (ext_idx_set.size());
51  std::copy (ext_idx_set.begin(), ext_idx_set.end(), ext_idx.begin());
52 
53  std::vector<size_type> id (ext_idx.size());
54  for (size_type i = 0; i < id.size(); i++) id[i] = i;
55 
57  ext_idx.size(),
58  ext_idx.begin().operator->(),
59  id.size(),
60  id.begin().operator->(),
61  ownership.dis_size(),
62  ownership.begin().operator->(),
63  tag,
64  ownership.comm(),
65  from,
66  to);
67 
68  std::vector<data_type> buffer (ext_idx.size());
70  get_pointer_from_iterator(local_data),
71  buffer.begin().operator->(),
72  from,
73  to,
74  set_op<data_type,data_type>(),
75  tag,
76  ownership.comm());
77 
79  get_pointer_from_iterator(local_data),
80  buffer.begin(),
81  from,
82  to,
83  set_op<data_type,data_type>(),
84  tag,
85  ownership.comm());
86 
87  ext_idx_map.clear();
88  for (size_type i = 0; i < buffer.size(); i++) {
89  ext_idx_map.insert (std::make_pair (ext_idx[i], buffer[i]));
90  }
91 }
92 
93 } // namespace rheolef
94 #endif // _RHEOLEF_MPI_SCATTER_MAP_H
95