Challenge

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

Objective:

To simulate the flow through a pipe for three different wedge angles using the Symmetry boundary condition and compare the results.

Solution

The fluid properties are the same as in the previous part of the challenge (Challenge 11).

Diameter = 0.004m

Rho = 1000 kgm^-3

Re = 2100

Entrance length Le = 0.05*Re*D = 0.05 * 2100 * 0.004 = 0.42 m

L = Le + 0.3 = 0.72 m

1.`theta = 10 deg`

The matlab script used to determine the blockMeshdict file is as follows

clear all
close all
clc

% Inputs
Re = 2100;      % Reynolds number
D = 0.004;       % Diameter of pipe
rho = 1000;     % density
nu = 8.91e-7;   % Kinematic viscosity

% Initial Calculations

mu = nu*rho; % Dynamic viscosity
V_avg = mu*Re/(rho*D);
V_max = 2*V_avg;

r = D/2;    % Radius in m

L_entr = 0.05*D*Re; % Length at entrance
L = L_entr + 0.3; % Total length

% Hagen Poiseuille calculations

delta_p = 8*mu*V_avg*L/r^2;     % Pressure      
Kin_pressure = delta_p/rho;     % Kinematic Pressure 

%Wedge angle
theta = 10;

R = linspace(0,r,1000);

for i = 1:length(R)
    tau(i) = 2*mu*V_max*(abs(R(i)))/r^2;
end

%Plot
plot(R,tau);
xlabel('Radius in m');
ylabel('Shear stress in N/m^2');
title('Variation of shear stress along radius');
grid on
hold on

%%
% BLOCKMESH DICT FILE

% Vertices
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)];


f1 = fopen('blockMeshDict_10.txt','w');


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

% Vertices
fprintf(f1,'Vertices\n');
fprintf(f1,'(\n');
fprintf(f1, '\t(%d, %d, %d)\n',0,0,0);
fprintf(f1, '\t(%d, %d, %d)\n',0, r*cosd(theta/2), -r*sind(theta/2));
fprintf(f1, '\t(%d, %d, %d)\n',0, r*cosd(theta/2), r*sind(theta/2));
fprintf(f1, '\t(%d, %d, %d)\n',L,0,0);
fprintf(f1, '\t(%d, %d, %d)\n',L, r*cosd(theta/2), -r*sind(theta/2));
fprintf(f1, '\t(%d, %d, %d)\n',L, r*cosd(theta/2), r*sind(theta/2));
fprintf(f1,')\n\n');


% Blocks
fprintf(f1, '\n');
fprintf(f1,'blocks\n');
fprintf(f1,'(\n');
fprintf(f1, '\t hex (0 3 4 1 0 3 5 2) ( %d %d %d) simpleGrading(1 0.1 1)\n',300,30,1);
fprintf(f1,')\n');

% Edges
 fprintf(f1,'edges\n(\n\t arc %d %d (%d %d %d)\n', 1,2,0,r,0);
 fprintf(f1,'\t arc %d %d (%d %d %d)\n', 4,5,L,r,0);
 fprintf(f1,');\n\n');

% Boundary
fprintf(f1,'boundary\n(\n');
fprintf(f1,'\t inlet\n');
fprintf(f1,'\t {\n');
fprintf(f1,'\t\t type patch;\n');
fprintf(f1,'\t\t faces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(0 1 2 0)\n');
fprintf(f1,'\t\t );\n');

fprintf(f1,'\t outlet\n');
fprintf(f1,'\t {\n');
fprintf(f1,'\t\t type patch;\n');
fprintf(f1,'\t\t faces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(3 5 4 3)\n');
fprintf(f1,'\t\t );\n');
fprintf(f1,'\t}\n');

fprintf(f1,'\t top\n');
fprintf(f1,'\t {\n');
fprintf(f1,'\t\t type wall;\n');
fprintf(f1,'\t\t faces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(1 4 5 2)\n');
fprintf(f1,'\t\t );\n');
fprintf(f1,'\t }\n');

fprintf(f1,'\t back\n');
fprintf(f1,'\t {\n');
fprintf(f1,'\t\t type symmetry;\n');
fprintf(f1,'\t\t faces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(0 2 5 3)\n');
fprintf(f1,'\t\t );\n');
fprintf(f1,'\t }\n');

fprintf(f1,'\t front\n');
fprintf(f1,'\t {\n');
fprintf(f1,'\t\t type symmetry;\n');
fprintf(f1,'\t\t faces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(0 3 4 1)\n');
fprintf(f1,'\t\t );\n');
fprintf(f1,'\t }\n');

