Challenge

Week 8 - Simulation of a backward facing step in OpenFOAM

Simulation of a backward facing step in OpenFOAM

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

THEROY-

Open Source Field Operation and Manipulation (OpenFOAM) is a free, open source CFD software. Which allows to simulate and perform flow motion across various geometry by running the solvers. As a CFD engineer, one has to study various aspects of flow variation in pressure field, velocity fields etc.

Now in this project we have to simulate the flow through a backward facing step

OBJECTIVE-

  • To simulate the flow through a backward facing step
  • To genrate Number of cells along the x direction (longer dimension) = 200
  • And Number of cells along the longer y direction = 20
  • To simulate the flow ny changing the gradent by factor of 0.2

STEPS -

  1. To simulate process, first start terminal in linux operating system using Cltr+Alt+T OR by right clicking>open Terminal.
  2. In terminal windiow type foam and it will open the openFoam where we can see various directory (by typing ls OR ll) like tutorials, applications, test etc
  3. To simulate our problem in openFoam we have to open tutorial directory by simply typing "tut" or "foam->cd tutorials/" (cd tut+tab will complite it to cd tutorials/). Once the tut is open type "ls" to see tutorials present the directory.
  4. We will select the icoFoam solver as it solves transient solver for incompressible, laminar flow of newtonian fluid; so type 'ls' and type 'cd incompressible/' and again type 'ls' to explore folder in incompressible folders.
  5. Select icofoam folder by typing "cd icoFoam/" and type 'ls' we can see two folders cavity and elbow select cavity by "cd cavity/"
  6. In cavity folder again there is cavity folder where we have to define our boundary, fluid domine and generate mesh. But we cannot make any changes in tutorial folder so we have to copy this folder where openFoam can allow to simulate the process.
  7. openFoam has a foldeer called run folder we can go to it edit delete and copy paste the solvers and run in this folder we can also explore this folder in folder opition in linux 'open folder home->openFoam->-->run' OR type "cd $FOAM_RUN/".
  8. Now to copy cavity we have to first copy the cavity folder to run folder to o tpye "cp -r cavity/ $FOAM_RUN/cavity_w8/. once folder is copyed go to the run, we have two ways to do one is the convemtional way opening it from folder (as mentioned above) amd other by opening from terminal.
  9. When cavity_w8 folder is created in run folder open and go to system folder where we can see the blockMeshDict where we have to edit the boundary conditions. To edit blockMeshDict type "gedit blockMeshDict" OR open it from files
  10. Following is the geometry of backward facing problem

  • Let us consider creating the geometry using 5 blocks as shown in the figure below,

  • Now let’s, start indexing the Vertices on the Back side of the Blocks, Since openFoam uses C++ programming, we start the index from “0”. (The Numbering of the vertices can be varied according to your comfort)

  • MESHING

Now to mesh the geometry fill in the number of cells in x, y and z direction inside the second parenthesis of the Hex command,

ie. hex (0 1 2 3 11 12 13 14) (200 20 1) simpleGrading (1 1 1)

where hex is hexagonal mesh of points as shown above (200 20 1); 200 mesh points around X directions 20 in Y directions, as it's 2D so Z direction will remain 1.

simpleGrading (1 1 1) shows that grading along X, Y, and Z direction is 1

  • FOR GRADING = 0.2

