Challenge

Week 8 - Simulation of a backward facing step in OpenFOAM

Objective:
1. To simulate an incompressible laminar-viscous flow using Backward facing step geometry and to perform a transient simulation.
2. To compare the results for below mentioned cases
(i) Simulate the flow without using Grading factor
(ii) Simulate the flow with Grading factor = 0.2


Background study:
The given case study is to be solved in OpenFOAM. This application consists of predefined solvers to execute the problems. For our case, chosen solver is icoFOAM. Chosen solver is exclusively used for
solving the Navier-Stokes equation for the incompressible laminar flow problems.

Procedure:
1. Geometry creation: BlockMeshDict is the file which consists of information on Geometry. So based on the given geometry, appropriate vertices are given at each node in the BlockMeshDict
file and required geometry is created.

2. Mesh Creation: The given geometry is meshed using the same BlockMeshDict file.

Number of cells along the x direction (longer dimension) = 200
Number of cells along the longer y direction = 20
To capture the fluid properties at the boundary walls and interface regions, finer mesh should be used. This is communicated to the OpenFOAM using a term called Grading factor.

Grading factor – Size of n th cell / Size of 1 st cell
In our case, we need to use 1 and 0.2 as grading factor values and results to be compared.

3. Defining regions:
The given geometry is equally divided into 5 blocks as shown in the below image. We need to
assign the type of walls in the given geometry

In the same BlockMeshDict file, the different faces such as Inlet, Outlet, should be assigned with Boundary types. Based on the type of face, the simulation would be carried out. For example, In
this problem, the inlet and outlet are assigned as “Patch” type and walls are assigned as “Wall” type. If any face is not assigned with boundary type, OpenFOAM considers them as Empty faces.


4. Generating Mesh:
In the terminal window, BlockMesh command should be executed. This is to create mesh on the required geometry. Below image shows the mesh for BlockMesh geometry with grading factor=1 and 0.2.

   (i) Grading Factor = 1

    (ii) Grading Factor = 0.2

  
5. Boundary Conditions
At time t=0 Sec, the velocity and Pressure conditions are given as Initial conditions. Since the flow is Laminar, the Re should be less than 2000. So based on Re, Hydraulic diameter of the block and fluid viscosity, the required Inlet velocity is found. Outlet is considered as open to atmosphere (Pout gauge = 0). The computed Inlet velocity and Outlet pressure value should be updated in U , P file available inside Folder “0”. In the transportproperties files, the required viscosity value needs to be updated.


6. Finally, the required start time, end time and time step value (delta T) should be updated in the ControlDict file. Based on the CFL no, the timestep needs to be calculated.
Once the above steps are carried out, icoFoam Solver can be executed in the Linux terminal. After the simulation is done, the post-processing can be done using Paraview application.

Program:

1. BlockMesh file with Grading Factor = 1

/*--------------------------------*- 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) //vertex0
    (8 0 0) //vertex1
    (8 0.5 0) //vertex2
    (0 0.5 0) //vertex3
    (8 1 0)  //vertex4
    (0 1 0) //vertex5
    (20 1 0) //vertex6
    (20 0.5 0) //vertex7
    (20 0 0) //vertex8
    (20 -1 0) //vertex9
    (8 -1 0) //vertex10
    (0 0 1) //vertex11
    (8 0 1) //vertex12
    (8 0.5 1) //vertex13
    (0 0.5 1) //vertex14
    (8 1 1) //vertex15
    (0 1 1) //vertex16
    (20 1 1) //vertex17
    (20 0.5 1) //vertex18
    (20 0 1) //vertex19
    (20 -1 1) //vertex20
    (8 -1 1) //vertex21
);

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

mergePatchPairs
(
);

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

2. BlockMesh file with Grading factor = 0.2

/*--------------------------------*- 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) //vertex0
    (8 0 0) //vertex1
    (8 0.5 0) //vertex2
    (0 0.5 0) //vertex3
    (8 1 0)  //vertex4
    (0 1 0) //vertex5
    (20 1 0) //vertex6
    (20 0.5 0) //vertex7
    (20 0 0) //vertex8
    (20 -1 0) //vertex9
    (8 -1 0) //vertex10
    (0 0 1) //vertex11
    (8 0 1) //vertex12
    (8 0.5 1) //vertex13
    (0 0.5 1) //vertex14
    (8 1 1) //vertex15
    (0 1 1) //vertex16
    (20 1 1) //vertex17
    (20 0.5 1) //vertex18
    (20 0 1) //vertex19
    (20 -1 1) //vertex20
    (8 -1 1) //vertex21
);

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

mergePatchPairs
(
);

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

3. 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         20;

deltaT          1e-3;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

4. Velocity file (U)

/*--------------------------------*- 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 (0.2 0 0);
    }

    outlet
    {
        type            zeroGradient;
    }

    walls
    {
        type            noSlip;
    }
}

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

5. Pressure File (P)

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

    walls
    {
        type            zeroGradient;
    }
}

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

6. Transport properties 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] 1e-5;


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

Results:

1) Grading Factor = 1

Velocity Contour:

Pressure Contour:

Velocity Profile at 0.085m

2) Grading Factor = 0.2

Velocity Contour:

Pressure Contour:

Velocity Profile at 0.085m

Inference:

1. Changing grading factor from 1 to 0.2 makes the mesh more finer at interface and wall region which helps in obtaning accurate results.

2. But in this problem, the results between two grading factor does not change a lot. It remains almost same.

3. Velocity profile along the length of the nozzle (at 0.085m) is obtained as Parabolic. This proves the laminar flow behaviour as per Hagen-Poiseulle equation.

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.