Challenge

Week 8 - Simulation of a backward facing step in OpenFOAM

Objective:

In this challenge, you are going to simulate an incompressible-laminar-viscous flow through the backward-facing step geometry. You should perform a transient simulation. The solver can be chosen based on the described physics of the flow. You need to explain the entire simulation procedure (how you set up the case). You should also provide explanations for every change you make inside the reference case files obtained from OpenFOAM tutorials.

After that, you will perform 2 case studies as described below and compare the results.

Case 1 - Simulate the flow without using any grading factor (i.e., GF = 1)

Case 2 - Simulate the flow with a grading factor of 0.2. The cells should be finer near the walls (including the step wall).

You can use the following mesh parameters but you can feel free to modify these values.

Mesh specification

Number of cells along the x-direction (longer dimension) = 200

Number of cells along the longer y-direction = 20;

Boundary condition specification

Objective:

In this challenge, you are going to simulate an incompressible-laminar-viscous flow through the backward-facing step geometry. You should perform a transient simulation. The solver can be chosen based on the described physics of the flow. You need to explain the entire simulation procedure (how you set up the case). You should also provide explanations for every change you make inside the reference case files obtained from OpenFOAM tutorials.

After that, you will perform 2 case studies as described below and compare the results.

Case 1 - Simulate the flow without using any grading factor (i.e., GF = 1)

Case 2 - Simulate the flow with a grading factor of 0.2. The cells should be finer near the walls (including the step wall).

You can use the following mesh parameters but you can feel free to modify these values.

Mesh specification

Number of cells along the x-direction (longer dimension) = 200

Number of cells along the longer y-direction = 20;

Boundary condition specification

Desired output

Measure the velocity profile at 0.085 m from the inlet of the geometry for both case studies and compare. You can use the plot over line tool for this.

Explain why the Grading/Growth factor is essential for meshing.

Solution:

Here we are going to simulate an incompressible laminar and viscous flow over a channel using the backward-facing step. And we are going to perform this simulation in OpenFOAM. And yes we are going to have to run some basic commands to run the simulation in order to understand flow properties then later we are going to post-process this in paraview to see how the temperature and pressure change with different time steps.

Now we get started we open the terminal command window in ubuntu, this is just like our command prompt from windows OS, and here we are going to go to the directory where the OpenFOAM is installed.

NOTE: that for every problem we have different solvers so here for Incompressible flow we have the ICOFOAM solver.

NOTE:

The solvers can be copied from the TUTORIALS folder RUN folder only then you are able o run the command or it won't run if one tries to do it in TUTORIAL itself. Below are examples of how you should proceed with t0he commands

total 84

drwxr-xr-x 17 root root 4096 Mar 8 18:19 ./

drwxr-xr-x 11 root root 4096 Mar 8 18:19 ../

-rwxr-xr-x 1 root root 504 Nov 14 18:07 Allclean*

-rwxr-xr-x 1 root root 3217 Nov 14 18:07 Allrun*

-rwxr-xr-x 1 root root 6048 Nov 14 18:07 Alltest*

drwxr-xr-x 5 root root 4096 Mar 8 18:19 basic/

drwxr-xr-x 9 root root 4096 Mar 8 18:19 combustion/

drwxr-xr-x 6 root root 4096 Mar 8 18:19 compressible/

drwxr-xr-x 4 root root 4096 Mar 8 18:19 discreteMethods/

drwxr-xr-x 3 root root 4096 Mar 8 18:19 DNS/

drwxr-xr-x 4 root root 4096 Mar 8 18:19 electromagnetics/

drwxr-xr-x 3 root root 4096 Mar 8 18:19 financial/

drwxr-xr-x 5 root root 4096 Mar 8 18:19 heatTransfer/

drwxr-xr-x 13 root root 4096 Mar 8 18:19 incompressible/

drwxr-xr-x 3 root root 4096 Mar 8 18:19 IO/

drwxr-xr-x 9 root root 4096 Mar 8 18:19 lagrangian/

drwxr-xr-x 8 root root 4096 Mar 8 18:19 mesh/

drwxr-xr-x 13 root root 4096 Mar 8 18:19 multiphase/

drwxr-xr-x 4 root root 4096 Mar 8 18:19 resources/

drwxr-xr-x 4 root root 4096 Mar 8 18:19 stressAnalysis/

skill_lync@skillync:/opt/openfoam8/tutorials$ cd basic/

skill_lync@skillync:/opt/openfoam8/tutorials/basic$ ls

laplacianFoam potentialFoam scalarTransportFoam

