1#include "Grid/grid_dist_id.hpp"
2#include "data_type/aggregate.hpp"
74 auto it = Old.getDomainIterator();
82 Old.template get<U>(key) = 1.0;
83 Old.template get<V>(key) = 0.0;
86 New.template get<U>(key) = 0.0;
87 New.template get<V>(key) = 0.0;
108 grid_key_dx<2> start({(
long int)std::floor(Old.size(0)*1.55f/domain.getHigh(0)),(
long int)std::floor(Old.size(1)*1.55f/domain.getHigh(1))});
109 grid_key_dx<2> stop ({(
long int)std::ceil (Old.size(0)*1.85f/domain.getHigh(0)),(
long int)std::ceil (Old.size(1)*1.85f/domain.getHigh(1))});
110 auto it_init = Old.getSubDomainIterator(start,stop);
112 while (it_init.isNext())
114 auto key = it_init.
get();
116 Old.template get<U>(key) = 0.5 + (((double)std::rand())/RAND_MAX -0.5)/100.0;
117 Old.template get<V>(key) = 0.25 + (((double)std::rand())/RAND_MAX -0.5)/200.0;
131int main(
int argc,
char* argv[])
161 openfpm_init(&argc,&argv);
167 size_t sz[2] = {128,128};
185 size_t timeSteps = 15000;
214 double spacing[2] = {Old.spacing(0),Old.spacing(1)};
229 init(Old,New,domain);
271 Old.template ghost_get<U,V>();
275 double uFactor = deltaT * du/(spacing[x]*spacing[x]);
276 double vFactor = deltaT * dv/(spacing[x]*spacing[x]);
278 for (
size_t i = 0; i < timeSteps; ++i)
280 auto it = Old.getDomainIterator();
287 New.get<U>(key) = Old.get<U>(key) + uFactor * (
288 Old.get<U>(key.move(x,1)) +
289 Old.get<U>(key.move(x,-1)) +
290 Old.get<U>(key.move(y,1)) +
291 Old.get<U>(key.move(y,-1)) +
292 -4.0*Old.get<U>(key)) +
293 - deltaT * Old.get<U>(key) * Old.get<V>(key) * Old.get<V>(key) +
294 - deltaT *
F * (Old.get<U>(key) - 1.0);
297 New.get<V>(key) = Old.get<V>(key) + vFactor * (
298 Old.get<V>(key.move(x,1)) +
299 Old.get<V>(key.move(x,-1)) +
300 Old.get<V>(key.move(y,1)) +
301 Old.get<V>(key.move(y,-1)) -
303 deltaT * Old.get<U>(key) * Old.get<V>(key) * Old.get<V>(key) +
304 - deltaT * (
F+K) * Old.get<V>(key);
318 Old.ghost_get<U,V>();
324 Old.ghost_get<U,V>();
325 Old.write_frame(
"output",count);
This class represent an N-dimensional box.
This is a distributed grid.
grid_key_dx is the key to access any element in the grid
__device__ __host__ index_type get(index_type i) const
Get the i index.
KeyT const ValueT ValueT OffsetIteratorT OffsetIteratorT int
[in] The number of segments that comprise the sorting data
OutputIteratorT OffsetT ReductionOpT OuputT init
< [in] The initial value of the reduction
[v_transform metafunction]
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...