Challenge

Week 8 - Simulation of a backward facing step in OpenFOAM

openfoam is an open software and it does not have graphical user interface.its a command appproach.

Aim:to create backward facing step simulation using openfoam .

case1.simplegrading as 1

case2.simplegrading as2

simple grating or grading factor=ratio of length of end cell ,start cell .

no of cells along x axis=200

no of cells along y axis=20

To create a mesh ,we need to use terminal for inputing the conditions for mesh and to get its paraview using open foam solvers ,commands and meshing options.

algorithm to solve backward facing step.

open the terminal

↓

hit tut ,which opens the list of 'tutorials' the open foam has end code examples.

this include:basic,incompressible,compressible,laplacianFoam,simple foam.

↓ls

as per our case of incompressible,hit incompressible

↓ls

typing ls to know the sub files or directories is helpful

it contains solvers like pimpleFoam,icoFoam.......

↓ls

select icoFoam as the solver

for selecting a file use vim filename if it has directories use cd directory name.

↓ls

choose cavity directory from the list of available dc's.

**in open foam to make the interface understand what it need to solve for,we create the copy of the directories or files which we gonna reedefine.

to attain this,copy the cavity directory using

cp -r cavity/ $FOAM_RUN

at this instant we define our openfoam what it should be going to solve.

↓

hit 'run' command

↓

there appears another cavity directory containing system ,constant,0 directories.

first select system command and edit the blockmeshdict in it using gedit.to cofirm the boundary values,come back to cavity folder and hit blockMesh similarly for any changes in controlDiact is to be looked upon to get stable mesh.

↓

the initial conditions of p,U should be changed in 0 directory.

↓

to cross check,hit icoFoam in cavity folder locaation.

our values will be setted at each and every step

↓

to get the paraview of our geometry,hit paraFoam in cavity folder.then apply the necessary modifications as per the req output.

CASE2

Grating factor 0.2

defining geometry in blockMeshDict file

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

vertices
(
    (0 0 0)
    (0.8 0 0)
    (0.8 0.05 0)
    (0 0.05 0)
    (0.8 0.1 0)
    (0 0.1 0)
    (2 0.1 0)
    (2 0.05 0)
    (2 0 0)
    (2 -0.1 0)
    (0.8 -0.1 0)
    (0 0 0.01)
    (0.8 0 0.01)
    (0.8 0.05 0.01)
    (0 0.05 0.01)
    (0.8 0.1 0.01)
    (0 0.1 0.01)
    (2 0.1 0.01)
    (2 0.05 0.01)
    (2 0 0.01)
    (2 -0.1 0.01)
    (0.8 -0.1 0.01)
 );
blocks
(
    hex (0 1 2 3 11 12 13 14) (100 10 1) simpleGrading (0.2 0.2 0.2)
    hex (3 2 4 5 14 13 15 16) (100 10 1) simpleGrating (0.2 0.2 0.2)
    hex (2 7 6 4 13 18 17 15) (100 10 1) simpleGrading (0.2 0.2 0.2)
    hex (1 8 7 2 12 19 18 13) (100 10 1) simpleGrading (0.2 0.2 0.2)
    hex (10 9 8 1 21 20 19 12) (100 10 1) simpleGrading (0.2 0.2 0.2) 
);

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

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

controlDict

much changes over here only dt step to confirm cfl no staisfied

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

startTime       0;

stopAt          endTime;

endTime         0.5;

deltaT          0.00001;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

the others remain unchanged.

our initialpressure and velocity conditions

/*--------------------------------*- 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;
    }
    Noslipwall
    {
        type            zeroGradient
    }    

    frontAndBack
    {
        type            empty;
    }
}

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

initial velocity condition

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

    Noslipwall
    {
        type            noSlip;
    }
    frontAndBack
    {
        type           empty;
    }
}

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

only this changes fetchs us to our product.

similarly for case 1just the replacement is 1for 0.2 in simpleGrading blocks.

paraviews

this is how our geometry look like

the desired geometry

CASE1gradingfactor1

views

the velocity profile from the inlet atdistance 0.085meters

CASE2:gradingfactor 0.2

views:

simple meshing of the geometry.

s

velocity profile of the geomrtry.

obtaining the value of velocity at dist 0.085 meters from the inlet.

the shape of the arc is curved or part of downward parabola.

Need of meshing:

a smaller grading factor produces a more uniform mesh.

results:

1.velocity is found increasing from the inlet and then gradually changes.

2.there are more changes to velocity with more grading factor from the both plots.

3.overall on decreasing the velocity profile smoother beecause we increase the no of cells at the core of the flow where the majority of velocity changes takes place.

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.