fprintf(f1,'\t axis\n');
fprintf(f1,'\t {\n');
fprintf(f1,'\t\t type empty;\n');
fprintf(f1,'\t\t faces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(0 3 3 0)\n');
fprintf(f1,'\t\t );\n');
fprintf(f1,'\t }\n');
fprintf(f1,'mergePatchPairs\n(\n');
fprintf(f1,');\n');

fclose(f1);


Blockmeshdict 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;
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

convertToMeters 1;

vertices
(
    (0 0 0)
    (0 0.002 -1.7431e-4)
    (0 0.002 1.7431e-4)
    (0.72 0 0)
    (0.72 0.002 -1.7431e-4)
    (0.72 0.002 1.7431e-4)
    
);

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

edges
(
 
);

boundary
(
    inlet
    {
        type patch;
        faces
        (
            (0 1 2 0)
        );
    }
    outlet
    {
        type patch;
        faces
        (
            (3 5 4 3)
            
        );
    }
    top
    {
        type wall;
        faces
        (
            (1 4 5 2)
            
        );
    }
    front
    {
        type symmetry;
        faces
        (
            (0 3 4 1)
            
        );
    }
    back
    {
        type symmetry;
        faces
        (
            (0 2 5 3)
            
        );
    }
    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         2;

deltaT          0.001;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

Pressure 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       volScalarField;
    object      p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 2 -2 0 0 0 0];

internalField   uniform 0;

boundaryField
{
    inlet
    {
        type            zeroGradient;
    }

    outlet
    {
        type            fixedValue;
        value		 uniform 0;	
    }

    back
    {
        type            symmetry;
    }
    front
    {
        type            symmetry;
    }
    top
    {
        type            zeroGradient;
    }
}

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

Velocity 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       volVectorField;
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 -1 0 0 0 0];

internalField   uniform (0.4678 0 0);

boundaryField
{
    inlet
    {
        type            fixedValue;
        value		 uniform (0.4678 0 0);
    }

    outlet
    {
        type            zeroGradient;
        	
    }

    back
    {
        type            symmetry;
    }
    front
    {
        type            symmetry;
    }
    top
    {
        type            noSlip;
    }
}

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

Generated mesh

Pressure contour

It can be seen, that there is high pressure (red) at the entry and low pressure (blue) at the exit of the pipe. The fluid flows from a region of high to low pressure.

Velocity contour

It can be seen, that the velocity is zero at the wall of the pipe due to the boundary layer, and increases gradually to a maximum value near the centre of the pipe.

Velocity profiles

X = 0.1 m

X = 0.42m

X = 0.7m

It can be seen that the velocity profile at the entry of the pipe (0.1m) has a steep decline. At the entrance length (0.42m) the profile is a parabolic curve, and remains constant until the end (0.72m).

Shear stress

When the fluid is moving, shear stresses are developed as the particles in the flow move relative to each other. For a fluid flowing in the pipe, the fluid velocity near the wall remains zero. Shear force is generated because of the friction between the adjacent layers of fluid that move relative to each other.

If the value of viscosity is constant, the shear stress is linearly dependent on the velocity gradient. As the change in velocity is larger, more the shear stress near the walls.

2.`theta = 25 deg`

The matlab script used to determine the blockMeshdict file is as follows

clear all
close all
clc

% Inputs
Re = 2100;      % Reynolds number
D = 0.004;       % Diameter of pipe
rho = 1000;     % density
nu = 8.91e-7;   % Kinematic viscosity

% Initial Calculations

mu = nu*rho; % Dynamic viscosity
V_avg = mu*Re/(rho*D);
V_max = 2*V_avg;

r = D/2;    % Radius in m

L_entr = 0.05*D*Re; % Length at entrance
L = L_entr + 0.3; % Total length

% Hagen Poiseuille calculations

delta_p = 8*mu*V_avg*L/r^2;     % Pressure      
Kin_pressure = delta_p/rho;     % Kinematic Pressure 

%Wedge angle
theta = 25;

R = linspace(0,r,1000);

for i = 1:length(R)
    tau(i) = 2*mu*V_max*(abs(R(i)))/r^2;
end

%Plot
plot(R,tau);
xlabel('Radius in m');
ylabel('Shear stress in N/m^2');
title('Variation of shear stress along radius');
grid on
hold on

%%
% BLOCKMESH DICT FILE

% Vertices
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)];


f1 = fopen('blockMeshDict_25.txt','w');


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

