Week 12 - Validation studies of Symmetry BC vs Wedge BC in OpenFOAM vs Analytical H.P equation
%blockmeshdict for wedge bc
clear all
close all
clc
%parameters
Re=2100;
rho=1200;
D=0.02;
r=D/2;
mu=0.89e-3;
v=0.88927e-6;
theta=input('Enter wedge angle')
L_h=0.06*Re*D;
L=L_h+0.5;
V_avg=(Re*mu)/(rho*D);
V_max=2*V_avg;
P_drop=(32*mu*L*V_avg)/D^2;
P_kinematic=(P_drop)/rho;
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)]
H1='/*--------------------------------*- C++ -*----------------------------------*\';
H2=' ========= |';
H3=' \\ / F ield | OpenFOAM: The Open Source CFD Toolbox';
H4=' \\ / O peration | Website: https://openfoam.org';
H5=' \\ / A nd | Version: 10';
H6=' \\/ M anipulation |';
H7='\*---------------------------------------------------------------------------*/';
H8='FoamFile';
H9='{'
H11=' format ascii;';
H12=' class dictionary;';
H13=' object blockMeshDict;';
H14='}'
H15='// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //';
f1=fopen('blockMeshDict3.txt','wt');
fprintf(f1,'%s \n',H1);
fprintf(f1,'%s \n',H2);
fprintf(f1,'%s \n',H3);
fprintf(f1,'%s \n',H4);
fprintf(f1,'%s \n',H5);
fprintf(f1,'%s \n',H6);
fprintf(f1,'%s \n',H7);
fprintf(f1,'%s \n',H8);
fprintf(f1,'%s \n',H9);
fprintf(f1,'%s \n',H11);
fprintf(f1,'%s \n',H12);
fprintf(f1,'%s \n',H13);
fprintf(f1,'%s \n',H14);
fprintf(f1,'%s \n',H15);
fprintf(f1,'\n');
fprintf(f1,'%s \n','convertToMeters 1;');
fprintf(f1,'%s \n','vertices');
fprintf(f1,'%s \n','(');
fprintf(f1,'%s (%f %f %f) \n',blanks(5),v0(1),v0(2),v0(3));
fprintf(f1,'%s (%f %f %f) \n',blanks(5),v1(1),v1(2),v1(3));
fprintf(f1,'%s (%f %f %f) \n',blanks(5),v2(1),v2(2),v2(3));
fprintf(f1,'%s (%f %f %f) \n',blanks(5),v3(1),v3(2),v3(3));
fprintf(f1,'%s (%f %f %f) \n',blanks(5),v4(1),v4(2),v4(3));
fprintf(f1,'%s (%f %f %f) \n',blanks(5),v5(1),v5(2),v5(3));
fprintf(f1,'%s \n',');');
fprintf(f1,'%s \n','blocks');
fprintf(f1,'%s \n','(');
fprintf(f1,'%s %s \n',blanks(5),'hex (0 2 1 0 3 5 4 3) (20 1 200) simpleGrading (1 1 1)');
fprintf(f1,'%s \n',');');
fprintf(f1,'%s \n','edges');
fprintf(f1,'%s \n','(');
fprintf(f1,'arc 1 2 (%f %f %f) \n',0,r,0);
fprintf(f1,'arc 4 5 (%f %f %f) \n',L,r,0);
fprintf(f1,'%s \n',');');
fprintf(f1,'%s \n','boundary');
fprintf(f1,'( \n');
fprintf(f1,'%s %s \n',blanks(5),'inlet');
fprintf(f1,'%s %s \n',blanks(5),'{');
fprintf(f1,'%s %s \n',blanks(10),'type patch;');
fprintf(f1,' %s \n','faces');
fprintf(f1,' %s \n','(');
fprintf(f1,' (%d %d %d %d)\n',0, 1, 2, 0);
fprintf(f1,' );\n');
fprintf(f1,' }\n');
fprintf(f1,' %s\n','outlet');
fprintf(f1,' {\n');
fprintf(f1,' %s\n','type patch;');
fprintf(f1,' %s\n','faces');
fprintf(f1,' (\n');
fprintf(f1,' (%d %d %d %d)\n',3, 4, 5, 3);
fprintf(f1,' );\n');
fprintf(f1,' }\n');
fprintf(f1,' %s\n','wedge_front');
fprintf(f1,' {\n');
fprintf(f1,' %s\n','type wedge;');
fprintf(f1,' %s\n','faces');
fprintf(f1,' (\n');
fprintf(f1,' (%d %d %d %d)\n',2, 5, 3, 0);
fprintf(f1,'\n');
fprintf(f1,' );\n');
fprintf(f1,' }\n');
fprintf(f1,' %s\n','wedge_back');
fprintf(f1,' {\n');
fprintf(f1,'%s\n',' type wedge;');
fprintf(f1,'%s\n',' faces');
fprintf(f1,' (\n');
fprintf(f1,'\n');
fprintf(f1,' (%d %d %d %d)\n',0, 3, 4, 1);
fprintf(f1,' );\n');
fprintf(f1,' }\n');
fprintf(f1,' %s\n','top');
fprintf(f1,' {\n');
fprintf(f1,' %s\n','type wall;');
fprintf(f1,' %s\n','faces');
fprintf(f1,' (\n');
fprintf(f1,' (%d %d %d %d)\n',1, 4, 5, 2);
fprintf(f1,' );\n');
fprintf(f1,' }\n');
fprintf(f1,' %s\n','axis');
fprintf(f1,' {\n');
fprintf(f1,' %s\n','type empty;');
fprintf(f1,' %s\n','faces');
fprintf(f1,' (\n');
fprintf(f1,' (%d %d %d %d)\n',0, 3, 3, 0);
fprintf(f1,' );\n');
fprintf(f1,' }\n');
fprintf(f1,' );\n');
fprintf(f1,'\n');
fprintf(f1,' %s\n','mergePatchPairs');
fprintf(f1,'(\n');
fprintf(f1,' );\n');
fprintf(f1,'\n');
fprintf(f1,' // ************************************************************************* //\n');
fclose(f1);
%for wedge bc & wedge angle 10deg
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0.000000 0.000000 0.000000)
(0.000000 0.009962 0.000872)
(0.000000 0.009962 -0.000872)
(3.020000 0.000000 0.000000)
(3.020000 0.009962 0.000872)
(3.020000 0.009962 -0.000872)
);
blocks
(
hex (0 2 1 0 3 5 4 3) (20 1 200) simpleGrading (1 1 1)
);
edges
(
arc 1 2 (0.000000 0.010000 0.000000)
arc 4 5 (3.020000 0.010000 0.000000)
);
boundary
(
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
wedge_front
{
type wedge;
faces
(
(2 5 3 0)
);
}
wedge_back
{
type wedge;
faces
(
(0 3 4 1)
);
}
top
{
type wall;
faces
(
(1 4 5 2)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom latestTime;
startTime 0;
stopAt endTime;
endTime 10;
deltaT 0.005;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Website: https://openfoam.org |
| \\ / A nd | Version: 10 |
| \\/ 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;
}
wedge_front
{
type wedge;
}
wedge_back
{
type wedge;
}
top
{
type zeroGradient;
}
axis
{
type empty;
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ 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.09373 0 0);
}
outlet
{
type zeroGradient;
}
top
{
type noSlip;
}
wedge_front
{
type wedge;
}
wedge_back
{
type wedge;
}
axis
{
type empty;
}
}
// ************************************************************************* //




