OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
main.cpp
1 #include "Grid/grid_dist_id.hpp"
2 
32 int main(int argc, char* argv[])
33 {
48 
50  // Initialize the library
51  openfpm_init(&argc,&argv);
52 
53  // 3D physical domain
54  Box<3,float> domain({0.0,0.0,0.0},{1.0,1.0,1.0});
55 
56  // Grid size on eaxh dimension
57  size_t sz[3] = {100,100,100};
58 
59  // Ghost part
60  Ghost<3,float> g(0.1);
61 
63 
86 
88  grid_dist_id<3, float, aggregate<float[3]>> g_dist(sz,domain,g);
89 
91 
105 
107  // Get the iterator (No ghost)
108  auto dom = g_dist.getDomainIterator();
109 
110  // Counter
111  size_t count = 0;
112 
113  // Iterate over all the grid points
114  while (dom.isNext())
115  {
117 
131 
133  // local grid key from iterator
134  auto key = dom.get();
135 
137 
203 
205  auto key_g = g_dist.getGKey(key);
206 
208 
221 
223  g_dist.template get<0>(key)[0] = key_g.get(0);
224  g_dist.template get<0>(key)[1] = key_g.get(1);
225  g_dist.template get<0>(key)[2] = key_g.get(2);
226 
227  // Count the points
228  count++;
229 
231 
233 
234  // next point
235  ++dom;
236  }
237 
239 
251 
253  g_dist.template ghost_get<0>();
254 
256 
269 
271  // Get the VCluster object
272  Vcluster<> & vcl = create_vcluster();
273 
274  // queue an operation of sum for the counter count
275  vcl.sum(count);
276 
277  // execute the operation
278  vcl.execute();
279 
280  // only master output
281  if (vcl.getProcessUnitID() == 0)
282  std::cout << "Number of points: " << count << "\n";
283 
285 
303 
305  g_dist.write("output");
306 
308 
330 
332  g_dist.getDecomposition().write("out_dec");
333 
335 
347 
349  openfpm_finalize();
350 
352 
361 }
size_t getProcessUnitID()
Get the process unit id.
Definition: Ghost.hpp:39
Implementation of VCluster class.
Definition: VCluster.hpp:58
void execute()
Execute all the requests.
This is a distributed grid.
void sum(T &num)
Sum the numbers across all processors and get the result.