% Vertices
fprintf(f1,'Vertices\n');
fprintf(f1,'(\n');
fprintf(f1, '\t(%d, %d, %d)\n',0,0,0);
fprintf(f1, '\t(%d, %d, %d)\n',0, r*cosd(theta/2), -r*sind(theta/2));
fprintf(f1, '\t(%d, %d, %d)\n',0, r*cosd(theta/2), r*sind(theta/2));
fprintf(f1, '\t(%d, %d, %d)\n',L,0,0);
fprintf(f1, '\t(%d, %d, %d)\n',L, r*cosd(theta/2), -r*sind(theta/2));
fprintf(f1, '\t(%d, %d, %d)\n',L, r*cosd(theta/2), r*sind(theta/2));
fprintf(f1,')\n\n');


% Blocks
fprintf(f1, '\n');
fprintf(f1,'blocks\n');
fprintf(f1,'(\n');
fprintf(f1, '\t hex (0 3 4 1 0 3 5 2) ( %d %d %d) simpleGrading(1 0.1 1)\n',300,30,1);
fprintf(f1,')\n');

% Edges
 fprintf(f1,'edges\n(\n\t arc %d %d (%d %d %d)\n', 1,2,0,r,0);
 fprintf(f1,'\t arc %d %d (%d %d %d)\n', 4,5,L,r,0);
 fprintf(f1,');\n\n');

% Boundary
fprintf(f1,'boundary\n(\n');
fprintf(f1,'\t inlet\n');
fprintf(f1,'\t {\n');
fprintf(f1,'\t\t type patch;\n');
fprintf(f1,'\t\t faces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(0 1 2 0)\n');
fprintf(f1,'\t\t );\n');

fprintf(f1,'\t outlet\n');
fprintf(f1,'\t {\n');
fprintf(f1,'\t\t type patch;\n');
fprintf(f1,'\t\t faces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(3 5 4 3)\n');
fprintf(f1,'\t\t );\n');
fprintf(f1,'\t}\n');

fprintf(f1,'\t top\n');
fprintf(f1,'\t {\n');
fprintf(f1,'\t\t type wall;\n');
fprintf(f1,'\t\t faces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(1 4 5 2)\n');
fprintf(f1,'\t\t );\n');
fprintf(f1,'\t }\n');

fprintf(f1,'\t back\n');
fprintf(f1,'\t {\n');
fprintf(f1,'\t\t type symmetry;\n');
fprintf(f1,'\t\t faces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(0 2 5 3)\n');
fprintf(f1,'\t\t );\n');
fprintf(f1,'\t }\n');

fprintf(f1,'\t front\n');
fprintf(f1,'\t {\n');
fprintf(f1,'\t\t type symmetry;\n');
fprintf(f1,'\t\t faces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(0 3 4 1)\n');
fprintf(f1,'\t\t );\n');
fprintf(f1,'\t }\n');

fprintf(f1,'\t axis\n');
fprintf(f1,'\t {\n');
fprintf(f1,'\t\t type empty;\n');
fprintf(f1,'\t\t faces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(0 3 3 0)\n');
fprintf(f1,'\t\t );\n');
fprintf(f1,'\t }\n');
fprintf(f1,'mergePatchPairs\n(\n');
fprintf(f1,');\n');

fclose(f1);


Blockmeshdict 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;
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

convertToMeters 1;

vertices
(
    (0 0 0)
    (0 0.00195 -4.328e-4)
    (0 0.00195 4.328-4)
    (0.72 0 0)
    (0.72 0.00195 -4.328e-4)
    (0.72 0.00195 4.328e-4)
    
);

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

edges
(
 
);

boundary
(
    inlet
    {
        type patch;
        faces
        (
            (0 1 2 0)
        );
    }
    outlet
    {
        type patch;
        faces
        (
            (3 5 4 3)
            
        );
    }
    top
    {
        type wall;
        faces
        (
            (1 4 5 2)
            
        );
    }
    front
    {
        type symmetry;
        faces
        (
            (0 3 4 1)
            
        );
    }
    back
    {
        type symmetry;
        faces
        (
            (0 2 5 3)
            
        );
    }
    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         2;

deltaT          0.001;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

Pressure 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       volScalarField;
    object      p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 2 -2 0 0 0 0];

internalField   uniform 0;

boundaryField
{
    inlet
    {
        type            zeroGradient;
    }

    outlet
    {
        type            fixedValue;
        value		 uniform 0;	
    }

    back
    {
        type            symmetry;
    }
    front
    {
        type            symmetry;
    }
    top
    {
        type            zeroGradient;
    }
}

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

