Challenge

Week 8 - Simulation of a backward facing step in OpenFOAM

AIM: To simulate an incompressible-laminar-viscous flow through the backward facing step geometry.

OBJECTIVES:

1. Simulate incompressible laminar viscous flow through BFS geometry using solvers in OpenFoam.

2. To compare the results of different grading i.e., 1 and 0.2 respectively any explaining the importance in grading/growth factor in meshing.

3. Mesh specifications is No. of cells along the x direction = 200 and No. of cells along the longer y direction = 20.

4. For Geometric specifications the geometric dimensions and boundary specifications of the Backward facing step (BFS) is given in below figure.

THEORY AND EXPLANATION:

STEPS INVOLVED IN SIMULATION:

1. In order to start the simulation process, First start terminal in Linux Operating system using ctrl+alt+T buttons on key board or right click -> Open Terminal. After starting terminal yo will see following window.

2. Now, we have to simulate our problem in openFOAM and we are going to solve our problem using tutorials present in openFOAM, therefore, just type ‘tut’ to open OpenFOAM tutorial directory. And type ‘ls’ to identify what kind of tutorials present inside this directory.

3. We have to solve incopressible flow simulation for this problem so select incompressible directory by typing ‘cd incompressible/’ and then again type ‘ls’ to explore folders in incompressible folders.

4. we will select icoFoam folder by typing ‘cd icoFoam/’ and by typing ‘ls’ we explore this folder in terminal.

icoFoam is the solver in openFoam which is use as transient solver for incopressible, laminar flow of Newtonian fluids. (Newtonian fluid is a fluid in which the viscous stress arising from its flow, at every point, are linearly correlated to the local strain rate - the rate of change of its deformation over time. Newtonian fluids are the simplest mathematical models of fluids that account for viscosity.)

5. Here, we have, again to option, cavity and elbow. They both are part of the icoFoam solver and cavity section use to create required domain and black mesh so select ‘cavity’ folder.

6. In cavity, we are, again, going to see cavity folder, where we have to define our fluid domain and generate block mesh. But we are not going to make any changes here in tutorial section. First of all, OpenFoam does no let anyone make any changes in their official tutorial and secondly, any changes with their official tutorials my corrupt openFoam. An in a bid to correct it, we may need to reinstall open foam all over again.

So, we are going to copy this cavity folder using ‘cp -r cavity’ command and paste it in openFoam run folder by typing ‘cp -r cavity $FOAM_RUN/cavity_test’.

7. And then open run folder by typing ‘cd $FOAM_RUN’. where we can see cavity_test file.

8. Now, we can make any changes to the cavity_test file, which will never affect the openFoam official files. Open cavity_test folder. Here, we can provide specification for our block mesh in system folder.

9. There are 4 script file system folder and by opening blockMeshDict we can create domain and provide required specification for block mesh. So, open this file by typing ‘gedit blockMeshDict’.

10. Now, make following changes in blockMeshDict script file. The blockMeshDict file is a script file that contains information regarding all aspects of the geometry:

CASE 1: For Grading Factor = 1

BLOCKMESHDICT FILE:

