Challenge

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

Objective:-

Using MATLAB to generate mesh automatically for varying wedge angles and also using symmetric scheme to obtain the result

Hagen poiseuuli's Equation:

`DeltaP=(32muLv)/d^2`

where, `DeltaP`is the pressure drop along a pipe in which incompressible Newtonian fluid is flowing

Constants Taken:

  • Geometry=Axi-symmetric
  • Re=2100
  • density=997 kg/m^3
  • Temperature=`25^0 C`
  • Dia of Pipe= 0.02m
  • Dynamic Viscosity = 0.089e-3 Pa.s
  • Kinematic Viscosity= 0.8927e-6 m^2/s
  • theta= `10^0,25^0,45^0`

MATLAB code for Generating blockMeshDict file with varying angles:-

close all
clc

theta=10;
Re=2100;
D=0.02;
L=0.06*Re*D;
R=D/2;
mu=0.89e-3;
rho=997.0;
nu=mu/rho;

v_avg=Re*mu/(D*rho);
v_max=2*v_avg;
del_p=(32*mu*v_avg*L)/(D^2);
kin_P=del_p/rho;

n1=50;
n2=1;
n3=300;
gfactor=0.5;

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*cosd(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='//***************************************************************************//';
f1=fopen('blockMeshDict.txt','w');

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');

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

fprintf(f1,'%s \n','vertices');
fprintf(f1,'%s \n','(');
fprintf(f1,'\t %s (%f %f %f) \n', blanks(5),v0(1),v0(2),v0(3));
fprintf(f1,'\t %s (%f %f %f) \n', blanks(5),v1(1),v1(2),v1(3));
fprintf(f1,'\t %s (%f %f %f) \n', blanks(5),v2(1),v2(2),v2(3));
fprintf(f1,'\t %s (%f %f %f) \n', blanks(5),v3(1),v3(2),v3(3));
fprintf(f1,'\t %s (%f %f %f) \n', blanks(5),v4(1),v4(2),v4(3));
fprintf(f1,'\t %s (%f %f %f) \n', blanks(5),v5(1),v5(2),v5(3));
fprintf(f1,'%s \n',');');
fprintf(f1,'\n');

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

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

fprintf(f1,'%s \n','boundary');
fprintf(f1,'%s \n','(');
fprintf(f1,'%s %s \n',blanks(5),'inlet');
fprintf(f1,'%s %s \n',blanks(5),'{');
fprintf(f1,'%s %s \n',blanks(10),'type patch');
fprintf(f1,'%s %s \n',blanks(10),'faces');
fprintf(f1,'%s %s \n',blanks(10),'(');
fprintf(f1,'%s %s \n',blanks(15),'(0 1 2 0)');
fprintf(f1,'%s %s \n',blanks(10),');');
fprintf(f1,'%s %s \n',blanks(5),'}');

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

fprintf(f1,'%s %s \n',blanks(5),'front');
fprintf(f1,'%s %s \n',blanks(5),'{');
fprintf(f1,'%s %s \n',blanks(10),'type symmetry');
fprintf(f1,'%s %s \n',blanks(10),'faces');
fprintf(f1,'%s %s \n',blanks(10),'(');
fprintf(f1,'%s %s \n',blanks(15),'(0 3 5 2)');
fprintf(f1,'%s %s \n',blanks(10),');');
fprintf(f1,'%s %s \n',blanks(5),'}');

fprintf(f1,'%s %s \n',blanks(5),'back');
fprintf(f1,'%s %s \n',blanks(5),'{');
fprintf(f1,'%s %s \n',blanks(10),'type symmetry');
fprintf(f1,'%s %s \n',blanks(10),'faces');
fprintf(f1,'%s %s \n',blanks(10),'(');
fprintf(f1,'%s %s \n',blanks(15),'(0 1 4 3)');
fprintf(f1,'%s %s \n',blanks(10),');');
fprintf(f1,'%s %s \n',blanks(5),'}');

fprintf(f1,'%s %s \n',blanks(5),'pipe');
fprintf(f1,'%s %s \n',blanks(5),'{');
fprintf(f1,'%s %s \n',blanks(10),'type wall');
fprintf(f1,'%s %s \n',blanks(10),'faces');
fprintf(f1,'%s %s \n',blanks(10),'(');
fprintf(f1,'%s %s \n',blanks(15),'(1 4 5 2)');
fprintf(f1,'%s %s \n',blanks(10),');');
fprintf(f1,'%s %s \n',blanks(5),'}');

fprintf(f1,'%s %s \n',blanks(5),'axis');
fprintf(f1,'%s %s \n',blanks(5),'{');
fprintf(f1,'%s %s \n',blanks(10),'type empty');
fprintf(f1,'%s %s \n',blanks(10),'faces');
fprintf(f1,'%s %s \n',blanks(10),'(');
fprintf(f1,'%s %s \n',blanks(15),'(0 3 3 0)');
fprintf(f1,'%s %s \n',blanks(10),');');
fprintf(f1,'%s %s \n',blanks(5),'}');
fprintf(f1,'%s \n',');');
fprintf(f1,'\n');

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

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

fprintf(f1,'\n');

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

blockMeshDict file for theta=10

/*--------------------------------*- 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.000000 0.000000 0.000000) 
	       (0.000000 0.009962 -0.000872) 
	       (0.000000 0.009962 0.000872) 
	       (2.520000 0.000000 0.000000) 
	       (2.520000 0.009962 -0.000872) 
	       (2.520000 0.009962 0.009962) 
); 

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

edges 
( 
      arc 1 2 (0.000000 0.010000 0.000000) 
      arc 1 2 (2.520000 0.010000 0.000000) 
); 

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

mergePatchPairs 
( 
); 

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

blockMeshDict file for theta=25

/*--------------------------------*- 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.000000 0.000000 0.000000) 
	       (0.000000 0.009763 -0.002164) 
	       (0.000000 0.009763 0.002164) 
	       (2.520000 0.000000 0.000000) 
	       (2.520000 0.009763 -0.002164) 
	       (2.520000 0.009763 0.009763) 
); 

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

edges 
( 
      arc 1 2 (0.000000 0.010000 0.000000) 
      arc 1 2 (2.520000 0.010000 0.000000) 
); 

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

mergePatchPairs 
( 
); 

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

blockMeshDict file for theta=45

/*--------------------------------*- 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.000000 0.000000 0.000000) 
	       (0.000000 0.009239 -0.003827) 
	       (0.000000 0.009239 0.003827) 
	       (2.520000 0.000000 0.000000) 
	       (2.520000 0.009239 -0.003827) 
	       (2.520000 0.009239 0.009239) 
); 

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

edges 
( 
      arc 1 2 (0.000000 0.010000 0.000000) 
      arc 1 2 (2.520000 0.010000 0.000000) 
); 

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

mergePatchPairs 
( 
); 

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

Velocity field file with changing inlet velocity and doing other necessary changes according to model:

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

    outlet
    {
        type            zeroGradient;
    }

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

Pressure field file with changing outlet Pressure and doing other necessary changes according to model:

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

     
    inlet
    {
        type            zeroGradient;
    }

    outlet
    {
        type            fixedValue;
        value           uniform 0.0168682;
    }

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

treansportProperties file changing value of nu and keeping other things constant:

/*--------------------------------*- 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    "constant";
    object      transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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


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

controlDict file changing endTime=10 and deltaT=0.001 and keeping other things constant:

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

deltaT          0.001;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;

Meshgrid at 10 wedge angle:

Meshgrid at 25 wedge angle:

Meshgrid at 45 wedge angle:

For wedge angle 10:

At 0.001m from inlet

At 0.05m from inlet

At 0.01m from inlet

At 0.5m from inlet

At 1.5m from inlet

At 2.25m from inlet

Shear Stress at 1.9m from inlet along the radius

For wedge angle 25:

At 0.001m from inlet

At 0.05m from inlet

At 0.1m from inlet

At 0.5m from inlet

At 1.5m from inlet

At 2.25m from inlet

Shear Stress at 1.9m from inlet along the radius

For wedge angle 45:

At 0.001m from inlet

At 0.05m from inlet

At 0.1m from inlet

At 0.5m from inlet

At 1.5m from inlet

At 2.52m from inlet

Shear Stress at 1.9m from inlet along the radius

Conclusion:

  • With increase in wedge angle velocity and pressure reaches more towards the exact solution.
  • Computational time for symmetric is more then wedge BCs.
  • Symmetric is more accurate then wedge BCs.
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.