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 #include "Decomposition/CartDecomposition.hpp"
4 
26 
28 constexpr size_t x = 0;
29 constexpr size_t y = 1;
30 constexpr size_t z = 2;
31 
32 constexpr size_t A = 0;
33 constexpr size_t B = 0;
34 
36 
37 int main(int argc, char* argv[])
38 {
53 
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 
82 
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 
105 
107  auto dom = g_dist.getDomainIterator();
108 
109  while (dom.isNext())
110  {
111 
113 
125 
127  auto key = dom.get();
128 
130 
143 
145  auto key_g = g_dist.getGKey(key);
146 
148 
161 
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 
187 
189  g_dist.template ghost_get<A>();
190 
192 
203 
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 
234 
236  g_dist.write("output");
237 
239 
249 
251  openfpm_finalize();
252 
254 
263 }
Definition: Ghost.hpp:39
This is a distributed grid.
This class is a trick to indicate the compiler a specific specialization pattern. ...
Definition: memory_c.hpp:201
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
Definition: aggregate.hpp:81