Symmetry vs Wedge vs HP equation
Objective:
To write a program in Matlab to generate BlockMeshDict file automaticlly for given grading schemes and symmetry boundary conditions and to simulate the flow through a pipe in OpenFoam and validate the results with theoretical results derived from Hagen poiseuille\'s equation and compare the symmetry and wedge boundary conditions.
Theory:
In this project we aim to simulate a section of pipe (Wedge shaped geometry) to understand various aspects of flow through a pipe. The fluid chosen is water and the flow is laminar and incompressible. Also we choose to neglect any changes in cross section.
Internal flow occurs when the fluid is filled entirely in a conduit and is driven primarily by a pressure difference.
Fluid velocity in a pipe changes from zero at the surface because of the no-slip boundary condition to a maximum at the pipe center. The average velocity `Vavg`remains constant in an incompressible flow when the cross section of the pipe is constant.
Symmetry Boundary condition:
The symmetry boundary condition defines a mirror face/surface. The symmetry condition should only be used if the physical object or geometry and the expected flow field pattern of the developed solution is mirrored along that surface. This boundary condition helps to reduces the computational domain in size and enables the modeling of a sub-domain of the complete setup.
In general, the symmetry condition applies the following constraints on the flow variables:
- The fluxes across a symmetry are zero.
- The normal components of velocity are set to zero.
- The normal components of all other variables are set to zero.
Wedge Boundary Condition:
The wedge boundary condition defines an axis-symmetric boundary condition. The model and flow must be axis-symmetric along a central line such that all physical variables of the flow have same value and distribution at a radius and angle.
The axis-symmetric ‘wedge’ boundary is specified by two planes that must be selected on separate sides of the domain on surfaces running along the central line.
Assumed Properties for the fluid and flow:
- Reynolds number(re) = 2100
- Length of Pipe(L) = 2m
- Diameter of Pipe(D) = 0.01m
- Temperature of water = 18C
- Dynamic Viscosity(µ) = 0.00105 Pa.s
- Kinematic Viscosty(mu) = 0.0000010533 m2/s
- Density(ρ) = 997 kg/m3
- Angle(theta) = 10,25,45 degrees
Calculated Values:
1. Length of the pipe using the entry length formula
`L= 0.05*Re*D`=1.056m
2.Average Velocity
`Vavg=(Re*mu)/(rho*D)`=0.1105m/s
3.Maximum Velocity
`Vmax=2*Vavg`=0.2211m/s
4.Pressure
`P=(32*mu*Vavg*L)/D^2` =18.564Pa
5.Kinematic Pressure
`Pkinematic =P/rho` = 0.0186m
MATLAB PROGRAM:
The blockMesh dict file is written in matlab which take radius of pipe length of pipe and wegde angle(Wedge bowndary condition = 10,25,45) as input and generate the file automatically.
clear all
close all
clc
L = 2;
theta = 10;
d = 0.02;
r = d/2;
nx = 200;
ny = 20;
nz =1;
line1=\'/*--------------------------------*- C++ -*----------------------------------*\\\';
line2=\'| ========= | |\';
line3=\'| \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox |\';
line4=\'| \\\\ / O peration | Version: 4.1 |\';
line5=\'| \\\\ / A nd | Web: www.OpenFOAM.org |\';
line6=\'| \\\\/ M anipulation | |\';
line7=\'\\*---------------------------------------------------------------------------*/\';
bd = fopen(\'blockMeshDict2\',\'w\')
fprintf(bd,\'%s\\n\',line1);
fprintf(bd,\'%s\\n\',line2);
fprintf(bd,\'%s\\n\',line3);
fprintf(bd,\'%s\\n\',line4);
fprintf(bd,\'%s\\n\',line5);
fprintf(bd,\'%s\\n\',line6);
fprintf(bd,\'%s\\n\',line7);
fprintf(bd,\'FoamFile\\n{\\n\');
fprintf(bd,\'%12s \\t 2.0;\\n\',\'version\');
fprintf(bd,\'%11s \\t ascii;\\n\',\'format\');
fprintf(bd,\'%10s \\t dictionary;\\n\',\'class\');
fprintf(bd,\'%11s \\t blockMeshDict;\\n\',\'object\');
fprintf(bd,\'}\\n\');
line8=\'// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //\';
fprintf(bd,\'%s\\n\\n\',line8);
fprintf(bd,\'convertToMeters 1;\\n\\n\');
fprintf(bd,\'vertices\\n\');
fprintf(bd,\'(\\n\');
fprintf(bd,\'\\t (%d %d %d)\\n\',0,0,0); % point 0
fprintf(bd,\'\\t (%d %d %d)\\n\',0,r*cosd(theta/2),r*sind(theta/2)); % point 1
fprintf(bd,\'\\t (%d %d %d)\\n\',0,r*cosd(theta/2),-r*sind(theta/2)); % point 2
fprintf(bd,\'\\t (%d %d %d)\\n\',L,0,0); % Pont 3
fprintf(bd,\'\\t (%d %d %d)\\n\',L,r*cosd(theta/2),r*sind(theta/2)); % point 4
fprintf(bd,\'\\t (%d %d %d)\\n\',L,(r*cosd(theta/2)),-r*sind(theta/2)); % point 5
fprintf(bd,\');\\n\\n\');
fprintf(bd,\'blocks\\n\');
fprintf(bd,\'(\\n\');
fprintf(bd,\' hex ( 0 3 5 2 0 3 4 1) (%d %d %d)\',nx,ny,nz);
fprintf(bd, \' SimpleGrading (1 1 1)\\n\\n\');
fprintf(bd,\');\\n\\n\');
fprintf(bd,\'edges\\n(\\n\\tarc %d %d (%d %d %d)\\n\',1,2,0,r,0);
fprintf(bd,\'\\tarc %d %d (%d %d %d)\\n\',4,5,L,r,0);
fprintf(bd,\');\\n\\n\');
fprintf(bd,\'boundary\\n(\\n\');
fprintf(bd,\'\\t inlet\\n\');
fprintf(bd,\'\\t{\\n\');
fprintf(bd,\'\\t\\t type patch;\\n\');
fprintf(bd,\'\\t\\t faces\\n\');
fprintf(bd,\'\\t\\t (\\n\');
fprintf(bd,\'\\t\\t\\t (0 1 2 0)\\n\');
fprintf(bd,\'\\t\\t );\\n\');
fprintf(bd,\'\\t}\\n\');
fprintf(bd,\'\\t outlet\\n\');
fprintf(bd,\'\\t{\\n\');
fprintf(bd,\'\\t\\t type patch;\\n\');
fprintf(bd,\'\\t\\t faces\\n\');
fprintf(bd,\'\\t\\t (\\n\');
fprintf(bd,\'\\t\\t\\t (3 5 4 3)\\n\');
fprintf(bd,\'\\t\\t );\\n\');
fprintf(bd,\'\\t}\\n\');
fprintf(bd,\'\\t top \\n\');
fprintf(bd,\'\\t{\\n\');
fprintf(bd,\'\\t\\t type wall;\\n\');
fprintf(bd,\'\\t\\t faces\\n\');
fprintf(bd,\'\\t\\t (\\n\');
fprintf(bd,\'\\t\\t\\t (1 4 5 2)\\n\');
fprintf(bd,\'\\t\\t );\\n\');
fprintf(bd,\'\\t}\\n\');
fprintf(bd,\'\\t back\\n\');
fprintf(bd,\'\\t{\\n\');
fprintf(bd,\'\\t\\t type symmetry;\\n\');
fprintf(bd,\'\\t\\t faces\\n\');
fprintf(bd,\'\\t\\t (\\n\');
fprintf(bd,\'\\t\\t\\t (0 2 5 3)\\n\');
fprintf(bd,\'\\t\\t );\\n\');
fprintf(bd,\'\\t}\\n\');
fprintf(bd,\'\\t front\\n\');
fprintf(bd,\'\\t{\\n\');
fprintf(bd,\'\\t\\t type symmetry;\\n\');
fprintf(bd,\'\\t\\t faces\\n\');
fprintf(bd,\'\\t\\t (\\n\');
fprintf(bd,\'\\t\\t\\t (0 3 4 1)\\n\');
fprintf(bd,\'\\t\\t );\\n\');
fprintf(bd,\'\\t}\\n\');
fprintf(bd,\'\\t axis\\n\');
fprintf(bd,\'\\t{\\n\');
fprintf(bd,\'\\t\\t type empty;\\n\');
fprintf(bd,\'\\t\\t faces\\n\');
fprintf(bd,\'\\t\\t (\\n\');
fprintf(bd,\'\\t\\t\\t (0 3 3 0)\\n\');
fprintf(bd,\'\\t\\t );\\n\');
fprintf(bd,\'\\t}\\n\');
fprintf(bd,\');\\n\\n\');
fprintf(bd,\'mergePatchPairs\\n(\\n\');
fprintf(bd,\');\\n\');
line9=\'// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //\';
fprintf(bd,\'%s\\n\',line9);
fclose(bd)
BlockmeshDict file for `theta=10`
/*--------------------------------*- C++ -*----------------------------------*\\
| ========= | |
| \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\\\ / O peration | Version: 4.1 |
| \\\\ / A nd | Web: www.OpenFOAM.org |
| \\\\/ M anipulation | |
\\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0)
(0 0.00996195 0.000871557)
(0 0.00996195 -0.000871557)
(2 0 0)
(2 0.00996195 0.000871557)
(2 0.00996195 -0.000871557)
);
blocks
(
hex ( 0 3 5 2 0 3 4 1) (200 20 1) SimpleGrading (1 1 1)
);
edges
(
arc 1 2 (0 0.01 0)
arc 4 5 (2 0.01 0)
);
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)
);
}
back
{
type symmetry;
faces
(
(0 2 5 3)
);
}
front
{
type symmetry;
faces
(
(0 3 4 1)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
BlockmeshDict file for `theta=25`
/*--------------------------------*- C++ -*----------------------------------*\\
| ========= | |
| \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\\\ / O peration | Version: 4.1 |
| \\\\ / A nd | Web: www.OpenFOAM.org |
| \\\\/ M anipulation | |
\\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0)
(0 0.00976296 0.0021644)
(0 0.00976296 -0.0021644)
(2 0 0)
(2 0.00976296 0.0021644)
(2 0.00976296 -0.0021644)
);
blocks
(
hex ( 0 3 5 2 0 3 4 1) (200 20 1) SimpleGrading (1 1 1)
);
edges
(
arc 1 2 (0 0.01 0)
arc 4 5 (2 0.01 0)
);
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)
);
}
back
{
type symmetry;
faces
(
(0 2 5 3)
);
}
front
{
type symmetry;
faces
(
(0 3 4 1)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
BlockmeshDict file for `theta=45`
/*--------------------------------*- C++ -*----------------------------------*\\
| ========= | |
| \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\\\ / O peration | Version: 4.1 |
| \\\\ / A nd | Web: www.OpenFOAM.org |
| \\\\/ M anipulation | |
\\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0)
(0 0.0092388 0.00382683)
(0 0.0092388 -0.00382683)
(2 0 0)
(2 0.0092388 0.00382683)
(2 0.0092388 -0.00382683)
);
blocks
(
hex ( 0 3 5 2 0 3 4 1) (200 20 1) SimpleGrading (1 1 1)
);
edges
(
arc 1 2 (0 0.01 0)
arc 4 5 (2 0.01 0)
);
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)
);
}
back
{
type symmetry;
faces
(
(0 2 5 3)
);
}
front
{
type symmetry;
faces
(
(0 3 4 1)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Now the next step is to give initial conditions of presssure(P) and velocity(U) in 0 folder.
P file
/*--------------------------------*- C++ -*----------------------------------*\\
========= |
\\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\\\ / O peration | Website: https://openfoam.org
\\\\ / A nd | Version: 6
\\\\/ M anipulation |
\\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
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.018;
}
top
{
type zeroGradient;
}
back
{
type symmetry;
}
front
{
type symmetry;
}
axis
{
type empty;
}
}
// ************************************************************************* //
U File
/*--------------------------------*- C++ -*----------------------------------*\\
========= |
\\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\\\ / O peration | Website: https://openfoam.org
\\\\ / A nd | Version: 6
\\\\/ M anipulation |
\\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0.1105 0 0);
boundaryField
{
inlet
{
type fixedValue;
value uniform (0.1105 0 0);
}
outlet
{
type zeroGradient;
}
top
{
type fixedValue;
value uniform (0 0 0);
}
back
{
type symmetry;
}
front
{
type symmetry;
}
axis
{
type empty;
}
}
// ************************************************************************* //
Output:
Wedge block for `theta=10`
Wedge block for `theta=25`
Wedge block for `theta=45`
Results:
Wedge Angle Mean Courant Number Max Courant Number Max Velocity from simulaion(m/s) Max velocity from Hagen poiseuille\'s eq(m/s)
2 degrees 0.2251 0.250 0.2201 0.2211
10 degrees 0.2284 0.3415 0.2205 0.2211
25 degrees 0.2290 0.3524 0.2209 0.2211
45 degrees 0.2325 0.3969 0.2210 0.2211
Conclusion:
1. Symmetry boundary condition is more accurate than wedge boundary condition.
2. Execution time of symmetry boundary condition is greater than wedge boundary condition for the same computational mesh.
3. Courant number increases with increasing wedge angle.