Example Three
Example Three
Patching Fields
This offering is not approved or endorsed by ESI® Group, ESI-OpenCFD® or the OpenFOAM®
Foundation, the producer of the OpenFOAM® software and owner of the OpenFOAM® trademark.
OpenFOAM® Basic Training
Tutorial Three
ISBN 978-3-903337-02-2
Publisher: chemical-engineering.at
Available from: www.fluiddynamics.at
OpenFOAM® Basic Training
Tutorial Three
Background
Tutorial Three
As it is obvious from the equation by decreasing the mesh size (i.e. ∆𝑥), the
time step size (∆𝑡) should also be adjusted (decreased) for reaching a stable
and convergent solution. Therefore the CFL condition is useful in helping us
choose a suitable time step size for our simulation. A common way of selecting
the time step size is to keep Courant number at 1, using the maximum possible
u and the smallest possible mesh size, a Δt that fits the criteria can be
calculated.
OpenFOAM® Basic Training
Tutorial Three
rhoPimpleFoam – shockTube
Tutorial outline
Use the rhoPimpleFoam solver; simulate 0.007 s of flow inside a shock tube,
with a mesh with 100, 1000 and 10000 cells in one dimension, for initial values
1 bar/0.1 bar and 10 bar/0.1 bar.
Objectives
To understand the setFields utility
Learn how to specify initial and boundary conditions
Investigate effect of grid resolution.
Data processing
Import your simulation into ParaView, and compare results.
OpenFOAM® Basic Training
Tutorial Three
1. Pre-processing
$FOAM_TUTORIALS/compressible/rhoPimpleFoam/laminar/shockT
ube
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * *//
>blockMesh
>setFields
Then run:
>rhoPimpleFoam
OpenFOAM® Basic Training
Tutorial Three
Note: In the 10000 cell case with 10 bar and 0.1 bar, the simulation will crash
with the default deltaT (1e-5); after checking the same case with 1000 cells,
you will find that the maximum Co is around 0.6 (Time = 0.001):
Courant Number mean: 0.0508555 max: 0.589018
In the case with 10000 cells, the number of cells is increased by factor 10, so
the cell size is reduced by factor 10. For keeping the Courant number in the
same range (around 0.6), according to the “Background” section, deltaT
should be decreased by factor 10. After reducing it to 1e-6 the simulation will
run smoothly.
Note: After running setFields for the first time, the files in the 0 directory are
overwritten. If the mesh is changed these files are not compatible with the new
mesh and the simulation will fail. To solve this problem replace the files in the
0 directory with the files in the 0.orig or the files with suffix “.orig”, e.g. p.orig in
the 0 directory. In the OpenFOAM® files or directories with suffix “.orig”
(“original”) usually contain the backup files. If a command changes the original
files these files can be replaced.
3. Post-processing
The simulation results are as follows:
OpenFOAM® Basic Training
Tutorial Three
Velocity along tube axis for 10 bar/0.1bar and 10000 cells case at t = 0.007s
OpenFOAM® Basic Training
Tutorial Three
Pressure along tube axis for 10 bar/0.1bar and 10000 cells case at
t = 0.007s
OpenFOAM® Basic Training
Tutorial Three
Temperature along tube axis for 10 bar/0.1bar and 10000 cells case at
t = 0.007 s
OpenFOAM® Basic Training
Tutorial Three