OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
main.cpp
1#include "Grid/grid_dist_id.hpp"
2
32int main(int argc, char* argv[])
33{
49
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
87
89
91
106
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
132
133 // local grid key from iterator
134 auto key = dom.get();
135
137
204
205 auto key_g = g_dist.getGKey(key);
206
208
222
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
252
253 g_dist.template ghost_get<0>();
254
256
270
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
304
305 g_dist.write("output");
306
308
331
332 g_dist.getDecomposition().write("out_dec");
333
335
348
349 openfpm_finalize();
350
352
361}
This class represent an N-dimensional box.
Definition Box.hpp:61
void execute()
Execute all the requests.
void sum(T &num)
Sum the numbers across all processors and get the result.
size_t getProcessUnitID()
Get the process unit id.
Implementation of VCluster class.
Definition VCluster.hpp:59
This is a distributed grid.