Challenge

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

The octave code to make blockmesh files for wedge and symmetry boundary conditions at 10,25 and 45 degree is as follows

clear all
close all
clc
%input
Re=2100; %ReynoldsNumber
d=0.01; %diameter of the pipe
r=d/2; %radius
le=0.05*Re*d; %entry length for laminar flow
l=le+0.3;
myu=1.002e-3;%absolute viscosity of water at 20 degree celsius
rho=997; %density
nu=1.004e-6; %kinematic viscosity of water at 20 degree C
grade_x=0.1;%grading along x
grade_y=1;%grading along y
grade_z=1;%grading along zzz
type={"wedge" "symmetry"}
for i=1:length(type)
  for theta=[10 25 45]
    %vertices
    p0=[0 0 0];
    p1=[0 r*cosd(theta/2) -r*sind(theta/2)];
    p2=[0 r*cosd(theta/2) r*sind(theta/2)];
    p3=[l 0 0];
    p4=[l r*cosd(theta/2) -r*sind(theta/2)];
    p5=[l r*cosd(theta/2) r*sind(theta/2)];
    name=sprintf("blockMeshDict_%s_%d",type{i},theta);
    f1=fopen(name,"w");
    fprintf(f1,'/*--------------------------------*- C++ -*----------------------------------*\\\n');
    fprintf(f1,'  =========                 |\n');
    fprintf(f1,'  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox\n');
    fprintf(f1,'   \\    /   O peration     | Website:  https://openfoam.org\n');
    fprintf(f1,'    \\  /    A nd           | Version:  8\n');
    fprintf(f1,'     \\/     M anipulation  |\n');
    fprintf(f1,'\\*---------------------------------------------------------------------------*/\n');
    fprintf(f1,'FoamFile\n');
    fprintf(f1,'{\n');
    fprintf(f1,'    version     2.0;\n');
    fprintf(f1,'    format      ascii;\n');
    fprintf(f1,'    class       dictionary;\n');
    fprintf(f1,'    object      blockMeshDict;\n');
    fprintf(f1,'}\n');
    fprintf(f1,'// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //\n\n');
    fprintf(f1,'convertToMeters 1;\n\n');
    fprintf(f1,'vertices\n');
    fprintf(f1,'(\n');
    fprintf(f1,'    (%d %d %d)//0\n',p0(1),p0(2),p0(3));
    fprintf(f1,'    (%d %d %d)//1\n',p1(1),p1(2),p1(3));
    fprintf(f1,'    (%d %d %d)//2\n',p2(1),p2(2),p2(3));
    fprintf(f1,'    (%d %d %d)//3\n',p3(1),p3(2),p3(3));
    fprintf(f1,'    (%d %d %d)//4\n',p4(1),p4(2),p4(3));
    fprintf(f1,'    (%d %d %d)//5\n',p5(1),p5(2),p5(3));
    fprintf(f1,');\n\n');
    fprintf(f1,'blocks\n(\n');
    fprintf(f1,'    hex (0 1 2 0 3 4 5 3) (50 1 100) simpleGrading (%d %d %d)\n',grade_x,grade_y,grade_z);
    fprintf(f1,');\n\n');
    fprintf(f1,'edges\n(\n');
    fprintf(f1,'    arc 1 2 (%d %d %d)\n',0,r,0);
    fprintf(f1,'    arc 4 5 (%d %d %d)\n',l,r,0);
    fprintf(f1,');\n\n'); 
    fprintf(f1,'boundary\n(\n');
    fprintf(f1,'    inlet\n');
    fprintf(f1,'    {\n');
    fprintf(f1,'        type patch;\n');
    fprintf(f1,'        faces\n');
    fprintf(f1,'        (\n');
    fprintf(f1,'            (0 2 1 0)\n');
    fprintf(f1,'        );\n');
    fprintf(f1,'    }\n');
    fprintf(f1,'    outlet\n');
    fprintf(f1,'    {\n');
    fprintf(f1,'        type patch;\n');
    fprintf(f1,'        faces\n');
    fprintf(f1,'        (\n');
    fprintf(f1,'            (3 4 5 3)\n');
    fprintf(f1,'        );\n');
    fprintf(f1,'    }\n');
    fprintf(f1,'    left\n');
    fprintf(f1,'    {\n');
    fprintf(f1,'        type %s;\n',type{i});
    fprintf(f1,'        faces\n');
    fprintf(f1,'        (\n');
    fprintf(f1,'            (0 3 5 2)\n');
    fprintf(f1,'        );\n');
    fprintf(f1,'    }\n');
    fprintf(f1,'    right\n');
    fprintf(f1,'    {\n');
    fprintf(f1,'        type %s;\n',type{i});
    fprintf(f1,'        faces\n');
    fprintf(f1,'        (\n');
    fprintf(f1,'            (0 1 4 3)\n');
    fprintf(f1,'        );\n');
    fprintf(f1,'    }\n');
    fprintf(f1,'    wall\n');
    fprintf(f1,'    {\n');
    fprintf(f1,'        type wall;\n');
    fprintf(f1,'        faces\n');
    fprintf(f1,'        (\n');
    fprintf(f1,'            (1 2 5 4)\n');
    fprintf(f1,'        );\n');
    fprintf(f1,'    }\n');
    fprintf(f1,'    axis\n');
    fprintf(f1,'    {\n');
    fprintf(f1,'        type empty;\n');
    fprintf(f1,'        faces\n');
    fprintf(f1,'        (\n');
    fprintf(f1,'            (0 3 3 0)\n');
    fprintf(f1,'        );\n');
    fprintf(f1,'    }\n');
    fprintf(f1,');\n\n');
    fprintf(f1,'mergePatchPairs\n(\n);\n\n');
    fprintf(f1,'// ************************************************************************* //\n');
    fclose(f1);
  end
end

The velocity and pressure conditions are as follows

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

    outlet
    {
        type            zeroGradient;
    }

    left
    {
        type            symmetry;
    }
    
    right
    {
        type            symmetry;
    }
    
    wall
    {
        type            fixedValue;
        value           uniform (0 0 0);
    }
    
    axis
    {
        type            empty;
    }
}

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

    left
    {
        type            symmetry;
    }
    
    right
    {
        type            symmetry;
    }
    
    wall
    {
        type           zeroGradient;
    }
    
    axis
    {
        type           empty;
    }
}

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

The pressure and velocity plots are attached below

The `DeltaP` from simulation is 0.22721.

FRom calculations

Vmax=`delta`P*R^2/4*μ*L=0.4153

We know,

`u(r)=v_max*(1-r^2/R^2)`

from this we velocity plot will be a downward parabola.

`DeltaP=(V_(avg)*mu*L)/D^2`

which is 0.201243

There is an error of 12.9%.

This is due to the fact as the wedge angle increase the size of the cell increases and acccuracy decreases. This can solved by reducing the element size but this greatly increases the computation time.

It can be observed that as the angle increases keeping the sizing same the results deviate from that of calculated.

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.