Challenge

Week 8 - Simulation of a backward facing step in OpenFOAM

Objective: -

  • To simulate an incompressible-laminar-viscous flow through the backward facing step geometry and perform transient simulation
  • 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 grading factor of 0.2. The cells should be finer near the walls (includig the step wall)

Mesh specification: -

  1. Number of cells along the x direction (longer dimension) = 200
  2. Number of cells along the longer y direction = 20

Incompressible flow : -

Flow in which there is no change in density or where density is constant which is called incompressible flow. An equivalent statement that implies incompressibility is that the divergence of the flow velocity is zero.

`nabla . u =0`

Laminar Flow :-

Laminar flow is flow where fluid is regular and there is no mixing. It can be visualised by the use of pathlines which do not intersect each other. Laminar flow are charterized by the particle following smooth path in layers with each layer moving smoothly past the adjacent layers with little or no mixing. At low velocities fluid tends to flow without lateral mixing and adajacent layers slide past one another like playing cards. There are no cross current perpendicular to direction of flow nor eddies or swirl of fluid. Laminar flow has motion of fluid very orderly with particle close to a solid surface moving in straight line parallel to surface.

Reynolds number : -

Reynolds number is parameter to diffrentiate flow is laminar or turbulent. Reynolds numnber is defined as ratio of inertial force to viscous flow When reynolds numnber is less than 2000, flow in pipe is laminar and greater than 2000 flow is turbulent.

`Re = (rho .v. L)/mu`

Viscous flow: -

Fluid flow in which there is a continous steady motion of particle the motion at fixed point always remains constant. It is also called streamline, laminar flow, steady flow. Fluid is form of layers which stick with wall has zero velocity which is known as no slip condition and it develops the frictional effect . Frrictional effect are also present between two layers of fluid and slower layers tries to slow down the fater layer which can be measeured by viscosity.

Grading factor: -

Grading factor = size of last cell / size of first cell

Steps : -

  • To start simulation process first Run Ubuntu on windows.
  • When terminal gets open then we are going to solve problem using tutorial so type tut in terminal
  • Then type 'ls' to see what kind of tutorial are present inside we have to solve incompressible flow simulation so open incompressible directory by usinf 'cd incompressible command'.
  • Type 'ls' and open icoFoam using 'cd icoFoam' as we need to solve for laminar viscous flow it is solver which is use for incompressible,laminar flow of newtonian fluid.
  • Then in icoFoam we will find cavity we will open that folder where we define our fluid domain and genrate blockmesh. OpenFoam does not let us change in there official tutorial and it can corrupt OpenFoam . So we need to copy cavity folder using 'cp-r cavity' command and paste it in OpenFoam run folder using 'cp-r cavity $FOAM_RUN/cavity_test'
  • Then run folder by typing 'cd $FOAM_RUN' and we can find cavity_test file and we make changes it will not affect official file.
  • In cavity_test we can find system file then we open system using 'cd system' command and where we can find blockmeshdict file and we need to open it by usinf 'notepad.exe blockMeshDict' we need to edit that file which contains information regarding geometry. File is shown below
  • Then we close and save blockmeshdict then we open controldict file using 'notepad.exe controlDict' where we provide start time ,end time and deltat. After making changes we close and save file. controldict file is shown below.
  • Then we define initial value for pressure and velocity. By going back to cavity_test we need to use command 'cd ..' then we give intial values in 0. which is shown below
  • Then we give 'cd ..' to go back to cavity_test then we run blockMesh command to deploy mesh and use 'checkMesh' command to check error in mesh if its ok we will get Mesh Ok on terminal.
blockMeshDict

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2012                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

scale   1;

vertices
(
    (0 0 0) 
    (0.08 0 0) 
    (0.08 0.005 0) 
    (0 0.005 0)  
    (0.08 0.01 0) 
    (0 0.01 0) 
    (0.20 0.01 0) 
    (0.20 0.005 0) 
    (0.20 0 0) 
    (0.20 -0.01 0) 
    (0.08 -0.01 0) 
    (0 0 0.1) 
    (0.08 0 0.1) 
    (0.08 0.005 0.1) 
    (0 0.005 0.1) 
    (0.08 0.01 0.1) 
    (0 0.01 0.1) 
    (0.20 0.01 0.1) 
    (0.20 0.005 0.1) 
    (0.20 0 0.1) 
    (0.20 -0.01 0.1) 
    (0.08 -0.01 0.1) 
);

