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. To perform a transient simulation.Choose the inlet velocity such that the flow is laminar.

After that, perform 2 case studies 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;

DESCRIPTION:

INCOMPRESSIBLE FLOW:

The flow in which there is no change in the density is called incompressible flow.

LAMINAR FLOW:

A laminar flow is one where the fluid motion is regular and there is no mixing.The path lines in laminar flow does not intersect each other.At low velocities, the fluid tends to flow without mixing and adjacent layers slide past one another like playing cards.There are no cross-currents perpendicular to direction of flow, nor eddies or swirls of fluid.

Reynolds number is the parameter used to differentiate between laminar and turbulent flow.If Reynolds number <2000 then flow is laminar and if >2000 flow is considered as turbulent.

VISCOUS FLOW:

A type of fluid flow in which there is a continuous steady motion of particles, the motion at a fixed point always remains constant.Also called streamline flow,laminar flow,steady flow.

The fluid flow is in form of layer.The layer which sticks to the wall has zero velocity which is called no-slip condition and it develops the frictional effect on the wall..Frictional effects are also present between two layers of fluid and slower layer tries to slow down the faster layer which can be measured by using viscosity.

MESH GRADING

Mesh grading is the ration of size of the end cell to the size of the initial cell.

Grading factor = Size of end cell/Size of initial cell

PROCEDURE:

1.Open openFoam tutorials and find the solver to solver the incompressible laminar viscous flow .

2.Then to copy the required solver and paster it in the openFoam run folder so that the standard files of OpenFoam remain untouched to avoid malfunction.

3.Then find the block mesh script using the command and create a domain space and provide the mesh specifications.

4.Find the 'controlDict' file to edit the start and end time for simulation.

5.Then in the copied folder to open the '0' folder and change the paramters for pressure and velocity.

6.Then use the blockMesh command to generate mesh and checkMesh to check the mesh.

7.A polyMesh is created then.

8.Then run the 'ifoFoam' command to run the solver and then use the 'paraFoam' to run the simulation.

9.The mesh is created and change the view according to the requirements and use 'polyfit tool' to plot the velocity profile at 0.085m from inlet.

10.Repeat the same procedure for 0.2 grading factor and compare the velocity results.

COMMANDS USED:

1.'ls' to see the list of folders or files in the openFoam

2.'pwd' to check the sequence of folder we are in

3.'cd ..' to go one step back in folder

4.'cp -r' to copy the files to the created folder in run

5.'blockMesh' to check the mesh

6.'checkMesh' to check the mesh

7.'icoFoam' to run the solver used

8.'parFoam' to view in paraview and check the affects

SIMULATION FOR FLOW WITHOUT GRADING FACTOR i.e GF=1

FOR BLOCK MESH

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

mergePatchPairs
(
);

FOR TRANSPORT PROPERTIES

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


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

FOR CONTROL DICTIONARY

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

deltaT          1e-4;

writeControl    runTime;

writeInterval   0.5;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

FOR PRESSURE PARAMETERS

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

    fixedwalls
    {
        type            zeroGradient;
    }
    frontAndBack
    {
    type empty;
}

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

FOR VELOCITY PARAMTERS

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

boundaryField
{
    outlet
    {
        type            zeroGradient;
    }

    Inlet
    {
        type            fixedValue;
        value uniform (0.5 0 0);
    }

    fixedwalls
    {
        type            noSlip;
    }
    frontAndBack
    {
    type empty;
}

}

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

SIMULATION FOR FLOW WITHGRADING FACTOR i.e GF=0.2 AT FIXED WALLS

FOR BLOCK MESH

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

mergePatchPairs
(
);

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

FOR TRANSPORT DICTIONARY

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


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

FOR CONTROL DICTIONARY

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

deltaT          1e-4;

writeControl    runTime;

writeInterval   0.5;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

FOR PRESSURE PARAMETERS

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

    fixedwalls
    {
        type            zeroGradient;
    }
    frontAndBack
    {
    type empty;
}

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

FOR VELOCITY PARAMETERS

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

boundaryField
{
    outlet
    {
        type            zeroGradient;
    }

    Inlet
    {
        type            fixedValue;
        value uniform (0.5 0 0);
    }

    fixedwalls
    {
        type            noSlip;
    }
    frontAndBack
    {
    type empty;
}

}

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

RESULTS:

WITHOUT GRADING FACTOR

The block mesh looks as below with GF=1

The velocity flow looks as follows

The plot for velocity at y-axis 0.085m without GF is as follows

WITH GRADING FACTOR 0.2 AT FIXED WALLS

The block mesh with GF=0.2 is as below

The velocity flow diagram is as follows

The velocity at 0.085m is as follows

CONCLUSION:

There is a sharp point in velocity plot for GF=0.2 compared to GF=1 seems more smooth and accurate than GF=0.2.But its not accurate.Because, if we look at the mesh is fine at step wall along x-axis and very coarse along y-axis, so we are not getting the smooth plot for GF=0.2.

By changing the grading factor from 1 to 0.2 the mesh becomes finer and the solution becomes accurate.

Overall with change in grading factor there are minor fluctuations in velocity graph compared to with no grading factor.

The execution time is lower for lower mesh grading factor.

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.