%for wedge bc & wedge angle 25 deg
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0.000000 0.000000 0.000000)
(0.000000 0.009763 0.002164)
(0.000000 0.009763 -0.002164)
(3.020000 0.000000 0.000000)
(3.020000 0.009763 0.002164)
(3.020000 0.009763 -0.002164)
);
blocks
(
hex (0 2 1 0 3 5 4 3) (20 1 200) simpleGrading (1 1 1)
);
edges
(
arc 1 2 (0.000000 0.010000 0.000000)
arc 4 5 (3.020000 0.010000 0.000000)
);
boundary
(
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
wedge_front
{
type wedge;
faces
(
(2 5 3 0)
);
}
wedge_back
{
type wedge;
faces
(
(0 3 4 1)
);
}
top
{
type wall;
faces
(
(1 4 5 2)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom latestTime;
startTime 0;
stopAt endTime;
endTime 10;
deltaT 0.005;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Website: https://openfoam.org |
| \\ / A nd | Version: 10 |
| \\/ 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;
}
wedge_front
{
type wedge;
}
wedge_back
{
type wedge;
}
top
{
type zeroGradient;
}
axis
{
type empty;
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ 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.09373 0 0);
}
outlet
{
type zeroGradient;
}
top
{
type noSlip;
}
wedge_front
{
type wedge;
}
wedge_back
{
type wedge;
}
axis
{
type empty;
}
}
// ************************************************************************* //




