44#include "Operators/Vector/vector_dist_operators.hpp"
45#include "Vector/vector_dist_subset.hpp"
46#include "DCPSE/DCPSE_op/DCPSE_op.hpp"
47#include "OdeIntegrators/OdeIntegrators.hpp"
77double dt=1e-2,tf=1.0,vf=1.0;
79void *PointerDistGlobal, *PointerDistSubset,*PointerDistSubset2;
115template<
typename DXX,
typename DYY>
122 RHSFunctor(DXX &Dxx,DYY &Dyy):Dxx(Dxx),Dyy(Dyy)
132 auto C = getV<0>(Particles);
133 auto C_bulk = getV<0>(Particles_bulk);
134 auto dC = getV<2>(Particles);
135 auto dC_bulk = getV<2>(Particles_bulk);
142 C_bulk[x]=X.data.get<0>();
143 C_bulk[y]=X.data.get<1>();
147 dC_bulk[x] = 0.1*(Dxx(C[x])+Dyy(C[x]));
148 dC_bulk[y] = 0.1*(Dxx(C[y])+Dyy(C[y]));
151 dxdt.data.get<0>()=dC[x];
152 dxdt.data.get<1>()=dC[y];
186template<
typename DXX,
typename DYY>
209 auto Pos = getV<PROP_POS>(Particles);
210 auto Concentration = getV<0>(Particles);
211 auto Velocity = getV<1>(Particles);
212 auto Concentration_bulk = getV<0>(Particles_bulk);
213 auto Velocity_bulk = getV<1>(Particles_bulk);
218 Concentration_bulk[x] = X.data.get<0>();
219 Concentration_bulk[y] = X.data.get<1>();
221 Velocity_bulk[x] = -vf*Pos[y] * exp(-10.0 * (Pos[x] * Pos[x] + Pos[y] * Pos[y]));
222 Velocity_bulk[y] = vf*Pos[x] * exp(-10.0 * (Pos[x] * Pos[x] + Pos[y] * Pos[y]));
223 Pos = Pos + dt * Velocity;
229 Particles_boundary.
update();
230 Dxx.update(Particles);
231 Dyy.update(Particles);
234 X.data.get<0>() = Concentration[x];
235 X.data.get<1>() = Concentration[y];
240 std::cout<<
"Taking a step at t="<<t<<
" with dt="<<t-t_old<<std::endl;
244 Particles.write_frame(
"PDE_sol", ctr);
262int main(
int argc,
char *argv[])
265 openfpm_init(&argc, &argv);
267 dt=std::atof(argv[1]);
268 tf=std::atof(argv[2]);
269 vf=std::atof(argv[3]);
285 const size_t sz[2] = {41, 41};
287 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
289 spacing[0] = 2.0 / (sz[0] - 1);
290 spacing[1] = 2.0 / (sz[1] - 1);
291 double rCut = 3.1 * spacing[0];
295 Particles.setPropNames({
"Concentration",
"Velocity",
"TempConcentration"});
297 auto it = Particles.getGridIterator(sz);
298 while (it.isNext()) {
301 double x = -1.0 + key.get(0) * spacing[0];
302 Particles.getLastPos()[0] = x;
303 double y = -1.0 + key.get(1) * spacing[1];
304 Particles.getLastPos()[1] = y;
306 if (x != -1.0 && x != 1.0 && y != -1.0 && y != 1) {
307 Particles.getLastSubset(0);
309 Particles.getLastSubset(1);
312 if (x == 0.0 && y > -0.5 && y < 0) {
313 Particles.template getLastProp<0>()[0] = 1.0;
314 Particles.template getLastProp<0>()[1] = 0.0;
315 }
else if (x == 0.0 && y > 0 && y < 0.5) {
316 Particles.template getLastProp<0>()[0] = 0.0;
317 Particles.template getLastProp<0>()[1] = 1.0;
319 Particles.template getLastProp<0>()[0] = 0.0;
320 Particles.template getLastProp<0>()[1] = 0.0;
325 Particles.ghost_get<0>();
328 Particles.write(
"Init");
349 PointerDistGlobal = (
void *) &Particles;
350 PointerDistSubset = (
void *) &Particles_bulk;
351 PointerDistSubset2 = (
void *) &Particles_boundary;
366 Derivative_xx Dxx(Particles, 2, rCut);
367 Derivative_yy Dyy(Particles, 2, rCut);
369 auto Pos = getV<PROP_POS>(Particles);
370 auto C = getV<0>(Particles);
371 auto V = getV<1>(Particles);
372 auto dC = getV<2>(Particles);
375 auto C_bulk = getV<0>(Particles_bulk);
376 auto dC_bulk = getV<2>(Particles_bulk);
396 boost::numeric::odeint::runge_kutta4<state_type_2d_ofp, double, state_type_2d_ofp, double, boost::numeric::odeint::vector_space_algebra_ofp> Odeint_rk4;
408 X.data.get<x>() = C[0];
409 X.data.get<y>() = C[1];
433 std::vector<double> inter_times;
435 size_t steps = boost::numeric::odeint::integrate_const(Odeint_rk4,
System, X, 0.0, tf, dt, ObserveAndUpdate);
449 std::cout <<
"No. of Time steps taken: " << steps << std::endl;
451 C_bulk[x] = X.data.get<0>();
452 C_bulk[y] = X.data.get<1>();
454 Dxx.deallocate(Particles);
455 Dyy.deallocate(Particles);
This class represent an N-dimensional box.
This class implement the point shape in an N-dimensional space.
void update()
Update the subset indexes.
void ghost_get(size_t opt=WITH_POSITION)
It synchronize the properties and position of the ghost particles.
void map(size_t opt=NONE)
It move all the particles that does not belong to the local processor to the respective processor.
void deleteGhost()
Delete the particles on the ghost.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
A 2d Odeint and Openfpm compatible structure.