blocks
(
    hex (0 1 2 3 11 12 13 14) (80 5 1) simpleGrading (1 1 1)
    hex (3 2 4 5 14 13 15 16) (80 5 1) simpleGrading (1 1 1)
    hex (2 7 6 4 13 18 17 15) (120 5 1) simpleGrading (1 1 1)
    hex (1 8 7 2 12 19 18 13) (120 5 1) simpleGrading (1 1 1)
    hex (10 9 8 1 21 20 19 12) (120 10 1) simpleGrading (1 1 1)
);

edges
(
);

boundary
(
    Inlet
    
    {
        type wall;
        faces
        (
            (0 11 14 3)
            (3 14 16 5)
        );
    }
    Outlet
    {
        type wall;
        faces
        (
            (9 8 19 20)
            (8 7 18 19)
            (7 6 17 18)
        );
    }
    

    frontAndBack
    {
        type empty;
        faces
        (
            (11 12 13 14)
            (14 13 15 16)
	    (13 18 17 15)
	    (12 19 18 13)
	    (21 20 19 12)
	    (0 3 2 1)
            (3 5 4 2)
            (2 4 6 7)
	    (1 2 7 8)
	    (10 1 8 9)
        );
    }
    fixedWalls
    {
        type wall;
        faces
        (
            (5 16 15 4)
            (0 1 12 11)
            (4 15 17 6)
            (10 9 20 21)
            (10 21 12 1)
        );
    }
);

mergePatchPairs
(
);

// ************************************************************************* //
BlockMeshDict 

applying grading factor 0.2

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2012                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

scale   1;

vertices
(
    (0 0 0) 
    (0.08 0 0) 
    (0.08 0.005 0) 
    (0 0.005 0)  
    (0.08 0.01 0) 
    (0 0.01 0) 
    (0.20 0.01 0) 
    (0.20 0.005 0) 
    (0.20 0 0) 
    (0.20 -0.01 0) 
    (0.08 -0.01 0) 
    (0 0 0.1) 
    (0.08 0 0.1) 
    (0.08 0.005 0.1) 
    (0 0.005 0.1) 
    (0.08 0.01 0.1) 
    (0 0.01 0.1) 
    (0.20 0.01 0.1) 
    (0.20 0.005 0.1) 
    (0.20 0 0.1) 
    (0.20 -0.01 0.1) 
    (0.08 -0.01 0.1) 
);

blocks
(
    hex (0 1 2 3 11 12 13 14) (80 5 1) simpleGrading (0.2 5 1)
    hex (3 2 4 5 14 13 15 16) (80 5 1) simpleGrading (0.2 0.2 1)
    hex (2 7 6 4 13 18 17 15) (120 5 1) simpleGrading (5 0.2 1)
    hex (1 8 7 2 12 19 18 13) (120 5 1) simpleGrading (5 5 1)
    hex (10 9 8 1 21 20 19 12) (120 10 1) simpleGrading (5 5 1)
);

edges
(
);

boundary
(
    Inlet
    
    {
        type wall;
        faces
        (
            (0 11 14 3)
            (3 14 16 5)
        );
    }
    Outlet
    {
        type wall;
        faces
        (
            (9 8 19 20)
            (8 7 18 19)
            (7 6 17 18)
        );
    }
    

    frontAndBack
    {
        type empty;
        faces
        (
            (11 12 13 14)
            (14 13 15 16)
	    (13 18 17 15)
	    (12 19 18 13)
	    (21 20 19 12)
	    (0 3 2 1)
            (3 5 4 2)
            (2 4 6 7)
	    (1 2 7 8)
	    (10 1 8 9)
        );
    }
    fixedWalls
    {
        type wall;
        faces
        (
            (5 16 15 4)
            (0 1 12 11)
            (4 15 17 6)
            (10 9 20 21)
            (10 21 12 1)
        );
    }
);

mergePatchPairs
(
);

// ************************************************************************* //
controlDict 

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2012                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application     icoFoam;

startFrom       startTime;

startTime       0;

stopAt          endTime;

endTime         0.5;

deltaT          0.0001;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


// ************************************************************************* //
Velocity

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2012                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     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;
    }

    fixedWalls
    {
        type            noSlip;
    }

    
    forntAndBack
    {
        type            empty;
    }
}

// ************************************************************************* //
Pressure 

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2012                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     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;
    }
    fixedWalls
    {
        type            zeroGradient;
    }

    frontAndBack
    {
        type            empty;
    }
}

// ************************************************************************* //

Output and result: -

All the output are uploaded as screenshot with and without grading factor. Velocity plot and at distance 0.085m are uploaded below with and without grading factor. We can see the the plot for velocity without grading factor seems more smooth and accurate . To get and effective and relible result we should know to use finer grading factor to get get fine 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.