%for wedge bc & wedge angle 45 deg
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0.000000 0.000000 0.000000)
(0.000000 0.009239 0.003827)
(0.000000 0.009239 -0.003827)
(3.020000 0.000000 0.000000)
(3.020000 0.009239 0.003827)
(3.020000 0.009239 -0.003827)
);
blocks
(
hex (0 2 1 0 3 5 4 3) (20 1 200) simpleGrading (1 1 1)
);
edges
(
arc 1 2 (0.000000 0.010000 0.000000)
arc 4 5 (3.020000 0.010000 0.000000)
);
boundary
(
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
wedge_front
{
type wedge;
faces
(
(2 5 3 0)
);
}
wedge_back
{
type wedge;
faces
(
(0 3 4 1)
);
}
top
{
type wall;
faces
(
(1 4 5 2)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom latestTime;
startTime 0;
stopAt endTime;
endTime 10;
deltaT 0.005;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Website: https://openfoam.org |
| \\ / A nd | Version: 10 |
| \\/ 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;
}
wedge_front
{
type wedge;
}
wedge_back
{
type wedge;
}
top
{
type zeroGradient;
}
axis
{
type empty;
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ 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.09373 0 0);
}
outlet
{
type zeroGradient;
}
top
{
type noSlip;
}
wedge_front
{
type wedge;
}
wedge_back
{
type wedge;
}
axis
{
type empty;
}
}
// ************************************************************************* //




