Week 12 - Symmetry vs Wedge vs HP equation
Objective:- To simulate and analyze pipe flow using symmetry boundary condition
Matlab code to generate blockmesh dict file for any angle theta
clear all
close all
clc
d=0.02
r=d/2
mu=8.9e-4;
rho=1000;
nu=mu/rho;
Re=2100;
Lent=0.06*Re*d
L=Lent+0.3
vavg=Re*nu/(rho);
vmax=2*vavg;
deltaP=(8*vavg*mu*L)/(r^2);
kinP=deltaP/rho;
fprintf ("Enter theta for Wedge BC");
theta=input('Enter the angle : ');
v0=[0 0 0];"/*point 0*/";
v1=[0 r*cosd(theta/2) -r*sind(theta/2)];"/*point 1*/";
v2=[0 r*cosd(theta/2) r*sind(theta/2)];"/*point 2*/";
v3=[L 0 0];"/*point 3*/";
v4=[L r*cosd(theta/2) -r*sind(theta/2)];"/*point 4*/";
v5=[L r*cosd(theta/2) r*sind(theta/2)];"/*point 5*/";
head1="/*--------------------------------*- C++ -*----------------------------------*\";
head2=" ========= | ";
head3=" \\ / F ield | OpenFOAM: The Open Source CFD Toolbox ";
head4=" \\ / O peration | Website: https://openfoam.org ";
head5=" \\ / A nd | Version: 8 ";
head6=" \\/ M anipulation | ";
head7="\*---------------------------------------------------------------------------*/";
b4=blanks(4);
b8=blanks(8);
b12=blanks(12);
b16=blanks(16);
dict1=" version 2.0;";
dict2=" format ascii;"
dict3=" class dictionary;"
dict4=" object blockMeshDict;";
dict5="// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //";
conv="convertToMeters 1;";
vertex1="vertices";
blocks1="hex (0 1 2 0 3 4 5 3) (50 1 200) simpleGrading (0.2 1 1)";
footer="// ************************************************************************* //"
f1=fopen('blockMeshDict.txt','w')
fprintf(f1,'%s\n',head1);
fprintf(f1,'%s\n',head2);
fprintf(f1,'%s\n',head3);
fprintf(f1,'%s\n',head4);
fprintf(f1,'%s\n',head5);
fprintf(f1,'%s\n',head6);
fprintf(f1,'%s\n',head7);
fprintf(f1,'FoamFile\n{\n');
fprintf(f1, '%s%s\n', b4,dict1);
fprintf(f1, '%s%s\n', b4,dict2);
fprintf(f1, '%s%s\n', b4,dict3);
fprintf(f1, '%s%s\n}\n', b4,dict4);
fprintf(f1, '%s%s\n', b4,dict5);
fprintf(f1, '%s\n',conv);
fprintf(f1, 'vertices\n(\n');
fprintf(f1, '%s(%d %d %d)\n', b4,v0(1),v0(2), v0(3));
fprintf(f1, '%s(%d %f %f)\n', b4,v1(1),v1(2), v1(3));
fprintf(f1, '%s(%d %f %f)\n', b4,v2(1),v2(2), v2(3));
fprintf(f1, '%s(%d %f %f)\n', b4,v3(1),v3(2), v3(3));
fprintf(f1, '%s(%d %f %f)\n', b4,v4(1),v4(2), v4(3));
fprintf(f1, '%s(%f %f %f)\n', b4,v5(1),v5(2), v5(3));
fprintf(f1,');\n');
fprintf(f1, '\nblocks\n(\n');
fprintf(f1, '%s%s%\n', b4,blocks1);
fprintf(f1, ');\n');
fprintf(f1,'\nedges\n(\n');
fprintf(f1,'%sarc 1 2 (0 %0.3f 0)\n', b4,r);
fprintf(f1,'%sarc 4 5 (%0.2f %0.3f 0)\n', b4,L,r);
fprintf(f1,');\n');
fprintf(f1,'\nboundary\n(\n');
fprintf(f1,'%saxis\n%s{\n',b4,b4);
fprintf(f1,'%stype empty;\n',b8);
fprintf(f1,'%sfaces\n%s(\n',b8,b8);
fprintf(f1,'%s(0 3 3 0)\n%s);\n%s}\n',b12,b8,b4);
fprintf(f1,'%sinlet\n%s{\n', b4,b4);
fprintf(f1, '%stype patch;\n', b8);
fprintf(f1, '%sfaces\n%s(\n', b8,b8);
fprintf(f1, '%s(0 0 2 1)\n%s);\n%s}\n', b12,b8,b4 );
fprintf(f1,'%swall\n%s{\n', b4,b4);
fprintf(f1, '%stype wall;\n', b8);
fprintf(f1, '%sfaces\n%s(\n', b8,b8);
fprintf(f1, '%s(2 5 4 1)\n%s);\n%s}\n', b12,b8,b4 );
fprintf(f1,'%soutlet\n%s{\n', b4,b4);
fprintf(f1, '%stype patch;\n', b8);
fprintf(f1, '%sfaces\n%s(\n', b8,b8);
fprintf(f1, '%s(3 4 5 3)\n%s);\n%s}\n', b12,b8,b4 );
fprintf(f1,'%sfront\n%s{\n', b4,b4);
fprintf(f1, '%stype symmetry;\n', b8);
fprintf(f1, '%sfaces\n%s(\n', b8,b8);
fprintf(f1, '%s(0 3 5 2)\n%s);\n%s}\n', b12,b8,b4 );
fprintf(f1,'%sback\n%s{\n', b4,b4);
fprintf(f1, '%stype symmetry;\n', b8);
fprintf(f1, '%sfaces\n%s(\n', b8,b8);
fprintf(f1, '%s(0 1 4 3)\n%s);\n%s}\n', b12,b8,b4 );
fprintf(f1,')\n');
fprintf(f1, '\nmergePatchPairs\n(\n);\n');
fprintf(f1,'%s',footer);
fclose(f1);
- Blockmesh dict file for 10 degrees
/*--------------------------------*- 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 0.009962 -0.000872)
(0 0.009962 0.000872)
(2.820000e+00 0.000000 0.000000)
(2.820000e+00 0.009962 -0.000872)
(2.820000 0.009962 0.000872)
);
blocks
(
hex (0 1 2 0 3 4 5 3) (50 1 200) simpleGrading (0.2 1 1));
edges
(
arc 1 2 (0 0.010 0)
arc 4 5 (2.82 0.010 0)
);
boundary
(
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
inlet
{
type patch;
faces
(
(0 0 2 1)
);
}
wall
{
type wall;
faces
(
(2 5 4 1)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
front
{
type symmetry;
faces
(
(0 3 5 2)
);
}
back
{
type symmetry;
faces
(
(0 1 4 3)
);
}
)
mergePatchPairs
(
);
// ************************************************************************* //
- Kinematic Pressure drop 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 volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
axis
{
type empty;
}
inlet
{
type zeroGradient;
}
wall
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0.018072;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
}
// ************************************************************************* //
- Initial Velocity
/*--------------------------------*- 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 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);
}
wall
{
type fixedValue;
value uniform (0 0 0);
}
outlet
{
type zeroGradient;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
}
// ************************************************************************* //
Results
- Wedge Angle 10



- Wedge Angle 25



-Wedge Angle 40



From the above plots we note that the profile for velocity and shear stress are on similar to the ones observed in wedge boundary condition. Differences however can be observed with regard to simulation time and accuracy. It is summarized in the below table
| Wedge Angle (Symmetry Boumdary Condition) | Courant Number max | Velocity Max | ClockTime | Hagen Poisuelle | Delta |
| 10 | 0.341418 | 0.1851 | 632 | 0.1869 | 0.0018 |
| 25 | 0.34465 | 0.1854 | 478 | 0.1869 | 0.0015 |
| 40 | 0.35874 | 0.1859 | 348 | 0.1869 | 0.001 |
| Wedge Angle | Maximum Velocity | Hagen Poisuelle | Delta | Time | |
| 2 | 0.185 | 0.1869 | 0.0019 | 382 | (This is the correct value. Wrong value inserted in previous submission) |
| 4 | 0.1851 | 0.1869 | 0.0018 | 260 | This is the correct value. Wrong value inserted in previous submission) |
CONCLUSION
- Symmetry Boundary condition produces more accurate results than wedge boundary condition
- In symmetry boundary conditon, higher the wedge angle, greater is the accuracy of the result.
- Symmetry boundary condition requires greater execution time that wedge boundary condition.
- Considering only symmetry, greater is the wedge angle, lower is the execution time.