Week 12 - Symmetry vs Wedge vs HP equation
Aim:
Matlab code:
clear all
close all
clc
%input data
D=0.01
R=D/2
Re=2100
Le=0.05*Re*D;
theta=[10];
mu=8.90e-04;
rho=997.130;
nu=(mu/rho);
L=Le+0.45
%calculating solution according to HP equation
V=(Re*mu)/(rho*D); %average velcoity
U_max=2*V; %max velocity
del_Pdel_x=(8*mu*V)/(R^2); % pressure gradient
delta_P=(8*mu*V*L)/(R^2); % pressure drop
Kin_P= 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)]
f1= fopen('BlockMeshDict.txt','w');
fprintf(f1, '%s\n', '/*--------------------------------*- C++ -*----------------------------------*\');
fprintf(f1, '%s\n', '========= | ');
fprintf(f1, '%s\n', '\\ / F ield | OpenFOAM: The Open Source CFD Toolbox ');
fprintf(f1, '%s\n', ' \\ / O peration | Website: https://openfoam.org ');
fprintf(f1, '%s\n', ' \\ / A nd | Version: 8 ');
fprintf(f1, '%s\n', ' \\/ M anipulation | ');
fprintf(f1, '%s\n', '\*---------------------------------------------------------------------------*/');
fprintf(f1, '%s\n', 'FoamFile');
fprintf(f1, '%s\n', '{');
fprintf(f1, '%s\n', ' version 2.0;');
fprintf(f1, '%s\n', ' format ascii;');
fprintf(f1, '%s\n', ' class dictionary;');
fprintf(f1, '%s\n', ' object blockMeshDict;');
fprintf(f1, '%s\n', '}');
fprintf(f1, '%s\n', '// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //');
fprintf(f1, '%s\n', ' convertToMeters 1;');
%defining the vertices of the geometry
fprintf(f1, '%s\n', 'vertices');
fprintf(f1, '%s\n', '(');
fprintf(f1, '\t(%d %d %d)\n' ,v0(1),v0(2),v0(3));
fprintf(f1, '\t(%d %d %d)\n' ,v1(1),v1(2),v1(3));
fprintf(f1, '\t(%d %d %d)\n' ,v2(1),v2(2),v2(3));
fprintf(f1, '\t(%d %d %d)\n' ,v3(1),v3(2),v3(3));
fprintf(f1, '\t(%d %d %d)\n' ,v4(1),v4(2),v4(3));
fprintf(f1, '\t(%d %d %d)\n' ,v5(1),v5(2),v5(3));
fprintf(f1, '%s\n\n',');');
%defining the blocks
fprintf(f1, '%s\n', 'blocks');
fprintf(f1, '%s\n', '(');
fprintf(f1, '\thex(0 1 2 0 3 4 5 3) (%d %d %d) simpleGrading(1 1 1)\n',300,1,30);
fprintf(f1, '%s\n\n',');');
%defining the edges
fprintf(f1, '%s\n', 'edges');
fprintf(f1, '%s\n', '(');
fprintf(f1, '\tarc %d %d (%d %d %d)\n' ,1,2,0,R,0);
fprintf(f1, '\tarc %d %d (%d %d %d)\n' ,4,5,L,R,0);
fprintf(f1, '%s\n\n',');');
%defining the boundaries
fprintf(f1, '%s\n', 'boundary');
fprintf(f1, '%s\n', '(');
fprintf(f1, '\tinlet\n\t{\n');
fprintf(f1, '\t\ttype patch;\n');
fprintf(f1, '\t\tfaces\n\t\t(\n');
fprintf(f1, '\t\t\t(0 2 1 0)\n');
fprintf(f1, '\t\t);\n\t}\n');
fprintf(f1, '\toutlet\n\t{\n');
fprintf(f1, '\t\ttype patch;\n');
fprintf(f1, '\t\tfaces\n\t\t(\n');
fprintf(f1, '\t\t\t(3 4 5 3)\n');
fprintf(f1, '\t\t);\n\t}\n');
fprintf(f1, '\twedge_front\n\t{\n');
fprintf(f1, '\t\ttype symmetry;\n');
fprintf(f1, '\t\tfaces\n\t\t(\n');
fprintf(f1, '\t\t\t(0 3 5 2)\n');
fprintf(f1, '\t\t);\n\t}\n');
fprintf(f1, '\twedge_back\n\t{\n');
fprintf(f1, '\t\ttype symmetry;\n');
fprintf(f1, '\t\tfaces\n\t\t(\n');
fprintf(f1, '\t\t\t(0 1 4 3)\n');
fprintf(f1, '\t\t);\n\t}\n');
fprintf(f1, '\ttop\n\t{\n');
fprintf(f1, '\t\ttype wall;\n');
fprintf(f1, '\t\tfaces\n\t\t(\n');
fprintf(f1, '\t\t\t(1 2 5 4)\n');
fprintf(f1, '\t\t);\n\t}\n');
fprintf(f1, '\taxis\n\t{\n');
fprintf(f1, '\t\ttype empty;\n');
fprintf(f1, '\t\tfaces\n\t\t(\n');
fprintf(f1, '\t\t\t(0 3 3 0)\n');
fprintf(f1, '\t\t);\n\t}\n');
fprintf(f1, ');\n\n');
fprintf(f1, 'mergePatchPairs\n(\n);\n\n');
fprintf(f1, '// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //');
fclose(f1)
WEDGE BOUNDARY CONDITION:
Angle 10:
BlockMeshDict:
/*--------------------------------*- 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 4.9809735e-03 -4.357787e-04)
(0 4.9809735e-03 4.357787e-04)
(1.5 0 0)
(1.5 4.9809735e-03 -4.357787e-04)
(1.5 4.9809735e-03 4.357787e-04)
);
blocks
(
hex (0 1 2 0 3 4 5 3) (30 1 100) simpleGrading (0.2 1 1)
);
edges
(
arc 1 2 (0 5.000000e-03 0)
arc 4 5 (1.5 5.000000e-03 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 2 1 0)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
top
{
type wall;
faces
(
(2 5 4 1)
);
}
wedge_back
{
type wedge;
faces
(
(0 1 4 3)
);
}
wedge_front
{
type wedge;
faces
(
(0 3 5 2)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
ControlDict:
/*--------------------------------*- 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;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 10;
deltaT 1e-2;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
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.187462 0 0);
boundaryField
{
inlet
{
type fixedValue;
value uniform (0.187462 0 0);
}
outlet
{
type zeroGradient;
}
top
{
type noSlip;
value uniform 0;
}
wedge_back
{
type wedge;
}
wedge_front
{
type wedge;
}
axis
{
type empty;
}
}
// ************************************************************************* //
Pressure:
/*--------------------------------*- 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
{
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
top
{
type zeroGradient;
}
wedge_back
{
type wedge;
}
wedge_front
{
type wedge;
}
axis
{
type empty;
}
}
// ************************************************************************* //
Results:





Angle 25:
BlockMeshDict:
/*--------------------------------*- 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 4.88148e-03 -1.0821981e-03)
(0 4.88148e-03 1.0821981e-03)
(1.5 0 0)
(1.5 4.88148e-03 -1.0821981e-03)
(1.5 4.88148e-03 1.0821981e-03)
);
blocks
(
hex (0 1 2 0 3 4 5 3) (30 1 100) simpleGrading (0.2 1 1)
);
edges
(
arc 1 2 (0 5.000000e-03 0)
arc 4 5 (1.5 5.000000e-03 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 2 1 0)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
top
{
type wall;
faces
(
(2 5 4 1)
);
}
wedge_back
{
type wedge;
faces
(
(0 1 4 3)
);
}
wedge_front
{
type wedge;
faces
(
(0 3 5 2)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
Results:





Angle 45:
BlockMeshDict:
/*--------------------------------*- 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 4.6193977e-03 -1.9134172e-03)
(0 4.6193977e-03 1.9134172e-03)
(1.5 0 0)
(1.5 4.6193977e-03 -1.9134172e-03)
(1.5 4.6193977e-03 1.9134172e-03)
);
blocks
(
hex (0 1 2 0 3 4 5 3) (30 1 100) simpleGrading (0.2 1 1)
);
edges
(
arc 1 2 (0 4.600000e-03 0)
arc 4 5 (1.5 4.600000e-03 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 2 1 0)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
top
{
type wall;
faces
(
(2 5 4 1)
);
}
wedge_back
{
type wedge;
faces
(
(0 1 4 3)
);
}
wedge_front
{
type wedge;
faces
(
(0 3 5 2)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
Results:





SYMMETRY BOUNDARY CONDITION:
Angle 10:
BlockMeshDict:
/*--------------------------------*- 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 4.9809735e-03 -4.357787e-04)
(0 4.9809735e-03 4.357787e-04)
(1.5 0 0)
(1.5 4.9809735e-03 -4.357787e-04)
(1.5 4.9809735e-03 4.357787e-04)
);
blocks
(
hex (0 1 2 0 3 4 5 3) (30 1 100) simpleGrading (0.2 1 1)
);
edges
(
arc 1 2 (0 5.000000e-03 0)
arc 4 5 (1.5 5.000000e-03 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 2 1 0)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
top
{
type wall;
faces
(
(2 5 4 1)
);
}
wedge_back
{
type symmetry;
faces
(
(0 1 4 3)
);
}
wedge_front
{
type symmetry;
faces
(
(0 3 5 2)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
ControlDict:
/*--------------------------------*- 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;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 10;
deltaT 1e-2;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
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.187462 0 0);
boundaryField
{
inlet
{
type fixedValue;
value uniform (0.187462 0 0);
}
outlet
{
type zeroGradient;
}
top
{
type noSlip;
value uniform 0;
}
wedge_back
{
type symmetry;
}
wedge_front
{
type symmetry;
}
axis
{
type empty;
}
}
// ************************************************************************* //
Pressure:
/*--------------------------------*- 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
{
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
top
{
type zeroGradient;
}
wedge_back
{
type symmetry;
}
wedge_front
{
type symmetry;
}
axis
{
type empty;
}
}
// ************************************************************************* //
Results:




Angle 25:
BlockMeshDict:
/*--------------------------------*- 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 4.88148e-03 -1.0821981e-03)
(0 4.88148e-03 1.0821981e-03)
(1.5 0 0)
(1.5 4.88148e-03 -1.0821981e-03)
(1.5 4.88148e-03 1.0821981e-03)
);
blocks
(
hex (0 1 2 0 3 4 5 3) (30 1 100) simpleGrading (0.2 1 1)
);
edges
(
arc 1 2 (0 5.000000e-03 0)
arc 4 5 (1.5 5.000000e-03 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 2 1 0)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
top
{
type wall;
faces
(
(2 5 4 1)
);
}
wedge_back
{
type symmetry;
faces
(
(0 1 4 3)
);
}
wedge_front
{
type symmetry;
faces
(
(0 3 5 2)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
Results:





Angle 45:
BlockMeshDict:
/*--------------------------------*- 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 4.6193977e-03 -1.9134172e-03)
(0 4.6193977e-03 1.9134172e-03)
(1.5 0 0)
(1.5 4.6193977e-03 -1.9134172e-03)
(1.5 4.6193977e-03 1.9134172e-03)
);
blocks
(
hex (0 1 2 0 3 4 5 3) (30 1 100) simpleGrading (0.2 1 1)
);
edges
(
arc 1 2 (0 4.600000e-03 0)
arc 4 5 (1.5 4.600000e-03 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 2 1 0)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
top
{
type wall;
faces
(
(2 5 4 1)
);
}
wedge_back
{
type symmetry;
faces
(
(0 1 4 3)
);
}
wedge_front
{
type symmetry;
faces
(
(0 3 5 2)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
Results:





Comparison:
(Analytical) (Numerical) (%) Time(sec) number
10 0.374924 0.37900 1.08% 49s 0.124629
25 0.374924 0.37770 0.74% 38s 0.493524
45 0.374924 0.37750 0.71% 39s 0.504651