/*--------------------------------*- C++ -*----------------------------------*
 ========= |
 \ / F ield | OpenFOAM: The Open Source CFD Toolbox
 \ / O peration | Website: https://openfoam.org
 \ / A nd | Version: 8
 \/ M anipulation |
*---------------------------------------------------------------------------*/
FoamFile
{
 version 2.0;
 format ascii;
 class dictionary;
 object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.01;
vertices
(
 (0 0 0) //vertex 0
 (8 0 0) //vertex 1
 (8 1 0) //vertex 2
 (0 1 0) //vertex 3
 (14 0 0) //vertex 4
 (14 1 0) //vertex 5
 (20 0 0) //vertex 6
 (20 1 0) //vertex 7
 (8 -1 0) //vertex 8
 (14 -1 0) //vertex 9
 (20 -1 0) //vertex 10

 (0 0 10) //vertex 11
 (8 0 10) //vertex 12
 (8 1 10) //vertex 13
 (0 1 10) //vertex 14
 (14 0 10) //vertex 15
 (14 1 10) //vertex 16
 (20 0 10) //vertex 17
 (20 1 10) //vertex 18
 (8 -1 10) //vertex 19
 (14 -1 10) //vertex 20
 (20 -1 10) //vertex 21
);
blocks
(
 hex (0 1 2 3 11 12 13 14) (200 20 1) simpleGrading (1 1 1)
 hex (1 4 5 2 12 15 16 13) (200 20 1) simpleGrading (1 1 1)
 hex (4 6 7 5 15 17 18 16) (200 20 1) simpleGrading (1 1 1)
 hex (9 10 6 4 20 21 17 15) (200 20 1) simpleGrading (1 1 1)
 hex (8 9 4 1 19 20 15 12) (200 20 1) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
 inlet
 {
 type patch;
 faces
 
(
 (0 3 14 11)
 );
 }
 outlet
 {
 type patch;
 faces
 (
 (6 17 18 7)
 (10 21 17 6)
 );
 }
 frontAndBack
 {
 type empty;
 faces
 (
 (0 1 2 3)
 (1 4 5 2)
 (4 6 7 5)
 (9 10 6 4)
 (8 9 4 1)

 (11 14 13 12)
 (12 13 16 15)
 (15 16 18 17)
 (20 15 17 21)
 (19 12 15 20)
 );
 }
 noslipwalls
 {
 type wall;
 faces
 (
 (2 13 14 3)
 (5 16 13 2)
 (7 18 16 5)
 (9 20 21 10)
 (8 19 20 9)
 (1 12 19 8)
 (0 11 12 1)
 );
 }
);
mergePatchPairs
(
);
// ************************************************************************* //

ControlDict file is modified as per the requirement:

CONTROLDICT FILE:

/*--------------------------------*- C++ -*----------------------------------*
 ========= |
 \ / F ield | OpenFOAM: The Open Source CFD Toolbox
 \ / O peration | Website: https://openfoam.org
 \ / A nd | Version: 8
 \/ M anipulation |
*---------------------------------------------------------------------------*/
FoamFile
{
 version 2.0;
 format ascii;
 class dictionary;
 location "system";
 object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 0.1;
deltaT 1e-5;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
  • The system also provides the schemes to discretise the differential equation for Finite volume control methods.
  • Change the directory to 0 folder and edit the pressure and velocity files so as to set the initial and boundary conditions for them. The modified files for the pressure and velocity are:

PRESSURE FILE:

/*--------------------------------*- C++ -*----------------------------------*
 ========= |
 \ / F ield | OpenFOAM: The Open Source CFD Toolbox
 \ / O peration | Website: https://openfoam.org
 \ / A nd | Version: 8
 \/ M anipulation |
*---------------------------------------------------------------------------*/
FoamFile
{
 version 2.0;
 format ascii;
 class volScalarField;
 object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
 inlet
 {
 type zeroGradient;
 }
 outlet
 {
 type fixedValue;
 value uniform 0;
 }
 frontAndBack
 {
 type empty;
 }

 noslipwalls
 {
 type zeroGradient;
 }
}
// ************************************************************************* //

VELOCITY FILLE:

/*--------------------------------*- C++ -*----------------------------------*
 ========= |
 \ / F ield | OpenFOAM: The Open Source CFD Toolbox
 \ / O peration | Website: https://openfoam.org
 \ / A nd | Version: 8
 \/ M anipulation |
*---------------------------------------------------------------------------*/
FoamFile
{
 version 2.0;
 format ascii;
 class volVectorField;
 object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
 inlet
 {
 type fixedValue;
 value uniform (1 0 0);
 }
 outlet
 {
 type zeroGradient;

 }
 frontAndBack
 {
 type empty;
 }

 noslipwalls
 {
 type zeroGradient;
 }
}
// ************************************************************************* //
  • After required modifications we change the directory to cavity and run ‘blockMesh’ command to create the blocks and mesh for the BFS. we can check the mesh using ‘checkMesh’ command.
  • Then we run the solver using ‘icoFom’ command. This will take few minutes to hours as depending upon processors
    computational power.
  • After the solver has run, we can post process the solution in paraview using ‘paraFoam’ command.

CASE 2: For Grading Factor = 0.2

BLOCKMESHDICT FILE:

/*--------------------------------*- C++ -*----------------------------------*
 ========= |
 \ / F ield | OpenFOAM: The Open Source CFD Toolbox
 \ / O peration | Website: https://openfoam.org
 \ / A nd | Version: 8
 \/ M anipulation |
*---------------------------------------------------------------------------*/
FoamFile
{
 version 2.0;
 format ascii;
 class dictionary;
 object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.01;
vertices
(
 (0 0 0) //vertex 0
 (8 0 0) //vertex 1
 (8 1 0) //vertex 2
 (0 1 0) //vertex 3
 (14 0 0) //vertex 4
 (14 1 0) //vertex 5
 (20 0 0) //vertex 6
 (20 1 0) //vertex 7
 (8 -1 0) //vertex 8
 (14 -1 0) //vertex 9
 (20 -1 0) //vertex 10

 (0 0 10) //vertex 11
 (8 0 10) //vertex 12
 (8 1 10) //vertex 13
 (0 1 10) //vertex 14
 (14 0 10) //vertex 15
 (14 1 10) //vertex 16
 (20 0 10) //vertex 17
 (20 1 10) //vertex 18
 (8 -1 10) //vertex 19
 (14 -1 10) //vertex 20
 (20 -1 10) //vertex 21
);
blocks
(
 hex (0 1 2 3 11 12 13 14) (200 20 1) simpleGrading (.2 1 1)
 hex (1 4 5 2 12 15 16 13) (200 20 1) simpleGrading (5 1 1)
 hex (4 6 7 5 15 17 18 16) (200 20 1) simpleGrading (.2 1 1)
 hex (9 10 6 4 20 21 17 15) (200 20 1) simpleGrading (.2 1 1)
 hex (8 9 4 1 19 20 15 12) (200 20 1) simpleGrading (5 1 1)
);
edges
(
);
boundary
(
 inlet
 {
 type patch;
 faces
(
 (0 3 14 11)
 );
 }
 outlet
 {
 type patch;
 faces
 (
 (6 17 18 7)
 (10 21 17 6)
 );
 }
 frontAndBack
 {
 type empty;
 faces
 (
 (0 1 2 3)
 (1 4 5 2)
 (4 6 7 5)
 (9 10 6 4)
 (8 9 4 1)

 (11 14 13 12)
 (12 13 16 15)
 (15 16 18 17)
 (20 15 17 21)
 (19 12 15 20)
 );
 }
 noslipwalls
 {
 type wall;
 faces
 (
 (2 13 14 3)
 (5 16 13 2)
 (7 18 16 5)
 (9 20 21 10)
 (8 19 20 9)
 (1 12 19 8)
 (0 11 12 1)
 );
 }
);
mergePatchPairs
(
);
// ************************************************************************* //

CONTROLDICT FILE:

/*--------------------------------*- C++ -*----------------------------------*
 ========= |
 \ / F ield | OpenFOAM: The Open Source CFD Toolbox
 \ / O peration | Website: https://openfoam.org
 \ / A nd | Version: 8
 \/ M anipulation |
*---------------------------------------------------------------------------*/
FoamFile
{
 version 2.0;
 format ascii;
 class dictionary;
 location "system";
 object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 0.05;
deltaT 5e-6;
writeControl timeStep;
writeInterval 100;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //

RESULTS:

After making above changes, now the mesh is uniformly distributed along the surface:

For Grading Factor = 1:

VELOCITY PROFILE:

PRESSURE PROFILE:

PLOT FOR VELOCITY AND PRESSURE:

For Grading Factor = 2:

VELOCITY PROFILE:

PRESSURE PROFILE:

PLOT FOR VELOCITY AND PRESSURE:

CONCLUSION:

Velocity and Pressure curves are smoother with the GF=1 compaired to GF=0.2, but the results are accurate with GF=0.2. Finally, I conclude that to get the more accurete results, use finer mesh.

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.

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.