Challenge

Week 12 - Symmetry vs Wedge vs HP equation

Symmetry vs Wedge Boundary Condition vs HP equation.

We have results of simulation from previous challenge for Hagen Poiseuille's equation from Analytical solution and Wedge boundary condition for 2,3and 4 degree wedge angles.

Here we will compare results for wedge angle of 10,25 and 45 degrees with Symmetry boundary condition.

First we will create Matlab code that can generate computational Mesh for any wedge angle same as in previous challenge.That code will be a blockMeshDict file which will be used in OpenFoam for creating Mesh.

Wedge boundary condition need to be replaced with symmetry boundary condition in blockMeshDict file,and in Pressure and velocity boundary file.

Matlab Code file:

clear all;
close all;
clc

D=0.02%Diameter of pipe in m
R=D/2 %Radius of pipe
theta=input('Enter the value of theta in degrees---'); %%wedge angle in degrees
L=3; %%Length of pipe in m

%Wedge dimension at 4 degrees
Point1=D/2*cosd(theta/2);
Point2=D/2*sind(theta/2);

%%File for writing blockMesh code
f2=fopen('blockMeshDict.txt','w')

%%Vertex and other parameters defined
Vertex_0=[0 0 0];
Vertex_1=[0 0 L];
Vertex_2=[Point1   -Point2      0];
Vertex_3=[Point1    Point2      0];
Vertex_4=[Point1   -Point2      L];
Vertex_5=[Point1    Point2      L];
Block=[0 2 3 0 1 4 5 1]
Cells=[50 1 300]
Grading=[0.1 1 1];
Inlet_face=[0 2 3 0];
Outlet_face=[1 4 5 1];
wall=[2 3 5 4];
wedge1=[0 1 4 2];
wedge2=[0 1 5 3];
axis=[0 1 1 0];

fprintf(f2,['/*------------------------------*- C++ -*----------------------------------',...
    '*\\',...
    '\n|   =========                   |                                           |',...
    '\n|  \\\\        /   F  ield        |  OpenFOAM:  TheOpen Source CFD Toolbox    |',...
    '\n|   \\\\      /    O  peration    |  Version:   plus                          |',...
    '\n|    \\\\    /     A  nd          |   Web:     www.OpenFOAM.com               |'...
    '\n|     \\\\  /      M  anipulation |                                           |',...
    '\n\\*-------------------------------------------------------------------------*/',...
    '\nFoamFile',...
    '\n{',...
    '\n     version     2.0;',...
    '\n     format      ascii;',...
    '\n     class       dictionary;',...
    '\n     object      blockMeshDict;',...
    '\n}',...
    '\n// ******************************************************************* //'])
fprintf(f2,'\n%s %.3f','convertToMeters', 1,';');

fprintf(f2,'\n')
fprintf(f2,'\nvertices');
fprintf(f2,'\n(');
fprintf(f2,'\n(');
fprintf(f2,'%12.6f',Vertex_0);
fprintf(f2,')');
fprintf(f2,'\n(');
fprintf(f2,'%12.6f',Vertex_1);
fprintf(f2,')');
fprintf(f2,'\n(');
fprintf(f2,'%12.6f',Vertex_2);
fprintf(f2,')');
fprintf(f2,'\n(');
fprintf(f2,'%12.6f',Vertex_3);
fprintf(f2,')');
fprintf(f2,'\n(');
fprintf(f2,'%12.6f',Vertex_4);
fprintf(f2,')');
fprintf(f2,'\n(');
fprintf(f2,'%12.6f',Vertex_5);
fprintf(f2,')');
fprintf(f2,'\n);');
fprintf(f2,'\n');
fprintf(f2,'\nblocks');
fprintf(f2,'\n(');
fprintf(f2,'\n');
fprintf(f2,'    hex (');
fprintf(f2,'%2.0f',Block);
fprintf(f2,') ');
fprintf(f2,'(');
fprintf(f2,'%4.0f',Cells);
fprintf(f2,') ');
fprintf(f2,'simpleGrading')
fprintf(f2,' (');
fprintf(f2,'%5.1f',Grading);
fprintf(f2,')');
fprintf(f2,'\n);');
fprintf(f2,'\n');
fprintf(f2,'\nedge')
fprintf(f2,'\n(')
fprintf(f2,'\n);')
fprintf(f2,'\n')
fprintf(f2,'\nboundary')
fprintf(f2,['\n(',...
    '\ninlet',...
    '\n{',...
   '\n type patch;',...
   '\n faces',...
   '\n(',...
   '\n('])

