Symmetry vs Wedge vs HP equation
Symmetry vs Wedge vs HP equation
Objetive :-
- You should have results obtained from solving the Hagen Poisuelle's equation
- You should have results obtained from simulating the pipe flow with the wedge BC
- You should obtain results for the pipe flow with symmetry BC
- Write a Matlab program that takes an angle as input and generates a blockMesh file for the given angle.
- Angles to test 10,25,45
Matlab Code :-
In this program same has like wedge blockMeshDict file but only difference is the use of symmetry patch in it and the different symmetry angles.
clear all
close all
clc
%Input parameter
%input wedge angle
theta = 45;
% reyolds number
re = 2100;
% Diameter of pipe in meters
d = 0.025;
% Length of pipe i meters
L = 0.06*re*d;
% Radius
r = d/2;
% viscosity of water
mu = 0.89e-3;
% density of water
rho = 997.0;
%Kinemayic viscosity of water
nu = mu/rho;
% calculation of pressure and velocity
%average velocity
vel_avg = re*mu/(d*rho);
%maximum velocity
vel_max = 2*vel_avg;
%pressure drop
del_p = (32*mu*vel_avg*L)/(d^2);
% Kinematic pressure drop
kin_p = del_p/rho;
%num of cells along the pipe
n1 = 50;
% num of cells radially
n2 = 1;
% num of cells on the curve
n3 = 300;
gfactor = 0.2;
% co-ordiates for the vertices
% starting point
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))];
% Printing the file
text1 ='/--------------------------------- C++ -----------------------------------';
text2 ='| ========= |';
text3 ='| \ / F ield | OpenFOAM: The Open Source CFD Toolbox |';
text4 ='| \ / O peration | Website: https://openfoam.org |';
text5 ='| \ / A nd | Version: 7 |';
text6 ='| \/ M anipulation | |';
text7 ='---------------------------------------------------------------------------/';
text8 ='FoamFile';
text9 ='{';
text10 =' version 2.0;';
text11 =' format ascii;';
text12 =' class dictionary;';
text13 =' object blockMeshDict;';
text14 ='}';
text15 ='// ********* //';
% Genearting a blockMeshDict
% Header
f1 = fopen('blockMeshDict.txt','wt');
fprintf(f1,'%sn',text1);
fprintf(f1,'%sn',text2);
fprintf(f1,'%sn',text3);
fprintf(f1,'%sn',text4);
fprintf(f1,'%sn',text5);
fprintf(f1,'%sn',text6);
fprintf(f1,'%sn',text7);
fprintf(f1,'%sn',text8);
fprintf(f1,'%sn',text9);
fprintf(f1,'%sn',text10);
fprintf(f1,'%sn',text11);
fprintf(f1,'%sn',text12);
fprintf(f1,'%sn',text13);
fprintf(f1,'%sn',text14);
fprintf(f1,'%snn',text15);
% Vertices
fprintf(f1,'converttoMeters 1;nn');
fprintf(f1,'verticesn(n');
fprintf(f1,'t(%d %d %d)n',V0(1),V0(2),V0(3));
fprintf(f1,'t(%d %d %d)n',V1(1),V1(2),V1(3));
fprintf(f1,'t(%d %d %d)n',V2(1),V2(2),V2(3));
fprintf(f1,'t(%d %d %d)n',V3(1),V3(2),V3(3));
fprintf(f1,'t(%d %d %d)n',V4(1),V4(2),V4(3));
fprintf(f1,'t(%d %d %d)n);nn',V5(1),V5(2),V5(3));
fprintf(f1,'blocksn(n');
fprintf(f1,'t hex (0 3 5 2 0 3 4 1)(%d %d %d)',n1,n2,n3);
fprintf(f1,'simpleGrading(%0.1f 1 1)n);nn',gfactor);
fprintf(f1,'edgesn(ntarc %d %d (%d %0.2f %d)ntarc %d %d (%0.2f %0.2f %d)n);nn',1,2,0,r,0,4,5,L,r,0);
fprintf(f1,'boundaryn(n');
fprintf(f1,'t%snt{ntt type %s;nnt faces nnt (nttt (%d %d %d %d) ntt);nt}nn','axis','empty',0,3,3,0);
fprintf(f1,'t%snt{ntt type %s;nnt faces nnt (nttt (%d %d %d %d) ntt);nt}nn','inlet','patch',0,1,2,0);
fprintf(f1,'t%snt{ntt type %s;nnt faces nnt (nttt (%d %d %d %d) ntt);nt}nn','pipe','wall',1,5,4,2);
fprintf(f1,'t%snt{ntt type %s;nnt faces nnt (nttt (%d %d %d %d) ntt);nt}nn','outlet','patch',3,4,5,3);
fprintf(f1,'t%snt{ntt type %s;nnt faces nnt (nttt (%d %d %d %d) ntt);nt}nn','front','symmetry',0,3,5,2);
fprintf(f1,'t%snt{ntt type %s;nnt faces nnt (nttt (%d %d %d %d) ntt);nt}nn','back','symmetry',0,1,4,3);
fprintf(f1,');nn');
fprintf(f1,'mergepatchpairsn(n);nn');
fprintf(f1,'%s',text15);
fclose(f1);
BlockMeshDict code:-
/--------------------------------- C++ -----------------------------------
========= |
\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\ / O peration | Website: https://openfoam.org
\ / A nd | Version: 7
\/ M anipulation |
---------------------------------------------------------------------------/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0)
(0 1.154849e-02 -4.783543e-03)
(0 1.154849e-02 4.783543e-03)
(3.150000e+00 0 0)
(3.150000e+00 1.154849e-02 -4.783543e-03)
(3.150000e+00 1.154849e-02 4.783543e-03)
);
blocks
(
hex (0 1 2 0 3 4 5 3) (100 1 500)simpleGrading (0.200000 1 1)
);
edges
(
arc 1 2 (0 0.010000 0)
arc 4 5 (2.520000 0.010000 0)
);
boundary
(
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
fixedWalls
{
type wall;
faces
(
(2 1 4 5)
);
}
front
{
type symmetry;
faces
(
(1 0 3 4)
);
}
back
{
type symmetry;
faces
(
(2 5 3 0)
);
}
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 5 4 3)
);
}
);
mergePatchPairs
(
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
symmetry :-
Symmetry boundary conition used for a physical object or geometry and the flow field pattern of the developed solution is mirrored along the surface. this condition helps to reduce the computational doain size and enables the modeling of a sub-domain of the complete setup.
ControlDict Code :-
/--------------------------------- C++ -----------------------------------
========= |
\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\ / O peration | Website: https://openfoam.org
\ / A nd | Version: 7
\/ M anipulation |
---------------------------------------------------------------------------/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 10;
deltaT 0.01;
writeControl timeStep;
writeInterval 10;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************* //
Velocity Profile :-
/--------------------------------- C++ -----------------------------------
========= |
\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\ / O peration | Website: https://openfoam.org
\ / A nd | Version: 7
\/ M anipulation |
---------------------------------------------------------------------------/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0.0937312 0 0);
boundaryField
{
axis
{
type empty;
}
inlet
{
type fixedValue;
value uniform (0.0937312 0 0);
}
fixedWalls
{
type fixedValue;
value uniform (0 0 0);
}
outlet
{
type zeroGradient;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
}
// ************************* //
Pressure Profile:-
/--------------------------------- C++ -----------------------------------
========= |
\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\ / O peration | Website: https://openfoam.org
\ / A nd | Version: 7
\/ M anipulation |
---------------------------------------------------------------------------/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
axis
{
type empty;
}
inlet
{
type zeroGradient;
}
fixedWalls
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0.0168682;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
}
// ************************* //
Transport Properties :-
/--------------------------------- C++ -----------------------------------
========= |
\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\ / O peration | Website: https://openfoam.org
\ / A nd | Version: 7
\/ M anipulation |
---------------------------------------------------------------------------/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nu [0 2 -1 0 0 0 0] 0.892e-6;
// ************************* //
Output :-
Theta 10 :-
Inlet :-
Outlet :-
Theta 25 :-
Inlet :-
Outlet :-
Theta 45 :-
Inlet :-
Outlet :-