74 #include "Operators/Vector/vector_dist_operators.hpp"
75 #include "Vector/vector_dist_subset.hpp"
76 #include "DCPSE/DCPSE_op/DCPSE_op.hpp"
77 #include "OdeIntegrators/OdeIntegrators.hpp"
108 void *PointerDistGlobal, *PointerDistSubset;
144 template<
typename DXX,
typename DYY>
151 RHSFunctor(DXX &Dxx,DYY &Dyy):Dxx(Dxx),Dyy(Dyy)
161 auto C = getV<0>(Particles);
162 auto C_bulk = getV<0>(Particles_bulk);
163 auto dC = getV<2>(Particles);
164 auto dC_bulk = getV<2>(Particles_bulk);
171 C_bulk[x]=X.data.get<0>();
172 C_bulk[y]=X.data.get<1>();
176 dC_bulk[x] = 0.1*(Dxx(C[x])+Dyy(C[x]));
177 dC_bulk[y] = 0.1*(Dxx(C[y])+Dyy(C[y]));
180 dxdt.data.get<0>()=dC[x];
181 dxdt.data.get<1>()=dC[y];
200 int main(
int argc,
char* argv[]) {
202 openfpm_init(&argc, &argv);
218 const size_t sz[2] = {41, 41};
220 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
222 spacing[0] = 2.0 / (sz[0] - 1);
223 spacing[1] = 2.0 / (sz[1] - 1);
224 double rCut = 3.1 * spacing[0];
228 Particles.setPropNames({
"Concentration",
"Velocity",
"TempConcentration"});
230 auto it = Particles.getGridIterator(sz);
231 while (it.isNext()) {
234 double x = -1.0 + key.get(0) * spacing[0];
235 Particles.getLastPos()[0] = x;
236 double y = -1.0 + key.get(1) * spacing[1];
237 Particles.getLastPos()[1] = y;
239 if (x != -1.0 && x != 1.0 && y != -1.0 && y != 1) {
240 Particles.getLastSubset(0);
242 Particles.getLastSubset(1);
245 if (x == 0.0 && y > -0.5 && y < 0) {
246 Particles.template getLastProp<0>()[0] = 1.0;
247 Particles.template getLastProp<0>()[1] = 0.0;
248 }
else if (x == 0.0 && y > 0 && y < 0.5) {
249 Particles.template getLastProp<0>()[0] = 0.0;
250 Particles.template getLastProp<0>()[1] = 1.0;
252 Particles.template getLastProp<0>()[0] = 0.0;
253 Particles.template getLastProp<0>()[1] = 0.0;
258 Particles.ghost_get<0>();
261 Particles.write(
"Init");
282 PointerDistGlobal = (
void *) &Particles;
283 PointerDistSubset = (
void *) &Particles_bulk;
300 auto verletList = Particles.template getVerlet<VL_NON_SYMMETRIC|VL_SKIP_REF_PART>(rCut);
301 Derivative_xx<decltype(verletList)> Dxx(Particles, verletList, 2, rCut);
302 Derivative_yy<decltype(verletList)> Dyy(Particles, verletList, 2, rCut);
304 auto Pos = getV<POS_PROP>(Particles);
305 auto C = getV<0>(Particles);
306 auto V = getV<1>(Particles);
307 auto dC = getV<2>(Particles);
310 auto C_bulk = getV<0>(Particles_bulk);
311 auto V_bulk = getV<1>(Particles_bulk);
312 auto dC_bulk = getV<2>(Particles_bulk);
333 boost::numeric::odeint::runge_kutta4<state_type_2d_ofp, double, state_type_2d_ofp, double, boost::numeric::odeint::vector_space_algebra_ofp> Odeint_rk4;
336 RHSFunctor<Derivative_xx<decltype(verletList)>, Derivative_yy<decltype(verletList)>> System(Dxx, Dyy);
341 X.data.get<x>() = C[x];
342 X.data.get<y>() = C[y];
370 double t = 0, tf = 1, dt = 1e-2;
373 V_bulk[x] = -Pos[y] * exp(-10.0 * (Pos[x] * Pos[x] + Pos[y] * Pos[y]));
374 V_bulk[y] = Pos[x] * exp(-10.0 * (Pos[x] * Pos[x] + Pos[y] * Pos[y]));
376 Particles.deleteGhost();
377 Particles.write_frame(
"PDE_Sol", ctr);
378 Particles.ghost_get<0>();
380 Odeint_rk4.do_step(System, X, t, dt);
382 C_bulk[x] = X.data.get<0>();
383 C_bulk[y] = X.data.get<1>();
388 Particles.ghost_get<0>();
390 Particles_bulk.update();
391 Particles_boundary.update();
392 Particles.updateVerlet(verletList,rCut);
393 Dxx.update(Particles);
394 Dyy.update(Particles);
396 X.data.get<0>()=C[x];
397 X.data.get<1>()=C[y];
403 Dxx.deallocate(Particles);
404 Dyy.deallocate(Particles);
This class represent an N-dimensional box.
This class implement the point shape in an N-dimensional space.
void ghost_get(size_t opt=WITH_POSITION)
It synchronize the properties and position of the ghost particles.
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.