Week 11 - Simulation of Flow through a pipe in OpenFoam
Aim:-
- In this project we are simulating an axi-symmetric flow by applying the wedge boundary condition.
- where the flow is laminar and flows through a constant cross-section pipe at an inlet Reynold's number of 2100.
- And validate results with the Hagen- Poiseuille's equations for the fully developed flow.
DESCRIPTION:-
- The project simulates the Hegen-Poiseuille flow throught a pipe of circular cross section.
- The flow is axi-symmetric flow i.e. the flow is symmetric to the axis of pipe.
- Hence to reduce the complexity, simulate only a section of pipe i.e. wedge from which flow will be simulated.
- MATLAB scripting is done to generate automatically comutational mesh by a wedge angel of 5 deg.
- Creating blockMeshDict file by the programe writen in MATLAB and then replacing it with the file which is to be present in run folder.
- The folder is coppied to frun folder from the foam folder where we have to choose the solver, here the solver is icoFoam which is present in incompressible folder.
- As it is uses to solve the incompressible laminar by Navier-stroke equation to simulate the flow through pipe.
- Once the wedge is simulaed in run folder use paraFoam to gain the results, and observe the velocity profile of flow at hydrodynamic entrance length of the pipe and at fully devloped flow.
- The data from the CFD simulations obtained from the Hegen-Poiseuille Equations to ensure the fidelity results.
HYDRODYNAMIC ENTRANCE & FULLY DEVELOPED FLOW REGIONS:-

