Challenge

Week 12 - Validation studies of Symmetry BC vs Wedge BC in OpenFOAM vs Analytical H.P equation

Aim:- Validation studies of symmetry boundary Condition vs Wedge boundary condition vs Analytical H.P equation

Objective:-

  1. Validate Hydro-dynamic length with the numerical result
  2. Validate the fully developed flow velocity profile with its analytical profile
  3. Validate maximum velocity and pressured drop for fully developed flow
  4. Post-process Shear stress and validate wall shear stress for fully developed flow
  5. Highlight the differences in both boundary conditions in terms of their usage and application

Angles to test:-

10 degrees

25 degrees

45 degrees

Theory:-

Wedge Boundary Condition

The Wedge Boundary Condition is used in CFD to define an axisymmetric situation, for eg. Cylinder. The model and flow must be axisymmetric along a central line such that all physical variables of the flow have the same value and distribution at a given radius for all angles.

This boundary condition is specified by two planes that must be selected on separate sides of the domain on surface running along the axis.

Symmetric Boundary Condition

The symmetry boundary condition defines a mirror face/surface. It should only be used if the physical object or geometry and the expected flow field pattern of the developed solution are mirrored along that surface. By using this boundary condition, the domain can essentially be halved, reducing the time to achieve a solution

In detail, the symmetry condition applies the following constraints on the flow variables.

  1. The fluxes across the symmetry are zero
  2. The normal components of all variables are set to zero

It can be applied to both planar or non-planar faces/surfaces on the domain boundaries

Matlab program for wedge boundary condition

D = 0.02
R_e = 2100
rho = 1000
mu = 0.00089
nu = mu/rho

A_c = (pi/4)*D^2  %Cross sectional area of pipe
p = pi*D  %wetted perimeter
D_h = 4*A_c/p  %Hydraulic diameter of pipe
r_h = D_h/2  %Hydraulic radius of pipe

if R_e < 2300
    L_e = 0.06*R_e*D_h
elseif R_e == 2300
    L_e = 115*D_h
elseif R_e > 4000
    L_e = 1.359*D_h*R_e^(1/4)
end


L = L_e + 0.18
R = r_h

theta = input('Enter the wedge angle = ')

v0 = [0 0 0]
v1 = [0 R*cosd(theta/2) R*sind(theta/2)]
v2 = [0 R*cosd(theta/2) -R*sind(theta/2)]
v3 = [L 0 0]
v4 = [L R*cosd(theta/2) R*sind(theta/2)]
v5 = [L R*cosd(theta/2) -R*sind(theta/2)]

h1='/*--------------------------------*- C++ -*----------------------------------*\'
h2='  =========                 |'
h3='  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox'
h4='   \\    /   O peration     | Website:  https://openfoam.org'
h5='    \\  /    A nd           | Version:  9'
h6='     \\/     M anipulation  |'
h7='\*---------------------------------------------------------------------------*/'
h8='FoamFile'
h9='{'
h10='    format      ascii;'
h11='    class       dictionary;'
h12='    object      blockMeshDict;'
h13='}'
h14='// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //'
h15='convertToMeters 1;'

f1 = fopen('blockMeshDict.txt','wt')

fprintf(f1,'%s\n',h1)
fprintf(f1,'%s\n',h2)
fprintf(f1,'%s\n',h3)
fprintf(f1,'%s\n',h4)
fprintf(f1,'%s\n',h5)
fprintf(f1,'%s\n',h6)
fprintf(f1,'%s\n',h7)
fprintf(f1,'%s\n',h8)
fprintf(f1,'%s\n',h9)
fprintf(f1,'%s\n',h10)
fprintf(f1,'%s\n',h11)
fprintf(f1,'%s\n',h12)
fprintf(f1,'%s\n',h13)
fprintf(f1,'%s\n',h14)

fprintf(f1,'\n%s\n',h15)

fprintf(f1,'\n%s\n','vertices')
fprintf(f1,'%s\n','(')

