rheolef  6.5
hack_array_scatter_tst.cc
Go to the documentation of this file.
1 // alloues dynamiquement => la memoire n'est pas contigue globalement
2 #include "rheolef/config.h"
3 #ifndef _RHEOLEF_HAVE_MPI
4 int main() { return 0; }
5 #else // _RHEOLEF_HAVE_MPI
6 
7 #include "rheolef/hack_array.h"
8 #include "rheolef/geo_element.h"
9 using namespace rheolef;
10 using namespace std;
11 
12 int main(int argc, char**argv)
13 {
14  environment distributed (argc, argv);
15  check_macro (communicator().size() == 2, "expect nproc = 2");
16  size_t iproc = (argc > 1) ? atoi(argv[1]) : 0;
17  size_t n, order;
18  din >> n >> order;
19  distributor ownership (n, communicator(), distributor::decide);
20  geo_element::parameter_type param (reference_element::e, order); // edge, order=read
21  hack_array<geo_element_hack> ge_e (ownership, param);
22  din >> ge_e;
23  set<size_t> set_ext_idx;
24  size_t jproc = (communicator().rank() == 0) ? 1 : 0;
25  for (size_t dis_i = ownership.first_index(jproc), dis_n = ownership.last_index(jproc); dis_i < dis_n; dis_i++) {
26  set_ext_idx.insert (dis_i);
27  }
28  ge_e.set_dis_indexes (set_ext_idx);
29  if (size_t(communicator().rank()) == iproc) {
30  cout << ge_e.dis_size() << " " << order << endl;
31  for (size_t dis_i = 0, dis_n = ge_e.dis_size(); dis_i < dis_n; dis_i++) {
32  cout << ge_e.dis_at (dis_i) << endl;
33  }
34  }
35 }
36 #endif // _RHEOLEF_HAVE_MPI
37