%for symmetry bc
clear all
close all
clc
%parameters
Re=2100;
rho=1200;
D=0.02;
r=D/2;
mu=0.89e-3;
v=0.88927e-6;
theta=input('Enter wedge angle')
L_h=0.06*Re*D;
L=L_h+0.5;
V_avg=(Re*mu)/(rho*D);
V_max=2*V_avg;
P_drop=(32*mu*L*V_avg)/D^2;
P_kinematic=(P_drop)/rho;
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)]
H1='/*--------------------------------*- C++ -*----------------------------------*\';
H2=' ========= |';
H3=' \\ / F ield | OpenFOAM: The Open Source CFD Toolbox';
H4=' \\ / O peration | Website: https://openfoam.org';
H5=' \\ / A nd | Version: 10';
H6=' \\/ M anipulation |';
H7='\*---------------------------------------------------------------------------*/';
H8='FoamFile';
H9='{'
H11=' format ascii;';
H12=' class dictionary;';
H13=' object blockMeshDict;';
H14='}'
H15='// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //';
f1=fopen('blockMeshDict5.txt','wt');
fprintf(f1,'%s \n',H1);
fprintf(f1,'%s \n',H2);
fprintf(f1,'%s \n',H3);
fprintf(f1,'%s \n',H4);
fprintf(f1,'%s \n',H5);
fprintf(f1,'%s \n',H6);
fprintf(f1,'%s \n',H7);
fprintf(f1,'%s \n',H8);
fprintf(f1,'%s \n',H9);
fprintf(f1,'%s \n',H11);
fprintf(f1,'%s \n',H12);
fprintf(f1,'%s \n',H13);
fprintf(f1,'%s \n',H14);
fprintf(f1,'%s \n',H15);
fprintf(f1,'\n');
fprintf(f1,'%s \n','convertToMeters 1;');
fprintf(f1,'%s \n','vertices');
fprintf(f1,'%s \n','(');
fprintf(f1,'%s (%f %f %f) \n',blanks(5),v0(1),v0(2),v0(3));
fprintf(f1,'%s (%f %f %f) \n',blanks(5),v1(1),v1(2),v1(3));
fprintf(f1,'%s (%f %f %f) \n',blanks(5),v2(1),v2(2),v2(3));
fprintf(f1,'%s (%f %f %f) \n',blanks(5),v3(1),v3(2),v3(3));
fprintf(f1,'%s (%f %f %f) \n',blanks(5),v4(1),v4(2),v4(3));
fprintf(f1,'%s (%f %f %f) \n',blanks(5),v5(1),v5(2),v5(3));
fprintf(f1,'%s \n',');');
fprintf(f1,'%s \n','blocks');
fprintf(f1,'%s \n','(');
fprintf(f1,'%s %s \n',blanks(5),'hex (0 2 1 0 3 5 4 3) (40 1 500) simpleGrading (1 1 1)');
fprintf(f1,'%s \n',');');
fprintf(f1,'%s \n','edges');
fprintf(f1,'%s \n','(');
fprintf(f1,'arc 1 2 (%f %f %f) \n',0,r,0);
fprintf(f1,'arc 4 5 (%f %f %f) \n',L,r,0);
fprintf(f1,'%s \n',');');
fprintf(f1,'%s \n','boundary');
fprintf(f1,'( \n');
fprintf(f1,'%s %s \n',blanks(5),'inlet');
fprintf(f1,'%s %s \n',blanks(5),'{');
fprintf(f1,'%s %s \n',blanks(10),'type patch;');
fprintf(f1,' %s \n','faces');
fprintf(f1,' %s \n','(');
fprintf(f1,' (%d %d %d %d)\n',0, 1, 2, 0);
fprintf(f1,' );\n');
fprintf(f1,' }\n');
fprintf(f1,' %s\n','outlet');
fprintf(f1,' {\n');
fprintf(f1,' %s\n','type patch;');
fprintf(f1,' %s\n','faces');
fprintf(f1,' (\n');
fprintf(f1,' (%d %d %d %d)\n',3, 4, 5, 3);
fprintf(f1,' );\n');
fprintf(f1,' }\n');
fprintf(f1,' %s\n','wedge_front');
fprintf(f1,' {\n');
fprintf(f1,' %s\n','type symmetry;');
fprintf(f1,' %s\n','faces');
fprintf(f1,' (\n');
fprintf(f1,' (%d %d %d %d)\n',2, 5, 3, 0);
fprintf(f1,'\n');
fprintf(f1,' );\n');
fprintf(f1,' }\n');
fprintf(f1,' %s\n','wedge_back');
fprintf(f1,' {\n');
fprintf(f1,'%s\n',' type symmetry;');
fprintf(f1,'%s\n',' faces');
fprintf(f1,' (\n');
fprintf(f1,'\n');
fprintf(f1,' (%d %d %d %d)\n',0, 3, 4, 1);
fprintf(f1,' );\n');
fprintf(f1,' }\n');
fprintf(f1,' %s\n','top');
fprintf(f1,' {\n');
fprintf(f1,' %s\n','type wall;');
fprintf(f1,' %s\n','faces');
fprintf(f1,' (\n');
fprintf(f1,' (%d %d %d %d)\n',1, 4, 5, 2);
fprintf(f1,' );\n');
fprintf(f1,' }\n');
fprintf(f1,' %s\n','axis');
fprintf(f1,' {\n');
fprintf(f1,' %s\n','type empty;');
fprintf(f1,' %s\n','faces');
fprintf(f1,' (\n');
fprintf(f1,' (%d %d %d %d)\n',0, 3, 3, 0);
fprintf(f1,' );\n');
fprintf(f1,' }\n');
fprintf(f1,' );\n');
fprintf(f1,'\n');
fprintf(f1,' %s\n','mergePatchPairs');
fprintf(f1,'(\n');
fprintf(f1,' );\n');
fprintf(f1,'\n');
fprintf(f1,' // ************************************************************************* //\n');
fclose(f1);
%for symmetry bc & wedge angle 10 deg
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0.000000 0.000000 0.000000)
(0.000000 0.009962 0.000872)
(0.000000 0.009962 -0.000872)
(3.020000 0.000000 0.000000)
(3.020000 0.009962 0.000872)
(3.020000 0.009962 -0.000872)
);
blocks
(
hex (0 2 1 0 3 5 4 3) (40 1 500) simpleGrading (1 1 1)
);
edges
(
arc 1 2 (0.000000 0.010000 0.000000)
arc 4 5 (3.020000 0.010000 0.000000)
);
boundary
(
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
wedge_front
{
type symmetry;
faces
(
(2 5 3 0)
);
}
wedge_back
{
type symmetry;
faces
(
(0 3 4 1)
);
}
top
{
type wall;
faces
(
(1 4 5 2)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom latestTime;
startTime 0;
stopAt endTime;
endTime 10;
deltaT 0.005;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Website: https://openfoam.org |
| \\ / A nd | Version: 10 |
| \\/ 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;
}
wedge_front
{
type symmetry;
}
wedge_back
{
type symmetry;
}
top
{
type zeroGradient;
}
axis
{
type empty;
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ 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.09373 0 0);
}
outlet
{
type zeroGradient;
}
top
{
type noSlip;
}
wedge_front
{
type symmetry;
}
wedge_back
{
type symmetry;
}
axis
{
type empty;
}
}
// ************************************************************************* //