fprintf(f1,'%s (%d %d %d)\n',blanks(3),(v0))
fprintf(f1,'%s (%d %d %d)\n',blanks(3),(v1))
fprintf(f1,'%s (%d %d %d)\n',blanks(3),(v2))
fprintf(f1,'%s (%d %d %d)\n',blanks(3),(v3))
fprintf(f1,'%s (%d %d %d)\n',blanks(3),(v4))
fprintf(f1,'%s (%d %d %d)\n',blanks(3),(v5))

fprintf(f1,'%s\n',');')

fprintf(f1,'\n%s\n','blocks')
fprintf(f1,'%s\n','(')
fprintf(f1,'%s %s\n',blanks(3),'hex (0 3 5 2 0 3 4 1) (200 50 1) simpleGrading (1 1 1)')
fprintf(f1,'%s\n',');')

fprintf(f1,'\n%s\n','edges')
fprintf(f1,'%s\n','(')
fprintf(f1,'%s arc 2 1 (%d %d %d)\n',blanks(3),0,R,0)
fprintf(f1,'%s arc 5 4 (%d %d %d)\n',blanks(3),L,R,0)
fprintf(f1,'%s\n',');')

fprintf(f1,'\n%s\n','boundary')
fprintf(f1,'%s\n','(')
fprintf(f1,'%s %s\n',blanks(3),'inlet')
fprintf(f1,'%s %s\n',blanks(3),'{')
fprintf(f1,'%s %s\n',blanks(7),'type patch;')
fprintf(f1,'%s %s\n',blanks(7),'faces')
fprintf(f1,'%s %s\n',blanks(7),'(')
fprintf(f1,'%s (%d %d %d %d)\n',blanks(11),0,1,2,0)
fprintf(f1,'%s %s\n',blanks(7),');')
fprintf(f1,'%s %s\n',blanks(3),'}')


fprintf(f1,'%s %s\n',blanks(3),'outlet')
fprintf(f1,'%s %s\n',blanks(3),'{')
fprintf(f1,'%s %s\n',blanks(7),'type patch;')
fprintf(f1,'%s %s\n',blanks(7),'faces')
fprintf(f1,'%s %s\n',blanks(7),'(')
fprintf(f1,'%s (%d %d %d %d)\n',blanks(11),3,5,4,3)
fprintf(f1,'%s %s\n',blanks(7),');')
fprintf(f1,'%s %s\n',blanks(3),'}')

fprintf(f1,'%s %s\n',blanks(3),'front')
fprintf(f1,'%s %s\n',blanks(3),'{')
fprintf(f1,'%s %s\n',blanks(7),'type wedge;')
fprintf(f1,'%s %s\n',blanks(7),'faces')
fprintf(f1,'%s %s\n',blanks(7),'(')
fprintf(f1,'%s (%d %d %d %d)\n',blanks(11),0,3,4,1)
fprintf(f1,'%s %s\n',blanks(7),');')
fprintf(f1,'%s %s\n',blanks(3),'}')

fprintf(f1,'%s %s\n',blanks(3),'back')
fprintf(f1,'%s %s\n',blanks(3),'{')
fprintf(f1,'%s %s\n',blanks(7),'type wedge;')
fprintf(f1,'%s %s\n',blanks(7),'faces')
fprintf(f1,'%s %s\n',blanks(7),'(')
fprintf(f1,'%s (%d %d %d %d)\n',blanks(11),0,2,5,3)
fprintf(f1,'%s %s\n',blanks(7),');')
fprintf(f1,'%s %s\n',blanks(3),'}')

fprintf(f1,'%s %s\n',blanks(3),'pipe')
fprintf(f1,'%s %s\n',blanks(3),'{')
fprintf(f1,'%s %s\n',blanks(7),'type wall;')
fprintf(f1,'%s %s\n',blanks(7),'faces')
fprintf(f1,'%s %s\n',blanks(7),'(')
fprintf(f1,'%s (%d %d %d %d)\n',blanks(11),1,4,5,2)
fprintf(f1,'%s %s\n',blanks(7),');')
fprintf(f1,'%s %s\n',blanks(3),'}')

