PABLO  0.1
PArallel Balanced Linear Octree
 All Classes Functions Variables Pages
test5.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> pablo5;
19 
21  int idx = 0;
22  pablo5.setBalance(idx,false);
23 
25  for (iter=1; iter<6; iter++){
26  pablo5.adaptGlobalRefine();
27  }
28 
30  double xc, yc;
31  xc = yc = 0.5;
32  double radius = 0.25;
33 
35  uint32_t nocts = pablo5.getNumOctants();
36  uint32_t nghosts = pablo5.getNumGhosts();
37  vector<double> oct_data(nocts, 0.0);
38 
40  for (int i=0; i<nocts; i++){
42  vector<vector<double> > nodes = pablo5.getNodes(i);
43  vector<double> center = pablo5.getCenter(i);
44  for (int j=0; j<global2D.nnodes; j++){
45  double x = nodes[j][0];
46  double y = nodes[j][1];
47  if ((pow((x-xc),2.0)+pow((y-yc),2.0) <= pow(radius,2.0))){
48  oct_data[i] = (pow((center[0]-xc),2.0)+pow((center[1]-yc),2.0));
49  }
50  }
51  }
52 
54  iter = 0;
55  pablo5.updateConnectivity();
56  pablo5.writeTest("Pablo5_iter"+to_string(static_cast<unsigned long long>(iter)), oct_data);
57 
59  int start = 1;
60  for (iter=start; iter<start+2; iter++){
61  for (int i=0; i<nocts; i++){
63  vector<vector<double> > nodes = pablo5.getNodes(i);
64  vector<double> center = pablo5.getCenter(i);
65  for (int j=0; j<global2D.nnodes; j++){
66  double x = nodes[j][0];
67  double y = nodes[j][1];
68  if ((pow((x-xc),2.0)+pow((y-yc),2.0) <= pow(radius,2.0))){
69  if (center[0]<=xc){
70 
72  pablo5.setMarker(i,1);
73  }
74  else{
75 
77  pablo5.setMarker(i,-1);
78  }
79  }
80  }
81  }
82 
84  vector<double> oct_data_new;
85  vector<uint32_t> mapper;
86  vector<bool> isghost;
87  pablo5.adapt(true);
88  nocts = pablo5.getNumOctants();
89  oct_data_new.resize(nocts, 0.0);
90 
94  for (uint32_t i=0; i<nocts; i++){
95  pablo5.getMapping(i, mapper, isghost);
96  if (pablo5.getIsNewC(i)){
97  for (int j=0; j<global2D.nchildren; j++){
98  oct_data_new[i] += oct_data[mapper[j]]/global2D.nchildren;
99  }
100  }
101  else if (pablo5.getIsNewR(i)){
102  oct_data_new[i] += oct_data[mapper[0]];
103  }
104  else{
105  oct_data_new[i] += oct_data[mapper[0]];
106  }
107  }
108 
110  pablo5.updateConnectivity();
111  pablo5.writeTest("Pablo5_iter"+to_string(static_cast<unsigned long long>(iter)), oct_data_new);
112 
113  oct_data = oct_data_new;
114  }
115 
116 #if NOMPI==0
117  }
118 
119  MPI::Finalize();
120 #endif
121 }
122 
void writeTest(string filename, vector< double > data)
Parallel Octree Manager Class - 2D specialization.
void setMarker(Class_Octant< 2 > *oct, int8_t marker)
bool getIsNewC(Class_Octant< 2 > *oct)
void getNodes(Class_Octant< 2 > *oct, dvector2D &nodes)
uint32_t getNumOctants() const
uint32_t getNumGhosts() const
void getMapping(uint32_t &idx, u32vector &mapper, vector< bool > &isghost)
bool getIsNewR(Class_Octant< 2 > *oct)
void setBalance(Class_Octant< 2 > *oct, bool balance)
void getCenter(Class_Octant< 2 > *oct, vector< double > &center)