Week 12 - Validation studies of Symmetry BC vs Wedge BC in OpenFOAM vs Analytical H.P equation
In this project we try to compare the results of Wedge and symmetry boundary condition in openFoam.
Assumption of Pipe Flow:
- We assume the fluid flow to be laminar in nature i.e. Re = 2100 (Reynolds Number).
- At 30*C the water properties are density=995.6 Kg/m^3, Kinematic viscosity =0.801 X 10^(-6), Dynamic viscosity = 0.798 X 10^(-3).
- Assume the Diameter of the pipe to be D = 0.0127m.
- Inorder to decide the length of the pipe
`L=0.06*Re*D` `implies L=0.06*2100*0.0127 = 1.6002m`
At `L>=1.6002m` the velocity profile is fully developed
- flow Velocity `Vavg=(Re*nu)/D=(2100*0.801*10^(-6))/0.0127=0.13244m/s`
Since the flow is incompressible, laminar, transisent we choose icoFoam as the solver. The icoFoam solver makes use of the PISO (pressure implicit with splitting operator) algorithm. This algorithm involves pressure velocity calculation for Navier stokes equation with one predictor step and two corrector step.
Inorder to solve the laminar flow through the entire pipe it would increase the computer resource. So to avoid it and take advantage of the axis symmetry nature of the pipe we tend to solve a part of the pipe, to simulate the pipe flow and evaluate its result.
Here, we use two types of boundary condition and compare the result with the analytical solution.
Wedge Boundary Condition :
This condition accepts the theta value less than 5 deg, so we simulate the solution for theta values of 4, 2, 1 degree.
For 4 Degree Wedge Boundary Condition:
Geometry & Meshing:
- Wedge boundary condition is used where the simulation geometry is axissymmetry in nature and to avoid computer resource in solving the entire pipe profile eventhough the result is gonna be the same.
- The pipe is divided into 800cells along the length of the pipe and 20cells along the radial direction of the pipe.
2 Degree Wedge angle

1 Degree Wedge angle

4 Degree Wedge angle

Wedge inlet