fprintf(f1,'%s %s\n',blanks(3),'axis')
fprintf(f1,'%s %s\n',blanks(3),'{')
fprintf(f1,'%s %s\n',blanks(7),'type empty;')
fprintf(f1,'%s %s\n',blanks(7),'faces')
fprintf(f1,'%s %s\n',blanks(7),'(')
fprintf(f1,'%s (%d %d %d %d)\n',blanks(11),0,3,3,0)
fprintf(f1,'%s %s\n',blanks(7),');')
fprintf(f1,'%s %s\n',blanks(3),'}')

fprintf(f1,'%s\n',');')
fprintf(f1,'\n%s\n','mergePatchPairs')
fprintf(f1,'%s\n','(')
fprintf(f1,'%s\n',');')
fprintf(f1,'%s\n','// ***********')

fclose(f1)

Matlab program for symmetry boundary condition

D = 0.02
R_e = 2100
rho = 1000
mu = 0.00089
nu = mu/rho

A_c = (pi/4)*D^2  %Cross sectional area of pipe
p = pi*D  %wetted perimeter
D_h = 4*A_c/p  %Hydraulic diameter of pipe
r_h = D_h/2  %Hydraulic radius of pipe

if R_e < 2300
    L_e = 0.06*R_e*D_h
elseif R_e == 2300
    L_e = 115*D_h
elseif R_e > 4000
    L_e = 1.359*D_h*R_e^(1/4)
end


L = L_e + 0.18
R = r_h

theta = input('Enter the wedge angle = ')

v0 = [0 0 0]
v1 = [0 R*cosd(theta/2) R*sind(theta/2)]
v2 = [0 R*cosd(theta/2) -R*sind(theta/2)]
v3 = [L 0 0]
v4 = [L R*cosd(theta/2) R*sind(theta/2)]
v5 = [L R*cosd(theta/2) -R*sind(theta/2)]

h1='/*--------------------------------*- C++ -*----------------------------------*\'
h2='  =========                 |'
h3='  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox'
h4='   \\    /   O peration     | Website:  https://openfoam.org'
h5='    \\  /    A nd           | Version:  9'
h6='     \\/     M anipulation  |'
h7='\*---------------------------------------------------------------------------*/'
h8='FoamFile'
h9='{'
h10='    format      ascii;'
h11='    class       dictionary;'
h12='    object      blockMeshDict;'
h13='}'
h14='// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //'
h15='convertToMeters 1;'

f1 = fopen('blockMeshDict.txt','wt')

fprintf(f1,'%s\n',h1)
fprintf(f1,'%s\n',h2)
fprintf(f1,'%s\n',h3)
fprintf(f1,'%s\n',h4)
fprintf(f1,'%s\n',h5)
fprintf(f1,'%s\n',h6)
fprintf(f1,'%s\n',h7)
fprintf(f1,'%s\n',h8)
fprintf(f1,'%s\n',h9)
fprintf(f1,'%s\n',h10)
fprintf(f1,'%s\n',h11)
fprintf(f1,'%s\n',h12)
fprintf(f1,'%s\n',h13)
fprintf(f1,'%s\n',h14)

fprintf(f1,'\n%s\n',h15)

fprintf(f1,'\n%s\n','vertices')
fprintf(f1,'%s\n','(')

fprintf(f1,'%s (%d %d %d)\n',blanks(3),(v0))
fprintf(f1,'%s (%d %d %d)\n',blanks(3),(v1))
fprintf(f1,'%s (%d %d %d)\n',blanks(3),(v2))
fprintf(f1,'%s (%d %d %d)\n',blanks(3),(v3))
fprintf(f1,'%s (%d %d %d)\n',blanks(3),(v4))
fprintf(f1,'%s (%d %d %d)\n',blanks(3),(v5))

fprintf(f1,'%s\n',');')

fprintf(f1,'\n%s\n','blocks')
fprintf(f1,'%s\n','(')
fprintf(f1,'%s %s\n',blanks(3),'hex (0 3 5 2 0 3 4 1) (200 50 1) simpleGrading (1 1 1)')
fprintf(f1,'%s\n',');')

