Challenge

Week 8 - Simulation of a backward facing step in OpenFOAM

First this is to select the existing case from incompressible directory in OpenFoam. Following is the procedure:

(base) pankaj@pankaj-HP-Laptop-15-da1xxx:~$ tut
(base) pankaj@pankaj-HP-Laptop-15-da1xxx:/opt/openfoam9/tutorials$ ls
Allclean combustion electromagnetics lagrangian stressAnalysis
Allrun compressible financial mesh
Alltest discreteMethods heatTransfer multiphase
basic DNS incompressible resources
(base) pankaj@pankaj-HP-Laptop-15-da1xxx:/opt/openfoam9/tutorials$ cd incompressible/
(base) pankaj@pankaj-HP-Laptop-15-da1xxx:/opt/openfoam9/tutorials/incompressible$ ls
adjointShapeOptimisationFoam pimpleFoam simpleFoam
boundaryFoam pisoFoam SRFPimpleFoam
icoFoam porousSimpleFoam SRFSimpleFoam
nonNewtonianIcoFoam shallowWaterFoam
(base) pankaj@pankaj-HP-Laptop-15-da1xxx:/opt/openfoam9/tutorials/incompressible$ cd icoFoam/
(base) pankaj@pankaj-HP-Laptop-15-da1xxx:/opt/openfoam9/tutorials/incompressible/icoFoam$ ls
cavity elbow
(base) pankaj@pankaj-HP-Laptop-15-da1xxx:/opt/openfoam9/tutorials/incompressible/icoFoam$ 

Now copying cavity and pasting it in run folder:

cp -r cavity/ $FOAM_RUN/

now we move to run folder>>cavity>>system and change the geometry according to our problem.

(NOTE: The geometry has been divided into 3 blocks)

CASE-I: SIMPLE GRADING (1 1 1)

(BLOCKMESH)

/*--------------------------------*- 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 10 0)
    (0 10 0)
    (200 10 0)
    (200 0 0)
    (200 -10 0)
    (80 -10 0)
    (0 0 0.1)
    (80 0 0.1)
    (80 10 0.1)
    (0 10 0.1)
    (200 10 0.1)
    (200 0 0.1)
    (200 -10 0.1)
    (80 -10 0.1)

);

blocks
(
    hex (0 1 2 3 8 9 10 11) (80 20 1) simpleGrading (1 1 1)
    hex (1 5 4 2 9 13 12 10) (120 20 1) simpleGrading (1 1 1)
    hex (7 6 5 1 15 14 13 9) (120 20 1) simpleGrading (1 1 1)
);

edges
(
);

boundary
(
    Inlet
    {
        type patch;
        faces
        (
	    (0 8 11 3) 
        );
    }


    Exit
    {
        type patch;
        faces
        (
            (4 12 13 5)
            (5 13 14 6)
        );
    }
    
    fixedWalls
    {
        type wall;
        faces
        (
            (11 10 2 3)
            (10 12 4 2)
            (1 9 8 0)
            (7 15 9 1)
            (7 6 14 15)
            

        );
    }
    frontAndBack
    {
        type empty;
        faces
        (
            (0 3 2 1)
            (1 2 4 5)
            (1 5 6 7)
            (8 9 10 11)
            (9 13 12 10)
            (15 14 13 9)
        );
    }
);

mergePatchPairs
(
);

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

Then we set the controldict file for time step and stopping time.

For lamilar case (Re=10) we have obtained `\Delta t` as 0.0001. Also it has been observed that running simulation beyond 0.1 sec has not changed the flow condition any further so stopping time is set at 0.1 sec.

(CONTROLDICT)

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

deltaT          0.0001;

writeControl    timeStep;

writeInterval   1;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

As we have changed moving boundary to fixed and added patches for inlet and outlet the p and U files also has to be changed. inlet velocity is set to uniform and at exit it is set zerogradient.

Pressure at inlet is set as zerogradient and exit fixed value of 0.

(p)

/*--------------------------------*- 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;
    }
    
    Exit
    {
    	type            fixedValue;
    	value		uniform 0;
    	
    }

    fixedWalls
    {
        type            zeroGradient;
    }

    frontAndBack
    {
        type            empty;
    }
}

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

(U)

/*--------------------------------*- 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 (10 0 0);
    }
    
    Exit
    {
        type            zeroGradient;

    }
    

    fixedWalls
    {
        type            noSlip;
    }

    frontAndBack
    {
        type            empty;
    }
}

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

RESULTS FOR UNIFORM CASE

CASE-II (GRADED MESH)

(BLOCKMESH)

/*--------------------------------*- 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 10 0)
    (0 10 0)
    (200 10 0)
    (200 0 0)
    (200 -10 0)
    (80 -10 0)
    (0 0 0.1)
    (80 0 0.1)
    (80 10 0.1)
    (0 10 0.1)
    (200 10 0.1)
    (200 0 0.1)
    (200 -10 0.1)
    (80 -10 0.1)

);

blocks
(
    hex (0 1 2 3 8 9 10 11) (80 20 1) simpleGrading (0.2 5 1)
    hex (1 5 4 2 9 13 12 10) (120 20 1) simpleGrading (5 5 1)
    hex (7 6 5 1 15 14 13 9) (120 20 1) simpleGrading (5 5 1)
);

edges
(
);

boundary
(
    Inlet
    {
        type patch;
        faces
        (
	    (0 8 11 3) 
        );
    }


    Exit
    {
        type patch;
        faces
        (
            (4 12 13 5)
            (5 13 14 6)
        );
    }
    
    fixedWalls
    {
        type wall;
        faces
        (
            (11 10 2 3)
            (10 12 4 2)
            (1 9 8 0)
            (7 15 9 1)
            (7 6 14 15)
            

        );
    }
    frontAndBack
    {
        type empty;
        faces
        (
            (0 3 2 1)
            (1 2 4 5)
            (1 5 6 7)
            (8 9 10 11)
            (9 13 12 10)
            (15 14 13 9)
        );
    }
);

mergePatchPairs
(
);

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

For this case we have to set the value of `\Delta t` more less than previous case we have set it to 0.00001 in the control dict and rest of the things are same.

(CONTROLDICT)

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

deltaT          0.00001;

writeControl    timeStep;

writeInterval   1;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

(RESULTS)

One can see that by refining the grid near the wall the boundary phenomenons can be captured more presisely.

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.