Week 12 - Validation studies of Symmetry BC vs Wedge BC in OpenFOAM vs Analytical H.P equation
AIM
In this challenge you will simulate the same problem as in week 11 but by applying Symmetry Boundary Condition. You will do the simulation for the below mentioned angles using both symmetry and wedge boundary conditions and validate them with HP equations like you did in week 11 challenge.
Angles to test: 10,25,45(degrees)
Procedure
To create brockmeshdict file in matlab for symmetry and wedge boundary conditions, only the values of coordinates of vertices changes with respect to the values of theta.
The controldict file and transport properties is same for both boundary conditions.
For pressure and vecocity boundary condition script files, the boundary type should be changed for front and back faces depending on the boundary condition that we are choosing (symmetry/wedge).
Given below is the files for symmetry boundary condition (45 degree wedge angle)
Matlab code for creating blockmeshdict file
clear all
close all
clc
theta=45; %wedge angle
Re =2100;%Reynold's number
D =0.01;%Diameter
R =D/2;%Radius
Le =0.05*Re*D; %hydrodynamic entry length
L =Le+0.4; %Total length
%Temperature = 25degree celsius
mu =8.90*10^-4; %Dynamic viscosity
rho =997; %density
nu =8.9267*10^-7; %kinematic viscosity
V_avg =(Re*mu)/(rho*D); %average velocity
V_max =2*V_avg; %maximum velocity
delta_p =(32*mu*L*V_avg)/(D^2); %pressure drop
kinematic_pressure =delta_p/rho; %kinematic pressure
%Vertices
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)];
q1 ='/*--------------------------------*- C++ -*----------------------------------*\';
q2 =' ========= |';
q3 =' \\ / F ield | OpenFOAM: The Open Source CFD Toolbox';
q4 =' \\ / O peration | Website: https://openfoam.org';
q5 =' \\ / A nd | Version: 9';
q6 =' \\/ M anipulation |';
q7 ='\*---------------------------------------------------------------------------*/';
q8 ='FoamFile';
q9 ='{';
q10 =' format ascii;';
q11 =' class dictionary;';
q12 =' object blockMeshDict;';
q13 ='}';
q14 ='// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //';
%creating the blockMeshDict file
f1 = fopen('blockMeshDict','w');
fprintf(f1,'%s\n',q1);
fprintf(f1,'%s\n',q2);
fprintf(f1,'%s\n',q3);
fprintf(f1,'%s\n',q4);
fprintf(f1,'%s\n',q5);
fprintf(f1,'%s\n',q6);
fprintf(f1,'%s\n',q7);
fprintf(f1,'%s\n',q8);
fprintf(f1,'%s\n',q9);
fprintf(f1,'%s\n',q10);
fprintf(f1,'%s\n',q11);
fprintf(f1,'%s\n',q12);
fprintf(f1,'%s\n',q13);
fprintf(f1,'%s\n',q14);
fprintf(f1,'\n');
fprintf(f1,'%s\n','convertToMeters 1;');
fprintf(f1,'\n');
fprintf(f1,'%s\n','vertices');
fprintf(f1,'%s\n','(');
fprintf(f1,'\t(%f %f %f)\n',v0(1),v0(2),v0(3));
fprintf(f1,'\t(%f %f %f)\n',v1(1),v1(2),v1(3));
fprintf(f1,'\t(%f %f %f)\n',v2(1),v2(2),v2(3));
fprintf(f1,'\t(%f %f %f)\n',v3(1),v3(2),v3(3));
fprintf(f1,'\t(%f %f %f)\n',v4(1),v4(2),v4(3));
fprintf(f1,'\t(%f %f %f)\n',v5(1),v5(2),v5(3));
fprintf(f1,'%s\n',');');
fprintf(f1,'\n');
%blocks
fprintf(f1,'%s\n','blocks');
fprintf(f1,'%s\n','(');
fprintf(f1,'\t%s\n','hex (0 3 5 2 0 3 4 1) (200 50 1) simpleGrading (1 0.3 1)');
fprintf(f1,'%s\n',');');
fprintf(f1,'\n');
%edges
fprintf(f1,'%s\n','edges');
fprintf(f1,'%s\n','(');
fprintf(f1,'\t%s\n','arc 1 2 (0.000000 0.005 0.000000)');
fprintf(f1,'\t%s\n','arc 4 5 (1.450000 0.005 0.000000)');
fprintf(f1,'%s\n',');');
fprintf(f1,'\n');
%boundary
fprintf(f1,'%s\n','boundary');
fprintf(f1,'%s\n','(');
fprintf(f1,'\t%s\n','inlet');
fprintf(f1,'\t%s\n','{');
fprintf(f1,'\t\t%s\n','type patch;');
fprintf(f1,'\t\t%s\n','faces');
fprintf(f1,'\t\t%s\n','(');
fprintf(f1,'\t\t\t%s\n','(0 1 2 0)');
fprintf(f1,'\t\t%s\n',');');
fprintf(f1,'\t%s\n','}');
fprintf(f1,'\n');
fprintf(f1,'\t%s\n','outlet');
fprintf(f1,'\t%s\n','{');
fprintf(f1,'\t\t%s\n','type patch;');
fprintf(f1,'\t\t%s\n','faces');
fprintf(f1,'\t\t%s\n','(');
fprintf(f1,'\t\t\t%s\n','(3 4 5 3)');
fprintf(f1,'\t\t%s\n',');');
fprintf(f1,'\t%s\n','}');
fprintf(f1,'\n');
fprintf(f1,'\t%s\n','axis');
fprintf(f1,'\t%s\n','{');
fprintf(f1,'\t\t%s\n','type empty;');
fprintf(f1,'\t\t%s\n','faces');
fprintf(f1,'\t\t%s\n','(');
fprintf(f1,'\t\t\t%s\n','(0 3 3 0)');
fprintf(f1,'\t\t%s\n',');');
fprintf(f1,'\t%s\n','}');
fprintf(f1,'\n');
fprintf(f1,'\t%s\n','front');
fprintf(f1,'\t%s\n','{');
fprintf(f1,'\t\t%s\n','type wedge;');
fprintf(f1,'\t\t%s\n','faces');
fprintf(f1,'\t\t%s\n','(');
fprintf(f1,'\t\t\t%s\n','(0 2 5 3)');
fprintf(f1,'\t\t%s\n',');');
fprintf(f1,'\t%s\n','}');
fprintf(f1,'\n');
fprintf(f1,'\t%s\n','back');
fprintf(f1,'\t%s\n','{');
fprintf(f1,'\t\t%s\n','type wedge;');
fprintf(f1,'\t\t%s\n','faces');
fprintf(f1,'\t\t%s\n','(');
fprintf(f1,'\t\t\t%s\n','(0 3 4 1)');
fprintf(f1,'\t\t%s\n',');');
fprintf(f1,'\t%s\n','}');
fprintf(f1,'\n');
fprintf(f1,'\t%s\n','top');
fprintf(f1,'\t%s\n','{');
fprintf(f1,'\t\t%s\n','type wall;');
fprintf(f1,'\t\t%s\n','faces');
fprintf(f1,'\t\t%s\n','(');
fprintf(f1,'\t\t\t%s\n','(1 2 5 4)');
fprintf(f1,'\t\t%s\n',');');
fprintf(f1,'\t%s\n','}');
fprintf(f1,'\n');
fprintf(f1,'%s\n',')');
fprintf(f1,'%s\n','mergePatchPairs');
fprintf(f1,'%s\n','(');
fprintf(f1,'%s\n',');');
blockMeshDict file
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0.000000 0.000000 0.000000)
(0.000000 0.004619 0.001913)
(0.000000 0.004619 -0.001913)
(1.450000 0.000000 0.000000)
(1.450000 0.004619 0.001913)
(1.450000 0.004619 -0.001913)
);
blocks
(
hex (0 3 5 2 0 3 4 1) (200 50 1) simpleGrading (1 0.3 1)
);
edges
(
arc 1 2 (0.000000 0.005 0.000000)
arc 4 5 (1.450000 0.005 0.000000)
);
boundary
(
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
front
{
type symmetry;
faces
(
(0 2 5 3)
);
}
back
{
type symmetry;
faces
(
(0 3 4 1)
);
}
top
{
type wall;
faces
(
(1 2 5 4)
);
}
)
mergePatchPairs
(
);
controlDict file
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 14;
deltaT 0.001;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
Transport properties
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nu [0 2 -1 0 0 0 0] 8.9267e-07;
// ************************************************************************* //
Velocity boundary condition
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
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.1875 0 0);
}
outlet
{
type zeroGradient;
}
axis
{
type empty;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
top
{
type noSlip;
}
}
// ************************************************************************* //
Pressure boundary condition
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
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;
}
axis
{
type empty;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
top
{
type zeroGradient;
}
}
// ************************************************************************* //
Results
For Symmetry boundary condition
Wedge angle -10 degree


Wedge angle - 25 degree



Wedge angle - 45 degree



For Wedge boundary condition
Wedge angle - 10 degree



Wedge angle - 25 degree



Wedge angle - 45 degree



Numerical results
Vavg=Vavg= 0.1875 m/s
Vmax=Vmax= 0.3749m/s
τ=τ= 0.13346 Nm2Nm2
Conclusion
From the results it is clear that for symmetry and wedge boundary conditions the plots are almost similar and the values are close to the analytical solution.
The execution time is higher for symmetry boundary condition than for wedge boundary condition.