- The figure above shows two regions hydrodynamic entrance region and fully developed region, the entrance length is the distance a flow travels after antering the pipe.
- This length refers to length of thr entry region, the area following the pipe entrance whare the effect originating from the unterior wall of the pipe propogate into the flow as an expending boundary layer.
- When the boundary layer expands to fill the entire pipe, the developing flow becomes a fully developed flow, where flow characteristics no longer change with increased distance along the pipe.
- The hydrodynamic entrance region refers to thr area of a pipe where fluid entering a pipe develops a velocity profile due to viscous forces propagating from the interior wall of pipe.
- The region of flow in which the effects of viscous effects and velosity are suddenly changes is called as boundary layer.
- The boundary surface divides the flow in a pipe into two regions, the irrotational flow region and the boundary layer region
- The viscous affects the velocity changes are significant are in the boundary layer region, and friction effects are negligible and the velocity essentially remains in the radial directtion is the irrotational region
- The thickness of the boundary increases gradually with the flow, when it reaches mid-section the velocity profile becomes filly developed.
- This length where the flow converts to fully developed region from till the entry point, is called as hydridynamic entrance region.
- The flow in this region is called hydrodynamically developed flow since this is the region where the velocity profile develops and keeps changing.
- The flow in the region is fully developed flow and remains cinstant across the pipe, creating a parabolic velocity profile as shown in figure above
- The shear stress is directly proportional to the velocity gradient, thus the shear stress at wall is maximum and shear stress at center is minimum.
- The Hydrodynamic entrance length can be calculated using
">Le=0.05⋅Re⋅D��=0.05⋅��⋅�L e = 0.05 ⋅ R e ⋅ D
where, Re is renolds number and Dis diameter of pipe.
- HAGEN-POISEUILLE EQUATION:-
- In non fluid dynamics the hagen-poiseuille equation is a physical law that gives the pressure drop in an incompressible and newtonian fluid in laminar flow flowing throught a long cylinder pipe of constant cross section.
- The equations describes pressure drop as follows,
- where
">ΔPΔ�= Pressure diffrence between intel and outlet.Δ P
- Following are some assumptions,
- Fluid is incompressible and newtonian ie. the flow should follow Newton's law of viscosity
- The flow is laminar throught a pipe of constamt circular cross section that is substantiallyb longer then its diameter.
- There is no relative motion between fluid particles and solid boundaries, that is no slip of fluid at the solid boundary.
- There is no accleration of fluid in the pipe.
DERIVING SOLUTIONS FOR FLOW PARAMETERS
- Known values;
Re=2100;
L=3m;
D=0.02;
- Unknowns,
">Vavg����V a v g ">Vmax�maxV max ">Le��L e ">ΔPΔ�Δ P
1. We have reynold's number
2. We know that the maximum velocity is at the center of pipe
3. Calculating hydrodynamic entrance length
4. For calculating pressure drop we have hagen-poiseuille equation,
FILE WRITING
We have to create blockMeshDict file using matlab/octave coding by file parsing technique.
clear all
close all
clc
%input
Re=2100;
%length
L=3;
%dia
D=0.02;
theta= 5;
rho=997;
mu=0.892*1e-3;
R=D/2;
L_e= 0.058*Re*D;
meshx=200;
meshy=20;
meshz=1;
gradex=1;
gradey=0.2;
gradez=1;
V_avg= (Re*mu)/(rho*D);
V_max= 2*V_avg;
delta_p=(32*mu*L*V_avg)/(D^2);
kin_p=(delta_p)/(rho);
%determining the vertices of wdge
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','/*--------------------------------*- C++ -*----------------------------------*');
fprintf(f1,'\n========= | ');
fprintf(f1,'\n\\ / F ield | OpenFOAM: The Open Source CFD Toolbox');
fprintf(f1,'\n\\ / O peration | Website: https://openfoam.org');
fprintf(f1,'\n\\ / A nd | Version: 8');
fprintf(f1,'\n\\/ M anipulation |');
fprintf(f1,'\n*---------------------------------------------------------------------------*/');
fprintf(f1,'\nFoamFile');
fprintf(f1,'\n{');
fprintf(f1,'\nversion 2.0;')
fprintf(f1,'\nformat ascii;')
fprintf(f1,'\nclass dictionary;')
fprintf(f1,'\nobject blockMeshDict;')
fprintf(f1,'\n}');
fprintf(f1,'\n%s','// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //');
fprintf(f1,'\nconvertToMeters 1;');
fprintf(f1,'\nvertices');
fprintf(f1,'\n(');
fprintf(f1,'\n(%f %f %f)//point0',v0(1),v0(2),v0(3));
fprintf(f1,'\n(%f %f %f)//point1',v1(1),v1(2),v1(3));
fprintf(f1,'\n(%f %f %f)//point2',v2(1),v2(2),v2(3));
fprintf(f1,'\n(%f %f %f)//point3',v3(1),v3(2),v3(3));
fprintf(f1,'\n(%f %f %f)//point4',v4(1),v4(2),v4(3));
fprintf(f1,'\n(%f %f %f)//point5',v5(1),v5(2),v5(3));
fprintf(f1,'\n);');
fprintf(f1,'\nblocks');
fprintf(f1,'\n(');
fprintf(f1,'\n hex (0 3 5 2 0 3 4 1) (%d %d %d ) simpleGrading (%f %f %f)',meshx,meshy,meshz,gradex,gradey,gradez);
fprintf(f1,');');
fprintf(f1,'\nedges');
fprintf(f1,'\n(');
fprintf(f1,'\n arc 1 2 (%f %f %f)',0,R,0);
fprintf(f1,'\n arc 4 5 (%f %f %f)',L,R,0);
fprintf(f1,'\n);');
fprintf(f1,'\nboundary');
fprintf(f1,'\n(');
fprintf(f1,'\n inlet');
fprintf(f1,'\n {');
fprintf(f1,'\n type patch;');
fprintf(f1,'\n faces');
fprintf(f1,'\n (');
fprintf(f1,'\n (0 1 2 0)');
fprintf(f1,'\n );');
fprintf(f1,'\n }');
fprintf(f1,'\n outlet');
fprintf(f1,'\n {');
fprintf(f1,'\n type patch;');
fprintf(f1,'\n faces');
fprintf(f1,'\n (');
fprintf(f1,'\n (3 5 4 3)');
fprintf(f1,'\n );');
fprintf(f1,'\n }');
fprintf(f1,'\n topwall');
fprintf(f1,'\n {');
fprintf(f1,'\n type wall;');
fprintf(f1,'\n faces');
fprintf(f1,'\n (');
fprintf(f1,'\n (1 4 5 2)');
fprintf(f1,'\n );');
fprintf(f1,'\n }');
fprintf(f1,'\n front');
fprintf(f1,'\n {');
fprintf(f1,'\n type wedge;');
fprintf(f1,'\n faces');
fprintf(f1,'\n (');
fprintf(f1,'\n (0 3 4 1)');
fprintf(f1,'\n );');
fprintf(f1,'\n }');
fprintf(f1,'\n back');
fprintf(f1,'\n {');
fprintf(f1,'\n type wedge;');
fprintf(f1,'\n faces');
fprintf(f1,'\n (');
fprintf(f1,'\n (0 2 5 3)');
fprintf(f1,'\n );');
fprintf(f1,'\n }');
fprintf(f1,'\n axis');
fprintf(f1,'\n {');
fprintf(f1,'\n type empty;');
fprintf(f1,'\n faces');
fprintf(f1,'\n (');
fprintf(f1,'\n (0 3 3 0)');
fprintf(f1,'\n );');
fprintf(f1,'\n }');
fprintf(f1,'\n);');
fprintf(f1,'\nmergePatchPairs');
fprintf(f1,'\n(');
fprintf(f1,'\n);');
fprintf(f1,'\n// ************************************************************************* //');
After running the code we get our blockMeshDict file as Output,
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.000000 0.000000 0.000000)//point0
(0.000000 0.009990 0.000436)//point1
(0.000000 0.009990 -0.000436)//point2
(3.000000 0.000000 0.000000)//point3
(3.000000 0.009990 0.000436)//point4
(3.000000 0.009990 -0.000436)//point5
);
blocks
(
hex (0 3 5 2 0 3 4 1) (200 20 1 ) simpleGrading (1.000000 0.200000 1.000000));
edges
(
arc 1 2 (0.000000 0.010000 0.000000)
arc 4 5 (3.000000 0.010000 0.000000)
);
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)
);
}
front
{
type wedge;
faces
(
(0 3 4 1)
);
}
back
{
type wedge;
faces
(
(0 2 5 3)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
controlDict file:-
/*--------------------------------*- 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 50;
deltaT 0.01;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
Pressure file:-
/*--------------------------------*- 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;
}
topwall
{
type zeroGradient;
}
front
{
type wedge;
}
back
{
type wedge;
}
axis
{
type empty;
}
}
// ************************************************************************* //
VELOCITY FILE:-
/*--------------------------------*- 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 0 0);
boundaryField
{
inlet
{
type fixedValue;
value uniform (0.09 0 0);
}
outlet
{
type zeroGradient;
}
topwall
{
type noSlip;
}
front
{
type wedge;
}
back
{
type wedge;
}
axis
{
type empty;
}
}
// ************************************************************************* //
transposeProperty FILE:-
/*--------------------------------*- 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 "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nu [0 2 -1 0 0 0 0] 0.892e-6;
// ************************************************************************* //
Now apply blockMesh comand and checkMesh and confirm the mesh is generated.
MESHING


VELOCITY
- Inlet velocity at initial time step

- velocity at final time step
- PLOTS
- Velocity at final time step

- Pressure at final time step

- shear stress plot:-
-
