PABLO  0.1
PArallel Balanced Linear Octree
 All Classes Functions Variables Pages
test120.cpp
1 #include "preprocessor_defines.dat"
2 #include "Class_Global.hpp"
3 #include "Class_Para_Tree.hpp"
4 #include "User_Data_Comm.hpp"
5 #include "User_Data_LB.hpp"
6 
7 using namespace std;
8 
9 // =================================================================================== //
10 
11 int main(int argc, char *argv[]) {
12 
13 #if NOMPI==0
14  MPI::Init(argc, argv);
15 
16  {
17 #endif
18  int iter = 0;
19 
21  Class_Para_Tree<3> pablo120;
22 
24  int idx = 0;
25  pablo120.setBalance(idx,false);
26 
28  for (iter=1; iter<6; iter++){
29  pablo120.adaptGlobalRefine();
30  }
31 
32 #if NOMPI==0
33 
34  pablo120.loadBalance();
35 #endif
36 
38  double xc, yc, zc;
39  double radius = 0.15;
40  double t0 = 0;
41  double Dt = 0.000025;
42  double omega = 2.0*3.14/0.001;
43 
45  xc = 0.25*cos(omega* Dt) + 0.5 ;
46  yc = 0.25*sin(omega* Dt) + 0.5;
47  zc = 100*Dt;
48 
50  uint32_t nocts = pablo120.getNumOctants();
51  vector<double> oct_data(nocts, 0.0);
52 
54  int itstart = 1;
55  int itend = 460;
56 
57  for (iter=itstart; iter<itend; iter++){
58 
60  xc = 0.25*cos(omega* Dt* (double) iter) + 0.5 ;
61  yc = 0.25*sin(omega* Dt* (double) iter) + 0.5;
62  zc = 100*Dt*iter;
63 
64  for (int i=0; i<nocts; i++){
65  bool inside = false;
67  vector<vector<double> > nodes = pablo120.getNodes(i);
69  vector<double> center = pablo120.getCenter(i);
70  oct_data[i] = sqrt((pow((center[0]-xc),2.0)+pow((center[1]-yc),2.0)+pow((center[2]-zc),2.0)));
71  for (int j=0; j<global3D.nnodes; j++){
72  double x = nodes[j][0];
73  double y = nodes[j][1];
74  double z = nodes[j][2];
75  if (pow((x-xc),2.0)+pow((y-yc),2.0)+pow((z-zc),2.0) <= pow(radius,2.0)){
76  if (pablo120.getLevel(i) < 6){
78  pablo120.setMarker(i,1);
79  }
80  else{
81  pablo120.setMarker(i,0);
82  }
83  inside = true;
84  }
85  }
86  if (pablo120.getLevel(i) > 5 && !inside){
88  pablo120.setMarker(i,-1);
89  }
90  }
91 
93  bool adapt = pablo120.adapt();
94 
95 #if NOMPI==0
96 
97  pablo120.loadBalance();
98 #endif
99 
101  nocts = pablo120.getNumOctants();
102  vector<double> oct_data_new(nocts, 0.0);
103  for (int i=0; i<nocts; i++){
104  vector<double> center = pablo120.getCenter(i);
105  oct_data_new[i] = sqrt((pow((center[0]-xc),2.0)+pow((center[1]-yc),2.0)+pow((center[2]-zc),2.0)));
106  }
107 
108  oct_data.resize(nocts);
109  oct_data = oct_data_new;
110  oct_data_new.clear();
111 
113  pablo120.updateConnectivity();
114  pablo120.writeTest("Pablo120_iter"+to_string(static_cast<unsigned long long>(iter)), oct_data);
115  }
116 #if NOMPI==0
117  }
118 
119  MPI::Finalize();
120 #endif
121 }
Parallel Octree Manager Class - 3D specialization.
uint8_t getLevel(Class_Octant< 3 > *oct)
void getCenter(Class_Octant< 3 > *oct, dvector &center)
void getNodes(Class_Octant< 3 > *oct, dvector2D &nodes)
uint32_t getNumOctants() const
void setMarker(Class_Octant< 3 > *oct, int8_t marker)
void writeTest(string filename, vector< double > data)
void setBalance(Class_Octant< 3 > *oct, bool balance)