Week 12 - Validation studies of Symmetry BC vs Wedge BC in OpenFOAM vs Analytical H.P equation
Validation studies of Symmetry BC vs Wedge BC in OpenFOAM vs Analytical Hagen-Poiseuille equation
This project is a continuation of the previous project. Here we will be creating different wedge blocks of angles `10^o, 25^o, and 45^o` with two different boundary conditions repeating the same steps that are filled in the previous project.
MATLAB Script
This MATLAB script from the previous project can be used to create different blocks by changing the value of theta in the script.
close all
clear all
clc
% Assumed Values
L=3; % Length of the Pipe
d=0.02; % Diameter Of the Pipe
r=d/2; % Radius of the Pipe
theta=3; % Wedge angle
x= r*sind(theta/2); % X co-ordinate
y= r*cosd(theta/2); % Y co-ordinate
nx=20; % No. of cells in x-direction
ny=1; % No. of cells in y-direction
nz=200; % No. of cells in y-direction
gfx = 1 ; % Grading Factor in x-direction
gfy = 1/2; % Grading Factor in y-direction
gfz = 1 ; % Grading Factor in z-direction
l(1) = "/*--------------------------------*- C++ -*----------------------------------*\";
l(2) = " ========= | ";
l(3) = " \\ / F ield | OpenFOAM: The Open Source CFD Toolbox ";
l(4) = " \\ / O peration | Website: https://openfoam.org ";
l(5) = " \\ / A nd | Version: 8 ";
l(6) = " \\/ M anipulation | ";
l(7) = "\*---------------------------------------------------------------------------*/";
l(8) = "FoamFile ";
l(9) = "{ ";
l(10)= " version 2.0; ";
l(11)= " format ascii; ";
l(12)= " class dictionary; ";
l(13)= " object blockMeshDict; ";
l(14)= "} ";
l(15)= "// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //";
l(16)= " ";
l(17)= "convertToMeters 1; ";
l(18)= " ";
% Vertices
l(19)= "vertices ";
l(20)= "( ";
l(21)= sprintf('(0 0 0) // vertice 0'); % Vertices 0 (0 0 0)
l(22)= sprintf('(%f %f 0) // vertice 1',x,y); % Vertices 1 (x y 0)
l(23)= sprintf('(%f %f 0) // vertice 2',-x,y); % Vertices 2 (-x y 0)
l(24)= sprintf('(%f %f %f) // vertice 3',0,0,L); % Vertices 3 (0 0 L)
l(25)= sprintf('(%f %f %f) // vertice 4',x,y,L); % Vertices 4 (x y L)
l(26)= sprintf('(%f %f %f) // vertice 5',-x,y,L); % Vertices 5 (-x y L)
l(27)=" ); ";
% Hexagonal Block
l(28)="blocks ";
l(29)="( ";
l(30)= sprintf(' hex (0 1 2 0 3 4 5 3)(%d %d %d) simpleGrading (%d %1.1f %d)',nx,ny,nz,gfx,gfy,gfz);
% hex (0 1 2 0 3 4 5 3) (nx ny nz) simpleGrading (gfx,gfy,gfz)
l(31)=" ); ";
% Edges
l(32)="edges ";
l(33)="( ";
l(34)= sprintf(' arc 1 2 (0 %2.2f 0)',r); % Arc Formation
l(35)= sprintf(' arc 4 5(0 %2.2f %2.2f)',r,L); % Arc Formation
l(36)="); ";
l(37)=" boundary ";
l(38)=" ( ";
l(39)=" Inlet ";
l(40)=" { ";
l(41)=" type patch; ";
l(42)=" faces ";
l(43)=" ( ";
l(44)=" (0 1 2 0) ";
l(45)=" ); ";
l(46)=" ";
l(47)=" } ";
l(48)=" Outlet ";
l(49)=" { ";
l(50)=" type patch; ";
l(51)=" faces ";
l(52)=" ( ";
l(53)=" (3 4 5 3) ";
l(54)=" ); ";
l(55)=" } ";
l(56)=" wedge1 ";
l(57)=" { ";
l(58)=" type wedge; ";
l(59)=" faces ";
l(60)=" ( ";
l(61)=" (0 3 4 1) ";
l(62)=" ); ";
l(63)=" } ";
l(64)=" wedge2 ";
l(65)=" { ";
l(66)=" type wedge; ";
l(67)=" faces ";
l(68)=" ( ";
l(69)=" (0 3 5 2) ";
l(70)=" ); ";
l(71)=" } ";
l(72)=" upperWall ";
l(73)=" { ";
l(74)=" type wall; ";
l(75)=" faces ";
l(76)=" ( ";
l(77)=" (4 5 2 1) ";
l(78)=" ); ";
l(79)=" } ";
l(80)=" ) ";
l(81)=" mergePatchPairs ";
l(82)=" ( ";
l(83)=" ); ";
l(84)=" ";
l(85)=" // ************************************************************************* // ";
s=size(l);
% blockMeshDict File
blockMeshDict=fopen('blockMeshDict','w');
for i=1:s(2)
fprintf(blockMeshDict,'%s \n',l(i));
end
fclose(blockMeshDict)
Boundary Condition: Wedge type
1) Wedge Angle: `10^o`
i) blockMeshDict file
/*--------------------------------*- 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 dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0) // vertice 0
(0.000872 0.009962 0) // vertice 1
(-0.000872 0.009962 0) // vertice 2
(0.000000 0.000000 3.000000) // vertice 3
(0.000872 0.009962 3.000000) // vertice 4
(-0.000872 0.009962 3.000000) // vertice 5
);
blocks
(
hex (0 1 2 0 3 4 5 3)(20 1 200) simpleGrading (1 0.5 1)
);
edges
(
arc 1 2 (0 0.01 0)
arc 4 5(0 0.01 3.00)
);
boundary
(
Inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
Outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
wedge1
{
type wedge;
faces
(
(0 3 4 1)
);
}
wedge2
{
type wedge;
faces
(
(0 3 5 2)
);
}
upperWall
{
type wall;
faces
(
(4 5 2 1)
);
}
)
mergePatchPairs
(
);
// ************************************************************************* //
ii) Block

iii) Velocity Profile at a distance of 0.1 m from the Inlet (Before Hydrodynamic Entry Length )

at a distance of 2.52 m from the Inlet ( At the Hydrodynamic Entry Length )

iv) Kinematic Pressure

v) Shear Stress

Boundary Condition: Wedge type
2) Wedge Angle: `25^o`
i) blockMeshDict File
/*--------------------------------*- 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 dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0) // vertice 0
(0.002164 0.009763 0) // vertice 1
(-0.002164 0.009763 0) // vertice 2
(0.000000 0.000000 3.000000) // vertice 3
(0.002164 0.009763 3.000000) // vertice 4
(-0.002164 0.009763 3.000000) // vertice 5
);
blocks
(
hex (0 1 2 0 3 4 5 3)(20 1 200) simpleGrading (1 0.5 1)
);
edges
(
arc 1 2 (0 0.01 0)
arc 4 5(0 0.01 3.00)
);
boundary
(
Inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
Outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
wedge1
{
type wedge;
faces
(
(0 3 4 1)
);
}
wedge2
{
type wedge;
faces
(
(0 3 5 2)
);
}
upperWall
{
type wall;
faces
(
(4 5 2 1)
);
}
)
mergePatchPairs
(
);
// ************************************************************************* //
ii) Block

iii) Velocity Profile at a distance of 2.52 m from the Inlet

iv)Kinematic Pressure

v)Shear Stress

Boundary Condition: Wedge type
3) Wedge Angle: `45^o`
i)blockMeshDict File
/*--------------------------------*- 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 dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0) // vertice 0
(0.003827 0.009239 0) // vertice 1
(-0.003827 0.009239 0) // vertice 2
(0.000000 0.000000 3.000000) // vertice 3
(0.003827 0.009239 3.000000) // vertice 4
(-0.003827 0.009239 3.000000) // vertice 5
);
blocks
(
hex (0 1 2 0 3 4 5 3)(20 1 200) simpleGrading (1 0.5 1)
);
edges
(
arc 1 2 (0 0.01 0)
arc 4 5(0 0.01 3.00)
);
boundary
(
Inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
Outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
wedge1
{
type wedge;
faces
(
(0 3 4 1)
);
}
wedge2
{
type wedge;
faces
(
(0 3 5 2)
);
}
upperWall
{
type wall;
faces
(
(4 5 2 1)
);
}
)
mergePatchPairs
(
);
// ************************************************************************* //
ii) Block

iii) Velocity Profile at a distance of 2.52 m from the Inlet

iv) Kinematic Pressure

v) Shear Stress

Boundary Type: Symmetry Type
The following MATLAB script is used to create a blockMeshDict file where we have changed from the wedge boundary condition to the symmetry type boundary condition.
close all
clear all
clc
% Assumed Values
L=3; % Length of the Pipe
d=0.02; % Diameter Of the Pipe
r=d/2; % Radius of the Pipe
theta=3; % Wedge angle
x= r*sind(theta/2); % X co-ordinate
y= r*cosd(theta/2); % Y co-ordinate
nx=20; % No. of cells in x-direction
ny=1; % No. of cells in y-direction
nz=200; % No. of cells in y-direction
gfx = 1 ; % Grading Factor in x-direction
gfy = 1/2; % Grading Factor in y-direction
gfz = 1 ; % Grading Factor in z-direction
l(1) = "/*--------------------------------*- C++ -*----------------------------------*\";
l(2) = " ========= | ";
l(3) = " \\ / F ield | OpenFOAM: The Open Source CFD Toolbox ";
l(4) = " \\ / O peration | Website: https://openfoam.org ";
l(5) = " \\ / A nd | Version: 8 ";
l(6) = " \\/ M anipulation | ";
l(7) = "\*---------------------------------------------------------------------------*/";
l(8) = "FoamFile ";
l(9) = "{ ";
l(10)= " version 2.0; ";
l(11)= " format ascii; ";
l(12)= " class dictionary; ";
l(13)= " object blockMeshDict; ";
l(14)= "} ";
l(15)= "// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //";
l(16)= " ";
l(17)= "convertToMeters 1; ";
l(18)= " ";
% Vertices
l(19)= "vertices ";
l(20)= "( ";
l(21)= sprintf('(0 0 0) // vertice 0'); % Vertices 0 (0 0 0)
l(22)= sprintf('(%f %f 0) // vertice 1',x,y); % Vertices 1 (x y 0)
l(23)= sprintf('(%f %f 0) // vertice 2',-x,y); % Vertices 2 (-x y 0)
l(24)= sprintf('(%f %f %f) // vertice 3',0,0,L); % Vertices 3 (0 0 L)
l(25)= sprintf('(%f %f %f) // vertice 4',x,y,L); % Vertices 4 (x y L)
l(26)= sprintf('(%f %f %f) // vertice 5',-x,y,L); % Vertices 5 (-x y L)
l(27)=" ); ";
% Hexagonal Block
l(28)="blocks ";
l(29)="( ";
l(30)= sprintf(' hex (0 1 2 0 3 4 5 3)(%d %d %d) simpleGrading (%d %1.1f %d)',nx,ny,nz,gfx,gfy,gfz);
% hex (0 1 2 0 3 4 5 3) (nx ny nz) simpleGrading (gfx,gfy,gfz)
l(31)=" ); ";
% Edges
l(32)="edges ";
l(33)="( ";
l(34)= sprintf(' arc 1 2 (0 %2.2f 0)',r); % Arc Formation
l(35)= sprintf(' arc 4 5(0 %2.2f %2.2f)',r,L); % Arc Formation
l(36)="); ";
l(37)=" boundary ";
l(38)=" ( ";
l(39)=" Inlet ";
l(40)=" { ";
l(41)=" type patch; ";
l(42)=" faces ";
l(43)=" ( ";
l(44)=" (0 1 2 0) ";
l(45)=" ); ";
l(46)=" ";
l(47)=" } ";
l(48)=" Outlet ";
l(49)=" { ";
l(50)=" type patch; ";
l(51)=" faces ";
l(52)=" ( ";
l(53)=" (3 4 5 3) ";
l(54)=" ); ";
l(55)=" } ";
l(56)=" wedge1 ";
l(57)=" { ";
l(58)=" type symmetry; ";
l(59)=" faces ";
l(60)=" ( ";
l(61)=" (0 3 4 1) ";
l(62)=" ); ";
l(63)=" } ";
l(64)=" wedge2 ";
l(65)=" { ";
l(66)=" type symmetry; ";
l(67)=" faces ";
l(68)=" ( ";
l(69)=" (0 3 5 2) ";
l(70)=" ); ";
l(71)=" } ";
l(72)=" upperWall ";
l(73)=" { ";
l(74)=" type wall; ";
l(75)=" faces ";
l(76)=" ( ";
l(77)=" (4 5 2 1) ";
l(78)=" ); ";
l(79)=" } ";
l(80)=" ) ";
l(81)=" mergePatchPairs ";
l(82)=" ( ";
l(83)=" ); ";
l(84)=" ";
l(85)=" // ************************************************************************* // ";
s=size(l);
% blockMeshDict File
blockMeshDict=fopen('blockMeshDict','w');
for i=1:s(2)
fprintf(blockMeshDict,'%s \n',l(i));
end
fclose(blockMeshDict)
Wedge angle: `10^o`
i) blockMeshDict
ii) Velocity Profile at a distance of 2.52 m from the Inlet

