3535 *
3636 * These are the header files that we need to include:
3737 *
38- * @snippet example/Numerics/Odeint/main2.cpp Ode2Include
38+ * @snippet example/Numerics/Odeint/Advection-Diffusion/ main2.cpp Ode2Include
3939 *
4040 */
4141// ! @cond [Ode2Include] @endcond
6666 *
6767 * dist_vector_type as the 2d openfpm distributed subset vector type
6868 *
69- * @snippet example/Numerics/Odeint/main2.cpp Initialization__two
69+ * @snippet example/Numerics/Odeint/Advection-Diffusion/ main2.cpp Initialization__two
7070 *
7171 */
7272// ! @cond [Initialization__two] @endcond
@@ -108,7 +108,7 @@ typedef vector_dist_subset<2, double, Property_type> dist_vector_subset_type;
108108 *
109109 * )
110110 *
111- * @snippet example/Numerics/Odeint/main2.cpp RHS2Functor
111+ * @snippet example/Numerics/Odeint/Advection-Diffusion/ main2.cpp RHS2Functor
112112 *
113113 */
114114// ! @cond [RHS2Functor] @endcond
@@ -179,20 +179,22 @@ struct RHSFunctor
179179 * We do our computations as required.
180180 * Then we copy back the output into the state_type dxdt.
181181 *
182- * @snippet example/Numerics/Odeint/main2.cpp Observer2Functor
182+ * @snippet example/Numerics/Odeint/Advection-Diffusion/ main2.cpp Observer2Functor
183183 *
184184 */
185185// ! @cond [Observer2Functor] @endcond
186- template <typename DXX,typename DYY>
186+ template <typename DXX, typename DYY, typename VerletList_type >
187187struct ObserverFunctor {
188188
189189 DXX &Dxx;
190190 DYY &Dyy;
191+ VerletList_type &verletList;
191192 int ctr;
192193 double t_old;
194+ double rCut;
193195
194196 // Constructor
195- ObserverFunctor (DXX &Dxx, DYY &Dyy) : Dxx(Dxx), Dyy(Dyy) {
197+ ObserverFunctor (DXX &Dxx, DYY &Dyy, VerletList_type& verletList, double rCut ) : Dxx(Dxx), Dyy(Dyy), verletList(verletList), rCut(rCut ) {
196198 // a counter for counting the np. of steps
197199 ctr = 0 ;
198200 // Starting with t=0, we compute the step size take by t-t_old. So for the first observed step size is what we provide. Which will be 0-(-dt)=dt.
@@ -206,7 +208,7 @@ struct ObserverFunctor {
206208 dist_vector_subset_type &Particles_boundary = *(dist_vector_subset_type *) PointerDistSubset2;
207209
208210 // Aliasing the position and properties.
209- auto Pos = getV<PROP_POS >(Particles);
211+ auto Pos = getV<POS_PROP >(Particles);
210212 auto Concentration = getV<0 >(Particles);
211213 auto Velocity = getV<1 >(Particles);
212214 auto Concentration_bulk = getV<0 >(Particles_bulk);
@@ -227,6 +229,7 @@ struct ObserverFunctor {
227229 // Updating the subset and operators based on new positions
228230 Particles_bulk.update ();
229231 Particles_boundary.update ();
232+ Particles.updateVerlet (verletList,rCut);
230233 Dxx.update (Particles);
231234 Dyy.update (Particles);
232235
@@ -255,7 +258,7 @@ struct ObserverFunctor {
255258 * We start with
256259 * * Initializing OpenFPM
257260 *
258- * @snippet example/Numerics/Odeint/main2.cpp initParticles2
261+ * @snippet example/Numerics/Odeint/Advection-Diffusion/ main2.cpp initParticles2
259262 *
260263 */
261264// ! @cond [initParticles2] @endcond
@@ -278,7 +281,7 @@ int main(int argc, char *argv[])
278281 *
279282 * Also, we fill the initial concentration as C_1(x=0,y>0 & y<0.5,t=0)=1,C_2(x=0,y<0 & y>-0.5,t=0)=1 and 0 everywhere else.
280283 *
281- * @snippet example/Numerics/Odeint/main2.cpp init2Subset
284+ * @snippet example/Numerics/Odeint/Advection-Diffusion/ main2.cpp init2Subset
282285 *
283286 */
284287 // ! @cond [init2Subset] @endcond
@@ -337,7 +340,7 @@ int main(int argc, char *argv[])
337340 * Further, We cast the Global Pointers so that Odeint RHS functor can recognize our openfpm distributed structure.
338341 *
339342 *
340- * @snippet example/Numerics/Odeint/main2.cpp Pointer2Init
343+ * @snippet example/Numerics/Odeint/Advection-Diffusion/ main2.cpp Pointer2Init
341344 */
342345 // ! @cond [Pointer2Init] @endcond
343346 // Now we initialize the grid with a filled circle. Outside the circle, the value of Phi_0 will be -1, inside +1.
@@ -358,15 +361,17 @@ int main(int argc, char *argv[])
358361 *
359362 * Here we create two dcpse based operators and alias the particle properties.
360363 *
361- * @snippet example/Numerics/Odeint/main2.cpp DCPSE2Alias
364+ * @snippet example/Numerics/Odeint/Advection-Diffusion/ main2.cpp DCPSE2Alias
362365 *
363366 */
364367 // ! @cond [DCPSE2Alias] @endcond
365368 // We create the DCPSE Based operators for discretization of the operators.
366- Derivative_xx Dxx (Particles, 2 , rCut);
367- Derivative_yy Dyy (Particles, 2 , rCut);
369+ auto verletList = Particles.template getVerlet <VL_NON_SYMMETRIC|VL_SKIP_REF_PART>(rCut);
370+
371+ Derivative_xx<decltype (verletList)> Dxx (Particles, verletList, 2 , rCut);
372+ Derivative_yy<decltype (verletList)> Dyy (Particles, verletList, 2 , rCut);
368373 // We create aliases for referring to property and and positions.
369- auto Pos = getV<PROP_POS >(Particles);
374+ auto Pos = getV<POS_PROP >(Particles);
370375 auto C = getV<0 >(Particles);
371376 auto V = getV<1 >(Particles);
372377 auto dC = getV<2 >(Particles);
@@ -387,7 +392,7 @@ int main(int argc, char *argv[])
387392 *
388393 * Also, we create the state type compatible with odeint and initialize the concentration in it.
389394 *
390- * @snippet example/Numerics/Odeint/main2.cpp Odeint2I
395+ * @snippet example/Numerics/Odeint/Advection-Diffusion/ main2.cpp Odeint2I
391396 *
392397 */
393398 // ! @cond [Odeint2I] @endcond
@@ -396,10 +401,10 @@ int main(int argc, char *argv[])
396401 boost::numeric::odeint::runge_kutta4<state_type_2d_ofp, double , state_type_2d_ofp, double , boost::numeric::odeint::vector_space_algebra_ofp> Odeint_rk4;
397402
398403 // The method Odeint_rk4 from Odeint, requires system (a function which computes RHS of the PDE), an instance of the Compute RHS functor. We create the System with the correct types and parameteres for the operators as declared before.
399- RHSFunctor<Derivative_xx, Derivative_yy> System (Dxx, Dyy);
404+ RHSFunctor<Derivative_xx< decltype (verletList)> , Derivative_yy< decltype (verletList)> > System (Dxx, Dyy);
400405
401406 // Since we are using Odeint to control the time steps, we also create a observer instance. Which also updates the position via an euler step for moving thr particles.
402- ObserverFunctor<Derivative_xx, Derivative_yy> ObserveAndUpdate (Dxx, Dyy);
407+ ObserverFunctor<Derivative_xx< decltype (verletList)> , Derivative_yy< decltype (verletList)>, decltype (verletList)> ObserveAndUpdate (Dxx, Dyy, verletList, rCut );
403408
404409
405410 // Furhter, odeint needs data in a state type "state_type_2d_ofp", we create one and fill in the initial condition.
@@ -425,7 +430,7 @@ int main(int argc, char *argv[])
425430 *
426431 * We finally deallocate the DCPSE operators and finalize the library.
427432 *
428- * @snippet example/Numerics/Odeint/main2.cpp OdeintTCall
433+ * @snippet example/Numerics/Odeint/Advection-Diffusion/ main2.cpp OdeintTCall
429434 *
430435 */
431436 // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -462,5 +467,5 @@ int main(int argc, char *argv[])
462467 *
463468 * ## Full code ## {#odeint_c2_full}
464469 *
465- * @include example/Numerics/Odeint/main2.cpp
470+ * @include example/Numerics/Odeint/Advection-Diffusion/ main2.cpp
466471 */
0 commit comments