Symmetry vs Wedge vs HP equation
The main aim of this challenge is to write a MATLAB code which generates block mesh file for angles 10,25 and 45 degrees. Then solve them using the IcoFoam folder in openfoam and then compare velocity profiles at different length of pipe.
Parameters:
Working Fluid: Water
Reynolds Number(Re) : 2100
Wedge Angle: 2.5 degree
Diameter : 0.004m
Density : 997kg/m3
Absolute Viscosity(mu) : 1e-3Pa.s
Calculation:
Kinematic Viscosity(nu) = Absolute Viscosity/(Density) = 1e-6
Length of Pipe for fully developed flow = `0.05*Diameter*Reynolds Number` = 0.41m
Average Velocity = `Re*nu/D` = 0.52658m/s
Maximum Velocity = 2*Average Velocity = 1.05319m/s
Pressure drop in pipe flow = `(32*mu*v_(avg)*L)/D^2`=442.327N/m2
Kinematic Pressure = Pressure Drop/Density = 0.4423658m2/s2
MATLAB CODE FOR BLOCKMESH FILE:
clear all
close all
clc
%Inpit parameters
L = 0.5;
theta = 45;
d = 0.004;
r = d/2;
nx = 400;
ny = 50;
nz =1;
bd = fopen('blockMeshDictfinal','w');
fprintf(bd,'FoamFile\n{\n');
fprintf(bd,'%12s \t 2.0;\n','version');
fprintf(bd,'%11s \t ascii;\n','format');
fprintf(bd,'%10s \t dictionary;\n','class');
fprintf(bd,'%11s \t blockMeshDict;\n','object');
fprintf(bd,'}\n');
line8='// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //';
fprintf(bd,'%s\n\n',line8);
fprintf(bd,'convertToMeters 1;\n\n');
fprintf(bd,'vertices\n');
fprintf(bd,'(\n');
fprintf(bd,'\t (%d %d %d)\n',0,0,0); % point 0
fprintf(bd,'\t (%d %d %d)\n',0,r*cosd(theta/2),r*sind(theta/2)); % point 1
fprintf(bd,'\t (%d %d %d)\n',0,r*cosd(theta/2),-r*sind(theta/2)); % point 2
fprintf(bd,'\t (%d %d %d)\n',L,0,0); % Pont 3
fprintf(bd,'\t (%d %d %d)\n',L,r*cosd(theta/2),r*sind(theta/2)); % point 4
fprintf(bd,'\t (%d %d %d)\n',L,(r*cosd(theta/2)),-r*sind(theta/2)); % point 5
fprintf(bd,');\n\n');
fprintf(bd,'blocks\n');
fprintf(bd,'(\n');
fprintf(bd,' hex ( 0 3 5 2 0 3 4 1) (%d %d %d)',nx,ny,nz);
fprintf(bd, ' SimpleGrading (1 0.2 1)\n\n');
fprintf(bd,');\n\n');
fprintf(bd,'edges\n(\n\tarc %d %d (%d %d %d)\n',1,2,0,r,0);
fprintf(bd,'\tarc %d %d (%d %d %d)\n',4,5,L,r,0);
fprintf(bd,');\n\n');
fprintf(bd,'boundary\n(\n');
fprintf(bd,'\t inlet\n');
fprintf(bd,'\t{\n');
fprintf(bd,'\t\t type patch;\n');
fprintf(bd,'\t\t faces\n');
fprintf(bd,'\t\t (\n');
fprintf(bd,'\t\t\t (0 0 1 2)\n');
fprintf(bd,'\t\t );\n');
fprintf(bd,'\t}\n');
fprintf(bd,'\t outlet\n');
fprintf(bd,'\t{\n');
fprintf(bd,'\t\t type patch;\n');
fprintf(bd,'\t\t faces\n');
fprintf(bd,'\t\t (\n');
fprintf(bd,'\t\t\t (4 3 3 5)\n');
fprintf(bd,'\t\t );\n');
fprintf(bd,'\t}\n');
fprintf(bd,'\t top \n');
fprintf(bd,'\t{\n');
fprintf(bd,'\t\t type wall;\n');
fprintf(bd,'\t\t faces\n');
fprintf(bd,'\t\t (\n');
fprintf(bd,'\t\t\t (5 2 1 4)\n');
fprintf(bd,'\t\t );\n');
fprintf(bd,'\t}\n');
fprintf(bd,'\t back\n');
fprintf(bd,'\t{\n');
fprintf(bd,'\t\t type wedge;\n');
fprintf(bd,'\t\t faces\n');
fprintf(bd,'\t\t (\n');
fprintf(bd,'\t\t\t (5 3 0 2)\n');
fprintf(bd,'\t\t );\n');
fprintf(bd,'\t}\n');
fprintf(bd,'\t front\n');
fprintf(bd,'\t{\n');
fprintf(bd,'\t\t type wedge;\n');
fprintf(bd,'\t\t faces\n');
fprintf(bd,'\t\t (\n');
fprintf(bd,'\t\t\t (3 4 1 0)\n');
fprintf(bd,'\t\t );\n');
fprintf(bd,'\t}\n');
fprintf(bd,'\t axis\n');
fprintf(bd,'\t{\n');
fprintf(bd,'\t\t type empty;\n');
fprintf(bd,'\t\t faces\n');
fprintf(bd,'\t\t (\n');
fprintf(bd,'\t\t\t (0 3 3 0)\n');
fprintf(bd,'\t\t );\n');
fprintf(bd,'\t}\n');
fprintf(bd,');\n\n');
fprintf(bd,'mergePatchPairs\n(\n');
fprintf(bd,');\n');
BLOCK MESH DICT FILE FOR ANGLE 45 DEGREE:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0)
(0 1.847759e-03 7.653669e-04)
(0 1.847759e-03 -7.653669e-04)
(5.000000e-01 0 0)
(5.000000e-01 1.847759e-03 7.653669e-04)
(5.000000e-01 1.847759e-03 -7.653669e-04)
);
blocks
(
hex ( 0 3 5 2 0 3 4 1) (500 50 1) SimpleGrading (1 0.1 1)
);
edges
(
arc 1 2 (0 2.000000e-03 0)
arc 4 5 (5.000000e-01 2.000000e-03 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 5 4 3)
);
}
top
{
type wall;
faces
(
(1 4 5 2)
);
}
back
{
type wedge;
faces
(
(0 2 5 3)
);
}
front
{
type wedge;
faces
(
(0 3 4 1)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
NOTE: BY CHANGING VALUES FROM 45 TO 25 AND 10 WE CAN GET OTHER TWO BLOCKMESH FILE. IN ALL THREE BLOCKMESH FILES ONLY X, Y, Z CO-ORDINATES CHANGES REST ALL REMAIN CONSTANT
BLOCK MESH DICT FILE FOR ANGLE 25 DEGREE:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0)
(0 1.952592e-03 4.328792e-04)
(0 1.952592e-03 -4.328792e-04)
(5.000000e-01 0 0)
(5.000000e-01 1.952592e-03 4.328792e-04)
(5.000000e-01 1.952592e-03 -4.328792e-04)
);
blocks
(
hex ( 0 3 5 2 0 3 4 1) (500 50 1) SimpleGrading (1 0.1 1)
);
edges
(
arc 1 2 (0 2.000000e-03 0)
arc 4 5 (5.000000e-01 2.000000e-03 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 5 4 3)
);
}
top
{
type wall;
faces
(
(1 4 5 2)
);
}
back
{
type wedge;
faces
(
(0 2 5 3)
);
}
front
{
type wedge;
faces
(
(0 3 4 1)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
BLOCKMESH DICT FILE FOR ANGLE 10 DEGREE:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0)
(0 1.992389e-03 1.743115e-04)
(0 1.992389e-03 -1.743115e-04)
(5.000000e-01 0 0)
(5.000000e-01 1.992389e-03 1.743115e-04)
(5.000000e-01 1.992389e-03 -1.743115e-04)
);
blocks
(
hex ( 0 3 5 2 0 3 4 1) (500 50 1) SimpleGrading (1 0.1 1)
);
edges
(
arc 1 2 (0 2.000000e-03 0)
arc 4 5 (5.000000e-01 2.000000e-03 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 5 4 3)
);
}
top
{
type wall;
faces
(
(1 4 5 2)
);
}
back
{
type wedge;
faces
(
(0 2 5 3)
);
}
front
{
type wedge;
faces
(
(0 3 4 1)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
INLET VELOCITY:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ 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.52658 0 0);
}
outlet
{
type zeroGradient;
}
axis
{
type empty;
}
top
{
type noSlip;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
}
INLET PRESSURE:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ 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.44365;
}
axis
{
type empty;
}
top
{
type zeroGradient;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
}
TRANSPORT PROPERTIES:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nu [0 2 -1 0 0 0 0] 1e-6;
// ************************************************************************* //
OBSERVATIONS:
From the simulations velocity profiles for all three cases are same throughout the pipe as well it matches with the results calculated from the wedge-shaped model.
Fully developed flow occurs at the distance of 0.41m from inlet as calculated from Hagen poiseuille's equation. But the time taken to solve these three simulations are way higher than the time taken for simulation for running wedge shape pipe flow because of the angle used here (10,25 and 45 degrees)
Results obtained for 10 and 25 degrees are same as of 45 degree