All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
The following is the simulation of a laminar flow of an incompressible fluid through the pipe in OpenFoam. The following figure depicts the physical situation of the flow. For a laminar flow, the hydrodynamic length, Lh=0.06⋅D⋅ReD, where D is pipe diameter, and ReD is Reynolds number…
Jaswanth Kalyan Kumar Alapati
updated on 07 Jan 2022
The following is the simulation of a laminar flow of an incompressible fluid through the pipe in OpenFoam.
The following figure depicts the physical situation of the flow.
For a laminar flow, the hydrodynamic length, Lh=0.06⋅D⋅ReD, where D is pipe diameter, and ReD is Reynolds number based on diameter.
Flow parameters:
D = 20 mm, L (pipe length) = 3000 mm, and ReD = 2100. Fluid is the water of density (ρ) = 996.59 kgm3 and viscosity (μ) = 0.000852 kgm−s. The inlet velocity (V) is determined as V = ReD⋅μρ⋅D = 0.089766102 ms.
Transient analysis of flow is performed using the icoFoam solver. The fluid domain for the simulation is prepared using blockMesh as follows. The wedge angle used is 30.
A MATLAB file (attached below) is created to write the blockMesh file for different flow parameters.
scale=0.001;
R=10; % In mm
theta=3; % In degrees
x=3000; % Length of pipe in mm
y=R*cos((theta/2)*pi/180); % y coordinate of corner points in mm
z=R*sin((theta/2)*pi/180); % z coordinate of corner points in mm
nx=3000; % no of cells along pipe length
ny=40; % no of cells along radial direction
gradef=0.1; % grading factor in radial direction
f=fopen('blockMeshDict.txt','w');
fprintf(f,'%s','/*--------------------------------*- C++ -*----------------------------------*\');
fprintf(f,'\n%s','| ========= | |');
fprintf(f,'\n%s','| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |');
fprintf(f,'\n%s','| \\ / O peration | Version: v2012 |');
fprintf(f,'\n%s','| \\ / A nd | Website: www.openfoam.com |');
fprintf(f,'\n%s','| \\/ M anipulation | |');
fprintf(f,'\n%s','\*---------------------------------------------------------------------------*/');
fprintf(f,'\n%s','FoamFile');
fprintf(f,'\n%s','{');
fprintf(f,'\n%s',' version ');
fprintf(f,'%.1f',2.0);
fprintf(f,'%s',';');
fprintf(f,'\n%s',' format ');
fprintf(f,'%s','ascii;');
fprintf(f,'\n%s',' class ');
fprintf(f,'%s','dictionary;');
fprintf(f,'\n%s',' object ');
fprintf(f,'%s','blockMeshDict;');
fprintf(f,'\n%s','}');
fprintf(f,'\n%s','// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //');
fprintf(f,'\n');
fprintf(f,'\n%s','scale ');
fprintf(f,'%.3f%s',scale,';');
fprintf(f,'\n');
fprintf(f,'\n%s','vertices');
fprintf(f,'\n%s','(');
fprintf(f,'\n%s%d %d %d%s',' (',0,0,0,')');
fprintf(f,'\n%s%d %.8f %.9f%s',' (',0,y,-1*z,')');
fprintf(f,'\n%s%d %.8f %.9f%s',' (',0,y,z,')');
fprintf(f,'\n%s%d %d %d%s',' (',x,0,0,')');
fprintf(f,'\n%s%d %.8f %.9f%s',' (',x,y,-1*z,')');
fprintf(f,'\n%s%d %.8f %.9f%s',' (',x,y,z,')');
fprintf(f,'\n%s',');');
fprintf(f,'\n');
fprintf(f,'\n%s','blocks');
fprintf(f,'\n%s','(');
fprintf(f,'\n %s','hex (');
fprintf(f,'%d %d %d %d %d %d %d %d%s',0,3,4,1,0,3,5,2,')');
fprintf(f,' %s%d %d %d%s','(',nx,ny,1,')');
fprintf(f,' %s','simpleGrading');
fprintf(f,' %s%d %.1f %d%s','(',1,gradef,1,')');
fprintf(f,'\n%s',');');
fprintf(f,'\n');
fprintf(f,'\n%s','edges');
fprintf(f,'\n%s','(');
fprintf(f,'\n %s','arc ');
fprintf(f,'%d %d',1,2);
fprintf(f,' %s%d %d %d%s','(',0,R,0,')');
fprintf(f,'\n %s','arc ');
fprintf(f,'%d %d',4,5);
fprintf(f,' %s%d %d %d%s','(',x,R,0,')');
fprintf(f,'\n%s',');');
fprintf(f,'\n');
fprintf(f,'\n%s','boundary');
fprintf(f,'\n%s','(');
fprintf(f,'\n %s','inlet');
fprintf(f,'\n %s','{');
fprintf(f,'\n %s','type patch;');
fprintf(f,'\n %s','faces');
fprintf(f,'\n %s','(');
fprintf(f,'\n %s%d %d %d %d%s','(',0,2,1,0,')');
fprintf(f,'\n %s',');');
fprintf(f,'\n %s','}');
fprintf(f,'\n %s','wall');
fprintf(f,'\n %s','{');
fprintf(f,'\n %s','type wall;');
fprintf(f,'\n %s','faces');
fprintf(f,'\n %s','(');
fprintf(f,'\n %s%d %d %d %d%s','(',1,2,5,4,')');
fprintf(f,'\n %s',');');
fprintf(f,'\n %s','}');
fprintf(f,'\n %s','axis');
fprintf(f,'\n %s','{');
fprintf(f,'\n %s','type empty;');
fprintf(f,'\n %s','faces');
fprintf(f,'\n %s','(');
fprintf(f,'\n %s%d %d %d %d%s','(',0,3,3,0,')');
fprintf(f,'\n %s',');');
fprintf(f,'\n %s','}');
fprintf(f,'\n %s','front');
fprintf(f,'\n %s','{');
fprintf(f,'\n %s','type wedge;');
fprintf(f,'\n %s','faces');
fprintf(f,'\n %s','(');
fprintf(f,'\n %s%d %d %d %d%s','(',0,3,5,2,')');
fprintf(f,'\n %s',');');
fprintf(f,'\n %s','}');
fprintf(f,'\n %s','back');
fprintf(f,'\n %s','{');
fprintf(f,'\n %s','type wedge;');
fprintf(f,'\n %s','faces');
fprintf(f,'\n %s','(');
fprintf(f,'\n %s%d %d %d %d%s','(',0,1,4,3,')');
fprintf(f,'\n %s',');');
fprintf(f,'\n %s','}');
fprintf(f,'\n %s','outlet');
fprintf(f,'\n %s','{');
fprintf(f,'\n %s','type patch;');
fprintf(f,'\n %s','faces');
fprintf(f,'\n %s','(');
fprintf(f,'\n %s%d %d %d %d%s','(',3,4,5,3,')');
fprintf(f,'\n %s',');');
fprintf(f,'\n %s','}');
fprintf(f,'\n%s',');');
fprintf(f,'\n');
fprintf(f,'\n%s','mergePatchPairs');
fprintf(f,'\n%s','(');
fprintf(f,'\n%s',');');
fprintf(f,'\n');
fprintf(f,'\n%s','// ************************************************************************* //');
fprintf(f,'\n');
fclose(f);
The blockMesh file generated is as follows.
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
scale 0.001;
vertices
(
(0 0 0)
(0 9.99657325 -0.261769483)
(0 9.99657325 0.261769483)
(3000 0 0)
(3000 9.99657325 -0.261769483)
(3000 9.99657325 0.261769483)
);
blocks
(
hex (0 3 4 1 0 3 5 2) (3000 40 1) simpleGrading (1 0.1 1)
);
edges
(
arc 1 2 (0 10 0)
arc 4 5 (3000 10 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 2 1 0)
);
}
wall
{
type wall;
faces
(
(1 2 5 4)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
front
{
type wedge;
faces
(
(0 3 5 2)
);
}
back
{
type wedge;
faces
(
(0 1 4 3)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
Boundary conditions are as follows.
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 101.6717005;
boundaryField
{
inlet
{
type zeroGradient;
}
wall
{
type zeroGradient;
}
axis
{
type empty;
}
front
{
type wedge;
}
back
{
type wedge;
}
outlet
{
type fixedValue;
value uniform 101.6717005;
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ 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.089766102 0 0);
}
wall
{
type noSlip;
}
axis
{
type empty;
}
front
{
type wedge;
}
back
{
type wedge;
}
outlet
{
type zeroGradient;
}
}
// ************************************************************************* //
The controlDict is as follows.
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 40;
deltaT 0.005;
writeControl runTime;
writeInterval 2;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
The simulation reached a steady state at the time, t = 26 s.
Analytically, the hydrodynamic length, Lh = 0.06*2100*0.02 = 2.52 m.
The velocity (magnitude) distribution along the axial direction at steady state is obtained as follows.
From the above plot, the velocity profile is fully developed approximately at x = 2.5 m.
Radial distributions of velocity at x = 2.8 m.
Radial distributions of velocity at x = 3 m.
At the inlet, velocity is mentioned. At outlet, pressure is mentioned.
Maximum velocity (at the centerline) through simulation is 0.1784 ms while the analytical value is 0.1795 ms.
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Week 1- Mixing Tee
This assignment aims to evaluate the mixing effectiveness of a Tee joint with two different outlet pipe lengths, namely small and long. The required Tee geometry is provided, and the interior volume for CFD analysis is extracted as shown below. Tee geometry with shorter outlet pipe: Extracted…
03 Sep 2022 08:13 PM IST
Week 12 - Validation studies of Symmetry BC vs Wedge BC in OpenFOAM vs Analytical H.P equation
Unlike in the previous assignment, where the simulation is performed using a transient solver icoFoam, the simulation is carried out using a steady-state solver simpleFoam since the emphasis is on the steady-state flow field. This assignment aims to compare the boundary conditions of Wedge and Symmetry…
11 Jan 2022 11:09 AM IST
Week 11 - Simulation of Flow through a pipe in OpenFoam
The following is the simulation of a laminar flow of an incompressible fluid through the pipe in OpenFoam. The following figure depicts the physical situation of the flow. For a laminar flow, the hydrodynamic length, Lh=0.06⋅D⋅ReD, where D is pipe diameter, and ReD is Reynolds number…
07 Jan 2022 10:13 AM IST
Week 9 - FVM Literature Review
Finite Volume Method (FVM) is a numerical technique for solving partial differential equations governing the phenomena. The method involves discretizing the domain into smaller volumes. These control volumes are connected by common faces. The governing equation in integral form is applied for all the control volumes followed…
26 Dec 2021 07:15 AM IST
Related Courses
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.