Velocity 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       volVectorField;
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 -1 0 0 0 0];

internalField   uniform (0.4678 0 0);

boundaryField
{
    inlet
    {
        type            fixedValue;
        value		 uniform (0.4678 0 0);
    }

    outlet
    {
        type            zeroGradient;
        	
    }

    back
    {
        type            symmetry;
    }
    front
    {
        type            symmetry;
    }
    top
    {
        type            noSlip;
    }
}

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

Generated mesh

Pressure contour

It can be seen, that there is high pressure (red) at the entry and low pressure (blue) at the exit of the pipe. The fluid flows from a region of high to low pressure.

Velocity contour

It can be seen, that the velocity is zero at the wall of the pipe due to the boundary layer, and increases gradually to a maximum value near the centre of the pipe.

Velocity profiles

X = 0.1 m

X = 0.42m

X = 0.7m

It can be seen that the velocity profile at the entry of the pipe (0.1m) has a steep decline. At the entrance length (0.42m) the profile is a parabolic curve, and remains constant until the end (0.72m).

Shear Stress

When the fluid is moving, shear stresses are developed as the particles in the flow move relative to each other. For a fluid flowing in the pipe, the fluid velocity near the wall remains zero. Shear force is generated because of the friction between the adjacent layers of fluid that move relative to each other.

If the value of viscosity is constant, the shear stress is linearly dependent on the velocity gradient. As the change in velocity is larger, more the shear stress near the walls.

3.`theta = 45 deg`

The matlab script used to determine the blockMeshdict file is as follows

clear all
close all
clc

% Inputs
Re = 2100;      % Reynolds number
D = 0.004;       % Diameter of pipe
rho = 1000;     % density
nu = 8.91e-7;   % Kinematic viscosity

% Initial Calculations

mu = nu*rho; % Dynamic viscosity
V_avg = mu*Re/(rho*D);
V_max = 2*V_avg;

r = D/2;    % Radius in m

L_entr = 0.05*D*Re; % Length at entrance
L = L_entr + 0.3; % Total length

% Hagen Poiseuille calculations

delta_p = 8*mu*V_avg*L/r^2;     % Pressure      
Kin_pressure = delta_p/rho;     % Kinematic Pressure 

%Wedge angle
theta = 45;

R = linspace(0,r,1000);

for i = 1:length(R)
    tau(i) = 2*mu*V_max*(abs(R(i)))/r^2;
end

%Plot
plot(R,tau);
xlabel('Radius in m');
ylabel('Shear stress in N/m^2');
title('Variation of shear stress along radius');
grid on
hold on

%%
% BLOCKMESH DICT FILE

% Vertices
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)];


f1 = fopen('blockMeshDict_45.txt','w');


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

% Vertices
fprintf(f1,'Vertices\n');
fprintf(f1,'(\n');
fprintf(f1, '\t(%d, %d, %d)\n',0,0,0);
fprintf(f1, '\t(%d, %d, %d)\n',0, r*cosd(theta/2), -r*sind(theta/2));
fprintf(f1, '\t(%d, %d, %d)\n',0, r*cosd(theta/2), r*sind(theta/2));
fprintf(f1, '\t(%d, %d, %d)\n',L,0,0);
fprintf(f1, '\t(%d, %d, %d)\n',L, r*cosd(theta/2), -r*sind(theta/2));
fprintf(f1, '\t(%d, %d, %d)\n',L, r*cosd(theta/2), r*sind(theta/2));
fprintf(f1,')\n\n');


% Blocks
fprintf(f1, '\n');
fprintf(f1,'blocks\n');
fprintf(f1,'(\n');
fprintf(f1, '\t hex (0 3 4 1 0 3 5 2) ( %d %d %d) simpleGrading(1 0.1 1)\n',300,30,1);
fprintf(f1,')\n');

% Edges
 fprintf(f1,'edges\n(\n\t arc %d %d (%d %d %d)\n', 1,2,0,r,0);
 fprintf(f1,'\t arc %d %d (%d %d %d)\n', 4,5,L,r,0);
 fprintf(f1,');\n\n');

% Boundary
fprintf(f1,'boundary\n(\n');
fprintf(f1,'\t inlet\n');
fprintf(f1,'\t {\n');
fprintf(f1,'\t\t type patch;\n');
fprintf(f1,'\t\t faces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(0 1 2 0)\n');
fprintf(f1,'\t\t );\n');