Wedge Outlet

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.000000 0.000000 0.000000)
(0.000000 0.006346 -0.000222)
(0.000000 0.006346 0.000222)
(1.600200 0.000000 0.000000)
(1.600200 0.006346 -0.000222)
(1.600200 0.006346 0.000222)
);
blocks
(
hex (0 3 4 1 0 3 5 2) (800 20 1) simpleGrading (0.1 0.1 1)
);
edges
(
arc 1 2 (0 0.0064 0)
arc 4 5 (1.6002 0.0064 0)
);
boundary
(
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
pipe_wall
{
type wall;
faces
(
(2 5 4 1)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
front
{
type wedge;
faces
(
(0 3 5 2)
);
}
back
{
type wedge;
faces
(
(0 1 4 3)
);
}
);
mergePatchPairs
(
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
p file : In subsonic condition the static pressure at the outlet is assumed to be P=0 and at the inlet zeroGradient boundary condition is provided which extrapolates the values from the neighbouring cells.
/*--------------------------------*- 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
{
axis
{
type empty;
}
pipe_wall
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
inlet
{
type zeroGradient;
}
front
{
type wedge;
}
back
{
type wedge;
}
}
// ************************************************************************* //
U file :
- The inlet is provided with the fixedValue and outlet with zeroGradient condition which extrapolates the value of the neighbouring outlet cell to the patch.
- At the pipe wall noSlip condition is provided i.e. V=0.
- The inclined wedge angled boundaries are given a special boundary type called ‘Wedge’. The wedge boundary takes into considereation the axis symmetrical condition and interpolates the resuts accordingly.
- The axis of the pipe is given ‘empty’ boundary condition as this part of the face is collapsed to create the wedge geometry. Information from this part of he plane is not needed hence empty condition is applied here.
/*--------------------------------*- 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.13244 0 0);
boundaryField
{
axis
{
type empty;
}
pipe_wall
{
type noSlip;
}
inlet
{
type fixedValue;
value uniform (0.13244 0 0);
}
outlet
{
type zeroGradient;
}
front
{
type wedge;
}
back
{
type wedge;
}
}
// ************************************************************************* //
transportProperties file: In this project water is used as working fluid which is the newtonian fluid, icoFoam is used us solver which takes kinematic viscosity as constant value.
/*--------------------------------*- 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] 0.801e-6;
// ************************************************************************* //
controlDict file :
- For the accurate result it is said that fluid should pass through the pipe atleast 10 times.
- Total time to solve the simulation is decided by the `t=n*L/(Vavg)=10*1.6002/.13244=120.82sec~121Sec`
- Timestep for stable solution is obtained when the courant no. is 1.
- `dx=L/(Numberof cells)=1.6002/800=0.002`
- `dt=(Co*dx)/(Vavg)=(1*0.002)/0.13244=0.0151``dt<0.0151 implies dt=0.005`
/*--------------------------------*- 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 121;
deltaT 0.001;
writeControl timeStep;
writeInterval 10000;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
Result:
- Similarly 2, 1 Degree condition can be solved, for which only the blockMeshDict file vertices values need to be changed.
- Shear stress value can be obtained by post processing the results through openFoam.
- Using the plot over line is used to plot the results obtained.
- shear stress `tau =mu * (delp)/(delx)`
1 Degree Wedge

2 Degree Wedge

4 Degree Wedge

Conclusion_1: from the results of 4, 2, 1 degree angles of the wedge we could conclude
- max Velocity results when compared, as the angle decreases the % error increases.
- Pressure drop across the pipe length, as the angle decreases the % error decreases.
- Shear Stress on pipe wall, as the angle decreases the % error increases.
- simulation time, as the angle is dereased the time as well decreses.

Symmetry Boundary Condition:
- This boundary condition is used when the solution can be mirrored across the boundary.
- Through this boundary condition flux across the bondary is zero and the normal gradient of all the variable is zero.
Geometry & Meshing:
10 Degree symmetry condition
22 Degree symmetry condition 45 Degree symmetry condition

Inlet boundary condition 
Outlet boundary condition

for 45 Degree symmetry boundary condition
Matlab blockMeshDict code file:
clear all
close all
clc
% definng the value for laminar flow
Re=2100; %reynolds number
D=0.0127; %diameter
R=D/2; %radius
theta=45; %theta
l=0.06*Re*D; %hydrodynamic entrance length
l_c=l+0.3; %characteristic length
mu=.798e-3; % dynamic viscosity
rho=995.6; %density of water
nu=mu/rho; %kinematic viscosity
v_avg=Re*nu/D; %average velocity
v_max=2*v_avg; %maximum velocity
f=64/Re; %darcy friction factor
delta_p=32*mu*v_avg*l/D^2; %pressure loss
%vertices
v0=[0 0 0];
v1=[0 R*cosd(0.5*theta) -R*sind(0.5*theta)];
v2=[0 R*cosd(0.5*theta) R*sind(0.5*theta)];
v3=[l 0 0];
v4=[l R*cosd(0.5*theta) -R*sind(0.5*theta)];
v5=[l R*cosd(0.5*theta) R*sind(0.5*theta)];
%writing the blockmeshDict file
%createing permission to write blockmeshDict file
f1=fopen('blockMeshDict.txt','w');
%header file
fprintf(f1,'%s','/*--------------------------------*- C++ -*----------------------------------*\');
fprintf(f1,'\n');
fprintf(f1,'%s',' ========= |');
fprintf(f1,'\n');
fprintf(f1,' \\ / F ield | OpenFOAM: The Open Source CFD Toolbox');
fprintf(f1,'\n');
fprintf(f1,' \\ / O peration | Website: https://openfoam.org');
fprintf(f1,'\n');
fprintf(f1,' \\ / A nd | Version: 9');
fprintf(f1,'\n');
fprintf(f1,' \\/ M anipulation |');
fprintf(f1,'\n');
fprintf(f1,'%s','\*---------------------------------------------------------------------------*/');
fprintf(f1,'\n');
fprintf(f1,'FoamFile');
fprintf(f1,'\n');
fprintf(f1,'{');
fprintf(f1,'\n');
fprintf(f1,' format ascii;');
fprintf(f1,'\n');
fprintf(f1,' class dictionary;');
fprintf(f1,'\n');
fprintf(f1,' object blockMeshDict;');
fprintf(f1,'\n');
fprintf(f1,'}');
fprintf(f1,'\n');
fprintf(f1,'// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //');
fprintf(f1,'\n');
fprintf(f1,'\n');
fprintf(f1,'convertToMeters 1;\n');
fprintf(f1,'\n');
fprintf(f1,'vertices');
fprintf(f1,'\n');
fprintf(f1,'(');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'(');
fprintf(f1,'%f %f %f',v0(1),v0(2),v0(3));
fprintf(f1,')');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'(');
fprintf(f1,'%f %f %f',v1(1),v1(2),v1(3));
fprintf(f1,')');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'(');
fprintf(f1,'%f %f %f',v2(1),v2(2),v2(3));
fprintf(f1,')');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'(');
fprintf(f1,'%f %f %f',v3(1),v3(2),v3(3));
fprintf(f1,')');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'(');
fprintf(f1,'%f %f %f',v4(1),v4(2),v4(3));
fprintf(f1,')');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'(');
fprintf(f1,'%f %f %f',v5(1),v5(2),v5(3));
fprintf(f1,')');
fprintf(f1,'\n');
fprintf(f1,');');
fprintf(f1,'\n');
fprintf(f1,'\n');
fprintf(f1,'blocks');
fprintf(f1,'\n');
fprintf(f1,'(');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'hex (0 3 4 1 0 3 5 2) (800 20 1) simpleGrading (0.1 0.1 1)');
fprintf(f1,'\n');
fprintf(f1,');');
fprintf(f1,'\n');
fprintf(f1,'\n');
fprintf(f1,'edges');
fprintf(f1,'\n');
fprintf(f1,'(');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'arc 1 2 (0 0.0064 0)');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'arc 4 5 (1.6002 0.0064 0)');
fprintf(f1,'\n');
fprintf(f1,');');
fprintf(f1,'\n');
fprintf(f1,'\n');
fprintf(f1,'boundary');
fprintf(f1,'\n');
fprintf(f1,'(');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'axis');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'{');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),'type empty;');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),'faces');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),'(');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(12),'(0 3 3 0)');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),');');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'}');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'pipe_wall');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'{');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),'type wall;');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),'faces');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),'(');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(12),'(1 4 5 2)');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),');');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'}');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'outlet');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'{');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),'type patch;');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),'faces');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),'(');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(12),'(3 4 5 3)');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),');');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'}');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'inlet');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'{');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),'type patch;');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),'faces');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),'(');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(12),'(0 1 2 0)');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),');');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'}');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'front');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'{');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),'type symmetry;');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),'faces');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),'(');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(12),'(0 3 5 2)');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),');');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'}');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'back');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'{');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),'type symmetry;');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),'faces');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),'(');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(12),'(0 1 4 3)');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(8),');');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(4),'}');
fprintf(f1,'\n');
fprintf(f1,');');
fprintf(f1,'\n');
fprintf(f1,'\n');
fprintf(f1,'mergePatchPairs');
fprintf(f1,'\n');
fprintf(f1,'(');
fprintf(f1,'\n');
fprintf(f1,');');
fprintf(f1,'\n');
fprintf(f1,'\n');
fprintf(f1,'// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //');
f1=fclose('all');
% shear stress calculation
r=linspace(0,R,100);
for i=1:length(r)
x(i)=(4*mu*v_avg*r(i));
tau(i)=x(i)/R^2;
end
figure (1)
plot (r,tau,'linewidth',2);
title('shear stress vs Radial distance');
ylabel('Radial Distance (m)');
xlabel('shear Stress');
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.000000 0.000000 0.000000)
(0.000000 0.005867 -0.002430)
(0.000000 0.005867 0.002430)
(1.600200 0.000000 0.000000)
(1.600200 0.005867 -0.002430)
(1.600200 0.005867 0.002430)
);
blocks
(
hex (0 3 4 1 0 3 5 2) (800 20 1) simpleGrading (0.1 0.1 1)
);
edges
(
arc 1 2 (0 0.0064 0)
arc 4 5 (1.6002 0.0064 0)
);
boundary
(
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
pipe_wall
{
type wall;
faces
(
(2 5 4 1)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
front
{
type symmetry;
faces
(
(0 3 5 2)
);
}
back
{
type symmetry;
faces
(
(0 1 4 3)
);
}
);
mergePatchPairs
(
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
p 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
{
axis
{
type empty;
}
pipe_wall
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
inlet
{
type zeroGradient;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
}
// ************************************************************************* //
U 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.13244 0 0);
boundaryField
{
axis
{
type empty;
}
pipe_wall
{
type noSlip;
}
inlet
{
type fixedValue;
value uniform (0.13244 0 0);
}
outlet
{
type zeroGradient;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
}
// ************************************************************************* //
transportProperties 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 "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nu [0 2 -1 0 0 0 0] 0.801e-6;
// ************************************************************************* //
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 121;
deltaT 0.001;
writeControl timeStep;
writeInterval 10000;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
Result_2:
- Similarly 22, 10 Degree condition can be solved, for which only the blockMeshDict file vertices values need to be changed.
- Shear stress value can be obtained by post processing the results through openFoam.
- Using the plot over line is used to plot the results obtained.
- shear stress `tau =mu * (delp)/(delx)`
10 Degree Symmetry condition

22 Degree Symmetry Condition

45 Degree Symmetry Condition

Conclusion_2: from the results of 10, 22, 45 degree angles of the symmetry condition we could conclude
- max Velocity results when compared, as the angle decreases the % error increases.
- Pressure drop across the pipe length, as the angle decreases the % error decreases.
- Shear Stress on pipe wall, as the angle decreases the % error decreases.
- simulation time, as the angle is dereased there is not much change in time.

Output:
- From both the boundary condition we can conclude that % error for max. Velocity is less with the symmetry condition. Within which as the angle increses % error is less.
- Simulation run time is larger for symmetry condition then wedge boundary condition.