Challenge

Week 12 - Symmetry vs Wedge vs HP equation

Objective : Comparison of simulation results with symmetry and wedge boundary conditions.

Procedure: Previously we made the file parsing with wedge boundary condition

  • This is applicable when wedge angle is less than 5 degree. Now when we increase the angle above 5 degree then we have to use symmetry boundary condition.
  • For this we will use front and back faces as symmetry type.
  • The blockmesh dict file can be generated by using following code by inputing the angle.
clc
clear all
close all

%Input the following Data
theta=input('enter the value of the wedge angle thea=');
diameter=0.01;
radius=(diameter)/2;
length=1.2;
conv='convertToMeters';
b='blocks';
e='edges';
b1='boundary'
v='vertices';
m='mergePatchPairs'

x1=blanks(5);
x2=blanks(8);

%........................OpenFOAM................blockMeshDict.................

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

%...............................................................................................
h18='// ************************************************************************* //'
%......................Assigning Vertices.........................
v0=[0 0 0];
v1=[radius*sind(theta/2) radius*cosd(theta/2) 0];
v2=[-radius*sind(theta/2) radius*cosd(theta/2) 0];
v3=[0 0 length];
v4=[radius*sind(theta/2) radius*cosd(theta/2) length];
v5=[-radius*sind(theta/2) radius*cosd(theta/2) length];

block=' hex (0 0 1 2 3 3 4 5) (1 50 250) simpleGrading (1 0.2 1)';

edge1='arc 1 2';
edge2='arc 4 5';

e1=[0 radius 0];
e2=[0 radius length];

inflow='(0 1 2 0)';
outflow='(3 5 4 3)';
wedge1='(0 3 4 1)';
wedge2='(0 2 5 3)';
wall='(1 4 5 2)';
axis='(0 3 3 0)';

f2=fopen('blockMeshDict.C','w')
fprintf(f2,'%s   \n',h1);
fprintf(f2,'%s   \n',h2);
fprintf(f2,'%s   \n',h3);
fprintf(f2,'%s   \n',h4);
fprintf(f2,'%s   \n',h5);
fprintf(f2,'%s   \n',h6);
fprintf(f2,'%s   \n',h7);
fprintf(f2,'%s   \n',h8);
fprintf(f2,'%s   \n',h9);
fprintf(f2,'%s   \n',h10);
fprintf(f2,'%s   \n',h11);
fprintf(f2,'%s   \n',h12);
fprintf(f2,'%s   \n',h13);
fprintf(f2,'%s   \n',h14);
fprintf(f2,'%s   \n',h15);
fprintf(f2,'%s  %d  %s \n',conv,1,';');
fprintf(f2,'%s   \n',v);
fprintf(f2,'%s   \n','(');
fprintf(f2,'%s  (%6.7f %6.7f %6.7f)\n', x1,v0(1),v0(2),v0(3));
fprintf(f2,'%s  (%6.7f %6.7f %6.7f)\n', x1,v1(1),v1(2),v1(3));
fprintf(f2,'%s  (%6.7f %6.7f %6.7f)\n', x1,v2(1),v2(2),v2(3));
fprintf(f2,'%s  (%6.7f %6.7f %6.7f)\n', x1,v3(1),v3(2),v3(3));
fprintf(f2,'%s  (%6.7f %6.7f %6.7f)\n', x1,v4(1),v4(2),v4(3));
fprintf(f2,'%s  (%6.7f %6.7f %6.7f)\n', x1,v5(1),v5(2),v5(3));
fprintf(f2,'%s   \n',');');

fprintf(f2,'%s   \n',b);
fprintf(f2,'%s   \n','(');
fprintf(f2,'%s %s  \n',x1,block);
fprintf(f2,'%s   \n',');');

fprintf(f2,'%s   \n',e);
fprintf(f2,'%s   \n','(');
fprintf(f2,'%s %s (%6.7f %6.7f %6.7f)\n', x1,edge1,e1(1),e1(2),e1(3));
fprintf(f2,'%s %s (%6.7f %6.7f %6.7f)\n', x1,edge2,e2(1),e2(2),e2(3));
fprintf(f2,'%s   \n',');');

fprintf(f2,'%s   \n',b1);
fprintf(f2,'%s   \n','(');


fprintf(f2,'%s %s    \n',x1,'inlet');
fprintf(f2,'%s %s    \n',x1,'{');
fprintf(f2,'%s %s    \n',x2,'type patch;');
fprintf(f2,'%s %s    \n',x2,'faces');
fprintf(f2,'%s %s    \n',x2,'(');
fprintf(f2,'%s %s    \n',x2,inflow);
fprintf(f2,'%s %s    \n',x2,');');
fprintf(f2,'%s %s    \n',x1,'}');

fprintf(f2,'%s %s    \n',x1,'outlet');
fprintf(f2,'%s %s    \n',x1,'{');
fprintf(f2,'%s %s    \n',x2,'type patch;');
fprintf(f2,'%s %s    \n',x2,'faces');
fprintf(f2,'%s %s    \n',x2,'(');
fprintf(f2,'%s %s    \n',x2,outflow);
fprintf(f2,'%s %s    \n',x2,');');
fprintf(f2,'%s %s    \n',x1,'}');

