PABLO  0.1
PArallel Balanced Linear Octree
 All Classes Functions Variables Pages
test16.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<2> pablo16;
22 
24  int idx = 0;
25  pablo16.setBalance(idx,false);
26 
28  for (iter=1; iter<6; iter++){
29  pablo16.adaptGlobalRefine();
30  }
31 
33  double xc, yc;
34  xc = yc = 0.5;
35  double radius = 0.25;
36 
38  uint32_t nocts = pablo16.getNumOctants();
39  uint32_t nghosts = pablo16.getNumGhosts();
40  vector<double> oct_data(nocts, 0.0), ghost_data(nghosts, 0.0);
41 
43  for (int i=0; i<nocts; i++){
45  vector<vector<double> > nodes = pablo16.getNodes(i);
47  vector<double> center = pablo16.getCenter(i);
48  for (int j=0; j<global2D.nnodes; j++){
49  double x = nodes[j][0];
50  double y = nodes[j][1];
51  if ((pow((x-xc),2.0)+pow((y-yc),2.0) <= pow(radius,2.0))){
52  oct_data[i] = (pow((center[0]-xc),2.0)+pow((center[1]-yc),2.0));
53  }
54  }
55  }
56 
58  iter = 0;
59  pablo16.updateConnectivity();
60  pablo16.writeTest("Pablo16_iter"+to_string(static_cast<unsigned long long>(iter)), oct_data);
61 
63  int start = 1;
64  for (iter=start; iter<start+2; iter++){
65  for (int i=0; i<nocts; i++){
67  vector<vector<double> > nodes = pablo16.getNodes(i);
69  vector<double> center = pablo16.getCenter(i);
70  for (int j=0; j<global2D.nnodes; j++){
71  double x = nodes[j][0];
72  double y = nodes[j][1];
73  if ((pow((x-xc),2.0)+pow((y-yc),2.0) <= pow(radius,2.0))){
74  if (center[0]<=xc){
75 
77  pablo16.setMarker(i,1);
78  }
79  else{
80 
82  pablo16.setMarker(i,-1);
83  }
84  }
85  }
86  }
87 
89  vector<double> oct_data_new;
90  vector<uint32_t> mapper;
91  vector<bool> isghost;
92  pablo16.adapt(true);
93  nocts = pablo16.getNumOctants();
94  oct_data_new.resize(nocts, 0.0);
95 
99  for (uint32_t i=0; i<nocts; i++){
100  pablo16.getMapping(i, mapper, isghost);
101  if (pablo16.getIsNewC(i)){
102  for (int j=0; j<global2D.nchildren; j++){
103  if (isghost[j]){
104  oct_data_new[i] += ghost_data[mapper[j]]/global3D.nchildren;
105  }
106  else{
107  oct_data_new[i] += oct_data[mapper[j]]/global3D.nchildren;
108  }
109  }
110  }
111  else{
112  oct_data_new[i] += oct_data[mapper[0]];
113  }
114  }
115 
117  pablo16.updateConnectivity();
118  pablo16.writeTest("Pablo16_iter"+to_string(static_cast<unsigned long long>(iter)), oct_data_new);
119 
120  oct_data = oct_data_new;
121  }
122 
123 #if NOMPI==0
124 
126  uint8_t levels = 4;
127  User_Data_LB<vector<double> > data_lb(oct_data,ghost_data);
128  pablo16.loadBalance(data_lb, levels);
129 #endif
130 
132  pablo16.updateConnectivity();
133  pablo16.writeTest("Pablo16_iter"+to_string(static_cast<unsigned long long>(iter)), oct_data);
134 
135 #if NOMPI==0
136  }
137 
138  MPI::Finalize();
139 #endif
140 }
141 
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)
void setBalance(Class_Octant< 2 > *oct, bool balance)
void getCenter(Class_Octant< 2 > *oct, vector< double > &center)