Wiki

Clone wiki

ug3 / examples

Test cases and sample results

Dependencies

You need the following to compile and run the code.

  1. A modern Fortran compiler like gfortran to compile solver
  2. MPI library (use Mpich since Openmpi seems to have memory leaks)
  3. PETSc library (need >= v3.8.0) needed by the solver. Set the shell variable PETSC_DIR to point to the directory containing PETSc include and library files.
  4. Metis library for partitioning. Set the shell variable METIS_DIR to point to the directory containing the Metis installation.
  5. (Optional) HDF5 library for saving solution. Set shell variable HDF5_DIR.
  6. (Optional) SZIP library for compression. Set shell variable SZ_DIR.
  7. 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

  1. param.in: This controls some numerical parameters like CFL number, etc.
  2. 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 ug3exa directory.

Add shell variable to specify the location of UG3, e.g., add the following in your $HOME/.bashrc file

export UG3_DIR=/home/praveen/Applications/ug3
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 examples/oneram6.

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.

param.in file

Parameters to control the simulation are read from the file param.in. A sample file is located in /path/to/ug3exa/param.in.

user.fpp file

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

#include "eos/ideal.f95"

Next, select the reconstruction scheme by including appropriate file as described below.

First order scheme

#include "recon/first.f95"

Second order scheme

#include "recon/second.f95"
Also set lbeta in param.in file. This must be between 0.5 and 1.

Minmod scheme

#include "recon/minmod.f95"
Also set lbeta in param.in file. This must be between 1 and 2.

MUSCL-type scheme

#include "recon/muscl.f95"
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"
Also set lbeta in param.in file. This must be between 1 and 2.

Minmax scheme

#include "recon/second.f95"
and set lgrad=1 in param.in file.

Venkatakrishnan scheme

#include "recon/second.f95"
and set lgrad=2 and the value of kvenkat in param.in file.

Numerical flux

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"
If using flux/hybrid.f95, set the parameters ducros_u0 and ducros_L0 in param.in file.

subroutine userinit

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 gasGam and gasR must be set here.

subroutine useric

This subroutine must set initial condition at a given spatial location.

subroutine userbc

This subroutine applies boundary condition based on face tag.

subroutine userdiff

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.

subroutine userpost

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

call checkpos(s)
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
3-stage RK
./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
./ug3 -options_table
To show which options were not used (may help to find wrong argument)
./ug3 -options_left
To print the PETSc timer logs at end of run
./ug3 -log_view
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 &

Updated