OpenFOAM Course Notes
OpenFOAM Course Notes
net/publication/331313286
CITATIONS READS
0 2,108
4 authors:
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
All content following this page was uploaded by Luofeng Huang on 24 February 2019.
Course Notes:
UCL OpenFOAM Course 2018
funded by the UCL Doctoral Skills Development Programme
Authors:
Luofeng Huang
Rui Song
Daniela Benites
Weilin Zeng
June 2018
Preface
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.
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
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).
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.
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
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
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.
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)
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
6
1.2. OPENFOAM CASE SETUP CHAPTER 1. OPENFOAM BASIS
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
8
Chapter 2
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.
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 ).
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
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.
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
An example is given below to illustrate the process: (details please see https://cfd.direct/
openfoam/user-guide/snappyhexmesh/)
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
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:
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):
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
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”.
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.
19
3.3. TUTORIAL: WAVES PASS THROUGH A PLATE CHAPTER 3. WAVE SIMULATION
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.
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.
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
4. Complie
source etc/bashrc
./Allwmake.firstInstall (this step takes hours)
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).
and do:
cd $WM_PROJECT_DIR/src/finiteVolume
wmake libso
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].
[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
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.
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.
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
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:
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 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.
38
5.2. REACTINGFOAM AND PASR CHAPTER 5. COMBUSTION
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.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
3.Centerline profile
42
5.3. TUTORIAL CHAPTER 5. COMBUSTION
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
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
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)
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!