PABLO  0.1
PArallel Balanced Linear Octree
 All Classes Functions Variables Pages
test14.cpp
1 #include "preprocessor_defines.dat"
2 #include "Class_Global.hpp"
3 #include "Class_Para_Tree.hpp"
4 #include "User_Data_Comm.hpp"
5 
6 using namespace std;
7 
8 // =================================================================================== //
9 
10 int main(int argc, char *argv[]) {
11 
12 #if NOMPI==0
13  MPI::Init(argc, argv);
14 
15  {
16 #endif
17  int iter = 0;
18  int dim = 2;
19 
21  Class_Para_Tree<2> pablo14;
22 
24  for (iter=1; iter<5; iter++){
25  pablo14.adaptGlobalRefine();
26  }
27 
28 #if NOMPI==0
29 
30  pablo14.loadBalance();
31 #endif
32 
34  double xc, yc;
35  xc = yc = 0.5;
36  double radius = 0.25;
37 
39  uint32_t nocts = pablo14.getNumOctants();
40  uint32_t nghosts = pablo14.getNumGhosts();
41  vector<double> oct_data(nocts, 0.0), ghost_data(nghosts, 0.0);
42 
44  for (int i=0; i<nocts; i++){
45  vector<vector<double> > nodes = pablo14.getNodes(i);
46  for (int j=0; j<global2D.nnodes; j++){
47  double x = nodes[j][0];
48  double y = nodes[j][1];
49  if ((pow((x-xc),2.0)+pow((y-yc),2.0) <= pow(radius,2.0))){
50  oct_data[i] = 1.0;
51  }
52  }
53  }
54 
56  for (int i=0; i<nghosts; i++){
58  Class_Octant<2> *oct = pablo14.getGhostOctant(i);
59  vector<vector<double> > nodes = pablo14.getNodes(oct);
60  for (int j=0; j<global2D.nnodes; j++){
61  double x = nodes[j][0];
62  double y = nodes[j][1];
63  if ((pow((x-xc),2.0)+pow((y-yc),2.0) <= pow(radius,2.0))){
64  ghost_data[i] = 1.0;
65  }
66  }
67  }
68 
70  iter = 0;
71  pablo14.updateConnectivity();
72  pablo14.writeTest("Pablo14_iter"+to_string(static_cast<unsigned long long>(iter)), oct_data);
73 
75  int start = iter + 1;
76  for (iter=start; iter<start+25; iter++){
77  vector<double> oct_data_smooth(nocts, 0.0);
78  vector<uint32_t> neigh, neigh_t;
79  vector<bool> isghost, isghost_t;
80  uint8_t iface, nfaces, codim;
81  for (int i=0; i<nocts; i++){
82  neigh.clear();
83  isghost.clear();
84 
86  for (codim=1; codim<dim+1; codim++){
87  if (codim == 1){
88  nfaces = global2D.nfaces;
89  }
90  else if (codim == 2){
91  nfaces = global2D.nnodes;
92  }
93  for (iface=0; iface<nfaces; iface++){
94  pablo14.findNeighbours(i,iface,codim,neigh_t,isghost_t);
95  neigh.insert(neigh.end(), neigh_t.begin(), neigh_t.end());
96  isghost.insert(isghost.end(), isghost_t.begin(), isghost_t.end());
97  }
98  }
99 
101  oct_data_smooth[i] = oct_data[i]/(neigh.size()+1);
102  for (int j=0; j<neigh.size(); j++){
103  if (isghost[j]){
104  oct_data_smooth[i] += ghost_data[neigh[j]]/(neigh.size()+1);
105  }
106  else{
107  oct_data_smooth[i] += oct_data[neigh[j]]/(neigh.size()+1);
108  }
109  }
110  }
111 
113  pablo14.updateConnectivity();
114  pablo14.writeTest("Pablo14_iter"+to_string(static_cast<unsigned long long>(iter)), oct_data_smooth);
115 
116 #if NOMPI==0
117 
118  User_Data_Comm<vector<double> > data_comm(oct_data_smooth, ghost_data);
119  pablo14.communicate(data_comm);
120 
121 #endif
122  oct_data = oct_data_smooth;
123 
124  }
125 #if NOMPI==0
126  }
127 
128  MPI::Finalize();
129 #endif
130 }
131 
132 
void writeTest(string filename, vector< double > data)
Parallel Octree Manager Class - 2D specialization.
Octant class definition - 2D specialization.
void findNeighbours(uint32_t idx, uint8_t iface, uint8_t codim, u32vector &neighbours, vector< bool > &isghost)
void getNodes(Class_Octant< 2 > *oct, dvector2D &nodes)
uint32_t getNumOctants() const
uint32_t getNumGhosts() const
void communicate(Class_Data_Comm_Interface< Impl > &userData)
Class_Octant< 2 > * getGhostOctant(uint32_t idx)