PABLO  0.1
PArallel Balanced Linear Octree
 All Classes Functions Variables Pages
test104.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;
17  int dim = 3;
18 
20  Class_Para_Tree<3> pablo104;
21 
23  for (iter=1; iter<4; iter++){
24  pablo104.adaptGlobalRefine();
25  }
26 
28  double xc, yc;
29  xc = yc = 0.5;
30  double radius = 0.25;
31 
33  uint32_t nocts = pablo104.getNumOctants();
34  vector<double> oct_data(nocts, 0.0);
35 
37  for (int i=0; i<nocts; i++){
39  vector<vector<double> > nodes = pablo104.getNodes(i);
40  for (int j=0; j<global3D.nnodes; j++){
41  double x = nodes[j][0];
42  double y = nodes[j][1];
43  if ((pow((x-xc),2.0)+pow((y-yc),2.0) <= pow(radius,2.0))){
44  oct_data[i] = 1.0;
45  }
46  }
47  }
48 
50  iter = 0;
51  pablo104.updateConnectivity();
52  pablo104.writeTest("Pablo104_iter"+to_string(static_cast<unsigned long long>(iter)), oct_data);
53 
55  int start = 1;
56  for (iter=start; iter<start+25; iter++){
57  vector<double> oct_data_smooth(nocts, 0.0);
58  vector<uint32_t> neigh, neigh_t;
59  vector<bool> isghost, isghost_t;
60  uint8_t iface, codim, nfaces;
61  for (int i=0; i<nocts; i++){
62  neigh.clear();
63  isghost.clear();
65  for (codim=1; codim<dim+1; codim++){
66  if (codim == 1){
67  nfaces = global3D.nfaces;
68  }
69  else if (codim == 2){
70  nfaces = global3D.nedges;
71  }
72  else if (codim == 3){
73  nfaces = global3D.nnodes;
74  }
75  for (iface=0; iface<nfaces; iface++){
76  pablo104.findNeighbours(i,iface,codim,neigh_t,isghost_t);
77  neigh.insert(neigh.end(), neigh_t.begin(), neigh_t.end());
78  isghost.insert(isghost.end(), isghost_t.begin(), isghost_t.end());
79  }
80  }
81 
83  oct_data_smooth[i] = oct_data[i]/(neigh.size()+1);
84  for (int j=0; j<neigh.size(); j++){
85  if (isghost[j]){
87  }
88  else{
89  oct_data_smooth[i] += oct_data[neigh[j]]/(neigh.size()+1);
90  }
91  }
92  }
93 
95  pablo104.updateConnectivity();
96  pablo104.writeTest("Pablo104_iter"+to_string(static_cast<unsigned long long>(iter)), oct_data_smooth);
97 
98  oct_data = oct_data_smooth;
99  }
100 #if NOMPI==0
101  }
102 
103  MPI::Finalize();
104 #endif
105 }
106 
void findNeighbours(uint32_t idx, uint8_t iface, uint8_t codim, u32vector &neighbours, vector< bool > &isghost)
Parallel Octree Manager Class - 3D specialization.
void getNodes(Class_Octant< 3 > *oct, dvector2D &nodes)
uint32_t getNumOctants() const
void writeTest(string filename, vector< double > data)