fprintf(f2,'%s %s    \n',x1,'front');
fprintf(f2,'%s %s    \n',x1,'{');
fprintf(f2,'%s %s    \n',x2,'type symmetry;');
fprintf(f2,'%s %s    \n',x2,'faces');
fprintf(f2,'%s %s    \n',x2,'(');
fprintf(f2,'%s %s    \n',x2,wedge1);
fprintf(f2,'%s %s    \n',x2,');');
fprintf(f2,'%s %s    \n',x1,'}');

fprintf(f2,'%s %s    \n',x1,'back');
fprintf(f2,'%s %s    \n',x1,'{');
fprintf(f2,'%s %s    \n',x2,'type symmetry;');
fprintf(f2,'%s %s    \n',x2,'faces');
fprintf(f2,'%s %s    \n',x2,'(');
fprintf(f2,'%s %s    \n',x2,wedge2);
fprintf(f2,'%s %s    \n',x2,');');
fprintf(f2,'%s %s    \n',x1,'}');

fprintf(f2,'%s %s    \n',x1,'wall');
fprintf(f2,'%s %s    \n',x1,'{');
fprintf(f2,'%s %s    \n',x2,'type wall;');
fprintf(f2,'%s %s    \n',x2,'faces');
fprintf(f2,'%s %s    \n',x2,'(');
fprintf(f2,'%s %s    \n',x2,wall);
fprintf(f2,'%s %s    \n',x2,');');
fprintf(f2,'%s %s    \n',x1,'}');

fprintf(f2,'%s %s    \n',x1,'axis');
fprintf(f2,'%s %s    \n',x1,'{');
fprintf(f2,'%s %s    \n',x2,'type empty;');
fprintf(f2,'%s %s    \n',x2,'faces');
fprintf(f2,'%s %s    \n',x2,'(');
fprintf(f2,'%s %s    \n',x2,axis);
fprintf(f2,'%s %s    \n',x2,');');
fprintf(f2,'%s %s    \n',x1,'}');
fprintf(f2,'%s   \n',');');

fprintf(f2,'%s   \n',m);
fprintf(f2,'%s   \n','(');
fprintf(f2,'%s   \n',');');

fprintf(f2,'%s   \n',h18);

fclose(f2);
  • After running the we get following blockMesh dict file
/*––––––––––––––––––––––––––––––--*- C++ -*–––––––––––––––––––––––––––––––––-*\    
| =========                 |                                                      
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox                
|  \\    /   O peration     | Version:  4.0                                        
|   \\  /    A nd           | Web:      www.OpenFOAM.org                           
|    \\/     M anipulation  |                                                      
 \*–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––*/    
FoamFile   
{   
    version     2.0;   
    format      ascii;   
    class       dictionary;   
    object      blockMeshDict;   
}   
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //   
convertToMeters  1  ; 
vertices   
(   
       (0.0000000 0.0000000 0.0000000)
       (0.0004358 0.0049810 0.0000000)
       (-0.0004358 0.0049810 0.0000000)
       (0.0000000 0.0000000 1.2000000)
       (0.0004358 0.0049810 1.2000000)
       (-0.0004358 0.0049810 1.2000000)
);   
blocks   
(   
       hex (0 0 1 2 3 3 4 5) (1 50 250) simpleGrading (1 0.2 1)  
);   
edges   
(   
      arc 1 2 (0.0000000 0.0050000 0.0000000)
      arc 4 5 (0.0000000 0.0050000 1.2000000)
);   
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)    
         );    
      }    
      wall    
      {    
         type wall;    
         faces    
         (    
         (1 4 5 2)    
         );    
      }    
      axis    
      {    
         type empty;    
         faces    
         (    
         (0 3 3 0)    
         );    
      }    
);   
mergePatchPairs   
(   
);   
// ************************************************************************* //   
  • Change the velocity field no slip at wall and inlet to 0.1869m/s and front and back as symmetry.
/*--------------------------------*- 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.1869);
    }

    wall
    {
        type            noSlip;
        value           uniform (0 0 0);
    }

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

// ************************************************************************* //
  • Change the pressure field as follows with zero gradient with inlet.
/*--------------------------------*- 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.063874;
    }


    wall
    {
        type            zeroGradient;
    }

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

// ************************************************************************* //
  • Change the time step size and start and end time.
/*--------------------------------*- 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       startTime;

startTime       0;

stopAt          endTime;

endTime         10;

deltaT          0.005;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


// ************************************************************************* //
  • Velocity contours

  • Maximum velocity is observed in 45° case along the pipe centerline.

  • Maximum velocity is observed in 45° case along the pipe centerline parabolic velocity profile can be seen which is similar to analytical results.

  • Maximum shear stress is observed in 45° case along the pipe wall linear variation profile can be seen which is similar to analytical results.

Conclusion

  • As it is observed that wedge boundary condition is appropriate when wedge angle is less than 5°.
  • As angle is larger than 5 then we need to consider symmetry boundary condition.
  • Results for symmetry 45° shows good accuracy as compared with analytical results.
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.