Week 12 - Symmetry vs Wedge vs HP equation
Objective: To compare the results of Symmetry vs Wedge Vs HP equation.
Description:
The subject of boundaries is quite complex because their role in modelling is not simply that of a geometric entity but an integral part of the solution and numerics through boundary conditions or inter-boundary ‘connections’. A discussion of boundaries sits uncomfortably between a discussion on meshes, fields, discretisation, computational processing etc.
We first need to consider that, for the purpose of applying boundary conditions, a boundary is generally broken up into a set of patches. One patch may include one or more enclosed areas of the boundary surface which do not necessarily need to be physically connected. A type is assigned to every patch as part of the mesh description, as part of the boundary file. It describes the type of patch in terms of geometry or a data ‘communication link’. An example boundary file is shown below for a icoFoam case. A type entry is clearly included for every patch (inlet, outlet, etc. ), with types assigned that include patch, symmetry, wedge and empty.
Wedge:
For 2 dimensional axi-symmetric cases, wedge type boundary condition is used e.g. a cylinder, the geometry is specified as a wedge of small angle and 1 cell thick running along the plane of symmetry, straddling one of the coordinate planes. The axi-symmetric wedge planes must be specified as separate patches of wedge type. The angle of wedge should be `<5^o`
Symmetry:
It is similar to that of wedge boundary condition in terms of function in addition it is used for any non-planar or 3 dimensional patch which uses the symmetry condition. No angular limit between the two symmetry planes in axi-symmetry problems as in wedge case.
Hagen–Poiseuille law:
Hagen–Poiseuille flow (or simply Poiseuille flow) is applicable to a variety of applications ranging from macroscopic pipes in industries to the flow of blood in veins. This project presents the simulation of Hagen–Poiseuille Flow (Laminar-Incompressible Flow) through a pipe having constant circular cross-section throughout the length. The whole report can be divided into two sections:
The former part aims to implement automation in the generation of computational mesh file, time-control file, and other necessary script files (later, these will be used by OpenFOAM to run the simulation) using MATLAB. As the flow has axis-symmetrical nature, only a reduced model is considered instead of entire circular pipe, thus reducing computational efforts extensively.
In the latter part, the CFD analysis is performed using an open-source CFD toolbox- OpenFOAM®, which utilized all the previously generated scripts files.
This project is principally focused to compare the results of Analytical obtained using HP law and Numerical solution obtained using different boundary conditions (wedge and symmetry), assuring the fidelity of the numerical results. Besides, this report includes the variation of velocity profile and pressure drop at different cross-sections throughout the length, and it also aimed to calculate the shear stress profiles as a part of post-processing results.
Matlab Code to generate openFoam files:
Main code:
close all
clear all
clc
s = 1; %scaling factor
L = 5; %Length of pipe
r = 0.015; %Radius of pipe
wedge_angle = 4; %Angle of wedge wrt axis
%assign zero no wedge angled script is needed
symmetry_angle = 4; %Angle of symmetry wrt axis
%assign zero if no symmetry angled script is needed
rho = 997; %density of working fluid
Re =2100; %renolds number
dx = 20; %Number of cells in X-direction
dy = 1; %Number of cells in y-direction
%increase the dy with increase in angle to see curved border of pipe
dz = 500; %Number of cells in z-direction
Xsg = 0.3; %Simple grading along X-direction
Ysg = 1; %Simple grading along Y-direction
Zsg = 1; %Simple grading along Z-direction
t = 210; %End time
dt = 0.001; %Time step
i =50; %writing interval
mu = 0.997*10^(-3);
if wedge_angle>0
FOAMscripts_wedge(s,L,r,wedge_angle,rho,Re,dx,dy,dz,Xsg,Ysg,Zsg,t,dt,i,mu)
end
if symmetry_angle>0
FOAMscripts_symmetry(s,L,r,symmetry_angle,rho,Re,dx,dy,dz,Xsg,Ysg,Zsg,t,dt,i,mu)
end
Function codes for wedge and symmetry boundary condition
function FOAMscripts_wedge(s,L,r,wedge_angle,rho,Re,dx,dy,dz,Xsg,Ysg,Zsg,t,dt,i,mu)
nue = mu/rho; %kinematic viscosity
v = (Re*nue)/(2*r); %Velocity
x1 = r*cosd(wedge_angle);
y1 = r*sind(wedge_angle);
z1 = 0;
x2 = r*cosd(360-wedge_angle);
y2 = r*sind(360-wedge_angle);
z2 = L;
%common header lines
line1='/*--------------------------------*-C++ -*--------------------------------*\';
line2=' ========= | ';
line3=' \\ / F ield | OpenFOAM: The Open Source CFD Toolbox ';
line4=' \\ / O peration | Website: https://openfoam.org ';
line5=' \\ / A nd | Version: 8 ';
line6=' \\/ M anipulation | ';
line7='\*-------------------------------------------------------------------------*/';
line8='FoamFile';
line9='// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //';
mkdir 'Flow_through_a_pipe_wedge';
mkdir 'Flow_through_a_pipe_wedge' 'system';
mkdir 'Flow_through_a_pipe_wedge' 'constant';
mkdir 'Flow_through_a_pipe_wedge' '0';
%% blockmeshdict
f=fopen('Flow_through_a_pipe_wedge\system\blockMeshDict','w');
fprintf(f,'%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n{\n%s\n%s\n%s\n',line1,line2,line3,line4,line5,line6,line7,line8);
fprintf(f,'\tversion \t2.0;\n\tformat \tascii;\n\tclass \t\tdictionary;\n\tobject \tblockMeshDict;\n}\n');
%starting line
fprintf(f,'%s',line9);
%defining scaling factor
fprintf(f,'\n\nconvertToMeters %d;\n\n',s);
%defining vertices
fprintf(f,'vertices\n(\n\n\t(0 0 0)\n\t(%f %f %f)\n\t(%f %f %f)\n\t(0 0 %f)\n\t(%f %f %f)\n\t(%f %f %f)\n);\n',x1,y1,z1,x1,y1,z2,z2,x2,y2,z1,x2,y2,z2);
%defining blocks
fprintf(f,'\nblocks\n(\n\thex (0 4 1 0 3 5 2 3) (%d %d %d) simpleGrading (%f %f %f)\n);\n',dx,dy,dz,Xsg,Ysg,Zsg);
%defining edges
fprintf(f,'\nedges\n(\n\tarc 1 4 (%f %f %f)\n\tarc 2 5 (%f %f %f)\n);\n',x1/2,y1/2,z1,x2/2,y2/2,z2);
%defining boundaries
fprintf(f,'\nboundary\n(\n\n\taxis\n\t{\n\t\ttype empty;\n\t\tfaces\n\t\t(\n\t\t\t(0 3 3 0)\n\t\t);\n\t}\n');
fprintf(f,'\tinlet\n\t{\n\t\ttype patch;\n\t\tfaces\n\t\t(\n\t\t\t(0 4 1 0)\n\t\t);\n\t}\n');
fprintf(f,'\toutlet\n\t{\n\t\ttype patch;\n\t\tfaces\n\t\t(\n\t\t\t(3 5 2 3)\n\t\t);\n\t}\n');
fprintf(f,'\tleftwall\n\t{\n\t\ttype wedge;\n\t\tfaces\n\t\t(\n\t\t\t(4 0 3 5)\n\t\t);\n\t}\n');
fprintf(f,'\trightwall\n\t{\n\t\ttype wedge;\n\t\tfaces\n\t\t(\n\t\t\t(0 1 2 3)\n\t\t);\n\t}\n');
fprintf(f,'\touterwall\n\t{\n\t\ttype wall;\n\t\tfaces\n\t\t(\n\t\t\t(1 4 5 2)\n\t\t);\n\t}\n\n\n);\n');
%defining patch pairs
fprintf(f,'\nmergePatchPairs\n(\n);\n');
%ending line
fprintf(f,'\n%s',line9);
fclose(f);
%% control dict
f=fopen('Flow_through_a_pipe_wedge\system\controlDict','w');
fprintf(f,'%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n{\n%s\n%s\n%s\n',line1,line2,line3,line4,line5,line6,line7,line8);
fprintf(f,'\tversion \t2.0;\n\tformat \t\tascii;\n\tclass \t\tdictionary;\n\tlocation\t"system";\n\tobject \t\tcontrolDict;\n}\n');
%starting line
fprintf(f,'%s\n',line9);
fprintf(f,'\napplication\ticoFoam;\n\nstartFrom\tstartTime;\n\nstartTime\t0;\n\nstopAt\t\tendTime;\n\nendTime\t\t%f;\n\ndeltaT\t\t%fs;',t,dt);
fprintf(f,'\n\nwriteControl\ttimeStep;\n\nwriteInterval\t%d;\n\npurgeWrite\t0;\n\nwriteFormat\tascii;\n\nwritePrecision\t6;\n\nwriteCompression\toff;\n\ntimeFormat\tgeneral;\n\ntimePrecision\t6;\n\nrunTimeModifiable\ttrue;',i);
%ending line
fprintf(f,'\n\n%s',line9);
fclose(f);
%% fvSchemes
f=fopen('Flow_through_a_pipe_wedge\system\fvSchemes','w');
fprintf(f,'%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n{\n%s\n%s\n%s\n',line1,line2,line3,line4,line5,line6,line7,line8);
fprintf(f,'\tversion \t2.0;\n\tformat \t\tascii;\n\tclass \t\tdictionary;\n\tlocation\t"system";\n\tobject \t\tfvSchemes;\n}\n');
%starting line
fprintf(f,'%s\n',line9);
fprintf(f,'\nddtSchemes\n{\n\tdefault\t\tEuler;\n}\n\ngradSchemes\n{\n\tdefault\t\tGauss linear;\n\tgrad(p)\t\tGauss linear;\n}\n\ndivSchemes\n{\n\tdefault\t\tnone;\n\tdiv(phi,U)\tGauss linear;\n}\n\n');
fprintf(f,'laplacianSchemes\n{\n\tdefault\t\tGauss linear orthogonal;\n}\n\ninterpolationSchemes\n{\n\tdefault\t\tlinear;\n}\n\nsnGradSchemes\n{\n\tdefault\t\torthogonal;\n}');
%ending line
fprintf(f,'\n\n%s',line9);
fclose(f);
%% fvSolution
f=fopen('Flow_through_a_pipe_wedge\system\fvSolution','w');
fprintf(f,'%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n{\n%s\n%s\n%s\n',line1,line2,line3,line4,line5,line6,line7,line8);
fprintf(f,'\tversion \t2.0;\n\tformat \t\tascii;\n\tclass \t\tdictionary;\n\tlocation\t"system";\n\tobject \t\tfvSolution;\n}\n');
%starting line
fprintf(f,'%s\n',line9);
fprintf(f,'\nsolvers\n{\n\tp\n\t{\n\t\tsolver\t\tPCG;\n\t\tpreconditioner\tDIC;\n\t\ttolerance\t1e-06;\n\t\trelTol\t\t0.05;\n\t}\n');
fprintf(f,'\n\tpFinal\n\t{\n\t\t$p;\n\t\trelTol\t\t0;\n\t}\n\n\tU\n\t{\n\t\tsolver\t\tsmoothSolver;\n\t\tsmoother\tsymGaussSeidel;\n\t\ttolerance\t1e-05;\n\t\trelTol\t\t0;\n\t}\n}\n');
fprintf(f,'\nPISO\n{\n\tnCorrectors\t2;\n\tnNonOrthogonalCorrectors\t0;\n\tpRefCell\t0;\n\tpRefValue\t0;\n}');
%ending line
fprintf(f,'\n\n%s',line9);
fclose(f);
%% transport properties
f=fopen('Flow_through_a_pipe_wedge\constant\transportProperties','w');
fprintf(f,'%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n{\n%s\n%s\n%s\n',line1,line2,line3,line4,line5,line6,line7,line8);
fprintf(f,'\tversion \t2.0;\n\tformat \t\tascii;\n\tclass \t\tdictionary;\n\tlocation\t"constant";\n\tobject \t\ttransportProperties;\n}\n');
%starting line
fprintf(f,'%s\n',line9);
%defining kinematic viscosity of water
fprintf(f,'\nnu\t\t[0 2 -1 0 0 0 0] %f;\n',nue);
%ending line
fprintf(f,'\n%s',line9);
fclose(f);
%% pressure
f=fopen('Flow_through_a_pipe_wedge\0\p','w');
fprintf(f,'%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n{\n%s\n%s\n%s\n',line1,line2,line3,line4,line5,line6,line7,line8);
fprintf(f,'\tversion \t2.0;\n\tformat \t\tascii;\n\tclass \t\tvolScalarField;\n\tobject \t\tP;\n}\n');
%starting line
fprintf(f,'%s\n',line9);
%defining pressure conditions
fprintf(f,'\ndimensions\t[0 2 -2 0 0 0 0];\n\ninternalField\tuniform 0;\n\nboundaryField\n{\n');
fprintf(f,'\tinlet\n\t{\n\t\ttype\tzeroGradient;\n\t}\n\toutlet\n\t{\n\t\ttype\tfixedValue;\n\t\tvalue\tuniform 0;\n\t}');
fprintf(f,'\n\taxis\n\t{\n\t\ttype\tempty;\n\t}\n\tleftwall\n\t{\n\t\ttype\twedge;\n\t}\n\trightwall\n\t{\n\t\ttype\twedge;\n\t}\n\touterwall\n\t{\n\t\ttype\tzeroGradient;\n\t}\n\n}');
%ending line
fprintf(f,'\n%s',line9);
fclose(f);
%% velocity
f=fopen('Flow_through_a_pipe_wedge\0\U','w');
fprintf(f,'%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n{\n%s\n%s\n%s\n',line1,line2,line3,line4,line5,line6,line7,line8);
fprintf(f,'\tversion \t2.0;\n\tformat \t\tascii;\n\tclass \t\tvolVectorField;\n\tobject \t\tU;\n}\n');
%starting line
fprintf(f,'%s\n',line9);
%defining velocity conditions
fprintf(f,'\ndimensions\t[0 1 -1 0 0 0 0];\n\ninternalField\tuniform (0 0 0);\n\nboundaryField\n{\n');
fprintf(f,'\toutlet\n\t{\n\t\ttype\tzeroGradient;\n\t}\n\tinlet\n\t{\n\t\ttype\tfixedValue;\n\t\tvalue\tuniform (0 0 %f);\n\t}',v);
fprintf(f,'\n\taxis\n\t{\n\t\ttype\tempty;\n\t}\n\tleftwall\n\t{\n\t\ttype\twedge;\n\t}\n\trightwall\n\t{\n\t\ttype\twedge;\n\t}\n\touterwall\n\t{\n\t\ttype\tnoSlip;\n\t}\n\n}');
%ending line
fprintf(f,'\n%s',line9);
fclose(f);
function FOAMscripts_symmetry(s,L,r,symmetry_angle,rho,Re,dx,dy,dz,Xsg,Ysg,Zsg,t,dt,i,mu)
nue = mu/rho; %kinematic viscosity
v = (Re*nue)/(2*r); %Velocity
x1 = r*cosd(symmetry_angle);
y1 = r*sind(symmetry_angle);
z1 = 0;
x2 = r*cosd(360-symmetry_angle);
y2 = r*sind(360-symmetry_angle);
z2 = L;
%common header lines
line1='/*--------------------------------*-C++ -*--------------------------------*\';
line2=' ========= | ';
line3=' \\ / F ield | OpenFOAM: The Open Source CFD Toolbox ';
line4=' \\ / O peration | Website: https://openfoam.org ';
line5=' \\ / A nd | Version: 8 ';
line6=' \\/ M anipulation | ';
line7='\*-------------------------------------------------------------------------*/';
line8='FoamFile';
line9='// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //';
mkdir 'Flow_through_a_pipe_symmetry';
mkdir 'Flow_through_a_pipe_symmetry' 'system';
mkdir 'Flow_through_a_pipe_symmetry' 'constant';
mkdir 'Flow_through_a_pipe_symmetry' '0';
%% blockmeshdict
f=fopen('Flow_through_a_pipe_symmetry\system\blockMeshDict','w');
fprintf(f,'%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n{\n%s\n%s\n%s\n',line1,line2,line3,line4,line5,line6,line7,line8);
fprintf(f,'\tversion \t2.0;\n\tformat \tascii;\n\tclass \t\tdictionary;\n\tobject \tblockMeshDict;\n}\n');
%starting line
fprintf(f,'%s',line9);
%defining scaling factor
fprintf(f,'\n\nconvertToMeters %d;\n\n',s);
%defining vertices
fprintf(f,'vertices\n(\n\n\t(0 0 0)\n\t(%f %f %f)\n\t(%f %f %f)\n\t(0 0 %f)\n\t(%f %f %f)\n\t(%f %f %f)\n);\n',x1,y1,z1,x1,y1,z2,z2,x2,y2,z1,x2,y2,z2);
%defining blocks
fprintf(f,'\nblocks\n(\n\thex (0 4 1 0 3 5 2 3) (%d %d %d) simpleGrading (%f %f %f)\n);\n',dx,dy,dz,Xsg,Ysg,Zsg);
%defining edges
fprintf(f,'\nedges\n(\n\tarc 1 4 (%f %f %f)\n\tarc 2 5 (%f %f %f)\n);\n',x1/2,y1/2,z1,x2/2,y2/2,z2);
%defining boundaries
fprintf(f,'\nboundary\n(\n\n\taxis\n\t{\n\t\ttype empty;\n\t\tfaces\n\t\t(\n\t\t\t(0 3 3 0)\n\t\t);\n\t}\n');
fprintf(f,'\tinlet\n\t{\n\t\ttype patch;\n\t\tfaces\n\t\t(\n\t\t\t(0 4 1 0)\n\t\t);\n\t}\n');
fprintf(f,'\toutlet\n\t{\n\t\ttype patch;\n\t\tfaces\n\t\t(\n\t\t\t(3 5 2 3)\n\t\t);\n\t}\n');
fprintf(f,'\tleftwall\n\t{\n\t\ttype symmetry;\n\t\tfaces\n\t\t(\n\t\t\t(4 0 3 5)\n\t\t);\n\t}\n');
fprintf(f,'\trightwall\n\t{\n\t\ttype symmetry;\n\t\tfaces\n\t\t(\n\t\t\t(0 1 2 3)\n\t\t);\n\t}\n');
fprintf(f,'\touterwall\n\t{\n\t\ttype wall;\n\t\tfaces\n\t\t(\n\t\t\t(1 4 5 2)\n\t\t);\n\t}\n\n\n);\n');
%defining patch pairs
fprintf(f,'\nmergePatchPairs\n(\n);\n');
%ending line
fprintf(f,'\n%s',line9);
fclose(f);
%% control dict
f=fopen('Flow_through_a_pipe_symmetry\system\controlDict','w');
fprintf(f,'%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n{\n%s\n%s\n%s\n',line1,line2,line3,line4,line5,line6,line7,line8);
fprintf(f,'\tversion \t2.0;\n\tformat \t\tascii;\n\tclass \t\tdictionary;\n\tlocation\t"system";\n\tobject \t\tcontrolDict;\n}\n');
%starting line
fprintf(f,'%s\n',line9);
fprintf(f,'\napplication\ticoFoam;\n\nstartFrom\tstartTime;\n\nstartTime\t0;\n\nstopAt\t\tendTime;\n\nendTime\t\t%f;\n\ndeltaT\t\t%fs;',t,dt);
fprintf(f,'\n\nwriteControl\ttimeStep;\n\nwriteInterval\t%d;\n\npurgeWrite\t0;\n\nwriteFormat\tascii;\n\nwritePrecision\t6;\n\nwriteCompression\toff;\n\ntimeFormat\tgeneral;\n\ntimePrecision\t6;\n\nrunTimeModifiable\ttrue;',i);
%ending line
fprintf(f,'\n\n%s',line9);
fclose(f);
%% fvSchemes
f=fopen('Flow_through_a_pipe_symmetry\system\fvSchemes','w');
fprintf(f,'%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n{\n%s\n%s\n%s\n',line1,line2,line3,line4,line5,line6,line7,line8);
fprintf(f,'\tversion \t2.0;\n\tformat \t\tascii;\n\tclass \t\tdictionary;\n\tlocation\t"system";\n\tobject \t\tfvSchemes;\n}\n');
%starting line
fprintf(f,'%s\n',line9);
fprintf(f,'\nddtSchemes\n{\n\tdefault\t\tEuler;\n}\n\ngradSchemes\n{\n\tdefault\t\tGauss linear;\n\tgrad(p)\t\tGauss linear;\n}\n\ndivSchemes\n{\n\tdefault\t\tnone;\n\tdiv(phi,U)\tGauss linear;\n}\n\n');
fprintf(f,'laplacianSchemes\n{\n\tdefault\t\tGauss linear orthogonal;\n}\n\ninterpolationSchemes\n{\n\tdefault\t\tlinear;\n}\n\nsnGradSchemes\n{\n\tdefault\t\torthogonal;\n}');
%ending line
fprintf(f,'\n\n%s',line9);
fclose(f);
%% fvSolution
f=fopen('Flow_through_a_pipe_symmetry\system\fvSolution','w');
fprintf(f,'%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n{\n%s\n%s\n%s\n',line1,line2,line3,line4,line5,line6,line7,line8);
fprintf(f,'\tversion \t2.0;\n\tformat \t\tascii;\n\tclass \t\tdictionary;\n\tlocation\t"system";\n\tobject \t\tfvSolution;\n}\n');
%starting line
fprintf(f,'%s\n',line9);
fprintf(f,'\nsolvers\n{\n\tp\n\t{\n\t\tsolver\t\tPCG;\n\t\tpreconditioner\tDIC;\n\t\ttolerance\t1e-06;\n\t\trelTol\t\t0.05;\n\t}\n');
fprintf(f,'\n\tpFinal\n\t{\n\t\t$p;\n\t\trelTol\t\t0;\n\t}\n\n\tU\n\t{\n\t\tsolver\t\tsmoothSolver;\n\t\tsmoother\tsymGaussSeidel;\n\t\ttolerance\t1e-05;\n\t\trelTol\t\t0;\n\t}\n}\n');
fprintf(f,'\nPISO\n{\n\tnCorrectors\t2;\n\tnNonOrthogonalCorrectors\t0;\n\tpRefCell\t0;\n\tpRefValue\t0;\n}');
%ending line
fprintf(f,'\n\n%s',line9);
fclose(f);
%% transport properties
f=fopen('Flow_through_a_pipe_symmetry\constant\transportProperties','w');
fprintf(f,'%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n{\n%s\n%s\n%s\n',line1,line2,line3,line4,line5,line6,line7,line8);
fprintf(f,'\tversion \t2.0;\n\tformat \t\tascii;\n\tclass \t\tdictionary;\n\tlocation\t"constant";\n\tobject \t\ttransportProperties;\n}\n');
%starting line
fprintf(f,'%s\n',line9);
%defining kinematic viscosity of water
fprintf(f,'\nnu\t\t[0 2 -1 0 0 0 0] %f;\n',nue);
%ending line
fprintf(f,'\n%s',line9);
fclose(f);
%% pressure
f=fopen('Flow_through_a_pipe_symmetry\0\p','w');
fprintf(f,'%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n{\n%s\n%s\n%s\n',line1,line2,line3,line4,line5,line6,line7,line8);
fprintf(f,'\tversion \t2.0;\n\tformat \t\tascii;\n\tclass \t\tvolScalarField;\n\tobject \t\tP;\n}\n');
%starting line
fprintf(f,'%s\n',line9);
%defining pressure conditions
fprintf(f,'\ndimensions\t[0 2 -2 0 0 0 0];\n\ninternalField\tuniform 0;\n\nboundaryField\n{\n');
fprintf(f,'\tinlet\n\t{\n\t\ttype\tzeroGradient;\n\t}\n\toutlet\n\t{\n\t\ttype\tfixedValue;\n\t\tvalue\tuniform 0;\n\t}');
fprintf(f,'\n\taxis\n\t{\n\t\ttype\tempty;\n\t}\n\tleftwall\n\t{\n\t\ttype\tsymmetry;\n\t}\n\trightwall\n\t{\n\t\ttype\tsymmetry;\n\t}\n\touterwall\n\t{\n\t\ttype\tzeroGradient;\n\t}\n\n}');
%ending line
fprintf(f,'\n%s',line9);
fclose(f);
%% velocity
f=fopen('Flow_through_a_pipe_symmetry\0\U','w');
fprintf(f,'%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n{\n%s\n%s\n%s\n',line1,line2,line3,line4,line5,line6,line7,line8);
fprintf(f,'\tversion \t2.0;\n\tformat \t\tascii;\n\tclass \t\tvolVectorField;\n\tobject \t\tU;\n}\n');
%starting line
fprintf(f,'%s\n',line9);
%defining velocity conditions
fprintf(f,'\ndimensions\t[0 1 -1 0 0 0 0];\n\ninternalField\tuniform (0 0 0);\n\nboundaryField\n{\n');
fprintf(f,'\toutlet\n\t{\n\t\ttype\tzeroGradient;\n\t}\n\tinlet\n\t{\n\t\ttype\tfixedValue;\n\t\tvalue\tuniform (0 0 %f);\n\t}',v);
fprintf(f,'\n\taxis\n\t{\n\t\ttype\tempty;\n\t}\n\tleftwall\n\t{\n\t\ttype\tsymmetry;\n\t}\n\trightwall\n\t{\n\t\ttype\tsymmetry;\n\t}\n\touterwall\n\t{\n\t\ttype\tnoSlip;\n\t}\n\n}');
%ending line
fprintf(f,'\n%s',line9);
fclose(f);
Output
blockMeshDict file using wedge boundary condition
/*--------------------------------*-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)
(0.014963 0.001046 0.000000)
(0.014963 0.001046 5.000000)
(0 0 5.000000)
(0.014963 -0.001046 0.000000)
(0.014963 -0.001046 5.000000)
);
blocks
(
hex (0 4 1 0 3 5 2 3) (20 1 500) simpleGrading (0.300000 1.000000 1.000000)
);
edges
(
arc 1 4 (0.007482 0.000523 0.000000)
arc 2 5 (0.007482 -0.000523 5.000000)
);
boundary
(
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
inlet
{
type patch;
faces
(
(0 4 1 0)
);
}
outlet
{
type patch;
faces
(
(3 5 2 3)
);
}
leftwall
{
type wedge;
faces
(
(4 0 3 5)
);
}
rightwall
{
type wedge;
faces
(
(0 1 2 3)
);
}
outerwall
{
type wall;
faces
(
(1 4 5 2)
);
}
);
mergePatchPairs
(
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
blockMeshDict file using symmtery boundary condition
/*--------------------------------*-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)
(0.014963 0.001046 0.000000)
(0.014963 0.001046 5.000000)
(0 0 5.000000)
(0.014963 -0.001046 0.000000)
(0.014963 -0.001046 5.000000)
);
blocks
(
hex (0 4 1 0 3 5 2 3) (20 1 500) simpleGrading (0.300000 1.000000 1.000000)
);
edges
(
arc 1 4 (0.007482 0.000523 0.000000)
arc 2 5 (0.007482 -0.000523 5.000000)
);
boundary
(
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
inlet
{
type patch;
faces
(
(0 4 1 0)
);
}
outlet
{
type patch;
faces
(
(3 5 2 3)
);
}
leftwall
{
type symmetry;
faces
(
(4 0 3 5)
);
}
rightwall
{
type symmetry;
faces
(
(0 1 2 3)
);
}
outerwall
{
type wall;
faces
(
(1 4 5 2)
);
}
);
mergePatchPairs
(
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Results:

where, `dU = U_(Analytical) - U_(Numerical)`
`dP = P_(Analytical) - P_(Numerical)`
`d(Tau)= Tau_(Analytical) - Tau_(Numerical)`
Note: Discription of geometry and Formulae to calculate the analytical solutions can be found on the following link https://skill-lync.com/projects/week-11-simulation-of-flow-through-a-pipe-in-openfoam-48
At the angle of 4degrees, we got almost equal error differances in the parameters using both wedge and symmetry boundary conditions.
Wedge boundary condition:
Above 4degree, though it exceeded the angular limit of 5degrees the simulation took place at the angles of 10 and 25 with inappropriate results violating HP law. At the angle of 45 degrees open foam has shown the error saying that the angle should be less than 5degrees.
Symmetry boundary condition:
Above 4degree, as it has no angular limit the results obtained at every angle is appropriate and satisfying the HP law.
Conclusion:
The difference in error at every angle is almost equal which is satisfying the axi-symmetry property in case of symmetry boundary condition.
The difference in error is very small, which states the fidelity of solution using numerical techniques using appropriate conditions.