All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Objective: To simulate an axisymmetric flow by applying the wedge boundary condition. To write code in Matlab to automate the generation of blockMeshDict file. Assumptions: Steady flow, incompressible and laminar flow Flow is two dimensional Constant fluid properties (Viscosity, Density, etc) Hagen-…
Ravi Shankar Yadav
updated on 09 Jan 2022
Objective:
Assumptions:
Hagen- Poiseuille's Equation:
In nonideal 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 through a long cylindrical pipe of a constant cross-section.
The pressure is given as Δp=8μLQπR4
Δp = Pressure difference between the two ends
L = Length of pipe
μ = Dynamic viscosity
Q = Volumetric flow rate
R = pipe radius
Given:
Analytical Solution:
Matlab code for generating the blockMeshDict file:
% Matlab code for generating the blockMeshDict file
clear all
close all
clc
% Inputs
% Wedge angle
theta = input('Enter the value of wedge angle = ');
% Reynolds number
Re =2100;
% Diameter
D=0.02;
% Length
L=0.06*Re*D;
% Radius
R=D/2;
% Dynamic viscosity
mu=0.89e-3;
% Density
rho=997.0;
% Kinematic viscosity
nu=mu/rho;
% Pressure and velocity
v_avg=Re*mu/(D*rho);
v_max=2*v_avg;
del_P =(32*mu*v_avg*L)/(D^2);
kin_P=del_P/rho;
n1=50;
n2=1;
n3=300;
gfactor=0.5;
% Vertices of the wedge
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)];
% Printing the contents of blockMesh file
string1='/*-------------------------------------*- C++ -*---------------------*\';
string2=' ========= | ';
string3=' \ / F ield | ';
string4=' \ / O peration |OPENFOAM:The Open Source CFD Toolbox ';
string5=' \ / A nd |Version: 9 ';
string6=' \ / M anipulation |Website: https://openfoam.org ';
string7='\*-------------------------------------------------------------------*/';
string8='FoamFile';
string9='{';
string10=' version 2.0;';
string11=' format acsii;';
string12=' class dictionary;';
string13=' object blockMeshDict;';
string14='}';
string15='//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //';
string16='//*******************************************************************//';
fpointer=fopen('blockMeshDict.txt','wt');
fprintf(fpointer,'%s\n',string1);
fprintf(fpointer,'%s\n',string2);
fprintf(fpointer,'%s\n',string3);
fprintf(fpointer,'%s\n',string4);
fprintf(fpointer,'%s\n',string5);
fprintf(fpointer,'%s\n',string6);
fprintf(fpointer,'%s\n \n',string7);
fprintf(fpointer,'%s\n',string8);
fprintf(fpointer,'%s\n',string9);
fprintf(fpointer,'%s\n',string10);
fprintf(fpointer,'%s\n',string11);
fprintf(fpointer,'%s\n',string12);
fprintf(fpointer,'%s\n',string13);
fprintf(fpointer,'%s\n',string14);
fprintf(fpointer,'%s\n \n',string15);
fprintf(fpointer,'%s\n','convertToMeters 1;');
fprintf(fpointer,'%s\n','vertices');
fprintf(fpointer,'%s\n','(');
fprintf(fpointer,'%s (%f %f %f)\n',blanks(5),V0(1),V0(2),V0(3));
fprintf(fpointer,'%s (%f %f %f)\n',blanks(5),V1(1),V1(2),V1(3));
fprintf(fpointer,'%s (%f %f %f)\n',blanks(5),V2(1),V2(2),V2(3));
fprintf(fpointer,'%s (%f %f %f)\n',blanks(5),V3(1),V3(2),V3(3));
fprintf(fpointer,'%s (%f %f %f)\n',blanks(5),V4(1),V4(2),V4(3));
fprintf(fpointer,'%s (%f %f %f)\n',blanks(5),V5(1),V5(2),V5(3));
fprintf(fpointer,'%s\n',');');
fprintf(fpointer,'\n');
fprintf(fpointer,'%s\n','blocks');
fprintf(fpointer,'%s\n','(');
fprintf(fpointer,'%s %s \n',blanks(5),'hex (0 1 2 0 3 4 5 3 ) (50 1 200) simpleGrading (0.5 1 1)');
fprintf(fpointer,'%s\n',');');
fprintf(fpointer,'\n');
fprintf(fpointer,'%s\n','edges');
fprintf(fpointer,'%s\n','(');
fprintf(fpointer,'%s arc 1 2 (%f %f %f)\n',blanks(5),0,R,0);
fprintf(fpointer,'%s arc 4 5 (%f %f %f)\n',blanks(5),0,R,0);
fprintf(fpointer,'%s\n',');');
fprintf(fpointer,'\n');
fprintf(fpointer,'%s\n','boundary');
fprintf(fpointer,'%s\n','(');
fprintf(fpointer,'%s %s\n',blanks(5),'inlet');
fprintf(fpointer,'%s %s\n',blanks(5),'{');
fprintf(fpointer,'%s %s\n',blanks(10),'type patch;');
fprintf(fpointer,'%s %s\n',blanks(10),'faces');
fprintf(fpointer,'%s %s\n',blanks(10),'(');
fprintf(fpointer,'%s %s\n',blanks(15),'(0 1 2 0 )');
fprintf(fpointer,'%s %s\n',blanks(10),');');
fprintf(fpointer,'%s %s\n',blanks(5),'}');
fprintf(fpointer,'%s %s\n',blanks(5),'outlet');
fprintf(fpointer,'%s %s\n',blanks(5),'{');
fprintf(fpointer,'%s %s\n',blanks(10),'type patch;');
fprintf(fpointer,'%s %s\n',blanks(10),'faces');
fprintf(fpointer,'%s %s\n',blanks(10),'(');
fprintf(fpointer,'%s %s\n',blanks(15),'(3 4 5 3)');
fprintf(fpointer,'%s %s\n',blanks(10),');');
fprintf(fpointer,'%s %s\n',blanks(5),'}');
fprintf(fpointer,'%s %s\n',blanks(5),'front');
fprintf(fpointer,'%s %s\n',blanks(5),'{');
fprintf(fpointer,'%s %s\n',blanks(10),'type wedge;');
fprintf(fpointer,'%s %s\n',blanks(10),'faces');
fprintf(fpointer,'%s %s\n',blanks(10),'(');
fprintf(fpointer,'%s %s\n',blanks(15),'(0 3 5 2)');
fprintf(fpointer,'%s %s\n',blanks(10),');');
fprintf(fpointer,'%s %s\n',blanks(5),'}');
fprintf(fpointer,'%s %s\n',blanks(5),'back');
fprintf(fpointer,'%s %s\n',blanks(5),'{');
fprintf(fpointer,'%s %s\n',blanks(10),'type wedge;');
fprintf(fpointer,'%s %s\n',blanks(10),'faces');
fprintf(fpointer,'%s %s\n',blanks(10),'(');
fprintf(fpointer,'%s %s\n',blanks(15),'(0 1 4 3)');
fprintf(fpointer,'%s %s\n',blanks(10),');');
fprintf(fpointer,'%s %s\n',blanks(5),'}');
fprintf(fpointer,'%s %s\n',blanks(5),'pipe');
fprintf(fpointer,'%s %s\n',blanks(5),'{');
fprintf(fpointer,'%s %s\n',blanks(10),'type wall;');
fprintf(fpointer,'%s %s\n',blanks(10),'faces');
fprintf(fpointer,'%s %s\n',blanks(10),'(');
fprintf(fpointer,'%s %s\n',blanks(15),'(1 4 5 2)');
fprintf(fpointer,'%s %s\n',blanks(10),');');
fprintf(fpointer,'%s %s\n',blanks(5),'}');
fprintf(fpointer,'%s %s\n',blanks(5),'axis');
fprintf(fpointer,'%s %s\n',blanks(5),'{');
fprintf(fpointer,'%s %s\n',blanks(10),'type empty;');
fprintf(fpointer,'%s %s\n',blanks(10),'faces');
fprintf(fpointer,'%s %s\n',blanks(10),'(');
fprintf(fpointer,'%s %s\n',blanks(15),'(0 3 3 0)');
fprintf(fpointer,'%s %s\n',blanks(10),');');
fprintf(fpointer,'%s %s\n',blanks(5),'}');
fprintf(fpointer,'%s\n',');');
fprintf(fpointer,'\n');
fprintf(fpointer,'%s\n','mergePatchPairs');
fprintf(fpointer,'%s\n','(');
fprintf(fpointer,'%s\n',');');
fprintf(fpointer,'\n');
fprintf(fpointer,'%s\n',string16);
fclose(fpointer);
BlockMeshDict File:
The blockMeshDict file generated by the MATLAB program will replace the blockMeshDict in the OpenFoam
/*-------------------------------------*- C++ -*---------------------*\
========= |
\ / F ield |
\ / O peration |OPENFOAM:The Open Source CFD Toolbox
\ / A nd |Version: 9
\ / M anipulation |Website: https://openfoam.org
\*-------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format acsii;
class dictionary;
object blockMeshDict;
}
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0.000000 0.000000 0.000000)
(0.000000 0.009997 -0.000262)
(0.000000 0.009997 0.000262)
(2.520000 0.000000 0.000000)
(2.520000 0.009997 -0.000262)
(2.520000 0.009997 0.000262)
);
blocks
(
hex (0 1 2 0 3 4 5 3 ) (50 1 200) simpleGrading (0.5 1 1)
);
edges
(
arc 1 2 (0.000000 0.010000 0.000000)
arc 4 5 (0.000000 0.010000 0.000000)
);
boundary
(
inlet
{
type patch;
faces
(
(0 1 2 0 )
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
front
{
type wedge;
faces
(
(0 3 5 2)
);
}
back
{
type wedge;
faces
(
(0 1 4 3)
);
}
pipe
{
type wall;
faces
(
(1 4 5 2)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
//*******************************************************************//
ControlDict File:
File related to the simulation time duration
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 10;
deltaT 0.001;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
Boundary Conditions:
Pressure Boundary Condition
The pressure boundary conditions were according to the pressure drop
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
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.0168682;
}
axis
{
type empty;
}
pipe
{
type zeroGradient;
}
front
{
type wedge;
}
back
{
type wedge;
}
}
// ************************************************************************* //
Velocity Boundary Condition
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
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.0937312 0 0);
}
outlet
{
type zeroGradient;
}
axis
{
type empty;
}
pipe
{
type noSlip;
}
front
{
type wedge;
}
back
{
type wedge;
}
}
// ************************************************************************* //
Transport properties File
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nu [0 2 -1 0 0 0 0] 8.927e-07;
// ************************************************************************* //
Output:
For wedge angle 4 degrees
Mesh
Velocity Distribution
Pressure Distribution
Graph:
Velocity Profile
Conclusions:
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-11 : Discretization of 3D intake manifold using GEM-3D
Aim: Discretization of 3D intake manifold using GEM-3D Objective: 1. Tutorial- single cyl DI add case 2 with discretization length 0.1 mm for intake runner and compare with default case 1 Parameters-Torque, BSFC, max cylinder pressure simulation time 2. Explore tutorial no 2 (GEM3D) - “Building intake…
31 Aug 2022 05:57 AM IST
Week-7 : Converting a detailed engine model to a FRM model
Aim: Converting a detailed engine model to an FRM model. Objective: Explore tutorial number 9 and write a detailed report. Build FRM Model for the following configuration using the FRM builder approach. Bore 102 mm stroke 115 mm CR 17 No of cylinder 6 CI engine Twin Scroll Turbine GT Controller Run all cases…
30 Aug 2022 02:54 AM IST
Week-6 : Turbocharger Modelling
Aim: Turbocharger Modelling using GT POWER Objective: List down different TC and locate examples from GT Power Explore tutorial number 6 and 7 Plot operating points on compressor and turbine maps In which application Variable Geometry Turbine is beneficial? Explore example- Diesel VGT EGR and understand the modeling…
22 Aug 2022 10:30 AM IST
Week-4 : Basic Calibration of Single cylinder CI-Engine
Aim: Basic Calibration of Single cylinder CI-Engine Objective: 1. Compare SI vs CI and list down differences (assignment no 2-SI) 2. Comments on the following parameters BSFC Exhaust Temperature A/F ratios 3. Change MFB 50 and observe the impact on performance Comparison: SI vs CI S.No./Engine type …
15 Aug 2022 03:48 PM 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.