12#include "Grid/grid_dist_id.hpp"
13#include "data_type/aggregate.hpp"
53 auto it = Old.getGridIterator();
58 auto key = it.get_dist();
61 Old.template insert<U>(key) = 1.0;
62 Old.template insert<V>(key) = 0.0;
65 New.template insert<U>(key) = 0.0;
66 New.template insert<V>(key) = 0.0;
71 long int x_start = Old.size(0)*1.55f/domain.getHigh(0);
72 long int y_start = Old.size(1)*1.55f/domain.getHigh(1);
73 long int z_start = Old.size(1)*1.55f/domain.getHigh(2);
75 long int x_stop = Old.size(0)*1.85f/domain.getHigh(0);
76 long int y_stop = Old.size(1)*1.85f/domain.getHigh(1);
77 long int z_stop = Old.size(1)*1.85f/domain.getHigh(2);
81 auto it_init = Old.getGridIterator(start,stop);
83 while (it_init.isNext())
85 auto key = it_init.get_dist();
87 Old.template insert<U>(key) = 0.5 + (((double)std::rand())/RAND_MAX -0.5)/10.0;
88 Old.template insert<V>(key) = 0.25 + (((double)std::rand())/RAND_MAX -0.5)/20.0;
95int main(
int argc,
char* argv[])
97 openfpm_init(&argc,&argv);
103 size_t sz[3] = {128,128,128};
122 size_t timeSteps = 200;
124 size_t timeSteps = 5000;
138 double spacing[3] = {Old.spacing(0),Old.spacing(1),Old.spacing(2)};
140 init(Old,New,domain);
144 Old.template ghost_get<U,V>();
148 double uFactor = deltaT * du/(spacing[x]*spacing[x]);
149 double vFactor = deltaT * dv/(spacing[x]*spacing[x]);
151 Old.write(
"Init_condition");
156 auto & v_cl = create_vcluster();
158 for (
size_t i = 0; i < timeSteps; ++i)
160 if (v_cl.rank() == 0)
161 {std::cout <<
"STEP: " << i << std::endl;}
170 auto it = Old.getDomainIterator();
178 auto mx = Cp.move(0,-1);
179 auto px = Cp.move(0,+1);
180 auto my = Cp.move(1,-1);
181 auto py = Cp.move(1,1);
182 auto mz = Cp.move(2,-1);
183 auto pz = Cp.move(2,1);
186 New.insert<U>(Cp) = Old.get<U>(Cp) + uFactor * (
193 6.0*Old.get<U>(Cp)) +
194 - deltaT * Old.get<U>(Cp) * Old.get<V>(Cp) * Old.get<V>(Cp) +
195 - deltaT *
F * (Old.get<U>(Cp) - 1.0);
199 New.insert<V>(Cp) = Old.get<V>(Cp) + vFactor * (
207 deltaT * Old.get<U>(Cp) * Old.get<V>(Cp) * Old.get<V>(Cp) +
208 - deltaT * (
F+K) * Old.get<V>(Cp);
221 Old.copy_sparse(New);
224 Old.ghost_get<U,V>();
230 Old.save(
"output_" + std::to_string(count));
236 std::cout <<
"Total simulation: " << tot_sim.
getwct() << std::endl;
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
Class for cpu time benchmarking.
void stop()
Stop the timer.
void start()
Start the timer.
double getwct()
Return the elapsed real time.
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...