for block 1 - hex (0 1 2 3 11 12 13 14) (200 20 1) simpleGrading (0.2 5 1)
for block 2 - hex (3 2 4 5 14 13 15 16) (200 20 1) simpleGrading (0.2 0.2 1)
for block 3 - hex (2 7 6 4 13 18 17 15) (200 20 1) simpleGrading (5 0.2 1)
for block 4 - hex (1 8 7 2 12 19 18 13) (200 20 1) simpleGrading (5 5 1)
for block 5 - hex (10 9 8 1 21 20 19 12) (200 20 1) simpleGrading (5 0.2 1)

  • Grading factor of 0.2 is given in every block along X and Y direction
  • while grading the mesh should form fine where there is lot eddies and contact forned
  • so in Y dierection mesh is fine towards the boundary, and in Y it is more fine at the backward step.
  • resulting the accurate simulations as the eddis or the turbulance will form at that phase.

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)     // vertice 0
    (8 0 0)     // vertice 1
    (8 0.5 0)   // vertice 2
    (0 0.5 0)   // vertice 3
    (8 1 0)     // vertice 4
    (0 1 0)     // vertice 5
    (20 1 0)    // vertice 6
    (20 0.5 0)  // vertice 7
    (20 0 0)    // vertice 8
    (20 -1 0)   // vertice 9
    (8 -1 0)    // vertice 10
    
    (0 0 0.1)    // vertice 11
    (8 0 0.1)    // vertice 12
    (8 0.5 0.1)  // vertice 13
    (0 0.5 0.1)  // vertice 14
    (8 1 0.1)    // vertice 15
    (0 1 0.1)    // vertice 16
    (20 1 0.1)   // vertice 17
    (20 0.5 0.1) // vertice 18
    (20 0 0.1)   // vertice 19
    (20 -1 0.1)  // vertice 20
    (8 -1 0.1)   // vertice 21
    
);

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

edges
(
);

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

mergePatchPairs
(
);

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

Simillarly,

Edit the control dict folder

controlDict folder-

/*--------------------------------*- 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.5;

deltaT          0.00009;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


// ************************************************************************* //
  • The system provides the schemes to discretise the diffrential equation for finite volume control methods.
  • Change the directory to 0 folder and edite the pressure and velocity files where the initial and boundary conditions for them. thw modified for the pressure and velocity


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;
    }

    bottom
    {
        type            zeroGradient;
    }
    
    top
    {
        type           zeroGradient;
    }
    
    frontAndBack
    {
        type            empty;
    }
}

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

VELOCITY 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       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;
    }

    bottom
    {
        type            noSlip;
    }
    
    top
    {
        type            noSlip;
    }
    
    frontAndBack
    {
        type            empty;
    }
}

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

Now edit the transportProperties in constant folder as follows
transportProperties 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    "constant";
    object      transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

nu              [0 2 -1 0 0 0 0] 0.892e-6;


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

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)     // vertice 0
    (8 0 0)     // vertice 1
    (8 0.5 0)   // vertice 2
    (0 0.5 0)   // vertice 3
    (8 1 0)     // vertice 4
    (0 1 0)     // vertice 5
    (20 1 0)    // vertice 6
    (20 0.5 0)  // vertice 7
    (20 0 0)    // vertice 8
    (20 -1 0)   // vertice 9
    (8 -1 0)    // vertice 10
    
    (0 0 0.1)    // vertice 11
    (8 0 0.1)    // vertice 12
    (8 0.5 0.1)  // vertice 13
    (0 0.5 0.1)  // vertice 14
    (8 1 0.1)    // vertice 15
    (0 1 0.1)    // vertice 16
    (20 1 0.1)   // vertice 17
    (20 0.5 0.1) // vertice 18
    (20 0 0.1)   // vertice 19
    (20 -1 0.1)  // vertice 20
    (8 -1 0.1)   // vertice 21
    
);

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

edges
(
);

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

mergePatchPairs
(
);

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

Simillarly,

Edit the control dict folder

controlDict folder-

/*--------------------------------*- 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.5;

deltaT          0.00009;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


// ************************************************************************* //
  • AT dt=0.25 WITH GARDING 1 and GRADING 0.2
  • With grading 1 at dt=0.25

  • With grading 0.2 at dt=0.25

  • GRADE =1

https://youtu.be/D18QWHl3CE4

  • GRADE = 0.2

https://youtu.be/OgkWutdzYR8

  • FINAL TIME STEP (dt=0.5)
  • With grade 1 at final time step

  • With grading 0.2 at final time step

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.