8/10/2019 La Minar Flow
1/16
Numerical Solution of Incompressible Laminar Flowover a backstep
Christian Frias
University of Pittsburgh
1 Introduction
Herein, a numerical model to solve the hydrodynamics of a laminar flow over a back-
step is presented. The numerical schemes for this model have been developed by
Roache (1968) and are explained in section 2. In order to obtain a laminar flow field
a small value of viscosity was selected (= 0.15cm2/s). The goal of the model was to
predict the recirculation pattern expected downstream the backstep face. Therefore,
the vorticity is an important parameter to calculate and from it calculate the streamfunction and velocities vectors. This model solves all the scales of turbulence, thus,
we can consider it as a direct numerical simulation for small Reynolds. Although, we
have used this model only for a laminar flow case it can be extended for turbulent
flows at small scales. Nowadays, in contrast to what Roache(1968) mentioned in his
paper, the simulation of turbulent flows is possible using the current computer re-
sources that we have. Thus, it could be possible to model turbiulent fluids such as
water over a backstep obstacle. The latter is a common phenomenon in environmen-
tal flows such as migration of dunes or ripples on river beds. The main characteristics
or these cases are the flow reattachment and the shear stress at the boundary wallswhich case the erosion and deposition patterns of river beds.
8/10/2019 La Minar Flow
2/16
2 C. Frias
2 Numerical Schemes and Boundary Conditions
2.1 Numerical Schemes
The equation solved by the model is the vorticity equation given in equation (1).
w
t +u
w
x +v
w
y =
2w
x2 +
2w
y2
. (1)
Where the vorticity is expressed in terms of the velocities by equation (2) and in
terms of the stream function by equation (3).
w= u
y+
v
x. (2)
w=2
x2 +
2
y2. (3)
Where y
=u, x
= v.
The steps that the model follows to solve the vorticity equation are:
1. Initialize all the variables: Mean velocity (Umean), kinematic viscosity (), time
step (t). The initial time step has been calculated as 0.9 of the critical time
step. This critical time step is given in equation (4).
tcrit= 1uij/x+vij/y+ 2/((1/x2 + 1/y2))
(4)
2. Creates the grid and input the initial values for the velocities. The grid used
and the type of boundary condition as well as the code given in the program
is shown in Figure 1. The origin of the grid is the upper left corner (i=0, j=0)
ant the last point of the grid is in the lower right corner (i= Number points
in x, j = Number of points in y )For the inlet a parabolic profile was used for
the velocities (see equation (5)) The initial values of velocities for the internal
points, the top wall and the outlet boundary were the mean velocity for the
velocities in the x direction and zero values for the velocity in the y direction.
Whereas, for the walls the two components of the velocity vector uand v were
initialized with zero values. The values of the stream function for the inlet were
considered as the integral of the velocity in y and the maximum value on this
boundary zone was used for the top wall boundary (ec
u(y)dy).e
8/10/2019 La Minar Flow
3/16
Numerical Solution of Incompressible Laminar Flow over a backstep 3
u= 6Umean(y e)(y c)
(e c)2 (5)
Figure 1: Mesh Layout
The vorticity in the inlet is calculated from the values ofu and v according to
equation (7). Whereas the values of vorticity in the walls are assumed to be the
same of the internal points that are next to the wall points in the perpendicular
direction. For example, the vorticity in a vertical wall (wverticalwall) is equal to
the point to the right wverticalwall = wi+1,j and the vorticity in a bottom wall
(wbottomwall) is equal to the point that is above wbottomwall= wi,j1
uinlet= 6Umean(y e)(y c)
(e c)2 (6)
winlet= 6Umean2y e c
(e c)2 (7)
3. The vorticity is calculated at the internal points with an upwind scheme for
the convection and a centered difference for dispersion. The expressions of the
discretized vorticity equation is given in equations (8) and (9).
8/10/2019 La Minar Flow
4/16
4 C. Frias
wn+1ij =wnij+ t
(uw)n
xij
(vw)n
xij+
2wn
x2ij+
2wn
y2ij
(8)
.
Where,
(uw)n
xij=
(uw)ni+1,j(uw)ni,j
xij, for u 0
(9)
4. Knowing the values of velocities, vorticity and stream function the program
advances in time for the stream function by over relaxation and calculates again
the new values of w and from them the values of the velocities.
5. Finally, if the steady state is reached the program stops and call a function
PrintReport.cpp to print the results in Tecplot.
2.2 Boundary Conditions
A summary of the boundary conditions is given next:
1. Inlet: The inlet has code (1) in the program and have a parabolic velocity profile
withv = 0. The vorticity and stream function are calculated by the procedure
described in the previous section.
2. Bottom Wall: This boundary has a Dirichlet no slip boundary conditions
which means that the values of the velocities u and v are zero. Also the value
for the stream function is given as zero and the vorticity is calculated by the
procedure described in the previous section.
3. Top Wall: This boundary has a Dirichlet slip boundary condition. It means
that initially the velocities are zero but the stream function is the total flowrate
of the domain at the beginning. The vorticity is calculated as a wall boundary
and was explained before.
4. Outlet: This is a Neumman zero gradient boundary condition. It means that
the derivatives in x and y for all the variables are set to zero.
8/10/2019 La Minar Flow
5/16
Numerical Solution of Incompressible Laminar Flow over a backstep 5
3 Results
Unfortunately, the program did not succeed and no logical results are showed in this
section. The initial conditions of the simulation are presented in Figures 2 and Figure3 for the vorticity and the stream function respectively.
Figure 2: Initial Vorticity
Figure 3: Initial Stream Function
8/10/2019 La Minar Flow
6/16
6 C. Frias
The steady state was reached at 10s. Therefore the plots for the vorticity and the
stream function are showed in Figure 4 and Figure 5.
Figure 4: Initial Vorticity
Figure 5: Initial Stream Function
4 Conclusions
Although the program could not reproduce the physics of the problem we can make
some conclusions about the behaviour of the code flaws.
8/10/2019 La Minar Flow
7/16
Numerical Solution of Incompressible Laminar Flow over a backstep 7
1. As we can see from the results the vorticity is not being transported. At the
beginning in the debug process we noticed that the array of stream function was
taken the values of the vorticity directly without any processing. This caused
that the vorticity and the stream function was not being transported. We fixedthat error however the vorticity remained the same. It seems that the initial
values of vorticity are not the correct ones at the inlet. Thus, the flows does not
complete a recirculation pattern and instead of that it resulted in an upward
flow at the beginning and a downward flow at the end as seen in Figure 4 and
Figure 5.
2. Concerning to the stream function and the velocities we can say that they are
correlated as expected. As we can see in Figure 5 the stream function has
negative values when the velocities are downward and positive values whenthe velocities are upward. Thus, we conclude that the error in the code is
not because of the equations used to calculate the velocities from the stream
function values.
3. On the future, this code can be corrected by beginning to check the treatment
of the equations used at the boundaries. It seems that the scheme used at the
walls is failing because with a detailed inspection of the plots we have found
vectors going upstream in the top wall and the bottom walls when the opposite
direction is expected.
References
[1] P.Roache,Numerical Soltions of Laminar Separated Flows(AIAA Journal, Vol. 8
No. 3, 1968).
5 Code
5.1 LaminarBackStep.h
#include
using namespace std;
struct POINT
{
8/10/2019 La Minar Flow
8/16
8 C. Frias
double w;
double psi;
double u;
double v;
double x;double y;
int code;// -3-verticalwall, -2-bottomwall, -1-topwall, 0-internal , 1-inlet, 2-outlet
};
double Sign(const double & Num);
void GridGenerator(vector< vector >& Grid, double Umean, int Nx, double a, double b, double c, double d, do
void PrintReport(vector& Grid);
5.2 LaminarBackStep.cpp
#include
#include
#include#include
#include "LaminarBackStep.h"
int main()
{
vector < vector < POINT > > Grid;
double Umean, nu, a=0.5, b=1.5, c=0.5, d=7.0, e;
double dx,dy,dt,dtc,t,tf,ap,afx,ab x,afy,aby,wfx,wbx,wfy,wby,psi fx,psibx,psify,psiby,f,err,err c,errmax;
int Nt,Nx;
e=a+c;
nu=0.15;//0.0000001002;
/*cout
8/10/2019 La Minar Flow
9/16
Numerical Solution of Incompressible Laminar Flow over a backstep 9
{
dt=1/(Grid[i][j].u/dx+Grid[i][j].v/dy+2/nu*(1/dx/dx+1/dy/dy));
if (dt>dtc) dtc=dt;
}
}dt=0.9*dtc;t=t+dt;
for(int i=0;i
8/10/2019 La Minar Flow
10/16
10 C. Frias
for(int j=0;jerrmax) errmax=abs(err);
}
if (Grid[i][j].code==-2)
{
err=Grid[i][j-1].psi+Grid[i][j].w*dy*dy/2-Grid[i][j].psi;
Grid[i][j].psi=Grid[i][j].psi+err;
if (abs(err)>errmax) errmax=abs(err);
}
if (Grid[i][j].code==-1)
{
err=Grid[i][j+1].psi+Grid[i][j].w*dy*dy/2-Grid[i][j].psi;
Grid[i][j].psi=Grid[i][j].psi+err;
if (abs(err)>errmax) errmax=abs(err);
}
if (Grid[i][j].code==0)
{
f=Grid[i][j].w;ap=2*(1/dx/dx+1/dy/dy);
afx=1/dx/dx;abx=1/dx/dx;afy=1/dy/dy;aby=1/dy/dy;
psifx=Grid[i+1][j].psi;psibx=Grid[i-1][j].psi;
psify=Grid[i][j-1].psi;psiby=Grid[i][j+1].psi;
err=(f+afx*psifx+abx*psibx-ap*Grid[i][j].psi+afy*psify+aby*psiby)/ap;
Grid[i][j].psi=Grid[i][j].psi+/*1.5**/err;
if (abs(err)>errmax) errmax=abs(err);
}
if (Grid[i][j].code==2)
{Grid[i][j].psi=2*Grid[i-1][j].psi-Grid[i-2][j].psi;
/*f=Grid[i][j].w;ap=2*(1/dx/dx+1/dy/dy);
afx=1/dx/dx;abx=1/dx/dx;afy=1/dy/dy;aby=1/dy/dy;
psifx=Grid[i][j].psi;psibx=Grid[i-1][j].psi;
psify=Grid[i][j-1].psi;psiby=Grid[i][j+1].psi;
err=(f+afx*psifx+abx*psibx-ap *Grid[i][j].psi+afy*psify+aby *psiby)/ap; //ficticious point
Grid[i][j].psi=Grid[i][j].psi+1.5*err;
if (abs(err)>errmax) errmax=abs(err);*/
//cout
8/10/2019 La Minar Flow
11/16
Numerical Solution of Incompressible Laminar Flow over a backstep 11
}
if (Grid[i][j].code==-2)
{
Grid[i][j].u=(Grid[i][j-1].psi-Grid[i][j].psi)/dy;
}if (Grid[i][j].code==-1)
{
Grid[i][j].u=(Grid[i][j].psi-Grid[i][j+1].psi)/dy;
}
if (Grid[i][j].code==0)
{
Grid[i][j].u=(Grid[i][j-1].psi-Grid[i][j+1].psi)/2/dy;
Grid[i][j].v=(Grid[i-1][j].psi-Grid[i+1][j].psi)/2/dx;
}
if (Grid[i][j].code==2)
{
Grid[i][j].u=(Grid[i][j-1].psi-Grid[i][j+1].psi)/2/dy;
Grid[i][j].v=(Grid[i-1][j].psi-Grid[i][j].psi)/dx;
}
}
}
}
PrintReport(Grid);
return 0;
}
5.3 GridGenerator.cpp
#include
#include
#include
#include "LaminarBackStep.h"
double uIntegral(double A, double B, double Umean, double c, double e);
double uIntegral(double A, double B, double Umean, double c, double e)
{
return -6*Umean / ((e-c)*(e-c)) * (c*e*B - 0.5*c*B*B - 0.5*e*B*B + B*B*B/3) + 6*Umean / ((e-c)*(e-c)) * (c*e*A - 0
}
void GridGenerator(vector& Grid, double Umean, int Nx, double a, double b, double c, double d, dou
{
POINT TempPoint;vector TempVecPoint;
double dxtemp, dx, dytemp, dy, x, y, psi;
int Ny_a, Ny_c, Ny_e, Nx_b, Nx_d, Nx_final;
dxtemp = (b+d)/(Nx);
if ( (int) floor((b+d)/dxtemp)% 2 == 0) Nx_final=floor((b+d)/dxtemp) +1; else Nx_final=floor((b+d)/dxtemp); // CHEC
dx = (b+d) / (Nx_final);
Nx_b = (int) floor(b/dx) +1 ;
Nx_d = (int) floor(d/dx) +1 ;
8/10/2019 La Minar Flow
12/16
12 C. Frias
dytemp = dx/2;
if ( (int) floor(e/dytemp)% 2 == 0) Ny_e=floor(e/dytemp) +1; else Ny_e=floor(e/dytemp);
dy= e / (Ny_e -1);
Ny_a = (int) floor(a/dy) +1 ;Ny_c = (int) floor(c/dy) +1 ;
cout
8/10/2019 La Minar Flow
13/16
Numerical Solution of Incompressible Laminar Flow over a backstep 13
TempVecPoint.push_back(TempPoint);
}
//x = 0;
y = c ;
TempPoint.x = x;TempPoint.y = y;
TempPoint.u = 0;
TempPoint.v = 0;
//TempPoint.code = -1; //topwall
TempPoint.code = -2; //bottomwall
TempPoint.psi =0; //initialized, this will change later
TempPoint.w = 0; //initialized, this will change later
TempVecPoint.push_back(TempPoint);
Grid.push_back(TempVecPoint); //stores the vector of points
TempVecPoint.clear();
}
//Walls, internal points after the corner and outlet
//x=0;
for (int i=0; i< Nx_d; i++)
{
x = x+dx;
y = a+c;
TempPoint.x = x;
TempPoint.y = y;
TempPoint.u = 0;
TempPoint.v = 0;
TempPoint.code = -1; //topwall
//TempPoint.code = -2;//bottomwall
TempPoint.psi =0; //initialized, this will change laterTempPoint.w = 0; //initialized, this will change later
TempVecPoint.push_back(TempPoint);
for (int j=1; j< Ny_e-1; j++)
{
//x = x;
y = a + c -j*dy;
TempPoint.x = x;
TempPoint.y = y;
//if (i == (Nx_d-1)) TempPoint.u =0; else TempPoint.u = Umean; //inputs the mean velocity for the internal points
/*if (i == (Nx_d-1))*/ TempPoint.u=Umean;//outlet and interior points
//else TempPoint.u = 0; //internal point
if(i == 0 && (y>=0 && y=0 && y
8/10/2019 La Minar Flow
14/16
14 C. Frias
TempPoint.psi =0; //initialized, this will change later
TempPoint.w = 0; //initialized, this will change later
TempVecPoint.push_back(TempPoint);
}
//x = 0;y = 0 ;
TempPoint.x = x;
TempPoint.y = y;
//if (i == (Nx_d-1))TempPoint.u = Umean;
TempPoint.u=0;
TempPoint.v = 0;
//if (i == (Nx_d-1)) TempPoint.code = 2; //outlet
/*else*/ TempPoint.code = -2; //bottomwall
TempPoint.psi =0; //initialized, this will change later
TempPoint.w = 0; //initialized, this will change later
TempVecPoint.push_back(TempPoint);
Grid.push_back(TempVecPoint); //stores the vector of points
TempVecPoint.clear();
}
cout
8/10/2019 La Minar Flow
15/16
Numerical Solution of Incompressible Laminar Flow over a backstep 15
for (int i=0; i
8/10/2019 La Minar Flow
16/16
16 C. Frias
//INLET
for (int j= 0 ; j < Grid[0].size(); j++ )
{
boundaryFile
Top Related