skill_lync@skillync:/opt/openfoam8/tutorials/basic$ cd ../

skill_lync@skillync:/opt/openfoam8/tutorials$ cd incompressible/

skill_lync@skillync:/opt/openfoam8/tutorials/incompressible$ ls

adjointShapeOptimizationFoam icoFoam pimpleFoam porousSimpleFoam simpleFoam SRFSimpleFoam

boundaryFoam nonNewtonianIcoFoam pisoFoam shallowWaterFoam SRFPimpleFoam

skill_lync@skillync:/opt/openfoam8/tutorials/incompressible$ cd icoFoam/

skill_lync@skillync:/opt/openfoam8/tutorials/incompressible/icoFoam$ ls

cavity elbow

skill_lync@skillync:/opt/openfoam8/tutorials/incompressible/icoFoam$ cp -r cavity/ FOAM_RUN

cp: cannot create directory 'FOAM_RUN': Permission denied

skill_lync@skillync:/opt/openfoam8/tutorials/incompressible/icoFoam$ cp -r cavity/ $FOAM_RUN

skill_lync@skillync:/opt/openfoam8/tutorials/incompressible/icoFoam$ $FOAM_RUN

bash: /home/skill_lync/OpenFOAM/skill_lync-8/run: Is a directory

skill_lync@skillync:/opt/openfoam8/tutorials/incompressible/icoFoam$ ls

cavity elbow

skill_lync@skillync:/opt/openfoam8/tutorials/incompressible/icoFoam$ cd $FOAM_RUN

skill_lync@skillync:~/OpenFOAM/skill_lync-8/run$ ls

cavity flange pitzDaily

skill_lync@skillync:~/OpenFOAM/skill_lync-8/run$ cd cavity

skill_lync@skillync:~/OpenFOAM/skill_lync-8/run/cavity$ ls

Allclean Allrun cavity cavityClipped cavityGrade

skill_lync@skillync:~/OpenFOAM/skill_lync-8/run/cavity$

as You can see here that you have copied the Cavity folder from icoFoam solver to the RUN folder, where we are going to run it. Now once we are here we need to edit the basic txt files to be able to read and for the simulation to run smoothly. STeps involved to run and edit the files. These ar the files that we need to edit before we for running simulations:

1. BLockMeshDict

2. controlDict

3. Fvscehmes

4. fvsolution

these files can be found under the cavity/cavity/system directory. that how we edit the following text files according to the objectives grid points

BlockmeshDict:

Create time

Creating block mesh from

"system/blockMeshDict"

Creating block edges

No non-planar block faces defined

Creating topology blocks

Creating topology patches

Creating block mesh topology

Check topology

Basic statistics

Number of internal faces : 5

Number of boundary faces : 20

Number of defined boundary faces : 20

Number of undefined boundary faces : 0

Checking patch -> block consistency

Creating block offsets

Creating merge list .

Creating polyMesh from blockMesh

Creating patches

Creating cells

Creating points with scale 1

Block 0 cell size :

i : 0.001 .. 0.001

j : 0.0005 .. 0.0005

k : 0.01

Block 1 cell size :

i : 0.001 .. 0.001

j : 0.0005 .. 0.0005

k : 0.01

Block 2 cell size :

i : 0.001 .. 0.001

j : 0.0005 .. 0.0005

k : 0.01

Block 3 cell size :

i : 0.001 .. 0.001

j : 0.0005 .. 0.0005

k : 0.01

Block 4 cell size :

i : 0.001 .. 0.001

j : 0.0005

k : 0.01

Writing polyMesh

----------------

Mesh Information

----------------

boundingBox: (0 -0.01 0) (0.2 0.01 0.01)

nPoints: 13282

nCells: 6400

nFaces: 25840

nInternalFaces: 12560

----------------

Patches

----------------

patch 0 (start: 12560 size: 20) name: inlet

patch 1 (start: 12580 size: 40) name: outlet

patch 2 (start: 12620 size: 12800) name: frontAndBack

patch 3 (start: 25420 size: 420) name: top_bottom_step

End

if it shows like this then your Blockmesh Command run smoothly which now is indicated that your simulation is correct and ready to run for postprocessing the results. After running the icoFoam command in the cavity folder we get to the next section of post-processing.

skill_lync@skillync:~/OpenFOAM/skill_lync-8/run/cavity/cavity$ cd ..

skill_lync@skillync:~/OpenFOAM/skill_lync-8/run/cavity$ ll

total 28

drwxr-xr-x 5 skill_lync skill_lync 4096 Apr 19 11:53 ./