%for symmetry bc & wedge angle 25 deg
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0.000000 0.000000 0.000000)
(0.000000 0.009763 0.002164)
(0.000000 0.009763 -0.002164)
(3.020000 0.000000 0.000000)
(3.020000 0.009763 0.002164)
(3.020000 0.009763 -0.002164)
);
blocks
(
hex (0 2 1 0 3 5 4 3) (40 1 500) simpleGrading (1 1 1)
);
edges
(
arc 1 2 (0.000000 0.010000 0.000000)
arc 4 5 (3.020000 0.010000 0.000000)
);
boundary
(
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
wedge_front
{
type symmetry;
faces
(
(2 5 3 0)
);
}
wedge_back
{
type symmetry;
faces
(
(0 3 4 1)
);
}
top
{
type wall;
faces
(
(1 4 5 2)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom latestTime;
startTime 0;
stopAt endTime;
endTime 10;
deltaT 0.005;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Website: https://openfoam.org |
| \\ / A nd | Version: 10 |
| \\/ 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;
}
wedge_front
{
type symmetry;
}
wedge_back
{
type symmetry;
}
top
{
type zeroGradient;
}
axis
{
type empty;
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ 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.09373 0 0);
}
outlet
{
type zeroGradient;
}
top
{
type noSlip;
}
wedge_front
{
type symmetry;
}
wedge_back
{
type symmetry;
}
axis
{
type empty;
}
}
// ************************************************************************* //




