OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
main.cpp
1 #include "Grid/grid_dist_id.hpp"
2 #include "data_type/aggregate.hpp"
3 
33 int main(int argc, char* argv[])
34 {
49 
51  // Initialize the library
52  openfpm_init(&argc,&argv);
53 
54  // 3D physical domain
55  Box<3,float> domain({0.0,0.0,0.0},{1.0,1.0,1.0});
56 
57  // Grid size on eaxh dimension
58  size_t sz[3] = {100,100,100};
59 
60  // Ghost part
61  Ghost<3,float> g(0.1);
62 
64 
87 
89  grid_dist_id<3, float, aggregate<float[3]>> g_dist(sz,domain,g);
90 
92 
106 
108  // Get the iterator (No ghost)
109  auto dom = g_dist.getDomainIterator();
110 
111  // Counter
112  size_t count = 0;
113 
114  // Iterate over all the grid points
115  while (dom.isNext())
116  {
118 
132 
134  // local grid key from iterator
135  auto key = dom.get();
136 
138 
204 
206  auto key_g = g_dist.getGKey(key);
207 
209 
222 
224  g_dist.template get<0>(key)[0] = key_g.get(0);
225  g_dist.template get<0>(key)[1] = key_g.get(1);
226  g_dist.template get<0>(key)[2] = key_g.get(2);
227 
228  // Count the points
229  count++;
230 
232 
234 
235  // next point
236  ++dom;
237  }
238 
240 
252 
254  g_dist.template ghost_get<0>();
255 
257 
270 
272  // Get the VCluster object
273  Vcluster & vcl = create_vcluster();
274 
275  // queue an operation of sum for the counter count
276  vcl.sum(count);
277 
278  // execute the operation
279  vcl.execute();
280 
281  // only master output
282  if (vcl.getProcessUnitID() == 0)
283  std::cout << "Number of points: " << count << "\n";
284 
286 
304 
306  g_dist.write("output");
307 
309 
331 
333  g_dist.getDecomposition().write("out_dec");
334 
336 
348 
350  openfpm_finalize();
351 
353 
362 }
Definition: Ghost.hpp:39
Implementation of VCluster class.
Definition: VCluster.hpp:36
This is a distributed grid.
This class is a trick to indicate the compiler a specific specialization pattern. ...
Definition: memory_c.hpp:201