All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Objective: Write a Matlab program that takes an angle as input and generates a blockMesh file for the given angle 10,25,45 degree. To compare the above results and discuss findings Calculation and Assumption Reynolds Number: 2100 Radius of pipe (r) :0.005 dynamics viscosity of water: 1.002 X 10^-3…
Om Yadav
updated on 19 May 2019
Objective:
Calculation and Assumption
Reynolds Number: 2100
Radius of pipe (r) :0.005
dynamics viscosity of water: 1.002 X 10^-3
Density of water :0.998 gm/cm3
Kinematic Viscosity of Water: 1.004 X 10^-6
length equation length of pipe:0.05 x Re x d=1.05
Hence the length of the pipe is taken as=2.1m
By using the Hagen Poiseuille\'s equation the pressure drop through the pipe is calculated
kinematic pressure drop in the pipe is 0.0717 m2/s2.
The code is written in Matlab and Blockmesh Dict file is generated by considering all the parameters provided in the questions.
% Code to create blockMeshDict file
clear all
close all
clc
L = 2.1;% Length of the pipe
theta = input(\'Wedge angle = \'); % Angle
r = 0.005; % Radius of the pipe
a = 1
b = 0.2
c = 1
nx = 300 % grid point along x-axis
ny = 50 % grid point along y-axis
nz =1 % grid point along z-axis
% Creating blockMesh file
line1=\'/*--------------------------------*- C++ -*----------------------------------*\\\';
line2=\'| ========= | |\';
line3=\'| \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox |\';
line4=\'| \\\\ / O peration | Version: 4.1 |\';
line5=\'| \\\\ / A nd | Web: www.OpenFOAM.org |\';
line6=\'| \\\\/ M anipulation | |\';
line7=\'\\*---------------------------------------------------------------------------*/\';
bmd = fopen(\'blockMeshDict\',\'wt\')
fprintf(bmd,\'%s\\n\',line1);
fprintf(bmd,\'%s\\n\',line2);
fprintf(bmd,\'%s\\n\',line3);
fprintf(bmd,\'%s\\n\',line4);
fprintf(bmd,\'%s\\n\',line5);
fprintf(bmd,\'%s\\n\',line6);
fprintf(bmd,\'%s\\n\',line7);
fprintf(bmd,\'FoamFile\\n{\\n\');
fprintf(bmd,\'%12s \\t 2.0;\\n\',\'version\');
fprintf(bmd,\'%11s \\t ascii;\\n\',\'format\');
fprintf(bmd,\'%10s \\t dictionary;\\n\',\'class\');
fprintf(bmd,\'%11s \\t blockMeshDict;\\n\',\'object\');
fprintf(bmd,\'}\\n\');
line8=\'// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //\';
fprintf(bmd,\'%s\\n\\n\',line8);
fprintf(bmd,\'convertToMeters 1;\\n\\n\');
fprintf(bmd,\'vertices\\n\');
fprintf(bmd,\'(\\n\');
fprintf(bmd,\'\\t (%d %d %d)\\n\',0,0,0); % point 0
fprintf(bmd,\'\\t (%d %d %d)\\n\',L,0,0); % Pont 1
fprintf(bmd,\'\\t (%d %d %d)\\n\',L,r*cosd(theta/2),r*sind(theta/2)); % point 2
fprintf(bmd,\'\\t (%d %d %d)\\n\',0,r*cosd(theta/2),r*sind(theta/2)); % point 3
fprintf(bmd,\'\\t (%d %d %d)\\n\',0,r*cosd(theta/2),-r*sind(theta/2)); % point 4
fprintf(bmd,\'\\t (%d %d %d)\\n\',L,(r*cosd(theta/2)),(-r*sind(theta/2))); % point 5
fprintf(bmd,\');\\n\\n\');
fprintf(bmd,\'blocks\\n\');
fprintf(bmd,\'(\\n\');
fprintf(bmd,\' hex ( 0 1 5 4 0 1 2 3) (%d %d %d)\',nx,ny,nz);
fprintf(bmd, \' SimpleGrading (%d %d %d)\\n\\n\',a,b,c);
fprintf(bmd,\');\\n\\n\');
fprintf(bmd,\'edges\\n(\\n\\tarc %d %d (%d %d %d)\\n\',4,3,0,r,0);
fprintf(bmd,\'\\tarc %d %d (%d %d %d)\\n\',5,2,L,r,0);
fprintf(bmd,\');\\n\\n\');
fprintf(bmd,\'boundary\\n(\\n\');
fprintf(bmd,\'\\t inlet\\n\');
fprintf(bmd,\'\\t{\\n\');
fprintf(bmd,\'\\t\\t type patch;\\n\');
fprintf(bmd,\'\\t\\t faces\\n\');
fprintf(bmd,\'\\t\\t (\\n\');
fprintf(bmd,\'\\t\\t\\t (%d %d %d %d)\\n\',0,0,3,4);
fprintf(bmd,\'\\t\\t );\\n\');
fprintf(bmd,\'\\t}\\n\');
fprintf(bmd,\'\\t outlet\\n\');
fprintf(bmd,\'\\t{\\n\');
fprintf(bmd,\'\\t\\t type patch;\\n\');
fprintf(bmd,\'\\t\\t faces\\n\');
fprintf(bmd,\'\\t\\t (\\n\');
fprintf(bmd,\'\\t\\t\\t (%d %d %d %d)\\n\',1,5,2,1);
fprintf(bmd,\'\\t\\t );\\n\');
fprintf(bmd,\'\\t}\\n\');
fprintf(bmd,\'\\t back\\n\');
fprintf(bmd,\'\\t{\\n\');
fprintf(bmd,\'\\t\\t type symmetry;\\n\');
fprintf(bmd,\'\\t\\t faces\\n\');
fprintf(bmd,\'\\t\\t (\\n\');
fprintf(bmd,\'\\t\\t\\t (%d %d %d %d)\\n\',0,4,5,1);
fprintf(bmd,\'\\t\\t );\\n\');
fprintf(bmd,\'\\t}\\n\');
fprintf(bmd,\'\\t front\\n\');
fprintf(bmd,\'\\t{\\n\');
fprintf(bmd,\'\\t\\t type symmetry;\\n\');
fprintf(bmd,\'\\t\\t faces\\n\');
fprintf(bmd,\'\\t\\t (\\n\');
fprintf(bmd,\'\\t\\t\\t (%d %d %d %d)\\n\',0,1,2,3);
fprintf(bmd,\'\\t\\t );\\n\');
fprintf(bmd,\'\\t}\\n\');
fprintf(bmd,\'\\t axis\\n\');
fprintf(bmd,\'\\t{\\n\');
fprintf(bmd,\'\\t\\t type empty;\\n\');
fprintf(bmd,\'\\t\\t faces\\n\');
fprintf(bmd,\'\\t\\t (\\n\');
fprintf(bmd,\'\\t\\t\\t (%d %d %d %d)\\n\',0,1,1,0);
fprintf(bmd,\'\\t\\t );\\n\');
fprintf(bmd,\'\\t}\\n\');
fprintf(bmd,\'\\t pipewall \\n\');
fprintf(bmd,\'\\t{\\n\');
fprintf(bmd,\'\\t\\t type wall;\\n\');
fprintf(bmd,\'\\t\\t faces\\n\');
fprintf(bmd,\'\\t\\t (\\n\');
fprintf(bmd,\'\\t\\t\\t (%d %d %d %d)\\n\',3,2,5,4);
fprintf(bmd,\'\\t\\t );\\n\');
fprintf(bmd,\'\\t}\\n\');
fprintf(bmd,\');\\n\\n\');
fprintf(bmd,\'mergePatchPairs\\n(\\n\');
fprintf(bmd,\');\\n\');
line9=\'// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //\';
fprintf(bmd,\'%s\\n\',line9);
fclose(bmd)
blockMesh Dict file generated by Matlab for an 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)
(2.100000e+00 0 0)
(2.100000e+00 4.980973e-03 4.357787e-04)
(0 4.980973e-03 4.357787e-04)
(0 4.980973e-03 -4.357787e-04)
(2.100000e+00 4.980973e-03 -4.357787e-04)
);
blocks
(
hex ( 0 1 5 4 0 1 2 3) (300 50 1) SimpleGrading (1 2.000000e-01 1)
);
edges
(
arc 4 3 (0 5.000000e-03 0)
arc 5 2 (2.100000e+00 5.000000e-03 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 0 3 4)
);
}
outlet
{
type patch;
faces
(
(1 5 2 1)
);
}
back
{
type symmetry;
faces
(
(0 4 5 1)
);
}
front
{
type symmetry;
faces
(
(0 1 2 3)
);
}
axis
{
type empty;
faces
(
(0 1 1 0)
);
}
pipewall
{
type wall;
faces
(
(3 2 5 4)
);
}
);
mergePatchPairs
(
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
blockMesh Dict file generated by Matlab for an 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)
(2.100000e+00 0 0)
(2.100000e+00 4.881480e-03 1.082198e-03)
(0 4.881480e-03 1.082198e-03)
(0 4.881480e-03 -1.082198e-03)
(2.100000e+00 4.881480e-03 -1.082198e-03)
);
blocks
(
hex ( 0 1 5 4 0 1 2 3) (300 50 1) SimpleGrading (1 2.000000e-01 1)
);
edges
(
arc 4 3 (0 5.000000e-03 0)
arc 5 2 (2.100000e+00 5.000000e-03 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 0 3 4)
);
}
outlet
{
type patch;
faces
(
(1 5 2 1)
);
}
back
{
type symmetry;
faces
(
(0 4 5 1)
);
}
front
{
type symmetry;
faces
(
(0 1 2 3)
);
}
axis
{
type empty;
faces
(
(0 1 1 0)
);
}
pipewall
{
type wall;
faces
(
(3 2 5 4)
);
}
);
mergePatchPairs
(
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
the blockMeshDict file generated by Matlab for an 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)
(2.100000e+00 0 0)
(2.100000e+00 4.619398e-03 1.913417e-03)
(0 4.619398e-03 1.913417e-03)
(0 4.619398e-03 -1.913417e-03)
(2.100000e+00 4.619398e-03 -1.913417e-03)
);
blocks
(
hex ( 0 1 5 4 0 1 2 3) (300 50 1) SimpleGrading (1 2.000000e-01 1)
);
edges
(
arc 4 3 (0 5.000000e-03 0)
arc 5 2 (2.100000e+00 5.000000e-03 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 0 3 4)
);
}
outlet
{
type patch;
faces
(
(1 5 2 1)
);
}
back
{
type symmetry;
faces
(
(0 4 5 1)
);
}
front
{
type symmetry;
faces
(
(0 1 2 3)
);
}
axis
{
type empty;
faces
(
(0 1 1 0)
);
}
pipewall
{
type wall;
faces
(
(3 2 5 4)
);
}
);
mergePatchPairs
(
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
the pressure conditions
/*--------------------------------*- 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
{
axis
{
type empty;
}
pipewall
{
type zeroGradient;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 10;
}
}
// ************************************************************************* //
the velocity boundary condition.
/*--------------------------------*- 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
{
axis
{
type empty;
}
pipewall
{
type fixedValue;
value uniform (0 0 0);
}
front
{
type symmetry;
}
back
{
type symmetry;
}
inlet
{
type fixedValue;
value uniform (0.2107 0 0);
}
outlet
{
type inletOutlet;
inletValue uniform (0.2107 0 0);
value uniform (0.2107 0 0);
}
}
// ************************************************************************* //
Results and plots of the various velocity conditions are given below:
All the fluid conditions are used similar to the first of the project. Here I have simulated three simulations with angle 10, 25, 45. initial conditions for each case of the simulation are the same. only the difference is in the front and back boundary condition here symmetry boundary condition is used which are given above.
The mesh structure is shown below:
Pipe flow model with an angle 10 degree.
The parameters like velocity and pressure are calculated at 1.05 meter from the entrance of the pipe are as follows.
Velocity: 0.4144 m/s
Pressure: 0.0736 (Kinematic Pressure)
Pipe flow model with an angle 25 degree.
The parameters like velocity and pressure are calculated at 1.05 meter from the entrance of the pipe are as follows.
Velocity: 0.456 m/s
Pressure: 0.0806 (Kinematic Pressure)
Pipe flow model with an angle 45 degree.
The parameters like velocity and pressure are calculated at 1.05 meter from the entrance of the pipe are as follows.
Velocity: 0.4164 m/s
Pressure: 0.0936 (Kinematic Pressure)
Theoretical Result calculated using Hagen Poisuelle\'s equation.
velocity: 0.4214 m/s
pressure: 0.07107 (Kinematic Pressure)
Comparision the result between the different wedge angle
Here, wedge angle 2 degree is with wedge BC and rest of all 10,25 and 45 degrees with symmetry BC.
Initially, the Matlab code is used to create the geometric model and mesh in both x and y directions. velocity condition for both input and output condition is provided for pipe flow. The wedges angle increases error will decrease . Hence from the above comparision, it is found that at wedge angle 3 degrees with wedge BC velocity profile will be fully developed and it takes lower simulation time.
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...
Simulation of Flow through a pipe in OpenFoam part 2
Objective: Write a Matlab program that takes an angle as input and generates a blockMesh file for the given angle 10,25,45 degree. To compare the above results and discuss findings Calculation and Assumption Reynolds Number: 2100 Radius of pipe (r) :0.005 dynamics viscosity of water: 1.002 X 10^-3…
19 May 2019 05:23 AM IST
Simulation of Flow through a pipe in OpenFoam part 1
Objective: To write a program in Matlab that can generate the computational mesh automatically for any wedge angle and grading schemes To show that the velocity profile matches with the Hagen Poiseuille\'s equation For a baseline mesh To show that the velocity profile is fully developed Post process…
19 May 2019 05:22 AM IST
BlockMesh Drill down challenge
The main objective is to use the icoFOAM solver to simulate the flow through a backward facing step. Initially, The geometry is generated for a variation of the incompressible cavity flow problem in OpenFOAM.The mesh is generated according to the need of the structure|(i.e with or without grading). …
07 Feb 2019 01:44 PM IST
Simulation of a 1D Super-sonic nozzle flow simulation using Macormack Method
The objective in this project is to write code to solve the 1D supersonic nozzle flow equations using the Macormack Method. The governing equations for both conservative and nonconservative are solved and compared. Also, the iteration number and computational time are compared until the final…
01 Nov 2018 12:39 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.