Test cases and sample results
- Test cases and sample results
- How to setup a test case
- param.in file
- user.fpp file
- Using PETSc TS
- Some tips and tricks
You need the following to compile and run the code.
- A modern Fortran compiler like gfortran to compile solver
- MPI library (use Mpich since Openmpi seems to have memory leaks)
- PETSc library (need >= v3.8.0) needed by the solver. Set the shell variable
PETSC_DIRto point to the directory containing PETSc include and library files.
- Metis library for partitioning. Set the shell variable
METIS_DIRto point to the directory containing the Metis installation.
- (Optional) HDF5 library for saving solution. Set shell variable
- (Optional) SZIP library for compression. Set shell variable
- C++ compiler for preprocessor
To visualize the results, we use a variety of open source tools like gnuplot, python, matplotlib, VisIt (with python scripting). The solution files are stored as vtk files with each partition writing its own solution file.
How to setup a test case
UG3 must be compiled for each test case for which you must create the following files
param.in: This controls some numerical parameters like CFL number, etc.
user.fpp: This contains subroutines for initial condition, boundary condition, etc.
To find out the format of these files, see the sample files in the
src_mpi directory or in the
Add shell variable to specify the location of UG3, e.g., add the following in your
You must select a compiler; e.g., to use GNU compilers, do
cd $UG3_DIR/src_mpi ln -s makefile_gnu.in makefile.in
Additionally, add other required softwares to your PATH variable, e.g.,
PATH=$PATH:/path/to/ug3pre/src PATH=$PATH:/path/to/gmsh/bin export PATH
As an example consider compiling the test case in
cd /path/to/ug3exa/oneram6 cp /path/to/ug3exa/makefile . make euler
If the compilation was successful, the executable
ug3 will be located in the same directory. To run a single process job, do
./ug3 > log.txt &
To run an mpi job, do
mpirun -np 4 ./ug3 > log.txt &
Always pipe the output to a file; without this the code will run slow as writing to screen is a slow process.
Parameters to control the simulation are read from the file
param.in. A sample file is located in
This file will be preprocessed by the compiler to generate a
user.f95 file. The equation of state, reconstruction scheme and numerical flux are set here by included appropriate files. See the sample file in
$UG3_DIR/src_mpi/user.fpp or in the examples.
At the top of the file, there must be a module with some size variables, e.g.,
module userdata implicit none integer,parameter :: mvc = 8 ! number of vertices per cell integer,parameter :: nvar = 5 ! number of variables end module userdata
This module will be included in many of the subroutines.
Equation of state
Currently, only the ideal gas is provided, so add this line
Next, select the reconstruction scheme by including appropriate file as described below.
First order scheme
Second order scheme
param.in file. This must be between 0.5 and 1.
param.in file. This must be between 1 and 2.
In this case, the limiter function has to be selected by including one of the following files
#include "recon/vanalbada.f95" #include "recon/vanleer.f95"
param.in file. This must be between 1 and 2.
lgrad=2 and the value of
Select the numerical flux by including one of the following files
#include "flux/roe.f95" #include "flux/rusanov.f95" #include "flux/hllc.f95" #include "flux/kepec.f95" #include "flux/hybrid.f95"
flux/hybrid.f95, set the parameters
This subroutine is called once before any computations start. It can be used to set some constants or parameters needed in other subroutines in
user.f95, for example freestream conditions. The constants related to the gas must be set in this subroutine, atleast the variables
gasR must be set here.
This subroutine must set initial condition at a given spatial location.
This subroutine applies boundary condition based on face tag.
This subroutines applies boundary condition on shear stress and heat flux needed for symmetry boundary or adiabatic boundary, and is needed only for Navier-Stokes computations.
This subroutine is called after every time step is completed. It can be used to do some postprocessing like computing lift, drag coefficients, checking positivity of solution, etc. To check positivity, add
If solution becomes negative anywhere, then the code will stop.
Using PETSc TS
You can use time stepping schemes from Petsc by setting
-tscheme petscts for the time scheme in param.in file. This scheme must be used for time accurate computations which requires global time stepping.
2-stage, 2-order SSPRK
./ug3 -ts_type ssp -ts_ssp_type rks2
4-stage, 3-order SSPRK (same as ssprk43)
./ug3 -ts_type ssp -ts_ssp_type rks3 -ts_ssp_nstages 4
./ug3 -ts_type rk -ts_rk_type 3 -ts_adapt_type none
Third order RK scheme of Bogacki-Shampine with 2nd order embedded method. This method has four stages.
./ug3 -ts_type rk -ts_rk_type 3bs -ts_adapt_type basic # default scheme, adaptive time stepping ./ug3 -ts_type rk -ts_rk_type 3bs -ts_adapt_type none # without adaptive time stepping
Classical fourth order RK
./ug3 -ts_type rk -ts_rk_type 4 -ts_adapt_type none
Fifth order Fehlberg RK scheme with a 4th order embedded method. This method has six stages.
./ug3 -ts_type rk -ts_rk_type 5f -ts_adapt_type basic # adaptive time stepping ./ug3 -ts_type rk -ts_rk_type 5f -ts_adapt_type none # without adaptive time stepping
Fifth order Dormand-Prince RK scheme with the 4th order embedded method. This method has seven stages.
./ug3 -ts_type rk -ts_rk_type 5dp -ts_adapt_type basic # adaptive time stepping ./ug3 -ts_type rk -ts_rk_type 5dp -ts_adapt_type none # without adaptive time stepping
Some tips and tricks
To print cell topology information
./ug3 -print_topo yes
To perform some grid checks
./ug3 -check_grid yes
To save vorticity into the solution files
./ug3 -save_vort yes
To save Q-criterion into the solution files
./ug3 -save_q yes
To print list of all options
To show which options were not used (may help to find wrong argument)
To print the PETSc timer logs at end of run
You can also try
./ug3 -log_view ::ascii_info_detail # prints a Python module with the data ./ug3 -log_view ::ascii_xml # prints an XML file which can be viewed in a web browser
Catch all error messages in a log file
mpirun -np 10 ./ug3 > log.txt 2>&1 &