Week 12 - Validation studies of Symmetry BC vs Wedge BC in OpenFOAM vs Analytical H.P equation
Objective:-
1.To write MATLAB codefor symmetry boundary conditions of flow through pipe.
2. To Simulate the pipe flow for 10, 25 and 45 degree angles.
3.To comapre results of wedge boundary condtions with symmetry boundary conditions.
MATLAB Program:-
clear all
close all
clc
D = 0.005;
r = D/2;
L =210*D;
Re = 2100;
theta = 25;
a =sind(theta/2);
b =cosd(theta/2);
y = r*b;
z = r*a;
header1='/*--------------------------------*- C++ -*----------------------------------*\';
header2='| ========= | |';
header3='| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |';
header4='| \\ / O peration | Version: v2012 |';
header5='| \\ / A nd | Website: www.openfoam.com |';
header6='| \\/ M anipulation | |';
header7='\*---------------------------------------------------------------------------*/';
f1 = fopen('blockMeshDict','w');
fprintf(f1, '%s\n',header1);
fprintf(f1, '%s\n',header2);
fprintf(f1, '%s\n',header3);
fprintf(f1, '%s\n',header4);
fprintf(f1, '%s\n',header5);
fprintf(f1, '%s\n',header6);
fprintf(f1, '%s\n',header7);
fprintf(f1,'FoamFile\n{\n');
fprintf(f1, '%12s \t 2.0;\n','version');
fprintf(f1, '%12s \t ascii;\n','format');
fprintf(f1, '%12s \t dictionary;\n','class');
fprintf(f1, '%12s \t blockMeshDict;\n','object');
fprintf(f1,'}\n');
header8='// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //';
fprintf(f1, '%s\n\n',header8);
fprintf(f1, "convertToMeters 1; \n");
fprintf(f1, " vertices \n");
fprintf(f1, " ( \n ");
fprintf(f1, " ( 0 0 0 ) \n " ); % Vertex 0
fprintf(f1, " (0 %d %d ) \n ",y,z ); % Vertex 1
fprintf(f1, " (0 %d %d ) \n ",y,-z ); % Vertex 2
fprintf(f1, " (%d 0 0) \n ",L); % Vertex 3
fprintf(f1, " (%d 0 0) \n ",L,y,z); % Vertex 4
fprintf(f1, " (%d 0 0) \n ",L,y,-z); % Vertex 5
fprintf(f1, " ); \n " );
fprintf(f1, " blocks \n " );
fprintf(f1, " ( \n " );
fprintf(f1, " hex ( 0 3 5 2 0 3 4 1) ( 200 50 1) simpleGrading (1 0.1 1) \n ");
fprintf(f1, " ); \n " );
fprintf(f1, " edges \n " );
fprintf(f1, " ( \n " );
fprintf(f1, " ); \n " );
fprintf(f1, " boundary \n " );
fprintf(f1, " ( \n " );
fprintf(f1, " inlet \n " );
fprintf(f1, " { \n " );
fprintf(f1, " type patch; \n " );
fprintf(f1, " faces \n " );
fprintf(f1, " ( \n " );
fprintf(f1, " (0 1 2 0) \n" );
fprintf(f1, " ); \n " );
fprintf(f1, " } \n " );
fprintf(f1, " outlet \n " );
fprintf(f1, " { \n " );
fprintf(f1, " type patch; \n " );
fprintf(f1, " faces \n " );
fprintf(f1, " ( \n " );
fprintf(f1, " (3 5 4 3) \n" );
fprintf(f1, " ); \n " );
fprintf(f1, " } \n " );
fprintf(f1, " topwall \n " );
fprintf(f1, " { \n " );
fprintf(f1, " type wall; \n " );
fprintf(f1, " faces \n " );
fprintf(f1, " ( \n " );
fprintf(f1, " (1 4 5 2) \n" );
fprintf(f1, " ); \n " );
fprintf(f1, " } \n " );
fprintf(f1, " axis \n " );
fprintf(f1, " { \n " );
fprintf(f1, " type empty; \n " );
fprintf(f1, " faces \n " );
fprintf(f1, " ( \n " );
fprintf(f1, " (0 3 3 0) \n" );
fprintf(f1, " ); \n " );
fprintf(f1, " } \n " );
fprintf(f1, " front \n " );
fprintf(f1, " { \n " );
fprintf(f1, " type symmetry; \n " );
fprintf(f1, " faces \n " );
fprintf(f1, " ( \n " );
fprintf(f1, " (0 3 4 1) \n" );
fprintf(f1, " ); \n " );
fprintf(f1, " } \n " );
fprintf(f1, " back \n " );
fprintf(f1, " { \n " );
fprintf(f1, " type symmetry; \n " );
fprintf(f1, " faces \n " );
fprintf(f1, " ( \n " );
fprintf(f1, " (0 2 5 3) \n" );
fprintf(f1, " ); \n " );
fprintf(f1, " } \n " );
fprintf(f1, " ); \n " );
fprintf(f1, "mergePatchPairs \n");
fprintf(f1, "( \n ");
fprintf(f1, "); \n");
header9="// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //";
fprintf(f1, "%s\n", header9);
fclose(f1);
blockMeshDict
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
( 0 0 0 )
(0 2.440740e-03 5.410990e-04 )
(0 2.440740e-03 -5.410990e-04 )
(1.050000e+00 0 0)
(1.05 2.440740e-03 5.410990e-04 )
(1.05 2.440740e-03 -5.410990e-04 )
);
blocks
(
hex ( 0 3 5 2 0 3 4 1) ( 200 50 1) simpleGrading (1 0.1 1)
);
edges
(
);
boundary
(
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 5 4 3)
);
}
topwall
{
type wall;
faces
(
(1 4 5 2)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
front
{
type symmetry;
faces
(
(0 3 4 1)
);
}
back
{
type symmetry;
faces
(
(0 2 5 3)
);
}
);
mergePatchPairs
(
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
controlDict
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 3;
deltaT 0.0001;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
transportProperties
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nu [0 2 -1 0 0 0 0 ] 1.0034e-6;;
// ************************************************************************* //
Velocity Boundary condition
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
inlet
{
type fixedValue;
value uniform (0.42 0 0);
}
outlet
{
type zeroGradient;
}
topwall
{
type noSlip;
value uniform (0 0 0);
}
axis
{
type empty;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
}
// ************************************************************************* //
Pressure Boundary condition
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ 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;
}
topwall
{
type zeroGradient;
}
axis
{
type empty;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
}
// ************************************************************************* //
Geometry and Mesh Generated:



Output :-
Velocity Profile:






Pressure Profile:

Comparison:
There is no much chang in the maximum velocities. execution time is greater for symmetry is than wedge type.
| Wedge Angle | Max Veocity (Analytical) | Max Veocity (Numerical) | Error(%) | Max. Courant No. |
| 10 | 0.3536 |
0.3844 |
0.91 | 0.013674 |
| 25 |
0.3537 |
0.3892 | 0.9 | 0.013921 |
| 45 |
0.3537 |
0.3945 | 0.89 | 0.014210 |
While the angle increases the error value in the maximum velocity is decreased. When wedge angle increase then the courant no. also increases.
Symmetric plane boundary conditions plays key role in terms of accuracy in the rsults. Maximum velocity at the centre of the pipe varies with wedge angle i.e. lesser wedge angle reduce the error percentage due to size of mesh element. Symmetry plane boundary condtions mirror all values which reduces computaional errors. Therfore,computation needs not to do on sub domain of the complete setup.