Week 11 - Simulation of Flow through a pipe in OpenFoam
Hagen- Poiseuille's equations :
Hagen–Poiseuille law, Poiseuille law or Poiseuille equation, is a physic law that gives the pressure drop in an incompressible and Newtonian fluid in laminar flow flowing through a long cylindrical pipe of constant cross-section
The assumptions of the equation are that the fluid is incompressible and Newtonian; the flow is laminar through a pipe of the constant circular cross-section that is substantially longer than its diameter; and there is no acceleration of fluid in the pipe. For velocities and pipe diameters above a threshold, actual fluid flow is not laminar but turbulent, leading to larger pressure drops than calculated by the Hagen–Poiseuille equation.

Δp is the pressure difference between the two ends,
L is the length of pipe,
μ is the dynamic viscosity.
Q is the volumetric flow rate,
R is the pipe radius
A is the cross section of pipe.
The above figure represents the flow through pipe
The layer in which the share viscous flow are significant is called boundary layer this boundary layer is important
concept its divide the flow pipe into two region boundary layer region and irrotational flow region
When the fluid just enter the pipe the thickness of a boundary layer gradually increases from zero moving in direction of flow and eventually reaches the pipe centre and fills the entire pipe the region from the entrance of the pipe to the point where the boundary layer covers the pipe is termed as a hydrodynamic region and length of a pipe in the region is termed as a hydro dynamic and length in this region the velocity profile develops and the floor is called hudrodynamically developing flow
Given
Reynolds number :2100
Working fluid :water
Fluid temperature :25celcus
Diameter of pipe :0.02
dynamic viscosity : 0.89*10^-3
kinematics viscosity :0.89*10^-6
difference between pressure :32*L*mu*avg velocity/D^2
Theta :4
length 2.25m
Analytical solution
average velocity :re*mu/rho*D = 0.09373
maximum velocity :2*avg velocity = 0.1874ms
pressure drop :16.187pa
kinematics pressure drop : delP/P = 0.0168m
By doing all this procedure copy the cavity fodder from the icoFoamr form and paste it from the separate folder and after the final editing of the block Marsh pressure and velocity parameters save the program and check the blocked my and the polymer has been created open paraview and run the simulation.
Matlab Code for creating blockmesh dic
clear all
close all
clc
%wedgeinput and angles
theta = input('Enter the value of wedge angle=');
Re = 2100;
D = 0.02;
L = 0.06*Re*D;
R = D/2;
mu = 0.89e-3;
rho = 997.0;
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 containt of blockMesh File
string1='/*--------------------------------*- C++ -*----------------------------------*\';
string2=' ========= |';
string3=' \\ / F ield | OpenFOAM: The Open Source CFD Toolbox';
string4=' \\ / O peration | Website: https://openfoam.org';
string5=' \\ / A nd | Version: 9';
string6=' \\/ M anipulation |';
string7='\*---------------------------------------------------------------------------*/';
string8='FoamFile';
string9='{';
string10=' format ascii;';
string11=' class dictionary;';
string12=' object blockMeshDict;';
string13='}';
string14='// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //';
fpoint=fopen('blockMeshDict.txt','wt');
fprintf(fpoint,'%sn',string1);
fprintf(fpoint,'%sn',string2);
fprintf(fpoint,'%sn',string3);
fprintf(fpoint,'%sn',string4);
fprintf(fpoint,'%sn',string5);
fprintf(fpoint,'%sn',string6);
fprintf(fpoint,'%sn',string7);
fprintf(fpoint,'%sn',string8);
fprintf(fpoint,'%sn',string9);
fprintf(fpoint,'%sn',string10);
fprintf(fpoint,'%sn',string11);
fprintf(fpoint,'%sn',string12);
fprintf(fpoint,'%sn',string13);
fprintf(fpoint,'%sn',string14);
fprintf(fpoint,'%sn','convertToMeters 1;');
fprintf(fpoint,'%sn','vertices');
fprintf(fpoint,'%sn','(');
fprintf(fpoint,'%s (%f %f %f) n',blanks(5),V0(1),V0(2),V0(3));
fprintf(fpoint,'%s (%f %f %f) n',blanks(5),V1(1),V1(2),V1(3));
fprintf(fpoint,'%s (%f %f %f) n',blanks(5),V2(1),V2(2),V2(3));
fprintf(fpoint,'%s (%f %f %f) n',blanks(5),V3(1),V3(2),V3(3));
fprintf(fpoint,'%s (%f %f %f) n',blanks(5),V4(1),V4(2),V4(3));
fprintf(fpoint,'%s (%f %f %f) n',blanks(5),V5(1),V5(2),V5(3));
fprintf(fpoint,'%sn',');');
fprintf(fpoint,'n');
fprintf(fpoint,'%sn','blocks');
fprintf(fpoint,'%sn','(');
fprintf(fpoint,'%s %s n',blanks(5),'hex(0 1 2 0 3 4 5 3) (50 1 200) simpleGrading(0.5 1 1)');
fprintf(fpoint,'%sn','(');
fprintf(fpoint,'n');
fprintf(fpoint,'%sn','boundry');
fprintf(fpoint,'%sn','(');
fprintf(fpoint,'%s %s n',blanks(5),'inlet');
fprintf(fpoint,'%s %s n',blanks(5),'{');
fprintf(fpoint,'%s %s n',blanks(10),'type patch;');
fprintf(fpoint,'%s %s n',blanks(10),'faces');
fprintf(fpoint,'%s %s n',blanks(10),'(');
fprintf(fpoint,'%s %s n',blanks(15),'(0 1 2 0)');
fprintf(fpoint,'%s %s n',blanks(10),');');
fprintf(fpoint,'%s %s n',blanks(5),'}');
fprintf(fpoint,'%s %s n',blanks(5),'outlet');
fprintf(fpoint,'%s %s n',blanks(5),'{');
fprintf(fpoint,'%s %s n',blanks(10),'type patch;');
fprintf(fpoint,'%s %s n',blanks(10),'faces');
fprintf(fpoint,'%s %s n',blanks(10),'(');
fprintf(fpoint,'%s %s n',blanks(15),'(3 4 5 3)');
fprintf(fpoint,'%s %s n',blanks(10),');');
fprintf(fpoint,'%s %s n',blanks(5),'}');
fprintf(fpoint,'%s %s n',blanks(5),'front');
fprintf(fpoint,'%s %s n',blanks(5),'{');
fprintf(fpoint,'%s %s n',blanks(10),'type wedge;');
fprintf(fpoint,'%s %s n',blanks(10),'faces');
fprintf(fpoint,'%s %s n',blanks(10),'(');
fprintf(fpoint,'%s %s n',blanks(15),'(0 3 5 2)');
fprintf(fpoint,'%s %s n',blanks(10),');');
fprintf(fpoint,'%s %s n',blanks(5),'}');
fprintf(fpoint,'%s %s n',blanks(5),'back');
fprintf(fpoint,'%s %s n',blanks(5),'{');
fprintf(fpoint,'%s %s n',blanks(10),'type wedge;');
fprintf(fpoint,'%s %s n',blanks(10),'faces');
fprintf(fpoint,'%s %s n',blanks(10),'(');
fprintf(fpoint,'%s %s n',blanks(15),'(0 1 4 3)');
fprintf(fpoint,'%s %s n',blanks(10),');');
fprintf(fpoint,'%s %s n',blanks(5),'}');
fprintf(fpoint,'%s %s n',blanks(5),'pipe');
fprintf(fpoint,'%s %s n',blanks(5),'{');
fprintf(fpoint,'%s %s n',blanks(10),'type wall;');
fprintf(fpoint,'%s %s n',blanks(10),'faces');
fprintf(fpoint,'%s %s n',blanks(10),'(');
fprintf(fpoint,'%s %s n',blanks(15),'(1 4 5 2)');
fprintf(fpoint,'%s %s n',blanks(10),');');
fprintf(fpoint,'%s %s n',blanks(5),'}');
fprintf(fpoint,'%s %s n',blanks(5),'axis');
fprintf(fpoint,'%s %s n',blanks(5),'{');
fprintf(fpoint,'%s %s n',blanks(10),'type empty;');
fprintf(fpoint,'%s %s n',blanks(10),'faces');
fprintf(fpoint,'%s %s n',blanks(10),'(');
fprintf(fpoint,'%s %s n',blanks(15),'(0 3 3 0)');
fprintf(fpoint,'%s %s n',blanks(10),');');
fprintf(fpoint,'%s %s n',blanks(5),'}');
fprintf(fpoint,'%s n',');');
fprintf(fpoint,'n');
fprintf(fpoint,'%s n','mergePatchPairs');
fprintf(fpoint,'%s n','(');
fprintf(fpoint,'%s n',');');
fprintf(fpoint,'n');
fprintf(fpoint,'%s n',string14);
fclose(fpoint);
************************************************************
Excuiting the code blockmeshDic
/*--------------------------------*- 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;
object blockMeshDict;
}