fprintf(f1,'\n%s\n','edges')
fprintf(f1,'%s\n','(')
fprintf(f1,'%s arc 2 1 (%d %d %d)\n',blanks(3),0,R,0)
fprintf(f1,'%s arc 5 4 (%d %d %d)\n',blanks(3),L,R,0)
fprintf(f1,'%s\n',');')

fprintf(f1,'\n%s\n','boundary')
fprintf(f1,'%s\n','(')
fprintf(f1,'%s %s\n',blanks(3),'inlet')
fprintf(f1,'%s %s\n',blanks(3),'{')
fprintf(f1,'%s %s\n',blanks(7),'type patch;')
fprintf(f1,'%s %s\n',blanks(7),'faces')
fprintf(f1,'%s %s\n',blanks(7),'(')
fprintf(f1,'%s (%d %d %d %d)\n',blanks(11),0,1,2,0)
fprintf(f1,'%s %s\n',blanks(7),');')
fprintf(f1,'%s %s\n',blanks(3),'}')


fprintf(f1,'%s %s\n',blanks(3),'outlet')
fprintf(f1,'%s %s\n',blanks(3),'{')
fprintf(f1,'%s %s\n',blanks(7),'type patch;')
fprintf(f1,'%s %s\n',blanks(7),'faces')
fprintf(f1,'%s %s\n',blanks(7),'(')
fprintf(f1,'%s (%d %d %d %d)\n',blanks(11),3,5,4,3)
fprintf(f1,'%s %s\n',blanks(7),');')
fprintf(f1,'%s %s\n',blanks(3),'}')

fprintf(f1,'%s %s\n',blanks(3),'front')
fprintf(f1,'%s %s\n',blanks(3),'{')
fprintf(f1,'%s %s\n',blanks(7),'type symmetry;')
fprintf(f1,'%s %s\n',blanks(7),'faces')
fprintf(f1,'%s %s\n',blanks(7),'(')
fprintf(f1,'%s (%d %d %d %d)\n',blanks(11),0,3,4,1)
fprintf(f1,'%s %s\n',blanks(7),');')
fprintf(f1,'%s %s\n',blanks(3),'}')

fprintf(f1,'%s %s\n',blanks(3),'back')
fprintf(f1,'%s %s\n',blanks(3),'{')
fprintf(f1,'%s %s\n',blanks(7),'type symmetry;')
fprintf(f1,'%s %s\n',blanks(7),'faces')
fprintf(f1,'%s %s\n',blanks(7),'(')
fprintf(f1,'%s (%d %d %d %d)\n',blanks(11),0,2,5,3)
fprintf(f1,'%s %s\n',blanks(7),');')
fprintf(f1,'%s %s\n',blanks(3),'}')

fprintf(f1,'%s %s\n',blanks(3),'pipe')
fprintf(f1,'%s %s\n',blanks(3),'{')
fprintf(f1,'%s %s\n',blanks(7),'type wall;')
fprintf(f1,'%s %s\n',blanks(7),'faces')
fprintf(f1,'%s %s\n',blanks(7),'(')
fprintf(f1,'%s (%d %d %d %d)\n',blanks(11),1,4,5,2)
fprintf(f1,'%s %s\n',blanks(7),');')
fprintf(f1,'%s %s\n',blanks(3),'}')

fprintf(f1,'%s %s\n',blanks(3),'axis')
fprintf(f1,'%s %s\n',blanks(3),'{')
fprintf(f1,'%s %s\n',blanks(7),'type empty;')
fprintf(f1,'%s %s\n',blanks(7),'faces')
fprintf(f1,'%s %s\n',blanks(7),'(')
fprintf(f1,'%s (%d %d %d %d)\n',blanks(11),0,3,3,0)
fprintf(f1,'%s %s\n',blanks(7),');')
fprintf(f1,'%s %s\n',blanks(3),'}')

fprintf(f1,'%s\n',');')
fprintf(f1,'\n%s\n','mergePatchPairs')
fprintf(f1,'%s\n','(')
fprintf(f1,'%s\n',');')
fprintf(f1,'%s\n','// ***********')

