rheolef  6.5
geo_mpi_put.cc
Go to the documentation of this file.
1 #include "rheolef/config.h"
2 #ifdef _RHEOLEF_HAVE_MPI
3 #include "rheolef/geo.h"
4 #include "rheolef/geo_domain.h"
5 #include "rheolef/dis_macros.h"
6 #include "rheolef/rheostream.h"
7 #include "rheolef/iorheo.h"
8 #include "rheolef/index_set.h"
9 
10 namespace rheolef {
11 
15  : _elts(elts), _first_dis_v(first_dis_v) {}
16  size_type size() const { return _elts.size(); }
18  const geo_element& K = _elts [ie];
19  return K.ios_dis_ie() - _first_dis_v;
20  }
21  const permutation_proxy& data() const { return *this; }
24 };
25 template <class T>
28 {
29  using namespace std;
31  check_macro (format[iorheo::rheo], "geo distributed: unsupported geo output file format=" << format);
32 
33  communicator comm = base::_geo_element[reference_element::p].ownership().comm();
35  size_type my_proc = comm.rank();
36  size_type nproc = comm.size();
37  size_type dis_nnod = base::_node.dis_size ();
38  size_type dis_nv = base::_geo_element[reference_element::p].dis_size ();
39  ops << setprecision(numeric_limits<Float>::digits10)
40  << "#!geo" << endl
41  << endl
42  << "mesh" << endl
43  << base::_version;
44 
45  geo_header h;
46  h.dimension = base::_dimension;
47  h.sys_coord = base::_sys_coord;
48  h.order = base::order();
49  h.dis_size_by_variant [0] = base::_node.dis_size();
50  for (size_type variant = 1; variant < reference_element::max_variant; variant++) {
51  h.dis_size_by_variant [variant] = base::_geo_element [variant].dis_size();
52  }
53  ops << endl << h << endl;
54  if (base::_dimension > 0) {
55  base::_node.permuted_put_values (ops, _inod2ios_dis_inod, _point_put<T>(base::_dimension));
56  ops << endl;
57  }
58  std::vector<size_type> node_perm ((my_proc == io_proc) ? dis_nnod : 0);
59  size_type tag_gather = distributor::get_new_tag();
60  if (my_proc == io_proc) {
61  size_type i_start = _inod2ios_dis_inod.ownership().first_index(my_proc);
62  size_type i_size = _inod2ios_dis_inod.ownership().size (my_proc);
63  for (size_type i = 0; i < i_size; i++) {
64  node_perm [i_start + i] = _inod2ios_dis_inod [i];
65  }
66  for (size_type iproc = 0; iproc < nproc; iproc++) {
67  if (iproc == my_proc) continue;
68  size_type i_start = _inod2ios_dis_inod.ownership().first_index(iproc);
69  size_type i_size = _inod2ios_dis_inod.ownership().size (iproc);
70  comm.recv (iproc, tag_gather, node_perm.begin().operator->() + i_start, i_size);
71  }
72  } else {
73  comm.send (0, tag_gather, _inod2ios_dis_inod.begin().operator->(), _inod2ios_dis_inod.size());
74  }
75  geo_element_permuted_put put_element (node_perm);
76  for (size_type dim = base::_map_dimension; dim > 0; dim--) {
77  size_type first_dis_v = 0;
79  variant < reference_element:: last_variant_by_dimension(dim); variant++) {
80 
81  if (base::_gs.ownership_by_variant[variant].dis_size() == 0) continue;
82  permutation_proxy perm (base::_geo_element [variant], first_dis_v);
83  base::_geo_element [variant].permuted_put_values (ops, perm, put_element);
84  first_dis_v += base::_gs.ownership_by_variant[variant].dis_size();
85  }
86  ops << endl;
87  }
89  iter = base::_domains.begin(),
90  last = base::_domains.end();
91  iter != last; ++iter) {
92  ops << endl;
93  (*iter).put (ops, *this);
94  }
95  return ops;
96 }
97 template <class T>
98 void
99 geo_rep<T,distributed>::dump (std::string name) const
100 {
101  fatal_macro ("dump: not yet");
102 #ifdef TODO
103  base::_node.dump (name + "-node");
104  base::_geo_element[variant].dump(name + "-elem-"+ref::name(variant));
105 #endif // TODO
106 }
107 template class geo_rep<Float,distributed>;
108 
109 } // namespace rheolef
110 #endif // _RHEOLEF_HAVE_MPI
111