##### Child pages
• OpenFOAM - Spillway Tutorial

# Page History

## Key

• This line was removed.
• Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

The case will be based on the damBreak tutorial supplied with OpenFOAM, but we will gather example files from other tutorials as well. In this tutorial we will look at a spillway width dimensions as shown in the image below (all dimensions are in meters):

The water will enter the domain with a fixed velocity along the left face, flow over the dam and out through the right boundary. The corners of the dam is rounded with a radius of 1 meter. As both the water velocity and the area of the inlet is known and fixed, we know the volume flow of water. In this case we will use 3.6

Wiki Markup
{latex}$m^3/s${latex}
per unit width as the target volume flow. As the solution reaches a steady state (when the discharge over the dam becomes equal to the amount of water entering the reservoir), we can record the height of the free surface.

...

We will now switch from the

Wiki Markup
{latex}$k-\epsilon${latex}
turbulence model used in the tutorial to a
Wiki Markup
{latex}$k-\omega$ SST{latex}
model. That means that we will have to make some slight adjustments in the differentiation schemes. Replace all occurrences of epsilon by omega and make sure that the divSchemes section looks like:

...

We have now changed the turbulence model from

Wiki Markup
{latex}$k-\epsilon${latex}
to a
Wiki Markup
{latex}$k-\omega$ SST{latex}
model. Follow the procedure in the original damBreak tutorial, and try to run this case. If you get any error messages, it is strongly recommended that you correct them before you proceed.

...

Make sure that all these files are present. If any more files are present (for example nuTilda, nut or alpha1.org) they can be deleted. To help us judging the boundary conditions for the turbulent variables k and omega, you can use the CFD-online turbulence calculator. With a target volume flow of 3.6

Wiki Markup
{latex}$m^3/s${latex}
per unit width over a height of 6 meter, that will give a inlet (freestream) velocity of 0.6 m/s. You can use your own judgments for the turbulence intensity levels and length scales (whether this spillway is in a river or in a great lake will affect the choices you make). In this example we have used 2% turbulence intensity with a characteristic length scale of 0.1 meter.

...

We have now made a new mesh, boundary and initial conditions. Before we try to run this case it might be wise to clean up the results from any previous runs. This is done with the foamClearPolyMesh and foamCleanTutorials commands. In addition to this we will have to move our initial and boundary condition files from the 0.org-folder to the 0-folder:

Code Block
 bash bash solid Terminal window solid
foamClearPolyMesh
foamCleanTutorials
cp 0.org/* 0/
blockMesh
interFoam

...

As nobody wants to write the input files for snappyHexMesh from scratch, we will copy it from one of the examples supplied with OpenFOAM. Look in the $FOAM_TUTORIALS/incompressible/pimpleDyMFoam/wingMotion/wingMotion_snappyHexMesh/system/ folder and copy the snappyHexMeshDict file into your system directory. Also copy the $FOAM_TUTORIALS/incompressible/pimpleDyMFoam/wingMotion/wingMotion2D_simpleFoam/system/extrudeMeshDict file to your system directory (we will need it later). This can be done with the following commands in the terminal:

Code Block
 bash bash solid Terminal window solid
cp $FOAM_TUTORIALS/incompressible/pimpleDyMFoam/wingMotion/wingMotion_snappyHexMesh/system/snappyHexMeshDict system/ cp$FOAM_TUTORIALS/incompressible/pimpleDyMFoam/wingMotion/wingMotion_snappyHexMesh/system/extrudeMeshDict system/

...

Now create the mesh:

Code Block
 bash bash solid Terminal window solid
blockMesh
snappyHexMesh -overwrite

...

Recreate the mesh with the new settings:

Code Block
 bash bash solid Terminal window solid
foamClearPolyMesh
blockMesh
snappyHexMesh -overwrite

...

We have all our boundary condition files in a folder 0.org, but we must put them in the folder 0. Therefore, delete all the files already present in the 0 folder (snappyHexMesh creates some files there that becomes invalid after mesh extrusion. Those files must be removed.) and copy the contents of 0.org into 0. Then you can use the setFields utility to initialize the volume fraction:

Code Block
 bash bash solid Terminal window solid
rm 0/*
cp 0.org/* 0/
setFields

...

Read through the rest of this file and make sure that you do understand what all the parameters mean. Note that we now have enabled automatic time-step scaling based on the Courant number. OpenFOAM will at each time iteration scale the timestep to satisfy Wiki Markup{latex}$\operatorname{max}(Co) < 0 .5${latex}.

### decomposeParDict

The system/decomposeParDict file controls the decomposition in several processes. Since we have one main direction, we will only decompose along the x-axis. Make sure that you decompose the domain in the same number of parts as you have processor cores available on your computer. You can choose decomposition method simple or hierarchical as you like, they will behave the same in this case. In this example we will use four processors and the simple method. The system/decomposeParDict file should then contain:

...

You are now ready to start the analysis. The first you do is to decompose the case , and then you start the solver in parallel:

Code Block
 bash bash solid Terminal window solid
decomposePar
mpirun -np 4 interFoam -parallel

...

When the analysis is finished it is time to find the answer to the original question: given a volume flow of 3.6

Wiki Markup
{latex}$m^3/s${latex}
, what is the water level behind the spillway? This can be found using the post-processing tools in Paraview.

...

To create an empty file, we can use the touch command. Then we open the file in Paraview:

Code Block
 bash bash solid Terminal window solid
touch spillway.foam
paraview spillway.foam

...

To find the free surface elevation at a point can at first seem to be somewhat difficult, as Paraview does not have any such "surface elevation tool". Another difficulty is that OpenFOAM itself does not solve for the surface elevation, it solves for the volume fraction

Wiki Markup
{latex}$\alpha_1 = \text{volume of water in cell}/\text{total volume of cell}${latex}
. That means that we will at least have one cell, probably more, where the volume fraction is somewhere in the region
Wiki Markup
{latex}$0 < \alpha_1 < 1${latex}
. There are (at least) two common ways to find the surface elevation from the volume fraction:

1. Sample the volume fraction along a vertical line parallel to the z-axis crossing the free surface, and use interpolation to find where Wiki Markup{latex}$\alpha_1 = 0 .5${latex}.
2. Integrate the volume fraction from the bottom of your domain to the atmosphere along a line parallel to the z-axis:
Wiki Markup
{latex}$\zeta = \int_0^{z_{atm}} \alpha_1 \mathrm{dz}${latex}

The latter method will be used here, as it is easy implementable in Paraview using standard tools.

...