PABLO  0.1
PArallel Balanced Linear Octree
 All Classes Functions Variables Pages
test4.cpp
1 #include "preprocessor_defines.dat"
2 #include "Class_Global.hpp"
3 #include "Class_Para_Tree.hpp"
4 
5 using namespace std;
6 
7 // =================================================================================== //
8 
9 int main(int argc, char *argv[]) {
10 
11 #if NOMPI==0
12  MPI::Init(argc, argv);
13 
14  {
15 #endif
16  int iter = 0;
18  Class_Para_Tree<2> pablo4;
19 
21  for (iter=1; iter<5; iter++){
22  pablo4.adaptGlobalRefine();
23  }
24 
26  double xc, yc;
27  xc = yc = 0.5;
28  double radius = 0.25;
29 
31  uint32_t nocts = pablo4.getNumOctants();
32  vector<double> oct_data(nocts, 0.0);
33 
35  for (int i=0; i<nocts; i++){
37  vector<vector<double> > nodes = pablo4.getNodes(i);
38  for (int j=0; j<global2D.nnodes; j++){
39  double x = nodes[j][0];
40  double y = nodes[j][1];
41  if ((pow((x-xc),2.0)+pow((y-yc),2.0) <= pow(radius,2.0))){
42  oct_data[i] = 1.0;
43  }
44  }
45  }
46 
48  iter = 0;
49  pablo4.updateConnectivity();
50  pablo4.writeTest("Pablo4_iter"+to_string(static_cast<unsigned long long>(iter)), oct_data);
51 
53  int start = 1;
54  for (iter=start; iter<start+25; iter++){
55  vector<double> oct_data_smooth(nocts, 0.0);
56  vector<uint32_t> neigh, neigh_t;
57  vector<bool> isghost, isghost_t;
58  uint8_t iface, nfaces;
59  int codim;
60  for (int i=0; i<nocts; i++){
61  neigh.clear();
62  isghost.clear();
63 
65  for (codim=1; codim<3; codim++){
66  if (codim == 1){
67  nfaces = global2D.nfaces;
68  }
69  else if (codim == 2){
70  nfaces = global2D.nnodes;
71  }
72  for (iface=0; iface<nfaces; iface++){
73  pablo4.findNeighbours(i,iface,codim,neigh_t,isghost_t);
74  neigh.insert(neigh.end(), neigh_t.begin(), neigh_t.end());
75  isghost.insert(isghost.end(), isghost_t.begin(), isghost_t.end());
76  }
77  }
78 
80  oct_data_smooth[i] = oct_data[i]/(neigh.size()+1);
81  for (int j=0; j<neigh.size(); j++){
82  if (isghost[j]){
84  }
85  else{
86  oct_data_smooth[i] += oct_data[neigh[j]]/(neigh.size()+1);
87  }
88  }
89  }
90 
92  pablo4.updateConnectivity();
93  pablo4.writeTest("Pablo4_iter"+to_string(static_cast<unsigned long long>(iter)), oct_data_smooth);
94 
95  oct_data = oct_data_smooth;
96  }
97 #if NOMPI==0
98  }
99 
100  MPI::Finalize();
101 #endif
102 }
void writeTest(string filename, vector< double > data)
Parallel Octree Manager Class - 2D specialization.
void findNeighbours(uint32_t idx, uint8_t iface, uint8_t codim, u32vector &neighbours, vector< bool > &isghost)
void getNodes(Class_Octant< 2 > *oct, dvector2D &nodes)
uint32_t getNumOctants() const