4 #include "Operators/Vector/vector_dist_operators.hpp"
5 #include "DCPSE/DCPSE_op/DCPSE_op.hpp"
14 int main(
int argc,
char* argv[])
20 openfpm_init(&argc,&argv);
21 auto &v_cl=create_vcluster();
27 std::ofstream output_file;
28 output_file.open(
"rk4_error_results.csv",std::ios_base::app);
30 size_t gdsz = std::stof(argv[1]);
31 const size_t sz[3] = {gdsz,gdsz,gdsz};
34 size_t bc[3] = {PERIODIC,PERIODIC,PERIODIC};
36 spacing[0] = 2.5 / (sz[0]);
37 spacing[1] = 2.5 / (sz[1]);
38 spacing[2] = 2.5 / (sz[2]);
39 double rCut = 2.9 * spacing[0];
44 double t=0,tf=std::stof(argv[2]);
47 typedef aggregate<VectorS<2, double>,
VectorS<2, double>,
VectorS<2, double>,
VectorS<2, double>,
VectorS<2, double>,
VectorS<2, double>>
Property_type;
51 Particles.setPropNames({
"Concentration",
"Initial",
"k1",
"k2",
"k3",
"k4"});
53 auto it = Particles.getGridIterator(sz);
57 double x = 0.0 + key.get(0) * spacing[0];
58 Particles.getLastPos()[0] = x;
59 double y = 0.0 + key.get(1) * spacing[1];
60 Particles.getLastPos()[1] = y;
61 double z = 0.0 + key.get(2) * spacing[2];
62 Particles.getLastPos()[2] = z;
64 Particles.template getLastProp<1>()[0] = 1.0;
65 Particles.template getLastProp<1>()[1] = 0.0;
67 if (x > 1.55 && x < 1.85 && y > 1.55 && y < 1.85 && z > 1.55 && z < 1.85) {
68 Particles.template getLastProp<1>()[0] = 0.5 + (((double)std::rand())/RAND_MAX -0.5)/10.0;
69 Particles.template getLastProp<1>()[1] = 0.25 + (((double)std::rand())/RAND_MAX -0.5)/20.0;
75 Particles.ghost_get<0>();
78 auto verletList = Particles.template getVerlet<VL_NON_SYMMETRIC|VL_SKIP_REF_PART>(rCut);
79 Laplacian<decltype(verletList)>
Lap(Particles, verletList, 2, rCut, support_options::RADIUS);
81 auto C = getV<0>(Particles);
82 auto Init = getV<1>(Particles);
83 auto k1 = getV<2>(Particles);
84 auto k2 = getV<3>(Particles);
85 auto k3 = getV<4>(Particles);
86 auto k4 = getV<5>(Particles);
99 timer timer_integrate;
100 timer_integrate.
start();
103 Particles.ghost_get<0>(SKIP_LABELLING);
104 k1[x]=d1*
Lap(C[x]) - C[x] * C[y] * C[y] +
F -
F * C[x];
105 k1[y]=d2*
Lap(C[y]) + C[x] * C[y] * C[y] - (
F+K) * C[y];
108 Particles.ghost_get<0>(SKIP_LABELLING);
109 k2[x]=d1*
Lap(C[x]) - C[x] * C[y] * C[y] +
F -
F * C[x];
110 k2[y]=d2*
Lap(C[y]) + C[x] * C[y] * C[y] - (
F+K) * C[y];
113 Particles.ghost_get<0>(SKIP_LABELLING);
114 k3[x]=d1*
Lap(C[x]) - C[x] * C[y] * C[y] +
F -
F * C[x];
115 k3[y]=d2*
Lap(C[y]) + C[x] * C[y] * C[y] - (
F+K) * C[y];
118 Particles.ghost_get<0>(SKIP_LABELLING);
119 k4[x]=d1*
Lap(C[x]) - C[x] * C[y] * C[y] +
F -
F * C[x];
120 k4[y]=d2*
Lap(C[y]) + C[x] * C[y] * C[y] - (
F+K) * C[y];
121 Init = Init + dt / 6.0 * (k1 + 2.0 * k2 + 2.0 * k3 + k4);
130 timer_integrate.
stop();
131 Particles.ghost_get<0,1>();
132 Particles.deleteGhost();
133 Particles.write(
"Final");
135 double tt=timer_integrate.
getwct();
140 {output_file << steps <<
","<<v_cl.size()<<
"," << tt/v_cl.size() <<
"\n";}
This class represent an N-dimensional box.
Laplacian second order on h (spacing)
This class implement the point shape in an N-dimensional space.
Class for cpu time benchmarking.
void stop()
Stop the timer.
void start()
Start the timer.
double getwct()
Return the elapsed real time.
Main class that encapsulate a vector properties operand to be used for expressions construction.
[v_transform metafunction]
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...