fprintf(f1,'\t outlet\n');
fprintf(f1,'\t {\n');
fprintf(f1,'\t\t type patch;\n');
fprintf(f1,'\t\t faces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(3 5 4 3)\n');
fprintf(f1,'\t\t );\n');
fprintf(f1,'\t}\n');

fprintf(f1,'\t top\n');
fprintf(f1,'\t {\n');
fprintf(f1,'\t\t type wall;\n');
fprintf(f1,'\t\t faces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(1 4 5 2)\n');
fprintf(f1,'\t\t );\n');
fprintf(f1,'\t }\n');

fprintf(f1,'\t back\n');
fprintf(f1,'\t {\n');
fprintf(f1,'\t\t type symmetry;\n');
fprintf(f1,'\t\t faces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(0 2 5 3)\n');
fprintf(f1,'\t\t );\n');
fprintf(f1,'\t }\n');

fprintf(f1,'\t front\n');
fprintf(f1,'\t {\n');
fprintf(f1,'\t\t type symmetry;\n');
fprintf(f1,'\t\t faces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(0 3 4 1)\n');
fprintf(f1,'\t\t );\n');
fprintf(f1,'\t }\n');

fprintf(f1,'\t axis\n');
fprintf(f1,'\t {\n');
fprintf(f1,'\t\t type empty;\n');
fprintf(f1,'\t\t faces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(0 3 3 0)\n');
fprintf(f1,'\t\t );\n');
fprintf(f1,'\t }\n');
fprintf(f1,'mergePatchPairs\n(\n');
fprintf(f1,');\n');

fclose(f1);


Blockmeshdict 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;
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

convertToMeters 1;

vertices
(
    (0 0 0)
    (0 0.00195 -4.328e-4)
    (0 0.00195 4.328-4)
    (0.72 0 0)
    (0.72 0.00195 -4.328e-4)
    (0.72 0.00195 4.328e-4)
    
);

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

edges
(
 
);

boundary
(
    inlet
    {
        type patch;
        faces
        (
            (0 1 2 0)
        );
    }
    outlet
    {
        type patch;
        faces
        (
            (3 5 4 3)
            
        );
    }
    top
    {
        type wall;
        faces
        (
            (1 4 5 2)
            
        );
    }
    front
    {
        type symmetry;
        faces
        (
            (0 3 4 1)
            
        );
    }
    back
    {
        type symmetry;
        faces
        (
            (0 2 5 3)
            
        );
    }
    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         2;

deltaT          0.001;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

Pressure 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       volScalarField;
    object      p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 2 -2 0 0 0 0];

internalField   uniform 0;

boundaryField
{
    inlet
    {
        type            zeroGradient;
    }

    outlet
    {
        type            fixedValue;
        value		 uniform 0;	
    }

    back
    {
        type            symmetry;
    }
    front
    {
        type            symmetry;
    }
    top
    {
        type            zeroGradient;
    }
}

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

Velocity 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       volVectorField;
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 -1 0 0 0 0];

internalField   uniform (0.4678 0 0);

boundaryField
{
    inlet
    {
        type            fixedValue;
        value		 uniform (0.4678 0 0);
    }

    outlet
    {
        type            zeroGradient;
        	
    }

    back
    {
        type            symmetry;
    }
    front
    {
        type            symmetry;
    }
    top
    {
        type            noSlip;
    }
}

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

Generated mesh

Pressure contour

It can be seen, that there is high pressure (red) at the entry and low pressure (blue) at the exit of the pipe. The fluid flows from a region of high to low pressure.

Velocity contour

It can be seen, that the velocity is zero at the wall of the pipe due to the boundary layer, and increases gradually to a maximum value near the centre of the pipe.

Velocity profiles

X = 0.1 m

X = 0.42m

X = 0.7m

It can be seen that the velocity profile at the entry of the pipe (0.1m) has a steep decline. At the entrance length (0.42m) the profile is a parabolic curve, and remains constant until the end (0.72m).

Shear stress

When the fluid is moving, shear stresses are developed as the particles in the flow move relative to each other. For a fluid flowing in the pipe, the fluid velocity near the wall remains zero. Shear force is generated because of the friction between the adjacent layers of fluid that move relative to each other.

If the value of viscosity is constant, the shear stress is linearly dependent on the velocity gradient. As the change in velocity is larger, more the shear stress near the walls.

Conclusion

Thus the simulation has been done for the three different wedge angles with the symmetry boundary condition, and the results have been compared.

The matlab m files have been attached below

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.