OpenFOAM-version-7/C3/2D-Dam-Break-Simulation-using-OpenFOAM/English

From Script | Spoken-Tutorial
Jump to: navigation, search

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


Learning Objectives

In this tutorial, we will learn how to,
  • Set up a case of multiphase flow
  • Decompose the domain using scotch decomposition method
  • Specify a non-uniform initial condition, and
  • View the results of a multiphase simulation in ParaView


Slide

System Specifications

To record this tutorial, I am using,

Ubuntu Linux OS version 22.04* OpenFOAM version 9

  • ParaView version 5.10.1, and
  • gedit Text Editor


Slide

Prerequisites* If not, please go through the prerequisite OpenFOAM tutorial on https://spoken-tutorial.org


As a prerequisite,
  • You should have basic knowledge of multiphase flows.
  • You should also be familiar with parallel computing in OpenFOAM.
  • If not, please go through the prerequisite OpenFOAM tutorials on this website.


Slide

Code Files

  • The files used in this tutorial are available in the Code Files link on this tutorial page
  • Please download and extract them
  • Make a copy and then use them while practicing
  • Copy the damBreak folder into the run directory to follow along


Slide

Breaking of a Dam

  • We will be solving the dam break problem shown in the figure.
  • Initially, there is a water column in the domain, and
  • It is surrounded by air.


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:
  • leftWall
  • rightWall
  • lowerWall, and
  • atmosphere


It is named so, as it is exposed to the atmosphere.

[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.


Therefore, a totalPressure of 0 Pa is imposed.

Only Narration The additional reading material has more details on p_rgh and its boundary conditions.


Please refer to it.

[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:


internalField uniform 0 Link

The domain is initialized uniformly with a value of 0.


This means the entire domain consists of only air.


We will be initializing the section of the domain with the water column later.

[gedit - alpha.water.orig] Highlight:


zeroGradient Link


Point to the contact angles and walls.

The surface tension effects between the walls and the fluid-interface are ignored.


Thus, the contact angle between the walls and the fluid-interface is 90 degrees.


Therefore, all three walls are imposed with zeroGradient boundary condition.

[gedit - alpha.water.orig] Highlight:


type inletOutlet Link

The inletOutlet type boundary condition is imposed on the top boundary.


It acts as a zeroGradient boundary condition for outflow.

[gedit - alpha.water.orig] Highlight:


inletValue uniform 0 Link

For inflow, this type of boundary condition takes the inletValue as the fixedValue.


We have specified the inletValue as 0, corresponding to 100 percent air.

[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:


gedit 0/U

Let’s view the initial and boundary values of U


U is the Velocity Boundary Conditions file.

Slide

Velocity Boundary Conditions* walls - noSlip

  • top (atmosphere) - pressureInletOutletVelocity


Let’s look at the boundary conditions of velocity.* At the walls, noSlip condition is imposed
  • At the top boundary, pressureInletOutletVelocity type boundary condition is imposed.


Slide

pressureInletOutletVelocity

The pressureInletOutletVelocity
  • Acts as a zeroGradient boundary condition for outflow.
  • And for inflow, it acts as a fixedValue boundary condition.


[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:


momentumTransport

In this simulation, the flow is considered to be laminar.


The same is specified in the momentumTransport file.

[Terminal] Type:


gedit constant/momentumTransport

Let's view the contents of the momentumTransport file.


The simulationType is specified as laminar.

[gedit - momentumTransport]

Close the window

Close the momentumTransport file.
[Terminal] Highlight:


g

The simulation requires the acceleration due to gravity, to be specified.


The g file is used to specify the acceleration due to gravity. This has been discussed in the previous tutorials in this series.

Slide


Transport Properties

These are the transport properties of water and air used in this simulation.
Slide


Transport Properties

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:


method scotch Link

The domain is decomposed using the scotch decomposition method.


Scotch decomposition requires no geometric input.


It attempts to minimize the number of processor boundaries.

[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.


This bounding box contains the cells that hold the water column.

Slide

boxToCell* box (minx miny minz) (maxx maxy maxz)


  • boxToCell creates a bounding box within a vector minimum and maximum to define the cells
  • This is the syntax of boxToCell


Slide


Water Column

The section occupied by the water column is shown in the figure.


We have considered the thickness of the geometry to be 0.1 meter.

Slide

boxToCell

For the water column,
  • The vector minimum is the origin, and
  • The vector maximum is (0.5,1,0.1)


[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:


alpha.water 1 Link

The phase fraction of water is specified to be 1 within the box.


This means that the box is completely filled with water.

[gedit - setFieldsDict]

Close the window

Close the setFieldsDict file.
[Terminal] Type:

blockMesh

Let’s mesh the geometry using the blockMesh command.
[Terminal] Type:


setFields

Then, let’s set the fields in the domain using the setFields command.


Note that the setFields command should be executed only after meshing.

Only Narration The additional reading material has more details on the setFields utility.


Please refer to it.

[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.
  • It solves incompressible, isothermal, turbulent, multiphase flows.
  • It captures the interface of 2 immiscible fluids using the volume of fluid method.


[Terminal] Type:

mpirun -np 4 interFoam -parallel

Let’s start the simulation using the following command.
[Terminal] Type:


reconstructPar

Since we had run our simulation in parallel, our solution is decomposed.


Let’s reconstruct our solution using the reconstructPar command.

[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


Click on vtkBlockColors >> Click on alpha.water Link

Let’s view the contours of phase fraction of water.


Click on the vtkBlockColors dropdown in the Active Variable Controls and select alpha.water.

[ParaView] Layout Window


Initial Phase Fraction Contour

You can see the initial contours of phase fraction of water showing the water column.
[ParaView] VCR Controls


Click on Play Link

Let’s see how the contours change with time.


Click on the Play button in the VCR Controls.

[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.


Let’s summarize.

Slide

Summary

In this tutorial, we have learnt to:
  • Set up a case of multiphase flow
  • Decompose the domain using scotch decomposition method
  • Specify a non-uniform initial condition, and
  • View the results of a multiphase simulation in ParaView


Slide

Assignment

As an assignment:* For the same domain, increase the height of the water column to 1.5 meter, and
  • Run the simulation.


Slide

About the Spoken Tutorial Project

The video at the following link summarizes the Spoken Tutorial project.


Please download and watch it.

Slide

Spoken Tutorial Workshops

We conduct workshops using Spoken Tutorials and give certificates.


Please contact us.

Slide

Spoken Tutorial Forum

Please post your timed queries in this forum.
Slide

FOSSEE Forum

* Do you have any general/technical questions?
  • Please visit the forum given in the link.


Slide

FOSSEE Case Study Project

  • The FOSSEE team coordinates solving feasible CFD problems of reasonable complexity using OpenFOAM.
  • We give honorarium and certificates to those who do this.
  • For more details, please visit these sites.


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.

Contributors and Content Editors

Evan