fprintf(f2,'%2.0f',Inlet_face)
fprintf(f2,[')',...
    '\n);',...
    '\n}',])
fprintf(f2,['\noutlet',...
    '\n{',...
   '\n type patch;',...
   '\n faces',...
   '\n(',...
   '\n('])
fprintf(f2,'%2.0f',Outlet_face)
fprintf(f2,[')',...
    '\n);',...
    '\n}',])

fprintf(f2,['\nwall',...
    '\n{',...
   '\n type wall;',...
   '\n faces',...
   '\n(',...
   '\n('])
fprintf(f2,'%2.0f',wall)
fprintf(f2,[')',...
    '\n);',...
    '\n}',])

fprintf(f2,['\nfront',...
    '\n{',...
   '\n type symmetry;',...
   '\n faces',...
   '\n(',...
   '\n('])
fprintf(f2,'%2.0f',wedge1)
fprintf(f2,[')',...
    '\n);',...
    '\n}',])

fprintf(f2,['\nback',...
    '\n{',...
   '\n type symmetry;',...
   '\n faces',...
   '\n(',...
   '\n('])
fprintf(f2,'%2.0f',wedge2)
fprintf(f2,[')',...
    '\n);',...
    '\n}',])

fprintf(f2,['\naxis',...
    '\n{',...
   '\n type empty;',...
   '\n faces',...
   '\n(',...
   '\n('])
fprintf(f2,'%2.0f',axis)
fprintf(f2,[')',...
    '\n);',...
    '\n}',])

fprintf(f2,'\n);')
fprintf(f2,'\nmergePatchPairs')
fprintf(f2,'\n(')
fprintf(f2,'\n);')

fprintf(f2,'\n// ********************************************************* //')



fclose(f2);  %%File close after writing

OpenFoam Case setup files:

BlockMeshDict:

/*------------------------------*- C++ -*----------------------------------*\
|   =========                   |                                           |
|  \\        /   F  ield        |  OpenFOAM:  TheOpen Source CFD Toolbox    |
|   \\      /    O  peration    |  Version:   plus                          |
|    \\    /     A  nd          |   Web:     www.OpenFOAM.com               |
|     \\  /      M  anipulation |                                           |
\*-------------------------------------------------------------------------*/
FoamFile
{
     version     2.0;
     format      ascii;
     class       dictionary;
     object      blockMeshDict;
}
// ******************************************************************* //
convertToMeters 1.000
; 

vertices
(
(    0.000000    0.000000    0.000000)
(    0.000000    0.000000    3.000000)
(    0.009763   -0.002164    0.000000)
(    0.009763    0.002164    0.000000)
(    0.009763   -0.002164    3.000000)
(    0.009763    0.002164    3.000000)
);

blocks
(
    hex ( 0 2 3 0 1 4 5 1) (  50   1 300) simpleGrading (  0.1  1.0  1.0)
);

edge
(
);

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

ControlDict file:

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

application     icoFoam;

startFrom       latestTime;

startTime       0;

stopAt          endTime;

endTime         30;

deltaT          5e-3;

writeControl    timeStep;

writeInterval   40;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

Pressure boundary condition file:

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

    front
    {
        type            symmetry;
    }

    back
    {
        type            symmetry;
    }

    axis
    {
        type		empty;
    }
}

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

Velocity Boundary condition file:

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

    front
    {
        
	type            symmetry;
        
    }
   
    back
    {
        
	type            symmetry;
        
    }
    axis
    {
        type            empty;
    }
}

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

Transport Properties file:

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



nu              [0 2 -1 0 0 0 0] 9e-07;


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

For `25^o` degree wedge angle:

At Hydrodynamic Entrance Length:

Simulation result for Velocity at Inlet

Simulation result for Velocity at Outlet:

For wedge angle `10^o`

For wedge angle `45^o`:

Outcomes:

1. A wedge boundary condition is used for axial and spherical symmetry ,but 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.

2.Though simulation using symmetry boundary condition take more time for execution than wedge boundary,but it gives less error and accurate results close to Analytical solution.

Wedge Angle Execution Time Max. Velocity obtained by simulation Max. Velocity (by Hagen Poiseuille equation)

Error

(in %)

10 5592 0.18455 0.186 0.78
25 5585 0.18472 0.186 0.69
45 5490 0.18509 0.186 0.49

3.From results above it can be figured out that with increase in wedge angle ,execution time decreases as well as results obtained are more accurate,less error.

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.