fclose(f1)

OpenFoam

‘blockMeshDict’ file for Wedge BC

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

vertices
(
    (0 0 0)
    (0 9.238795e-03 3.826834e-03)
    (0 9.238795e-03 -3.826834e-03)
    (2.700000e+00 0 0)
    (2.700000e+00 9.238795e-03 3.826834e-03)
    (2.700000e+00 9.238795e-03 -3.826834e-03)
);

blocks
(
    hex (0 3 5 2 0 3 4 1) (200 50 1) simpleGrading (1 1 1)
);

edges
(
    arc 2 1 (0 1.000000e-02 0)
    arc 5 4 (2.700000e+00 1.000000e-02 0)
);

boundary
(
    inlet
    {
        type patch;
        faces
        (
            (0 1 2 0)
        );
    }
    outlet
    {
        type patch;
        faces
        (
            (3 5 4 3)
        );
    }
    front
    {
        type wedge;
        faces
        (
            (0 3 4 1)
        );
    }
    back
    {
        type wedge;
        faces
        (
            (0 2 5 3)
        );
    }
    pipe
    {
        type wall;
        faces
        (
            (1 4 5 2)
        );
    }
    axis
    {
        type empty;
        faces
        (
            (0 3 3 0)
        );
    }
);

mergePatchPairs
(
);
// ***********

‘blockMeshDict’ file for Symmetry BC

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

vertices
(
    (0 0 0)
    (0 9.238795e-03 3.826834e-03)
    (0 9.238795e-03 -3.826834e-03)
    (2.700000e+00 0 0)
    (2.700000e+00 9.238795e-03 3.826834e-03)
    (2.700000e+00 9.238795e-03 -3.826834e-03)
);

blocks
(
    hex (0 3 5 2 0 3 4 1) (200 50 1) simpleGrading (1 1 1)
);

edges
(
    arc 2 1 (0 1.000000e-02 0)
    arc 5 4 (2.700000e+00 1.000000e-02 0)
);

boundary
(
    inlet
    {
        type patch;
        faces
        (
            (0 1 2 0)
        );
    }
    outlet
    {
        type patch;
        faces
        (
            (3 5 4 3)
        );
    }
    front
    {
        type symmetry;
        faces
        (
            (0 3 4 1)
        );
    }
    back
    {
        type symmetry;
        faces
        (
            (0 2 5 3)
        );
    }
    pipe
    {
        type wall;
        faces
        (
            (1 4 5 2)
        );
    }
    axis
    {
        type empty;
        faces
        (
            (0 3 3 0)
        );
    }
);

mergePatchPairs
(
);
// ***********

‘ControlDict’ file

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

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

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;
    }
    outlet
    {
        type            fixedValue;
        value		 uniform 0;
    }
    pipe
    {
        type            zeroGradient;
    }
    axis
    {
        type            empty;
    }
    front
    {
        type            symmetry;
    }
    back
    {
        type            symmetry;
    }
}

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

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 (1 0 0);
    }
    outlet
    {
        type            zeroGradient;

    }
    pipe
    {
        type            noSlip;
        value           uniform 0;
    }
    axis
    {
        type            empty;
    }
    front
    {
        type            symmetry;
    }
    back
    {
        type            symmetry;
    }
}

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

Result:-

Meshed model

`10^o`

`25^o`

`45^o`

Comparison between Wedge and Symmetry BC

`10^o`

Velocity plot

Wedge BC

Symmetry BC

Shear-Stress plot

Wegde BC

Symmetry BC

`25^o`

Velocity plot

Wedge BC

Symmetry BC

Shear-Stress plot

Wedge BC

Symmetry BC

`45^o`

Velocity plot

Wedge BC

Symmetry BC

Shear-Stress plot

Wedge BC

Symmetry BC

Conclusion:-

From the above plots it can be said that by increasing the wedge angle, the accuracy of the numerical solution decreases and error with respect to analytical solution increases.

Error between the numerical solution of wedge and symmetry boundary conditions is very less or simply more or less both are giving same numerical solutions

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.