Challenge

Week 8 - Simulation of a backward facing step in OpenFOAM

Objective: The aim is to simulate an incompressible laminar viscous flow through the backward facing step geometry.

Incompressible-Laminar-Viscous flow:

Incompressible flow:

Flow has a constant density i.e., doesn’t mean there is no change in density in the flow. Flow has a minimal change in density which is in neglectable range. Ex., Point 1 density value is 0.00012 & Point 2 density value is 0.000122.

Laminar flow:

Flow is in steady, linear & smooth manner and parallel to the surface. Flow has a less velocity at nearby surface due to the viscous whereas velocity in the flow at other points are higher.

In order to determine the laminar flow, fluid properties helps to find it which we called as Reynold’s number.

Reynold’s number is the ratio of the inertial force (ρ, u, L) to the viscous force (µ).

`Re = (ρ*u*L)/µ`

where,

ρ – Density of the fluid

u – Flow speed

L – Length of the geometry

µ - Dynamic viscosity

Grading factor:

The ratio of size of the end cell to size of the start cell is called grading factor.

This factor is essential because when mesh is fine, solution is more accurate and reduce the convergence time.

Steps for simulation:

  1. Initially, copy the cavity folder from the OpenFoam tutorials which is inside the incompressible folder, then in icoFoam folder by using the command “cp –r (folder name)/ $FOAM_RUN/(new folder name)” in the terminal window. To reach the tutorial folder from run folder just type the command “tut” in the terminal window. To see the list inside the folder type the command “ls”.
  2. Go to the run folder by typing “cd $FOAM_RUN” in the terminal window where we are going to run the simulation by copying the folder from the tutorials without change anything in it because that may lead to some collapse and we can’t recover it back. Only solution is re-installing OpenFoam.
  3. Inside the cavity folder, 0 folder has p & U text files. Constant folder has transport properties file. Finally, system folder has blockMeshDict, controlDict files. These are the required files to do the simulation by changing the things as per our problem required.
  4. Given geometry has 5 blocks with 21 vertices. To create the geometry, open the blockMeshDict file with the help of the command “gedit” and arrange the vertices as per right hand thumb rule. Then, assign the type for the inlet & outlet as patches. For front and back, assign empty. For no slip walls, assign as wall. Finally, save the file.
  5. Open the pressure & velocity file, where assign the inlet conditions for the pressure is zero gradient & for the velocity is fixed value. At outlet, it’s vice versa. For front and back, both type are empty. For no slip walls, pressure type is empty and velocity type is no slip. Finally, save the files.
  6. Open the transport properties file, where change the value of nu as 0.89e-6 to solve the solution for the laminar viscous flow which helps to obtain the courant number less than or equal to 0.5 till the simulation ends.
  7. Open the controlDict file to set the simulation timings, interval between each timings, time steps as per requirement.
  8. Command “./Allrun” in the terminal window to run the simulation. Now, go inside the folder & then type “paraFoam” to see the para view of the given geometry.
  9. Run the simulation in the para view, save screenshot of velocity and pressure with and without applying grading factor.
  10. By using plot over line, measure the velocity profile for both cases.

Code:

BlockmeshDict file code for without grading:

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

convertToMeters 0.001;

vertices
(
    (0 0 0)
    (80 0 0)
    (80 5 0)
    (0 5 0)
    (80 10 0)
    (0 10 0)
    (200 10 0)
    (200 5 0)
    (200 0 0)
    (200 -10 0)
    (80 -10 0)

    (0 0 5)
    (80 0 5)
    (80 5 5)
    (0 5 5)
    (80 10 5)
    (0 10 5)
    (200 10 5)
    (200 5 5)
    (200 0 5)
    (200 -10 5)
    (80 -10 5)
);

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 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)
        );
    }
    frontAndBack
    {
        type empty;
        faces
        (
            (0 3 2 1)
            (11 12 13 14)
            (3 5 4 2)
            (13 15 16 14)
            (2 4 6 7)
            (13 18 17 15)
            (1 2 7 8)
            (12 19 18 13)
            (10 1 8 9)
            (21 20 19 12)
        );
    }
    noSlipWalls
    {
        type wall;
        faces
        (
            (4 5 16 15)
            (4 15 17 6)            
            (0 1 12 11)
            (9 20 21 10)
            (1 10 21 12)
        );
    }
);

mergePatchPairs
(
);

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

BlockmeshDict file code for grading 0.2:

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

convertToMeters 0.001;

vertices
(
    (0 0 0)
    (80 0 0)
    (80 5 0)
    (0 5 0)
    (80 10 0)
    (0 10 0)
    (200 10 0)
    (200 5 0)
    (200 0 0)
    (200 -10 0)
    (80 -10 0)

    (0 0 5)
    (80 0 5)
    (80 5 5)
    (0 5 5)
    (80 10 5)
    (0 10 5)
    (200 10 5)
    (200 5 5)
    (200 0 5)
    (200 -10 5)
    (80 -10 5)
);

blocks
(
    hex (0 1 2 3 11 12 13 14) (80 5 1) simpleGrading (0.2 1 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 (1 0.2 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 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)
        );
    }
    frontAndBack
    {
        type empty;
        faces
        (
            (0 3 2 1)
            (11 12 13 14)
            (3 5 4 2)
            (13 15 16 14)
            (2 4 6 7)
            (13 18 17 15)
            (1 2 7 8)
            (12 19 18 13)
            (10 1 8 9)
            (21 20 19 12)
        );
    }
    noSlipWalls
    {
        type wall;
        faces
        (
            (4 5 16 15)
            (4 15 17 6)            
            (0 1 12 11)
            (9 20 21 10)
            (1 10 21 12)
        );
    }
);

mergePatchPairs
(
);

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

ControlDict file code:

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

application     icoFoam;

startFrom       startTime;

startTime       0;

stopAt          endTime;

endTime         0.5;

deltaT          0.0005;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

Pressure file code:

/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  9
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    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 file code:

/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  9
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    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            noSlip;
    }
}

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

Transport properties file code:

/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  9
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    format      ascii;
    class       dictionary;
    location    "constant";
    object      transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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


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

Results:

Without grading:

Mesh geometry:

Velocity flow:

Velocity profile at 0.085:

For grading factor 0.2:

Mesh geometry:

Velocity flow:

Velocity profile at 0.085:

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.