All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Objective This is the part 2 of the project. In this project we are simulating the flow through a wedge with 10, 25 and 45 degree wedge angle. And we are also changing the type of wedge to "symmetry" in openFoam blockMeshDict file and respective files. Part from that the rest remains the same. Then comaring the results…
Mohammad Saifuddin
updated on 01 Sep 2019
Objective
This is the part 2 of the project. In this project we are simulating the flow through a wedge with 10, 25 and 45 degree wedge angle. And we are also changing the type of wedge to "symmetry" in openFoam blockMeshDict file and respective files. Part from that the rest remains the same. Then comaring the results of part 1 and part 2 of the project.
SOLUTION
Matlab code to generate blockMeshDict file using file parsing teshnique
%% Matlab code to generate openFoam blockMeshDict file for different values of theta
clear all
close all
clc
% Input data
R = 2100 % Reynold's number (given)
d = 0.02 % m , diameter
r = d/2 % m, radius
L_entry = 0.06*R*d% m, Entry length of the pipe, using the entry length formula for laminar flow through a pipe
L = L_entry + 0.3 % m, Total lenght of pipe
th = 10 % Wedge angle in degree
mu = 8.9e-4 % P.s, Dynamic viscosity of water at 25 degree C
rho = 997 % Kg/m^3, density of water at 25 degree C
nu = mu/rho % m^2/s, kinematic viscosity of water at 25 degree C
% calculating the solution according to Hagen poiseuille's flow equation
v_avg = (R*mu)/(rho*d) % average velocity
v_max = 2*v_avg % maximum velocity
del_p = (8*mu*L*v_avg)/(r^2) % pressure drop
kin_p = del_p/rho % kinematic pressure
nx = 300 % number of grid point in x axis
ny = 1 % number of grid point in y axis
nz = 50 % number of grid point in z axis
ln1='/*--------------------------------*- C++ -*----------------------------------*\';
ln2='| ========= | |';
ln3='| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |';
ln4='| \\ / O peration | Website: https://openfoam.org |';
ln5='| \\ / A nd | Version: 7 |';
ln6='| \\/ M anipulation | |';
ln7='\*---------------------------------------------------------------------------*/';
ln8='FoamFile';
ln9='{';
ln10=' version 2.0;';
ln11=' format ascii;';
ln12=' class dictionary;';
ln13=' object blockMeshDict;';
ln14='}';
ln15='// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //';
ln16='convertToMeters 1;';
%creating blank spaces
b5 = blanks(5);
b10 = blanks(10);
b15 = blanks(15);
% defining vertices
v0 = [0 0 0];
v1 = [0 r*cosd(th/2) -r*sind(th/2)];
v2 = [0 r*cosd(th/2) r*sind(th/2)];
v3 = [L 0 0];
v4 = [L r*cosd(th/2) -r*sind(th/2)];
v5 = [L r*cosd(th/2) r*sind(th/2)];
e1 = [0 r 0];
e2 = [L r 0];
f1 = fopen('blockMeshDict.txt','w');
fprintf(f1,'%s\n',ln1);
fprintf(f1,'%s\n',ln2);
fprintf(f1,'%s\n',ln3);
fprintf(f1,'%s\n',ln4);
fprintf(f1,'%s\n',ln5);
fprintf(f1,'%s\n',ln6);
fprintf(f1,'%s\n',ln7);
fprintf(f1,'%s\n',ln8);
fprintf(f1,'%s\n',ln9);
fprintf(f1,'%s\n',ln10);
fprintf(f1,'%s\n',ln11);
fprintf(f1,'%s\n',ln12);
fprintf(f1,'%s\n',ln13);
fprintf(f1,'%s\n',ln14);
fprintf(f1,'%s\n',ln15);
fprintf(f1,'\n');
fprintf(f1,'%s\n',ln16);
% printing vertices
fprintf(f1,'\n');
fprintf(f1,'%s\n','vertices');
fprintf(f1,'%s\n','(');
fprintf(f1,'%s (%d %d %d)\n',b5,v0(1),v0(2),v0(3));
fprintf(f1,'%s (%d %f %f)\n',b5,v1(1),v1(2),v1(3));
fprintf(f1,'%s (%d %f %f)\n',b5,v2(1),v2(2),v2(3));
fprintf(f1,'%s (%f %d %d)\n',b5,v3(1),v3(2),v3(3));
fprintf(f1,'%s (%f %f %f)\n',b5,v4(1),v4(2),v4(3));
fprintf(f1,'%s (%f %f %f)\n',b5,v5(1),v5(2),v5(3));
fprintf(f1,'%s\n',');');
% printing blocks
fprintf(f1,'\nblocks\n(\n');
fprintf(f1,'%shex (0 1 2 0 3 4 5 3) (%d %d %d) simpleGrading (1 1 1)\n);\n',b5,nx,ny,nz);
% printing edges
fprintf(f1,'\nedges\n(\n');
fprintf(f1,'%sarc 1 2 (%d %f %d)\n%sarc 4 5 (%f %f %d)\n);',b5,e1(1),e1(2),e1(3),b5,e2(1),e2(2),e2(3));
% printing boundaries
fprintf(f1,'\n\nboundary\n(\n');
fprintf(f1,'%sinlet\n%s{\n',b5,b5);
fprintf(f1,'%stype patch;\n%sfaces\n%s(\n%s(0 2 1 0)\n%s);\n%s}\n',b10,b10,b10,b15,b10,b5);
fprintf(f1,'\n%soutlet\n%s{\n',b5,b5);
fprintf(f1,'%stype patch;\n%sfaces\n%s(\n%s(3 4 5 3)\n%s);\n%s}\n',b10,b10,b10,b15,b10,b5);
fprintf(f1,'\n%saxis\n%s{\n',b5,b5);
fprintf(f1,'%stype empty;\n%sfaces\n%s(\n%s(0 3 3 0)\n%s);\n%s}\n',b10,b10,b10,b15,b10,b5);
fprintf(f1,'\n%stop\n%s{\n',b5,b5);
fprintf(f1,'%stype wall;\n%sfaces\n%s(\n%s(2 5 4 1)\n%s);\n%s}\n',b10,b10,b10,b15,b10,b5);
fprintf(f1,'\n%sfront_wedge\n%s{\n',b5,b5);
fprintf(f1,'%stype symmetry;\n%sfaces\n%s(\n%s(0 3 5 2)\n%s);\n%s}\n',b10,b10,b10,b15,b10,b5);
fprintf(f1,'\n%sback_wedge\n%s{\n',b5,b5);
fprintf(f1,'%stype symmetry;\n%sfaces\n%s(\n%s(0 1 4 3)\n%s);\n%s}\n\n);\n',b10,b10,b10,b15,b10,b5);
fprintf(f1,'\nmergePatchPairs\n(\n);\n');
fprintf(f1,'\n%s',ln15);
openFoam blockMeshDict file generated by the above matlab code
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Website: https://openfoam.org |
| \\ / A nd | Version: 7 |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0)
(0 0.009962 -0.000872)
(0 0.009962 0.000872)
(2.820000 0 0)
(2.820000 0.009962 -0.000872)
(2.820000 0.009962 0.000872)
);
blocks
(
hex (0 1 2 0 3 4 5 3) (300 1 50) simpleGrading (1 1 1)
);
edges
(
arc 1 2 (0 0.010000 0)
arc 4 5 (2.820000 0.010000 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 2 1 0)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
top
{
type wall;
faces
(
(2 5 4 1)
);
}
front_wedge
{
type symmetry;
faces
(
(0 3 5 2)
);
}
back_wedge
{
type symmetry;
faces
(
(0 1 4 3)
);
}
);
mergePatchPairs
(
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
openFoam pressure file
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ 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.0189;
}
axis
{
type empty;
}
top
{
type zeroGradient;
}
front_wedge
{
type symmetry;
}
back_wedge
{
type symmetry;
}
}
// ************************************************************************* //
openFoam velocity file
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0.0937 0 0);
boundaryField
{
inlet
{
type fixedValue;
value uniform (0.0937 0 0);
}
outlet
{
type zeroGradient;
}
axis
{
type empty;
}
top
{
type fixedValue;
value uniform (0 0 0);
}
front_wedge
{
type symmetry;
}
back_wedge
{
type symmetry;
}
}
// ************************************************************************* //
openFoam controlDict file
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
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;
// ************************************************************************* //
openFoam transportProperties file
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nu [0 2 -1 0 0 0 0] 8.9268e-07;
// ************************************************************************* //
Report
PRE-PROCESSING AND SOLVING
POST PROCESSING
Using matlab code to generate blockMeshDict file for different value of theta, and creating wedge for that angle.
Mesh for wedge angle 10 degrees
Mesh for wedge angle 25 degrees
Mesh for wedge angle 45 degrees
Simulation result for velocity (Wedge angle = 10 degree)
Simulation result for velocity (Wedge angle = 25 degree)
Simulation result for velocity (Wedge angle = 45 degree)
Velocity profiles for wedge angle 10 degree, at different positions in x-axis.
CALCULATING SHEAR STRESS FOR WEDGE ANGLE 10 DEGREE.
Matlab code to calculate shear stress from simulation data (Do not use clear all, close all, and clc, because it will clear the imported data of velocity from the workspace)
%% Calculating shear stress by using .csv file data from the openFoam simulation
mu = 8.9000e-04;
y = linspace(-0.01,0.01,1000);
dy = y(2) - y(1);
for i = 1:1000
du = u(i+1) - u(i);
dU = abs(du);
t(i) = mu*(dU/dy);
end
plot(y,t)
legend('Shear stress')
xlabel('Radial distance "r" (m)')
ylabel('Shear stress (\tau) (N / m^{2})')
title(sprintf('Change in shear stress for fully developed flow at x = 2.82 m\nwith radial distance "r" (Simulation result)'))
grid minor
Matlab code to calculate shear stress analytically.
clear all
close all
clc
%% Calculating shear stress analytically
r = linspace(-0.01,0.01,1000); % m, radial distance
R = 0.01; % m, max radial distance
Re = 2100; % Reynold's number (given)
rho = 997; % Kg/m^3, density of water at 25 degree C
d = 0.02; % m , diameter
mu = 8.9000e-04; % dynamic viscosity of water at 25 degree C
v_avg = (Re*mu)/(rho*d); % average velocity
v_max = 2*v_avg; % maximum velocity
for i = 1:length(r)
t(i) = (2*mu*v_max*abs(r(i)))/(R^2);
end
plot(r,t)
legend('Shear stress','location','north')
xlabel('Radial distance "r" (m)')
ylabel('Shear stress (\tau) (N / m^{2})')
title(sprintf('Change in shear stress for fully developed flow at x = 2.82 m\nwith radial distance "r" (Analytical result)'))
grid minor
COMPARING THE ANALYTICAL RESULTS WITH SIMULATION RESULTS FOR PART 1 & PART 2 OF THE CHALLENGE.
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...
External Aerodynamics of a Mercedes Truck After Performing Surface Wrapping in STAR-CCM+
Surface Wrapping Surface wrapping is a method of extracting the desired surface with the desired volume of interest to perform CFD analysis. Surface wrapping does not incorporate all the minor details of the inside of the geometry, it only takes the outer detail of the geometry. When the CAD file contains a lot…
16 Feb 2020 02:12 PM IST
External flow Analysis of Ahmed body and Comparing the Numerical and Experimental data in STAR-CCM+.
Objective: Create the Ahmed Body slant for both 250 and 350 Run Steady-state implicit coupled flow simulation Use the turbulence models K-OmegsSST and k-epsilon Validate the velocity profile along the Ahmed body at different points with the experimental data. Calculate the cd and cl using the different turbulence.…
16 Feb 2020 01:45 PM IST
External flow analysis of NACA 0012 airfoil for different values of angle of attack in STAR - CCM+
NACA The NACA airfoils are airfoil shapes for aircraft wings developed by the National Advisory Committee for Aeronautics (NACA). The shape of the NACA airfoils is described using a series of digits following the word "NACA". The parameters in the numerical code can be entered into equations to precisely generate the cross-section…
29 Jan 2020 04:34 AM IST
Transient state analysis of Rayleigh Taylor instability in ANSYS FLUENT.
Objective Discuss some practical CFD models that have been based on the mathematical analysis of Rayleigh Taylor waves. And explain how these mathematical models have been adapted for CFD calculations. Perform the Rayleigh Taylor instability simulation for 3 different mesh sizes with the base mesh being 0.5 mm. Compare…
15 Jan 2020 09:52 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.