Challenge

Week 8 - Simulation of a backward facing step in OpenFOAM

simulation of a Backward facing step problem in OpenFoam:

Simulation of an incompressible laminar viscous flow in a backward-facing step geometry

According to the problem statement, we must choose the solver type and here I have chosen icoFoam as a solver

Give the vertices according to the geometry considered and assing the mesh properties and grading factor

Here, the problem is solved according to the grading factor

Gradient Factor :

Gradient factor is needed for meshing of geometry because, mostly, the finer mesh will give the result at a very discrete point

if mesh would be very fine results would be more accurate at every cell.

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

vertices
(
    (0 0 0)
    (8 0 0)
    (8 0.5 0)
    (0 0.5 0)
    (8 1 0)
    (0 1 0)
    (20 1 0)
    (20 0.5 0)
    (20 0 0)
    (20 -1 0)
    (8 -1 0)
    
    (0 0 0.6)
    (8 0 0.6)
    (8 0.5 0.6)
    (0 0.5 0.6)
    (8 1 0.6 )
    (0 1 0.6)
    (20 1 0.6)
    (20 0.5 0.6)
    (20 0 0.6)
    (20 -1 0.6)
    (8 -1 0.6)
);

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

mergePatchPairs
(
);

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

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

deltaT 0.005;

writeControl timeStep;

writeInterval 10;

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: 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;
}

frontAndBack
{
type empty;
}
topandbottom
{
type zeroGradient;
}
}

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

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

outlet
{
type zeroGradient;

}

frontAndBack
{
type empty;
}
topandbottom
{
type noSlip;
}
}

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

With the gradient factor 0.2

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

vertices
(
(0 0 0)
(8 0 0)
(8 0.5 0)
(0 0.5 0)
(8 1 0)
(0 1 0)
(20 1 0)
(20 0.5 0)
(20 0 0)
(20 -1 0)
(8 -1 0)

(0 0 0.6)
(8 0 0.6)
(8 0.5 0.6)
(0 0.5 0.6)
(8 1 0.6 )
(0 1 0.6)
(20 1 0.6)
(20 0.5 0.6)
(20 0 0.6)
(20 -1 0.6)
(8 -1 0.6)
);

blocks
(
hex (0 1 2 3 11 12 13 14) (80 10 1) simpleGrading (0.2 5 1)

hex (3 2 4 5 14 13 15 16) (80 10 1) simpleGrading (0.2 0.2 1)

hex (2 7 6 4 13 18 17 15) (120 10 1) simpleGrading (5 0.2 1)

hex (1 8 7 2 12 19 18 13) (120 10 1) simpleGrading (5 5 1)

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

topandbottom
{
type wall;
faces
(
(4 5 16 15)
(4 15 17 6)
(0 1 12 11)
(9 20 21 10)
(1 10 21 12)

);
}

);

mergePatchPairs
(
);

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

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.