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#include "data_type/aggregate.hpp"
3#include "Decomposition/CartDecomposition.hpp"
4
27
28constexpr size_t x = 0;
29constexpr size_t y = 1;
30constexpr size_t z = 2;
31
32constexpr size_t A = 0;
33constexpr size_t B = 1;
34
36
37int main(int argc, char* argv[])
38{
54
55 openfpm_init(&argc,&argv);
56
57 // domain
58 Box<3,float> domain({0.0,0.0,0.0},{1.0,1.0,1.0});
59
60 // grid sizes
61 size_t sz[3] = {100,100,100};
62
63 // ghost extension
64 Ghost<3,float> g(0.03);
65
67
83
84 // a convenient alias for aggregate<...>
85 typedef aggregate<float,float> grid_point;
86
87 grid_dist_id<3, float, grid_point> g_dist(sz,domain,g);
88
90
106
107 auto dom = g_dist.getDomainIterator();
108
109 while (dom.isNext())
110 {
111
113
126
127 auto key = dom.get();
128
130
144
145 auto key_g = g_dist.getGKey(key);
146
148
162
163 g_dist.template get<A>(key) = key_g.get(0)*key_g.get(0) + key_g.get(1)*key_g.get(1) + key_g.get(2)*key_g.get(2);
164
166
168
169 ++dom;
170 }
171
173
188
189 g_dist.template ghost_get<A>();
190
192
204
205 auto dom2 = g_dist.getDomainIterator();
206
207 while (dom2.isNext())
208 {
209 auto key = dom2.get();
210
211 // Laplace stencil
212 g_dist.template get<B>(key) = g_dist.template get<A>(key.move(x,1)) + g_dist.template get<A>(key.move(x,-1)) +
213 g_dist.template get<A>(key.move(y,1)) + g_dist.template get<A>(key.move(y,-1)) +
214 g_dist.template get<A>(key.move(z,1)) + g_dist.template get<A>(key.move(z,-1)) -
215 6*g_dist.template get<A>(key);
216
217 ++dom2;
218 }
219
221
235
236 g_dist.write("output");
237
239
250
251 openfpm_finalize();
252
254
263}
This class represent an N-dimensional box.
Definition Box.hpp:61
This is a distributed grid.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...