OpenFOAM-version-7/C3/2D-Dam-Break-Simulation-using-OpenFOAM/English
Title of the script: 2D Dam Break Simulation using OpenFOAM
Author: Ashley Melvin
Keywords: OpenFOAM, ParaView, CFD, computational fluid dynamics, blockMesh, VOF, volume of fluid, multiphase flow, dam break, scotch decomposition, setFields, FOSSEE, spoken tutorial, video tutorial.
Visual Cue | Narration |
Slide
Opening Slide |
Welcome to this tutorial on 2D Dam Break Simulation |
Slide
|
In this tutorial, we will learn how to,
|
Slide
System Specifications |
To record this tutorial, I am using,
Ubuntu Linux OS version 22.04* OpenFOAM version 9
|
Slide
Prerequisites* If not, please go through the prerequisite OpenFOAM tutorial on https://spoken-tutorial.org
|
As a prerequisite,
|
Slide
Code Files |
|
Slide
Breaking of a Dam |
|
Only Narration | Let’s see what happens when a dam, that holds the water column, suddenly breaks. |
CTRL + ALT + T keys | Open the terminal by pressing Ctrl, Alt and T keys together. |
[Terminal] Type:
cd $FOAM_RUN |
Type this command and press Enter to move into the run directory. |
[Terminal] Type:
cd damBreak |
Let’s move into the damBreak folder using the following command. |
[Terminal] Type:
gedit system/blockMeshDict |
Let’s open the blockMeshDict file in a text editor. |
Slide
Dam Break Geometry |
The geometry is divided into 5 blocks as shown in the diagram. |
[gedit - blockMeshDict] Highlight:
Blocks List Link |
The 5 blocks are defined as shown. |
Slide
Boundaries |
The boundaries of the geometry are:
|
[gedit - blockMeshDict] Highlight:
Boundary List Link |
The 4 faces are defined in the boundary list as shown. |
[gedit - blockMeshDict]
Close the window |
Close the blockMeshDict file. |
Only Narration | Now, let’s view the initial and boundary conditions files. |
[Terminal] Type:
gedit 0/p_rgh |
Let’s view the initial and boundary values of p_rgh |
Only Narration | p_rgh is the pressure without the hydrostatic contribution. |
[gedit - p_rgh] Highlight:
fixedFluxPressure Link |
All three walls are imposed with fixedFluxPressure boundary conditions. |
[gedit - p_rgh] Highlight:
value uniform 0 Link |
For the type fixedFluxPressure, value is just a placeholder for the first time-step. |
[gedit - p_rgh] Highlight:
atmosphere boundary condition Link |
The top boundary is exposed to the atmosphere.
|
Only Narration | The additional reading material has more details on p_rgh and its boundary conditions.
|
[gedit - p_rgh]
Close the window |
Close the p_rgh file. |
[Terminal] Type:
gedit 0/alpha.water.orig |
Let’s view the initial and boundary values of phase fraction of water. |
[gedit - alpha.water.orig] Highlight:
|
The domain is initialized uniformly with a value of 0.
|
[gedit - alpha.water.orig] Highlight:
|
The surface tension effects between the walls and the fluid-interface are ignored.
|
[gedit - alpha.water.orig] Highlight:
|
The inletOutlet type boundary condition is imposed on the top boundary.
|
[gedit - alpha.water.orig] Highlight:
|
For inflow, this type of boundary condition takes the inletValue as the fixedValue.
|
[gedit - alpha.water.orig] Highlight:
value uniform 0 Link |
For the type inletOutlet, value is just a placeholder for the first time-step. |
[gedit - alpha.water.orig]
Close the window |
Close the phase fraction file. |
[Terminal] Type:
|
Let’s view the initial and boundary values of U
|
Slide
Velocity Boundary Conditions* walls - noSlip
|
Let’s look at the boundary conditions of velocity.* At the walls, noSlip condition is imposed
|
Slide
pressureInletOutletVelocity |
The pressureInletOutletVelocity
|
[gedit - U]
Close the window |
Close the U file. |
[Terminal] Type:
ls constant |
Let’s look at the constant files used in the simulation. |
[Terminal] Highlight:
|
In this simulation, the flow is considered to be laminar.
|
[Terminal] Type:
|
Let's view the contents of the momentumTransport file.
|
[gedit - momentumTransport]
Close the window |
Close the momentumTransport file. |
[Terminal] Highlight:
|
The simulation requires the acceleration due to gravity, to be specified.
|
Slide
|
These are the transport properties of water and air used in this simulation. |
Slide
Highlight: Newtonian Link |
Both water and air are considered to be Newtonian fluids. |
[Terminal] Type:
gedit constant/transportProperties |
Let’s open the transportProperties file in a text editor. |
[gedit - transportProperties] Highlight:
phases (water air) Link |
The two phases in this simulation are water and air. |
[gedit - transportProperties] Highlight:
Properties of water and air Link |
The properties of water and air are specified as shown. |
[gedit - transportProperties] Highlight:
sigma 0.07 Link |
The surface tension between water and air is taken to be 0.07 Newton per meter. |
[gedit - transportProperties]
Close the window |
Close the transportProperties file. |
Only Narration | Now let’s look at how the domain is decomposed for the parallel run. |
[Terminal] Type:
gedit system/decomposeParDict |
Let’s open the decomposePar dictionary in a text editor. |
[gedit - decomposeParDict] Highlight:
numberOfSubdomains 4 Link |
The domain is decomposed into 4 sub-domains. |
[gedit - decomposeParDict] Highlight:
|
The domain is decomposed using the scotch decomposition method.
|
[gedit - decomposeParDict]
Close the window |
Close the decomposeParDict file. |
Only Narration | Now, let’s see how to initialize the section of the domain with a water column. |
[Terminal] Type:
gedit system/setFieldsDict |
Such non-uniform initial conditions are specified using the setFields dictionary. |
[gedit - setFieldsDict] Highlight:
defaultFieldValues Link |
The default value of fields for the domain is specified using the defaultFieldValues list. |
[gedit - setFieldsDict] Highlight: Link
volScalarFieldValue alpha.water 0 |
The default value of phase fraction of water is specified as 0. |
[gedit - setFieldsDict] Highlight:
regions Link |
Next, we set the regions where the field values are different from the default values. |
[gedit - setFieldsDict] Highlight:
boxToCell Link |
We specify the cells within a bounding box using boxToCell.
|
Slide
boxToCell* box (minx miny minz) (maxx maxy maxz)
|
|
Slide
|
The section occupied by the water column is shown in the figure.
|
Slide
boxToCell |
For the water column,
|
[gedit - setFieldsDict] Highlight:
box (0 0 0) (0.5 1 0.1) Link |
We specify the bounding box as shown. |
[gedit - setFieldsDict] Highlight:
fieldValues List Link |
The fieldValues to be specified within the box is defined as shown. |
[gedit - setFieldsDict] Highlight:
|
The phase fraction of water is specified to be 1 within the box.
|
[gedit - setFieldsDict]
Close the window |
Close the setFieldsDict file. |
[Terminal] Type:
blockMesh |
Let’s mesh the geometry using the blockMesh command. |
[Terminal] Type:
|
Then, let’s set the fields in the domain using the setFields command.
|
Only Narration | The additional reading material has more details on the setFields utility.
|
[Terminal] Type:
decomposePar |
Let’s decompose the domain using the decomposePar command. |
Slide
interFoam* Captures the interface of 2 immiscible fluids using the volume of fluid (VOF) method.
|
We will use the interFoam solver to simulate this problem.
|
[Terminal] Type:
mpirun -np 4 interFoam -parallel |
Let’s start the simulation using the following command. |
[Terminal] Type:
|
Since we had run our simulation in parallel, our solution is decomposed.
|
[Terminal] Type:
paraFoam |
Let’s now view the simulated results in ParaView. |
[ParaView] Properties Tab
Click on Apply |
Click on the Apply button to view the geometry. |
[ParaView] Active Variable Controls
|
Let’s view the contours of phase fraction of water.
|
[ParaView] Layout Window
|
You can see the initial contours of phase fraction of water showing the water column. |
[ParaView] VCR Controls
|
Let’s see how the contours change with time.
|
[ParaView] Layout Window
Phase Fraction Contour animation |
The animation shows the water flow for 5 seconds from the instance when the dam was broken. |
[ParaView] Close ParaView | Close the ParaView window. |
Only Narration | With this we have come to the end of the tutorial.
|
Slide
Summary |
In this tutorial, we have learnt to:
|
Slide
Assignment |
As an assignment:* For the same domain, increase the height of the water column to 1.5 meter, and
|
Slide
About the Spoken Tutorial Project |
The video at the following link summarizes the Spoken Tutorial project.
|
Slide
Spoken Tutorial Workshops |
We conduct workshops using Spoken Tutorials and give certificates.
|
Slide
Spoken Tutorial Forum |
Please post your timed queries in this forum. |
Slide
FOSSEE Forum |
* Do you have any general/technical questions?
|
Slide
FOSSEE Case Study Project |
|
Slide
Acknowledgement |
The Spoken Tutorial project was established by the Ministry of Education, Govt. of India. |
Only Narration | This tutorial is contributed by Ashley Melvin, Ashuthosh P S, John Pinto and Payel Mukherjee from IIT Bombay.
Thank you for joining. |