├── tests ├── body │ ├── body2d.txt │ ├── body3d.txt │ └── CMakeLists.txt ├── misc │ ├── CMakeLists.txt │ └── delta_test.cpp ├── boundary │ └── CMakeLists.txt ├── operators │ └── CMakeLists.txt ├── CMakeLists.txt └── mesh │ ├── CMakeLists.txt │ └── main.cpp ├── examples ├── decoupledibpm │ ├── flatplate3dRe100_GPU │ │ ├── .gitignore │ │ ├── config │ │ │ ├── forces_solver.info │ │ │ ├── velocity_solver.info │ │ │ └── poisson_solver.info │ │ ├── README.md │ │ ├── AoA0 │ │ │ ├── scripts │ │ │ │ └── createBody.py │ │ │ └── config.yaml │ │ ├── AoA10 │ │ │ ├── scripts │ │ │ │ └── createBody.py │ │ │ └── config.yaml │ │ ├── AoA20 │ │ │ ├── scripts │ │ │ │ └── createBody.py │ │ │ └── config.yaml │ │ ├── AoA30 │ │ │ └── scripts │ │ │ │ └── createBody.py │ │ ├── AoA40 │ │ │ └── scripts │ │ │ │ └── createBody.py │ │ ├── AoA50 │ │ │ └── scripts │ │ │ │ └── createBody.py │ │ ├── AoA60 │ │ │ └── scripts │ │ │ │ └── createBody.py │ │ ├── AoA70 │ │ │ └── scripts │ │ │ │ └── createBody.py │ │ ├── AoA80 │ │ │ └── scripts │ │ │ │ └── createBody.py │ │ └── AoA90 │ │ │ └── scripts │ │ │ └── createBody.py │ ├── cylinder2dRe100_GPU │ │ ├── config │ │ │ ├── forces_solver.info │ │ │ ├── velocity_solver.info │ │ │ └── poisson_solver.info │ │ ├── scripts │ │ │ ├── createBody.py │ │ │ └── plotForceCoefficients.py │ │ ├── README.md │ │ └── config.yaml │ ├── cylinder2dRe3000_GPU │ │ ├── config │ │ │ ├── forces_solver.info │ │ │ ├── velocity_solver.info │ │ │ └── poisson_solver.info │ │ ├── scripts │ │ │ ├── createBody.py │ │ │ └── plotVorticity.py │ │ ├── README.md │ │ └── config.yaml │ ├── cylinder2dRe40_GPU │ │ ├── config │ │ │ ├── forces_solver.info │ │ │ ├── velocity_solver.info │ │ │ └── poisson_solver.info │ │ ├── scripts │ │ │ ├── createBody.py │ │ │ └── plotVorticity.py │ │ ├── README.md │ │ └── config.yaml │ ├── cylinder2dRe550_GPU │ │ ├── config │ │ │ ├── forces_solver.info │ │ │ ├── velocity_solver.info │ │ │ └── poisson_solver.info │ │ ├── scripts │ │ │ ├── createBody.py │ │ │ └── plotVorticity.py │ │ ├── README.md │ │ └── config.yaml │ ├── flatplate3dRe100AoA30_GPU │ │ ├── config │ │ │ ├── forces_solver.info │ │ │ ├── velocity_solver.info │ │ │ └── poisson_solver.info │ │ ├── README.md │ │ ├── scripts │ │ │ ├── createBody.py │ │ │ └── plotForceCoefficients.py │ │ └── config.yaml │ └── multicylinders2dRe100_GPU │ │ ├── config │ │ ├── forces_solver.info │ │ ├── velocity_solver.info │ │ └── poisson_solver.info │ │ ├── config.yaml │ │ ├── README.md │ │ └── scripts │ │ └── createBodies.py ├── navierstokes │ ├── taylorgreenvortex2dRe100 │ │ ├── kinetic-energy.png │ │ ├── absoluteerror-t50.0-u.png │ │ ├── simulationresult-t50.0-u.png │ │ ├── config │ │ │ ├── velocity_solver.info │ │ │ └── poisson_solver.info │ │ ├── README.md │ │ └── config.yaml │ ├── taylorgreenvortex3dRe1600_GPU │ │ ├── vorticity-x-neg-pi.png │ │ ├── mean-kinetic-energy.png │ │ ├── mean-kinetic-energy-dissipation-rate.png │ │ ├── config │ │ │ ├── velocity_solver.info │ │ │ └── poisson_solver.info │ │ └── config.yaml │ ├── liddrivencavity2dRe100 │ │ ├── config │ │ │ ├── velocity_solver.info │ │ │ └── poisson_solver.info │ │ ├── README.md │ │ └── config.yaml │ ├── liddrivencavity2dRe1000 │ │ ├── config │ │ │ ├── velocity_solver.info │ │ │ └── poisson_solver.info │ │ ├── README.md │ │ └── config.yaml │ ├── liddrivencavity2dRe1000_GPU │ │ ├── config │ │ │ ├── velocity_solver.info │ │ │ └── poisson_solver.info │ │ ├── README.md │ │ └── config.yaml │ ├── liddrivencavity2dRe3200 │ │ ├── config │ │ │ ├── velocity_solver.info │ │ │ └── poisson_solver.info │ │ ├── README.md │ │ └── config.yaml │ ├── liddrivencavity2dRe5000 │ │ ├── config │ │ │ ├── velocity_solver.info │ │ │ └── poisson_solver.info │ │ ├── README.md │ │ └── config.yaml │ └── convergence │ │ ├── liddrivencavity2dRe100_20 │ │ ├── 20 │ │ │ └── config.yaml │ │ ├── 60 │ │ │ └── config.yaml │ │ ├── 180 │ │ │ └── config.yaml │ │ ├── 540 │ │ │ └── config.yaml │ │ ├── configs │ │ │ └── solversPetscOptions.info │ │ └── README.md │ │ └── liddrivencavity2dRe100_30 │ │ ├── 30 │ │ └── config.yaml │ │ ├── 90 │ │ └── config.yaml │ │ ├── 270 │ │ └── config.yaml │ │ ├── 810 │ │ └── config.yaml │ │ ├── configs │ │ └── solversPetscOptions.info │ │ └── README.md ├── api_examples │ ├── oscillatingcylinder2dRe100_GPU │ │ ├── config │ │ │ ├── forces_solver.info │ │ │ ├── velocity_solver.info │ │ │ └── poisson_solver.info │ │ ├── scripts │ │ │ └── createBody.py │ │ ├── config.yaml │ │ ├── CMakeLists.txt │ │ └── main.cpp │ ├── liddrivencavity2d │ │ ├── config │ │ │ ├── velocity_solver.info │ │ │ └── poisson_solver.info │ │ ├── config.yaml │ │ └── CMakeLists.txt │ └── README.md ├── .gitignore ├── ibpm │ ├── cylinder2dRe40 │ │ ├── config │ │ │ ├── velocity_solver.info │ │ │ └── poisson_solver.info │ │ ├── scripts │ │ │ ├── createBody.py │ │ │ └── plotVorticity.py │ │ ├── README.md │ │ └── config.yaml │ ├── cylinder2dRe550 │ │ ├── config │ │ │ ├── velocity_solver.info │ │ │ └── poisson_solver.info │ │ ├── scripts │ │ │ ├── createBody.py │ │ │ └── plotVorticity.py │ │ ├── README.md │ │ └── config.yaml │ ├── cylinder2dRe100_GPU │ │ ├── config │ │ │ ├── velocity_solver.info │ │ │ └── poisson_solver.info │ │ ├── scripts │ │ │ ├── createBody.py │ │ │ └── plotForceCoefficients.py │ │ ├── README.md │ │ └── config.yaml │ ├── cylinder2dRe3000 │ │ ├── config │ │ │ ├── velocity_solver.info │ │ │ └── poisson_solver.info │ │ ├── scripts │ │ │ ├── createBody.py │ │ │ └── plotVorticity.py │ │ ├── README.md │ │ └── config.yaml │ ├── cylinder2dRe3000_GPU │ │ ├── config │ │ │ ├── velocity_solver.info │ │ │ └── poisson_solver.info │ │ ├── scripts │ │ │ ├── createBody.py │ │ │ └── plotVorticity.py │ │ ├── README.md │ │ └── config.yaml │ └── cylinder2dRe550_GPU │ │ ├── config │ │ ├── velocity_solver.info │ │ └── poisson_solver.info │ │ ├── scripts │ │ ├── createBody.py │ │ └── plotVorticity.py │ │ ├── README.md │ │ └── config.yaml └── data │ ├── koumoutsakos_leonard_1995_cylinder_dragCoefficientRe40.dat │ ├── koumoutsakos_leonard_1995_cylinder_dragCoefficientRe550.dat │ ├── koumoutsakos_leonard_1995_cylinder_dragCoefficientRe3000.dat │ ├── taira_et_al_2007_flatPlateRe100AR2_CdvsAoA.dat │ ├── taira_et_al_2007_flatPlateRe100AR2_ClvsAoA.dat │ └── ghia_et_al_1982_lid_driven_cavity.dat ├── doc └── markdowns │ └── images │ ├── cylinder2dRe40_vorticity.png │ ├── cylinder2dRe550_GPU_vorticity.png │ ├── cylinder2dRe40_dragcoefficient.png │ ├── flatplate3dRe100_forceCoefficients.png │ ├── cylinder2dRe550_GPU_dragcoefficient.png │ └── liddrivencavity2dRe100_velocitycenterlines.png ├── .gitignore ├── applications ├── vorticity │ └── CMakeLists.txt ├── writemesh │ ├── CMakeLists.txt │ └── main.cpp ├── ibpm │ └── CMakeLists.txt ├── createxdmf │ └── CMakeLists.txt ├── navierstokes │ └── CMakeLists.txt ├── decoupledibpm │ └── CMakeLists.txt └── CMakeLists.txt ├── src ├── private │ └── private.h ├── boundary │ ├── boundary.cpp │ ├── singleboundaryneumann.cpp │ ├── singleboundarydirichlet.cpp │ └── singleboundaryperiodic.cpp └── solution │ └── solution.cpp ├── petibm-config.cmake.in ├── LICENSE ├── .github └── workflows │ └── build.yaml ├── include └── petibm │ ├── boundarysimple.h │ ├── linsolveramgx.h │ ├── singleboundaryneumann.h │ ├── singleboundarydirichlet.h │ ├── singleboundaryperiodic.h │ ├── linsolverksp.h │ └── solutionsimple.h ├── codemeta.json └── CONTRIBUTING.md /tests/body/body2d.txt: -------------------------------------------------------------------------------- 1 | 4 2 | 0.25 0.25 3 | 0.75 0.25 4 | 0.75 0.75 5 | 0.25 0.75 6 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100_GPU/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore body files 2 | *.body 3 | -------------------------------------------------------------------------------- /doc/markdowns/images/cylinder2dRe40_vorticity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/barbagroup/PetIBM/master/doc/markdowns/images/cylinder2dRe40_vorticity.png -------------------------------------------------------------------------------- /doc/markdowns/images/cylinder2dRe550_GPU_vorticity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/barbagroup/PetIBM/master/doc/markdowns/images/cylinder2dRe550_GPU_vorticity.png -------------------------------------------------------------------------------- /doc/markdowns/images/cylinder2dRe40_dragcoefficient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/barbagroup/PetIBM/master/doc/markdowns/images/cylinder2dRe40_dragcoefficient.png -------------------------------------------------------------------------------- /doc/markdowns/images/flatplate3dRe100_forceCoefficients.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/barbagroup/PetIBM/master/doc/markdowns/images/flatplate3dRe100_forceCoefficients.png -------------------------------------------------------------------------------- /doc/markdowns/images/cylinder2dRe550_GPU_dragcoefficient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/barbagroup/PetIBM/master/doc/markdowns/images/cylinder2dRe550_GPU_dragcoefficient.png -------------------------------------------------------------------------------- /examples/navierstokes/taylorgreenvortex2dRe100/kinetic-energy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/barbagroup/PetIBM/master/examples/navierstokes/taylorgreenvortex2dRe100/kinetic-energy.png -------------------------------------------------------------------------------- /doc/markdowns/images/liddrivencavity2dRe100_velocitycenterlines.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/barbagroup/PetIBM/master/doc/markdowns/images/liddrivencavity2dRe100_velocitycenterlines.png -------------------------------------------------------------------------------- /tests/body/body3d.txt: -------------------------------------------------------------------------------- 1 | 8 2 | 0.25 0.25 0.25 3 | 0.75 0.25 0.25 4 | 0.75 0.75 0.25 5 | 0.25 0.75 0.25 6 | 0.25 0.25 0.75 7 | 0.75 0.25 0.75 8 | 0.75 0.75 0.75 9 | 0.25 0.75 0.75 10 | -------------------------------------------------------------------------------- /examples/navierstokes/taylorgreenvortex2dRe100/absoluteerror-t50.0-u.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/barbagroup/PetIBM/master/examples/navierstokes/taylorgreenvortex2dRe100/absoluteerror-t50.0-u.png -------------------------------------------------------------------------------- /examples/navierstokes/taylorgreenvortex3dRe1600_GPU/vorticity-x-neg-pi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/barbagroup/PetIBM/master/examples/navierstokes/taylorgreenvortex3dRe1600_GPU/vorticity-x-neg-pi.png -------------------------------------------------------------------------------- /examples/navierstokes/taylorgreenvortex2dRe100/simulationresult-t50.0-u.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/barbagroup/PetIBM/master/examples/navierstokes/taylorgreenvortex2dRe100/simulationresult-t50.0-u.png -------------------------------------------------------------------------------- /examples/navierstokes/taylorgreenvortex3dRe1600_GPU/mean-kinetic-energy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/barbagroup/PetIBM/master/examples/navierstokes/taylorgreenvortex3dRe1600_GPU/mean-kinetic-energy.png -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe100_GPU/config/forces_solver.info: -------------------------------------------------------------------------------- 1 | # forces solver: prefix `-forces_` 2 | -forces_ksp_type preonly 3 | -forces_pc_type lu 4 | -forces_pc_factor_mat_solver_type superlu_dist 5 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe3000_GPU/config/forces_solver.info: -------------------------------------------------------------------------------- 1 | # forces solver: prefix `-forces_` 2 | -forces_ksp_type preonly 3 | -forces_pc_type lu 4 | -forces_pc_factor_mat_solver_type superlu_dist 5 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe40_GPU/config/forces_solver.info: -------------------------------------------------------------------------------- 1 | # forces solver: prefix `-forces_` 2 | -forces_ksp_type preonly 3 | -forces_pc_type lu 4 | -forces_pc_factor_mat_solver_type superlu_dist 5 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe550_GPU/config/forces_solver.info: -------------------------------------------------------------------------------- 1 | # forces solver: prefix `-forces_` 2 | -forces_ksp_type preonly 3 | -forces_pc_type lu 4 | -forces_pc_factor_mat_solver_type superlu_dist 5 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100_GPU/config/forces_solver.info: -------------------------------------------------------------------------------- 1 | # forces solver: prefix `-forces_` 2 | -forces_ksp_type preonly 3 | -forces_pc_type lu 4 | -forces_pc_factor_mat_solver_type superlu_dist 5 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100AoA30_GPU/config/forces_solver.info: -------------------------------------------------------------------------------- 1 | # forces solver: prefix `-forces_` 2 | -forces_ksp_type preonly 3 | -forces_pc_type lu 4 | -forces_pc_factor_mat_solver_type superlu_dist 5 | -------------------------------------------------------------------------------- /examples/decoupledibpm/multicylinders2dRe100_GPU/config/forces_solver.info: -------------------------------------------------------------------------------- 1 | # forces solver: prefix `-forces_` 2 | -forces_ksp_type preonly 3 | -forces_pc_type lu 4 | -forces_pc_factor_mat_solver_type superlu_dist 5 | -------------------------------------------------------------------------------- /examples/api_examples/oscillatingcylinder2dRe100_GPU/config/forces_solver.info: -------------------------------------------------------------------------------- 1 | # forces solver: prefix `-forces_` 2 | -forces_ksp_type preonly 3 | -forces_pc_type lu 4 | -forces_pc_factor_mat_solver_type superlu_dist 5 | -------------------------------------------------------------------------------- /examples/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore the numerical solution and post-process data 2 | solution 3 | *.h5 4 | iterations.txt 5 | forces.txt 6 | figures 7 | *.out 8 | *.xmf 9 | *.curve 10 | .logamgx 11 | *.log 12 | view.log 13 | **/output 14 | -------------------------------------------------------------------------------- /examples/navierstokes/taylorgreenvortex3dRe1600_GPU/mean-kinetic-energy-dissipation-rate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/barbagroup/PetIBM/master/examples/navierstokes/taylorgreenvortex3dRe1600_GPU/mean-kinetic-energy-dissipation-rate.png -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe40/config/velocity_solver.info: -------------------------------------------------------------------------------- 1 | # velocity solver: prefix `-velocity_` 2 | -velocity_ksp_type bcgs 3 | -velocity_ksp_atol 1.0E-06 4 | -velocity_ksp_rtol 0.0 5 | -velocity_ksp_max_it 1000 6 | -velocity_pc_type jacobi 7 | -velocity_pc_jacobi_type diagonal 8 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe550/config/velocity_solver.info: -------------------------------------------------------------------------------- 1 | # velocity solver: prefix `-velocity_` 2 | -velocity_ksp_type bcgs 3 | -velocity_ksp_atol 1.0E-06 4 | -velocity_ksp_rtol 0.0 5 | -velocity_ksp_max_it 1000 6 | -velocity_pc_type jacobi 7 | -velocity_pc_jacobi_type diagonal 8 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe100_GPU/config/velocity_solver.info: -------------------------------------------------------------------------------- 1 | # velocity solver: prefix `-velocity_` 2 | -velocity_ksp_type bcgs 3 | -velocity_ksp_atol 1.0E-06 4 | -velocity_ksp_rtol 0.0 5 | -velocity_ksp_max_it 1000 6 | -velocity_pc_type jacobi 7 | -velocity_pc_jacobi_type diagonal 8 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe3000/config/velocity_solver.info: -------------------------------------------------------------------------------- 1 | # velocity solver: prefix `-velocity_` 2 | -velocity_ksp_type bcgs 3 | -velocity_ksp_atol 1.0E-06 4 | -velocity_ksp_rtol 0.0 5 | -velocity_ksp_max_it 1000 6 | -velocity_pc_type jacobi 7 | -velocity_pc_jacobi_type diagonal 8 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe3000_GPU/config/velocity_solver.info: -------------------------------------------------------------------------------- 1 | # velocity solver: prefix `-velocity_` 2 | -velocity_ksp_type bcgs 3 | -velocity_ksp_atol 1.0E-06 4 | -velocity_ksp_rtol 0.0 5 | -velocity_ksp_max_it 1000 6 | -velocity_pc_type jacobi 7 | -velocity_pc_jacobi_type diagonal 8 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe550_GPU/config/velocity_solver.info: -------------------------------------------------------------------------------- 1 | # velocity solver: prefix `-velocity_` 2 | -velocity_ksp_type bcgs 3 | -velocity_ksp_atol 1.0E-06 4 | -velocity_ksp_rtol 0.0 5 | -velocity_ksp_max_it 1000 6 | -velocity_pc_type jacobi 7 | -velocity_pc_jacobi_type diagonal 8 | -------------------------------------------------------------------------------- /examples/api_examples/liddrivencavity2d/config/velocity_solver.info: -------------------------------------------------------------------------------- 1 | # Velocity solver: prefix `-velocity_` 2 | -velocity_ksp_type bcgs 3 | -velocity_ksp_atol 1.0E-06 4 | -velocity_ksp_rtol 0.0 5 | -velocity_ksp_max_it 1000 6 | -velocity_pc_type jacobi 7 | -velocity_pc_jacobi_type diagonal 8 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe100_GPU/config/velocity_solver.info: -------------------------------------------------------------------------------- 1 | # velocity solver: prefix `-velocity_` 2 | -velocity_ksp_type bcgs 3 | -velocity_ksp_atol 1.0E-06 4 | -velocity_ksp_rtol 0.0 5 | -velocity_ksp_max_it 1000 6 | -velocity_pc_type jacobi 7 | -velocity_pc_jacobi_type diagonal 8 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe3000_GPU/config/velocity_solver.info: -------------------------------------------------------------------------------- 1 | # velocity solver: prefix `-velocity_` 2 | -velocity_ksp_type bcgs 3 | -velocity_ksp_atol 1.0E-06 4 | -velocity_ksp_rtol 0.0 5 | -velocity_ksp_max_it 1000 6 | -velocity_pc_type jacobi 7 | -velocity_pc_jacobi_type diagonal 8 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe40_GPU/config/velocity_solver.info: -------------------------------------------------------------------------------- 1 | # velocity solver: prefix `-velocity_` 2 | -velocity_ksp_type bcgs 3 | -velocity_ksp_atol 1.0E-06 4 | -velocity_ksp_rtol 0.0 5 | -velocity_ksp_max_it 1000 6 | -velocity_pc_type jacobi 7 | -velocity_pc_jacobi_type diagonal 8 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe550_GPU/config/velocity_solver.info: -------------------------------------------------------------------------------- 1 | # velocity solver: prefix `-velocity_` 2 | -velocity_ksp_type bcgs 3 | -velocity_ksp_atol 1.0E-06 4 | -velocity_ksp_rtol 0.0 5 | -velocity_ksp_max_it 1000 6 | -velocity_pc_type jacobi 7 | -velocity_pc_jacobi_type diagonal 8 | -------------------------------------------------------------------------------- /examples/navierstokes/liddrivencavity2dRe100/config/velocity_solver.info: -------------------------------------------------------------------------------- 1 | # velocity solver: prefix `-velocity_` 2 | -velocity_ksp_type bcgs 3 | -velocity_ksp_atol 1.0E-06 4 | -velocity_ksp_rtol 0.0 5 | -velocity_ksp_max_it 1000 6 | -velocity_pc_type jacobi 7 | -velocity_pc_jacobi_type diagonal 8 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100AoA30_GPU/config/velocity_solver.info: -------------------------------------------------------------------------------- 1 | # velocity solver: prefix `-velocity_` 2 | -velocity_ksp_type bcgs 3 | -velocity_ksp_atol 1.0E-06 4 | -velocity_ksp_rtol 0.0 5 | -velocity_ksp_max_it 1000 6 | -velocity_pc_type jacobi 7 | -velocity_pc_jacobi_type diagonal 8 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe3000/config/poisson_solver.info: -------------------------------------------------------------------------------- 1 | # Poisson solver: prefix `-poisson_` 2 | -poisson_ksp_type cg 3 | -poisson_ksp_atol 1.0E-06 4 | -poisson_ksp_rtol 0.0 5 | -poisson_ksp_max_it 20000 6 | -poisson_pc_type gamg 7 | -poisson_pc_gamg_type agg 8 | -poisson_pc_gamg_agg_nsmooths 1 9 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe40/config/poisson_solver.info: -------------------------------------------------------------------------------- 1 | # Poisson solver: prefix `-poisson_` 2 | -poisson_ksp_type cg 3 | -poisson_ksp_atol 1.0E-06 4 | -poisson_ksp_rtol 0.0 5 | -poisson_ksp_max_it 20000 6 | -poisson_pc_type gamg 7 | -poisson_pc_gamg_type agg 8 | -poisson_pc_gamg_agg_nsmooths 1 9 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe550/config/poisson_solver.info: -------------------------------------------------------------------------------- 1 | # Poisson solver: prefix `-poisson_` 2 | -poisson_ksp_type cg 3 | -poisson_ksp_atol 1.0E-06 4 | -poisson_ksp_rtol 0.0 5 | -poisson_ksp_max_it 20000 6 | -poisson_pc_type gamg 7 | -poisson_pc_gamg_type agg 8 | -poisson_pc_gamg_agg_nsmooths 1 9 | -------------------------------------------------------------------------------- /examples/navierstokes/liddrivencavity2dRe1000/config/velocity_solver.info: -------------------------------------------------------------------------------- 1 | # velocity solver: prefix `-velocity_` 2 | -velocity_ksp_type bcgs 3 | -velocity_ksp_atol 1.0E-06 4 | -velocity_ksp_rtol 0.0 5 | -velocity_ksp_max_it 1000 6 | -velocity_pc_type jacobi 7 | -velocity_pc_jacobi_type diagonal 8 | -------------------------------------------------------------------------------- /examples/navierstokes/liddrivencavity2dRe1000_GPU/config/velocity_solver.info: -------------------------------------------------------------------------------- 1 | # velocity solver: prefix `-velocity_` 2 | -velocity_ksp_type bcgs 3 | -velocity_ksp_atol 1.0E-06 4 | -velocity_ksp_rtol 0.0 5 | -velocity_ksp_max_it 1000 6 | -velocity_pc_type jacobi 7 | -velocity_pc_jacobi_type diagonal 8 | -------------------------------------------------------------------------------- /examples/navierstokes/liddrivencavity2dRe3200/config/velocity_solver.info: -------------------------------------------------------------------------------- 1 | # velocity solver: prefix `-velocity_` 2 | -velocity_ksp_type bcgs 3 | -velocity_ksp_atol 1.0E-06 4 | -velocity_ksp_rtol 0.0 5 | -velocity_ksp_max_it 1000 6 | -velocity_pc_type jacobi 7 | -velocity_pc_jacobi_type diagonal 8 | -------------------------------------------------------------------------------- /examples/navierstokes/liddrivencavity2dRe5000/config/velocity_solver.info: -------------------------------------------------------------------------------- 1 | # velocity solver: prefix `-velocity_` 2 | -velocity_ksp_type bcgs 3 | -velocity_ksp_atol 1.0E-06 4 | -velocity_ksp_rtol 0.0 5 | -velocity_ksp_max_it 1000 6 | -velocity_pc_type jacobi 7 | -velocity_pc_jacobi_type diagonal 8 | -------------------------------------------------------------------------------- /examples/navierstokes/taylorgreenvortex2dRe100/config/velocity_solver.info: -------------------------------------------------------------------------------- 1 | # velocity solver: prefix `-velocity_` 2 | -velocity_ksp_type bcgs 3 | -velocity_ksp_atol 1.0E-14 4 | -velocity_ksp_rtol 0.0 5 | -velocity_ksp_max_it 1000 6 | -velocity_pc_type jacobi 7 | -velocity_pc_jacobi_type diagonal 8 | -------------------------------------------------------------------------------- /examples/api_examples/oscillatingcylinder2dRe100_GPU/config/velocity_solver.info: -------------------------------------------------------------------------------- 1 | # Velocity solver: prefix `-velocity_` 2 | -velocity_ksp_type bcgs 3 | -velocity_ksp_atol 1.0E-06 4 | -velocity_ksp_rtol 0.0 5 | -velocity_ksp_max_it 1000 6 | -velocity_pc_type jacobi 7 | -velocity_pc_jacobi_type diagonal 8 | -------------------------------------------------------------------------------- /examples/api_examples/liddrivencavity2d/config/poisson_solver.info: -------------------------------------------------------------------------------- 1 | # Poisson solver: prefix `-poisson_` 2 | -poisson_ksp_type cg 3 | -poisson_ksp_atol 1.0E-06 4 | -poisson_ksp_rtol 0.0 5 | -poisson_ksp_max_it 1000 6 | -poisson_pc_type gamg 7 | -poisson_pc_gamg_type agg 8 | -poisson_pc_gamg_agg_nsmooths 1 9 | -poisson_mg_levels_ksp_type cg 10 | -------------------------------------------------------------------------------- /examples/navierstokes/liddrivencavity2dRe100/config/poisson_solver.info: -------------------------------------------------------------------------------- 1 | # Poisson solver: prefix `-poisson_` 2 | -poisson_ksp_type cg 3 | -poisson_ksp_atol 1.0E-06 4 | -poisson_ksp_rtol 0.0 5 | -poisson_ksp_max_it 1000 6 | -poisson_pc_type gamg 7 | -poisson_pc_gamg_type agg 8 | -poisson_pc_gamg_agg_nsmooths 1 9 | -poisson_mg_levels_ksp_type cg 10 | -------------------------------------------------------------------------------- /examples/navierstokes/liddrivencavity2dRe1000/config/poisson_solver.info: -------------------------------------------------------------------------------- 1 | # Poisson solver: prefix `-poisson_` 2 | -poisson_ksp_type cg 3 | -poisson_ksp_atol 1.0E-06 4 | -poisson_ksp_rtol 0.0 5 | -poisson_ksp_max_it 1000 6 | -poisson_pc_type gamg 7 | -poisson_pc_gamg_type agg 8 | -poisson_pc_gamg_agg_nsmooths 1 9 | -poisson_mg_levels_ksp_type cg 10 | -------------------------------------------------------------------------------- /examples/navierstokes/liddrivencavity2dRe3200/config/poisson_solver.info: -------------------------------------------------------------------------------- 1 | # Poisson solver: prefix `-poisson_` 2 | -poisson_ksp_type cg 3 | -poisson_ksp_atol 1.0E-06 4 | -poisson_ksp_rtol 0.0 5 | -poisson_ksp_max_it 1000 6 | -poisson_pc_type gamg 7 | -poisson_pc_gamg_type agg 8 | -poisson_pc_gamg_agg_nsmooths 1 9 | -poisson_mg_levels_ksp_type cg 10 | -------------------------------------------------------------------------------- /examples/navierstokes/liddrivencavity2dRe5000/config/poisson_solver.info: -------------------------------------------------------------------------------- 1 | # Poisson solver: prefix `-poisson_` 2 | -poisson_ksp_type cg 3 | -poisson_ksp_atol 1.0E-06 4 | -poisson_ksp_rtol 0.0 5 | -poisson_ksp_max_it 1000 6 | -poisson_pc_type gamg 7 | -poisson_pc_gamg_type agg 8 | -poisson_pc_gamg_agg_nsmooths 1 9 | -poisson_mg_levels_ksp_type cg 10 | -------------------------------------------------------------------------------- /tests/misc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(misc delta_test.cpp) 2 | 3 | target_link_libraries(misc 4 | PRIVATE MPI::MPI_CXX 5 | PRIVATE PkgConfig::PETSC 6 | PRIVATE yaml-cpp 7 | PRIVATE petibm 8 | PRIVATE gtest_main 9 | ) 10 | 11 | cmake_path(GET CMAKE_CURRENT_BINARY_DIR PARENT_PATH TEST_DIR) 12 | gtest_discover_tests(misc WORKING_DIRECTORY ${TEST_DIR}) 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore build directory 2 | build 3 | 4 | # Ignore backup files 5 | *~ 6 | 7 | # Ignore files generated by Doxygen 8 | doc/html 9 | doc/doxygen_sqlite3.db 10 | 11 | # Ignore Python compiled files 12 | *.pyc 13 | 14 | # Ignore debugging info files generated by Apple's Xcode 15 | *.dSYM 16 | 17 | # Ignore VSCode configuration 18 | .vscode 19 | 20 | # Ignore any cache 21 | **/.cache 22 | -------------------------------------------------------------------------------- /tests/boundary/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(boundary singleboundary_test.cpp) 2 | 3 | target_link_libraries(boundary 4 | PRIVATE MPI::MPI_CXX 5 | PRIVATE PkgConfig::PETSC 6 | PRIVATE yaml-cpp 7 | PRIVATE petibm 8 | PRIVATE gtest_main 9 | ) 10 | 11 | cmake_path(GET CMAKE_CURRENT_BINARY_DIR PARENT_PATH TEST_DIR) 12 | gtest_discover_tests(boundary WORKING_DIRECTORY ${TEST_DIR}) 13 | -------------------------------------------------------------------------------- /tests/operators/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(operators createbnhead_test.cpp) 2 | 3 | target_link_libraries(operators 4 | PRIVATE MPI::MPI_CXX 5 | PRIVATE PkgConfig::PETSC 6 | PRIVATE yaml-cpp 7 | PRIVATE petibm 8 | PRIVATE gtest_main 9 | ) 10 | 11 | cmake_path(GET CMAKE_CURRENT_BINARY_DIR PARENT_PATH TEST_DIR) 12 | gtest_discover_tests(operators WORKING_DIRECTORY ${TEST_DIR}) 13 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | enable_testing() 2 | 3 | include(GoogleTest) 4 | 5 | add_subdirectory(body) 6 | add_subdirectory(boundary) 7 | add_subdirectory(mesh) 8 | add_subdirectory(misc) 9 | add_subdirectory(operators) 10 | 11 | add_custom_target(check 12 | COMMAND ${CMAKE_CTEST_COMMAND} 13 | DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 14 | COMMENT "Run tests" 15 | DEPENDS body boundary mesh misc operators 16 | ) 17 | -------------------------------------------------------------------------------- /tests/mesh/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(mesh 2 | cartesianmesh2d_dirichlet.cpp 3 | cartesianmesh2d_yperiodic.cpp 4 | cartesianmesh3d_dirichlet.cpp 5 | main.cpp 6 | ) 7 | 8 | target_link_libraries(mesh 9 | PRIVATE MPI::MPI_CXX 10 | PRIVATE PkgConfig::PETSC 11 | PRIVATE yaml-cpp 12 | PRIVATE petibm 13 | PRIVATE gtest_main 14 | ) 15 | 16 | cmake_path(GET CMAKE_CURRENT_BINARY_DIR PARENT_PATH TEST_DIR) 17 | gtest_discover_tests(mesh WORKING_DIRECTORY ${TEST_DIR}) 18 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100_GPU/config/velocity_solver.info: -------------------------------------------------------------------------------- 1 | config_version=2 2 | 3 | communicator=MPI 4 | min_rows_latency_hiding=-1 5 | matrix_consolidation_lower_threshold=0 6 | matrix_consolidation_upper_threshold=1000 7 | fine_level_consolidation=0 8 | determinism_flag=1 9 | 10 | solver(solv)=PBICGSTAB 11 | solv:max_iters=1000 12 | solv:monitor_residual=1 13 | solv:convergence=ABSOLUTE 14 | solv:tolerance=1.0E-06 15 | solv:norm=L2 16 | solv:print_solve_stats=0 17 | solv:store_res_history=1 18 | solv:print_grid_stats=0 19 | solv:obtain_timings=0 20 | solv:preconditioner(prec)=NOSOLVER 21 | -------------------------------------------------------------------------------- /examples/navierstokes/convergence/liddrivencavity2dRe100_20/configs/solversPetscOptions.info: -------------------------------------------------------------------------------- 1 | # solversPetscOptions.info 2 | 3 | # Velocity solver: prefix `-velocity_` 4 | -velocity_ksp_type bcgs 5 | -velocity_ksp_rtol 1.0E-08 6 | -velocity_ksp_atol 0.0 7 | -velocity_ksp_max_it 10000 8 | -velocity_pc_type jacobi 9 | -velocity_pc_jacobi_type diagonal 10 | 11 | # Poisson solver: prefix `-poisson_` 12 | -poisson_ksp_type cg 13 | -poisson_ksp_rtol 1.0E-08 14 | -poisson_ksp_atol 0.0 15 | -poisson_ksp_max_it 20000 16 | -poisson_pc_type gamg 17 | -poisson_pc_gamg_type agg 18 | -poisson_pc_gamg_agg_nsmooths 1 19 | -------------------------------------------------------------------------------- /examples/navierstokes/convergence/liddrivencavity2dRe100_30/configs/solversPetscOptions.info: -------------------------------------------------------------------------------- 1 | # solversPetscOptions.info 2 | 3 | # Velocity solver: prefix `-velocity_` 4 | -velocity_ksp_type bcgs 5 | -velocity_ksp_rtol 1.0E-08 6 | -velocity_ksp_atol 0.0 7 | -velocity_ksp_max_it 10000 8 | -velocity_pc_type jacobi 9 | -velocity_pc_jacobi_type diagonal 10 | 11 | # Poisson solver: prefix `-poisson_` 12 | -poisson_ksp_type cg 13 | -poisson_ksp_rtol 1.0E-08 14 | -poisson_ksp_atol 0.0 15 | -poisson_ksp_max_it 20000 16 | -poisson_pc_type gamg 17 | -poisson_pc_gamg_type agg 18 | -poisson_pc_gamg_agg_nsmooths 1 19 | -------------------------------------------------------------------------------- /examples/decoupledibpm/multicylinders2dRe100_GPU/config/velocity_solver.info: -------------------------------------------------------------------------------- 1 | config_version=2 2 | 3 | communicator=MPI 4 | min_rows_latency_hiding=-1 5 | matrix_consolidation_lower_threshold=0 6 | matrix_consolidation_upper_threshold=1000 7 | fine_level_consolidation=0 8 | determinism_flag=1 9 | 10 | solver(solv)=PBICGSTAB 11 | solv:max_iters=1000 12 | solv:monitor_residual=1 13 | solv:convergence=ABSOLUTE 14 | solv:tolerance=1.0E-06 15 | solv:norm=L2 16 | solv:print_solve_stats=0 17 | solv:store_res_history=1 18 | solv:print_grid_stats=0 19 | solv:obtain_timings=0 20 | solv:preconditioner(prec)=NOSOLVER 21 | -------------------------------------------------------------------------------- /examples/navierstokes/liddrivencavity2dRe100/README.md: -------------------------------------------------------------------------------- 1 | # 2D lid-driven cavity flow at Re=100 2 | 3 | Run the example: 4 | 5 | ``` 6 | mpiexec -np 1 petibm-navierstokes -options_left -log_view ascii:view.log 7 | ``` 8 | 9 | The simulation completes within a few seconds when using 1 CPU process 10 | (Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz). 11 | 12 | Plot the centerline velocity components and compare with the numerical results 13 | from Ghia et al. (1982): 14 | 15 | ``` 16 | python scripts/plotCenterlineVelocities.py 17 | ``` 18 | 19 | The plot is saved in the sub-folder `figures` of the simulation directory. 20 | -------------------------------------------------------------------------------- /examples/navierstokes/liddrivencavity2dRe3200/README.md: -------------------------------------------------------------------------------- 1 | # 2D lid-driven cavity flow at Re=3200 2 | 3 | Run the example: 4 | 5 | ``` 6 | mpiexec -np 4 petibm-navierstokes -options_left -log_view ascii:view.log 7 | ``` 8 | 9 | The simulation completes in about 6 minutes when using 4 CPU processes 10 | (Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz). 11 | 12 | Plot the centerline velocity components and compare with the numerical results 13 | from Ghia et al. (1982): 14 | 15 | ``` 16 | python scripts/plotCenterlineVelocities.py 17 | ``` 18 | 19 | The plot is saved in the sub-folder `figures` of the simulation directory. 20 | -------------------------------------------------------------------------------- /examples/navierstokes/liddrivencavity2dRe5000/README.md: -------------------------------------------------------------------------------- 1 | # 2D lid-driven cavity flow at Re=5000 2 | 3 | Run the example: 4 | 5 | ``` 6 | mpiexec -np 4 petibm-navierstokes -options_left -log_view ascii:view.log 7 | ``` 8 | 9 | The simulation completes in about 16 minutes when using 4 processes 10 | (Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz). 11 | 12 | Plot the centerline velocity components and compare with the numerical results 13 | from Ghia et al. (1982): 14 | 15 | ``` 16 | python scripts/plotCenterlineVelocities.py 17 | ``` 18 | 19 | The plot is saved in the sub-folder `figures` of the simulation directory. 20 | -------------------------------------------------------------------------------- /examples/navierstokes/liddrivencavity2dRe1000/README.md: -------------------------------------------------------------------------------- 1 | # 2D lid-driven cavity flow at Re=1000 2 | 3 | Run the example: 4 | 5 | ``` 6 | mpiexec -np 2 petibm-navierstokes -options_left -log_view ascii:view.log 7 | ``` 8 | 9 | The simulation completes in less than 2 minutes when using 2 CPU processes 10 | (Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz). 11 | 12 | Plot the centerline velocity components and compare with the numerical results 13 | from Ghia et al. (1982): 14 | 15 | ``` 16 | python scripts/plotCenterlineVelocities.py 17 | ``` 18 | 19 | The plot is saved in the sub-folder `figures` of the simulation directory. 20 | -------------------------------------------------------------------------------- /tests/mesh/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * \file tests/mesh/main.cpp 3 | * \copyright Copyright (c) 2016-2018, Barba group. All rights reserved. 4 | * \license BSD 3-Clause License. 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | // Run all tests 11 | int main(int argc, char **argv) 12 | { 13 | PetscErrorCode status; 14 | 15 | ::testing::InitGoogleTest(&argc, argv); 16 | status = PetscInitialize(&argc, &argv, nullptr, nullptr); 17 | CHKERRQ(status); 18 | status = RUN_ALL_TESTS(); 19 | status = PetscFinalize(); 20 | CHKERRQ(status); 21 | 22 | return status; 23 | } // main 24 | -------------------------------------------------------------------------------- /tests/body/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(body singlebody_test.cpp) 2 | 3 | target_link_libraries(body 4 | PRIVATE MPI::MPI_CXX 5 | PRIVATE PkgConfig::PETSC 6 | PRIVATE yaml-cpp 7 | PRIVATE petibm 8 | PRIVATE gtest_main 9 | ) 10 | 11 | add_custom_command( 12 | TARGET body 13 | POST_BUILD 14 | COMMAND ${CMAKE_COMMAND} -E 15 | copy ${CMAKE_CURRENT_SOURCE_DIR}/body2d.txt ${CMAKE_CURRENT_BINARY_DIR} 16 | COMMAND ${CMAKE_COMMAND} -E 17 | copy ${CMAKE_CURRENT_SOURCE_DIR}/body3d.txt ${CMAKE_CURRENT_BINARY_DIR} 18 | ) 19 | 20 | cmake_path(GET CMAKE_CURRENT_BINARY_DIR PARENT_PATH TEST_DIR) 21 | gtest_discover_tests(body WORKING_DIRECTORY ${TEST_DIR}) 22 | -------------------------------------------------------------------------------- /examples/navierstokes/taylorgreenvortex3dRe1600_GPU/config/velocity_solver.info: -------------------------------------------------------------------------------- 1 | config_version=2 2 | 3 | communicator=MPI_DIRECT 4 | min_rows_latency_hiding=-1 5 | matrix_consolidation_lower_threshold=0 6 | matrix_consolidation_upper_threshold=1000 7 | fine_level_consolidation=0 8 | determinism_flag=1 9 | 10 | solver(solv)=PBICGSTAB 11 | solv:max_iters=1000 12 | solv:monitor_residual=1 13 | solv:convergence=ABSOLUTE 14 | solv:tolerance=1.0E-14 15 | solv:norm=L2 16 | solv:print_solve_stats=0 17 | solv:store_res_history=1 18 | solv:print_grid_stats=0 19 | solv:obtain_timings=0 20 | solv:preconditioner(prec)=BLOCK_JACOBI 21 | 22 | prec:relaxation_factor=0.9 23 | prec:max_iters=1 24 | prec:monitor_residual=0 25 | -------------------------------------------------------------------------------- /examples/navierstokes/convergence/liddrivencavity2dRe100_20/README.md: -------------------------------------------------------------------------------- 1 | # Convergence test of the Navier-Stokes solver 2 | 3 | Run the cases from the present directory: 4 | 5 | ``` 6 | petibm-navierstokes -directory 20 -options_left -log_view ascii:20/view.log 7 | petibm-navierstokes -directory 60 -options_left -log_view ascii:60/view.log 8 | petibm-navierstokes -directory 180 -options_left -log_view ascii:180/view.log 9 | petibm-navierstokes -directory 540 -options_left -log_view ascii:540/view.log 10 | ``` 11 | 12 | Computes the observed orders of convergence for the velocity components and 13 | the pressure using three consistently refined grids: 14 | 15 | ``` 16 | python scripts/getOrderConvergence.py 17 | ``` 18 | -------------------------------------------------------------------------------- /examples/navierstokes/convergence/liddrivencavity2dRe100_30/README.md: -------------------------------------------------------------------------------- 1 | # Convergence test of the Navier-Stokes solver 2 | 3 | Run the cases from the present directory: 4 | 5 | ``` 6 | petibm-navierstokes -directory 30 -options_left -log_view ascii:30/view.log 7 | petibm-navierstokes -directory 90 -options_left -log_view ascii:90/view.log 8 | petibm-navierstokes -directory 270 -options_left -log_view ascii:270/view.log 9 | petibm-navierstokes -directory 810 -options_left -log_view ascii:810/view.log 10 | ``` 11 | 12 | Computes the observed orders of convergence for the velocity components and 13 | the pressure using three consistently refined grids: 14 | 15 | ``` 16 | python scripts/getOrderConvergence.py 17 | ``` 18 | -------------------------------------------------------------------------------- /examples/navierstokes/liddrivencavity2dRe1000_GPU/README.md: -------------------------------------------------------------------------------- 1 | # 2D lid-driven cavity flow at Re=1000 (GPU) 2 | 3 | Run the example using 1 GPU (index 0): 4 | 5 | ``` 6 | export CUDA_VISIBLE_DEVICES= 7 | mpiexec -np 2 petibm-navierstokes -options_left -log_view ascii:view.log 8 | ``` 9 | 10 | The simulation completes in less than 2 minutes when using: 11 | - 2 CPU processes (Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz), 12 | - 1 NVIDIA K40 GPU device. 13 | 14 | Plot the centerline velocity components and compare with the numerical results 15 | from Ghia et al. (1982): 16 | 17 | ``` 18 | python scripts/plotCenterlineVelocities.py 19 | ``` 20 | 21 | The plot is saved in the sub-folder `figures` of the simulation directory. 22 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe40/scripts/createBody.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create a circle. 3 | """ 4 | 5 | import pathlib 6 | import math 7 | import numpy 8 | 9 | 10 | root_dir = pathlib.Path(__file__).absolute().parents[1] 11 | 12 | # Circle's parameters. 13 | R = 0.5 # radius 14 | xc, yc = 0.0, 0.0 # center's coordinates 15 | ds = 0.025 # distance between two consecutive points 16 | 17 | # Create coordinates of the circle. 18 | n = math.ceil(2 * numpy.pi * R / ds) # number of divisions 19 | theta = numpy.linspace(0.0, 2.0 * numpy.pi, num=n + 1)[:-1] 20 | x, y = xc + R * numpy.cos(theta), yc + R * numpy.sin(theta) 21 | 22 | # Write coordinates into file. 23 | filepath = root_dir / 'circle.body' 24 | with open(filepath, 'w') as outfile: 25 | outfile.write('{}\n'.format(n)) 26 | with open(filepath, 'ab') as outfile: 27 | numpy.savetxt(outfile, numpy.c_[x, y]) 28 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe550/scripts/createBody.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create a circle. 3 | """ 4 | 5 | import pathlib 6 | import math 7 | import numpy 8 | 9 | 10 | root_dir = pathlib.Path(__file__).absolute().parents[1] 11 | 12 | # Circle's parameters. 13 | R = 0.5 # radius 14 | xc, yc = 0.0, 0.0 # center's coordinates 15 | ds = 0.01 # distance between two consecutive points 16 | 17 | # Create coordinates of the circle. 18 | n = math.ceil(2 * numpy.pi * R / ds) # number of divisions 19 | theta = numpy.linspace(0.0, 2.0 * numpy.pi, num=n + 1)[:-1] 20 | x, y = xc + R * numpy.cos(theta), yc + R * numpy.sin(theta) 21 | 22 | # Write coordinates into file. 23 | filepath = root_dir / 'circle.body' 24 | with open(filepath, 'w') as outfile: 25 | outfile.write('{}\n'.format(n)) 26 | with open(filepath, 'ab') as outfile: 27 | numpy.savetxt(outfile, numpy.c_[x, y]) 28 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe100_GPU/scripts/createBody.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create a circle. 3 | """ 4 | 5 | import pathlib 6 | import math 7 | import numpy 8 | 9 | 10 | root_dir = pathlib.Path(__file__).absolute().parents[1] 11 | 12 | # Circle's parameters. 13 | R = 0.5 # radius 14 | xc, yc = 0.0, 0.0 # center's coordinates 15 | ds = 0.02 # distance between two consecutive points 16 | 17 | # Create coordinates of the circle. 18 | n = math.ceil(2 * numpy.pi * R / ds) # number of divisions 19 | theta = numpy.linspace(0.0, 2.0 * numpy.pi, num=n + 1)[:-1] 20 | x, y = xc + R * numpy.cos(theta), yc + R * numpy.sin(theta) 21 | 22 | # Write coordinates into file. 23 | filepath = root_dir / 'circle.body' 24 | with open(filepath, 'w') as outfile: 25 | outfile.write('{}\n'.format(n)) 26 | with open(filepath, 'ab') as outfile: 27 | numpy.savetxt(outfile, numpy.c_[x, y]) 28 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe3000/scripts/createBody.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create a circle. 3 | """ 4 | 5 | import pathlib 6 | import math 7 | import numpy 8 | 9 | 10 | root_dir = pathlib.Path(__file__).absolute().parents[1] 11 | 12 | # Circle's parameters. 13 | R = 0.5 # radius 14 | xc, yc = 0.0, 0.0 # center's coordinates 15 | ds = 0.004 # distance between two consecutive points 16 | 17 | # Create coordinates of the circle. 18 | n = math.ceil(2 * numpy.pi * R / ds) # number of divisions 19 | theta = numpy.linspace(0.0, 2.0 * numpy.pi, num=n + 1)[:-1] 20 | x, y = xc + R * numpy.cos(theta), yc + R * numpy.sin(theta) 21 | 22 | # Write coordinates into file. 23 | filepath = root_dir / 'circle.body' 24 | with open(filepath, 'w') as outfile: 25 | outfile.write('{}\n'.format(n)) 26 | with open(filepath, 'ab') as outfile: 27 | numpy.savetxt(outfile, numpy.c_[x, y]) 28 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe3000_GPU/scripts/createBody.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create a circle. 3 | """ 4 | 5 | import pathlib 6 | import math 7 | import numpy 8 | 9 | 10 | root_dir = pathlib.Path(__file__).absolute().parents[1] 11 | 12 | # Circle's parameters. 13 | R = 0.5 # radius 14 | xc, yc = 0.0, 0.0 # center's coordinates 15 | ds = 0.004 # distance between two consecutive points 16 | 17 | # Create coordinates of the circle. 18 | n = math.ceil(2 * numpy.pi * R / ds) # number of divisions 19 | theta = numpy.linspace(0.0, 2.0 * numpy.pi, num=n + 1)[:-1] 20 | x, y = xc + R * numpy.cos(theta), yc + R * numpy.sin(theta) 21 | 22 | # Write coordinates into file. 23 | filepath = root_dir / 'circle.body' 24 | with open(filepath, 'w') as outfile: 25 | outfile.write('{}\n'.format(n)) 26 | with open(filepath, 'ab') as outfile: 27 | numpy.savetxt(outfile, numpy.c_[x, y]) 28 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe550_GPU/scripts/createBody.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create a circle. 3 | """ 4 | 5 | import pathlib 6 | import math 7 | import numpy 8 | 9 | 10 | root_dir = pathlib.Path(__file__).absolute().parents[1] 11 | 12 | # Circle's parameters. 13 | R = 0.5 # radius 14 | xc, yc = 0.0, 0.0 # center's coordinates 15 | ds = 0.01 # distance between two consecutive points 16 | 17 | # Create coordinates of the circle. 18 | n = math.ceil(2 * numpy.pi * R / ds) # number of divisions 19 | theta = numpy.linspace(0.0, 2.0 * numpy.pi, num=n + 1)[:-1] 20 | x, y = xc + R * numpy.cos(theta), yc + R * numpy.sin(theta) 21 | 22 | # Write coordinates into file. 23 | filepath = root_dir / 'circle.body' 24 | with open(filepath, 'w') as outfile: 25 | outfile.write('{}\n'.format(n)) 26 | with open(filepath, 'ab') as outfile: 27 | numpy.savetxt(outfile, numpy.c_[x, y]) 28 | -------------------------------------------------------------------------------- /examples/api_examples/oscillatingcylinder2dRe100_GPU/scripts/createBody.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create a circle. 3 | """ 4 | 5 | import pathlib 6 | import math 7 | import numpy 8 | 9 | 10 | # Circle's parameters. 11 | R = 0.5 # radius 12 | xc, yc = 0.0, 0.0 # center's coordinates 13 | ds = 8.0 / 512 # distance between two consecutive points 14 | 15 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 16 | 17 | # Generate coordinates of the circle. 18 | n = math.ceil(2.0 * numpy.pi * R / ds) 19 | theta = numpy.linspace(0.0, 2.0 * numpy.pi, num=n + 1)[:-1] 20 | x, y = xc + R * numpy.cos(theta), yc + R * numpy.sin(theta) 21 | 22 | # Write coordinates into file. 23 | filepath = simu_dir / 'circle.body' 24 | with open(filepath, 'w') as outfile: 25 | outfile.write('{}\n'.format(x.size)) 26 | with open(filepath, 'ab') as outfile: 27 | numpy.savetxt(outfile, numpy.c_[x, y]) 28 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe100_GPU/scripts/createBody.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create a circle. 3 | """ 4 | 5 | import pathlib 6 | import math 7 | import numpy 8 | 9 | 10 | root_dir = pathlib.Path(__file__).absolute().parents[1] 11 | 12 | # Circle's parameters. 13 | R = 0.5 # radius 14 | xc, yc = 0.0, 0.0 # center's coordinates 15 | ds = 0.02 # distance between two consecutive points 16 | 17 | # Create coordinates of the circle. 18 | n = math.ceil(2 * numpy.pi * R / ds) # number of divisions 19 | theta = numpy.linspace(0.0, 2.0 * numpy.pi, num=n + 1)[:-1] 20 | x, y = xc + R * numpy.cos(theta), yc + R * numpy.sin(theta) 21 | 22 | # Write coordinates into file. 23 | filepath = root_dir / 'circle.body' 24 | with open(filepath, 'w') as outfile: 25 | outfile.write('{}\n'.format(n)) 26 | with open(filepath, 'ab') as outfile: 27 | numpy.savetxt(outfile, numpy.c_[x, y]) 28 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe3000_GPU/scripts/createBody.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create a circle. 3 | """ 4 | 5 | import pathlib 6 | import math 7 | import numpy 8 | 9 | 10 | root_dir = pathlib.Path(__file__).absolute().parents[1] 11 | 12 | # Circle's parameters. 13 | R = 0.5 # radius 14 | xc, yc = 0.0, 0.0 # center's coordinates 15 | ds = 0.004 # distance between two consecutive points 16 | 17 | # Create coordinates of the circle. 18 | n = math.ceil(2 * numpy.pi * R / ds) # number of divisions 19 | theta = numpy.linspace(0.0, 2.0 * numpy.pi, num=n + 1)[:-1] 20 | x, y = xc + R * numpy.cos(theta), yc + R * numpy.sin(theta) 21 | 22 | # Write coordinates into file. 23 | filepath = root_dir / 'circle.body' 24 | with open(filepath, 'w') as outfile: 25 | outfile.write('{}\n'.format(n)) 26 | with open(filepath, 'ab') as outfile: 27 | numpy.savetxt(outfile, numpy.c_[x, y]) 28 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe40_GPU/scripts/createBody.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create a circle. 3 | """ 4 | 5 | import pathlib 6 | import math 7 | import numpy 8 | 9 | 10 | root_dir = pathlib.Path(__file__).absolute().parents[1] 11 | 12 | # Circle's parameters. 13 | R = 0.5 # radius 14 | xc, yc = 0.0, 0.0 # center's coordinates 15 | ds = 0.025 # distance between two consecutive points 16 | 17 | # Create coordinates of the circle. 18 | n = math.ceil(2 * numpy.pi * R / ds) # number of divisions 19 | theta = numpy.linspace(0.0, 2.0 * numpy.pi, num=n + 1)[:-1] 20 | x, y = xc + R * numpy.cos(theta), yc + R * numpy.sin(theta) 21 | 22 | # Write coordinates into file. 23 | filepath = root_dir / 'circle.body' 24 | with open(filepath, 'w') as outfile: 25 | outfile.write('{}\n'.format(n)) 26 | with open(filepath, 'ab') as outfile: 27 | numpy.savetxt(outfile, numpy.c_[x, y]) 28 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe550_GPU/scripts/createBody.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create a circle. 3 | """ 4 | 5 | import pathlib 6 | import math 7 | import numpy 8 | 9 | 10 | root_dir = pathlib.Path(__file__).absolute().parents[1] 11 | 12 | # Circle's parameters. 13 | R = 0.5 # radius 14 | xc, yc = 0.0, 0.0 # center's coordinates 15 | ds = 0.01 # distance between two consecutive points 16 | 17 | # Create coordinates of the circle. 18 | n = math.ceil(2 * numpy.pi * R / ds) # number of divisions 19 | theta = numpy.linspace(0.0, 2.0 * numpy.pi, num=n + 1)[:-1] 20 | x, y = xc + R * numpy.cos(theta), yc + R * numpy.sin(theta) 21 | 22 | # Write coordinates into file. 23 | filepath = root_dir / 'circle.body' 24 | with open(filepath, 'w') as outfile: 25 | outfile.write('{}\n'.format(n)) 26 | with open(filepath, 'ab') as outfile: 27 | numpy.savetxt(outfile, numpy.c_[x, y]) 28 | -------------------------------------------------------------------------------- /examples/navierstokes/taylorgreenvortex2dRe100/README.md: -------------------------------------------------------------------------------- 1 | # 2D Taylor-Green vortex w/ Re=100 2 | 3 | This example shows how to use symbolic expressions as initial conditions. 4 | 5 | To run this example, do 6 | 7 | ```shell 8 | $ mpiexec -n petibm-navierstokes 9 | ``` 10 | 11 | It should take less than 4 minutes with 6 CPU cores of Intel i7-5930K. 12 | 13 | Once the simulation is done, run the following command for post-processing (assuming required Python packages were installed): 14 | 15 | ```shell 16 | $ python postprocessing.py 17 | ``` 18 | 19 | **Results** 20 | 21 | - U velocity contour at t=50 22 | ![U velocity contour at t=50](simulationresult-t50.0-u.png) 23 | - Absolute error of U velocity at t=50 24 | ![Absolute error of U at t=50](absoluteerror-t50.0-u.png) 25 | - Total kinetic energy 26 | ![Total kinetic energy](kinetic-energy.png) 27 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe40/README.md: -------------------------------------------------------------------------------- 1 | # 2D flow around cylinder (Re=40) 2 | 3 | Run the example using 2 CPU processes: 4 | 5 | ``` 6 | mpiexec -np 2 petibm-ibpm -options_left -log_view ascii:view.log 7 | ``` 8 | 9 | The simulation takes less than 5 minutes to complete when using: 10 | - 2 CPU processes (Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz) 11 | 12 | Plot the instantaneous drag coefficients and compares with numerical results 13 | from Koumoutsakos and Leonard (1995): 14 | 15 | ``` 16 | python scripts/plotDragCoefficient.py 17 | ``` 18 | 19 | Compute the vorticity field at saved time steps: 20 | 21 | ``` 22 | petibm-vorticity 23 | ``` 24 | 25 | Plot the contour of the vorticity field at last saved time step: 26 | 27 | ``` 28 | python scripts/plotVorticity.py 29 | ``` 30 | 31 | The plots are saved as PNG files in the sub-folder `figures` of the simulation 32 | directory. 33 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe550/README.md: -------------------------------------------------------------------------------- 1 | # 2D flow around cylinder (Re=550) 2 | 3 | Run the example using 2 CPU processes: 4 | 5 | ``` 6 | mpiexec -np 2 petibm-ibpm -options_left -log_view ascii:view.log 7 | ``` 8 | 9 | The simulation completes in about 1 hour and 30 minutes when using: 10 | - 2 CPU processes (Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz) 11 | 12 | Plot the instantaneous drag coefficients and compares with numerical results 13 | from Koumoutsakos and Leonard (1995): 14 | 15 | ``` 16 | python scripts/plotDragCoefficient.py 17 | ``` 18 | 19 | Compute the vorticity field at saved time steps: 20 | 21 | ``` 22 | petibm-vorticity 23 | ``` 24 | 25 | Plot the contour of the vorticity field at last saved time step: 26 | 27 | ``` 28 | python scripts/plotVorticity.py 29 | ``` 30 | 31 | The plots are saved as PNG files in the sub-folder `figures` of the simulation 32 | directory. 33 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe3000/README.md: -------------------------------------------------------------------------------- 1 | # 2D flow around cylinder (Re=3000) 2 | 3 | Run the example using 4 CPU processes: 4 | 5 | ``` 6 | mpiexec -np 4 petibm-ibpm -options_left -log_view ascii:view.log 7 | ``` 8 | 9 | The simulation completes in about 10 hours and 30 minutes when using: 10 | - 4 CPU processes (Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz) 11 | 12 | Plot the instantaneous drag coefficients and compares with numerical results 13 | from Koumoutsakos and Leonard (1995): 14 | 15 | ``` 16 | python scripts/plotDragCoefficient.py 17 | ``` 18 | 19 | Compute the vorticity field at saved time steps: 20 | 21 | ``` 22 | petibm-vorticity 23 | ``` 24 | 25 | Plot the contour of the vorticity field at last saved time step: 26 | 27 | ``` 28 | python scripts/plotVorticity.py 29 | ``` 30 | 31 | The plots are saved as PNG files in the sub-folder `figures` of the simulation 32 | directory. 33 | -------------------------------------------------------------------------------- /applications/vorticity/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(petibm-vorticity main.cpp) 2 | 3 | set_target_properties(petibm-vorticity PROPERTIES 4 | RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 5 | INSTALL_RPATH "${PETIBM_RPATH}" 6 | ) 7 | 8 | target_compile_options(petibm-vorticity 9 | PRIVATE -Wno-deprecated-declarations 10 | ) 11 | 12 | target_compile_definitions(petibm-vorticity 13 | PRIVATE $<$:HAVE_AMGX> 14 | ) 15 | 16 | target_link_libraries(petibm-vorticity 17 | PRIVATE MPI::MPI_CXX 18 | PRIVATE PkgConfig::PETSC 19 | PRIVATE yaml-cpp 20 | PRIVATE petibm 21 | ) 22 | 23 | target_link_options(petibm-vorticity 24 | PRIVATE "-Wl,--as-needed" 25 | PRIVATE "-Wl,--no-allow-shlib-undefined" 26 | PRIVATE "-Wl,--no-undefined" 27 | ) 28 | 29 | install( 30 | TARGETS petibm-vorticity 31 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 32 | ) 33 | -------------------------------------------------------------------------------- /applications/writemesh/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(petibm-writemesh main.cpp) 2 | 3 | set_target_properties(petibm-writemesh PROPERTIES 4 | RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 5 | INSTALL_RPATH "${PETIBM_RPATH}" 6 | ) 7 | 8 | target_compile_options(petibm-writemesh 9 | PRIVATE -Wno-deprecated-declarations 10 | ) 11 | 12 | target_compile_definitions(petibm-writemesh 13 | PRIVATE $<$:HAVE_AMGX> 14 | ) 15 | 16 | target_link_libraries(petibm-writemesh 17 | PRIVATE MPI::MPI_CXX 18 | PRIVATE PkgConfig::PETSC 19 | PRIVATE yaml-cpp 20 | PRIVATE petibm 21 | ) 22 | 23 | target_link_options(petibm-writemesh 24 | PRIVATE "-Wl,--as-needed" 25 | PRIVATE "-Wl,--no-allow-shlib-undefined" 26 | PRIVATE "-Wl,--no-undefined" 27 | ) 28 | 29 | install( 30 | TARGETS petibm-writemesh 31 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 32 | ) 33 | -------------------------------------------------------------------------------- /applications/ibpm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(petibm-ibpm ibpm.h ibpm.cpp main.cpp) 2 | 3 | set_target_properties(petibm-ibpm PROPERTIES 4 | RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 5 | INSTALL_RPATH "${PETIBM_RPATH}" 6 | ) 7 | 8 | target_compile_options(petibm-ibpm 9 | PRIVATE -Wno-deprecated-declarations 10 | ) 11 | 12 | target_compile_definitions(petibm-ibpm 13 | PRIVATE $<$:HAVE_AMGX> 14 | ) 15 | 16 | target_link_libraries(petibm-ibpm 17 | PRIVATE MPI::MPI_CXX 18 | PRIVATE PkgConfig::PETSC 19 | PRIVATE yaml-cpp 20 | PRIVATE petibm 21 | PRIVATE petibmapps 22 | ) 23 | 24 | target_link_options(petibm-ibpm 25 | PRIVATE "-Wl,--as-needed" 26 | PRIVATE "-Wl,--no-allow-shlib-undefined" 27 | PRIVATE "-Wl,--no-undefined" 28 | ) 29 | 30 | install( 31 | TARGETS petibm-ibpm 32 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 33 | ) 34 | -------------------------------------------------------------------------------- /applications/createxdmf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(petibm-createxdmf main.cpp) 2 | 3 | set_target_properties(petibm-createxdmf PROPERTIES 4 | RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 5 | INSTALL_RPATH "${PETIBM_RPATH}" 6 | ) 7 | 8 | target_compile_options(petibm-createxdmf 9 | PRIVATE -Wno-deprecated-declarations 10 | ) 11 | 12 | target_compile_definitions(petibm-createxdmf 13 | PRIVATE $<$:HAVE_AMGX> 14 | ) 15 | 16 | target_link_libraries(petibm-createxdmf 17 | PRIVATE MPI::MPI_CXX 18 | PRIVATE PkgConfig::PETSC 19 | PRIVATE yaml-cpp 20 | PRIVATE petibm 21 | ) 22 | 23 | target_link_options(petibm-createxdmf 24 | PRIVATE "-Wl,--as-needed" 25 | PRIVATE "-Wl,--no-allow-shlib-undefined" 26 | PRIVATE "-Wl,--no-undefined" 27 | ) 28 | 29 | install( 30 | TARGETS petibm-createxdmf 31 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 32 | ) 33 | -------------------------------------------------------------------------------- /examples/data/koumoutsakos_leonard_1995_cylinder_dragCoefficientRe40.dat: -------------------------------------------------------------------------------- 1 | # Drag coefficient over an impulsively started cylinder at Re=40 2 | # Koumoutsakos and Leonard (1995) 3 | # High-resoluation simulations of the flow 4 | # around an impulsively started cylinder using vortex methods 5 | 0.059032682 5.976446 6 | 0.0804132 5.4272904 7 | 0.09839249 4.866178 8 | 0.13003284 4.3170714 9 | 0.19598496 3.696486 10 | 0.27543908 3.189399 11 | 0.3648817 2.8554955 12 | 0.47815165 2.5933478 13 | 0.6152302 2.4148967 14 | 0.77618295 2.278351 15 | 0.96442974 2.183727 16 | 1.1799893 2.1190844 17 | 1.5083885 2.0669212 18 | 1.9872465 2.027417 19 | 2.575543 1.9884354 20 | 3.0201828 1.9607081 21 | 3.533231 1.9273373 22 | 4.06678 1.9060049 23 | 4.57639 1.8845581 24 | 5.2091174 1.8636993 25 | 5.7153163 1.836266 26 | 6.454081 1.8039733 27 | 7.1962376 1.7896074 28 | 7.801596 1.7745881 29 | 8.4924345 1.7719175 30 | 9.285891 1.7577965 31 | 9.980149 1.7551422 -------------------------------------------------------------------------------- /examples/api_examples/liddrivencavity2d/config.yaml: -------------------------------------------------------------------------------- 1 | mesh: 2 | - direction: x 3 | start: 0.0 4 | subDomains: 5 | - end: 1.0 6 | cells: 32 7 | stretchRatio: 1.0 8 | - direction: y 9 | start: 0.0 10 | subDomains: 11 | - end: 1.0 12 | cells: 32 13 | stretchRatio: 1.0 14 | 15 | flow: 16 | initialVelocity: [0.0, 0.0] 17 | boundaryConditions: 18 | - location: xMinus 19 | u: [DIRICHLET, 0.0] 20 | v: [DIRICHLET, 0.0] 21 | - location: xPlus 22 | u: [DIRICHLET, 0.0] 23 | v: [DIRICHLET, 0.0] 24 | - location: yMinus 25 | u: [DIRICHLET, 0.0] 26 | v: [DIRICHLET, 0.0] 27 | - location: yPlus 28 | u: [DIRICHLET, 1.0] 29 | v: [DIRICHLET, 0.0] 30 | 31 | parameters: 32 | velocitySolver: 33 | type: CPU 34 | config: config/velocity_solver.info 35 | poissonSolver: 36 | type: CPU 37 | config: config/poisson_solver.info 38 | -------------------------------------------------------------------------------- /examples/data/koumoutsakos_leonard_1995_cylinder_dragCoefficientRe550.dat: -------------------------------------------------------------------------------- 1 | # Drag coefficient over an impulsively started cylinder at Re=550 2 | # Koumoutsakos and Leonard (1995) 3 | # High-resoluation simulations of the flow 4 | # around an impulsively started cylinder using vortex methods 5 | # U*t/R Cd 6 | 0.04675 1.85679 7 | 0.06966 1.62464 8 | 0.09292 1.43892 9 | 0.11647 1.29188 10 | 0.14031 1.18352 11 | 0.18055 1.07127 12 | 0.22090 0.97449 13 | 0.27781 0.89316 14 | 0.34298 0.81955 15 | 0.44930 0.75361 16 | 0.61327 0.70691 17 | 0.79399 0.70274 18 | 1.06549 0.75258 19 | 1.30433 0.82956 20 | 1.55155 0.92973 21 | 1.79054 1.02604 22 | 2.01306 1.11852 23 | 2.21895 1.18394 24 | 2.44943 1.24159 25 | 2.69616 1.27599 26 | 2.89343 1.28727 27 | 3.09883 1.28693 28 | 3.31232 1.27110 29 | 3.60789 1.24353 30 | 3.95273 1.21201 31 | 4.33858 1.17269 32 | 4.80663 1.13710 33 | 5.30756 1.10532 34 | 5.84133 1.06962 35 | 6.20271 1.05354 36 | 6.56410 1.03747 37 | 6.98299 1.02130 -------------------------------------------------------------------------------- /applications/navierstokes/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(petibm-navierstokes navierstokes.h navierstokes.cpp main.cpp) 2 | 3 | set_target_properties(petibm-navierstokes PROPERTIES 4 | RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 5 | INSTALL_RPATH "${PETIBM_RPATH}" 6 | ) 7 | 8 | target_compile_options(petibm-navierstokes 9 | PRIVATE -Wno-deprecated-declarations 10 | ) 11 | 12 | target_compile_definitions(petibm-navierstokes 13 | PRIVATE $<$:HAVE_AMGX> 14 | ) 15 | 16 | target_link_libraries(petibm-navierstokes 17 | PRIVATE MPI::MPI_CXX 18 | PRIVATE PkgConfig::PETSC 19 | PRIVATE yaml-cpp 20 | PRIVATE petibm 21 | ) 22 | 23 | target_link_options(petibm-navierstokes 24 | PRIVATE "-Wl,--as-needed" 25 | PRIVATE "-Wl,--no-allow-shlib-undefined" 26 | PRIVATE "-Wl,--no-undefined" 27 | ) 28 | 29 | install( 30 | TARGETS petibm-navierstokes 31 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 32 | ) 33 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe550_GPU/README.md: -------------------------------------------------------------------------------- 1 | # 2D flow around cylinder (Re=550) 2 | 3 | Run the example using 2 CPU processes and 1 GPU device: 4 | 5 | ``` 6 | export CUDA_VISIBLE_DEVICES= 7 | mpiexec -np 2 petibm-ibpm -options_left -log_view ascii:view.log 8 | ``` 9 | 10 | The simulation completes in less than 5 minutes when using: 11 | - 2 CPU processes (Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz), 12 | - 1 NVIDIA K40 GPU device. 13 | 14 | Plot the instantaneous drag coefficients and compares with numerical results 15 | from Koumoutsakos and Leonard (1995): 16 | 17 | ``` 18 | python scripts/plotDragCoefficient.py 19 | ``` 20 | 21 | Compute the vorticity field at saved time steps: 22 | 23 | ``` 24 | petibm-vorticity 25 | ``` 26 | 27 | Plot the contour of the vorticity field at last saved time step: 28 | 29 | ``` 30 | python scripts/plotVorticity.py 31 | ``` 32 | 33 | The plots are saved as PNG files in the sub-folder `figures` of the simulation 34 | directory. 35 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe3000_GPU/README.md: -------------------------------------------------------------------------------- 1 | # 2D flow around cylinder (Re=3000) 2 | 3 | Run the example using 4 CPU processes and 2 GPU devices: 4 | 5 | ``` 6 | export CUDA_VISIBLE_DEVICES=, 7 | mpiexec -np 4 petibm-ibpm -options_left -log_view ascii:view.log 8 | ``` 9 | 10 | The simulation completes in about 50 minutes when using: 11 | - 4 CPU processes (Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz), 12 | - 2 NVIDIA K20 GPU devices. 13 | 14 | Plot the instantaneous drag coefficients and compares with numerical results 15 | from Koumoutsakos and Leonard (1995): 16 | 17 | ``` 18 | python scripts/plotDragCoefficient.py 19 | ``` 20 | 21 | Compute the vorticity field at saved time steps: 22 | 23 | ``` 24 | petibm-vorticity 25 | ``` 26 | 27 | Plot the contour of the vorticity field at last saved time step: 28 | 29 | ``` 30 | python scripts/plotVorticity.py 31 | ``` 32 | 33 | The plots are saved as PNG files in the sub-folder `figures` of the simulation 34 | directory. 35 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe40_GPU/README.md: -------------------------------------------------------------------------------- 1 | # 2D flow around cylinder (Re=40) 2 | 3 | Run the example using 2 CPU processes and 2 GPUs: 4 | 5 | ``` 6 | export CUDA_VISIBLE_DEVICES=, 7 | mpiexec -np 2 petibm-decoupledibpm -options_left -log_view ascii:view.log 8 | ``` 9 | 10 | The simulation takes about 1 minute to complete when using: 11 | - 2 CPU processes (Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz), 12 | - 2 NVIDIA K20 GPU devices. 13 | 14 | Plot the instantaneous drag coefficients and compares with numerical results 15 | from Koumoutsakos and Leonard (1995): 16 | 17 | ``` 18 | python scripts/plotDragCoefficient.py 19 | ``` 20 | 21 | Compute the vorticity field at saved time steps: 22 | 23 | ``` 24 | petibm-vorticity 25 | ``` 26 | 27 | Plot the contour of the vorticity field at last saved time step: 28 | 29 | ``` 30 | python scripts/plotVorticity.py 31 | ``` 32 | 33 | The plots are saved as PNG files in the sub-folder `figures` of the simulation 34 | directory. 35 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe550_GPU/README.md: -------------------------------------------------------------------------------- 1 | # 2D flow around cylinder (Re=550) 2 | 3 | Run the example using 2 CPU processes and 2 GPUs: 4 | 5 | ``` 6 | export CUDA_VISIBLE_DEVICES=, 7 | mpiexec -np 2 petibm-decoupledibpm -options_left -log_view ascii:view.log 8 | ``` 9 | 10 | The simulation takes about 2 minutes to complete when using: 11 | - 2 CPU processes (Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz), 12 | - 2 NVIDIA K20 GPU devices. 13 | 14 | Plot the instantaneous drag coefficients and compares with numerical results 15 | from Koumoutsakos and Leonard (1995): 16 | 17 | ``` 18 | python scripts/plotDragCoefficient.py 19 | ``` 20 | 21 | Compute the vorticity field at saved time steps: 22 | 23 | ``` 24 | petibm-vorticity 25 | ``` 26 | 27 | Plot the contour of the vorticity field at last saved time step: 28 | 29 | ``` 30 | python scripts/plotVorticity.py 31 | ``` 32 | 33 | The plots are saved as PNG files in the sub-folder `figures` of the simulation 34 | directory. 35 | -------------------------------------------------------------------------------- /applications/decoupledibpm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(petibm-decoupledibpm decoupledibpm.h decoupledibpm.cpp main.cpp) 2 | 3 | set_target_properties(petibm-decoupledibpm PROPERTIES 4 | RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 5 | INSTALL_RPATH "${PETIBM_RPATH}" 6 | ) 7 | 8 | target_compile_options(petibm-decoupledibpm 9 | PRIVATE -Wno-deprecated-declarations 10 | ) 11 | 12 | target_compile_definitions(petibm-decoupledibpm 13 | PRIVATE $<$:HAVE_AMGX> 14 | ) 15 | 16 | target_link_libraries(petibm-decoupledibpm 17 | PRIVATE MPI::MPI_CXX 18 | PRIVATE PkgConfig::PETSC 19 | PRIVATE yaml-cpp 20 | PRIVATE petibm 21 | PRIVATE petibmapps 22 | ) 23 | 24 | target_link_options(petibm-decoupledibpm 25 | PRIVATE "-Wl,--as-needed" 26 | PRIVATE "-Wl,--no-allow-shlib-undefined" 27 | PRIVATE "-Wl,--no-undefined" 28 | ) 29 | 30 | install( 31 | TARGETS petibm-decoupledibpm 32 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 33 | ) 34 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe3000_GPU/README.md: -------------------------------------------------------------------------------- 1 | # 2D flow around cylinder (Re=3000) 2 | 3 | Run the example using 4 CPU processes and 2 GPUs: 4 | 5 | ``` 6 | export CUDA_VISIBLE_DEVICES=, 7 | mpiexec -np 4 petibm-decoupledibpm -options_left -log_view ascii:view.log 8 | ``` 9 | 10 | The simulation completes in less than 20 minutes to complete when using: 11 | - 4 CPU processes (Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz), 12 | - 2 NVIDIA K20 GPU devices. 13 | 14 | Plot the instantaneous drag coefficients and compares with numerical results 15 | from Koumoutsakos and Leonard (1995): 16 | 17 | ``` 18 | python scripts/plotDragCoefficient.py 19 | ``` 20 | 21 | Compute the vorticity field at saved time steps: 22 | 23 | ``` 24 | petibm-vorticity 25 | ``` 26 | 27 | Plot the contour of the vorticity field at last saved time step: 28 | 29 | ``` 30 | python scripts/plotVorticity.py 31 | ``` 32 | 33 | The plots are saved as PNG files in the sub-folder `figures` of the simulation 34 | directory. 35 | -------------------------------------------------------------------------------- /src/private/private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * \file private.h 3 | * \brief Prototypes of private functions that shared by different source files. 4 | * \copyright Copyright (c) 2016-2018, Barba group. All rights reserved. 5 | * \license BSD 3-Clause License. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | /** 13 | * \brief Operator< of MatStencil for using it as a key to map. 14 | * 15 | * Currently, this is made to be a private only used by PetIBM internally. 16 | * 17 | * For the detail of implementation, please refer to 18 | * std::lexicographical_compare. This is just a simplified version. 19 | */ 20 | static bool operator<(const MatStencil &l, const MatStencil &r) 21 | { 22 | if (l.k < r.k) return true; 23 | if (l.k > r.k) return false; 24 | 25 | if (l.j < r.j) return true; 26 | if (l.j > r.j) return false; 27 | 28 | if (l.i < r.i) return true; 29 | if (l.i > r.i) return false; 30 | 31 | if (l.c < r.c) return true; 32 | 33 | return false; 34 | } // operator< 35 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe100_GPU/config/poisson_solver.info: -------------------------------------------------------------------------------- 1 | config_version=2 2 | 3 | communicator=MPI 4 | min_rows_latency_hiding=-1 5 | matrix_consolidation_lower_threshold=0 6 | matrix_consolidation_upper_threshold=1000 7 | fine_level_consolidation=0 8 | determinism_flag=1 9 | 10 | solver(solv)=PCG 11 | solv:max_iters=1000 12 | solv:monitor_residual=1 13 | solv:convergence=ABSOLUTE 14 | solv:tolerance=1.0E-06 15 | solv:norm=L2 16 | solv:print_solve_stats=0 17 | solv:store_res_history=1 18 | solv:print_grid_stats=0 19 | solv:obtain_timings=0 20 | solv:preconditioner(prec)=AMG 21 | 22 | prec:algorithm=AGGREGATION 23 | prec:max_iters=1 24 | prec:cycle=V 25 | prec:presweeps=1 26 | prec:postsweeps=1 27 | prec:max_levels=100 28 | prec:min_coarse_rows=2 29 | prec:max_matching_iterations=200 30 | prec:max_unassigned_percentage=0.05 31 | prec:selector=SIZE_2 32 | prec:coarse_solver(c_solver)=DENSE_LU_SOLVER 33 | prec:dense_lu_num_rows=128 34 | prec:dense_lu_max_rows=0 35 | prec:coarsest_sweeps=1 36 | prec:smoother(smooth)=BLOCK_JACOBI 37 | 38 | smooth:relaxation_factor=0.9 39 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe3000_GPU/config/poisson_solver.info: -------------------------------------------------------------------------------- 1 | config_version=2 2 | 3 | communicator=MPI 4 | min_rows_latency_hiding=-1 5 | matrix_consolidation_lower_threshold=0 6 | matrix_consolidation_upper_threshold=1000 7 | fine_level_consolidation=0 8 | determinism_flag=1 9 | 10 | solver(solv)=PCG 11 | solv:max_iters=1000 12 | solv:monitor_residual=1 13 | solv:convergence=ABSOLUTE 14 | solv:tolerance=1.0E-06 15 | solv:norm=L2 16 | solv:print_solve_stats=0 17 | solv:store_res_history=1 18 | solv:print_grid_stats=0 19 | solv:obtain_timings=0 20 | solv:preconditioner(prec)=AMG 21 | 22 | prec:algorithm=AGGREGATION 23 | prec:max_iters=1 24 | prec:cycle=V 25 | prec:presweeps=1 26 | prec:postsweeps=1 27 | prec:max_levels=100 28 | prec:min_coarse_rows=2 29 | prec:max_matching_iterations=200 30 | prec:max_unassigned_percentage=0.05 31 | prec:selector=SIZE_2 32 | prec:coarse_solver(c_solver)=DENSE_LU_SOLVER 33 | prec:dense_lu_num_rows=128 34 | prec:dense_lu_max_rows=0 35 | prec:coarsest_sweeps=1 36 | prec:smoother(smooth)=BLOCK_JACOBI 37 | 38 | smooth:relaxation_factor=0.9 39 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe550_GPU/config/poisson_solver.info: -------------------------------------------------------------------------------- 1 | config_version=2 2 | 3 | communicator=MPI 4 | min_rows_latency_hiding=-1 5 | matrix_consolidation_lower_threshold=0 6 | matrix_consolidation_upper_threshold=1000 7 | fine_level_consolidation=0 8 | determinism_flag=1 9 | 10 | solver(solv)=PCG 11 | solv:max_iters=1000 12 | solv:monitor_residual=1 13 | solv:convergence=ABSOLUTE 14 | solv:tolerance=1.0E-06 15 | solv:norm=L2 16 | solv:print_solve_stats=0 17 | solv:store_res_history=1 18 | solv:print_grid_stats=0 19 | solv:obtain_timings=0 20 | solv:preconditioner(prec)=AMG 21 | 22 | prec:algorithm=AGGREGATION 23 | prec:max_iters=1 24 | prec:cycle=V 25 | prec:presweeps=1 26 | prec:postsweeps=1 27 | prec:max_levels=100 28 | prec:min_coarse_rows=2 29 | prec:max_matching_iterations=200 30 | prec:max_unassigned_percentage=0.05 31 | prec:selector=SIZE_2 32 | prec:coarse_solver(c_solver)=DENSE_LU_SOLVER 33 | prec:dense_lu_num_rows=128 34 | prec:dense_lu_max_rows=0 35 | prec:coarsest_sweeps=1 36 | prec:smoother(smooth)=BLOCK_JACOBI 37 | 38 | smooth:relaxation_factor=0.9 39 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe40_GPU/config/poisson_solver.info: -------------------------------------------------------------------------------- 1 | config_version=2 2 | 3 | communicator=MPI 4 | min_rows_latency_hiding=-1 5 | matrix_consolidation_lower_threshold=0 6 | matrix_consolidation_upper_threshold=1000 7 | fine_level_consolidation=0 8 | determinism_flag=1 9 | 10 | solver(solv)=PCG 11 | solv:max_iters=1000 12 | solv:monitor_residual=1 13 | solv:convergence=ABSOLUTE 14 | solv:tolerance=1.0E-06 15 | solv:norm=L2 16 | solv:print_solve_stats=0 17 | solv:store_res_history=1 18 | solv:print_grid_stats=0 19 | solv:obtain_timings=0 20 | solv:preconditioner(prec)=AMG 21 | 22 | prec:algorithm=CLASSICAL 23 | prec:max_iters=1 24 | prec:cycle=V 25 | prec:presweeps=1 26 | prec:postsweeps=1 27 | prec:max_levels=100 28 | prec:min_coarse_rows=2 29 | prec:interp_max_elements=-1 30 | prec:interp_truncation_factor=1.1 31 | prec:interpolator=D2 32 | prec:max_row_sum=1.1 33 | prec:selector=PMIS 34 | prec:strength=AHAT 35 | prec:strength_threshold=0.25 36 | prec:coarse_solver(c_solver)=DENSE_LU_SOLVER 37 | prec:dense_lu_num_rows=128 38 | prec:dense_lu_max_rows=0 39 | prec:coarsest_sweeps=1 40 | prec:smoother(smooth)=BLOCK_JACOBI 41 | 42 | smooth:relaxation_factor=0.9 43 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe100_GPU/config/poisson_solver.info: -------------------------------------------------------------------------------- 1 | config_version=2 2 | 3 | communicator=MPI 4 | min_rows_latency_hiding=-1 5 | matrix_consolidation_lower_threshold=0 6 | matrix_consolidation_upper_threshold=1000 7 | fine_level_consolidation=0 8 | determinism_flag=1 9 | 10 | solver(solv)=PCG 11 | solv:max_iters=1000 12 | solv:monitor_residual=1 13 | solv:convergence=ABSOLUTE 14 | solv:tolerance=1.0E-06 15 | solv:norm=L2 16 | solv:print_solve_stats=0 17 | solv:store_res_history=1 18 | solv:print_grid_stats=0 19 | solv:obtain_timings=0 20 | solv:preconditioner(prec)=AMG 21 | 22 | prec:algorithm=CLASSICAL 23 | prec:max_iters=1 24 | prec:cycle=V 25 | prec:presweeps=1 26 | prec:postsweeps=1 27 | prec:max_levels=100 28 | prec:min_coarse_rows=2 29 | prec:interp_max_elements=-1 30 | prec:interp_truncation_factor=1.1 31 | prec:interpolator=D2 32 | prec:max_row_sum=1.1 33 | prec:selector=PMIS 34 | prec:strength=AHAT 35 | prec:strength_threshold=0.25 36 | prec:coarse_solver(c_solver)=DENSE_LU_SOLVER 37 | prec:dense_lu_num_rows=128 38 | prec:dense_lu_max_rows=0 39 | prec:coarsest_sweeps=1 40 | prec:smoother(smooth)=BLOCK_JACOBI 41 | 42 | smooth:relaxation_factor=0.9 43 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe3000_GPU/config/poisson_solver.info: -------------------------------------------------------------------------------- 1 | config_version=2 2 | 3 | communicator=MPI 4 | min_rows_latency_hiding=-1 5 | matrix_consolidation_lower_threshold=0 6 | matrix_consolidation_upper_threshold=1000 7 | fine_level_consolidation=0 8 | determinism_flag=1 9 | 10 | solver(solv)=PCG 11 | solv:max_iters=1000 12 | solv:monitor_residual=1 13 | solv:convergence=ABSOLUTE 14 | solv:tolerance=1.0E-06 15 | solv:norm=L2 16 | solv:print_solve_stats=0 17 | solv:store_res_history=1 18 | solv:print_grid_stats=0 19 | solv:obtain_timings=0 20 | solv:preconditioner(prec)=AMG 21 | 22 | prec:algorithm=CLASSICAL 23 | prec:max_iters=1 24 | prec:cycle=V 25 | prec:presweeps=1 26 | prec:postsweeps=1 27 | prec:max_levels=100 28 | prec:min_coarse_rows=2 29 | prec:interp_max_elements=-1 30 | prec:interp_truncation_factor=1.1 31 | prec:interpolator=D2 32 | prec:max_row_sum=1.1 33 | prec:selector=PMIS 34 | prec:strength=AHAT 35 | prec:strength_threshold=0.25 36 | prec:coarse_solver(c_solver)=DENSE_LU_SOLVER 37 | prec:dense_lu_num_rows=128 38 | prec:dense_lu_max_rows=0 39 | prec:coarsest_sweeps=1 40 | prec:smoother(smooth)=BLOCK_JACOBI 41 | 42 | smooth:relaxation_factor=0.9 43 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe550_GPU/config/poisson_solver.info: -------------------------------------------------------------------------------- 1 | config_version=2 2 | 3 | communicator=MPI 4 | min_rows_latency_hiding=-1 5 | matrix_consolidation_lower_threshold=0 6 | matrix_consolidation_upper_threshold=1000 7 | fine_level_consolidation=0 8 | determinism_flag=1 9 | 10 | solver(solv)=PCG 11 | solv:max_iters=1000 12 | solv:monitor_residual=1 13 | solv:convergence=ABSOLUTE 14 | solv:tolerance=1.0E-06 15 | solv:norm=L2 16 | solv:print_solve_stats=0 17 | solv:store_res_history=1 18 | solv:print_grid_stats=0 19 | solv:obtain_timings=0 20 | solv:preconditioner(prec)=AMG 21 | 22 | prec:algorithm=CLASSICAL 23 | prec:max_iters=1 24 | prec:cycle=V 25 | prec:presweeps=1 26 | prec:postsweeps=1 27 | prec:max_levels=100 28 | prec:min_coarse_rows=2 29 | prec:interp_max_elements=-1 30 | prec:interp_truncation_factor=1.1 31 | prec:interpolator=D2 32 | prec:max_row_sum=1.1 33 | prec:selector=PMIS 34 | prec:strength=AHAT 35 | prec:strength_threshold=0.25 36 | prec:coarse_solver(c_solver)=DENSE_LU_SOLVER 37 | prec:dense_lu_num_rows=128 38 | prec:dense_lu_max_rows=0 39 | prec:coarsest_sweeps=1 40 | prec:smoother(smooth)=BLOCK_JACOBI 41 | 42 | smooth:relaxation_factor=0.9 43 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100_GPU/config/poisson_solver.info: -------------------------------------------------------------------------------- 1 | config_version=2 2 | 3 | communicator=MPI 4 | min_rows_latency_hiding=-1 5 | matrix_consolidation_lower_threshold=0 6 | matrix_consolidation_upper_threshold=1000 7 | fine_level_consolidation=0 8 | determinism_flag=1 9 | 10 | solver(solv)=PCG 11 | solv:max_iters=1000 12 | solv:monitor_residual=1 13 | solv:convergence=ABSOLUTE 14 | solv:tolerance=1.0E-06 15 | solv:norm=L2 16 | solv:print_solve_stats=0 17 | solv:store_res_history=1 18 | solv:print_grid_stats=0 19 | solv:obtain_timings=0 20 | solv:preconditioner(prec)=AMG 21 | 22 | prec:algorithm=CLASSICAL 23 | prec:max_iters=1 24 | prec:cycle=V 25 | prec:presweeps=1 26 | prec:postsweeps=1 27 | prec:max_levels=100 28 | prec:min_coarse_rows=2 29 | prec:interp_max_elements=-1 30 | prec:interp_truncation_factor=1.1 31 | prec:interpolator=D2 32 | prec:max_row_sum=1.1 33 | prec:selector=PMIS 34 | prec:strength=AHAT 35 | prec:strength_threshold=0.25 36 | prec:coarse_solver(c_solver)=DENSE_LU_SOLVER 37 | prec:dense_lu_num_rows=128 38 | prec:dense_lu_max_rows=0 39 | prec:coarsest_sweeps=1 40 | prec:smoother(smooth)=BLOCK_JACOBI 41 | 42 | smooth:relaxation_factor=0.9 43 | -------------------------------------------------------------------------------- /examples/navierstokes/liddrivencavity2dRe100/config.yaml: -------------------------------------------------------------------------------- 1 | mesh: 2 | - direction: x 3 | start: 0.0 4 | subDomains: 5 | - end: 1.0 6 | cells: 32 7 | stretchRatio: 1.0 8 | - direction: y 9 | start: 0.0 10 | subDomains: 11 | - end: 1.0 12 | cells: 32 13 | stretchRatio: 1.0 14 | 15 | flow: 16 | nu: 0.01 17 | initialVelocity: [0.0, 0.0] 18 | boundaryConditions: 19 | - location: xMinus 20 | u: [DIRICHLET, 0.0] 21 | v: [DIRICHLET, 0.0] 22 | - location: xPlus 23 | u: [DIRICHLET, 0.0] 24 | v: [DIRICHLET, 0.0] 25 | - location: yMinus 26 | u: [DIRICHLET, 0.0] 27 | v: [DIRICHLET, 0.0] 28 | - location: yPlus 29 | u: [DIRICHLET, 1.0] 30 | v: [DIRICHLET, 0.0] 31 | 32 | parameters: 33 | dt: 0.01 34 | startStep: 0 35 | nt: 1000 36 | nsave: 1000 37 | nrestart: 1000 38 | convection: ADAMS_BASHFORTH_2 39 | diffusion: CRANK_NICOLSON 40 | velocitySolver: 41 | type: CPU 42 | config: config/velocity_solver.info 43 | poissonSolver: 44 | type: CPU 45 | config: config/poisson_solver.info 46 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100AoA30_GPU/config/poisson_solver.info: -------------------------------------------------------------------------------- 1 | config_version=2 2 | 3 | communicator=MPI 4 | min_rows_latency_hiding=-1 5 | matrix_consolidation_lower_threshold=0 6 | matrix_consolidation_upper_threshold=1000 7 | fine_level_consolidation=0 8 | determinism_flag=1 9 | 10 | solver(solv)=PCG 11 | solv:max_iters=1000 12 | solv:monitor_residual=1 13 | solv:convergence=ABSOLUTE 14 | solv:tolerance=1.0E-06 15 | solv:norm=L2 16 | solv:print_solve_stats=0 17 | solv:store_res_history=1 18 | solv:print_grid_stats=0 19 | solv:obtain_timings=0 20 | solv:preconditioner(prec)=AMG 21 | 22 | prec:algorithm=CLASSICAL 23 | prec:max_iters=1 24 | prec:cycle=V 25 | prec:presweeps=1 26 | prec:postsweeps=1 27 | prec:max_levels=100 28 | prec:min_coarse_rows=2 29 | prec:interp_max_elements=-1 30 | prec:interp_truncation_factor=1.1 31 | prec:interpolator=D2 32 | prec:max_row_sum=1.1 33 | prec:selector=PMIS 34 | prec:strength=AHAT 35 | prec:strength_threshold=0.25 36 | prec:coarse_solver(c_solver)=DENSE_LU_SOLVER 37 | prec:dense_lu_num_rows=128 38 | prec:dense_lu_max_rows=0 39 | prec:coarsest_sweeps=1 40 | prec:smoother(smooth)=BLOCK_JACOBI 41 | 42 | smooth:relaxation_factor=0.9 43 | -------------------------------------------------------------------------------- /examples/decoupledibpm/multicylinders2dRe100_GPU/config/poisson_solver.info: -------------------------------------------------------------------------------- 1 | config_version=2 2 | 3 | communicator=MPI 4 | min_rows_latency_hiding=-1 5 | matrix_consolidation_lower_threshold=0 6 | matrix_consolidation_upper_threshold=1000 7 | fine_level_consolidation=0 8 | determinism_flag=1 9 | 10 | solver(solv)=PCG 11 | solv:max_iters=1000 12 | solv:monitor_residual=1 13 | solv:convergence=ABSOLUTE 14 | solv:tolerance=1.0E-06 15 | solv:norm=L2 16 | solv:print_solve_stats=0 17 | solv:store_res_history=1 18 | solv:print_grid_stats=0 19 | solv:obtain_timings=0 20 | solv:preconditioner(prec)=AMG 21 | 22 | prec:algorithm=CLASSICAL 23 | prec:max_iters=1 24 | prec:cycle=V 25 | prec:presweeps=1 26 | prec:postsweeps=1 27 | prec:max_levels=100 28 | prec:min_coarse_rows=2 29 | prec:interp_max_elements=-1 30 | prec:interp_truncation_factor=1.1 31 | prec:interpolator=D2 32 | prec:max_row_sum=1.1 33 | prec:selector=PMIS 34 | prec:strength=AHAT 35 | prec:strength_threshold=0.25 36 | prec:coarse_solver(c_solver)=DENSE_LU_SOLVER 37 | prec:dense_lu_num_rows=128 38 | prec:dense_lu_max_rows=0 39 | prec:coarsest_sweeps=1 40 | prec:smoother(smooth)=BLOCK_JACOBI 41 | 42 | smooth:relaxation_factor=0.9 43 | -------------------------------------------------------------------------------- /examples/navierstokes/liddrivencavity2dRe1000_GPU/config/poisson_solver.info: -------------------------------------------------------------------------------- 1 | config_version=2 2 | 3 | communicator=MPI 4 | min_rows_latency_hiding=-1 5 | matrix_consolidation_lower_threshold=0 6 | matrix_consolidation_upper_threshold=1000 7 | fine_level_consolidation=0 8 | determinism_flag=1 9 | 10 | solver(solv)=PCG 11 | solv:max_iters=1000 12 | solv:monitor_residual=1 13 | solv:convergence=ABSOLUTE 14 | solv:tolerance=1.0E-06 15 | solv:norm=L2 16 | solv:print_solve_stats=0 17 | solv:store_res_history=1 18 | solv:print_grid_stats=0 19 | solv:obtain_timings=0 20 | solv:preconditioner(prec)=AMG 21 | 22 | prec:algorithm=CLASSICAL 23 | prec:max_iters=1 24 | prec:cycle=V 25 | prec:presweeps=1 26 | prec:postsweeps=1 27 | prec:max_levels=100 28 | prec:min_coarse_rows=2 29 | prec:interp_max_elements=-1 30 | prec:interp_truncation_factor=1.1 31 | prec:interpolator=D2 32 | prec:max_row_sum=1.1 33 | prec:selector=PMIS 34 | prec:strength=AHAT 35 | prec:strength_threshold=0.25 36 | prec:coarse_solver(c_solver)=DENSE_LU_SOLVER 37 | prec:dense_lu_num_rows=128 38 | prec:dense_lu_max_rows=0 39 | prec:coarsest_sweeps=1 40 | prec:smoother(smooth)=BLOCK_JACOBI 41 | 42 | smooth:relaxation_factor=0.9 43 | -------------------------------------------------------------------------------- /examples/api_examples/oscillatingcylinder2dRe100_GPU/config/poisson_solver.info: -------------------------------------------------------------------------------- 1 | config_version=2 2 | 3 | communicator=MPI 4 | min_rows_latency_hiding=-1 5 | matrix_consolidation_lower_threshold=0 6 | matrix_consolidation_upper_threshold=1000 7 | fine_level_consolidation=0 8 | determinism_flag=1 9 | 10 | solver(solv)=PCG 11 | solv:max_iters=1000 12 | solv:monitor_residual=1 13 | solv:convergence=ABSOLUTE 14 | solv:tolerance=1.0E-06 15 | solv:norm=L2 16 | solv:print_solve_stats=0 17 | solv:store_res_history=1 18 | solv:print_grid_stats=0 19 | solv:obtain_timings=0 20 | solv:preconditioner(prec)=AMG 21 | 22 | prec:algorithm=CLASSICAL 23 | prec:max_iters=1 24 | prec:cycle=V 25 | prec:presweeps=1 26 | prec:postsweeps=1 27 | prec:max_levels=100 28 | prec:min_coarse_rows=2 29 | prec:interp_max_elements=-1 30 | prec:interp_truncation_factor=1.1 31 | prec:interpolator=D2 32 | prec:max_row_sum=1.1 33 | prec:selector=PMIS 34 | prec:strength=AHAT 35 | prec:strength_threshold=0.25 36 | prec:coarse_solver(c_solver)=DENSE_LU_SOLVER 37 | prec:dense_lu_num_rows=128 38 | prec:dense_lu_max_rows=0 39 | prec:coarsest_sweeps=1 40 | prec:smoother(smooth)=BLOCK_JACOBI 41 | 42 | smooth:relaxation_factor=0.9 43 | -------------------------------------------------------------------------------- /examples/navierstokes/liddrivencavity2dRe1000/config.yaml: -------------------------------------------------------------------------------- 1 | mesh: 2 | - direction: x 3 | start: 0.0 4 | subDomains: 5 | - end: 1.0 6 | cells: 128 7 | stretchRatio: 1.0 8 | - direction: y 9 | start: 0.0 10 | subDomains: 11 | - end: 1.0 12 | cells: 128 13 | stretchRatio: 1.0 14 | 15 | flow: 16 | nu: 0.001 17 | initialVelocity: [0.0, 0.0] 18 | boundaryConditions: 19 | - location: xMinus 20 | u: [DIRICHLET, 0.0] 21 | v: [DIRICHLET, 0.0] 22 | - location: xPlus 23 | u: [DIRICHLET, 0.0] 24 | v: [DIRICHLET, 0.0] 25 | - location: yMinus 26 | u: [DIRICHLET, 0.0] 27 | v: [DIRICHLET, 0.0] 28 | - location: yPlus 29 | u: [DIRICHLET, 1.0] 30 | v: [DIRICHLET, 0.0] 31 | 32 | parameters: 33 | dt: 0.004 34 | startStep: 0 35 | nt: 10000 36 | nsave: 10000 37 | nrestart: 10000 38 | convection: ADAMS_BASHFORTH_2 39 | diffusion: CRANK_NICOLSON 40 | velocitySolver: 41 | type: CPU 42 | config: config/velocity_solver.info 43 | poissonSolver: 44 | type: CPU 45 | config: config/poisson_solver.info 46 | -------------------------------------------------------------------------------- /examples/navierstokes/liddrivencavity2dRe5000/config.yaml: -------------------------------------------------------------------------------- 1 | mesh: 2 | - direction: x 3 | start: 0.0 4 | subDomains: 5 | - end: 1.0 6 | cells: 192 7 | stretchRatio: 1.0 8 | - direction: y 9 | start: 0.0 10 | subDomains: 11 | - end: 1.0 12 | cells: 192 13 | stretchRatio: 1.0 14 | 15 | flow: 16 | nu: 0.0002 17 | initialVelocity: [0.0, 0.0] 18 | boundaryConditions: 19 | - location: xMinus 20 | u: [DIRICHLET, 0.0] 21 | v: [DIRICHLET, 0.0] 22 | - location: xPlus 23 | u: [DIRICHLET, 0.0] 24 | v: [DIRICHLET, 0.0] 25 | - location: yMinus 26 | u: [DIRICHLET, 0.0] 27 | v: [DIRICHLET, 0.0] 28 | - location: yPlus 29 | u: [DIRICHLET, 1.0] 30 | v: [DIRICHLET, 0.0] 31 | 32 | parameters: 33 | dt: 0.002 34 | startStep: 0 35 | nt: 60000 36 | nsave: 60000 37 | nrestart: 60000 38 | convection: ADAMS_BASHFORTH_2 39 | diffusion: CRANK_NICOLSON 40 | velocitySolver: 41 | type: CPU 42 | config: config/velocity_solver.info 43 | poissonSolver: 44 | type: CPU 45 | config: config/poisson_solver.info 46 | -------------------------------------------------------------------------------- /examples/navierstokes/liddrivencavity2dRe1000_GPU/config.yaml: -------------------------------------------------------------------------------- 1 | mesh: 2 | - direction: x 3 | start: 0.0 4 | subDomains: 5 | - end: 1.0 6 | cells: 128 7 | stretchRatio: 1.0 8 | - direction: y 9 | start: 0.0 10 | subDomains: 11 | - end: 1.0 12 | cells: 128 13 | stretchRatio: 1.0 14 | 15 | flow: 16 | nu: 0.001 17 | initialVelocity: [0.0, 0.0] 18 | boundaryConditions: 19 | - location: xMinus 20 | u: [DIRICHLET, 0.0] 21 | v: [DIRICHLET, 0.0] 22 | - location: xPlus 23 | u: [DIRICHLET, 0.0] 24 | v: [DIRICHLET, 0.0] 25 | - location: yMinus 26 | u: [DIRICHLET, 0.0] 27 | v: [DIRICHLET, 0.0] 28 | - location: yPlus 29 | u: [DIRICHLET, 1.0] 30 | v: [DIRICHLET, 0.0] 31 | 32 | parameters: 33 | dt: 0.004 34 | startStep: 0 35 | nt: 10000 36 | nsave: 10000 37 | nrestart: 10000 38 | convection: ADAMS_BASHFORTH_2 39 | diffusion: CRANK_NICOLSON 40 | velocitySolver: 41 | type: CPU 42 | config: config/velocity_solver.info 43 | poissonSolver: 44 | type: GPU 45 | config: config/poisson_solver.info 46 | -------------------------------------------------------------------------------- /examples/navierstokes/liddrivencavity2dRe3200/config.yaml: -------------------------------------------------------------------------------- 1 | mesh: 2 | - direction: x 3 | start: 0.0 4 | subDomains: 5 | - end: 1.0 6 | cells: 192 7 | stretchRatio: 1.0 8 | - direction: y 9 | start: 0.0 10 | subDomains: 11 | - end: 1.0 12 | cells: 192 13 | stretchRatio: 1.0 14 | 15 | flow: 16 | nu: 0.0003125 17 | initialVelocity: [0.0, 0.0] 18 | boundaryConditions: 19 | - location: xMinus 20 | u: [DIRICHLET, 0.0] 21 | v: [DIRICHLET, 0.0] 22 | - location: xPlus 23 | u: [DIRICHLET, 0.0] 24 | v: [DIRICHLET, 0.0] 25 | - location: yMinus 26 | u: [DIRICHLET, 0.0] 27 | v: [DIRICHLET, 0.0] 28 | - location: yPlus 29 | u: [DIRICHLET, 1.0] 30 | v: [DIRICHLET, 0.0] 31 | 32 | parameters: 33 | dt: 0.002 34 | startStep: 0 35 | nt: 25000 36 | nsave: 25000 37 | nrestart: 25000 38 | convection: ADAMS_BASHFORTH_2 39 | diffusion: CRANK_NICOLSON 40 | velocitySolver: 41 | type: CPU 42 | config: config/velocity_solver.info 43 | poissonSolver: 44 | type: CPU 45 | config: config/poisson_solver.info 46 | -------------------------------------------------------------------------------- /examples/navierstokes/taylorgreenvortex3dRe1600_GPU/config/poisson_solver.info: -------------------------------------------------------------------------------- 1 | config_version=2 2 | 3 | communicator=MPI_DIRECT 4 | min_rows_latency_hiding=-1 5 | matrix_consolidation_lower_threshold=0 6 | matrix_consolidation_upper_threshold=1000 7 | fine_level_consolidation=0 8 | determinism_flag=1 9 | 10 | solver(solv)=PCG 11 | solv:max_iters=1000 12 | solv:monitor_residual=1 13 | solv:convergence=ABSOLUTE 14 | solv:tolerance=1.0E-14 15 | solv:norm=L2 16 | solv:print_solve_stats=0 17 | solv:store_res_history=1 18 | solv:print_grid_stats=0 19 | solv:obtain_timings=0 20 | solv:preconditioner(prec)=AMG 21 | 22 | prec:algorithm=CLASSICAL 23 | prec:max_iters=1 24 | prec:cycle=V 25 | prec:presweeps=1 26 | prec:postsweeps=1 27 | prec:max_levels=100 28 | prec:min_coarse_rows=2 29 | prec:interp_max_elements=-1 30 | prec:interp_truncation_factor=1.1 31 | prec:interpolator=D2 32 | prec:max_row_sum=1.1 33 | prec:selector=PMIS 34 | prec:strength=AHAT 35 | prec:strength_threshold=0.25 36 | prec:coarse_solver(c_solver)=DENSE_LU_SOLVER 37 | prec:dense_lu_num_rows=128 38 | prec:dense_lu_max_rows=0 39 | prec:coarsest_sweeps=1 40 | prec:smoother(smooth)=BLOCK_JACOBI 41 | 42 | smooth:relaxation_factor=0.9 43 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe100_GPU/README.md: -------------------------------------------------------------------------------- 1 | # 2D flow around cylinder (Re=100) 2 | 3 | Run the example using 4 CPU processes and 2 GPUs: 4 | 5 | ``` 6 | export CUDA_VISIBLE_DEVICES=, 7 | mpiexec -np 4 petibm-ibpm -options_left -log_view ascii:view.log 8 | ``` 9 | 10 | The simulation completes in less than 2 hours when using: 11 | - 4 CPU processes (Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz), 12 | - 2 NVIDIA K20 GPU devices. 13 | 14 | Plot the instantaneous force coefficients: 15 | 16 | ``` 17 | python scripts/plotDragCoefficient.py 18 | ``` 19 | 20 | We obtained a mean drag coefficient of 1.3336 and a mean lift coefficient of 21 | 0.0032 (min: -0.3488, max: 0.3487). 22 | 23 | The plot is saved in the sub-folder `figures` of the simulation directory. 24 | 25 | Compute the vorticity field at saved time steps: 26 | 27 | ``` 28 | petibm-vorticity 29 | ``` 30 | 31 | Create XDMF files to visualize the data with VisIt: 32 | 33 | ``` 34 | petibm-createxdmf 35 | ``` 36 | 37 | The XDMF files `p.xmf` (pressure), `u.xmf` (x-velocity), `v.xmf` (y-velocity), 38 | and `wz.xmf` (vorticity) are saved in the simulation directory and can be used 39 | as input files to visualize data with VisIt. 40 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe100_GPU/README.md: -------------------------------------------------------------------------------- 1 | # 2D flow around cylinder (Re=100) 2 | 3 | Run the example using 4 CPU processes and 2 GPUs: 4 | 5 | ``` 6 | export CUDA_VISIBLE_DEVICES=, 7 | mpiexec -np 4 petibm-decoupledibpm -options_left -log_view ascii:view.log 8 | ``` 9 | 10 | The simulation completes in less than an hour when using: 11 | - 4 CPU processes (Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz), 12 | - 2 NVIDIA K20 GPU devices. 13 | 14 | Plot the instantaneous force coefficients: 15 | 16 | ``` 17 | python scripts/plotDragCoefficient.py 18 | ``` 19 | 20 | We obtained a mean drag coefficient of 1.3422 and a mean lift coefficient of 21 | 0.0022 (min: -0.3473, max: 0.3474). 22 | 23 | The plot is saved in the sub-folder `figures` of the simulation directory. 24 | 25 | Compute the vorticity field at saved time steps: 26 | 27 | ``` 28 | petibm-vorticity 29 | ``` 30 | 31 | Create XDMF files to visualize the data with VisIt: 32 | 33 | ``` 34 | petibm-createxdmf 35 | ``` 36 | 37 | The XDMF files `p.xmf` (pressure), `u.xmf` (x-velocity), `v.xmf` (y-velocity), 38 | and `wz.xmf` (vorticity) are saved in the simulation directory and can be used 39 | as input files to visualize data with VisIt. 40 | -------------------------------------------------------------------------------- /examples/navierstokes/convergence/liddrivencavity2dRe100_20/180/config.yaml: -------------------------------------------------------------------------------- 1 | mesh: 2 | - direction: x 3 | start: 0.0 4 | subDomains: 5 | - end: 1.0 6 | cells: 180 7 | stretchRatio: 1.0 8 | - direction: y 9 | start: 0.0 10 | subDomains: 11 | - end: 1.0 12 | cells: 180 13 | stretchRatio: 1.0 14 | 15 | flow: 16 | nu: 0.01 17 | initialVelocity: [0.0, 0.0] 18 | boundaryConditions: 19 | - location: xMinus 20 | u: [DIRICHLET, 0.0] 21 | v: [DIRICHLET, 0.0] 22 | - location: xPlus 23 | u: [DIRICHLET, 0.0] 24 | v: [DIRICHLET, 0.0] 25 | - location: yMinus 26 | u: [DIRICHLET, 0.0] 27 | v: [DIRICHLET, 0.0] 28 | - location: yPlus 29 | u: [DIRICHLET, 1.0] 30 | v: [DIRICHLET, 0.0] 31 | 32 | parameters: 33 | dt: 5.0E-04 34 | startStep: 0 35 | nt: 500 36 | nsave: 500 37 | nrestart: 500 38 | convection: EULER_EXPLICIT 39 | diffusion: EULER_IMPLICIT 40 | velocitySolver: 41 | type: CPU 42 | config: ../configs/solversPetscOptions.info 43 | poissonSolver: 44 | type: CPU 45 | config: ../configs/solversPetscOptions.info 46 | -------------------------------------------------------------------------------- /examples/navierstokes/convergence/liddrivencavity2dRe100_20/20/config.yaml: -------------------------------------------------------------------------------- 1 | mesh: 2 | - direction: x 3 | start: 0.0 4 | subDomains: 5 | - end: 1.0 6 | cells: 20 7 | stretchRatio: 1.0 8 | - direction: y 9 | start: 0.0 10 | subDomains: 11 | - end: 1.0 12 | cells: 20 13 | stretchRatio: 1.0 14 | 15 | flow: 16 | nu: 0.01 17 | initialVelocity: [0.0, 0.0] 18 | boundaryConditions: 19 | - location: xMinus 20 | u: [DIRICHLET, 0.0] 21 | v: [DIRICHLET, 0.0] 22 | - location: xPlus 23 | u: [DIRICHLET, 0.0] 24 | v: [DIRICHLET, 0.0] 25 | - location: yMinus 26 | u: [DIRICHLET, 0.0] 27 | v: [DIRICHLET, 0.0] 28 | - location: yPlus 29 | u: [DIRICHLET, 1.0] 30 | v: [DIRICHLET, 0.0] 31 | 32 | parameters: 33 | dt: 5.0E-04 34 | startStep: 0 35 | nt: 500 36 | nsave: 500 37 | nrestart: 500 38 | convection: EULER_EXPLICIT 39 | diffusion: EULER_IMPLICIT 40 | velocitySolver: 41 | type: CPU 42 | config: ../configs/solversPetscOptions.info 43 | poissonSolver: 44 | type: CPU 45 | config: ../configs/solversPetscOptions.info 46 | -------------------------------------------------------------------------------- /examples/navierstokes/convergence/liddrivencavity2dRe100_20/540/config.yaml: -------------------------------------------------------------------------------- 1 | mesh: 2 | - direction: x 3 | start: 0.0 4 | subDomains: 5 | - end: 1.0 6 | cells: 540 7 | stretchRatio: 1.0 8 | - direction: y 9 | start: 0.0 10 | subDomains: 11 | - end: 1.0 12 | cells: 540 13 | stretchRatio: 1.0 14 | 15 | flow: 16 | nu: 0.01 17 | initialVelocity: [0.0, 0.0] 18 | boundaryConditions: 19 | - location: xMinus 20 | u: [DIRICHLET, 0.0] 21 | v: [DIRICHLET, 0.0] 22 | - location: xPlus 23 | u: [DIRICHLET, 0.0] 24 | v: [DIRICHLET, 0.0] 25 | - location: yMinus 26 | u: [DIRICHLET, 0.0] 27 | v: [DIRICHLET, 0.0] 28 | - location: yPlus 29 | u: [DIRICHLET, 1.0] 30 | v: [DIRICHLET, 0.0] 31 | 32 | parameters: 33 | dt: 5.0E-04 34 | startStep: 0 35 | nt: 500 36 | nsave: 500 37 | nrestart: 500 38 | convection: EULER_EXPLICIT 39 | diffusion: EULER_IMPLICIT 40 | velocitySolver: 41 | type: CPU 42 | config: ../configs/solversPetscOptions.info 43 | poissonSolver: 44 | type: CPU 45 | config: ../configs/solversPetscOptions.info 46 | -------------------------------------------------------------------------------- /examples/navierstokes/convergence/liddrivencavity2dRe100_20/60/config.yaml: -------------------------------------------------------------------------------- 1 | mesh: 2 | - direction: x 3 | start: 0.0 4 | subDomains: 5 | - end: 1.0 6 | cells: 60 7 | stretchRatio: 1.0 8 | - direction: y 9 | start: 0.0 10 | subDomains: 11 | - end: 1.0 12 | cells: 60 13 | stretchRatio: 1.0 14 | 15 | flow: 16 | nu: 0.01 17 | initialVelocity: [0.0, 0.0] 18 | boundaryConditions: 19 | - location: xMinus 20 | u: [DIRICHLET, 0.0] 21 | v: [DIRICHLET, 0.0] 22 | - location: xPlus 23 | u: [DIRICHLET, 0.0] 24 | v: [DIRICHLET, 0.0] 25 | - location: yMinus 26 | u: [DIRICHLET, 0.0] 27 | v: [DIRICHLET, 0.0] 28 | - location: yPlus 29 | u: [DIRICHLET, 1.0] 30 | v: [DIRICHLET, 0.0] 31 | 32 | parameters: 33 | dt: 5.0E-04 34 | startStep: 0 35 | nt: 500 36 | nsave: 500 37 | nrestart: 500 38 | convection: EULER_EXPLICIT 39 | diffusion: EULER_IMPLICIT 40 | velocitySolver: 41 | type: CPU 42 | config: ../configs/solversPetscOptions.info 43 | poissonSolver: 44 | type: CPU 45 | config: ../configs/solversPetscOptions.info 46 | -------------------------------------------------------------------------------- /examples/navierstokes/convergence/liddrivencavity2dRe100_30/270/config.yaml: -------------------------------------------------------------------------------- 1 | mesh: 2 | - direction: x 3 | start: 0.0 4 | subDomains: 5 | - end: 1.0 6 | cells: 270 7 | stretchRatio: 1.0 8 | - direction: y 9 | start: 0.0 10 | subDomains: 11 | - end: 1.0 12 | cells: 270 13 | stretchRatio: 1.0 14 | 15 | flow: 16 | nu: 0.01 17 | initialVelocity: [0.0, 0.0] 18 | boundaryConditions: 19 | - location: xMinus 20 | u: [DIRICHLET, 0.0] 21 | v: [DIRICHLET, 0.0] 22 | - location: xPlus 23 | u: [DIRICHLET, 0.0] 24 | v: [DIRICHLET, 0.0] 25 | - location: yMinus 26 | u: [DIRICHLET, 0.0] 27 | v: [DIRICHLET, 0.0] 28 | - location: yPlus 29 | u: [DIRICHLET, 1.0] 30 | v: [DIRICHLET, 0.0] 31 | 32 | parameters: 33 | dt: 5.0E-04 34 | startStep: 0 35 | nt: 500 36 | nsave: 500 37 | nrestart: 500 38 | convection: EULER_EXPLICIT 39 | diffusion: EULER_IMPLICIT 40 | velocitySolver: 41 | type: CPU 42 | config: ../configs/solversPetscOptions.info 43 | poissonSolver: 44 | type: CPU 45 | config: ../configs/solversPetscOptions.info 46 | -------------------------------------------------------------------------------- /examples/navierstokes/convergence/liddrivencavity2dRe100_30/30/config.yaml: -------------------------------------------------------------------------------- 1 | mesh: 2 | - direction: x 3 | start: 0.0 4 | subDomains: 5 | - end: 1.0 6 | cells: 30 7 | stretchRatio: 1.0 8 | - direction: y 9 | start: 0.0 10 | subDomains: 11 | - end: 1.0 12 | cells: 30 13 | stretchRatio: 1.0 14 | 15 | flow: 16 | nu: 0.01 17 | initialVelocity: [0.0, 0.0] 18 | boundaryConditions: 19 | - location: xMinus 20 | u: [DIRICHLET, 0.0] 21 | v: [DIRICHLET, 0.0] 22 | - location: xPlus 23 | u: [DIRICHLET, 0.0] 24 | v: [DIRICHLET, 0.0] 25 | - location: yMinus 26 | u: [DIRICHLET, 0.0] 27 | v: [DIRICHLET, 0.0] 28 | - location: yPlus 29 | u: [DIRICHLET, 1.0] 30 | v: [DIRICHLET, 0.0] 31 | 32 | parameters: 33 | dt: 5.0E-04 34 | startStep: 0 35 | nt: 500 36 | nsave: 500 37 | nrestart: 500 38 | convection: EULER_EXPLICIT 39 | diffusion: EULER_IMPLICIT 40 | velocitySolver: 41 | type: CPU 42 | config: ../configs/solversPetscOptions.info 43 | poissonSolver: 44 | type: CPU 45 | config: ../configs/solversPetscOptions.info 46 | -------------------------------------------------------------------------------- /examples/navierstokes/convergence/liddrivencavity2dRe100_30/810/config.yaml: -------------------------------------------------------------------------------- 1 | mesh: 2 | - direction: x 3 | start: 0.0 4 | subDomains: 5 | - end: 1.0 6 | cells: 810 7 | stretchRatio: 1.0 8 | - direction: y 9 | start: 0.0 10 | subDomains: 11 | - end: 1.0 12 | cells: 810 13 | stretchRatio: 1.0 14 | 15 | flow: 16 | nu: 0.01 17 | initialVelocity: [0.0, 0.0] 18 | boundaryConditions: 19 | - location: xMinus 20 | u: [DIRICHLET, 0.0] 21 | v: [DIRICHLET, 0.0] 22 | - location: xPlus 23 | u: [DIRICHLET, 0.0] 24 | v: [DIRICHLET, 0.0] 25 | - location: yMinus 26 | u: [DIRICHLET, 0.0] 27 | v: [DIRICHLET, 0.0] 28 | - location: yPlus 29 | u: [DIRICHLET, 1.0] 30 | v: [DIRICHLET, 0.0] 31 | 32 | parameters: 33 | dt: 5.0E-04 34 | startStep: 0 35 | nt: 500 36 | nsave: 500 37 | nrestart: 500 38 | convection: EULER_EXPLICIT 39 | diffusion: EULER_IMPLICIT 40 | velocitySolver: 41 | type: CPU 42 | config: ../configs/solversPetscOptions.info 43 | poissonSolver: 44 | type: CPU 45 | config: ../configs/solversPetscOptions.info 46 | -------------------------------------------------------------------------------- /examples/navierstokes/convergence/liddrivencavity2dRe100_30/90/config.yaml: -------------------------------------------------------------------------------- 1 | mesh: 2 | - direction: x 3 | start: 0.0 4 | subDomains: 5 | - end: 1.0 6 | cells: 90 7 | stretchRatio: 1.0 8 | - direction: y 9 | start: 0.0 10 | subDomains: 11 | - end: 1.0 12 | cells: 90 13 | stretchRatio: 1.0 14 | 15 | flow: 16 | nu: 0.01 17 | initialVelocity: [0.0, 0.0] 18 | boundaryConditions: 19 | - location: xMinus 20 | u: [DIRICHLET, 0.0] 21 | v: [DIRICHLET, 0.0] 22 | - location: xPlus 23 | u: [DIRICHLET, 0.0] 24 | v: [DIRICHLET, 0.0] 25 | - location: yMinus 26 | u: [DIRICHLET, 0.0] 27 | v: [DIRICHLET, 0.0] 28 | - location: yPlus 29 | u: [DIRICHLET, 1.0] 30 | v: [DIRICHLET, 0.0] 31 | 32 | parameters: 33 | dt: 5.0E-04 34 | startStep: 0 35 | nt: 500 36 | nsave: 500 37 | nrestart: 500 38 | convection: EULER_EXPLICIT 39 | diffusion: EULER_IMPLICIT 40 | velocitySolver: 41 | type: CPU 42 | config: ../configs/solversPetscOptions.info 43 | poissonSolver: 44 | type: CPU 45 | config: ../configs/solversPetscOptions.info 46 | -------------------------------------------------------------------------------- /examples/api_examples/README.md: -------------------------------------------------------------------------------- 1 | # API examples 2 | 3 | This folder contains examples on how to use the PetIBM API to build flow solvers. 4 | The examples provided here are just for demonstration purpose. 5 | While they may still be used to conduct flow simulations, their functionalities are limited. 6 | 7 | Solvers with more complete features can be found in the `applications` folder under the PetIBM directory. 8 | (Binary executables for those solvers can be found in the `bin` folder of the PetIBM installation directory.) 9 | 10 | Contents of the present folder: 11 | * `liddrivencavity2d`: a basic Navier-Stokes solver using a projection method (Perot, 1993); 12 | * `oscillatingcylinder2dRe100_GPU`: a Navier-Stokes solver using a decoupled immersed-boundary projection method (Li et al., 2016) to compute the 2D flow around an inline-oscillating cylinder (Poisson system solved on GPU devices). 13 | 14 | 15 | __References:__ 16 | 17 | * Li, R. Y., Xie, C. M., Huang, W. X., & Xu, C. X. (2016). An efficient immersed boundary projection method for flow over complex/moving boundaries. Computers & Fluids, 140, 122-135. 18 | * Perot, J. B. (1993). An analysis of the fractional step method. Journal of Computational Physics, 108(1), 51-58. -------------------------------------------------------------------------------- /examples/api_examples/liddrivencavity2d/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.18) 2 | project(liddrivencavity2d) 3 | 4 | # path to petibm installation 5 | set(PETIBM_DIR "$ENV{PETIBM_DIR}" CACHE PATH "The path to PetIBM installation.") 6 | set(CMAKE_PREFIX_PATH ${PETIBM_DIR} ${CMAKE_PREFIX_PATH}) 7 | 8 | # needs explicitly use MPI 9 | find_package(MPI REQUIRED) 10 | 11 | # find petibm 12 | message(CHECK_START "Finding petibm") 13 | find_package(petibm 0.5.4 REQUIRED) 14 | message(CHECK_PASS "done") 15 | 16 | # add executable 17 | add_executable(liddrivencavity2d main.cpp) 18 | 19 | # dependencies to link against 20 | target_link_libraries(liddrivencavity2d PRIVATE MPI::MPI_CXX petibm::petibm) 21 | 22 | # copy the case configuration/post-processing files to the build folder 23 | add_custom_command( 24 | TARGET liddrivencavity2d 25 | POST_BUILD 26 | COMMAND ${CMAKE_COMMAND} -E 27 | copy ${CMAKE_CURRENT_SOURCE_DIR}/config.yaml ${CMAKE_CURRENT_BINARY_DIR} 28 | COMMAND ${CMAKE_COMMAND} -E 29 | copy ${CMAKE_CURRENT_SOURCE_DIR}/postprocessing.xmf ${CMAKE_CURRENT_BINARY_DIR} 30 | COMMAND ${CMAKE_COMMAND} -E 31 | copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/config ${CMAKE_CURRENT_BINARY_DIR}/config 32 | ) 33 | -------------------------------------------------------------------------------- /examples/data/koumoutsakos_leonard_1995_cylinder_dragCoefficientRe3000.dat: -------------------------------------------------------------------------------- 1 | # Drag coefficient over an impulsively started cylinder at Re=3000 2 | # Koumoutsakos and Leonard (1995) 3 | # High-resoluation simulations of the flow 4 | # around an impulsively started cylinder using vortex methods 5 | 0.03102 0.85895 6 | 0.04964 0.73851 7 | 0.06825 0.64025 8 | 0.10548 0.54517 9 | 0.16132 0.45642 10 | 0.24199 0.38669 11 | 0.34747 0.33914 12 | 0.47777 0.31379 13 | 0.60807 0.30745 14 | 0.76319 0.32647 15 | 0.92451 0.36133 16 | 1.04240 0.39937 17 | 1.18511 0.45325 18 | 1.31541 0.51664 19 | 1.43330 0.58637 20 | 1.57601 0.67512 21 | 1.71251 0.77021 22 | 1.84281 0.86212 23 | 1.96691 0.94453 24 | 2.06618 0.99842 25 | 2.19028 1.05547 26 | 2.40124 1.11569 27 | 2.61220 1.14105 28 | 2.74871 1.15055 29 | 2.85419 1.16006 30 | 2.95346 1.18225 31 | 3.05895 1.21395 32 | 3.17063 1.25832 33 | 3.26370 1.29952 34 | 3.38780 1.35024 35 | 3.48707 1.38827 36 | 3.58014 1.41046 37 | 3.67942 1.42314 38 | 3.77870 1.41997 39 | 3.91520 1.39778 40 | 4.10755 1.35024 41 | 4.30610 1.31220 42 | 4.47983 1.28051 43 | 4.71562 1.23613 44 | 4.92658 1.20444 45 | 5.11892 1.17908 46 | 5.27404 1.15372 47 | 5.40434 1.12520 48 | 5.52223 1.09667 49 | 5.66494 1.06498 50 | 5.77663 1.04913 51 | 5.89452 1.03962 52 | 5.99380 1.03645 -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100AoA30_GPU/README.md: -------------------------------------------------------------------------------- 1 | # 3D flow around inclined flat plate (Re=100, AR=2, AoA=30deg) 2 | 3 | Run the example using 4 CPU processes and 1 GPU: 4 | 5 | ``` 6 | export CUDA_VISIBLE_DEVICES= 7 | mpiexec -np 4 petibm-decoupledibpm -options_left -log_view ascii:view.log 8 | ``` 9 | 10 | The simulation completes in less than 20 minutes when using: 11 | - 4 CPU processes (Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz), 12 | - 1 NVIDIA K40 GPU device. 13 | 14 | Plot the instantaneous force coefficients: 15 | 16 | ``` 17 | python scripts/plotDragCoefficient.py 18 | ``` 19 | 20 | We obtained a mean drag coefficient of 0.7393 and a mean lift coefficient of 21 | 0.7059. 22 | 23 | The plot is saved in the sub-folder `figures` of the simulation directory. 24 | 25 | Compute the vorticity field at saved time steps: 26 | 27 | ``` 28 | petibm-vorticity 29 | ``` 30 | 31 | Create XDMF files to visualize the data with VisIt: 32 | 33 | ``` 34 | petibm-createxdmf 35 | ``` 36 | 37 | The XDMF files `p.xmf` for the pressure, `u.xmf`, `v.xmf`, and `w.xmf` for the 38 | velocity components, and `wx.xmf`, `wy.xmf`, and `wz.xmf` for the vorticity 39 | components are saved in the simulation directory and can be used as input files 40 | to visualize data with VisIt. 41 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100_GPU/README.md: -------------------------------------------------------------------------------- 1 | # 3D flow around inclined flat plate (Re=100, AR=2) 2 | 3 | Run the example using 1 GPU: 4 | 5 | ``` 6 | export CUDA_VISIBLE_DEVICES= 7 | # Declare list of angles of attack to run 8 | angles=(0 10 20 30 40 50 60 70 80 90) 9 | for angle in ${angles[@]}; do 10 | echo "*** Angle of attack: $angle degrees ***" 11 | # Generate immersed boundary points 12 | python "AoA$angle/scripts/createBody.py" 13 | # Run PetIBM 14 | mpiexec -np 4 petibm-decoupledibpm \ 15 | -directory "AoA$angle" \ 16 | -options_left \ 17 | -log_view ascii:"AoA$angle/view.log" 18 | done 19 | ``` 20 | 21 | Each simulation completes in about 8 minutes when using: 22 | - 4 CPU processes (Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz), 23 | - 1 NVIDIA K40 GPU device. 24 | 25 | Plot the instantaneous force coefficients and compare with the experimental 26 | results from Taira et al. (2007): 27 | 28 | ``` 29 | python scripts/plotDragCoefficient.py 30 | ``` 31 | 32 | The figure will be saved in the sub-folder `figures`. 33 | 34 | _References:_ 35 | * Taira, K., Dickson, W. B., Colonius, T., Dickinson, M. H., & Rowley, C. W. (2007). "Unsteadiness in flow over a flat plate at angle-of-attack at low Reynolds numbers." AIAA Paper, 710, 2007. 36 | -------------------------------------------------------------------------------- /examples/navierstokes/taylorgreenvortex2dRe100/config/poisson_solver.info: -------------------------------------------------------------------------------- 1 | # Poisson solver: prefix `-poisson_` 2 | -poisson_ksp_type cg 3 | -poisson_ksp_atol 1.0E-14 4 | -poisson_ksp_rtol 0.0 5 | -poisson_ksp_max_it 20000 6 | 7 | -poisson_pc_type hypre 8 | -poisson_pc_hypre_type boomeramg 9 | -poisson_pc_hypre_boomeramg_cycle_type V 10 | -poisson_pc_hypre_boomeramg_max_levels 100 11 | -poisson_pc_hypre_boomeramg_max_iter 1 12 | -poisson_pc_hypre_boomeramg_tol 0.0 13 | -poisson_pc_hypre_boomeramg_truncfactor 0.0 14 | -poisson_pc_hypre_boomeramg_P_max 0 15 | -poisson_pc_hypre_boomeramg_agg_nl 0 16 | -poisson_pc_hypre_boomeramg_agg_num_paths 1 17 | -poisson_pc_hypre_boomeramg_strong_threshold 0.25 18 | -poisson_pc_hypre_boomeramg_max_row_sum 1.0 19 | -poisson_pc_hypre_boomeramg_grid_sweeps_down 1 20 | -poisson_pc_hypre_boomeramg_grid_sweeps_up 1 21 | -poisson_pc_hypre_boomeramg_grid_sweeps_coarse 1 22 | -poisson_pc_hypre_boomeramg_relax_type_all symmetric-SOR/Jacobi 23 | -poisson_pc_hypre_boomeramg_relax_type_coarse symmetric-SOR/Jacobi 24 | -poisson_pc_hypre_boomeramg_relax_weight_all 1.0 25 | -poisson_pc_hypre_boomeramg_outer_relax_weight_all 1.0 26 | -poisson_pc_hypre_boomeramg_measure_type local 27 | -poisson_pc_hypre_boomeramg_coarsen_type HMIS 28 | -poisson_pc_hypre_boomeramg_interp_type ext+i-cc 29 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100AoA30_GPU/scripts/createBody.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create a flat plate of length 1.0 with aspect ratio 2.0 and a 30-degree 3 | inclination. 4 | The plate is discretized with spacing 0.04 in the x-y plane and with spacing 5 | 0.04 along the z-direction. 6 | """ 7 | 8 | import math 9 | import pathlib 10 | import numpy 11 | 12 | 13 | # Flat-plate's parameters. 14 | L = 1.0 # chord length 15 | AR = 2.0 # aspect ratio 16 | xc, yc, zc = 0.0, 0.0, 0.0 # center's coordinates 17 | aoa = 30.0 # angle of inclination in degrees 18 | ds = 0.04 # mesh spacing 19 | 20 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 21 | 22 | # Generate coordinates of the flat plate. 23 | n = math.ceil(L / ds) 24 | s = numpy.linspace(xc - L / 2, xc + L / 2, num=n + 1) 25 | 26 | x = xc + numpy.cos(numpy.radians(-aoa)) * s 27 | y = yc + numpy.sin(numpy.radians(-aoa)) * s 28 | 29 | nz = math.ceil(L * AR / ds) 30 | z = numpy.linspace(zc - L * AR / 2, zc + L * AR / 2, num=nz + 1) 31 | 32 | # Write coordinates into file. 33 | filepath = simu_dir / 'flatplate.body' 34 | with open(filepath, 'w') as outfile: 35 | outfile.write('{}\n'.format(x.size * z.size)) 36 | for zi in z: 37 | with open(filepath, 'ab') as outfile: 38 | numpy.savetxt(outfile, numpy.c_[x, y, zi * numpy.ones(x.size)]) 39 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100_GPU/AoA0/scripts/createBody.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create a flat plate of length 1.0 with aspect ratio 2.0 and a 0-degree 3 | inclination. 4 | The plate is discretized with spacing 0.04 in the x-y plane and with spacing 5 | 0.04 along the z-direction. 6 | """ 7 | 8 | import math 9 | import pathlib 10 | import numpy 11 | 12 | 13 | # Flat-plate's parameters. 14 | L = 1.0 # chord length 15 | AR = 2.0 # aspect ratio 16 | xc, yc, zc = 0.0, 0.0, 0.0 # center's coordinates 17 | aoa = 0.0 # angle of inclination in degrees 18 | ds = 0.04 # mesh spacing 19 | 20 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 21 | 22 | # Generate coordinates of the flat plate. 23 | n = math.ceil(L / ds) 24 | s = numpy.linspace(xc - L / 2, xc + L / 2, num=n + 1) 25 | 26 | x = xc + numpy.cos(numpy.radians(-aoa)) * s 27 | y = yc + numpy.sin(numpy.radians(-aoa)) * s 28 | 29 | nz = math.ceil(L * AR / ds) 30 | z = numpy.linspace(zc - L * AR / 2, zc + L * AR / 2, num=nz + 1) 31 | 32 | # Write coordinates into file. 33 | filepath = simu_dir / 'flatplateAoA{}.body'.format(aoa) 34 | with open(filepath, 'w') as outfile: 35 | outfile.write('{}\n'.format(x.size * z.size)) 36 | for zi in z: 37 | with open(filepath, 'ab') as outfile: 38 | numpy.savetxt(outfile, numpy.c_[x, y, zi * numpy.ones(x.size)]) 39 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100_GPU/AoA10/scripts/createBody.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create a flat plate of length 1.0 with aspect ratio 2.0 and a 10-degree 3 | inclination. 4 | The plate is discretized with spacing 0.04 in the x-y plane and with spacing 5 | 0.04 along the z-direction. 6 | """ 7 | 8 | import math 9 | import pathlib 10 | import numpy 11 | 12 | 13 | # Flat-plate's parameters. 14 | L = 1.0 # chord length 15 | AR = 2.0 # aspect ratio 16 | xc, yc, zc = 0.0, 0.0, 0.0 # center's coordinates 17 | aoa = 10.0 # angle of inclination in degrees 18 | ds = 0.04 # mesh spacing 19 | 20 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 21 | 22 | # Generate coordinates of the flat plate. 23 | n = math.ceil(L / ds) 24 | s = numpy.linspace(xc - L / 2, xc + L / 2, num=n + 1) 25 | 26 | x = xc + numpy.cos(numpy.radians(-aoa)) * s 27 | y = yc + numpy.sin(numpy.radians(-aoa)) * s 28 | 29 | nz = math.ceil(L * AR / ds) 30 | z = numpy.linspace(zc - L * AR / 2, zc + L * AR / 2, num=nz + 1) 31 | 32 | # Write coordinates into file. 33 | filepath = simu_dir / 'flatplateAoA{}.body'.format(aoa) 34 | with open(filepath, 'w') as outfile: 35 | outfile.write('{}\n'.format(x.size * z.size)) 36 | for zi in z: 37 | with open(filepath, 'ab') as outfile: 38 | numpy.savetxt(outfile, numpy.c_[x, y, zi * numpy.ones(x.size)]) 39 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100_GPU/AoA20/scripts/createBody.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create a flat plate of length 1.0 with aspect ratio 2.0 and a 20-degree 3 | inclination. 4 | The plate is discretized with spacing 0.04 in the x-y plane and with spacing 5 | 0.04 along the z-direction. 6 | """ 7 | 8 | import math 9 | import pathlib 10 | import numpy 11 | 12 | 13 | # Flat-plate's parameters. 14 | L = 1.0 # chord length 15 | AR = 2.0 # aspect ratio 16 | xc, yc, zc = 0.0, 0.0, 0.0 # center's coordinates 17 | aoa = 20.0 # angle of inclination in degrees 18 | ds = 0.04 # mesh spacing 19 | 20 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 21 | 22 | # Generate coordinates of the flat plate. 23 | n = math.ceil(L / ds) 24 | s = numpy.linspace(xc - L / 2, xc + L / 2, num=n + 1) 25 | 26 | x = xc + numpy.cos(numpy.radians(-aoa)) * s 27 | y = yc + numpy.sin(numpy.radians(-aoa)) * s 28 | 29 | nz = math.ceil(L * AR / ds) 30 | z = numpy.linspace(zc - L * AR / 2, zc + L * AR / 2, num=nz + 1) 31 | 32 | # Write coordinates into file. 33 | filepath = simu_dir / 'flatplateAoA{}.body'.format(aoa) 34 | with open(filepath, 'w') as outfile: 35 | outfile.write('{}\n'.format(x.size * z.size)) 36 | for zi in z: 37 | with open(filepath, 'ab') as outfile: 38 | numpy.savetxt(outfile, numpy.c_[x, y, zi * numpy.ones(x.size)]) 39 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100_GPU/AoA30/scripts/createBody.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create a flat plate of length 1.0 with aspect ratio 2.0 and a 30-degree 3 | inclination. 4 | The plate is discretized with spacing 0.04 in the x-y plane and with spacing 5 | 0.04 along the z-direction. 6 | """ 7 | 8 | import math 9 | import pathlib 10 | import numpy 11 | 12 | 13 | # Flat-plate's parameters. 14 | L = 1.0 # chord length 15 | AR = 2.0 # aspect ratio 16 | xc, yc, zc = 0.0, 0.0, 0.0 # center's coordinates 17 | aoa = 30.0 # angle of inclination in degrees 18 | ds = 0.04 # mesh spacing 19 | 20 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 21 | 22 | # Generate coordinates of the flat plate. 23 | n = math.ceil(L / ds) 24 | s = numpy.linspace(xc - L / 2, xc + L / 2, num=n + 1) 25 | 26 | x = xc + numpy.cos(numpy.radians(-aoa)) * s 27 | y = yc + numpy.sin(numpy.radians(-aoa)) * s 28 | 29 | nz = math.ceil(L * AR / ds) 30 | z = numpy.linspace(zc - L * AR / 2, zc + L * AR / 2, num=nz + 1) 31 | 32 | # Write coordinates into file. 33 | filepath = simu_dir / 'flatplateAoA{}.body'.format(aoa) 34 | with open(filepath, 'w') as outfile: 35 | outfile.write('{}\n'.format(x.size * z.size)) 36 | for zi in z: 37 | with open(filepath, 'ab') as outfile: 38 | numpy.savetxt(outfile, numpy.c_[x, y, zi * numpy.ones(x.size)]) 39 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100_GPU/AoA40/scripts/createBody.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create a flat plate of length 1.0 with aspect ratio 2.0 and a 40-degree 3 | inclination. 4 | The plate is discretized with spacing 0.04 in the x-y plane and with spacing 5 | 0.04 along the z-direction. 6 | """ 7 | 8 | import math 9 | import pathlib 10 | import numpy 11 | 12 | 13 | # Flat-plate's parameters. 14 | L = 1.0 # chord length 15 | AR = 2.0 # aspect ratio 16 | xc, yc, zc = 0.0, 0.0, 0.0 # center's coordinates 17 | aoa = 40.0 # angle of inclination in degrees 18 | ds = 0.04 # mesh spacing 19 | 20 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 21 | 22 | # Generate coordinates of the flat plate. 23 | n = math.ceil(L / ds) 24 | s = numpy.linspace(xc - L / 2, xc + L / 2, num=n + 1) 25 | 26 | x = xc + numpy.cos(numpy.radians(-aoa)) * s 27 | y = yc + numpy.sin(numpy.radians(-aoa)) * s 28 | 29 | nz = math.ceil(L * AR / ds) 30 | z = numpy.linspace(zc - L * AR / 2, zc + L * AR / 2, num=nz + 1) 31 | 32 | # Write coordinates into file. 33 | filepath = simu_dir / 'flatplateAoA{}.body'.format(aoa) 34 | with open(filepath, 'w') as outfile: 35 | outfile.write('{}\n'.format(x.size * z.size)) 36 | for zi in z: 37 | with open(filepath, 'ab') as outfile: 38 | numpy.savetxt(outfile, numpy.c_[x, y, zi * numpy.ones(x.size)]) 39 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100_GPU/AoA50/scripts/createBody.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create a flat plate of length 1.0 with aspect ratio 2.0 and a 50-degree 3 | inclination. 4 | The plate is discretized with spacing 0.04 in the x-y plane and with spacing 5 | 0.04 along the z-direction. 6 | """ 7 | 8 | import math 9 | import pathlib 10 | import numpy 11 | 12 | 13 | # Flat-plate's parameters. 14 | L = 1.0 # chord length 15 | AR = 2.0 # aspect ratio 16 | xc, yc, zc = 0.0, 0.0, 0.0 # center's coordinates 17 | aoa = 50.0 # angle of inclination in degrees 18 | ds = 0.04 # mesh spacing 19 | 20 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 21 | 22 | # Generate coordinates of the flat plate. 23 | n = math.ceil(L / ds) 24 | s = numpy.linspace(xc - L / 2, xc + L / 2, num=n + 1) 25 | 26 | x = xc + numpy.cos(numpy.radians(-aoa)) * s 27 | y = yc + numpy.sin(numpy.radians(-aoa)) * s 28 | 29 | nz = math.ceil(L * AR / ds) 30 | z = numpy.linspace(zc - L * AR / 2, zc + L * AR / 2, num=nz + 1) 31 | 32 | # Write coordinates into file. 33 | filepath = simu_dir / 'flatplateAoA{}.body'.format(aoa) 34 | with open(filepath, 'w') as outfile: 35 | outfile.write('{}\n'.format(x.size * z.size)) 36 | for zi in z: 37 | with open(filepath, 'ab') as outfile: 38 | numpy.savetxt(outfile, numpy.c_[x, y, zi * numpy.ones(x.size)]) 39 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100_GPU/AoA60/scripts/createBody.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create a flat plate of length 1.0 with aspect ratio 2.0 and a 60-degree 3 | inclination. 4 | The plate is discretized with spacing 0.04 in the x-y plane and with spacing 5 | 0.04 along the z-direction. 6 | """ 7 | 8 | import math 9 | import pathlib 10 | import numpy 11 | 12 | 13 | # Flat-plate's parameters. 14 | L = 1.0 # chord length 15 | AR = 2.0 # aspect ratio 16 | xc, yc, zc = 0.0, 0.0, 0.0 # center's coordinates 17 | aoa = 60.0 # angle of inclination in degrees 18 | ds = 0.04 # mesh spacing 19 | 20 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 21 | 22 | # Generate coordinates of the flat plate. 23 | n = math.ceil(L / ds) 24 | s = numpy.linspace(xc - L / 2, xc + L / 2, num=n + 1) 25 | 26 | x = xc + numpy.cos(numpy.radians(-aoa)) * s 27 | y = yc + numpy.sin(numpy.radians(-aoa)) * s 28 | 29 | nz = math.ceil(L * AR / ds) 30 | z = numpy.linspace(zc - L * AR / 2, zc + L * AR / 2, num=nz + 1) 31 | 32 | # Write coordinates into file. 33 | filepath = simu_dir / 'flatplateAoA{}.body'.format(aoa) 34 | with open(filepath, 'w') as outfile: 35 | outfile.write('{}\n'.format(x.size * z.size)) 36 | for zi in z: 37 | with open(filepath, 'ab') as outfile: 38 | numpy.savetxt(outfile, numpy.c_[x, y, zi * numpy.ones(x.size)]) 39 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100_GPU/AoA70/scripts/createBody.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create a flat plate of length 1.0 with aspect ratio 2.0 and a 70-degree 3 | inclination. 4 | The plate is discretized with spacing 0.04 in the x-y plane and with spacing 5 | 0.04 along the z-direction. 6 | """ 7 | 8 | import math 9 | import pathlib 10 | import numpy 11 | 12 | 13 | # Flat-plate's parameters. 14 | L = 1.0 # chord length 15 | AR = 2.0 # aspect ratio 16 | xc, yc, zc = 0.0, 0.0, 0.0 # center's coordinates 17 | aoa = 70.0 # angle of inclination in degrees 18 | ds = 0.04 # mesh spacing 19 | 20 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 21 | 22 | # Generate coordinates of the flat plate. 23 | n = math.ceil(L / ds) 24 | s = numpy.linspace(xc - L / 2, xc + L / 2, num=n + 1) 25 | 26 | x = xc + numpy.cos(numpy.radians(-aoa)) * s 27 | y = yc + numpy.sin(numpy.radians(-aoa)) * s 28 | 29 | nz = math.ceil(L * AR / ds) 30 | z = numpy.linspace(zc - L * AR / 2, zc + L * AR / 2, num=nz + 1) 31 | 32 | # Write coordinates into file. 33 | filepath = simu_dir / 'flatplateAoA{}.body'.format(aoa) 34 | with open(filepath, 'w') as outfile: 35 | outfile.write('{}\n'.format(x.size * z.size)) 36 | for zi in z: 37 | with open(filepath, 'ab') as outfile: 38 | numpy.savetxt(outfile, numpy.c_[x, y, zi * numpy.ones(x.size)]) 39 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100_GPU/AoA80/scripts/createBody.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create a flat plate of length 1.0 with aspect ratio 2.0 and a 80-degree 3 | inclination. 4 | The plate is discretized with spacing 0.04 in the x-y plane and with spacing 5 | 0.04 along the z-direction. 6 | """ 7 | 8 | import math 9 | import pathlib 10 | import numpy 11 | 12 | 13 | # Flat-plate's parameters. 14 | L = 1.0 # chord length 15 | AR = 2.0 # aspect ratio 16 | xc, yc, zc = 0.0, 0.0, 0.0 # center's coordinates 17 | aoa = 80.0 # angle of inclination in degrees 18 | ds = 0.04 # mesh spacing 19 | 20 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 21 | 22 | # Generate coordinates of the flat plate. 23 | n = math.ceil(L / ds) 24 | s = numpy.linspace(xc - L / 2, xc + L / 2, num=n + 1) 25 | 26 | x = xc + numpy.cos(numpy.radians(-aoa)) * s 27 | y = yc + numpy.sin(numpy.radians(-aoa)) * s 28 | 29 | nz = math.ceil(L * AR / ds) 30 | z = numpy.linspace(zc - L * AR / 2, zc + L * AR / 2, num=nz + 1) 31 | 32 | # Write coordinates into file. 33 | filepath = simu_dir / 'flatplateAoA{}.body'.format(aoa) 34 | with open(filepath, 'w') as outfile: 35 | outfile.write('{}\n'.format(x.size * z.size)) 36 | for zi in z: 37 | with open(filepath, 'ab') as outfile: 38 | numpy.savetxt(outfile, numpy.c_[x, y, zi * numpy.ones(x.size)]) 39 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100_GPU/AoA90/scripts/createBody.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create a flat plate of length 1.0 with aspect ratio 2.0 and a 90-degree 3 | inclination. 4 | The plate is discretized with spacing 0.04 in the x-y plane and with spacing 5 | 0.04 along the z-direction. 6 | """ 7 | 8 | import math 9 | import pathlib 10 | import numpy 11 | 12 | 13 | # Flat-plate's parameters. 14 | L = 1.0 # chord length 15 | AR = 2.0 # aspect ratio 16 | xc, yc, zc = 0.0, 0.0, 0.0 # center's coordinates 17 | aoa = 90.0 # angle of inclination in degrees 18 | ds = 0.04 # mesh spacing 19 | 20 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 21 | 22 | # Generate coordinates of the flat plate. 23 | n = math.ceil(L / ds) 24 | s = numpy.linspace(xc - L / 2, xc + L / 2, num=n + 1) 25 | 26 | x = xc + numpy.cos(numpy.radians(-aoa)) * s 27 | y = yc + numpy.sin(numpy.radians(-aoa)) * s 28 | 29 | nz = math.ceil(L * AR / ds) 30 | z = numpy.linspace(zc - L * AR / 2, zc + L * AR / 2, num=nz + 1) 31 | 32 | # Write coordinates into file. 33 | filepath = simu_dir / 'flatplateAoA{}.body'.format(aoa) 34 | with open(filepath, 'w') as outfile: 35 | outfile.write('{}\n'.format(x.size * z.size)) 36 | for zi in z: 37 | with open(filepath, 'ab') as outfile: 38 | numpy.savetxt(outfile, numpy.c_[x, y, zi * numpy.ones(x.size)]) 39 | -------------------------------------------------------------------------------- /examples/navierstokes/taylorgreenvortex2dRe100/config.yaml: -------------------------------------------------------------------------------- 1 | mesh: 2 | - direction: x 3 | start: -3.141592653589793 4 | subDomains: 5 | - end: 3.141592653589793 6 | cells: 256 7 | stretchRatio: 1.0 8 | - direction: y 9 | start: -3.141592653589793 10 | subDomains: 11 | - end: 3.141592653589793 12 | cells: 256 13 | stretchRatio: 1.0 14 | 15 | flow: 16 | nu: 0.01 17 | initialVelocity: 18 | - "cos(x) * sin(y)" 19 | - "- sin(x) * cos(y)" 20 | initialPressure: "- (cos(2*x) + cos(2*y)) / 4" 21 | boundaryConditions: 22 | - location: xMinus 23 | u: [PERIODIC, 0.0] 24 | v: [PERIODIC, 0.0] 25 | - location: xPlus 26 | u: [PERIODIC, 0.0] 27 | v: [PERIODIC, 0.0] 28 | - location: yMinus 29 | u: [PERIODIC, 0.0] 30 | v: [PERIODIC, 0.0] 31 | - location: yPlus 32 | u: [PERIODIC, 1.0] 33 | v: [PERIODIC, 0.0] 34 | 35 | parameters: 36 | dt: 0.01 37 | startStep: 0 38 | nt: 10000 39 | nsave: 1000 40 | nrestart: 10000 41 | convection: ADAMS_BASHFORTH_2 42 | diffusion: CRANK_NICOLSON 43 | velocitySolver: 44 | type: CPU 45 | config: config/velocity_solver.info 46 | poissonSolver: 47 | type: CPU 48 | config: config/poisson_solver.info 49 | -------------------------------------------------------------------------------- /petibm-config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include(CMakeFindDependencyMacro) 4 | 5 | # `find_dependency` will change PACKAGE_PREFIX_DIR; make a copy here 6 | set_and_check(PETIBM_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") 7 | set_and_check(PETIBM_LIBRARY_DIR "@PACKAGE_CMAKE_INSTALL_LIBDIR@") 8 | 9 | # configure extra paths to find cmake/pkg-config modules/configs 10 | set(CMAKE_PREFIX_PATH "@PACKAGE_PETSC_DIR@" ${CMAKE_PREFIX_PATH}) 11 | set(CMAKE_PREFIX_PATH "@PACKAGE_YAMLCPP_DIR@" ${CMAKE_PREFIX_PATH}) 12 | set(CMAKE_PREFIX_PATH "@PACKAGE_AMGXWRAPPER_DIR@" ${CMAKE_PREFIX_PATH}) 13 | 14 | # recover dependencies 15 | find_dependency(PkgConfig) 16 | pkg_search_module(PETSC REQUIRED IMPORTED_TARGET petsc) 17 | find_dependency(yaml-cpp 0.7.0 REQUIRED) 18 | find_dependency(amgxwrapper 1.6.1 REQUIRED) 19 | 20 | # aliases required by petibm::petibm 21 | add_library(amgxwrapper ALIAS amgxwrapper::amgxwrapper) 22 | 23 | # generate an imported target petibm::petibm and petibm::petibmapps 24 | include(${PETIBM_LIBRARY_DIR}/cmake/petibm/petibm-target.cmake) 25 | include(${PETIBM_LIBRARY_DIR}/cmake/petibm/petibmapps-target.cmake) 26 | 27 | # using the imported target to create PETIBM_LIBRARIES 28 | get_target_property(PETIBM_LIBRARIES petibm::petibm LOCATION) 29 | set_and_check(PETIBM_LIBRARIES ${PETIBM_LIBRARIES}) 30 | 31 | check_required_components(petibm) 32 | -------------------------------------------------------------------------------- /src/boundary/boundary.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file boundary.cpp 3 | * \brief Implementation of boundary::BoundaryBase, type::Boundary, and factory 4 | * function. \copyright Copyright (c) 2016-2018, Barba group. All rights 5 | * reserved. \license BSD 3-Clause License. 6 | */ 7 | 8 | #include 9 | #include 10 | 11 | namespace petibm 12 | { 13 | namespace boundary 14 | { 15 | // default destructor 16 | BoundaryBase::~BoundaryBase() 17 | { 18 | PetscFunctionBeginUser; 19 | PetscErrorCode ierr; 20 | PetscBool finalized; 21 | 22 | ierr = PetscFinalized(&finalized); CHKERRV(ierr); 23 | if (finalized) return; 24 | 25 | comm = MPI_COMM_NULL; 26 | } // ~BoundaryBase 27 | 28 | PetscErrorCode BoundaryBase::destroy() 29 | { 30 | PetscFunctionBeginUser; 31 | 32 | std::vector>().swap(bds); 33 | 34 | comm = MPI_COMM_NULL; 35 | mpiSize = mpiRank = 0; 36 | mesh.reset(); 37 | 38 | PetscFunctionReturn(0); 39 | } // destroy 40 | 41 | PetscErrorCode createBoundary(const type::Mesh &mesh, const YAML::Node &node, 42 | type::Boundary &boundary) 43 | { 44 | PetscFunctionBeginUser; 45 | 46 | boundary = std::make_shared(mesh, node); 47 | 48 | PetscFunctionReturn(0); 49 | } // createBoundary 50 | 51 | } // end of namespace boundary 52 | } // end of namespace petibm 53 | -------------------------------------------------------------------------------- /examples/api_examples/oscillatingcylinder2dRe100_GPU/config.yaml: -------------------------------------------------------------------------------- 1 | flow: 2 | nu: 0.01 3 | initialVelocity: [0.0, 0.0] 4 | boundaryConditions: 5 | - location: xMinus 6 | u: [DIRICHLET, 0.0] 7 | v: [DIRICHLET, 0.0] 8 | - location: xPlus 9 | u: [DIRICHLET, 0.0] 10 | v: [DIRICHLET, 0.0] 11 | - location: yMinus 12 | u: [DIRICHLET, 0.0] 13 | v: [DIRICHLET, 0.0] 14 | - location: yPlus 15 | u: [DIRICHLET, 0.0] 16 | v: [DIRICHLET, 0.0] 17 | 18 | mesh: 19 | - direction: x 20 | start: -4.0 21 | subDomains: 22 | - end: 4.0 23 | cells: 512 24 | stretchRatio: 1.0 25 | - direction: y 26 | start: -4.0 27 | subDomains: 28 | - end: 4.0 29 | cells: 512 30 | stretchRatio: 1.0 31 | 32 | parameters: 33 | dt: 0.002 34 | startStep: 0 35 | nt: 10000 36 | nsave: 100 37 | nrestart: 5000 38 | convection: ADAMS_BASHFORTH_2 39 | diffusion: CRANK_NICOLSON 40 | delta: PESKIN_2002 41 | velocitySolver: 42 | type: CPU 43 | config: config/velocity_solver.info 44 | poissonSolver: 45 | type: GPU 46 | config: config/poisson_solver.info 47 | forcesSolver: 48 | type: CPU 49 | config: config/forces_solver.info 50 | 51 | bodies: 52 | - type: points 53 | name: "circle" 54 | file: circle.body 55 | kinematics: 56 | KC: 5.0 57 | D: 1.0 58 | f: 0.2 59 | center: [0.0, 0.0] 60 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe40/config.yaml: -------------------------------------------------------------------------------- 1 | flow: 2 | nu: 0.025 3 | initialVelocity: [1.0, 0.0] 4 | boundaryConditions: 5 | - location: xMinus 6 | u: [DIRICHLET, 1.0] 7 | v: [DIRICHLET, 0.0] 8 | - location: xPlus 9 | u: [CONVECTIVE, 1.0] 10 | v: [CONVECTIVE, 1.0] 11 | - location: yMinus 12 | u: [DIRICHLET, 1.0] 13 | v: [DIRICHLET, 0.0] 14 | - location: yPlus 15 | u: [DIRICHLET, 1.0] 16 | v: [DIRICHLET, 0.0] 17 | 18 | mesh: 19 | - direction: x 20 | start: -15.0 21 | subDomains: 22 | - end: -0.6 23 | cells: 69 24 | stretchRatio: 0.952380952 25 | - end: 0.6 26 | cells: 48 27 | stretchRatio: 1.0 28 | - end: 15.0 29 | cells: 69 30 | stretchRatio: 1.05 31 | 32 | - direction: y 33 | start: -15.0 34 | subDomains: 35 | - end: -0.6 36 | cells: 69 37 | stretchRatio: 0.952380952 38 | - end: 0.6 39 | cells: 48 40 | stretchRatio: 1.0 41 | - end: 15.0 42 | cells: 69 43 | stretchRatio: 1.05 44 | 45 | parameters: 46 | dt: 0.01 47 | startStep: 0 48 | nt: 2000 49 | nsave: 2000 50 | nrestart: 2000 51 | convection: ADAMS_BASHFORTH_2 52 | diffusion: CRANK_NICOLSON 53 | velocitySolver: 54 | type: CPU 55 | config: config/velocity_solver.info 56 | poissonSolver: 57 | type: CPU 58 | config: config/poisson_solver.info 59 | 60 | bodies: 61 | - type: points 62 | file: circle.body 63 | -------------------------------------------------------------------------------- /examples/decoupledibpm/multicylinders2dRe100_GPU/config.yaml: -------------------------------------------------------------------------------- 1 | flow: 2 | nu: 0.01 3 | initialVelocity: [1.0, 0.0] 4 | boundaryConditions: 5 | - location: xMinus 6 | u: [DIRICHLET, 1.0] 7 | v: [DIRICHLET, 0.0] 8 | - location: xPlus 9 | u: [CONVECTIVE, 1.0] 10 | v: [CONVECTIVE, 1.0] 11 | - location: yMinus 12 | u: [PERIODIC, 0.0] 13 | v: [PERIODIC, 0.0] 14 | - location: yPlus 15 | u: [PERIODIC, 0.0] 16 | v: [PERIODIC, 0.0] 17 | 18 | mesh: 19 | - direction: x 20 | start: -10.0 21 | subDomains: 22 | - end: -0.75 23 | cells: 186 24 | stretchRatio: 0.991332611050921 25 | - end: 0.75 26 | cells: 75 27 | stretchRatio: 1.0 28 | - end: 30.0 29 | cells: 301 30 | stretchRatio: 1.008743169398907 31 | 32 | - direction: y 33 | start: -5.0 34 | subDomains: 35 | - end: 5.0 36 | cells: 500 37 | stretchRatio: 1.0 38 | 39 | parameters: 40 | dt: 0.01 41 | startStep: 0 42 | nt: 20000 43 | nsave: 2000 44 | nrestart: 2000 45 | convection: ADAMS_BASHFORTH_2 46 | diffusion: CRANK_NICOLSON 47 | velocitySolver: 48 | type: GPU 49 | config: config/velocity_solver.info 50 | poissonSolver: 51 | type: GPU 52 | config: config/poisson_solver.info 53 | forcesSolver: 54 | type: CPU 55 | config: config/forces_solver.info 56 | 57 | bodies: 58 | - type: points 59 | file: circle1.body 60 | - type: points 61 | file: circle2.body 62 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe3000/config.yaml: -------------------------------------------------------------------------------- 1 | flow: 2 | nu: 0.00033333333333 3 | initialVelocity: [1.0, 0.0] 4 | boundaryConditions: 5 | - location: xMinus 6 | u: [DIRICHLET, 1.0] 7 | v: [DIRICHLET, 0.0] 8 | - location: xPlus 9 | u: [CONVECTIVE, 1.0] 10 | v: [CONVECTIVE, 1.0] 11 | - location: yMinus 12 | u: [DIRICHLET, 1.0] 13 | v: [DIRICHLET, 0.0] 14 | - location: yPlus 15 | u: [DIRICHLET, 1.0] 16 | v: [DIRICHLET, 0.0] 17 | 18 | mesh: 19 | - direction: x 20 | start: -15.0 21 | subDomains: 22 | - end: -0.52 23 | cells: 363 24 | stretchRatio: 0.9900990099 25 | - end: 0.52 26 | cells: 260 27 | stretchRatio: 1.0 28 | - end: 15.0 29 | cells: 363 30 | stretchRatio: 1.01 31 | 32 | - direction: y 33 | start: -15.0 34 | subDomains: 35 | - end: -0.52 36 | cells: 363 37 | stretchRatio: 0.9900990099 38 | - end: 0.52 39 | cells: 260 40 | stretchRatio: 1.0 41 | - end: 15.0 42 | cells: 363 43 | stretchRatio: 1.01 44 | 45 | parameters: 46 | dt: 0.001 47 | startStep: 0 48 | nt: 3000 49 | nsave: 3000 50 | nrestart: 3000 51 | convection: ADAMS_BASHFORTH_2 52 | diffusion: CRANK_NICOLSON 53 | velocitySolver: 54 | type: CPU 55 | config: velocity_solver.info 56 | poissonSolver: 57 | type: CPU 58 | config: poisson_solver.info 59 | 60 | bodies: 61 | - type: points 62 | file: circle.body 63 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe550/config.yaml: -------------------------------------------------------------------------------- 1 | flow: 2 | nu: 0.00181818181818 3 | initialVelocity: [1.0, 0.0] 4 | boundaryConditions: 5 | - location: xMinus 6 | u: [DIRICHLET, 1.0] 7 | v: [DIRICHLET, 0.0] 8 | - location: xPlus 9 | u: [CONVECTIVE, 1.0] 10 | v: [CONVECTIVE, 1.0] 11 | - location: yMinus 12 | u: [DIRICHLET, 1.0] 13 | v: [DIRICHLET, 0.0] 14 | - location: yPlus 15 | u: [DIRICHLET, 1.0] 16 | v: [DIRICHLET, 0.0] 17 | 18 | mesh: 19 | - direction: x 20 | start: -15.0 21 | subDomains: 22 | - end: -0.54 23 | cells: 171 24 | stretchRatio: 0.980392156 25 | - end: 0.54 26 | cells: 108 27 | stretchRatio: 1.0 28 | - end: 15.0 29 | cells: 171 30 | stretchRatio: 1.02 31 | 32 | - direction: y 33 | start: -15.0 34 | subDomains: 35 | - end: -0.54 36 | cells: 171 37 | stretchRatio: 0.980392156 38 | - end: 0.54 39 | cells: 108 40 | stretchRatio: 1.0 41 | - end: 15.0 42 | cells: 171 43 | stretchRatio: 1.02 44 | 45 | parameters: 46 | dt: 0.0025 47 | startStep: 0 48 | nt: 1200 49 | nsave: 1200 50 | nrestart: 1200 51 | convection: ADAMS_BASHFORTH_2 52 | diffusion: CRANK_NICOLSON 53 | velocitySolver: 54 | type: CPU 55 | config: config/velocity_solver.info 56 | poissonSolver: 57 | type: CPU 58 | config: config/poisson_solver.info 59 | 60 | bodies: 61 | - type: points 62 | file: circle.body 63 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe3000_GPU/config.yaml: -------------------------------------------------------------------------------- 1 | flow: 2 | nu: 0.00033333333333 3 | initialVelocity: [1.0, 0.0] 4 | boundaryConditions: 5 | - location: xMinus 6 | u: [DIRICHLET, 1.0] 7 | v: [DIRICHLET, 0.0] 8 | - location: xPlus 9 | u: [CONVECTIVE, 1.0] 10 | v: [CONVECTIVE, 1.0] 11 | - location: yMinus 12 | u: [DIRICHLET, 1.0] 13 | v: [DIRICHLET, 0.0] 14 | - location: yPlus 15 | u: [DIRICHLET, 1.0] 16 | v: [DIRICHLET, 0.0] 17 | 18 | mesh: 19 | - direction: x 20 | start: -15.0 21 | subDomains: 22 | - end: -0.52 23 | cells: 363 24 | stretchRatio: 0.9900990099 25 | - end: 0.52 26 | cells: 260 27 | stretchRatio: 1.0 28 | - end: 15.0 29 | cells: 363 30 | stretchRatio: 1.01 31 | 32 | - direction: y 33 | start: -15.0 34 | subDomains: 35 | - end: -0.52 36 | cells: 363 37 | stretchRatio: 0.9900990099 38 | - end: 0.52 39 | cells: 260 40 | stretchRatio: 1.0 41 | - end: 15.0 42 | cells: 363 43 | stretchRatio: 1.01 44 | 45 | parameters: 46 | dt: 0.001 47 | startStep: 0 48 | nt: 3000 49 | nsave: 3000 50 | nrestart: 3000 51 | convection: ADAMS_BASHFORTH_2 52 | diffusion: CRANK_NICOLSON 53 | velocitySolver: 54 | type: CPU 55 | config: config/velocity_solver.info 56 | poissonSolver: 57 | type: GPU 58 | config: config/poisson_solver.info 59 | 60 | bodies: 61 | - type: points 62 | file: circle.body 63 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe550_GPU/config.yaml: -------------------------------------------------------------------------------- 1 | flow: 2 | nu: 0.00181818181818 3 | initialVelocity: [1.0, 0.0] 4 | boundaryConditions: 5 | - location: xMinus 6 | u: [DIRICHLET, 1.0] 7 | v: [DIRICHLET, 0.0] 8 | - location: xPlus 9 | u: [CONVECTIVE, 1.0] 10 | v: [CONVECTIVE, 1.0] 11 | - location: yMinus 12 | u: [DIRICHLET, 1.0] 13 | v: [DIRICHLET, 0.0] 14 | - location: yPlus 15 | u: [DIRICHLET, 1.0] 16 | v: [DIRICHLET, 0.0] 17 | 18 | mesh: 19 | - direction: x 20 | start: -15.0 21 | subDomains: 22 | - end: -0.54 23 | cells: 171 24 | stretchRatio: 0.980392156 25 | - end: 0.54 26 | cells: 108 27 | stretchRatio: 1.0 28 | - end: 15.0 29 | cells: 171 30 | stretchRatio: 1.02 31 | 32 | - direction: y 33 | start: -15.0 34 | subDomains: 35 | - end: -0.54 36 | cells: 171 37 | stretchRatio: 0.980392156 38 | - end: 0.54 39 | cells: 108 40 | stretchRatio: 1.0 41 | - end: 15.0 42 | cells: 171 43 | stretchRatio: 1.02 44 | 45 | parameters: 46 | dt: 0.0025 47 | startStep: 0 48 | nt: 1200 49 | nsave: 1200 50 | nrestart: 1200 51 | convection: ADAMS_BASHFORTH_2 52 | diffusion: CRANK_NICOLSON 53 | velocitySolver: 54 | type: CPU 55 | config: config/velocity_solver.info 56 | poissonSolver: 57 | type: GPU 58 | config: config/poisson_solver.info 59 | 60 | bodies: 61 | - type: points 62 | file: circle.body 63 | -------------------------------------------------------------------------------- /examples/api_examples/oscillatingcylinder2dRe100_GPU/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.18) 2 | project(oscillatngcylinder) 3 | 4 | # path to petibm installation 5 | set(PETIBM_DIR "$ENV{PETIBM_DIR}" CACHE PATH "The path to PetIBM installation.") 6 | set(CMAKE_PREFIX_PATH ${PETIBM_DIR} ${CMAKE_PREFIX_PATH}) 7 | 8 | # needs explicitly use MPI 9 | find_package(MPI REQUIRED) 10 | 11 | # find petibm 12 | message(CHECK_START "Finding petibm") 13 | find_package(petibm 0.5.4 REQUIRED) 14 | message(CHECK_PASS "done") 15 | 16 | # add executable 17 | add_executable(oscillatngcylinder 18 | main.cpp 19 | oscillatingcylinder.cpp 20 | oscillatingcylinder.h 21 | ) 22 | 23 | # dependencies to link against 24 | target_link_libraries(oscillatngcylinder 25 | PRIVATE MPI::MPI_CXX 26 | PRIVATE petibm::petibm 27 | PRIVATE petibm::petibmapps 28 | ) 29 | 30 | # copy the case configuration/post-processing files to the build folder 31 | add_custom_command( 32 | TARGET oscillatngcylinder 33 | POST_BUILD 34 | COMMAND ${CMAKE_COMMAND} -E 35 | copy ${CMAKE_CURRENT_SOURCE_DIR}/config.yaml ${CMAKE_CURRENT_BINARY_DIR} 36 | COMMAND ${CMAKE_COMMAND} -E 37 | copy ${CMAKE_CURRENT_SOURCE_DIR}/circle.body ${CMAKE_CURRENT_BINARY_DIR} 38 | COMMAND ${CMAKE_COMMAND} -E 39 | copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/config ${CMAKE_CURRENT_BINARY_DIR}/config 40 | COMMAND ${CMAKE_COMMAND} -E 41 | copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/scripts ${CMAKE_CURRENT_BINARY_DIR}/scripts 42 | ) 43 | -------------------------------------------------------------------------------- /src/boundary/singleboundaryneumann.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file singleboundaryneumann.cpp 3 | * \brief Implementation of the class `SingleBoundaryNeumann`. 4 | * \copyright Copyright (c) 2016-2018, Barba group. All rights reserved. 5 | * \license BSD 3-Clause License. 6 | */ 7 | 8 | #include 9 | 10 | namespace petibm 11 | { 12 | namespace boundary 13 | { 14 | SingleBoundaryNeumann::SingleBoundaryNeumann(const type::Mesh &inMesh, 15 | const type::BCLoc &inLoc, 16 | const type::Field &inField, 17 | const PetscReal &inValue) 18 | : SingleBoundaryBase(inMesh, inLoc, inField, type::NEUMANN, inValue) 19 | { 20 | } // SingleBoundaryNeumann 21 | 22 | PetscErrorCode SingleBoundaryNeumann::setGhostICsKernel( 23 | const PetscReal &targetValue, type::GhostPointInfo &p) 24 | { 25 | PetscFunctionBeginUser; 26 | 27 | p.a0 = 1.0; 28 | p.a1 = normal * p.dL * value; 29 | 30 | p.value = p.a0 * targetValue + p.a1; 31 | 32 | PetscFunctionReturn(0); 33 | } // setGhostICsKernel 34 | 35 | PetscErrorCode SingleBoundaryNeumann::updateEqsKernel( 36 | const PetscReal &targetValue, const PetscReal &dt, type::GhostPointInfo &p) 37 | { 38 | PetscFunctionBeginUser; 39 | // for time-independent Neumann BC, the coefficient a0 & a1 won't change 40 | PetscFunctionReturn(0); 41 | } // updateEqsKernel 42 | 43 | } // end of namespace boundary 44 | } // end of namespace petibm 45 | -------------------------------------------------------------------------------- /examples/decoupledibpm/multicylinders2dRe100_GPU/README.md: -------------------------------------------------------------------------------- 1 | # 2D flow around 2 vertically aligned cylinders (Re=100) 2 | 3 | To generate the boundary coordinates for the two cylinders: 4 | 5 | ``` 6 | python scripts/createBodies.py 7 | ``` 8 | 9 | To run the example using 4 CPU processes and 1 GPU: 10 | 11 | ``` 12 | export CUDA_VISIBLE_DEVICES= 13 | mpiexec -np 4 petibm-decoupledibpm -options_left -log_view ascii:view.log 14 | ``` 15 | 16 | The simulation completes in less than 20 minutes when using: 17 | - 4 CPU processes (Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz), 18 | - 1 NVIDIA K40 GPU device. 19 | 20 | To plot the instantaneous force coefficients: 21 | 22 | ``` 23 | python scripts/plotDragCoefficient.py 24 | ``` 25 | 26 | Here are the force coefficients we obtained when averaging between 125 and 200 time units of flow simulation: 27 | 28 | - Body 1: 29 | + Cd = 1.7603 30 | + Cl = -0.0023 ([min, max] = [-0.4888, 0.4888]) 31 | - Body 2: 32 | + Cd = 1.7604 33 | + Cl = 0.0022 ([min, max] = [-0.4886, 0.4886]) 34 | 35 | The plot is saved in the sub-folder `figures` of the simulation directory. 36 | 37 | To compute the vorticity field at saved time steps: 38 | 39 | ``` 40 | petibm-vorticity 41 | ``` 42 | 43 | To create XDMF files to visualize the data with VisIt: 44 | 45 | ``` 46 | petibm-createxdmf 47 | ``` 48 | 49 | The XDMF files `p.xmf` (pressure), `u.xmf` (x-velocity), `v.xmf` (y-velocity), 50 | and `wz.xmf` (vorticity) are saved in the simulation directory and can be used 51 | as input files to visualize data with VisIt. 52 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe100_GPU/config.yaml: -------------------------------------------------------------------------------- 1 | flow: 2 | nu: 0.01 3 | initialVelocity: [1.0, 0.0] 4 | boundaryConditions: 5 | - location: xMinus 6 | u: [DIRICHLET, 1.0] 7 | v: [DIRICHLET, 0.0] 8 | - location: xPlus 9 | u: [CONVECTIVE, 1.0] 10 | v: [CONVECTIVE, 1.0] 11 | - location: yMinus 12 | u: [DIRICHLET, 1.0] 13 | v: [DIRICHLET, 0.0] 14 | - location: yPlus 15 | u: [DIRICHLET, 1.0] 16 | v: [DIRICHLET, 0.0] 17 | 18 | mesh: 19 | - direction: x 20 | start: -10.0 21 | subDomains: 22 | - end: -0.75 23 | cells: 186 24 | stretchRatio: 0.991332611050921 25 | - end: 0.75 26 | cells: 75 27 | stretchRatio: 1.0 28 | - end: 30.0 29 | cells: 301 30 | stretchRatio: 1.008743169398907 31 | 32 | - direction: y 33 | start: -10.0 34 | subDomains: 35 | - end: -0.75 36 | cells: 186 37 | stretchRatio: 0.991332611050921 38 | - end: 0.75 39 | cells: 75 40 | stretchRatio: 1.0 41 | - end: 10.0 42 | cells: 186 43 | stretchRatio: 1.008743169398907 44 | 45 | parameters: 46 | dt: 0.01 47 | startStep: 0 48 | nt: 20000 49 | nsave: 2000 50 | nrestart: 2000 51 | convection: ADAMS_BASHFORTH_2 52 | diffusion: CRANK_NICOLSON 53 | velocitySolver: 54 | type: CPU 55 | config: config/velocity_solver.info 56 | poissonSolver: 57 | type: GPU 58 | config: config/poisson_solver.info 59 | 60 | bodies: 61 | - type: points 62 | file: circle.body 63 | -------------------------------------------------------------------------------- /examples/data/taira_et_al_2007_flatPlateRe100AR2_CdvsAoA.dat: -------------------------------------------------------------------------------- 1 | # Drag coefficient as a function of the angle of attack 2 | # of a flat-plate with aspect ratio 2 at Re=100 3 | # Experimental results from Dickson reported by Taira et al. (2007) and Taira (2008) 4 | # AoA (deg) Cd 5 | 1.07856 0.39189 6 | 2.15712 0.38176 7 | 3.11585 0.38851 8 | 5.03329 0.38176 9 | 6.11185 0.39527 10 | 7.19041 0.40878 11 | 8.02929 0.39865 12 | 9.22770 0.39527 13 | 10.30626 0.40878 14 | 11.26498 0.41554 15 | 12.22370 0.42568 16 | 14.14114 0.43919 17 | 16.05859 0.45608 18 | 17.13715 0.46959 19 | 19.05459 0.49324 20 | 20.13316 0.50676 21 | 23.12916 0.54730 22 | 24.08788 0.56081 23 | 25.04660 0.58108 24 | 27.08389 0.60811 25 | 29.00133 0.64189 26 | 30.19973 0.63851 27 | 31.15845 0.65541 28 | 32.11718 0.67905 29 | 33.07590 0.69932 30 | 35.11318 0.72973 31 | 36.07190 0.74324 32 | 37.03062 0.75676 33 | 38.10919 0.78041 34 | 39.18775 0.80068 35 | 41.10519 0.83108 36 | 43.14248 0.86824 37 | 45.17976 0.90541 38 | 47.09720 0.92905 39 | 48.05593 0.95946 40 | 49.01465 0.97635 41 | 50.21305 1.00000 42 | 52.13049 1.02365 43 | 54.04794 1.06419 44 | 55.96538 1.09122 45 | 58.00266 1.11149 46 | 58.84155 1.14527 47 | 60.03995 1.14527 48 | 61.11851 1.16216 49 | 62.91611 1.19257 50 | 65.07323 1.23311 51 | 67.11052 1.27027 52 | 69.02796 1.30405 53 | 71.18509 1.35135 54 | 71.90413 1.37838 55 | 73.22237 1.39189 56 | 75.01997 1.42905 57 | 76.09853 1.46284 58 | 77.29694 1.45946 59 | 78.01598 1.48649 60 | 78.97470 1.50676 61 | 80.05326 1.51689 62 | 81.85087 1.53716 63 | 84.12783 1.54392 64 | 86.04527 1.53716 65 | 87.72304 1.53041 66 | 90.00000 1.52703 67 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe40_GPU/config.yaml: -------------------------------------------------------------------------------- 1 | flow: 2 | nu: 0.025 3 | initialVelocity: [1.0, 0.0] 4 | boundaryConditions: 5 | - location: xMinus 6 | u: [DIRICHLET, 1.0] 7 | v: [DIRICHLET, 0.0] 8 | - location: xPlus 9 | u: [CONVECTIVE, 1.0] 10 | v: [CONVECTIVE, 1.0] 11 | - location: yMinus 12 | u: [DIRICHLET, 1.0] 13 | v: [DIRICHLET, 0.0] 14 | - location: yPlus 15 | u: [DIRICHLET, 1.0] 16 | v: [DIRICHLET, 0.0] 17 | 18 | mesh: 19 | - direction: x 20 | start: -15.0 21 | subDomains: 22 | - end: -0.6 23 | cells: 69 24 | stretchRatio: 0.952380952 25 | - end: 0.6 26 | cells: 48 27 | stretchRatio: 1.0 28 | - end: 15.0 29 | cells: 69 30 | stretchRatio: 1.05 31 | 32 | - direction: y 33 | start: -15.0 34 | subDomains: 35 | - end: -0.6 36 | cells: 69 37 | stretchRatio: 0.952380952 38 | - end: 0.6 39 | cells: 48 40 | stretchRatio: 1.0 41 | - end: 15.0 42 | cells: 69 43 | stretchRatio: 1.05 44 | 45 | parameters: 46 | dt: 0.01 47 | startStep: 0 48 | nt: 2000 49 | nsave: 2000 50 | nrestart: 2000 51 | convection: ADAMS_BASHFORTH_2 52 | diffusion: CRANK_NICOLSON 53 | velocitySolver: 54 | type: CPU 55 | config: config/velocity_solver.info 56 | poissonSolver: 57 | type: GPU 58 | config: config/poisson_solver.info 59 | forcesSolver: 60 | type: CPU 61 | config: config/forces_solver.info 62 | 63 | bodies: 64 | - type: points 65 | file: circle.body 66 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe550_GPU/config.yaml: -------------------------------------------------------------------------------- 1 | flow: 2 | nu: 0.00181818181818 3 | initialVelocity: [1.0, 0.0] 4 | boundaryConditions: 5 | - location: xMinus 6 | u: [DIRICHLET, 1.0] 7 | v: [DIRICHLET, 0.0] 8 | - location: xPlus 9 | u: [CONVECTIVE, 1.0] 10 | v: [CONVECTIVE, 1.0] 11 | - location: yMinus 12 | u: [DIRICHLET, 1.0] 13 | v: [DIRICHLET, 0.0] 14 | - location: yPlus 15 | u: [DIRICHLET, 1.0] 16 | v: [DIRICHLET, 0.0] 17 | 18 | mesh: 19 | - direction: x 20 | start: -15.0 21 | subDomains: 22 | - end: -0.54 23 | cells: 171 24 | stretchRatio: 0.980392156 25 | - end: 0.54 26 | cells: 108 27 | stretchRatio: 1.0 28 | - end: 15.0 29 | cells: 171 30 | stretchRatio: 1.02 31 | 32 | - direction: y 33 | start: -15.0 34 | subDomains: 35 | - end: -0.54 36 | cells: 171 37 | stretchRatio: 0.980392156 38 | - end: 0.54 39 | cells: 108 40 | stretchRatio: 1.0 41 | - end: 15.0 42 | cells: 171 43 | stretchRatio: 1.02 44 | 45 | parameters: 46 | dt: 0.0025 47 | startStep: 0 48 | nt: 1200 49 | nsave: 1200 50 | nrestart: 1200 51 | convection: ADAMS_BASHFORTH_2 52 | diffusion: CRANK_NICOLSON 53 | velocitySolver: 54 | type: CPU 55 | config: config/velocity_solver.info 56 | poissonSolver: 57 | type: GPU 58 | config: config/poisson_solver.info 59 | forcesSolver: 60 | type: CPU 61 | config: config/forces_solver.info 62 | 63 | bodies: 64 | - type: points 65 | file: circle.body 66 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe3000_GPU/config.yaml: -------------------------------------------------------------------------------- 1 | flow: 2 | nu: 0.00033333333333 3 | initialVelocity: [1.0, 0.0] 4 | boundaryConditions: 5 | - location: xMinus 6 | u: [DIRICHLET, 1.0] 7 | v: [DIRICHLET, 0.0] 8 | - location: xPlus 9 | u: [CONVECTIVE, 1.0] 10 | v: [CONVECTIVE, 1.0] 11 | - location: yMinus 12 | u: [DIRICHLET, 1.0] 13 | v: [DIRICHLET, 0.0] 14 | - location: yPlus 15 | u: [DIRICHLET, 1.0] 16 | v: [DIRICHLET, 0.0] 17 | 18 | mesh: 19 | - direction: x 20 | start: -15.0 21 | subDomains: 22 | - end: -0.52 23 | cells: 363 24 | stretchRatio: 0.9900990099 25 | - end: 0.52 26 | cells: 260 27 | stretchRatio: 1.0 28 | - end: 15.0 29 | cells: 363 30 | stretchRatio: 1.01 31 | 32 | - direction: y 33 | start: -15.0 34 | subDomains: 35 | - end: -0.52 36 | cells: 363 37 | stretchRatio: 0.9900990099 38 | - end: 0.52 39 | cells: 260 40 | stretchRatio: 1.0 41 | - end: 15.0 42 | cells: 363 43 | stretchRatio: 1.01 44 | 45 | parameters: 46 | dt: 0.001 47 | startStep: 0 48 | nt: 3000 49 | nsave: 3000 50 | nrestart: 3000 51 | convection: ADAMS_BASHFORTH_2 52 | diffusion: CRANK_NICOLSON 53 | velocitySolver: 54 | type: CPU 55 | config: config/velocity_solver.info 56 | poissonSolver: 57 | type: GPU 58 | config: config/poisson_solver.info 59 | forcesSolver: 60 | type: CPU 61 | config: config/forces_solver.info 62 | 63 | bodies: 64 | - type: points 65 | file: circle.body 66 | -------------------------------------------------------------------------------- /examples/api_examples/oscillatingcylinder2dRe100_GPU/main.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file main.cpp 3 | * \brief Main function for the simulation of a two-dimensional 4 | * inline-oscillating cylinder. 5 | * \copyright Copyright (c) 2016-2018, Barba group. All rights reserved. 6 | * \license BSD 3-Clause License. 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | #include "oscillatingcylinder.h" 15 | 16 | int main(int argc, char **argv) 17 | { 18 | PetscErrorCode ierr; 19 | YAML::Node config; 20 | OscillatingCylinderSolver solver; 21 | 22 | ierr = PetscInitialize(&argc, &argv, nullptr, nullptr); CHKERRQ(ierr); 23 | ierr = PetscLogDefaultBegin(); CHKERRQ(ierr); 24 | 25 | // parse configuration files; store info in YAML node 26 | ierr = petibm::parser::getSettings(config); CHKERRQ(ierr); 27 | 28 | // initialize the solver 29 | ierr = solver.init(PETSC_COMM_WORLD, config); CHKERRQ(ierr); 30 | ierr = solver.ioInitialData(); CHKERRQ(ierr); 31 | ierr = PetscPrintf(PETSC_COMM_WORLD, 32 | "Completed initialization stage\n"); CHKERRQ(ierr); 33 | 34 | // integrate the solution in time 35 | while (!solver.finished()) 36 | { 37 | // compute the solution at the next time step 38 | ierr = solver.advance(); CHKERRQ(ierr); 39 | // output data to files 40 | ierr = solver.write(); CHKERRQ(ierr); 41 | } 42 | 43 | // destroy the solver 44 | ierr = solver.destroy(); CHKERRQ(ierr); 45 | 46 | ierr = PetscFinalize(); CHKERRQ(ierr); 47 | 48 | return 0; 49 | } // main 50 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe100_GPU/config.yaml: -------------------------------------------------------------------------------- 1 | flow: 2 | nu: 0.01 3 | initialVelocity: [1.0, 0.0] 4 | boundaryConditions: 5 | - location: xMinus 6 | u: [DIRICHLET, 1.0] 7 | v: [DIRICHLET, 0.0] 8 | - location: xPlus 9 | u: [CONVECTIVE, 1.0] 10 | v: [CONVECTIVE, 1.0] 11 | - location: yMinus 12 | u: [DIRICHLET, 1.0] 13 | v: [DIRICHLET, 0.0] 14 | - location: yPlus 15 | u: [DIRICHLET, 1.0] 16 | v: [DIRICHLET, 0.0] 17 | 18 | mesh: 19 | - direction: x 20 | start: -10.0 21 | subDomains: 22 | - end: -0.75 23 | cells: 186 24 | stretchRatio: 0.991332611050921 25 | - end: 0.75 26 | cells: 75 27 | stretchRatio: 1.0 28 | - end: 30.0 29 | cells: 301 30 | stretchRatio: 1.008743169398907 31 | 32 | - direction: y 33 | start: -10.0 34 | subDomains: 35 | - end: -0.75 36 | cells: 186 37 | stretchRatio: 0.991332611050921 38 | - end: 0.75 39 | cells: 75 40 | stretchRatio: 1.0 41 | - end: 10.0 42 | cells: 186 43 | stretchRatio: 1.008743169398907 44 | 45 | parameters: 46 | dt: 0.01 47 | startStep: 0 48 | nt: 20000 49 | nsave: 2000 50 | nrestart: 2000 51 | convection: ADAMS_BASHFORTH_2 52 | diffusion: CRANK_NICOLSON 53 | velocitySolver: 54 | type: CPU 55 | config: config/velocity_solver.info 56 | poissonSolver: 57 | type: GPU 58 | config: config/poisson_solver.info 59 | forcesSolver: 60 | type: CPU 61 | config: config/forces_solver.info 62 | 63 | bodies: 64 | - type: points 65 | file: circle.body 66 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe3000/scripts/plotVorticity.py: -------------------------------------------------------------------------------- 1 | """ 2 | Computes, plots, and saves the 2D vorticity field from a PetIBM simulation 3 | after 3000 time steps (3 non-dimensional time-units). 4 | """ 5 | 6 | import pathlib 7 | import h5py 8 | import numpy 9 | from matplotlib import pyplot 10 | 11 | 12 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 13 | data_dir = simu_dir / 'output' 14 | 15 | # Read vorticity field and its grid from files. 16 | name = 'wz' 17 | filepath = data_dir / 'grid.h5' 18 | f = h5py.File(filepath, 'r') 19 | x, y = f[name]['x'][:], f[name]['y'][:] 20 | X, Y = numpy.meshgrid(x, y) 21 | timestep = 3000 22 | filepath = data_dir / '{:0>7}.h5'.format(timestep) 23 | f = h5py.File(filepath, 'r') 24 | wz = f[name][:] 25 | 26 | # Read body coordinates from file. 27 | filepath = simu_dir / 'circle.body' 28 | with open(filepath, 'r') as infile: 29 | xb, yb = numpy.loadtxt(infile, dtype=numpy.float64, 30 | unpack=True, skiprows=1) 31 | 32 | pyplot.rc('font', family='serif', size=16) 33 | 34 | # Plot the filled contour of the vorticity. 35 | fig, ax = pyplot.subplots(figsize=(6.0, 6.0)) 36 | ax.grid() 37 | ax.set_xlabel('x') 38 | ax.set_ylabel('y') 39 | levels = numpy.linspace(-56.0, 56.0, 28) 40 | ax.contour(X, Y, wz, levels=levels, colors='black') 41 | ax.plot(xb, yb, color='red') 42 | ax.set_xlim(-0.6, 1.6) 43 | ax.set_ylim(-0.8, 0.8) 44 | ax.set_aspect('equal') 45 | fig.tight_layout() 46 | 47 | pyplot.show() 48 | 49 | # Save figure. 50 | fig_dir = simu_dir / 'figures' 51 | fig_dir.mkdir(parents=True, exist_ok=True) 52 | filepath = fig_dir / 'wz{:0>7}.png'.format(timestep) 53 | fig.savefig(str(filepath), dpi=300) 54 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe40/scripts/plotVorticity.py: -------------------------------------------------------------------------------- 1 | """ 2 | Computes, plots, and saves the 2D vorticity field from a PetIBM simulation 3 | after 2000 time steps (20 non-dimensional time-units). 4 | """ 5 | 6 | import pathlib 7 | import h5py 8 | import numpy 9 | from matplotlib import pyplot 10 | 11 | 12 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 13 | data_dir = simu_dir / 'output' 14 | 15 | # Read vorticity field and its grid from files. 16 | name = 'wz' 17 | filepath = data_dir / 'grid.h5' 18 | f = h5py.File(filepath, 'r') 19 | x, y = f[name]['x'][:], f[name]['y'][:] 20 | X, Y = numpy.meshgrid(x, y) 21 | timestep = 2000 22 | filepath = data_dir / '{:0>7}.h5'.format(timestep) 23 | f = h5py.File(filepath, 'r') 24 | wz = f[name][:] 25 | 26 | # Read body coordinates from file. 27 | filepath = simu_dir / 'circle.body' 28 | with open(filepath, 'r') as infile: 29 | xb, yb = numpy.loadtxt(infile, dtype=numpy.float64, 30 | unpack=True, skiprows=1) 31 | 32 | pyplot.rc('font', family='serif', size=16) 33 | 34 | # Plot the filled contour of the vorticity. 35 | fig, ax = pyplot.subplots(figsize=(6.0, 6.0)) 36 | ax.grid() 37 | ax.set_xlabel('x') 38 | ax.set_ylabel('y') 39 | levels = numpy.linspace(-3.0, 3.0, 16) 40 | ax.contour(X, Y, wz, levels=levels, colors='black') 41 | ax.plot(xb, yb, color='red') 42 | ax.set_xlim(-1.0, 4.0) 43 | ax.set_ylim(-2.0, 2.0) 44 | ax.set_aspect('equal') 45 | fig.tight_layout() 46 | 47 | pyplot.show() 48 | 49 | # Save figure. 50 | fig_dir = simu_dir / 'figures' 51 | fig_dir.mkdir(parents=True, exist_ok=True) 52 | filepath = fig_dir / 'wz{:0>7}.png'.format(timestep) 53 | fig.savefig(str(filepath), dpi=300) 54 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe550/scripts/plotVorticity.py: -------------------------------------------------------------------------------- 1 | """ 2 | Computes, plots, and saves the 2D vorticity field from a PetIBM simulation 3 | after 1200 time steps (3 non-dimensional time-units). 4 | """ 5 | 6 | import pathlib 7 | import h5py 8 | import numpy 9 | from matplotlib import pyplot 10 | 11 | 12 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 13 | data_dir = simu_dir / 'output' 14 | 15 | # Read vorticity field and its grid from files. 16 | name = 'wz' 17 | filepath = data_dir / 'grid.h5' 18 | f = h5py.File(filepath, 'r') 19 | x, y = f[name]['x'][:], f[name]['y'][:] 20 | X, Y = numpy.meshgrid(x, y) 21 | timestep = 1200 22 | filepath = data_dir / '{:0>7}.h5'.format(timestep) 23 | f = h5py.File(filepath, 'r') 24 | wz = f[name][:] 25 | 26 | # Read body coordinates from file. 27 | filepath = simu_dir / 'circle.body' 28 | with open(filepath, 'r') as infile: 29 | xb, yb = numpy.loadtxt(infile, dtype=numpy.float64, 30 | unpack=True, skiprows=1) 31 | 32 | pyplot.rc('font', family='serif', size=16) 33 | 34 | # Plot the filled contour of the vorticity. 35 | fig, ax = pyplot.subplots(figsize=(6.0, 6.0)) 36 | ax.grid() 37 | ax.set_xlabel('x') 38 | ax.set_ylabel('y') 39 | levels = numpy.linspace(-32.0, 32.0, 32) 40 | ax.contour(X, Y, wz, levels=levels, colors='black') 41 | ax.plot(xb, yb, color='red') 42 | ax.set_xlim(-0.6, 1.6) 43 | ax.set_ylim(-0.8, 0.8) 44 | ax.set_aspect('equal') 45 | fig.tight_layout() 46 | 47 | pyplot.show() 48 | 49 | # Save figure. 50 | fig_dir = simu_dir / 'figures' 51 | fig_dir.mkdir(parents=True, exist_ok=True) 52 | filepath = fig_dir / 'wz{:0>7}.png'.format(timestep) 53 | fig.savefig(str(filepath), dpi=300) 54 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe3000_GPU/scripts/plotVorticity.py: -------------------------------------------------------------------------------- 1 | """ 2 | Computes, plots, and saves the 2D vorticity field from a PetIBM simulation 3 | after 3000 time steps (3 non-dimensional time-units). 4 | """ 5 | 6 | import pathlib 7 | import h5py 8 | import numpy 9 | from matplotlib import pyplot 10 | 11 | 12 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 13 | data_dir = simu_dir / 'output' 14 | 15 | # Read vorticity field and its grid from files. 16 | name = 'wz' 17 | filepath = data_dir / 'grid.h5' 18 | f = h5py.File(filepath, 'r') 19 | x, y = f[name]['x'][:], f[name]['y'][:] 20 | X, Y = numpy.meshgrid(x, y) 21 | timestep = 3000 22 | filepath = data_dir / '{:0>7}.h5'.format(timestep) 23 | f = h5py.File(filepath, 'r') 24 | wz = f[name][:] 25 | 26 | # Read body coordinates from file. 27 | filepath = simu_dir / 'circle.body' 28 | with open(filepath, 'r') as infile: 29 | xb, yb = numpy.loadtxt(infile, dtype=numpy.float64, 30 | unpack=True, skiprows=1) 31 | 32 | pyplot.rc('font', family='serif', size=16) 33 | 34 | # Plot the filled contour of the vorticity. 35 | fig, ax = pyplot.subplots(figsize=(6.0, 6.0)) 36 | ax.grid() 37 | ax.set_xlabel('x') 38 | ax.set_ylabel('y') 39 | levels = numpy.linspace(-56.0, 56.0, 28) 40 | ax.contour(X, Y, wz, levels=levels, colors='black') 41 | ax.plot(xb, yb, color='red') 42 | ax.set_xlim(-0.6, 1.6) 43 | ax.set_ylim(-0.8, 0.8) 44 | ax.set_aspect('equal') 45 | fig.tight_layout() 46 | 47 | pyplot.show() 48 | 49 | # Save figure. 50 | fig_dir = simu_dir / 'figures' 51 | fig_dir.mkdir(parents=True, exist_ok=True) 52 | filepath = fig_dir / 'wz{:0>7}.png'.format(timestep) 53 | fig.savefig(str(filepath), dpi=300) 54 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe550_GPU/scripts/plotVorticity.py: -------------------------------------------------------------------------------- 1 | """ 2 | Computes, plots, and saves the 2D vorticity field from a PetIBM simulation 3 | after 1200 time steps (3 non-dimensional time-units). 4 | """ 5 | 6 | import pathlib 7 | import h5py 8 | import numpy 9 | from matplotlib import pyplot 10 | 11 | 12 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 13 | data_dir = simu_dir / 'output' 14 | 15 | # Read vorticity field and its grid from files. 16 | name = 'wz' 17 | filepath = data_dir / 'grid.h5' 18 | f = h5py.File(filepath, 'r') 19 | x, y = f[name]['x'][:], f[name]['y'][:] 20 | X, Y = numpy.meshgrid(x, y) 21 | timestep = 1200 22 | filepath = data_dir / '{:0>7}.h5'.format(timestep) 23 | f = h5py.File(filepath, 'r') 24 | wz = f[name][:] 25 | 26 | # Read body coordinates from file. 27 | filepath = simu_dir / 'circle.body' 28 | with open(filepath, 'r') as infile: 29 | xb, yb = numpy.loadtxt(infile, dtype=numpy.float64, 30 | unpack=True, skiprows=1) 31 | 32 | pyplot.rc('font', family='serif', size=16) 33 | 34 | # Plot the filled contour of the vorticity. 35 | fig, ax = pyplot.subplots(figsize=(6.0, 6.0)) 36 | ax.grid() 37 | ax.set_xlabel('x') 38 | ax.set_ylabel('y') 39 | levels = numpy.linspace(-32.0, 32.0, 32) 40 | ax.contour(X, Y, wz, levels=levels, colors='black') 41 | ax.plot(xb, yb, color='red') 42 | ax.set_xlim(-0.6, 1.6) 43 | ax.set_ylim(-0.8, 0.8) 44 | ax.set_aspect('equal') 45 | fig.tight_layout() 46 | 47 | pyplot.show() 48 | 49 | # Save figure. 50 | fig_dir = simu_dir / 'figures' 51 | fig_dir.mkdir(parents=True, exist_ok=True) 52 | filepath = fig_dir / 'wz{:0>7}.png'.format(timestep) 53 | fig.savefig(str(filepath), dpi=300) 54 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2014-2015, Anush Krishnan, Olivier Mesnard 4 | Copyright (c) 2016-2020, Barba group 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | * Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe40_GPU/scripts/plotVorticity.py: -------------------------------------------------------------------------------- 1 | """ 2 | Computes, plots, and saves the 2D vorticity field from a PetIBM simulation 3 | after 2000 time steps (20 non-dimensional time-units). 4 | """ 5 | 6 | import pathlib 7 | import h5py 8 | import numpy 9 | from matplotlib import pyplot 10 | 11 | 12 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 13 | data_dir = simu_dir / 'output' 14 | 15 | # Read vorticity field and its grid from files. 16 | name = 'wz' 17 | filepath = data_dir / 'grid.h5' 18 | f = h5py.File(filepath, 'r') 19 | x, y = f[name]['x'][:], f[name]['y'][:] 20 | X, Y = numpy.meshgrid(x, y) 21 | timestep = 2000 22 | filepath = data_dir / '{:0>7}.h5'.format(timestep) 23 | f = h5py.File(filepath, 'r') 24 | wz = f[name][:] 25 | 26 | # Read body coordinates from file. 27 | filepath = simu_dir / 'circle.body' 28 | with open(filepath, 'r') as infile: 29 | xb, yb = numpy.loadtxt(infile, dtype=numpy.float64, 30 | unpack=True, skiprows=1) 31 | 32 | pyplot.rc('font', family='serif', size=16) 33 | 34 | # Plot the filled contour of the vorticity. 35 | fig, ax = pyplot.subplots(figsize=(6.0, 6.0)) 36 | ax.grid() 37 | ax.set_xlabel('x') 38 | ax.set_ylabel('y') 39 | levels = numpy.linspace(-3.0, 3.0, 16) 40 | ax.contour(X, Y, wz, levels=levels, colors='black') 41 | ax.plot(xb, yb, color='red') 42 | ax.set_xlim(-1.0, 4.0) 43 | ax.set_ylim(-2.0, 2.0) 44 | ax.set_aspect('equal') 45 | fig.tight_layout() 46 | 47 | pyplot.show() 48 | 49 | # Save figure. 50 | fig_dir = simu_dir / 'figures' 51 | fig_dir.mkdir(parents=True, exist_ok=True) 52 | filepath = fig_dir / 'wz{:0>7}.png'.format(timestep) 53 | fig.savefig(str(filepath), dpi=300) 54 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe3000_GPU/scripts/plotVorticity.py: -------------------------------------------------------------------------------- 1 | """ 2 | Computes, plots, and saves the 2D vorticity field from a PetIBM simulation 3 | after 3000 time steps (3 non-dimensional time-units). 4 | """ 5 | 6 | import pathlib 7 | import h5py 8 | import numpy 9 | from matplotlib import pyplot 10 | 11 | 12 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 13 | data_dir = simu_dir / 'output' 14 | 15 | # Read vorticity field and its grid from files. 16 | name = 'wz' 17 | filepath = data_dir / 'grid.h5' 18 | f = h5py.File(filepath, 'r') 19 | x, y = f[name]['x'][:], f[name]['y'][:] 20 | X, Y = numpy.meshgrid(x, y) 21 | timestep = 3000 22 | filepath = data_dir / '{:0>7}.h5'.format(timestep) 23 | f = h5py.File(filepath, 'r') 24 | wz = f[name][:] 25 | 26 | # Read body coordinates from file. 27 | filepath = simu_dir / 'circle.body' 28 | with open(filepath, 'r') as infile: 29 | xb, yb = numpy.loadtxt(infile, dtype=numpy.float64, 30 | unpack=True, skiprows=1) 31 | 32 | pyplot.rc('font', family='serif', size=16) 33 | 34 | # Plot the filled contour of the vorticity. 35 | fig, ax = pyplot.subplots(figsize=(6.0, 6.0)) 36 | ax.grid() 37 | ax.set_xlabel('x') 38 | ax.set_ylabel('y') 39 | levels = numpy.linspace(-56.0, 56.0, 28) 40 | ax.contour(X, Y, wz, levels=levels, colors='black') 41 | ax.plot(xb, yb, color='red') 42 | ax.set_xlim(-0.6, 1.6) 43 | ax.set_ylim(-0.8, 0.8) 44 | ax.set_aspect('equal') 45 | fig.tight_layout() 46 | 47 | pyplot.show() 48 | 49 | # Save figure. 50 | fig_dir = simu_dir / 'figures' 51 | fig_dir.mkdir(parents=True, exist_ok=True) 52 | filepath = fig_dir / 'wz{:0>7}.png'.format(timestep) 53 | fig.savefig(str(filepath), dpi=300) 54 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe550_GPU/scripts/plotVorticity.py: -------------------------------------------------------------------------------- 1 | """ 2 | Computes, plots, and saves the 2D vorticity field from a PetIBM simulation 3 | after 1200 time steps (3 non-dimensional time-units). 4 | """ 5 | 6 | import pathlib 7 | import h5py 8 | import numpy 9 | from matplotlib import pyplot 10 | 11 | 12 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 13 | data_dir = simu_dir / 'output' 14 | 15 | # Read vorticity field and its grid from files. 16 | name = 'wz' 17 | filepath = data_dir / 'grid.h5' 18 | f = h5py.File(filepath, 'r') 19 | x, y = f[name]['x'][:], f[name]['y'][:] 20 | X, Y = numpy.meshgrid(x, y) 21 | timestep = 1200 22 | filepath = data_dir / '{:0>7}.h5'.format(timestep) 23 | f = h5py.File(filepath, 'r') 24 | wz = f[name][:] 25 | 26 | # Read body coordinates from file. 27 | filepath = simu_dir / 'circle.body' 28 | with open(filepath, 'r') as infile: 29 | xb, yb = numpy.loadtxt(infile, dtype=numpy.float64, 30 | unpack=True, skiprows=1) 31 | 32 | pyplot.rc('font', family='serif', size=16) 33 | 34 | # Plot the filled contour of the vorticity. 35 | fig, ax = pyplot.subplots(figsize=(6.0, 6.0)) 36 | ax.grid() 37 | ax.set_xlabel('x') 38 | ax.set_ylabel('y') 39 | levels = numpy.linspace(-32.0, 32.0, 32) 40 | ax.contour(X, Y, wz, levels=levels, colors='black') 41 | ax.plot(xb, yb, color='red') 42 | ax.set_xlim(-0.6, 1.6) 43 | ax.set_ylim(-0.8, 0.8) 44 | ax.set_aspect('equal') 45 | fig.tight_layout() 46 | 47 | pyplot.show() 48 | 49 | # Save figure. 50 | fig_dir = simu_dir / 'figures' 51 | fig_dir.mkdir(parents=True, exist_ok=True) 52 | filepath = fig_dir / 'wz{:0>7}.png'.format(timestep) 53 | fig.savefig(str(filepath), dpi=300) 54 | -------------------------------------------------------------------------------- /.github/workflows/build.yaml: -------------------------------------------------------------------------------- 1 | name: Build and Test 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | - develop 8 | 9 | workflow_dispatch: 10 | 11 | jobs: 12 | build-and-test: 13 | runs-on: ubuntu-latest 14 | container: barbagroup/petibm:gh-action-base 15 | steps: 16 | 17 | - name: Activating conda environment 18 | run: | 19 | micromamba shell init --shell=bash --prefix=/root/micromamba 20 | source ~/.bashrc 21 | micromamba activate base 22 | micromamba info 23 | 24 | - name: Checking out PetIBM source code 25 | uses: actions/checkout@v3 26 | 27 | - name: Configuring PetIBM 28 | run: | 29 | source ~/.bashrc 30 | micromamba activate base 31 | mkdir -p $GITHUB_WORKSPACE/build && cd $GITHUB_WORKSPACE/build 32 | cmake \ 33 | -DCMAKE_INSTALL_PREFIX=${PREFIX} \ 34 | -DCMAKE_CXX_COMPILER=${CXX} \ 35 | -DCMAKE_BUILD_TYPE=Debug \ 36 | -DYAMLCPP_DIR=${PREFIX} \ 37 | -DSYMENGINE_DIR=${PREFIX} \ 38 | -DPETSC_DIR=${PREFIX} \ 39 | -DPETSC_ARCH="" \ 40 | -DPETIBM_ENABLE_TESTS=ON \ 41 | -DPETIBM_USE_AMGX=OFF \ 42 | $GITHUB_WORKSPACE 43 | 44 | - name: Building PetIBM 45 | run: | 46 | source ~/.bashrc 47 | micromamba activate base 48 | cd $GITHUB_WORKSPACE/build 49 | make all -j $(nproc) 50 | 51 | - name: Running tests 52 | run: | 53 | source ~/.bashrc 54 | micromamba activate base 55 | cd $GITHUB_WORKSPACE/build 56 | make check 57 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100AoA30_GPU/scripts/plotForceCoefficients.py: -------------------------------------------------------------------------------- 1 | """ 2 | Post-processes the force coefficients from a PetIBM simulation. 3 | """ 4 | 5 | import pathlib 6 | import numpy 7 | from matplotlib import pyplot 8 | 9 | 10 | # Set up root directory. 11 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 12 | data_dir = simu_dir / 'output' 13 | 14 | # Get the force coefficients. 15 | filepath = data_dir / 'forces-0.txt' 16 | with open(filepath, 'r') as infile: 17 | t, cd, cl = numpy.loadtxt(infile, dtype=numpy.float64, 18 | unpack=True, usecols=(0, 1, 2)) 19 | 20 | # Compute the time-averaged force coefficients. 21 | # Get the min/max values of the lift coefficient. 22 | limits = (15.0, 20.0) 23 | mask = numpy.where(numpy.logical_and(t >= limits[0], t <= limits[1])) 24 | cd_mean, cl_mean = cd[mask].mean(), cl[mask].mean() 25 | cl_min, cl_max = cl[mask].min(), cl[mask].max() 26 | print(' = {:0.4f}'.format(cd_mean)) 27 | print(' = {:0.4f} ([{:0.4f}, {:0.4f}])'.format(cl_mean, cl_min, cl_max)) 28 | 29 | pyplot.rc('font', family='serif', size=16) 30 | 31 | # Plots the figure. 32 | fig, ax = pyplot.subplots(nrows=2, figsize=(10.0, 6.0), sharex=True) 33 | ax[0].grid() 34 | ax[0].set_ylabel('Drag coefficient') 35 | ax[0].plot(t, cd) 36 | ax[0].set_ylim(0.6, 1.2) 37 | ax[1].grid() 38 | ax[1].set_xlabel('Non-dimensional time') 39 | ax[1].set_ylabel('Lift coefficient') 40 | ax[1].plot(t, cl) 41 | ax[1].set_xlim(0.0, 20.0) 42 | ax[1].set_ylim(0.6, 1.2) 43 | fig.tight_layout() 44 | 45 | pyplot.show() 46 | 47 | # Save figure. 48 | fig_dir = simu_dir / 'figures' 49 | fig_dir.mkdir(parents=True, exist_ok=True) 50 | filepath = fig_dir / 'forceCoefficients.png' 51 | fig.savefig(str(filepath), dpi=300) 52 | -------------------------------------------------------------------------------- /applications/writemesh/main.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file mesh/main.cpp 3 | * \brief Small application to create and write mesh coordinates to a file. 4 | * \copyright Copyright (c) 2016-2018, Barba group. All rights reserved. 5 | * \license BSD 3-Clause License. 6 | * \see writemesh 7 | * \ingroup writemesh 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | /** 17 | * \defgroup writemesh Pre-processing utility: writemesh 18 | * \brief A pre-processing utility that creates a mesh and writes 19 | * the gridline coordinates to a HDF5 file. 20 | * 21 | * \ingroup apps 22 | */ 23 | 24 | int main(int argc, char **argv) 25 | { 26 | PetscErrorCode ierr; 27 | YAML::Node config; 28 | petibm::type::Mesh mesh; 29 | 30 | ierr = PetscInitialize(&argc, &argv, nullptr, nullptr); CHKERRQ(ierr); 31 | ierr = PetscLogDefaultBegin(); CHKERRQ(ierr); 32 | 33 | // parse configuration files; store info in YAML node 34 | ierr = petibm::parser::getSettings(config); CHKERRQ(ierr); 35 | 36 | // create mesh 37 | ierr = petibm::mesh::createMesh(PETSC_COMM_WORLD, config, mesh); 38 | CHKERRQ(ierr); 39 | 40 | // write grid data into HDF5 file 41 | std::string filePath = config["output"].as() + "/grid.h5"; 42 | char s[PETSC_MAX_PATH_LEN]; 43 | PetscBool flag = PETSC_FALSE; 44 | ierr = PetscOptionsGetString(nullptr, nullptr, "-file", s, sizeof(s), 45 | &flag); CHKERRQ(ierr); 46 | if (flag) filePath = s; 47 | ierr = mesh->write(filePath); CHKERRQ(ierr); 48 | 49 | ierr = mesh->destroy(); CHKERRQ(ierr); 50 | ierr = PetscFinalize(); CHKERRQ(ierr); 51 | 52 | return 0; 53 | } // main 54 | -------------------------------------------------------------------------------- /examples/ibpm/cylinder2dRe100_GPU/scripts/plotForceCoefficients.py: -------------------------------------------------------------------------------- 1 | """ 2 | Plot the instantaneous force coefficients. 3 | Compute the time-averaged force coefficients 4 | and the min/max values for the lift coefficient. 5 | """ 6 | 7 | import pathlib 8 | import numpy 9 | from matplotlib import pyplot 10 | 11 | 12 | # Set up root directory. 13 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 14 | data_dir = simu_dir / 'output' 15 | 16 | # Get the force coefficients. 17 | filepath = data_dir / 'forces-0.txt' 18 | with open(filepath, 'r') as infile: 19 | t, fx, fy = numpy.loadtxt(infile, dtype=numpy.float64, unpack=True) 20 | cd, cl = 2 * fx, 2 * fy 21 | 22 | # Compute the time-averaged force coefficients. 23 | # Get the min/max values of the lift coefficient. 24 | limits = (100.0, 200.0) 25 | mask = numpy.where(numpy.logical_and(t >= limits[0], t <= limits[1])) 26 | cd_mean, cl_mean = cd[mask].mean(), cl[mask].mean() 27 | cl_min, cl_max = cl[mask].min(), cl[mask].max() 28 | print(' = {:0.4f}'.format(cd_mean)) 29 | print(' = {:0.4f} ([{:0.4f}, {:0.4f}])'.format(cl_mean, cl_min, cl_max)) 30 | 31 | pyplot.rc('font', family='serif', size=16) 32 | 33 | # Plots the figure. 34 | fig, ax = pyplot.subplots(nrows=2, figsize=(10.0, 6.0), sharex=True) 35 | ax[0].grid() 36 | ax[0].set_ylabel('Drag coefficient') 37 | ax[0].plot(t, cd) 38 | ax[0].set_ylim(1.0, 1.5) 39 | ax[1].grid() 40 | ax[1].set_xlabel('Non-dimensional time') 41 | ax[1].set_ylabel('Lift coefficient') 42 | ax[1].plot(t, cl) 43 | ax[1].set_xlim(0.0, 200.0) 44 | ax[1].set_ylim(-0.4, 0.4) 45 | fig.tight_layout() 46 | 47 | pyplot.show() 48 | 49 | # Save figure. 50 | fig_dir = simu_dir / 'figures' 51 | fig_dir.mkdir(parents=True, exist_ok=True) 52 | filepath = fig_dir / 'forceCoefficients.png' 53 | fig.savefig(str(filepath), dpi=300) 54 | -------------------------------------------------------------------------------- /examples/decoupledibpm/cylinder2dRe100_GPU/scripts/plotForceCoefficients.py: -------------------------------------------------------------------------------- 1 | """ 2 | Plot the instantaneous force coefficients. 3 | Compute the time-averaged force coefficients 4 | and the min/max values for the lift coefficient. 5 | """ 6 | 7 | import pathlib 8 | import numpy 9 | from matplotlib import pyplot 10 | 11 | 12 | # Set up root directory. 13 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 14 | data_dir = simu_dir / 'output' 15 | 16 | # Get the force coefficients. 17 | filepath = data_dir / 'forces-0.txt' 18 | with open(filepath, 'r') as infile: 19 | t, fx, fy = numpy.loadtxt(infile, dtype=numpy.float64, unpack=True) 20 | cd, cl = 2 * fx, 2 * fy 21 | 22 | # Compute the time-averaged force coefficients. 23 | # Get the min/max values of the lift coefficient. 24 | limits = (100.0, 200.0) 25 | mask = numpy.where(numpy.logical_and(t >= limits[0], t <= limits[1])) 26 | cd_mean, cl_mean = cd[mask].mean(), cl[mask].mean() 27 | cl_min, cl_max = cl[mask].min(), cl[mask].max() 28 | print(' = {:0.4f}'.format(cd_mean)) 29 | print(' = {:0.4f} ([{:0.4f}, {:0.4f}])'.format(cl_mean, cl_min, cl_max)) 30 | 31 | pyplot.rc('font', family='serif', size=16) 32 | 33 | # Plots the figure. 34 | fig, ax = pyplot.subplots(nrows=2, figsize=(10.0, 6.0), sharex=True) 35 | ax[0].grid() 36 | ax[0].set_ylabel('Drag coefficient') 37 | ax[0].plot(t, cd) 38 | ax[0].set_ylim(1.0, 1.5) 39 | ax[1].grid() 40 | ax[1].set_xlabel('Non-dimensional time') 41 | ax[1].set_ylabel('Lift coefficient') 42 | ax[1].plot(t, cl) 43 | ax[1].set_xlim(0.0, 200.0) 44 | ax[1].set_ylim(-0.4, 0.4) 45 | fig.tight_layout() 46 | 47 | pyplot.show() 48 | 49 | # Save figure. 50 | fig_dir = simu_dir / 'figures' 51 | fig_dir.mkdir(parents=True, exist_ok=True) 52 | filepath = fig_dir / 'forceCoefficients.png' 53 | fig.savefig(str(filepath), dpi=300) 54 | -------------------------------------------------------------------------------- /include/petibm/boundarysimple.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file boundarysimple.h 3 | * \brief Definition of boundary::BoundarySimple 4 | * \copyright Copyright (c) 2016-2018, Barba group. All rights reserved. 5 | * \license BSD 3-Clause License. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | #include 13 | 14 | #include 15 | 16 | namespace petibm 17 | { 18 | namespace boundary 19 | { 20 | /** 21 | * \brief An implementation of petibm::boundary::BoundaryBase. 22 | * \see boundaryModule, petibm::type::Boundary, petibm::boundary::BoundaryBase 23 | * \ingroup boundaryModule 24 | */ 25 | class BoundarySimple : public BoundaryBase 26 | { 27 | public: 28 | /** \copydoc BoundaryBase::BoundaryBase(const type::Mesh &, const YAML::Node 29 | * &) */ 30 | BoundarySimple(const type::Mesh &mesh, const YAML::Node &node); 31 | 32 | /** \copydoc BoundaryBase::~BoundaryBase */ 33 | virtual ~BoundarySimple() = default; 34 | 35 | // implementation of BoundaryBase::setGhostICs 36 | virtual PetscErrorCode setGhostICs(const type::Solution &soln); 37 | 38 | // implementation of BoundaryBase::updateEqs 39 | virtual PetscErrorCode updateEqs(const type::Solution &soln, 40 | const PetscReal &dt); 41 | 42 | // implementation of BoundaryBase::updateGhostValues 43 | virtual PetscErrorCode updateGhostValues(const type::Solution &soln); 44 | 45 | // implementation of BoundaryBase::copyValues2LocalVecs 46 | virtual PetscErrorCode copyValues2LocalVecs( 47 | std::vector &lclVecs) const; 48 | 49 | protected: 50 | // implementation of BoundaryBase::init 51 | virtual PetscErrorCode init(const type::Mesh &mesh, const YAML::Node &node); 52 | 53 | }; // BoundarySimple 54 | 55 | } // end of namespace boundary 56 | 57 | } // end of namespace petibm 58 | -------------------------------------------------------------------------------- /examples/data/taira_et_al_2007_flatPlateRe100AR2_ClvsAoA.dat: -------------------------------------------------------------------------------- 1 | # Lift coefficient as a function of the angle of attack 2 | # of a flat-plate with aspect ratio 2 at Re=100 3 | # Experimental results from Dickson reported by Taira et al. (2007) and Taira (2008) 4 | # AoA (deg) Cl 5 | 0.95872 0.03547 6 | 2.03728 0.06757 7 | 2.99601 0.10980 8 | 3.95473 0.15372 9 | 5.03329 0.20270 10 | 5.99201 0.22973 11 | 6.95073 0.28716 12 | 8.02929 0.29899 13 | 9.10786 0.34122 14 | 9.94674 0.37838 15 | 11.02530 0.41723 16 | 11.98402 0.45101 17 | 13.06258 0.48649 18 | 13.90146 0.51689 19 | 15.09987 0.54392 20 | 15.93875 0.57264 21 | 17.01731 0.59628 22 | 17.97603 0.63682 23 | 18.93475 0.65203 24 | 20.01332 0.67568 25 | 20.97204 0.70101 26 | 22.05060 0.71453 27 | 23.00932 0.72466 28 | 23.96804 0.72973 29 | 25.04660 0.74493 30 | 26.00533 0.74662 31 | 26.96405 0.75845 32 | 28.04261 0.75169 33 | 28.88149 0.76182 34 | 31.03861 0.75507 35 | 32.23702 0.75338 36 | 33.91478 0.75000 37 | 35.95206 0.74662 38 | 38.94807 0.74662 39 | 40.98535 0.73818 40 | 43.02264 0.72804 41 | 44.94008 0.72635 42 | 47.09720 0.70608 43 | 48.89481 0.70101 44 | 50.81225 0.68581 45 | 51.89081 0.67736 46 | 52.96938 0.66047 47 | 53.92810 0.65203 48 | 54.88682 0.63007 49 | 55.96538 0.63851 50 | 56.92410 0.61993 51 | 58.00266 0.60642 52 | 58.96138 0.59628 53 | 59.92010 0.58953 54 | 60.99867 0.56757 55 | 62.07723 0.55912 56 | 63.99467 0.53885 57 | 66.03196 0.52027 58 | 66.99068 0.51182 59 | 67.94940 0.49155 60 | 68.90812 0.48480 61 | 70.94540 0.45777 62 | 71.90413 0.44764 63 | 72.98269 0.42736 64 | 73.82157 0.40878 65 | 74.90013 0.39696 66 | 75.97870 0.38514 67 | 77.05726 0.36318 68 | 78.01598 0.33953 69 | 78.97470 0.32432 70 | 79.93343 0.30236 71 | 81.01199 0.28209 72 | 81.85087 0.26689 73 | 82.92943 0.22804 74 | 84.00799 0.21115 75 | 84.96671 0.19257 76 | 85.92543 0.16216 77 | 86.88416 0.13851 78 | 87.96272 0.11655 79 | 88.92144 0.08446 80 | 90.00000 0.06926 81 | -------------------------------------------------------------------------------- /codemeta.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld", 3 | "@type": "Code", 4 | "author": [ 5 | { 6 | "@id": "http://orcid.org/0000-0001-6330-2709", 7 | "@type": "Person", 8 | "email": "pychuang@gwu.edu", 9 | "name": "Pi-Yueh Chuang", 10 | "affiliation": "Department of Mechanical and Aerospace Engineering, The George Washington University, Washington, DC, USA" 11 | }, 12 | { 13 | "@id": "http://orcid.org/0000-0001-5335-7853", 14 | "@type": "Person", 15 | "email": "mesnardo@gwu.edu", 16 | "name": "Olivier Mesnard", 17 | "affiliation": "Department of Mechanical and Aerospace Engineering, The George Washington University, Washington, DC, USA" 18 | }, 19 | { 20 | "@id": "http://orcid.org/0000-0001-6409-7022", 21 | "@type": "Person", 22 | "email": "k.anush@gmail.com", 23 | "name": "Anush Krishnan", 24 | "affiliation": "nuTonomy Inc., Cambridge, MA, USA (previously at Boston University)" 25 | }, 26 | { 27 | "@id": "http://orcid.org/0000-0001-5812-2711", 28 | "@type": "Person", 29 | "email": "labarba@gwu.edu", 30 | "name": "Lorena A. Barba", 31 | "affiliation": "Department of Mechanical and Aerospace Engineering, The George Washington University, Washington, DC, USA" 32 | } 33 | ], 34 | "identifier": "", 35 | "codeRepository": "https://github.com/barbagroup/PetIBM", 36 | "datePublished": "2018-01-25", 37 | "dateModified": "2017-01-25", 38 | "dateCreated": "2018-01-25", 39 | "description": "PetIBM is a toolbox with applications of the immersed-boundary method on distributed-memory architectures.", 40 | "keywords": "Computational Fluid Dynamics, Immersed-Boundary Method, PETSc, GPU, NVIDIA AmgX", 41 | "license": "BSD 3-Clause", 42 | "title": "PetIBM", 43 | "version": "v0.3" 44 | } 45 | -------------------------------------------------------------------------------- /include/petibm/linsolveramgx.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file linsolveramgx.h 3 | * \brief Def. of LinSolverAmgX. 4 | * \copyright Copyright (c) 2016-2018, Barba group. All rights reserved. 5 | * \license BSD 3-Clause License. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | #include 13 | 14 | namespace petibm 15 | { 16 | namespace linsolver 17 | { 18 | /** 19 | * \class LinSolverAmgX 20 | * \brief Iterative solver using wrapper of AmgX. 21 | * 22 | * This class holds a AmgXSolver from AmgXWrapper package. Users must enable 23 | * AmgX and AmgXWrapper when building PetIBM in order to use this class. 24 | * 25 | * \see petibm::type::LinSolver, petibm::linsolver::createLinSolver. 26 | * \ingroup linsolver 27 | */ 28 | class LinSolverAmgX : public LinSolverBase 29 | { 30 | public: 31 | /** \copydoc LinSolverBase(const std::string &, const std::string &) */ 32 | LinSolverAmgX(const std::string &solverName, const std::string &file); 33 | 34 | /** \copydoc ~LinSolverBase */ 35 | virtual ~LinSolverAmgX(); 36 | 37 | /** \copydoc LinSolverBase::destroy */ 38 | virtual PetscErrorCode destroy(); 39 | 40 | /** \copydoc LinSolverBase::setMatrix */ 41 | virtual PetscErrorCode setMatrix(const Mat &A); 42 | 43 | /** \copydoc LinSolverBase::solve */ 44 | virtual PetscErrorCode solve(Vec &x, Vec &b); 45 | 46 | /** \copydoc LinSolverBase::getIters */ 47 | virtual PetscErrorCode getIters(PetscInt &iters); 48 | 49 | /** \copydoc LinSolverBase::getResidual */ 50 | virtual PetscErrorCode getResidual(PetscReal &res); 51 | 52 | protected: 53 | /** \brief the underlying AmgX wrapper solver. */ 54 | AmgXSolver amgx; 55 | 56 | /** \copydoc LinSolverBase::init */ 57 | virtual PetscErrorCode init(); 58 | 59 | }; // LinSolverAmgX 60 | 61 | } // namespace linsolver 62 | 63 | } // end of namespace petibm 64 | -------------------------------------------------------------------------------- /include/petibm/singleboundaryneumann.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file singleboundaryneumann.h 3 | * \brief Definition of the class `SingleBoundaryNeumann`. 4 | * \copyright Copyright (c) 2016-2018, Barba group. All rights reserved. 5 | * \license BSD 3-Clause License. 6 | */ 7 | 8 | #pragma once 9 | 10 | // here goes headers from our PetIBM 11 | #include 12 | 13 | namespace petibm 14 | { 15 | namespace boundary 16 | { 17 | /** 18 | * \brief An implementation of SingleBoundaryBase for Neumann BC. 19 | * \see boundaryModule, petibm::type::SingleBoundary, 20 | * petibm::boundary::createSingleBoundary \ingroup boundaryModule 21 | */ 22 | class SingleBoundaryNeumann : public SingleBoundaryBase 23 | { 24 | public: 25 | /** 26 | * \brief Constructor. 27 | * \param mesh [in] a Mesh instance. 28 | * \param loc [in] the location of the target boundary. 29 | * \param field [in] the target field. 30 | * \param value [in] BC value. 31 | */ 32 | SingleBoundaryNeumann(const type::Mesh &mesh, const type::BCLoc &loc, 33 | const type::Field &field, const PetscReal &value); 34 | 35 | /** \copydoc SingleBoundaryBase::~SingleBoundaryBase */ 36 | virtual ~SingleBoundaryNeumann() = default; 37 | 38 | protected: 39 | // implementation of SingleBoundaryBase::setGhostICsKernel 40 | virtual PetscErrorCode setGhostICsKernel(const PetscReal &targetValue, 41 | type::GhostPointInfo &p); 42 | 43 | // implementation of SingleBoundaryBase::updateEqsKernel 44 | virtual PetscErrorCode updateEqsKernel(const PetscReal &targetValue, 45 | const PetscReal &dt, 46 | type::GhostPointInfo &p); 47 | 48 | }; // SingleBoundaryNeumann 49 | 50 | } // end of namespace boundary 51 | } // end of namespace petibm 52 | -------------------------------------------------------------------------------- /include/petibm/singleboundarydirichlet.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file singleboundarydirichlet.h 3 | * \brief Definition of the class `SingleBoundaryDirichlet`. 4 | * \copyright Copyright (c) 2016-2018, Barba group. All rights reserved. 5 | * \license BSD 3-Clause License. 6 | */ 7 | 8 | #pragma once 9 | 10 | // here goes headers from our PetIBM 11 | #include 12 | 13 | namespace petibm 14 | { 15 | namespace boundary 16 | { 17 | /** 18 | * \brief An implementation of SingleBoundaryBase for Dirichlet BC. 19 | * \see boundaryModule, petibm::type::SingleBoundary, 20 | * petibm::boundary::createSingleBoundary \ingroup boundaryModule 21 | */ 22 | class SingleBoundaryDirichlet : public SingleBoundaryBase 23 | { 24 | public: 25 | /** 26 | * \brief Constructor. 27 | * \param mesh [in] a Mesh instance. 28 | * \param loc [in] the location of the target boundary. 29 | * \param field [in] the target field. 30 | * \param value [in] BC value. 31 | */ 32 | SingleBoundaryDirichlet(const type::Mesh &mesh, const type::BCLoc &loc, 33 | const type::Field &field, const PetscReal &value); 34 | 35 | /** \copydoc SingleBoundaryBase::~SingleBoundaryBase */ 36 | virtual ~SingleBoundaryDirichlet() = default; 37 | 38 | protected: 39 | // implementation of SingleBoundaryBase::setGhostICsKernel 40 | virtual PetscErrorCode setGhostICsKernel(const PetscReal &targetValue, 41 | type::GhostPointInfo &p); 42 | 43 | // implementation of SingleBoundaryBase::updateEqsKernel 44 | virtual PetscErrorCode updateEqsKernel(const PetscReal &targetValue, 45 | const PetscReal &dt, 46 | type::GhostPointInfo &p); 47 | 48 | }; // SingleBoundaryDirichlet 49 | 50 | } // end of namespace boundary 51 | } // end of namespace petibm 52 | -------------------------------------------------------------------------------- /examples/navierstokes/taylorgreenvortex3dRe1600_GPU/config.yaml: -------------------------------------------------------------------------------- 1 | mesh: 2 | - direction: x 3 | start: -3.141592653589793 4 | subDomains: 5 | - end: 3.141592653589793 6 | cells: 256 7 | stretchRatio: 1.0 8 | - direction: y 9 | start: -3.141592653589793 10 | subDomains: 11 | - end: 3.141592653589793 12 | cells: 256 13 | stretchRatio: 1.0 14 | - direction: z 15 | start: -3.141592653589793 16 | subDomains: 17 | - end: 3.141592653589793 18 | cells: 256 19 | stretchRatio: 1.0 20 | 21 | flow: 22 | nu: 0.000625 23 | initialVelocity: 24 | - "sin(x) * cos(y) * cos(z)" 25 | - "- cos(x) * sin(y) * cos(z)" 26 | - "0" 27 | initialPressure: "(cos(2*x) + cos(2*y)) * (cos(2*z) + 2) / 16" 28 | boundaryConditions: 29 | - location: xMinus 30 | u: [PERIODIC, 0.0] 31 | v: [PERIODIC, 0.0] 32 | w: [PERIODIC, 0.0] 33 | - location: xPlus 34 | u: [PERIODIC, 0.0] 35 | v: [PERIODIC, 0.0] 36 | w: [PERIODIC, 0.0] 37 | - location: yMinus 38 | u: [PERIODIC, 0.0] 39 | v: [PERIODIC, 0.0] 40 | w: [PERIODIC, 0.0] 41 | - location: yPlus 42 | u: [PERIODIC, 1.0] 43 | v: [PERIODIC, 0.0] 44 | w: [PERIODIC, 0.0] 45 | - location: zMinus 46 | u: [PERIODIC, 0.0] 47 | v: [PERIODIC, 0.0] 48 | w: [PERIODIC, 0.0] 49 | - location: zPlus 50 | u: [PERIODIC, 1.0] 51 | v: [PERIODIC, 0.0] 52 | w: [PERIODIC, 0.0] 53 | 54 | parameters: 55 | dt: 0.01 56 | startStep: 0 57 | nt: 2000 58 | nsave: 100 59 | nrestart: 500 60 | convection: ADAMS_BASHFORTH_2 61 | diffusion: CRANK_NICOLSON 62 | velocitySolver: 63 | type: GPU 64 | config: config/velocity_solver.info 65 | poissonSolver: 66 | type: GPU 67 | config: config/poisson_solver.info 68 | -------------------------------------------------------------------------------- /tests/misc/delta_test.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file delta_test.cpp 3 | * \brief Unit-tests for the discrete delta functions. 4 | * \copyright Copyright (c) 2016-2018, Barba group. All rights reserved. 5 | * \license BSD 3-Clause License. 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | #include "gtest/gtest.h" 15 | 16 | #include "petibm/delta.h" 17 | 18 | using namespace petibm::delta; 19 | 20 | // check value is zero outside region of influence 21 | TEST(deltaRomaEtAlTest, zeroOutside) 22 | { 23 | const PetscReal h = 1.0; 24 | EXPECT_EQ(0.0, Roma_et_al_1999(1.5, h)); 25 | EXPECT_EQ(0.0, Roma_et_al_1999(2.0, h)); 26 | } 27 | 28 | // check maximum value at 0 29 | TEST(deltaRomaEtAlTest, maximumValue) 30 | { 31 | const PetscReal h = 1.0; 32 | EXPECT_EQ(2.0 / 3.0, Roma_et_al_1999(0.0, h)); 33 | } 34 | 35 | // check delta function is monotonically decreasing 36 | TEST(deltaRomaEtAlTest, decreasingInfluence) 37 | { 38 | const PetscReal h = 1.0; 39 | // create a sorted vector of random reals between 0.0 and 1.5 40 | std::vector vals(10); 41 | std::default_random_engine engine; 42 | std::uniform_real_distribution distrib(0.0, 1.5); 43 | std::generate(vals.begin(), vals.end(), [&]() { return distrib(engine); }); 44 | std::sort(vals.begin(), vals.end()); 45 | // assert decreasing influence as the distance increases 46 | for (unsigned int i = 0; i < vals.size() - 1; i++) 47 | ASSERT_GT(Roma_et_al_1999(vals[i], h), Roma_et_al_1999(vals[i + 1], h)); 48 | } 49 | 50 | // Run all tests 51 | int main(int argc, char **argv) 52 | { 53 | PetscErrorCode ierr, status; 54 | 55 | ::testing::InitGoogleTest(&argc, argv); 56 | ierr = PetscInitialize(&argc, &argv, nullptr, nullptr); CHKERRQ(ierr); 57 | status = RUN_ALL_TESTS(); 58 | ierr = PetscFinalize(); CHKERRQ(ierr); 59 | 60 | return status; 61 | } // main 62 | -------------------------------------------------------------------------------- /src/boundary/singleboundarydirichlet.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file singleboundarydirichlet.cpp 3 | * \brief Implementation of the class `SingleBoundaryDirichlet`. 4 | * \copyright Copyright (c) 2016-2018, Barba group. All rights reserved. 5 | * \license BSD 3-Clause License. 6 | */ 7 | 8 | #include 9 | 10 | namespace petibm 11 | { 12 | namespace boundary 13 | { 14 | SingleBoundaryDirichlet::SingleBoundaryDirichlet(const type::Mesh &inMesh, 15 | const type::BCLoc &inLoc, 16 | const type::Field &inField, 17 | const PetscReal &inValue) 18 | : SingleBoundaryBase(inMesh, inLoc, inField, type::DIRICHLET, inValue) 19 | { 20 | } // SingleBoundaryDirichlet 21 | 22 | PetscErrorCode SingleBoundaryDirichlet::setGhostICsKernel( 23 | const PetscReal &targetValue, type::GhostPointInfo &p) 24 | { 25 | PetscFunctionBeginUser; 26 | 27 | PetscInt dir = int(loc) / 2; 28 | 29 | // bad idea; this means every ghost point, p, passed in will need to go 30 | // through this if-condition, even though they all have same dir and field 31 | // Luckily, for time-independent Dirichlet BC, a0 & a1 won't change 32 | // afterward 33 | if (dir == int(field)) 34 | { 35 | p.a0 = 0.0; 36 | p.a1 = value; 37 | } 38 | else 39 | { 40 | p.a0 = -1.0; 41 | p.a1 = 2.0 * value; 42 | } 43 | 44 | p.value = p.a0 * targetValue + p.a1; 45 | 46 | PetscFunctionReturn(0); 47 | } // setGhostICsKernel 48 | 49 | PetscErrorCode SingleBoundaryDirichlet::updateEqsKernel( 50 | const PetscReal &targetValue, const PetscReal &dt, type::GhostPointInfo &p) 51 | { 52 | PetscFunctionBeginUser; 53 | // for time-independent Dirichlet BC, the coefficient a0 & a1 won't change 54 | PetscFunctionReturn(0); 55 | } // updateEqsKernel 56 | 57 | } // end of namespace boundary 58 | } // end of namespace petibm 59 | -------------------------------------------------------------------------------- /include/petibm/singleboundaryperiodic.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file singleboundaryperiodic.h 3 | * \brief Definition of the class `SingleBoundaryPeriodic`. 4 | * \copyright Copyright (c) 2016-2018, Barba group. All rights reserved. 5 | * \license BSD 3-Clause License. 6 | */ 7 | 8 | #pragma once 9 | 10 | // here goes headers from our PetIBM 11 | #include 12 | 13 | namespace petibm 14 | { 15 | namespace boundary 16 | { 17 | /** 18 | * \brief An implementation of SingleBoundaryBase for periodic BC. 19 | * \see boundaryModule, petibm::type::SingleBoundary, 20 | * petibm::boundary::createSingleBoundary \ingroup boundaryModule 21 | * 22 | * PETSc will handle periodic BCs for us, so this is just a trivial 23 | * implementation to keep consistency. 24 | */ 25 | class SingleBoundaryPeriodic : public SingleBoundaryBase 26 | { 27 | public: 28 | /** 29 | * \brief Constructor. 30 | * \param mesh [in] a Mesh instance. 31 | * \param loc [in] the location of the target boundary. 32 | * \param field [in] the target field. 33 | * \param value [in] BC value. 34 | */ 35 | SingleBoundaryPeriodic(const type::Mesh &mesh, const type::BCLoc &loc, 36 | const type::Field &field, const PetscReal &value); 37 | 38 | /** \copydoc SingleBoundaryBase::~SingleBoundaryBase */ 39 | virtual ~SingleBoundaryPeriodic() = default; 40 | 41 | protected: 42 | // implementation of SingleBoundaryBase::setGhostICsKernel 43 | virtual PetscErrorCode setGhostICsKernel(const PetscReal &targetValue, 44 | type::GhostPointInfo &p); 45 | 46 | // implementation of SingleBoundaryBase::updateEqsKernel 47 | virtual PetscErrorCode updateEqsKernel(const PetscReal &targetValue, 48 | const PetscReal &dt, 49 | type::GhostPointInfo &p); 50 | 51 | }; // SingleBoundaryPeriodic 52 | 53 | } // end of namespace boundary 54 | } // end of namespace petibm 55 | -------------------------------------------------------------------------------- /include/petibm/linsolverksp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file linsolverksp.h 3 | * \brief Def. of LinSolverKSP. 4 | * \copyright Copyright (c) 2016-2018, Barba group. All rights reserved. 5 | * \license BSD 3-Clause License. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | #include 13 | 14 | namespace petibm 15 | { 16 | namespace linsolver 17 | { 18 | /** 19 | * \class LinSolverKSP 20 | * \brief Iterative solver using PETSc KSP. 21 | * 22 | * This class holds a KSP object from PETSc. The configuration of this 23 | * underlying KSP solver will be read from the provided argument `file`. 24 | * 25 | * \see petibm::type::LinSolver, petibm::linsolver::createLinSolver. 26 | * \ingroup linsolver 27 | */ 28 | class LinSolverKSP : public LinSolverBase 29 | { 30 | public: 31 | /** \copydoc LinSolverBase(const std::string &, const std::string &) 32 | * 33 | * The argument `name` will be used as a prefix for the configuration of the 34 | * underlying KSP solver in the provided configuration file. 35 | */ 36 | LinSolverKSP(const std::string &solverName, const std::string &file); 37 | 38 | /** \copydoc ~LinSolverBase */ 39 | virtual ~LinSolverKSP(); 40 | 41 | /** \copydoc LinSolverBase::destroy */ 42 | virtual PetscErrorCode destroy(); 43 | 44 | /** \copydoc LinSolverBase::setMatrix */ 45 | virtual PetscErrorCode setMatrix(const Mat &A); 46 | 47 | /** \copydoc LinSolverBase::solve */ 48 | virtual PetscErrorCode solve(Vec &x, Vec &b); 49 | 50 | /** \copydoc LinSolverBase::getIters */ 51 | virtual PetscErrorCode getIters(PetscInt &iters); 52 | 53 | /** \copydoc LinSolverBase::getResidual */ 54 | virtual PetscErrorCode getResidual(PetscReal &res); 55 | 56 | protected: 57 | /** \brief the underlying KSP solver */ 58 | KSP ksp; 59 | 60 | /** \copydoc LinSolverBase::init */ 61 | virtual PetscErrorCode init(); 62 | 63 | }; // LinSolverKSP 64 | 65 | } // end of namespace linsolver 66 | 67 | } // end of namespace petibm 68 | -------------------------------------------------------------------------------- /src/solution/solution.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file solution.cpp 3 | * \brief Implementation of the factory function 4 | * and members of the class petibm::solution::SolutionBase. 5 | * \copyright Copyright (c) 2016-2018, Barba group. All rights reserved. 6 | * \license BSD 3-Clause License. 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace petibm 14 | { 15 | namespace solution 16 | { 17 | // Destructor. 18 | SolutionBase::~SolutionBase() 19 | { 20 | PetscErrorCode ierr; 21 | PetscBool finalized; 22 | 23 | PetscFunctionBeginUser; 24 | 25 | ierr = PetscFinalized(&finalized); CHKERRV(ierr); 26 | if (finalized) return; 27 | 28 | ierr = VecDestroy(&UGlobal); CHKERRV(ierr); 29 | ierr = VecDestroy(&pGlobal); CHKERRV(ierr); 30 | comm = MPI_COMM_NULL; 31 | } // ~SolutionBase 32 | 33 | // Manually destroy data. 34 | PetscErrorCode SolutionBase::destroy() 35 | { 36 | PetscErrorCode ierr; 37 | 38 | PetscFunctionBeginUser; 39 | 40 | dim = -1; 41 | ierr = VecDestroy(&UGlobal); CHKERRQ(ierr); 42 | ierr = VecDestroy(&pGlobal); CHKERRQ(ierr); 43 | info = ""; 44 | 45 | comm = MPI_COMM_NULL; 46 | mpiRank = mpiSize = 0; 47 | mesh.reset(); 48 | 49 | PetscFunctionReturn(0); 50 | } // destroy 51 | 52 | // Print information about the solution to standard output. 53 | PetscErrorCode SolutionBase::printInfo() const 54 | { 55 | PetscErrorCode ierr; 56 | 57 | PetscFunctionBeginUser; 58 | 59 | ierr = io::print(info); CHKERRQ(ierr); 60 | 61 | PetscFunctionReturn(0); 62 | } // printInfo 63 | 64 | // Factory function to create a petibm::solution::Solution object. 65 | PetscErrorCode createSolution(const type::Mesh &mesh, type::Solution &solution) 66 | { 67 | PetscFunctionBeginUser; 68 | 69 | solution = std::make_shared(mesh); 70 | 71 | PetscFunctionReturn(0); 72 | } // createSolution 73 | 74 | } // end of namespace solution 75 | } // end of namespace petibm 76 | -------------------------------------------------------------------------------- /include/petibm/solutionsimple.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file solutionsimple.h 3 | * \brief Definition of class petibm::solution::SolutionSimple. 4 | * \copyright Copyright (c) 2016-2018, Barba group. All rights reserved. 5 | * \license BSD 3-Clause License. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | namespace petibm 16 | { 17 | namespace solution 18 | { 19 | /** 20 | * \brief Class to hold the velocity vector field and pressure scalar field. 21 | * 22 | * \see solutionModule, petibm::type::Solution, petibm::solution::createSolution 23 | * \ingroup solutionModule 24 | */ 25 | class SolutionSimple : public SolutionBase 26 | { 27 | public: 28 | /** \copydoc SolutionBase(const type::Mesh &) */ 29 | SolutionSimple(const type::Mesh &mesh); 30 | 31 | /** \copydoc ~SolutionBase */ 32 | virtual ~SolutionSimple(); 33 | 34 | // documentation: see petibm::solution::SolutionBase::setInitialConditions 35 | virtual PetscErrorCode setInitialConditions(const YAML::Node &node); 36 | 37 | // documentation: see petibm::solution::SolutionBase::convert2Velocity 38 | virtual PetscErrorCode convert2Velocity(const Mat &Rinv); 39 | 40 | // documentation: see petibm::solution::SolutionBase::convert2Flux 41 | virtual PetscErrorCode convert2Flux(const Mat &R); 42 | 43 | // documentation: see petibm::solution::SolutionBase::write 44 | virtual PetscErrorCode write(const std::string &filePath) const; 45 | 46 | // documentation: see petibm::solution::SolutionBase::read 47 | virtual PetscErrorCode read(const std::string &filePath); 48 | 49 | protected: 50 | // documentation: see petibm::solution::SolutionBase::init 51 | virtual PetscErrorCode init(const type::Mesh &mesh); 52 | 53 | /** 54 | * \brief Create a string with information about the solution. 55 | * 56 | * \return PetscErrorCode. 57 | */ 58 | PetscErrorCode createInfoString(); 59 | 60 | }; // SolutionSimple 61 | 62 | } // end of namespace solution 63 | } // end of namespace petibm 64 | -------------------------------------------------------------------------------- /examples/data/ghia_et_al_1982_lid_driven_cavity.dat: -------------------------------------------------------------------------------- 1 | # Centerline velocities from Ghia et al. (1982) for a lid-driven cavity flow 2 | # [y], [u Re=[100, 1000, 3200, 5000, 10000]], [x], [v Re=[100, 1000, 3200, 5000, 10000]] 3 | 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.00000 4 | 0.054700 -0.037170 -0.181090 -0.32407 -0.41165 -0.42735 0.062500 0.092330 0.274850 0.395600 0.424470 0.43983 5 | 0.062500 -0.041920 -0.201960 -0.35344 -0.42901 -0.42537 0.070300 0.100910 0.290120 0.409170 0.433290 0.43733 6 | 0.070300 -0.047750 -0.222200 -0.37827 -0.43643 -0.41657 0.078100 0.108900 0.303530 0.419060 0.436480 0.43124 7 | 0.101600 -0.064340 -0.297300 -0.41933 -0.40435 -0.38000 0.093800 0.123170 0.326270 0.427680 0.429510 0.41487 8 | 0.171900 -0.101500 -0.382890 -0.34323 -0.33050 -0.32709 0.156300 0.160770 0.370950 0.371190 0.353680 0.35070 9 | 0.281300 -0.156620 -0.278050 -0.24427 -0.22855 -0.23186 0.226600 0.175070 0.330750 0.290300 0.280660 0.28003 10 | 0.453100 -0.210900 -0.106480 -0.86636 -0.07404 -0.07540 0.234400 0.175270 0.322350 0.281880 0.272800 0.27224 11 | 0.500000 -0.205810 -0.060800 -0.04272 -0.03039 0.031110 0.500000 0.054540 0.024260 0.009990 0.009450 0.00831 12 | 0.617200 -0.136410 0.057020 0.071560 0.081830 0.083440 0.804700 -0.245330 -0.31966 -0.31184 -0.30018 -0.30719 13 | 0.734400 0.003320 0.187190 0.197910 0.200870 0.206730 0.859400 -0.224450 -0.42665 -0.37401 -0.36214 -0.36737 14 | 0.851600 0.231510 0.333040 0.346820 0.335560 0.346350 0.906300 -0.169140 -0.51550 -0.44307 -0.41442 -0.41496 15 | 0.953100 0.687170 0.466040 0.461010 0.460360 0.478040 0.945300 -0.103130 -0.39188 -0.54053 -0.52876 -0.45863 16 | 0.960900 0.737220 0.511170 0.465470 0.459920 0.480700 0.953100 -0.088640 -0.33714 -0.52357 -0.55408 -0.49099 17 | 0.968800 0.788710 0.574920 0.482960 0.461200 0.477830 0.960900 -0.073910 -0.27669 -0.47425 -0.55069 -0.52987 18 | 0.976600 0.841230 0.659280 0.532360 0.482230 0.472210 0.968800 -0.059060 -0.21388 -0.39017 -0.49774 -0.54302 19 | 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 0.000000 0.000000 0.000000 0.000000 0.000000 20 | -------------------------------------------------------------------------------- /src/boundary/singleboundaryperiodic.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file singleboundaryperiodic.cpp 3 | * \brief Implementation of the class `SingleBoundaryPeriodic`. 4 | * \copyright Copyright (c) 2016-2018, Barba group. All rights reserved. 5 | * \license BSD 3-Clause License. 6 | */ 7 | 8 | #include 9 | 10 | namespace petibm 11 | { 12 | namespace boundary 13 | { 14 | SingleBoundaryPeriodic::SingleBoundaryPeriodic(const type::Mesh &inMesh, 15 | const type::BCLoc &inLoc, 16 | const type::Field &inField, 17 | const PetscReal &inValue) 18 | { 19 | // for Periodic, though we don't have to implement anything, 20 | // we still setup some basic values 21 | 22 | // create a shared pointer to mesh; bad practice... 23 | mesh = inMesh; 24 | 25 | // obtain MPI information from CartesianMesh object 26 | comm = mesh->comm; 27 | mpiSize = mesh->mpiSize; 28 | mpiRank = mesh->mpiRank; 29 | 30 | // set dim 31 | dim = mesh->dim; 32 | 33 | // set the location 34 | loc = inLoc; 35 | 36 | // set field 37 | field = inField; 38 | 39 | // set type 40 | type = type::PERIODIC; 41 | 42 | // set value 43 | value = inValue; 44 | 45 | // set normal 46 | normal = ((int(loc) % 2) == 0) ? -1.0 : 1.0; 47 | } // SingleBoundaryPeriodic 48 | 49 | PetscErrorCode SingleBoundaryPeriodic::setGhostICsKernel( 50 | const PetscReal &targetValue, type::GhostPointInfo &p) 51 | { 52 | PetscFunctionBeginUser; 53 | // for Periodic BC, do nothing. Let PETSc handle that. 54 | PetscFunctionReturn(0); 55 | } // setGhostICsKernel 56 | 57 | PetscErrorCode SingleBoundaryPeriodic::updateEqsKernel( 58 | const PetscReal &targetValue, const PetscReal &dt, type::GhostPointInfo &p) 59 | { 60 | PetscFunctionBeginUser; 61 | // for Periodic BC, do nothing. Let PETSc handle that. 62 | PetscFunctionReturn(0); 63 | } // updateEqsKernel 64 | 65 | } // end of namespace boundary 66 | } // end of namespace petibm 67 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute to PetIBM 2 | 3 | Welcome to the developer's guide of PetIBM! 4 | 5 | ## Adding new features and fixing bugs 6 | 7 | All new features and bug fixes must go through a pull-request review procedure. 8 | If you want to contribute to PetIBM, please fork the Barbagroup's [PetIBM](https://github.com/barbagroup/PetIBM) repository, make your changes on your fork, and then open a pull-request with your changes against the main PetIBM repository. 9 | 10 | For new features and minor bugs (with small impact), the base branch of the pull-request should be the `develop` branch of the main repository. 11 | (The `develop` branch will be merged into the `master` one once we are ready for a new release of PetIBM.) 12 | 13 | For major bugs, the base branch should be the `master` branch of the main repository; it will be considered as a hotfix (bugfix) and a new version of PetIBM will be released as soon as possible by the maintainers with the micro number incremented. 14 | 15 | New features should come with some kind of test or example to verify and/or validate the implementation. 16 | 17 | 18 | ## Reporting bugs and requesting new features 19 | 20 | To report bugs, request new features, or simply ask questions, please open a GitHub issue on the Barbagroup's PetIBM repository. 21 | 22 | 23 | ## Writing documentation 24 | 25 | New classes, methods, functions, and namespaces must be documented with Doxygen-style doctrings. 26 | 27 | To locally generate and check the Doxygen documentation, use the command-line: 28 | 29 | > cd doc 30 | > doxygen Doxyfile 31 | 32 | and open the file `doc/html/index.html` in your favorite browser. 33 | 34 | You should also add code documentation whenever necessary; it will greatly help other developers to review your new features and bug fixes. 35 | 36 | For new features, user's documentation must also be written. 37 | For this purpose, we use Markdown files that are located in the `doc` folder of the root directory of PetIBM. 38 | 39 | The User's documentation and API documentation are up-to-date with the latest release of PetIBM, which should be close to the latest commit on the `master` branch. 40 | -------------------------------------------------------------------------------- /examples/decoupledibpm/multicylinders2dRe100_GPU/scripts/createBodies.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create two circles and write coordinates into files. 3 | """ 4 | 5 | import pathlib 6 | import math 7 | import numpy 8 | 9 | 10 | def create_circle(R=0.5, center=(0.0, 0.0), ds=0.01): 11 | """ 12 | Generate coordinates of circle. 13 | 14 | Parameters 15 | ---------- 16 | R: float, optional 17 | radius; 18 | default: 0.5. 19 | center: 2-tuple of floats, optional 20 | center's coordinates; 21 | default: (0.0, 0.0). 22 | ds: float, optional 23 | mesh spacing; 24 | default: 0.01. 25 | 26 | Returns 27 | ------- 28 | x: 1D Numpy array of floats 29 | x coordinates. 30 | y: 1D Numpy array of floats 31 | y coordinates. 32 | """ 33 | xc, yc = center 34 | n = math.ceil(2 * numpy.pi * R / ds) 35 | theta = numpy.linspace(0.0, 2.0 * numpy.pi, num=n, endpoint=False) 36 | x, y = xc + R * numpy.cos(theta), yc + R * numpy.sin(theta) 37 | return x, y 38 | 39 | 40 | def write_coordinates(coords, filepath): 41 | """ 42 | Write coordinates into file. 43 | The first line contains the number of points. 44 | The coordinates are written into columns. 45 | 46 | Parameters 47 | ---------- 48 | coords: 2-tuple of 1D Numpy arrays of floats 49 | The coordinates. 50 | filepath: string 51 | Path of the output file. 52 | """ 53 | x, y = coords 54 | n = x.size 55 | with open(filepath, 'w') as outfile: 56 | outfile.write('{}\n'.format(n)) 57 | with open(filepath, 'ab') as outfile: 58 | numpy.savetxt(outfile, numpy.c_[x, y]) 59 | 60 | 61 | simu_dir = pathlib.Path(__file__).absolute().parents[1] 62 | 63 | # Generate coordinates of first body and write into file. 64 | circle1 = create_circle(R=0.5, center=(0.0, -2.5), ds=0.02) 65 | filepath = simu_dir / 'circle1.body' 66 | write_coordinates(circle1, filepath) 67 | 68 | # Generate coordinates of first body and write into file. 69 | circle2 = create_circle(R=0.5, center=(0.0, 2.5), ds=0.02) 70 | filepath = simu_dir / 'circle2.body' 71 | write_coordinates(circle2, filepath) 72 | -------------------------------------------------------------------------------- /applications/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # library of developing applications 2 | add_library(petibmapps 3 | navierstokes/navierstokes.cpp 4 | navierstokes/navierstokes.h 5 | ibpm/ibpm.cpp 6 | ibpm/ibpm.h 7 | decoupledibpm/decoupledibpm.cpp 8 | decoupledibpm/decoupledibpm.h 9 | rigidkinematics/rigidkinematics.cpp 10 | rigidkinematics/rigidkinematics.h 11 | ) 12 | 13 | set_target_properties(petibmapps PROPERTIES 14 | POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} 15 | INSTALL_RPATH "${PETIBM_RPATH}" 16 | ) 17 | 18 | target_include_directories(petibmapps 19 | PUBLIC 20 | $ 21 | $ 22 | ) 23 | 24 | target_compile_options(petibmapps 25 | PRIVATE -Wno-deprecated-declarations 26 | ) 27 | 28 | target_compile_definitions(petibmapps 29 | PRIVATE $<$:HAVE_AMGX> 30 | ) 31 | 32 | target_link_libraries(petibmapps 33 | PRIVATE MPI::MPI_CXX 34 | PUBLIC PkgConfig::PETSC 35 | PUBLIC yaml-cpp 36 | PUBLIC petibm 37 | ) 38 | 39 | target_link_options(petibmapps 40 | PRIVATE "-Wl,--as-needed" 41 | PRIVATE "-Wl,--no-allow-shlib-undefined" 42 | PRIVATE "-Wl,--no-undefined" 43 | ) 44 | 45 | install( 46 | TARGETS petibmapps 47 | EXPORT petibmapps-target 48 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 49 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 50 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 51 | ) 52 | 53 | install( 54 | DIRECTORY 55 | ${CMAKE_CURRENT_SOURCE_DIR}/navierstokes 56 | ${CMAKE_CURRENT_SOURCE_DIR}/ibpm 57 | ${CMAKE_CURRENT_SOURCE_DIR}/decoupledibpm 58 | ${CMAKE_CURRENT_SOURCE_DIR}/rigidkinematics 59 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/petibm 60 | FILES_MATCHING PATTERN "*.h" 61 | ) 62 | 63 | install( 64 | EXPORT petibmapps-target NAMESPACE petibm:: 65 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/petibm 66 | ) 67 | 68 | # executables 69 | add_subdirectory(createxdmf) 70 | add_subdirectory(writemesh) 71 | add_subdirectory(vorticity) 72 | add_subdirectory(navierstokes) 73 | add_subdirectory(ibpm) 74 | add_subdirectory(decoupledibpm) 75 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100AoA30_GPU/config.yaml: -------------------------------------------------------------------------------- 1 | flow: 2 | nu: 0.01 3 | initialVelocity: [1.0, 0.0, 0.0] 4 | boundaryConditions: 5 | - location: xMinus 6 | u: [DIRICHLET, 1.0] 7 | v: [DIRICHLET, 0.0] 8 | w: [DIRICHLET, 0.0] 9 | - location: xPlus 10 | u: [CONVECTIVE, 1.0] 11 | v: [CONVECTIVE, 0.0] 12 | w: [CONVECTIVE, 0.0] 13 | - location: yMinus 14 | u: [DIRICHLET, 1.0] 15 | v: [DIRICHLET, 0.0] 16 | w: [DIRICHLET, 0.0] 17 | - location: yPlus 18 | u: [DIRICHLET, 1.0] 19 | v: [DIRICHLET, 0.0] 20 | w: [DIRICHLET, 0.0] 21 | - location: zMinus 22 | u: [DIRICHLET, 1.0] 23 | v: [DIRICHLET, 0.0] 24 | w: [DIRICHLET, 0.0] 25 | - location: zPlus 26 | u: [DIRICHLET, 1.0] 27 | v: [DIRICHLET, 0.0] 28 | w: [DIRICHLET, 0.0] 29 | 30 | mesh: 31 | - direction: x 32 | start: -4.0 33 | subDomains: 34 | - end: -0.5 35 | cells: 43 36 | stretchRatio: 0.970873786407767 37 | - end: 0.7 38 | cells: 30 39 | stretchRatio: 1.0 40 | - end: 6.1 41 | cells: 54 42 | stretchRatio: 1.03 43 | 44 | - direction: y 45 | start: -5.0 46 | subDomains: 47 | - end: -0.6 48 | cells: 13 49 | stretchRatio: 0.7692307692307692 50 | - end: 0.6 51 | cells: 30 52 | stretchRatio: 1.0 53 | - end: 5.0 54 | cells: 13 55 | stretchRatio: 1.3 56 | 57 | - direction: z 58 | start: -5.0 59 | subDomains: 60 | - end: -1.2 61 | cells: 12 62 | stretchRatio: 0.7692307692307692 63 | - end: 1.2 64 | cells: 60 65 | stretchRatio: 1.0 66 | - end: 5.0 67 | cells: 12 68 | stretchRatio: 1.3 69 | 70 | parameters: 71 | dt: 0.01 72 | startStep: 0 73 | nt: 2000 74 | nsave: 2000 75 | nrestart: 2000 76 | convection: ADAMS_BASHFORTH_2 77 | diffusion: CRANK_NICOLSON 78 | velocitySolver: 79 | type: CPU 80 | config: config/velocity_solver.info 81 | poissonSolver: 82 | type: GPU 83 | config: config/poisson_solver.info 84 | forcesSolver: 85 | type: CPU 86 | config: config/forces_solver.info 87 | 88 | bodies: 89 | - type: points 90 | file: flatplate.body 91 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100_GPU/AoA0/config.yaml: -------------------------------------------------------------------------------- 1 | flow: 2 | nu: 0.01 3 | initialVelocity: [1.0, 0.0, 0.0] 4 | boundaryConditions: 5 | - location: xMinus 6 | u: [DIRICHLET, 1.0] 7 | v: [DIRICHLET, 0.0] 8 | w: [DIRICHLET, 0.0] 9 | - location: xPlus 10 | u: [CONVECTIVE, 1.0] 11 | v: [CONVECTIVE, 0.0] 12 | w: [CONVECTIVE, 0.0] 13 | - location: yMinus 14 | u: [DIRICHLET, 1.0] 15 | v: [DIRICHLET, 0.0] 16 | w: [DIRICHLET, 0.0] 17 | - location: yPlus 18 | u: [DIRICHLET, 1.0] 19 | v: [DIRICHLET, 0.0] 20 | w: [DIRICHLET, 0.0] 21 | - location: zMinus 22 | u: [DIRICHLET, 1.0] 23 | v: [DIRICHLET, 0.0] 24 | w: [DIRICHLET, 0.0] 25 | - location: zPlus 26 | u: [DIRICHLET, 1.0] 27 | v: [DIRICHLET, 0.0] 28 | w: [DIRICHLET, 0.0] 29 | 30 | mesh: 31 | - direction: x 32 | start: -4.0 33 | subDomains: 34 | - end: -0.5 35 | cells: 43 36 | stretchRatio: 0.970873786407767 37 | - end: 0.7 38 | cells: 30 39 | stretchRatio: 1.0 40 | - end: 6.1 41 | cells: 54 42 | stretchRatio: 1.03 43 | 44 | - direction: y 45 | start: -5.0 46 | subDomains: 47 | - end: -0.6 48 | cells: 13 49 | stretchRatio: 0.7692307692307692 50 | - end: 0.6 51 | cells: 30 52 | stretchRatio: 1.0 53 | - end: 5.0 54 | cells: 13 55 | stretchRatio: 1.3 56 | 57 | - direction: z 58 | start: -5.0 59 | subDomains: 60 | - end: -1.2 61 | cells: 12 62 | stretchRatio: 0.7692307692307692 63 | - end: 1.2 64 | cells: 60 65 | stretchRatio: 1.0 66 | - end: 5.0 67 | cells: 12 68 | stretchRatio: 1.3 69 | 70 | parameters: 71 | dt: 0.01 72 | startStep: 0 73 | nt: 2000 74 | nsave: 2000 75 | nrestart: 2000 76 | convection: ADAMS_BASHFORTH_2 77 | diffusion: CRANK_NICOLSON 78 | velocitySolver: 79 | type: GPU 80 | config: ../config/velocity_solver.info 81 | poissonSolver: 82 | type: GPU 83 | config: ../config/poisson_solver.info 84 | forcesSolver: 85 | type: CPU 86 | config: ../config/forces_solver.info 87 | 88 | bodies: 89 | - type: points 90 | file: flatplateAoA0.body 91 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100_GPU/AoA10/config.yaml: -------------------------------------------------------------------------------- 1 | flow: 2 | nu: 0.01 3 | initialVelocity: [1.0, 0.0, 0.0] 4 | boundaryConditions: 5 | - location: xMinus 6 | u: [DIRICHLET, 1.0] 7 | v: [DIRICHLET, 0.0] 8 | w: [DIRICHLET, 0.0] 9 | - location: xPlus 10 | u: [CONVECTIVE, 1.0] 11 | v: [CONVECTIVE, 0.0] 12 | w: [CONVECTIVE, 0.0] 13 | - location: yMinus 14 | u: [DIRICHLET, 1.0] 15 | v: [DIRICHLET, 0.0] 16 | w: [DIRICHLET, 0.0] 17 | - location: yPlus 18 | u: [DIRICHLET, 1.0] 19 | v: [DIRICHLET, 0.0] 20 | w: [DIRICHLET, 0.0] 21 | - location: zMinus 22 | u: [DIRICHLET, 1.0] 23 | v: [DIRICHLET, 0.0] 24 | w: [DIRICHLET, 0.0] 25 | - location: zPlus 26 | u: [DIRICHLET, 1.0] 27 | v: [DIRICHLET, 0.0] 28 | w: [DIRICHLET, 0.0] 29 | 30 | mesh: 31 | - direction: x 32 | start: -4.0 33 | subDomains: 34 | - end: -0.5 35 | cells: 43 36 | stretchRatio: 0.970873786407767 37 | - end: 0.7 38 | cells: 30 39 | stretchRatio: 1.0 40 | - end: 6.1 41 | cells: 54 42 | stretchRatio: 1.03 43 | 44 | - direction: y 45 | start: -5.0 46 | subDomains: 47 | - end: -0.6 48 | cells: 13 49 | stretchRatio: 0.7692307692307692 50 | - end: 0.6 51 | cells: 30 52 | stretchRatio: 1.0 53 | - end: 5.0 54 | cells: 13 55 | stretchRatio: 1.3 56 | 57 | - direction: z 58 | start: -5.0 59 | subDomains: 60 | - end: -1.2 61 | cells: 12 62 | stretchRatio: 0.7692307692307692 63 | - end: 1.2 64 | cells: 60 65 | stretchRatio: 1.0 66 | - end: 5.0 67 | cells: 12 68 | stretchRatio: 1.3 69 | 70 | parameters: 71 | dt: 0.01 72 | startStep: 0 73 | nt: 2000 74 | nsave: 2000 75 | nrestart: 2000 76 | convection: ADAMS_BASHFORTH_2 77 | diffusion: CRANK_NICOLSON 78 | velocitySolver: 79 | type: GPU 80 | config: ../config/velocity_solver.info 81 | poissonSolver: 82 | type: GPU 83 | config: ../config/poisson_solver.info 84 | forcesSolver: 85 | type: CPU 86 | config: ../config/forces_solver.info 87 | 88 | bodies: 89 | - type: points 90 | file: flatplateAoA10.body 91 | -------------------------------------------------------------------------------- /examples/decoupledibpm/flatplate3dRe100_GPU/AoA20/config.yaml: -------------------------------------------------------------------------------- 1 | flow: 2 | nu: 0.01 3 | initialVelocity: [1.0, 0.0, 0.0] 4 | boundaryConditions: 5 | - location: xMinus 6 | u: [DIRICHLET, 1.0] 7 | v: [DIRICHLET, 0.0] 8 | w: [DIRICHLET, 0.0] 9 | - location: xPlus 10 | u: [CONVECTIVE, 1.0] 11 | v: [CONVECTIVE, 0.0] 12 | w: [CONVECTIVE, 0.0] 13 | - location: yMinus 14 | u: [DIRICHLET, 1.0] 15 | v: [DIRICHLET, 0.0] 16 | w: [DIRICHLET, 0.0] 17 | - location: yPlus 18 | u: [DIRICHLET, 1.0] 19 | v: [DIRICHLET, 0.0] 20 | w: [DIRICHLET, 0.0] 21 | - location: zMinus 22 | u: [DIRICHLET, 1.0] 23 | v: [DIRICHLET, 0.0] 24 | w: [DIRICHLET, 0.0] 25 | - location: zPlus 26 | u: [DIRICHLET, 1.0] 27 | v: [DIRICHLET, 0.0] 28 | w: [DIRICHLET, 0.0] 29 | 30 | mesh: 31 | - direction: x 32 | start: -4.0 33 | subDomains: 34 | - end: -0.5 35 | cells: 43 36 | stretchRatio: 0.970873786407767 37 | - end: 0.7 38 | cells: 30 39 | stretchRatio: 1.0 40 | - end: 6.1 41 | cells: 54 42 | stretchRatio: 1.03 43 | 44 | - direction: y 45 | start: -5.0 46 | subDomains: 47 | - end: -0.6 48 | cells: 13 49 | stretchRatio: 0.7692307692307692 50 | - end: 0.6 51 | cells: 30 52 | stretchRatio: 1.0 53 | - end: 5.0 54 | cells: 13 55 | stretchRatio: 1.3 56 | 57 | - direction: z 58 | start: -5.0 59 | subDomains: 60 | - end: -1.2 61 | cells: 12 62 | stretchRatio: 0.7692307692307692 63 | - end: 1.2 64 | cells: 60 65 | stretchRatio: 1.0 66 | - end: 5.0 67 | cells: 12 68 | stretchRatio: 1.3 69 | 70 | parameters: 71 | dt: 0.01 72 | startStep: 0 73 | nt: 2000 74 | nsave: 2000 75 | nrestart: 2000 76 | convection: ADAMS_BASHFORTH_2 77 | diffusion: CRANK_NICOLSON 78 | velocitySolver: 79 | type: GPU 80 | config: ../config/velocity_solver.info 81 | poissonSolver: 82 | type: GPU 83 | config: ../config/poisson_solver.info 84 | forcesSolver: 85 | type: CPU 86 | config: ../config/forces_solver.info 87 | 88 | bodies: 89 | - type: points 90 | file: flatplateAoA20.body 91 | --------------------------------------------------------------------------------