PABLO  0.1
PArallel Balanced Linear Octree
 All Classes Functions Variables Pages
test1.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 
17  Class_Para_Tree<2> pablo1;
18 
20  pablo1.computeConnectivity();
21  pablo1.write("Pablo1_iter0");
22 
24  pablo1.adaptGlobalRefine();
25  pablo1.updateConnectivity();
26  pablo1.write("Pablo1_iter1");
27 
29  double xc, yc;
30  xc = yc = 0.5;
31 
33  pablo1.setBalanceCodimension(1);
34 
36  uint32_t nocts = pablo1.getNumOctants();
37  for (int i=0; i<nocts; i++){
38  vector<double> center = pablo1.getCenter(i);
39  double x = center[0];
40  double y = center[1];
41  if (x>xc)
42  pablo1.setBalance(i,false);
43  }
44 
46  double radius = 0.4;
47 
49  int nref1 = 6;
50  for (int iter=0; iter<nref1; iter++){
51  nocts = pablo1.getNumOctants();
52  for (int i=0; i<nocts; i++){
54  Class_Octant<2> *oct = pablo1.getOctant(i);
56  vector<double> center = pablo1.getCenter(oct);
57  double x = center[0];
58  double y = center[1];
59 
61  if ((pow((x-xc),2.0)+pow((y-yc),2.0) < pow(radius,2.0)) &&
62  (y<yc)){
63  pablo1.setMarker(oct, 1);
64  }
65  }
67  pablo1.adapt();
68  pablo1.updateConnectivity();
69  pablo1.write("Pablo1_iter"+to_string(static_cast<unsigned long long>(iter+2)));
70  }
71 
74  int nref2 = 5;
75  int iter = 0;
76  bool done = true;
77  while(iter<=nref2){
78  done = true;
79  while(done)
80  {
81  nocts = pablo1.getNumOctants();
82  for (int i=0; i<nocts; i++){
84  vector<double> center = pablo1.getCenter(i);
85  double x = center[0];
86  double y = center[1];
87  if ((pow((x-xc),2.0)+pow((y-yc),2.0) < pow(radius,2.0)) &&
88  (y>yc) && iter<=nref2 && pablo1.getLevel(i)<=iter+1){
89 
91  pablo1.setMarker(i, 1);
92  }
93  }
94  done = pablo1.adapt();
95  pablo1.updateConnectivity();
96  pablo1.write("Pablo1_iter"+to_string(static_cast<unsigned long long>(iter+nref1+2)));
97  }
98  iter++;
99  }
101  pablo1.adaptGlobalRefine();
102  pablo1.updateConnectivity();
103  pablo1.write("Pablo1_iter"+to_string(static_cast<unsigned long long>(iter+nref1+3)));
104 #if NOMPI==0
105  }
106 
107  MPI::Finalize();
108 #endif
109 }
110 
uint8_t getLevel(Class_Octant< 2 > *oct)
Class_Octant< 2 > * getOctant(uint32_t idx)
Parallel Octree Manager Class - 2D specialization.
Octant class definition - 2D specialization.
void setMarker(Class_Octant< 2 > *oct, int8_t marker)
uint32_t getNumOctants() const
void setBalanceCodimension(uint8_t b21codim)
void write(string filename)
void setBalance(Class_Octant< 2 > *oct, bool balance)
void getCenter(Class_Octant< 2 > *oct, vector< double > &center)