OpenFOAM Tutorial
OpenFOAM Tutorial
discussions, stats, and author profiles for this publication at: https://www.researchgate.net/publication/282272911
CITATIONS READS
0 7,041
1 author:
Victor Pozzobon
Ecole Centrale Paris
7 PUBLICATIONS 8 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
OpenFOAM tutorial
Discover it, tame it, use it
by Victor Pozzobon
(victor.pozzobon@mines-albi.fr)
Mesh directory
Mesh instructions
Parameters file
14th March 2016 Pozzobon Victor 10
Ex. 1: Cavity – Run the case
Scene
2 cm 20 cm
Wall 2
7 1
4
Inlet Outlet
y
Symmetry
0 3
14th March 2016 plane Pozzobon Victor 19
Ex. 2: Square tube – A new mesh
● Beware, the
points are to be Scaling
prescribed in factor
order not to
back cross a line Block division
● Do (0 4 7 3) along axis
Points
locations Division grading
4 7
0 3 Points needed to
14th March 2016 Pozzobon Victor build a block 20
Ex. 2: Square tube – A new mesh
Face
● Avoid (0 3 4 7) name
4 7
Face
type
0 3 Point sequence
delimiting the
face
Wall
Inlet Outlet
Boundary condition
on 'inlet' patch
14th March 2016 Pozzobon Victor 24
Ex. 2: Square tube – IC / BC, p
● Open transportProperties
file, this is where physical
properties value (e.g.
viscosity) are specified:
gedit constant/transportProperties
Property name
Property dimension
[ kg m s K mol A Cd]
Property value
Subdictionaries for some viscosity laws,
can be removed in our case
14th March 2016 Pozzobon Victor 27
Ex. 2: Square tube – Control values
● Setting a 1D case
● Solving a transient problem
● Postprocessing with ParaFOAM: importing
variables (other than p and U)
20 cm
● Modify file:
gedit system/blockMeshDict
● Build mesh:
blockMesh
● Setting a 2D case
● Building a 2 block mesh
● Changing convergence criterion
● Postprocessing with ParaFoam: plotting
streamlines
2m
2m
14th March 2016 Pozzobon Victor 41
Ex. 4: 2D flat plate – Case creation
Inlet Outlet
Symmetry
wall
Block 1
Down Plate
Block 2
14th March 2016 Pozzobon Victor 43
Ex. 4: 2D flat plate – Creating mesh
Solver
Solved type and
field options
14th March 2016 Pozzobon Victor 49
Ex. 4: 2D flat plate – Convergence
Residues values
set for convergence
14th March 2016 Pozzobon Victor 50
Ex. 4: 2D flat plate – Run the case
1 cm
Axis
Outlet
Inlet
5°
Front and
Back
Wall
14th March 2016 Pozzobon Victor 57
Ex. 5: 2D pipe – Block creation
● Draw a wegde,
with a 5° angle
(twice 2.5°)
● Points 1, 2 and 3 are
not used to build the cos(2.5°)
geometry. OpenFOAM
uses them to define sin(2.5°)
x, y and z directions :
- point 0 to point 1 = x
- point 1 to point 2 = y
- point 0 to point 4 = z
14th March 2016 Pozzobon Victor 58
Ex. 5: 2D pipe – Patches creation
● In order to do things
by the book, create
two 'wedge' patches
(here, 'front' and
'back')
● It would have worked
with only one, but
checkMesh would have
returned an error
⃗ =0
∇ .U ⃗ = −κ
U μ ∇p ∇ 2 p=0
Symmetry
planes
Inlet Outlet
100 cm
14th March 2016 Pozzobon Victor 66
Ex. 6: Tubular reactor – Solver
directory creation
● Reach 'run' directory:
run
● Create a solver directory:
mkdir solvers
● Copy an existing solver:
cp -r $FOAM_APP/solvers/basic/laplacianFoam solvers/.
● Rename the solver directory:
mv solvers/laplacianFoam solvers/tubeFoam
Pressure field
(scalar field)
Velocity field
(vector field)
Physical property
called 'Mu'
Solved equations
(implicit '=0')
Error file
and line number
3. Take care of it
Number of correction
iteration (used for non
orthogonal meshes)
Changing it is not
mandatory
100 cm
14th March 2016 Pozzobon Victor 84
Ex. 7: Tubular reactor – Solver
directory creation
● Reach 'run' directory:
run
● Move to solver directory:
cd solvers
● Copy the existing solver:
cp -r tubeFoam tubeChemFoam
● Move to and clean the directory:
cd tubeChemFoam
wclean
Defined in
the source
14th March 2016 Pozzobon Victor code 87
Ex. 7: Tubular reactor – Solver
modification / createFields.H
● Modify createFields.H to
read the physical
properties:
gedit createFields.H
Interpolates the
velocity field on the
mesh in order to
later calculate the
divergence operator
● Modify physical
properties:
gedit constant/transportPropeties
1 cm
⃗
dU p 2 ⃗
⃗ ⃗
+ U ∇ . U =−∇ ρ +η∇ U
dt
14th March 2016 Pozzobon Victor 99
Ex. 8: Heating pipe – Case setup
T inlet = 20 °C
T surrounding = 80 °C
−k ∇ T . ⃗n =−h(T −T sur )
14th March 2016 Pozzobon Victor 100
Ex. 8: Heating pipe – Solver
creation
● Reach 'run' directory:
run
● Move to solver directory:
cd solvers
●
Copy simpleFoam:
cp -r $FOAM_APP/solvers/incompressible/simpleFoam .
mv simpleFoam simpleThermFoam
● Move to the new solver directory:
cd simpleThermFoam
Loading turbulence
model (we do not
use it in this case)
Add temperature
field
Loading
transportProperties
dictionary
files
options
dt −k ∇ T . ⃗n =−h(T −T sur )
−Ea
d LC
1
−Ea T
=−A 2 e LC + A 1 e RT C
2
dt
Chocolate
14th March 2016 Pozzobon Victor 128
Ex. 9: Cake baking – Solver
directory creation
● Reach 'run' directory:
run
● Move to solver directory:
cd solvers
● Copy the existing solver:
cp -r tubeFoam cakeFoam
● Move to and clean the directory:
cd cakeFoam
wclean
Top
Left
Down Right
SymmetryWall
Water inlet
Tank walls
● Modify velocity
boundary conditions
according to the case
setup:
gedit 0/U
Negative because of
axis orientation
Negative because of
axis orientation
Number of processors
that are going to be
used
Maximum Courant
number
Number of processors
you want to use (has to
be in agreement with
decomposeParDict)
Adjust Camera
button