iii) Kinematic Pressure

iv) Shear Stress

Wedge angle: `25^o`
i) blockMeshDict
ii) Velocity Profile at a distance of 2.52 m from the Inlet

iii) Kinematic Pressure

iv) Shear Stress

Wedge angle: `45^o`
i) blockMeshDict
ii) Velocity Profile at a distance of 2.52 m from the Inlet

iii) Kinematic Pressure

iv) Shear Stress

Comparison Table
| Maximum Velocity | Kinematic Pressure Drop | Maximum Shear Stress | |
| Wedge Type | |||
| 10 | 0.1857 | 0.02577 | 0.03085 |
| 25 | 0.1862 | 0.02689 | 0.03142 |
| 45 | 0.1873 | 0.02890 | 0.03297 |
| Theoretical Value | 0.1869 | 0.02 | 0.0332 |
| Symmetry Type | |||
| 10 | 0.1824 | 0.02553 | 0.03034 |
| 25 | 0.1831 | 0.02636 | 0.03095 |
| 45 | 0.1852 | 0.02882 | 0.03254 |
Conclusion
We can observe that from all the graphs and comparison tables, we found nearly no difference in the results obtained from the two different boundary conditions for the different blocks. It is because the fundamental physic of the problem is not changed irrespective of the boundary condition.