Challenge

Week 8 - Simulation of a backward facing step in OpenFOAM

The structure dimensions are as it is described in the task.

First, I divided the study area into five blocks which make it easy to draw the structure using blockMesh. The blocks corners will be numbed as the picture below.

the following code explains how this structure could be build in blockMesh

vertices
(
// Front Face
(0 0 0) //0
(0.08 0 0) //1
(0.08 0.005 0) //2
(0 0.005 0) //3
(0.08 0.01 0) //4
(0 0.01 0) //5
(0.2 0.01 0) //6
(0.2 0.005 0) //7
(0.2 0 0) //8
(0.2 -0.01 0) //9
(0.08 -0.01 0) //10

// Back Face
(0 0 0.001) //11
(0.08 0 0.001) //12
(0.08 0.005 0.001) //13
(0 0.005 0.001) //14
(0.08 0.01 0.001) //15
(0 0.01 0.001) //16
(0.2 0.01 0.001) //17
(0.2 0.005 0.001) //18
(0.2 0 0.001) //19
(0.2 -0.01 0.001) //20
(0.08 -0.01 0.001) //21
);

In theory the mesh should be finer in the where there is a big change in structure dimension or near the Inlet or Outlet. In other words where the user expect the gradient to be big

The number of nodes in the block and the scaling factor will be defined as following.

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)
);

the mesh looks like

when the scaling factor is one the bocks code will looks like

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)
);

the mesh then looks like

at the end I defined the inlet, outlet, walls and front and back

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

I used the “Pitzdaily” from simpleFoam example to build this task on it. I changed the blockMeshDict and controlDict files.

I changed the time end to 0.5 sand time step to 0.0005 in the controlDict.

the result for GF = 1 are as the following pictures for both U and P

the line plot of the U magnitude on 0.058 m distance from the inlet

the result for the second case with scaling factor 0.2 and 5 as following

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

vertices
(
    // Front Face
    (0 0 0)		//0
    (0.08 0 0)		//1
    (0.08 0.005 0)	//2
    (0 0.005 0)	        //3
    (0.08 0.01 0)	//4
    (0 0.01 0)		//5
    (0.2 0.01 0)	//6
    (0.2 0.005 0)	//7
    (0.2 0 0)		//8
    (0.2 -0.01 0)	//9
    (0.08 -0.01 0)	//10
    
    // Back Face   
    (0 0 0.001)		        //11
    (0.08 0 0.001)		//12
    (0.08 0.005 0.001)		//13
    (0 0.005 0.001)		//14
    (0.08 0.01 0.001)		//15
    (0 0.01 0.001)		//16
    (0.2 0.01 0.001)		//17
    (0.2 0.005 0.001)		//18
    (0.2 0 0.001)		//19
    (0.2 -0.01 0.001)		//20
    (0.08 -0.01 0.001)		//21
);

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

mergePatchPairs
(
);

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

startFrom       startTime;

startTime       0;

stopAt          endTime;

endTime         0.5;

deltaT          0.005;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;

cacheTemporaryObjects
(
    kEpsilon:G
);

functions
{
    #includeFunc streamlines
    #includeFunc writeObjects(kEpsilon:G)
}

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