0% found this document useful (0 votes)
284 views

OpenFOAM Course Notes

This document provides course notes for a 2018 OpenFOAM workshop at University College London. It introduces OpenFOAM, covering installation, case setup, and running simulations. It then provides tutorials for ship flow simulation, wave simulation using the waves2foam toolbox, and fluid-structure interaction simulations. The overall document serves as a reference for learning OpenFOAM and completing hands-on tutorials during the workshop.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
284 views

OpenFOAM Course Notes

This document provides course notes for a 2018 OpenFOAM workshop at University College London. It introduces OpenFOAM, covering installation, case setup, and running simulations. It then provides tutorials for ship flow simulation, wave simulation using the waves2foam toolbox, and fluid-structure interaction simulations. The overall document serves as a reference for learning OpenFOAM and completing hands-on tutorials during the workshop.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/331313286

UCL OpenFOAM Course Notes 2018

Technical Report · June 2018


DOI: 10.13140/RG.2.2.29439.05284

CITATIONS READS
0 2,108

4 authors:

Luofeng Huang Rui Song


University College London University College London
39 PUBLICATIONS   107 CITATIONS    16 PUBLICATIONS   192 CITATIONS   

SEE PROFILE SEE PROFILE

Daniela Benites Weilin Zeng


University College London University College London
8 PUBLICATIONS   8 CITATIONS    27 PUBLICATIONS   2,221 CITATIONS   

SEE PROFILE SEE PROFILE

Some of the authors of this publication are also working on these related projects:

SEDNA: Safe maritime operations under extreme conditions; the Arctic case View project

OpenFOAM Teach, Research and Development View project

All content following this page was uploaded by Luofeng Huang on 24 February 2019.

The user has requested enhancement of the downloaded file.


A doctoral skill course at University College London
Established with a UCl Research-led initiative Award

Course Notes:
UCL OpenFOAM Course 2018
funded by the UCL Doctoral Skills Development Programme

Authors:
Luofeng Huang
Rui Song
Daniela Benites
Weilin Zeng

Department of Mechanical Engineering


University College London

June 2018
Preface

