Challenge

Week 8 - Simulation of a backward facing step in OpenFOAM

open terminal

open foam tutarioal using shortcut tut

open cavity file using below command

cd incompressible/icoFoam/cavity/

copy cavity file to run file with name of test_cavity using this command

cp -r cavity $FOAM_RUN/test_cavity

  • To create block/backward facing step geometry

first the copied file is saved in run

file to open that file the run file is opened using run shortcut

cd test_cavity/system/

gedit blockMeshDict

for grading factor 1

`gf=(size of end cell)/(size of initial cell)`

/--------------------------------- C++ -----------------------------------\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  10
     \\/     M anipulation  |
\---------------------------------------------------------------------------/
FoamFile
{
    format      ascii;
    class       dictionary;
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

convertToMeters 1;

vertices
(
   (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
   (0 0 0.1)//11
   (0.08 0 0.1)//12
   (0.08 0.005 0.1)//13
   (0 0.005 0.1)//14
   (0.08 0.01 0.1)//15
   (0 0.01 0.1)//16
   (0.2 0.01 0.1)//17
   (0.2 0.005 0.1)//18
   (0.2 0 0.1)//19
   (0.2 -0.01 0.1)//20
   (0.08 -0.01 0.1)//21
   
  
   
);

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

);

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

for grading factor 0.2

/--------------------------------- C++ -----------------------------------\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  10
     \\/     M anipulation  |
\---------------------------------------------------------------------------/
FoamFile
{
    format      ascii;
    class       dictionary;
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

convertToMeters 1;

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

);

// ************************* //
  • for controlDist

gedit controlDist

/--------------------------------- C++ -----------------------------------\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  10
     \\/     M anipulation  |
\---------------------------------------------------------------------------/
FoamFile
{
    format      ascii;
    class       dictionary;
    location    "system";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application     icoFoam;

startFrom       startTime;

startTime       0;

stopAt          endTime;

endTime         0.5;

deltaT          0.0002;

writeControl    runTime;

writeInterval   0.1;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


// ************************* //
  • Velocity field

cd ../0

gedit U

/--------------------------------- C++ -----------------------------------\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  10
     \\/     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);
    }
    outlet
    {
       type 		zeroGradient;
       
    }

    fixedWalls
    {
        type            noSlip;
    }

    frontAndBack
    {
        type            empty;
    }
}

// ************************* //
  • Pressure field

gedit p

/--------------------------------- C++ -----------------------------------\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  10
     \\/     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;
    }
}

// ************************* //
  • physical property

cd ../constant

gedit physicalProperties

/--------------------------------- C++ -----------------------------------\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  10
     \\/     M anipulation  |
\---------------------------------------------------------------------------/
FoamFile
{
    format      ascii;
    class       dictionary;
    location    "constant";
    object      physicalProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

nu              [0 2 -1 0 0 0 0] 0.01;


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

once the all the above parameter defined

blockMesh :- is used to mesh the block

checkMesh :- is used to check the mesh of the block

icoFoam :- this is solver used to solve the problem

paraFoam :- script that launches ParaView, by default using the reader module supplied with OpenFOAM

once the paraFoam is opened the field is selected

run program look velocity and presre behaviour on block

the velocity profile graph is ploted using plot over command at x 0.085

Results

Conclusion

from above two plot of velocity grading its seen that velocity profile look more smooth in without grading block then the with rading 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.