drwxrwxr-x 5 skill_lync skill_lync 4096 Mar 22 16:59 ../

-rwxr-xr-x 1 skill_lync skill_lync 450 Mar 26 12:00 Allclean*

-rwxr-xr-x 1 skill_lync skill_lync 2346 Mar 26 12:00 Allrun*

drwxr-xr-x 245 skill_lync skill_lync 4096 Apr 20 17:58 cavity/

drwxr-xr-x 5 skill_lync skill_lync 4096 Apr 19 11:53 cavityClipped/

drwxr-xr-x 5 skill_lync skill_lync 4096 Apr 19 11:53 cavityGrade/

skill_lync@skillync:~/OpenFOAM/skill_lync-8/run/cavity$ Blockmesh

Blockmesh: command not found

skill_lync@skillync:~/OpenFOAM/skill_lync-8/run/cavity$ ls

Allclean Allrun cavity cavityClipped cavityGrade

skill_lync@skillync:~/OpenFOAM/skill_lync-8/run/cavity$ cd cavity

skill_lync@skillync:~/OpenFOAM/skill_lync-8/run/cavity/cavity$ ls

0 0.075 0.15 0.225 0.3 0.375 0.45 0.525 0.6 0.675 0.75 0.825 0.9 0.975 1.05 1.125 1.2

0.005 0.08 0.155 0.23 0.305 0.38 0.455 0.53 0.605 0.68 0.755 0.83 0.905 0.98 1.055 1.13 constant

0.01 0.085 0.16 0.235 0.31 0.385 0.46 0.535 0.61 0.685 0.76 0.835 0.91 0.985 1.06 1.135 system

0.015 0.09 0.165 0.24 0.315 0.39 0.465 0.54 0.615 0.69 0.765 0.84 0.915 0.99 1.065 1.14

0.02 0.095 0.17 0.245 0.32 0.395 0.47 0.545 0.62 0.695 0.77 0.845 0.92 0.995 1.07 1.145

0.025 0.1 0.175 0.25 0.325 0.4 0.475 0.55 0.625 0.7 0.775 0.85 0.925 1 1.075 1.15

0.03 0.105 0.18 0.255 0.33 0.405 0.48 0.555 0.63 0.705 0.78 0.855 0.93 1.005 1.08 1.155

0.035 0.11 0.185 0.26 0.335 0.41 0.485 0.56 0.635 0.71 0.785 0.86 0.935 1.01 1.085 1.16

0.04 0.115 0.19 0.265 0.34 0.415 0.49 0.565 0.64 0.715 0.79 0.865 0.94 1.015 1.09 1.165

0.045 0.12 0.195 0.27 0.345 0.42 0.495 0.57 0.645 0.72 0.795 0.87 0.945 1.02 1.095 1.17

0.05 0.125 0.2 0.275 0.35 0.425 0.5 0.575 0.65 0.725 0.8 0.875 0.95 1.025 1.1 1.175

0.055 0.13 0.205 0.28 0.355 0.43 0.505 0.58 0.655 0.73 0.805 0.88 0.955 1.03 1.105 1.18

0.06 0.135 0.21 0.285 0.36 0.435 0.51 0.585 0.66 0.735 0.81 0.885 0.96 1.035 1.11 1.185

0.065 0.14 0.215 0.29 0.365 0.44 0.515 0.59 0.665 0.74 0.815 0.89 0.965 1.04 1.115 1.19

0.07 0.145 0.22 0.295 0.37 0.445 0.52 0.595 0.67 0.745 0.82 0.895 0.97 1.045 1.12 1.195

This is how it looks like that the simulation through completely and correctly which shows the number of time steps it took and required to post-process with para form using paraview and display the results.

Output:

when the simple grading at 1.

Why Grading/Growth factor is essential for meshing?

To sum up, the blockMeshDict dictionary generates a single block with:
• X/Y/Z dimensions: 1.0/1.0/1.0
• As the cell spacing in all directions is defined as 0.05, it will use the following number of cells in the X, Y, and Z directions: 20 x 20 x 20 cells.
• One single hex block with straight lines.
• Six patches of base type wall, namely, left, right, top, bottom, front, and back.
• The information regarding the patch base type and patch name is saved in the file boundary. Feel free to modify this file to fit your needs.
• Remember to use the utility check mesh to check the quality of the mesh and look for topological errors.
• Topological errors must be repaired.

conclusion: There is a slight difference between the meshes and the plot from the output. As we can see the slope is not different from one another.

A.1 Standard solvers (openfoam.com)

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.