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.

OBJECTIVE:

  • Should perform a transient simulation.
  • In which, we should perform 2 case studies as described below and compare the results.
  • Mesh specification

    1. Number of cells along the x-direction (longer dimension) = 200
    2. Number of cells along the longer y-direction = 20;
  • Measure the velocity profile at 0.085 m from the inlet of the geometry for both case studies and compare. You can use the plot over line tool for this.
  • Explain why the Grading/Growth factor is essential for meshing. || as per the below figure

CODE AND EXPLANATION:

  • We start by opening the terminal for the code.
  • We start by opening the tutorials
  • We have to solve incompressible flow simulations so we select incompressible to directory.
  • In his particular solver, we need a solution for laminar-viscous flow. So here we choose ‘icoFoam’.
  • IcoFoam is the solver in OpenFOAM which is used as a transient solver for incompressible, laminar flow of Newtonian fluids.
  • The cavity section use to create a required domain and black mesh so select the ‘cavity’ folder.
  • Then we open the cavity folder in which we have to define our fluid domain and generate block mesh.
  • We are going to copy this cavity folder using the ‘cp -r cavity’ command and paste it in OpenFOAM run.
  • And on the run folder, where we can see the cavity_test file.
  • In this folder, we would be having the 4 script folder where we edit according to the given and required data.
  • Making the following changes in the blockMeshDict script file.
  • All aspects of the geometry are in the bellow file which we edit accordingly.
  • When we open this file, first, we are going to see header information in the form of a comment which is not executable.
  • Then, we will see the file identifier by which OpenFOAM reads to understand the type of file it's reading in this case it is ‘blockMeshDict’. it contain information in the dictionary format, means, key, and value format. As we can see, version is the key and ‘2.0’ is its value, that’s why it's called key-value pair. And here we don’t have to make any changes, so we keep it as it is.
  • The simpleGrading command is used to allow the grading to the mesh of the geometry. Each axis has its own grading factor, the grading factor is the ratio of the size of the cell at the end by the size of the cell at the start. The 3 grading factors (0.2, 0.5, 0.8) are allotted at each axis when a wall is present.
  • The boundaries are allotted by the vertices of the face. The boundaries are Inlet, outlet, top face, bottom face, sidestep, front and back face.

  • Once the blockMeshDict file is ready set the timestep, endtime and other properties in the controlDict file. The changes have to be made in the initial P and U file in the 0 folder as the labeling of the boundaries and requirements vary. Use the blockMesh command to get the polyMesh folder and then call the icoFoam command to run the simulation.
  • Once the simulation is completed call the paraFoam command to use ParaView and obtain the plots.
  • After running the animation, select the plot over the line command and plot the velocity over x=0.085 metres.

  • Repeat the procedure for grading factor 0.2.

---------------------------*\
  =========                 |
  \\      /  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 1000;

vertices
(
    (0 0 -0.5)
    (0.08 0 -0.5)
    (0.08 0.005 -0.5)
    (0 0.005 -0.5)
    (0.08 0.01 -0.5)
    (0 0.01 -0.5)
    (0.2 0.01 -0.5)
    (0.2 0.005 -0.5)
    (0.2 0 -0.5)
    (0.2 -0.01 -0.5)
    (0.08 -0.01 -0.5)

    (0 0 0.5)
    (0.08 0 0.5)
    (0.08 0.005 0.5)
    (0 0.005 0.5)
    (0.08 0.01 0.5)
    (0 0.01 0.5)
    (0.2 0.01 0.5)
    (0.2 0.005 0.5)
    (0.2 0 0.5)
    (0.2 -0.01 0.5)
    (0.08 -0.01 0.5)
);

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

edges
(
);

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

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

startTime       0;

stopAt          endTime;

endTime         10;

deltaT          1e-2;

writeControl    timeStep;

writeInterval   100;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;

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

    sidestep
    {
        type            zeroGradient;
    }
 
    frontAndBack
    {
        type            empty;
    }
}
/--------------------------------- 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;
    }

    top
    {
        type            noSlip;
    }

    bottom
    {
        type            noSlip;
    }

    sidestep
    {
        type            noSlip;
    }

    frontAndBack
    {
        type            empty;
    }
}
// ************************* //

These images show us the general check to whether the mesh is right or not.

RESULTS FROM THE PARAFOAM:

let us view the results in paraView by using the ‘paraFoam’ command:

Pressure Distribution along the domain area:-

Velocity Distribution along the domain area:-

Velocity Plot:-

THEN WE REPEAT THE PROCESS to grading factor 0.2:

So we have plotted the velocity plot for both, without grading factor and with 0.2 grading factor, cases. If we take a look at all the three-line graphs, we can see, the plot for velocity without grading factor seems more smooth and accurate than the other two plots. So one can say, grading can disrupt our result. But it is incorrect. Because, if we take a good look at it, we can notice, the mesh is fine at the step wall along the X-axis but very coarse along Y-axis. Therefore, we are not getting a smooth plot for velocity at 0.085 point at Y-axis

This shows us that a finer mesh captures the results more accurately.

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.