Skip to content

Commit 98223dc

Browse files
committed
Merge
2 parents 7f6d2c2 + 436d6a3 commit 98223dc

File tree

36 files changed

+5362
-95
lines changed

36 files changed

+5362
-95
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ README
5656
**/src/Makefile
5757
./Makefile
5858
Makefile.in
59-
Makefile
6059
config.status
6160
configure
6261
numerics
@@ -127,4 +126,4 @@ projectId.sh
127126

128127
**/.gitignore
129128
.gitignore
130-
/doxygen/
129+
/doxygen/

cmake_modules/FindPETSc.cmake

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
2323
#
2424

25-
cmake_policy(VERSION 3.3)
25+
cmake_policy(VERSION 3.5...3.27)
2626

2727
set(PETSC_VALID_COMPONENTS
2828
C
@@ -293,7 +293,16 @@ int main(int argc,char *argv[]) {
293293
find_path (PETSC_INCLUDE_CONF petscconf.h HINTS "${PETSC_DIR}" PATH_SUFFIXES "${PETSC_ARCH}/include" "bmake/${PETSC_ARCH}" NO_DEFAULT_PATH)
294294
mark_as_advanced (PETSC_INCLUDE_DIR PETSC_INCLUDE_CONF)
295295
set (petsc_includes_minimal ${PETSC_INCLUDE_CONF} ${PETSC_INCLUDE_DIR})
296+
find_package(MPI REQUIRED)
297+
if (MPI_FOUND)
298+
# 1) Make the “minimal” and “all” include‐paths see mpi.h:
299+
list(APPEND petsc_includes_minimal ${MPI_C_INCLUDE_DIRS})
300+
list(APPEND petsc_includes_all ${MPI_C_INCLUDE_DIRS})
296301

302+
# 2) Make the TS‐test and the “all”‐libraries test link libmpi:
303+
list(APPEND PETSC_LIBRARIES_TS ${MPI_C_LIBRARIES})
304+
list(APPEND PETSC_LIBRARIES_ALL ${MPI_C_LIBRARIES})
305+
endif()
297306
petsc_test_runs ("${petsc_includes_minimal}" "${PETSC_LIBRARIES_TS}" petsc_works_minimal)
298307
if (petsc_works_minimal)
299308
message (STATUS "Minimal PETSc includes and libraries work. This probably means we are building with shared libs.")

example/Numerics/2D_ActiveFluid/main.cpp

Lines changed: 69 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,16 @@ struct PolarEv
235235
*/
236236
//! @cond [ActiveObserver2Functor] @endcond
237237
// Functor to calculate velocity and move particles with explicit euler
238-
template<typename DX,typename DY,typename DXX,typename DXY,typename DYY>
238+
template<
239+
typename DX,
240+
typename DY,
241+
typename DX_BULK,
242+
typename DY_BULK,
243+
typename DXX,
244+
typename DXY,
245+
typename DYY,
246+
typename verletList_type,
247+
typename verletListBulk_type>
239248
struct CalcVelocity
240249
{
241250

@@ -244,12 +253,36 @@ struct CalcVelocity
244253
DXX &Dxx;
245254
DXY &Dxy;
246255
DYY &Dyy;
256+
verletList_type& verletList;
257+
verletListBulk_type& verletList_bulk;
247258

248259
double t_old;
260+
double rCut;
249261
int ctr;
250262

251263
//Constructor
252-
CalcVelocity(DX &Dx,DY &Dy,DXX &Dxx,DXY &Dxy,DYY &Dyy,DX &Bulk_Dx,DY &Bulk_Dy):Dx(Dx),Dy(Dy),Dxx(Dxx),Dxy(Dxy),Dyy(Dyy),Bulk_Dx(Bulk_Dx),Bulk_Dy(Bulk_Dy)
264+
CalcVelocity(
265+
DX &Dx,
266+
DY &Dy,
267+
DXX &Dxx,
268+
DXY &Dxy,
269+
DYY &Dyy,
270+
DX_BULK &Bulk_Dx,
271+
DY_BULK &Bulk_Dy,
272+
verletList_type& verletList,
273+
verletListBulk_type& verletList_bulk,
274+
double rCut
275+
):
276+
Dx(Dx),
277+
Dy(Dy),
278+
Dxx(Dxx),
279+
Dxy(Dxy),
280+
Dyy(Dyy),
281+
Bulk_Dx(Bulk_Dx),
282+
Bulk_Dy(Bulk_Dy),
283+
verletList(verletList),
284+
verletList_bulk(verletList_bulk),
285+
rCut(rCut)
253286
{
254287
t_old = 0.0;
255288
ctr = 0;
@@ -266,7 +299,7 @@ struct CalcVelocity
266299

267300
timer tt;
268301

269-
auto Pos = getV<PROP_POS>(Particles);
302+
auto Pos = getV<POS_PROP>(Particles);
270303
auto Pol=getV<POLARIZATION>(Particles);
271304
auto V = getV<VELOCITY>(Particles);
272305
auto H_p_b = getV<HPB>(Particles);
@@ -284,6 +317,8 @@ struct CalcVelocity
284317
Particles_bulk.update();
285318
Particles_boundary.update();
286319
tt.start();
320+
Particles.updateVerlet(verletList,rCut);
321+
Particles_bulk.updateVerlet(verletList_bulk,rCut);
287322
Dx.update(Particles);
288323
Dy.update(Particles);
289324
Dxy.update(Particles);
@@ -616,7 +651,7 @@ int main(int argc, char* argv[])
616651
Particles.map();
617652
Particles.ghost_get<POLARIZATION>();
618653

619-
//auto Pos = getV<PROP_POS>(Particles);
654+
//auto Pos = getV<POS_PROP>(Particles);
620655

621656
auto Pol = getV<POLARIZATION>(Particles);
622657
auto V = getV<VELOCITY>(Particles);
@@ -663,21 +698,44 @@ int main(int argc, char* argv[])
663698
auto RHS_bulk = getV<VRHS>(Particles_bulk);
664699
auto div_bulk = getV<DIV>(Particles_bulk);
665700

666-
Derivative_x Dx(Particles,ord,rCut), Bulk_Dx(Particles_bulk,ord,rCut);
667-
Derivative_y Dy(Particles, ord, rCut), Bulk_Dy(Particles_bulk, ord,rCut);
668-
Derivative_xy Dxy(Particles, ord, rCut);
701+
auto verletList = Particles.template getVerlet<VL_NON_SYMMETRIC|VL_SKIP_REF_PART>(rCut);
702+
auto verletList_bulk = Particles_bulk.template getVerlet<VL_NON_SYMMETRIC|VL_SKIP_REF_PART>(rCut);
703+
704+
Derivative_x<decltype(verletList)> Dx(Particles, verletList, ord,rCut);
705+
Derivative_y<decltype(verletList)> Dy(Particles, verletList, ord, rCut);
706+
Derivative_xy<decltype(verletList)> Dxy(Particles, verletList, ord, rCut);
707+
708+
Derivative_x<decltype(verletList_bulk)> Bulk_Dx(Particles, Particles_bulk, verletList_bulk, ord, rCut);
709+
Derivative_y<decltype(verletList_bulk)> Bulk_Dy(Particles, Particles_bulk, verletList_bulk, ord, rCut);
669710
auto Dyx = Dxy;
670-
Derivative_xx Dxx(Particles, ord, rCut);
671-
Derivative_yy Dyy(Particles, ord, rCut);
711+
Derivative_xx<decltype(verletList)> Dxx(Particles, verletList, ord, rCut);
712+
Derivative_yy<decltype(verletList)> Dyy(Particles, verletList, ord, rCut);
672713

673714
boost::numeric::odeint::runge_kutta4< state_type_2d_ofp,double,state_type_2d_ofp,double,boost::numeric::odeint::vector_space_algebra_ofp> rk4;
674715

675716
vectorGlobal=(void *) &Particles;
676717
vectorGlobal_bulk=(void *) &Particles_bulk;
677718
vectorGlobal_boundary=(void *) &Particles_boundary;
678719

679-
PolarEv<Derivative_x,Derivative_y,Derivative_xx,Derivative_xy,Derivative_yy> System(Dx,Dy,Dxx,Dxy,Dyy);
680-
CalcVelocity<Derivative_x,Derivative_y,Derivative_xx,Derivative_xy,Derivative_yy> CalcVelocityObserver(Dx,Dy,Dxx,Dxy,Dyy,Bulk_Dx,Bulk_Dy);
720+
PolarEv<
721+
Derivative_x<decltype(verletList)>,
722+
Derivative_y<decltype(verletList)>,
723+
Derivative_xx<decltype(verletList)>,
724+
Derivative_xy<decltype(verletList)>,
725+
Derivative_yy<decltype(verletList)>>
726+
System(Dx,Dy,Dxx,Dxy,Dyy);
727+
728+
CalcVelocity<
729+
Derivative_x<decltype(verletList)>,
730+
Derivative_y<decltype(verletList)>,
731+
Derivative_x<decltype(verletList_bulk)>,
732+
Derivative_y<decltype(verletList_bulk)>,
733+
Derivative_xx<decltype(verletList)>,
734+
Derivative_xy<decltype(verletList)>,
735+
Derivative_yy<decltype(verletList)>,
736+
decltype(verletList),
737+
decltype(verletList_bulk)>
738+
CalcVelocityObserver(Dx,Dy,Dxx,Dxy,Dyy,Bulk_Dx,Bulk_Dy,verletList,verletList_bulk,rCut);
681739

682740
state_type_2d_ofp tPol;
683741
tPol.data.get<0>()=Pol[x];

example/Numerics/OdeInt/Makefile renamed to example/Numerics/OdeInt/Advection-Diffusion/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
include ../../example.mk
2-
include ../../common.mk
1+
include ../../../example.mk
2+
include ../../../common.mk
3+
4+
35

46
OBJ = main.o
57
OBJ2 = main2.o
File renamed without changes.

example/Numerics/OdeInt/main.cpp renamed to example/Numerics/OdeInt/Advection-Diffusion/main.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,11 @@ int main(int argc, char* argv[]) {
293293
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
294294
//! @cond [DCPSE1Alias] @endcond
295295
//We create the DCPSE Based operators for discretization of the operators.
296-
Derivative_xx Dxx(Particles, 2, rCut);
297-
Derivative_yy Dyy(Particles, 2, rCut);
296+
auto verletList = Particles.template getVerlet<VL_NON_SYMMETRIC|VL_SKIP_REF_PART>(rCut);
297+
Derivative_xx<decltype(verletList)> Dxx(Particles, verletList, 2, rCut);
298+
Derivative_yy<decltype(verletList)> Dyy(Particles, verletList, 2, rCut);
298299
//We create aliases for referring to property and and positions.
299-
auto Pos = getV<PROP_POS>(Particles);
300+
auto Pos = getV<POS_PROP>(Particles);
300301
auto C = getV<0>(Particles);
301302
auto V = getV<1>(Particles);
302303
auto dC = getV<2>(Particles);
@@ -328,7 +329,7 @@ int main(int argc, char* argv[]) {
328329
boost::numeric::odeint::runge_kutta4<state_type_2d_ofp, double, state_type_2d_ofp, double, boost::numeric::odeint::vector_space_algebra_ofp> Odeint_rk4;
329330

330331
//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.
331-
RHSFunctor<Derivative_xx, Derivative_yy> System(Dxx, Dyy);
332+
RHSFunctor<Derivative_xx<decltype(verletList)>, Derivative_yy<decltype(verletList)>> System(Dxx, Dyy);
332333

333334
//Furhter, odeint needs data in a state type "state_type_2d_ofp", we create one and fill in the initial condition.
334335
state_type_2d_ofp X;
@@ -384,6 +385,7 @@ int main(int argc, char* argv[]) {
384385
//We update the subset and operators as the particles moved.
385386
Particles_bulk.update();
386387
Particles_boundary.update();
388+
Particles.updateVerlet(verletList,rCut);
387389
Dxx.update(Particles);
388390
Dyy.update(Particles);
389391
//Reinitialzing as distributed size can change.

example/Numerics/OdeInt/main2.cpp renamed to example/Numerics/OdeInt/Advection-Diffusion/main2.cpp

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
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
@@ -66,7 +66,7 @@
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>
187187
struct 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

Comments
 (0)