%for symmetry bc & wedge angle 45 deg
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0.000000 0.000000 0.000000)
(0.000000 0.009239 0.003827)
(0.000000 0.009239 -0.003827)
(3.020000 0.000000 0.000000)
(3.020000 0.009239 0.003827)
(3.020000 0.009239 -0.003827)
);
blocks
(
hex (0 2 1 0 3 5 4 3) (40 1 500) simpleGrading (1 1 1)
);
edges
(
arc 1 2 (0.000000 0.010000 0.000000)
arc 4 5 (3.020000 0.010000 0.000000)
);
boundary
(
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
wedge_front
{
type symmetry;
faces
(
(2 5 3 0)
);
}
wedge_back
{
type symmetry;
faces
(
(0 3 4 1)
);
}
top
{
type wall;
faces
(
(1 4 5 2)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom latestTime;
startTime 0;
stopAt endTime;
endTime 10;
deltaT 0.005;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Website: https://openfoam.org |
| \\ / A nd | Version: 10 |
| \\/ 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;
}
wedge_front
{
type symmetry;
}
wedge_back
{
type symmetry;
}
top
{
type zeroGradient;
}
axis
{
type empty;
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ 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.09373 0 0);
}
outlet
{
type zeroGradient;
}
top
{
type noSlip;
}
wedge_front
{
type symmetry;
}
wedge_back
{
type symmetry;
}
axis
{
type empty;
}
}
// ************************************************************************* //




In order to conduct the validation study for the given simulation of flow through a pipe, we have to write separate blockMeshDict files using matlab codes, for each indivdual type and angles of 10,25 and 45 degrees individually for wedge and symmetry conditions, inside which we will be specifying all the parameters necessary to run the simulation. We first specify the given parameters, then open a .txt file, and then write all the steps inside the file and save it. Then, we open ubuntu, tutorials and inside tutorials incompressible inside which the solve icoFoam is chosen.
Inside icoFoam, we get cavity folder which we copy to our $FOAM_RUN folder using cp -r cavity $FOAM_RUN/cavity3 so that the original files remain untouched. then after copying, we replace all the data inside the blockMeshDIct file with the file we earlier created using matlab. Then, we specify all the necessary parameters such as the simulation run time, the time steps, the starting time and purge. Then we open the pressure file inide which we define the faces and their types, and similarly modify the velocity file as well. After entering all the required data, we give the value for nu inside the physicalproperties folder and save it.
After saving all the files, we use blockMesh command to run the mesh and then use checkMesh command to check for the appropriateness of mesh. Then we can use icoFoam command to run the simulation for the stipulated time and use paraview using paraFoam command to view the results.
We check all the parameters we need to see and then we view the velocity and pressure profiles correspondingly and use plot by line command to plot the line graph for velocity and pressure at last time step. These steps are repeated for all the 6 cases individually and the results are obtained.
Now, comparing the hydridynamic length, analytically, we can calculate as: L_h=0.06*Re*D, where Re is 2100, and D = 0.02. So, we get the length as 2.52m and from the plots, it is evident that only after the length of 2.52m, the the profile for velocity fully develops.
Now, comparing the pressure drops, we can get the analytical value using the formula given below:
`△ P = (V _(a v g) ⋅ μ ⋅ L )/D ^2` and for the values used, we get ``v_(avg)`as 0.0779. Now, we calculate `Delta`P and the value obtianed is 0.5233 units. The value obtained from the graph is 0.014 units.
Now, for the velocity profile, the values obtained from the graphs for maximum velocity is 0.16 units and the analytical value calculated is V_max=2*V_avg which is equal to 0.1557.
During the comparison between the simulation for both the conditions, it was evident that the simulation time for symmetry condition was much more higher than that taken for the wedge condition. This is because in symmetry condition, the calculations are done in all the 3 dimensions. Also, there is no significant change observed in the velocities for all the cases. But, for accurate results, symmetry condition can be preffered.