OpenFOAM (https://www.openfoam.com/) is an opensource simulation tool originally developed


by Jasak et al. [1] and Weller at al. [2]. It has been successfully applied to various research areas,
including Engineering, Physics, Chemistry and Biology. By employing OpenFOAM, one can simu-
late the desired physical process using a computer, followed by the post-processing utility to analyse
the results. Pictures and videos can be generated to illustrate the process. As the development of
IT technique, OpenFOAM has become a powerful skill for a scientific researcher to grasp.

Compared with other commercial simulation tools, people usually think that OpenFOAM is more
difficult to learn. The main difficulty includes:
• A beginner is not familiar with its operation environment, Linux.

• To understand OpenFOAM codes requires a foundation in Computational Fluid Dynamics


(CFD) and C++.
• Online study materials are not comprehensive, and on-site courses are in scarcity.
However, after getting through an initial adaptive period, you would start to enjoy the beauty of
OpenFOAM. Every OpenFOAM code is accessible, where you can find the intelligence of numerical
approaches, which is the wisdom crystallisation of many great scientists. By using OpenFOAM, you
will gain a deep understanding on CFD theories and how the theories are implemented. Further-
more, as OpenFOAM package is opensource, you are free to conduct any modifications upon the
codes, which would be a fantastic way to perform your research innovation.

The UCL OpenFOAM Course is free, aiming to help research students start using OpenFOAM
and generate research interests. The notes play a role of assisting the on-site courses held at UCL,
but we still try our best to make everything clear here, for others who may learn online. During the
workshops, we will teach the basic of OpenFOAM and some applications. In the form of hands-on
workshops, participants will be able to follow our tutorials step-by-step. Besides, we will discuss the
possibility of collaborative projects using OpenFOAM.

The course was inspired by the OSCFD course being taught by Håkan Nilsson at Chalmers Univer-
sity of Technology, Sweden (http://www.tfd.chalmers.se/~hani/kurser/OS_CFD/). It is a more
advanced and comprehensive OpenFOAM course, which is highly appreciated by the OpenFOAM
learners around the world.

1
Contents

1 OpenFOAM basis 1
1.1 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.1 Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.2 OpenFOAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 OpenFOAM case setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2.1 Foundational CFD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2.2 Mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2.3 Timestep and solver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2.4 Initial and boundary conditions . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.3 Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

2 Ship flow simulation 9


2.1 Case introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 Free-surface modelling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3 Boundary conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.4 Mesh around the ship . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.5 Ship resistance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

3 Wave simulation 18
3.1 Installation(waves2foam) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.2 Test case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.3 Tutorial: waves pass through a plate . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.3.1 Theoretical background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.3.2 Case setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.3.3 Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.3.4 Post-processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

4 Fluid-Structure Interaction 25
4.1 Preparation: stress-analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.2 Installation(FSI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.2.1 foam-extend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.2.2 fsiFoam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.3 FSI approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.4 FSI tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.4.1 Case structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.4.2 Mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.4.3 Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.5 Wave-induced FSI problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.5.1 Code development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.5.2 Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

2
5 Combustion 36
5.1 Turbulent reacting flows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.1.1 Governing equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.1.2 Large Eddy Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5.1.3 Turbulent modelling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.1.4 Combustion modelling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.2 reactingFoam and PaSR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.3 Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.3.2 Mesh and boundary conditions . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.3.3 Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.3.4 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

Reference 44

Reading recommendation 45

Acknowledgements 46
Chapter 1

OpenFOAM basis

1.1 Installation
1.1.1 Linux
OpenFOAM can be installed on Linux, macOS and Windows, but Linux has the best compatibility
and covers all the functions of OpenFOAM. Therefore, it is recommended to install Linux to operate
OpenFOAM.

The easiest way to install Linux system is to install a virtual machine on top of your original
operation system (e.g. Windows). An instruction to install a virtual linux system is given as follows
(based on the notes provided by Professor Håakan Nilsson).

1. Download the official version VirtualBox (both Platform Packages and Extension Pack), from
https://www.virtualbox.org/wiki/Downloads. Install it.
2. After installing VirtualBox, start it and:
Create new virtual disk:
Click on New
Name: Ubuntu 16.04 LTS
Operating System: Linux
Version: Ubuntu 64-bit (in case you can only select 32-bit here, see http://www.fixedbyvonnie.
com/2014/11/virtualbox-showing-32-bit-guest-versions-64-bit-host-os/#.WvHgFYgvxPY)
Base memory: 2048MB (minimum 2GB required for 64-bit operating system)
Create a virtual hard drive now
VDI
Dynamically allocated
Set a limit on hard drive storage to 50GB
Click on Create
(Settings can be changed later)
3. Download Ubuntu 16.04 from http://releases.ubuntu.com/16.04/,
click 64-bit PC (AMD64) desktop image (under Select an image - Desktop image),
then you will get an iso file (1.5GB).
4. Double-click on the virtual disk you just created in VirtualBox. In the pop-up window, click
on the icon ”Choose a virtual optical disk file”, and browse to the Ubuntu iso-file you just
downloaded.
Ubuntu should be initialised in a window named ”Ubuntu 16.04 LTS [Running] Oracle VM
VirtualBox”.
Click on Install Ubuntu and select your specific settings
It is recommended that you tick: Download updates while installing, and Install third-party

1
1.1. INSTALLATION CHAPTER 1. OPENFOAM BASIS

software
Restart when asked (just click on the button that pops up). You may need to press Enter at
some point.
(When it asks you if it should erase the disk, don’t worry - it refers to the virtual disk you
have just created in VirtualBox, not your Windows disk.)

5. After the installation is done. You will enter an Linux Desktop (Ubuntu).

Figure 1.1: Linux desktop of Ubuntu

1.1.2 OpenFOAM
In a Linux system, you are ready to install OpenFOAM. OpenFOAM has different versions, and it
keeps updating. Here we give the example of how to install OpenFOAM 4.0. (most of functions are
the same in different versions)
To install and utilise OpenFOAM, it is essential to use a Terminal. By press ”Ctrl+Alt+T”, a
terminal window will occur, where you can type your commands.

Figure 1.2: A terminal in Ubuntu

1. In your terminal, copy-paste-enter the following commands (one by one, you may need to enter
your password at some points to give permission). Note the short cuts for copy and paste are
”ctrl+shift+c” and ”ctrl+shift+v” respectively.
sudo add-apt-repository http://dl.openfoam.org/ubuntu
sudo sh -c "wget -O - http://dl.openfoam.org/gpg.key | apt-key add -"

2
1.2. OPENFOAM CASE SETUP CHAPTER 1. OPENFOAM BASIS

sudo apt-get update


sudo apt-get -y install openfoam4
2. Now, OpenFOAM has been installed on your computer. Do one more step to complete user
configuration
In the terminal, execute gedit ~/.bashrc, then a file will be opened.
At the end of the file, ADD a line: source /opt/openfoam4/etc/bashrc
Save the file.
3. create a your own directory to store your OpenFOAM file, by executing the following line in
a terminal:
mkdir -p $FOAM_RUN

Congratulations. Your OpenFOAM 4.0 should have been set up OK.


(The above steps are referred from https://openfoam.org/download/4-0-ubuntu/. Check it out
for problems and more information.)

1.2 OpenFOAM case setup


Once installed, OpenFOAM files are saved at the directory: computer/opt/openfoam4

There are many ready-to-use cases stored under the folder ”tutorials”, which are fantastic to start
with. Your own cases can always be modified based on these tutorials, so you should never write
the whole codes.
Note: when modifying a tutorial, you should first copy it to your own directory, which was created in
the last step of the installation(home/OpenFOAM/yourname/run), so that the original case setting
can be preserved.

3
1.2. OPENFOAM CASE SETUP CHAPTER 1. OPENFOAM BASIS

Let’s enter a tutorial case to see how a basic OpenFOAM case looks like,
go to: tutorials/incompressible/icoFoam/cavity/cavity

A basic OpenFOAM case consists of three separate directories:

1. The ”0” time folder: the boundary and initial conditions for each of the variables in question,
e.g. pressure, velocity.
2. The ”constant” folder: the properties of the fluid in question, e.g. viscosity, density.
3. The ”system” folder: how will we solve the case, including space discretization, time discretiza-
tion, solver (what governing equations to use) and numerical scheme/solution.

1.2.1 Foundational CFD


Before further learning of OpenFOAM, this is a short section to prepare a little CFD knowledge as
background.
The basic idea to solve an OpenFOAM simulation includes two parts, space discretization and time
discretization. Space discretization is to devide a domain of interest into a number of non-overlapping
cells, known as mesh; time discretization is to split a process into a number of timesteps.
When we want to learn a process, we mesh the domain by a number of cells and get the solution
of each single cell, which compose into the solution of the whole space domain. This is similar to a
film: a single frame is performed via many elements, and a higher cell number can provide a better
resolution.

4
1.2. OPENFOAM CASE SETUP CHAPTER 1. OPENFOAM BASIS

Timestep is simpler. When the time of a process you want to learn is certain, e.g. 10s. 100-timesteps
means you want to solve the results per 0.1s; then 1000-timesteps means 0.01s.
To sum up, increasing cell number or timestep number means solving a simulation with a higher
requirement, while the computational time will increase accordingly.

Then, for a single cell and a timestep, we can solve the governing equations to obtain the parametres
that are of interest, e.g. the Navier-Stokes equations, to solve the pressure (P ) and velocity (v).

∇·v =0 (1.1)

∂(ρv)
+ ∇ · (ρvv) − ∇ · τ = −∇p + ρg (1.2)
∂t

1.2.2 Mesh
The generation of mesh is dictated by a file called blockMeshDict, stored under the system direc-
tory.
Open the blockMeshDict of the cavity tutorial, we can see the content as in the picture below.
(after ”//” are annotations)

OpenFOAM always operates in a three-dimensional Cartesian coordinate system. In blockMeshDict,


first we need to define some vertices:
Once the vertices are defined, they are numbered in order (start with 0, so there are 8 points in
total, numbered 0-7).
The vertices 0-7 can form a hexahedron, which is defined in the blocks part, and this is our com-
putational domain.
(20 20 1) means the hexahedron will be meshed with 20 cells in the X direction, 20 cells in the Y
direction and 1 cell in the Z direction (in a two-dimensional problem, we only put one cell in the
inactive direction).
Therefore, this domain will be divided into 20*20*1 = 400 cells.
The simplegrading (1 1 1) means the sizes of the mesh are uniform on all X Y Z directions.
Changing the value here can make the cell size gradually increase along a direction. For example,
simplegrading (10 1 1) means the length of the last cell is 10 times of that of the first cell along the
X direction.

Every four vertices can form a face, which can be classified in the Boundary part:

5
1.2. OPENFOAM CASE SETUP CHAPTER 1. OPENFOAM BASIS

1.2.3 Timestep and solver


The system/controlDict codes are shown as follows, in which you can modify the solver, runtime,
time-step size, how often the results are stored, etc..
The name of a OpenFOAM solver ends with Foam, and the prefixion depends on the solver type.
For example:
icoFoam solves the incompressible laminar Navier-Stokes equations using the PISO algorithm;
interFoam is a solver for 2 incompressible fluids;
fsiFoam is used for Fluid-Structure Interaction (FSI) problems;

6
1.2. OPENFOAM CASE SETUP CHAPTER 1. OPENFOAM BASIS

1.2.4 Initial and boundary conditions


So far, we introduced the setting of how to solve a case. Now we are going to discuss how to define
a problem physically, which is known as initial condition (IC) and boundary conditions (BC). IC is
straightforward to understand - it defines the initial configurations of a simulation, i.e. when t = 0.
BC defines how the simulation being pushed forward per timestep.
Open the 0 folder, there are two files called P and U, which defines the IC and BC for presure and
velocity respectively.
Here we use the U file to give an example. As there are three kinds of boundary defined in
blockMeshDict, movingWall, fixedWall and frontAndBack. The U file shows the movingWall bound-
ary always have a constant velocity of (1 0 0), and the fixedWall does not have a velocity. ”empty”
BC is usually used on the inactive boundaries of a two-dimensional problem, which can be under-
stand as: no solution is required.

Thus, the case is set up as:


Fluid is initialised as static in a box.
The upper wall of the box start moving towards the right at a velocity of 1 m/s, while the other
walls keep fixed. The moving wall will change the status of the fluid inside, as the fluid has viscosity
(see constant/transportProperties).
If you run the simulation, OpenFOAM will tell you what would happen in such a box.

7
1.3. SIMULATION CHAPTER 1. OPENFOAM BASIS

1.3 Simulation
To run this simulation you need to execute the following steps from your terminal:
1. as mentioned earlier, always copy the case to your user directory before running or modifying,
so as to keep the original file:
cp -r ../../opt/openfoam4/tutorials/incompressile/icoFoam/cavity/cavity $FOAM_RUN
cd $FOAM_RUN/cavity

2. build the mesh:


blockMesh
3. launch the solver:
icoFoam

4. post-processing (OpenFOAM is installed with an opensource post-processing tool - paraview)


paraFoam
5. now you have entered paraview and you can view the computational results (the field of P and
U for each time step)

More details please see: https://www.openfoam.com/documentation/tutorial-guide/tutorialse2.


php#x6-60002.1

8
Chapter 2

Ship flow simulation

To study how to simulate ship flow in OpenFOAM, we use a case of DTCHull as an example in this
chapter, which is stored under tutorials/multiPhase/interFoam/ras/DTCHull.

2.1 Case introduction


A schematic diagram of the case is shown in Figure 2.1. The flow field is a multi-phase field, with
air in the upper part and water in the lower part. The ship model was initialised as floating on the
water surface according to the designed draft, and it was fixed. To be conformed to an open ocean
environment, the computational domain was modelling as infinite, i.e. no boundary wall was set at
the sides or the bottom. A constant velocity (U) against the ship bow was set to the water, which
provided the ship resistance. The total resistance of the ship was considered in this work, which is
calculated as the sum of the force component against the bow direction.

Figure 2.1: Schematic diagram of the simulation case. The hull is floating on the water surface and subjected
to flowing water of a constant velocity (U ).

2.2 Free-surface modelling


As the fluid domain is a two-phase mixture of air and water, the Volume of Fluid (VOF) method
[3] was used to model the free surface. The VOF method introduces a passive scalar α, which
denotes the fractional volume of a cell occupied by a specific phase. In this model, a value of α = 1
corresponds to a cell full of water and a value of α = 0 indicates a cell full of air. Thus, the free

9
2.3. BOUNDARY CONDITIONS CHAPTER 2. SHIP FLOW SIMULATION

surface, which is a mix of these two phases, is formed by the cells with 0 < α < 1. The α value was
solved by its transport equation as expressed in Equation 2.1, and further the local density (ρ) and
viscosity (µ) were determined according to the corresponding α, as Equation 2.2 and 2.3.
∂α
+ ∇(vα) = 0 (2.1)
∂t

ρ = αρwater + (1 − α)ρair (2.2)

µ = αµwater + (1 − α)µair (2.3)


The multi-phase model is defined in system/setFieldDict, as:

It defines a specific area where α = 1, and the other area defaults α = 0. Here it says the cells of
Z < 0.244 m is water and Z > 0.244 m is air, so the free surface of this case is at Z = 0.244 m.

2.3 Boundary conditions


The BCs of this case is to generate a water flow of steady velocity, which is explained separately as
0/U and 0/P.

U:
• Inlet: fixedValue is a vbasic BC and easy to understand. Here it gives the inlet boundary a
constant speed of (-1.668 0 0) towards the outlet direction.
• Outlet: outletPhaseMeanVelocity adjusts the velocity for the given phase to achieve the
specified mean thus causing the phase-fraction to adjust according to the mass flow rate. By
applying this boundary condition, the mass flow rate of the water phase in the outlet boundary
is set to equal to the inlet mass rate, so that the water volume in the computational domain
can keep constant. This BC can avoid the waterline continuously increase/decrease, which is
typically used as the outlet condition for a towing-tank ship simulation in order to maintain
the outlet water level as the same as the inlet.
• Atmosphere: pressureInletOutletVelocity - here we specific the tangential velocity across
this face to equal (-1.668 0 0).

10
2.3. BOUNDARY CONDITIONS CHAPTER 2. SHIP FLOW SIMULATION

P:
• Inlet: fixedFluxPressure is used to set the pressure gradient to be specified by the velocity
boundary condition, so that the fixed water velocity can be matched.
• Outlet: zeroGradient means the gradient of pressure equals to zero, typically used as outlet
pressure BC.

• Atmosphere: totalPressure calculates the pressure from a specified total pressure p0 and
local velocity U. (Here we define the atmosphere pressure to be 0 pascal)

11
2.4. MESH AROUND THE SHIP CHAPTER 2. SHIP FLOW SIMULATION

2.4 Mesh around the ship


As a realistic ship hull is complex, blockMesh is incapable to build the mesh around the hull. Here
we use another OpenFOAM mesh tool snappyHexMesh to refine the mesh around the hull.

There are three main steps in SnappyHexMesh:


1. castellatedMesh
2. snap
3. addLayers

An example is given below to illustrate the process: (details please see https://cfd.direct/
openfoam/user-guide/snappyhexmesh/)

This is a geometry in a domain after blockMesh:

castellatedMesh: the edges of the geometry are detected, and then the meshes that intersect with
the edges are refined.

snap: the cells inside the geometry are removed, and then the boundary is smoothed.

addLayers: shrink the existing mesh from the boundary and insert layers of cells

12
2.4. MESH AROUND THE SHIP CHAPTER 2. SHIP FLOW SIMULATION

In the DTCHull case, the snappyHexMesh is governed by system/snappyHexMeshDict.

Load the STL file of the hull and define the hull surface as wall:

Now we open the system/snappyHexMeshDict file, where we can define the settings about how to
be refined the mesh around the ship.
Step 1:

13
2.4. MESH AROUND THE SHIP CHAPTER 2. SHIP FLOW SIMULATION

Step 2:

14
2.5. SHIP RESISTANCE CHAPTER 2. SHIP FLOW SIMULATION

Step 3:

The refined mesh around the ship are shown below.

2.5 Ship resistance


OpenFOAM uses a functionObject-forces to calculate ship resistance, which is added in the end
of the controlDict file. This functionObject dictates OpenFOAM to calculate the pressure force
and shear force that acts on a specific body.

15
2.5. SHIP RESISTANCE CHAPTER 2. SHIP FLOW SIMULATION

After the simulation is done. The results of this functionObject is stored under postprocessing/forces/0,
where you can find a data file.
Open the file in Excel you can see the forces as a function of time. Then the ship resistance is
calculated as the sum of pressure force and shear force on the X direction.

The ship resistance at six different velocities (velocity can be varied in the 0/U file) was calculated and
plotted in Figure 2.2, as a function of the simulation time. It can be seen that the resistance value
oscillates and the oscillation amplitude reduces over time. When the resistance curve eventually
approaches a steady harmonic state, the computational resistance was taken as the average value of
the crest and trough.
A comparison between the computational results (CFD) and the corresponding experimental data
(Exp.) [4] is given in Figure 2.3, where good agreement can be found. For all the six velocity
conditions, the computational results are slightly smaller than the experimental values and the

16
2.5. SHIP RESISTANCE CHAPTER 2. SHIP FLOW SIMULATION

deviations are less than 5%. Therefore, it is concluded the applied numerical approach can accurately
predict the total resistance of a ship in open water.

Figure 2.2: Total ship resistance at different velocities (U ) over simulation time.

Figure 2.3: A comparison of the computational ship resistance with the corresponding experimental data
[4].

17
Chapter 3

Wave simulation

To effective generate ocean surface waves in a Numerical Wave Tank (NWT), Jacobsen, et al.[5],
developed a toolbox called waves2Foam. We need first to install it for the current version of Open-
FOAM before using.
Waves are composed of two phases, water and air. The solver developed inside the toolbox is called
waveFoam, which based on a solver for two incompressible fluids using a volume of fluid (VOF)
approach, namely interFoam.

3.1 Installation(waves2foam)
1. Before proceeding with the installation of waves2Foam, we must include the dependencies (or
verify they are already within the Ubuntu environment):

• Subversion (SVN) (Execute in a terminal: sudo apt install subversion).

• git (Execute in a terminal: sudo apt install git).

• gfortran (Execute in a terminal: sudo apt install gfortran).

• GNU Scientific Library (GSL), follow the steps in


https://astrointro.wordpress.com/2017/05/17/installing-gnu-scientific-library-gsl-in-ubuntu-
16-04-and-compiling-codes/ (get the latest version).

2. Download waves2foam, execute in the terminal:


svn co http://svn.code.sf.net/p/openfoam-extend/svn/trunk/Breeder_1.6/other/waves2Foam

3. Establish directories for waves2foam:


cd OpenFOAM/
cd YOUR USER DIRECTORY (name-4.1)
mkdir applications
cd applications/
mkdir utilities

4. Find the waves2Foam folder in your Downloads section, extract it and copy it into the Utilities
directory you just created (OpenFOAM/YOUR NAME-4.1/applications/utilities). Open the
waves2Foam folder, enter ”applications” and enter ”solvers”, copy and paste ”solvers400”,
change the name of the copy into ”solvers410”.

18
3.2. TEST CASE CHAPTER 3. WAVE SIMULATION

5. Compile waves2Foam with your OpenFOAM, open a terminal:


cd OpenFOAM/YOUR NAME-4.1/applications/utilities/waves2Foam
./Allwmake (take a while to complete)

Now, waves2Foam should have been set up OK. We are ready to try one of the tutorials and ver-
ify that the toolbox is running smoothly.The manual of waves2Foam is available at ResearchGate,
search ”waves2Foam munual”.

To update waves2Foam, use:


cd OpenFOAM/YOUR NAME-4.1/applications/utilities/waves2Foam
svn update
./Allwmake

3.2 Test case


To verify that the toolbox is correctly installed we are going to run a tutorial case, waveFlume.
Further information regarding this and other tutorials available are described in the official manual.
Check that your terminal is still within the waves2Foam folder and execute:
cd tutorials/waveFoam/
cp -r waveFlume waveFlumeExample
cd waveFlumeExample
./Allrun

This case will run for 10 to 20 minutes (if you want, you can reduce the 20 s of simulational
time inside the controlDict file, and you can check its progress inside the folderâs window. After the
execution of the tutorial finishes, check that the post-processor is working as well, proceed with:
nano foam.foam
An edit file will be opened within the terminal window, type any letters (example XYZ), and save
the file by using CTRL+O, followed by exiting with CTRL+X. A dummy filed was created inside
our tutorial folder. Then, to open Paraview:
paraview foam.foam
Click ”Apply”, select the option of visualisation of alpha.water and click ”Play” button. You will
see the generation of the waves inside the NWT. The red section is the water, and the blue one is
the air. By playing the animation of this simulation, we can see that waves have been effectively
generated and propagate in the model.

Next,we will understand the theories behind waves2Foam: how this toolbox generates the free
surface waves, how we build our domain, which is the input data for the waves as to understand
what output results we can get depending on the case.

3.3 Tutorial: waves pass through a plate


The study case used in this tutorial includes a Numerical Wave Tank (NWT) with an upright plate
located near its mid-section. The Figure below shows the dimensions of the plate as well as the ones
of the NWT. Regular waves were used, with a wavelength of 5.5 m, a wave height of 0.1 m and a
wave period of 2.0 s; the conditions are considered for intermediate water depth.

19
3.3. TUTORIAL: WAVES PASS THROUGH A PLATE CHAPTER 3. WAVE SIMULATION

3.3.1 Theoretical background


For the wave generation at the inlet and wave absorption at the outlet a relaxation zone technique
is used. Within these relaxation zones the values obtained numerically are neglected and fixed to
analytical results using a relaxation function at each time step. The wave parameters are calculated
according to the wave theories set at the input. In the Figure shown below it can be seen how
the NWT would look like; the minimum dimensions of each zone depend on the wave length (L)
considered.

Figure 3.1: Layout of the NWT: ZONE I - Inlet Relaxation Zone (Wave Generation); ZONE II - Section for
the analysis; ZONE III - Outlet Relaxation Zone.

3.3.2 Case setup


Now, in order to build our tutorial case, we are starting by copying the tutorial waveFlume and
rename it as waveFlume_Example:
run
cd ../applications/utilities/waves2foam/tutorials/waveFoam/
cp -r waveFlume waveFlume_Example

Mesh
For the mesh generation we are going to use the same option as it was done in the previous cavity
tutorial in 1.2.2, blockMeshDict, which produces a block-structured hexahedral mesh. The only
difference is that our domain here involves the two sections of the NWT: one for the water and the
other for the atmosphere. Below, the vertices show that our NWT has dimensions of 25.0 x 1.6 x 0.1
m (the short distance -one-cell- in the z-direction indicates a 2D case), the depth of the tank is 1.2
m. The next sections of the blockMeshDict are the same as explained in section 1.2.2, additionally
we include a patch for an object (an upright plate) fixed inside the NWT.

20
3.3. TUTORIAL: WAVES PASS THROUGH A PLATE CHAPTER 3. WAVE SIMULATION

To build the object fixed inside the NWT, we are going to create the patch using the topoSetDict
as shown below. This file must be in the folder called system. Please download it from the folder
Wave Generation in the Dropbox link shared for the course. In the case of this patch, the geometry
of the object is a rectangle (with the boxToCell selection, but other options are available (check
https://openfoamwiki.net/index.php/TopoSet). Then, the dimensions of the plate would be
0.05 x 0.50 x 0.1 m. What this will do is to create a void geometry whose sides will be acting as
walls, in the limits we set of the bounding box.

Waves
For setting up the wave parameters, inside the constant folder, we will open the waveProperties.input
file. Inside this file we can include the average depth, the wave period, the wave height, the relaxation-
zones and the wave theory to be applied (for this case we are using the first order wave theory, named
here firstStokes). In the first part of the inletCoeffs section the parameters of the wave will be
written:

21
3.3. TUTORIAL: WAVES PASS THROUGH A PLATE CHAPTER 3. WAVE SIMULATION

And in the second part would be the ones for the relaxation zones. More information on the
parameters used here can be found in Section 2.7 of the WAVES2FOAM MANUAL.

Boundary conditions
In the case of the BCs of the cell faces we must include the created fixedPlate patch in each one
of the files of the 0.org folder, as it is highlighted below:

22
3.3. TUTORIAL: WAVES PASS THROUGH A PLATE CHAPTER 3. WAVE SIMULATION

3.3.3 Simulation
First, we need to enter through the window terminal to the folder waveFlume_Example:
run
cd ../applications/utilities/waves2foam/tutorials/waveFoam/waveFlume_Example
gedit Allrun

The text file to execute the simulation of the model will be opened. Below the line of meshing
we are going to include the lines for running the topoSetDict (before the line of waveFoam):
runApplication topoSet
runApplication subsetMesh -overwrite c0 -patch fixedPlate

After this, we save and close the file and go back to the window terminal. We execute the command:
./Allrun
We should have new folders of each time step as well the log files of each application in our example
window as it is shown below.

3.3.4 Post-processing
First we create the dummy file called foam.foam and then open paraview, as in the previous example.
This is the image of the NWT you will get:

23
3.3. TUTORIAL: WAVES PASS THROUGH A PLATE CHAPTER 3. WAVE SIMULATION

Now, we are going to see some of the results of the free surface elevation obtained and measured in
the front and rear of the fixed plate.

Figure 3.2: The recorded waves in front of and behind the plate.

24
Chapter 4

Fluid-Structure Interaction

In previous simulations, fluid-induced solid deformation is negligible, and the solid is commonly
assumed as rigid, so we only obtain the solution of the fluid field. However, when considerable solid
deformation occurs, FSI approach is required to solve both fluid and solid mechanics.

4.1 Preparation: stress-analysis


To solve an FSI problem with OpenFOAM, this section will present how to solve solid mechan-
ics in OpenFOAM, as a preparation. The tutorial case we are using is plateHole, stored under
tutorials/stressAnalysis/solidDisplacementFoam/plateHole.

The case conducts the structural analysis of a square plate with a circular hole at its centre. It is
loaded with a uniform traction of σ = 10 kPa over its left and right faces

According to the symmetry, only one quarter of the plate was taken into calculation, to save com-
putational costs. The mesh and boundary conditions of the case were defined as below.

25
4.1. PREPARATION: STRESS-ANALYSIS
CHAPTER 4. FLUID-STRUCTURE INTERACTION

The mechanical properties of the solid is defined in mechanicalProperties, including density, Pois-
son’s ratio and Young’s modulus.

26
4.2. INSTALLATION(FSI) CHAPTER 4. FLUID-STRUCTURE INTERACTION

The results are presented as the displacement of each cell (D). By varying the Young’s modulus
(E) of the plate, it can be observed (with the filter wrap by vector) that considerable deformation
occurs with a small Young’s modulus applied.
More details please see: https://www.openfoam.com/documentation/tutorial-guide/tutorialse9.
php#x16-830005.1.

Figure 4.1: Structural response of the plate. Left: E = 2e11 Pa; Right: E = 2e5 Pa.

In the above case, the load on the solid body was applied by boundary conditions, i.e. a specific
traction value was set on the solid boundaries. However, in an FSI problem, the load on the solid
body is usually unknown. We need to solve the fluid field first, get the fluid load on the solid, and
then the solid solver can solve the solid mechanism. In OpenFOAM, such a process can be preformed
via fsiFoam, an opensource FSI solver developed by Tukovic et al. [6; 7]. Next, we will introduce
how to install and use fsiFoam.

4.2 Installation(FSI)
fsiFoam needs to be installed on foam-extend, which is the extended/advanced version of openFOAM
that developed by active contributors. To conduct FSI simulations, this section first provides in-
structions on installing foam-extend and fsiFoam.

4.2.1 foam-extend
foam-extend is a different version to the original openFOAM. First, we need to revise the bashrc file
(the commands that will automatically execute when you open a terminal):
1. open the bashrc file by: go to the home direcotory, ctrl+H to show hiden files, open .bashrc
2. in the file, REMOVE the line for initialising openFOAM
source /opt/openfoam4/etc/bashrc
AND ADD
alias of40='source ../../opt/openfoam4/etc/bashrc'
3. ADD one line under the last line for initialising foam-extend:
alias fe40='source $HOME/foam/foam-extend-4.0/etc/bashrc'

Thus, when you open a new terminal, type of40 to use openFoam 4.0, type fe40 to use foam-
extend 4.0. Otherwise, these two versions will interrupt each other.

The steps to install foam-extend 4.0 are outlined as below. (based on the notes given by Prof
Hakan Nillson)
1. Install dependences, Open new terminal window and execute the following commands. (line-
by-line, since you have to type your password on the ”sudo” lines, and also agree to do the

27
4.2. INSTALLATION(FSI) CHAPTER 4. FLUID-STRUCTURE INTERACTION

installations by typing Y)
sudo apt-get install git-core build-essential binutils-dev cmake flex
sudo apt-get install zlib1g-dev qt4-dev-tools libqt4-dev libncurses5-dev libiberty-dev
sudo apt-get install libxt-dev rpm mercurial graphviz python python-dev
sudo apt-get install openmpi-bin libopenmpi-dev
sudo apt-get install paraview

2. Download it
mkdir $HOME/foam
cd $HOME/foam
git clone git://git.code.sf.net/p/foam-extend/foam-extend-4.0 foam-extend-4.0

3. Some changes to the installation procedure to save time and disk:


echo "export WM_THIRD_PARTY_USE_BISON_27=1" > etc/prefs.sh
echo "export WM_MPLIB=SYSTEMOPENMPI" >> etc/prefs.sh
echo "export OPENMPI_DIR=/usr" >> etc/prefs.sh
echo "export OPENMPI_BIN_DIR=\$OPENMPI_DIR/bin" >> etc/prefs.sh

4. Complie
source etc/bashrc
./Allwmake.firstInstall (this step takes hours)

5. Make a user derectory


mkdir -p $FOAM_RUN

4.2.2 fsiFoam
1. Download the package (oepn a terminal and use fe40 to initialise foam-extend)
mkdir -p $WM_PROJECT_USER_DIR
cd $WM_PROJECT_USER_DIR
wget https://openfoamwiki.net/images/d/d6/Fsi_40.tar.gz
tar -xzf Fsi_40.tar.gz

2. Compile
cd FluidSolidInteraction/src
./Allwmake
3. Then, before we try running the tutorial cases, we need to fix a few dependencies (note, be-
tween ”do” and ”done”, the two ”sed” commands are both end with ”item” in the second
line):
cd ..
find run -name options | while read item
do
sed -i -e 's=$(WM_PROJECT_DIR)/applications/solvers/FSI=$(WM_PROJECT_USER_DIR)/
FluidSolidInteraction/src=' $item
sed -i -e 's=$(WM_THIRD_PARTY_DIR)/packages/eigen3=$(WM_PROJECT_USER_DIR)/
FluidSolidInteraction/src/ThirdParty/eigen3=' $item
done
4. Fix some bugs
Open $WM_PROJECT_DIR/src/finiteVolume/finiteVolume/fvSchemes/fvSchemes.C,

28
4.3. FSI APPROACH CHAPTER 4. FLUID-STRUCTURE INTERACTION

uncomment the following lines (they should be commended, when you open the file).

Open $WM_PROJECT_DIR/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C, comment the


following lines.

and do:
cd $WM_PROJECT_DIR/src/finiteVolume
wmake libso

4.3 FSI approach


In fsiFoam, a partitioned algorithm is used to solve the FSI problem, which solves the fluid and
solid mechanism separately and links them together via the fluid-solid interface. In other words,
fsiFoam employs a fluid solver (e.g. icoFoam) to obtain the fluid field, and employs a solid solver
(e.g. solidDisplacementFoam) to solve the solid mechanism. Besides, an FSI scheme is used to link
the fluid solution and solid solution. The process is illustrated as below.

4.4 FSI tutorial


Here we use a tutorial to demonstrate how to conduct an FSI simulation. The case is stored under
USER-DIRECTORY/FluidSolidInteraction/run/fsiFoam/beamInCrossFlow
The case consists of an elastic thick plate attached to the bottom surface of a rectangular channel.

29
4.4. FSI TUTORIAL CHAPTER 4. FLUID-STRUCTURE INTERACTION

The geometry of the spatial domain is given below. An incompressible viscous fluid enters the
channel from the left-hand side with a velocity that gradually increases [7].

4.4.1 Case structure


Since the fluid and solid parts are solved separately, they are defined in two folders. As shown in
the tree diagram below, the FSI case mainly consists of two parts: fluid and solid. Each of them
has its own 0, constant and system directory, as a common OpenFOAM case, and the “create-
Zones” and “setBatch” define the fluid/solid interface. The “makeLinks”, “makeSerialLinks” and
“removeSerialLinks” files manage the link between the fluid and solid. The “Allrun” and “Allclean”
files are located in the fluid part, and the “AllrunPar” file is used for parallel computation. During
the process of an FSI simulation, only the fluid part needs to be executed, because the solid part
will be called automatically over each timestep.

[A FSI CASE]
|-- fluid
|-- |-- 0
|-- |-- Allclean
|-- |-- Allrun
|-- |-- AllrunPar
|-- |-- constant
|-- |-- createZones
|-- |-- setBatch
|-- |-- system
|-- makeLinks
|-- makeSerialLinks
|-- removeSerialLinks
|-- solid
|-- 0
|--constant
|-- createZones
|-- setBatch
|-- system

4.4.2 Mesh
The mesh of an FSI case also contains two parts, i.e. fluid mesh and solid mesh, defined separately in
their constant/polyMesh/blockMeshDict. The fluid mesh and solid mesh must match each other

30
4.4. FSI TUTORIAL CHAPTER 4. FLUID-STRUCTURE INTERACTION

through their interface and compose a whole computational domain, as shown in Figure 4.2.
An interface boundary condition has to be defined in both the fluid and solid mesh. Moreover,
the interface in fluid mesh and the interface in solid mesh have to be at a same location. Through
the interface, the loads of fluid on solid is outputted to the solid solver and converted into the
displacement of the solid surface.

Figure 4.2: Fluid mesh, solid mesh and the integral mesh. (Blue: fluid field; Red: interface; Grey: Solid
field)

4.4.3 Simulation
Running the case with ./Allrun
(If you are using this case for the first time, you need to do:)
sed -i s/tcsh/sh/g *Links
./removeSerialLinks fluid solid
./makeSerialLinks fluid solid
cd fluid
./Allclean
./Allrun

Use paraview to view the results and it can be seen that obvious deformation of the solid body
has been simulated (upper: t=0s; lower: t=10s).

31
4.5. WAVE-INDUCED FSI PROBLEMS CHAPTER 4. FLUID-STRUCTURE INTERACTION

4.5 Wave-induced FSI problems


Last section introduced how to conduct an FSI simulation via fsiFoam. However, the fsiFoam
package that we can download from public domain has not included a multiphase library, which
means it cannot be used to simulate the FSI problems containing free-surface modelling. In order to
investigate the FSI problems in maritime/ocean field, this section will develop the code of fsiFoam.
Specifically, we will compose three solvers: fsiFoam, interDyMFoam and waves2Foam.

4.5.1 Code development


The development route of this work is shown below, where the original FSI package will first be
extended into two-phase (fsiFoam+interDyMFoam) and then be endowed the capability of generating
a target wave field (fsiFoam+interDyMFoam+waves2Foam).

To extend the FSI package from single-phase to two-phase, essentially it is to build a new free-surface
fluid library beside other existing fluid libraries, e.g. pisoFluid, icoFluid. The fluid libraries of
FSI package are stored under src/fluidSolidInteraction/fluidSolvers/. For this purpose, the
code of interDyMFoam will be transplanted as a new two-phase fluid library under the fluidSolvers
directory, which will be named as “interFluid”.

32
4.5. WAVE-INDUCED FSI PROBLEMS CHAPTER 4. FLUID-STRUCTURE INTERACTION

The coupling of waves2Foam with FSI package is divided into two parts: on the one hand, to build
a new solver that can call both waves2Foam package and FSI package, named waveFsiFoam; on the
other hand, to include necessary wave objects into interFluid,named waveInterFluid.

Detailed steps can be found at [8]:


http://www.tfd.chalmers.se/~hani/kurser/OS_CFD_2017/LuofengHuang/2017_OSCFD_Report_
Luofeng.pdf

4.5.2 Tutorial
Here we provide a tutorial of how to use the developed solver, waveFsiFoam, to run a wave-induced
FSI case: beamInWave.
First of all, we need to modify the case file of “beamInCrossFlow” as follows.

Boundary conditions
Compared with the original “beamInCrossFlow” case , the following revises are required under
fluid/0/ :
1. Copy the alpha1.org file from the tutorial case “damBreakWithoutObstacle” (within the instal-
lation of foam-extend 4.0), so that the VOF method will divide the domain into two phase.
2. Rename the pressure field from p to pd; Revise its outlet boundary into a zeroGradient condition
and its top boundary into a totalPressure (typically used to model the atmosphere) condition.
3. To generate waves at the inlet boundary, the inlet boundary conditions of volume fraction
alpha1.org and velocity U are set as waveAlpha and waveVelocity respectively, which are the
boundary conditions installed with the waves2Foam package.
For alpha1.org
inlet
{
type waveAlpha;
refValue uniform 0;
refGrad uniform 0;
valueFraction uniform 1;
value uniform 0;
}
For U
inlet
{
type waveVelocity;
refValue uniform ( 0 0 0 );
refGradient uniform ( 0 0 0 );
valueFraction uniform 1;
value uniform ( 0 0 0 );
}

Constant
Compared with the original “beamInCrossFlow” case, the following revises are required under
fluid/constant/ :
1. In fluidProperties, set the “fluidslover” as waveInterFluid (this step calls the new fluid library
developed in this study), also change the following “fluidcoeffs” value into waveInterFluidCoeffs.
2. Replace the transportProperties file by that of the tutorial case “damBreakWithoutObsta-
cle”.
3. Copy waveProperties.input from the toturial case “waveFlume”, as well as the g file and

33
4.5. WAVE-INDUCED FSI PROBLEMS CHAPTER 4. FLUID-STRUCTURE INTERACTION

RASproperties file. Adjust the “sealevel” and other wave parameters according to the geometry.

System and Allrun


Compared with the original “beamInCrossFlow” case, the following revises are required under
fluid/system/ :
1. In controlDict, change the “application” value into waveFsiFoam (this step calls the developed
new solver) and comment the previous object functions.
2. Replace the fvSchemes file and fvSolution file by those of the tutorial case “damBreakWith-
outObstacle”, and revise the pressure field of the two files from p to pd.

To run the case by the command “./Allrun”, the fluid/Allrun file needs to be revised as be-
low:

• Allrun:line 21-30

cd fluid
cp 0/alpha1.org 0/alpha1

runApplication setWaveParameters
runApplication setWaveField

runApplication $application

# ----------------------------------------------------------------- end-of-file

The utility setWaveParameters is a pre-processing utility, which computes all the necessary wave
parameters based on physical meaningful properties, e.g. setWaveParametes converts information
on water depth and wave period into a wave number for first order Stokes wave theory. In this step,
it will load the constant/waveProperties.input and output the processed data into a new file,
constant/waveProperties .
The utility setWaveField is used to set the initial conditions according to a user defined wave the-
ory, which is defined by the keyword “initializationName” in the file waveProperties.input (see
Section 2.3).
The last step calls the solver waveFsiFoam, as defined by “getAppapplication” in fluid/controlDict.
Thus, the new solver waveFsiFoam will solve the case.

34
4.5. WAVE-INDUCED FSI PROBLEMS CHAPTER 4. FLUID-STRUCTURE INTERACTION

Figure 4.3: The interaction of the beam with incoming waves: when the beam is hit by a wave crest, it
deforms forward (above); when the beam is hit by a wave trough, it deforms backward (below).

35
Chapter 5

Combustion

5.1 Turbulent reacting flows


5.1.1 Governing equations
Reacting flows can be described by a system of governing equations, namely continuity, momentum,
and species and energy equations.
First, the continuity equation manages the mass conservation and can be denoted as:

Where ρ is the density, t is time, uj is the velocity components in the j-th direction, xj is the spatial
vector.
The momentum equation is described as:

Where p is the pressure, and gi is the body forces per unit volume. τij is the viscous stress tensor,
and for a Newtonian fluid, it can be expressed as:

where δij is the Kronecker delta, and µ is the dynamic viscosity.


In reacting flows, multiple species must be tackled, and hence the conservation of each species α is
in consideration. The transport equation for the species mass fractions is written as:

36
5.1. TURBULENT REACTING FLOWS CHAPTER 5. COMBUSTION

where Yα is the mass fraction of species α. Ja,j is the diffusion flux, which can be further described
using Fick’s Law:

where Dα is the species diffusion coefficient. Besides the species transport, the conservation of
energy needs to be achieved. The energy equation takes this form in terms of enthalpy h:

where q̇ is the heat source term, and qj is the diffusive flux.

5.1.2 Large Eddy Simulation


Large Eddy Simulation (LES) applies a low-pass spatial filter to the instantaneous governing equa-
tions, separating motions of the small length scale from those of large length scale. The former,
known as sub-grid scales, are rather modeled than directly computed, while the latter are resolved.
The filtered field, denoted with a bar above, is defined as:

where is the flow domain, and G is the filter kernel which should be positive definite. ∆ is the
characteristic filter width, which may alter according to the position, and is usually defined as the
cubic root of the cell volume.
A widely used manner for the filtering operation is to adopt a top-hat filter:

To tackle the density variations in reacting flows, Favre filtering operation is introduced as:

In this way, instantaneous quantities are divided into a resolved filtered mean and an unresolved
sub-grid fluctuation:

37
5.1. TURBULENT REACTING FLOWS CHAPTER 5. COMBUSTION

Applying Favre filtering operation to the governing equations, the filtered equations take the follow-
ing forms:
Continuity:

Momentum:

where the unresolved Reynolds stress requires a sub-grid scale turbulence model to close.
After manipulation of filtering function, the filtered transport equations are described as:
Enthalpy:

Chemical species:

where ω¯˙α is the unclosed chemical source term, which cannot be resolved directly and remain the
most difficult task in turbulent combustion modelling.

5.1.3 Turbulent modelling


Tentative classification of the turbulent SGS LES closures available [9].

38
5.2. REACTINGFOAM AND PASR CHAPTER 5. COMBUSTION

5.1.4 Combustion modelling


Tentative classification of the turbulent reacting LES closures available [9].

5.2 reactingFoam and PaSR


Since the reaction zone parameters, as a rule, can not be resolved on a computational grid, the
sub-grid diffusion term due to micro-mixing was approximated with the help of introduction of a
micro-mixing time as suggested in the âinteraction with the meanâ approach. Then, assuming that
chemical processes proceed in such a way that the shortest chemical time associated with particular
(reference) species participating in the reaction was constrained by the micro-mixing time, a system
of PaSR equations consisting can obtained.
The PaSR combustion model derives the reation rate in a transient manner (Christ, RWTH):

κ is Mixed fraction of cell that can react.


The parameter κ is based on two time scalesı̈ 41

39
5.3. TUTORIAL CHAPTER 5. COMBUSTION

In OpenFOAM:

5.3 Tutorial
5.3.1 Introduction
The case under consideration is the bluff-body stabilized premixed flame experiment performed
under the Volvo Flygmotor AB program . It is relatively simple and includes many features in
practical combustors, such as flame anchoring, recirculation zones, and shear layers. It has been
used for LES model validation and lean premixed combustion study . The configuration consists of a
1m-long straight channel with a rectangular cross section of 0.12 m * 0.24 m. The flame is anchored
on a bluff body, having an equilateral triangular cross section (side length H = 0.04 m), located 0.68
m upstream of the exit. A propane and air mixture at 1 atm and 288 K (Tin) is introduced at an
equivalence ratio of 0.65. The mixture flows at bulk inlet velocity of Uin = 17m/s, resulting in a
bulk Reynolds number of 48000 and Karlowitz number of 62, with an inlet turbulence intensity of
3-4%. Temperature was measured by CARS and velocity by LDA.

40
5.3. TUTORIAL CHAPTER 5. COMBUSTION

Figure 5.1: Schematic of the Volvo Rig combustor. The interior width in the z-direction is 6H.

5.3.2 Mesh and boundary conditions


The grid size is chosen based on two criteria: the resolution of the boundary layer on the bluff body,
estimated to be around 5 mm, and the Pope energy criterion which suggests that a filter-width
to integral length scale ratio of Î/H = 0.083 should be maintained to resolve 80% of the turbulent
kinetic energy. The latter criterion gives a maximum filter width of 3.3mm. Three grid resolutions of
3, 2 and 1 mm respectively are generated, where the filtered width is cubic root of the cell volume.
At the inlet, Dirichlet conditions are used for all variables except the pressure, for which zero
Neumann conditions are employed. At the exit, zero Neumann conditions are specified for all
variables except the pressure, for which wave-transmissive conditions are used. No-slip conditions
are applied to walls of the duct as well as the bluff-body, while zero Neumann conditions are specified
for the other variables. The time-step is variable, and the compressible Courant number is lower
than 0.2 throughout the simulations. Chemistry is computed using a single-step mechanism for
propane/air flames.

Figure 5.2: Mesh (produced by Gmsh)

5.3.3 Simulation
As the grids need to be relatively fine in LES, 2D simulation is considered first (even though it is
still very consuming). Then 3D simulation can be conducted for statistical results.
Three properties in setup should be paid more attention to:
1.LESProperties - Different turbulence models to choose and filter shape should be defined.
2.combustionProperties - Choose different combustion models and define the parameters.
3.thermophysicalProperties - The chemistry mechanism format should be clarified here.

41
5.3. TUTORIAL CHAPTER 5. COMBUSTION

5.3.4 Results

The above is 2D simulation to save the time. The outline captures the overall features such as shear
layer, recirculation zones.
The results below are obtained by 3D simulations.
1.Vorticity

2.Instantaneous temperature profile

3.Centerline profile

42
5.3. TUTORIAL CHAPTER 5. COMBUSTION

4.Axial velocity profile

43
Reference

[1] Jasak H, Jemcov A, Tukovic Z, et al. OpenFOAM: A C++ library for complex physics simu-
lations. In: International workshop on coupled methods in numerical dynamics. vol. 1000. IUC
Dubrovnik, Croatia; 2007. p. 1–20.
[2] Weller HG, Tabor G, Jasak H, Fureby C. A tensorial approach to computational continuum
mechanics using object-oriented techniques. Computers in physics. 1998;12(6):620–631.

[3] Hirt CW, Nichols BD. Volume of fluid (VOF) method for the dynamics of free boundaries.
Journal of computational physics. 1981;39(1):201–225.
[4] Moctar Oe, Shigunov V, Zorn T. Duisburg Test Case: Post-panamax container ship for bench-
marking. Ship Technology Research. 2012;59(3):50–64.

[5] Jacobsen NG, Fuhrman DR, Fredsøe J. A Wave Generation Toolbox for the Open-Source CFD
Library: OpenFoam .
R International Journal for Numerical Methods in Fluids. 2012;70(9):1073–
1088.
[6] Tukovic Z, Cardiff P, Karac A, Jasak H, Ivankovic A. OpenFOAM library for fluid structure
interaction. In: 9th OpenFOAM Workshop. vol. 2014; 2014. .

[7] Tukovic Z, Karac A, Cardiff P, Jasak H, Ivankovic A. OpenFOAM finite volume solver for
fluid-solid interaction. Tractions of FAMENA. 2018;.
[8] Huang L. An opensource solver for wave-induced FSI problems. In Proceedings of CFD with-
OpenSource Software; 2018.

[9] Gicquel LY, Staffelbach G, Poinsot T. Large eddy simulations of gaseous flames in gas turbine
combustion chambers. Progress in Energy and Combustion Science. 2012;38(6):782–817.

44
Reading recommendation

1. OpenFOAM user guide


http://foam.sourceforge.net/docs/Guides-a4/OpenFOAMUserGuide-A4.pdf

2. Youtube channel of József Nagy, excellent tutorial-vedios to begin with:


https://www.youtube.com/channel/UCjdgpuxuAxH9BqheyE82Vvw?&ab_channel=J%C3%B3zsefNagy

3. OpenFOAM tutorials of Victor Pozzobon on Researchgate:


https://www.researchgate.net/project/OpenFOAM-Tutoring

4. Maric, T., Hopken, J. and Mooney, K., 2014. The OpenFOAM technology primer.
(first five chapters provide comprehensive OpenFOAM foundation)

5. Moukalled, F., Mangani, L. and Darwish, M., 2016. The finite volume method in computa-
tional fluid dynamics.
(the theoretical foundation of OpenFOAM)

45
Acknowledgements

Leading the way


Prof Giles Thomas (University College London)
Prof Guoxiong Wu (University College London)
Prof Håkan Nilsson (Chalmers University of Technology)
Dr Željko Tukovic (University of Zagreb)
Dr Philip Cardiff (University College Dublin)

Logistical supports
Rochelle Rowe (UCL Doctoral Skills Team)
Kasia Bronk (UCL Doctoral Skills Team)
Shanaz Durrant (UCL Doctoral Skills Team)
Alexandra Grimova (UCL Mechanical Engineering Financial)
Philip Ross (UCL Mechanical Engineering Financial)
Martina Bertazzon (UCL Mechanical Engineering Financial)
Heather Kelly (UCL Information Services Division)

Fighting together
Minghao Li (Chalmers University of Technology)
Qicheng Meng (UCL)
Kang Ren (UCL)
Chris Ryan (UCL)
Andrea GL Rosa (UCL)
Bojan Igrec (UCL)
Christopher-John Cassar (UCL)
Faheem Rehman (UCL)
Shiyu Lyu (UCL)
Yeru Shang (Sussex University)

46
RLI Report (OpenFOAM Workshop)

Luofeng Huang, Rui Song

OpenFOAM is an opensource numerical software that can be applied to various research areas,
including Physics, Chemistry, Biology and Engineering. It has become the most popular
simulation tool for scientific research. However, at UCL, although many researchers have been
aware of its power, a learning opportunity was lacked here.

With great appreciation to the RLI project organised by the UCL doctoral skills development
programme, the research students at UCL were offered a chance to organise a workshop,
aiming at introducing the usage of OpenFOAM. Similar workshops have already established
in other universities, such as the University of Zagreb, Chalmers University of Technology,
Delft University of Technology. The workshop is a mixture of lecturing theories and hands-on
tutorials, which was reckoned to be the best manner for OpenFOAM beginners.

We are glad to report the OpenFOAM workshop was held successfully. During the
discussion after each session, very encouraging feedbacks have been received from the
attendants. The workshops were delivered by four tutors, including Luofeng Huang, Rui Song,
Daniela Benites and Weilin Zeng. They are all PhD or Post-docs from the Department of
Mechanical Engineering. Prof Giles Thomas provided valuable suggestions for the
organisations and helped us advertise the workshop. Besides, a guest lecturer, Dr Yeru Shang
from Sussex University, was invited as well. the In three days, the workshop covered how to
install the OpenFOAM, its basic theories and steps to perform a simulation. Examples were
given on ship simulation, waves simulation, combustion simulation, turbulent simulation,
structural analysis, fluid-structural interaction, etc.. A fifty-page notes (see attachment) was
made to illustrate the tutorials step by step, which played a tremendous role.

There are totally 18 participants who attended the workshop, while we believe they should be
more who are interested in OpenFOAM. Improvement in the future should be addressed in the
advertising. Potential participants may not really effectively receive the advertisement. A
remedy can be contacting the supervisors who are supervising relevant students.

There was about 1 hour discussion time arranged at the end of each session. The students were
asked to briefly introduce themselves and their PhD research. Through these discussions, it was
reckoned that there are potential cooperation opportunities between the students and the tutors
and cross disciplines. Great interest was also received from some students’ supervisors. They
hope and will encourage more students to come to this workshop, if there would be one in the
next year.

As an expectation of both the students and the tutors, a UCL OpenFOAM user community was
established. This offered us a platform for discussion and cooperation after the workshop. The
tutors are responsible to maintain the community and the attended students can join this
community and become members for free. Based on the UCL OpenFOAM user community,
activities will be carried on, including the annual meeting, network events and lectures by
famous OpenFOAMers. For example, the principal developer of OpenFOAM, Prof Hrvoje
Jasak (http://wikki.gridcore.se/oldstuff/partners/prof.-hrvoje-jasak) has preliminarily agreed to
come to UCL and give a talk.

The whole workshop ended in a rigorous and relaxed atmosphere. We believe it is a good start
and hope to deliver it year by year. For the organisers ourselves, we learned how to propose a
project, apply for funding, prepare lectures, transfer skills, manage groups…Thanks to this
experience, who are not only PhDs focusing on own research – we completed such a
comprehensive training and got the happiness of sharing knowledge and helping others!

View publication stats

You might also like