Está en la página 1de 14

University of New Mexico

Solving the 2D Incompressible


Navier-Stokes Equation

Juan Pablo madrigal Cianci


May 9, 2017

1
1 Introduction

2 Problem Setup

The incompressible Navier-Stokes equations in two spatial dimensions is give by

w 1 2
+ p = (w )w + w, (2.1)
t Re
w = 0, (2.2)

for some 2-dimensional domain and given boundary and initial conditions.
1
where w = (u, v) is the velocity field, p is the pressure of the system, and Re

is the Reynolds number. In particular, we are interested in solving the 2D

lid-driven cavity problem, given by the following PDE:

1
ut + px = (u2 )x (uv)y + (uxx + vyy ), (2.3)
Re
1
vt + py = (v 2 )x (uv)x + (vxx + vyy ), (2.4)
Re
ux + vy = 0, (2.5)

(u, v) [0, 1]2 [0, 1] (2.6)

with boundary conditions given by

u(0, y, t) = u(1, y, t) = u(x, 0, t) = 0, (2.7)

v(x, 0, t) = v(x, 1, t) = v(1, y, t) = v(0, y, t) = 0, (2.8)

u(x, 1, t) = 1, (2.9)

and initial conditions given by

u(x, y, 0) = v(x, y, 0) = 0 (2.10)

2
For visualization purposes, we introduce the stream function, q, which denotes

the path of a particle at any instance in time. The stream function is defined

in such a way that (q) = w.

Figure 2.1: Depiction of the lid-driven cavity problem we are solving.

3 Discretization of the PDE

Denote the numerical approximations of u, v, p, q by U, V, P, Q. We consider

the time evolution independently from the spatial one, i.e we need to solve the

spatial part at each time step. To do so, we use Chorins projection method [1],

on which the pressure is decouple and calculated independently of the velocity

field. The main idea behind the projection method is to ignore the pressure

term P and approximate the velocity field by an intermediate value, (U , V ).

3
Recall the PDE:

1
ut + px = (u2 )x (uv)y + (uxx + vyy ), (3.1)
Re
1
vt + py = (v 2 )x (uv)x + (vxx + vyy ), (3.2)
Re
ux + vy = 0, (3.3)

We treat the non-linear terms explicitly in time:

U Un
= ((U n )2 )x (U n V n )y (3.4)
t
VVn
= ((V n )2 )y (U n V n )x . (3.5)
t

at any given time step n, for some intermediate values U , V . Now, for some

other intermediate values values, (U , V ), we let

U U 1
= (U + Uyy

) (3.6)
t Re xx

V V 1
= (V + Vyy

). (3.7)
t Re xx

We then perform the pressure correction to the previous terms and obtain

U n+1 U
= (P n+1 )x (3.8)
t
V n+1 V
= (P n+1 )y , (3.9)
t

which can be rewritten as

Wn+1 Wn
= P n+1 , (3.10)
t t

4
where W = (U, V ). Note that if we take the divergence on both sides of 3.10,

equation 2.5 yields


Wn
= 2 P n+1 , (3.11)
t

Lastly, the stream function can be computed by taking the gradient on both

sides of its definition,

(Q) = W Qx = V, Qy = U (3.12)

Apply 2D Curl: 2 Q = (Q) = W = Uy Vx (3.13)

= 2 Q = Uy Vx (3.14)

Note that with this formulation we are solving Poissons equation 4 times (one

for each of the parameters we are interested on) on each time step. This in turns

results ideal since Laplaces equation is one of the most studied PDEs and given

its matrix form we can apply numerically efficient algorithms such as Multigrid

and Conjugate Gradient. We use a staggered grid and a finite difference scheme

to discretize the derivatives. In general, a description of the discretization of

the non-linear terms is given in [4]. The evolution in time is given by a Taylor

time-stepping.

Following the approach in [1], [2] and [4], we use a staggered grid with the

pressure p in the cell midpoints, the velocities u placed on the vertical cell inter-

faces, and the velocities v placed on the horizontal cell interfaces. The stream

function q is defined on the cell corners, as it is shown in 3.1.

5
Figure 3.1: Depiction of the staggered grid.

4 Solution of the System

Thanks to the discretization used, we are left with four Laplaces equations

that can be solved iteratively. Note, however, that there are other approaches

to this, like using spectral based methods (FFT) or a preconditioned version of

Choleskys factorization. We proceed to implement methods studied in class,

namely Conjugate Gradient and Multigrid, and see how they compare. Addi-

tionally, we also compute the solution of those Laplaces equations via MAT-

LABs integrated solver (\) in order to provide a wider comparison. Note

that the backslash solver is optimized both by vectorizing and by choosing an

6
appropriate algorithm in order to solve directly. For all experiments run we

consider grid-sizes of the form 2n , since this is a more friendly mesh-size for the

multigrid method.

4.1 Brief overview of the methods

4.1.1 Conjugate Gradient

We proceed to implement the simplest version of the conjugate gradient algo-

rithm. Note that there are more advanced forms of this algorithm that include

parallelization or the use of preconditioners. On its simplest form, the conjugate

gradient method is given by the following algorithm:

Figure 4.1: Conjugate Gradient algorithm, taken from [3].

4.1.2 2D Multigrid

As for the Multigrid method, we consider the standard V-cycle presented in

[3]. The algorithm is given bellow. The only difference between the 1D and

2D Multigrid algorithms is in the way that the restriction and interpolation

operators are constructed. Denote the restriction operator by IhH and the inter-
h
polation operator by IH . Denote the coarsest mesh-size by h0 and let H = 2h.

Finally, let smooth (A,b,x0) be the smoothing action of the system Ax = b

with initial guess x0 , using nu iterations. The algorithm is shown in Figure 4.2.

7
Figure 4.2: V-Cycle Algorithm, as given in [3].

In the previous case, we denote the 2-D interpolation operator by the Kronecker

tensor product of the 1-D interpolation operators, ihH :

h
IH = ihH ihH , (4.1)

where
1

2


1





1

1
ihH

= 2 . (4.2)
2

..
1

.



1



2


1

Moreover, we get that the restriction operator can be associated with the inter-

polation operator by

h
I2h = 4(Ih2h )T . (4.3)

8
4.2 Testing the Solvers

We implement the solver for the Navier-Stokes equation using both conjugate

gradient and 2-D multigrid on a matrix of size 4096 4096 using a 2 3 GHz

Quad-Core Intel Xeon with 16GB RAM . The results obtained are shown in

figure 4.3 and 4.4. On Figure 4.3, we get the norm of the residuals provided at

each level of the of the v-cycle, being step 1 and 5 the finest coarse size and 3

being the coarsest one. We are relaxing 4 times on each level using Gauss-Seidel.

Figure 4.4 shows the residuals for conjugate gradient. Note that for U and V

the convergence is pretty fast, whilst it takes a larger number of iterations for

P and Q, which ultimately contributes to the difference in efficiency between

both methods (see next section). In general, it can be said that both methods

methods works, particularly compared to direct methods which are incredibly

inefficient for matrices of this size.

9
Figure 4.3: Residuals Multigrid. Top: U, V. Bottom P,Q.

Figure 4.4: Residuals Conjugate Gradient. Top: U, V. Bottom P,Q.

10
4.3 Results and Comparison

Solving the 2D Navier-Stokes equation on a square grid [0, 1] with N 2 points and

integrating for t [0, 1] and using CG, Multigrid (V-cycle), and MATLABs \

(which uses a Cholesky factorization given that the matrices are sparse, SPD)

in order to solve the arising Laplaces equations, we obtain the running times

presented in Table 4.1.

N \Method CG Multigrid Backslash

28 7.8965 5.7829 6.8495

210 10.2902 6.7087 7.8063

212 78.9132 13.1671 14.5051

214 443.8054 60.5948 76.5526

Table 4.1: CPU Time for different methods and grid-sizes.

As we can see from Table 4.1, multigrid is much more efficient than both con-

jugate gradient and MATLABs built in solver. Interestingly enough, MATLABs

solver runs faster than our version of CG, however, this could be in part because

of the heavy optimization that the backslash solver has and the fact that we

are using sparse matrices. Additionally, we first considered using GMRES(n),

where n is the number of restarts, however, this method proved to be very inef-

ficient, even when the number of restarts was low. Moreover, this method has

the disadvantage of not being guaranteed to converge if we take restarts.

A visualization of the result is given by Figure 4.5, where we denote the pressure

field in color, the streamline function, that is, the trajectory a particle would

take at any given point by the contour plot, and the velocity as a vector field.

11
Re = 1e+03 t = 0.01 x 10
3
Re = 1e+03 t = 0.2 Re = 1e+03 t = 0.4 Re = 1e+03 t = 0.6 Re = 1e+03 t = 0.8
1 1 1 1 1
2
0.9 0.9 0.9 0.9 0.9
1.5
0.8 0.8 0.8 0.8 0.8

0.7 1 0.7 0.7 0.7 0.7

0.6 0.5 0.6 0.6 0.6 0.6

0.5
y

0.5 0.5 0.5 0.5


0
0.4 0.4 0.4 0.4 0.4

0.5
0.3 0.3 0.3 0.3 0.3

0.2 1 0.2 0.2 0.2 0.2

0.1 1.5 0.1 0.1 0.1 0.1

0 0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0 0.2 0.4 0.6 0.8 1
x

Figure 4.5: Progression of the solution for different times, from left to right,

t=0.01, t=0.2, t=0.4, t=0.6, t=0.8.

5 Final Remarks

We have seen how to numerically solve the 2D incompressible Navier-Stokes

equations using some of the numerical algorithms studied in class. As men-

tioned before, GMRES was not included in the analysis since when doing the

numerical experiments it proved to be much slower (even when using restarts)

than conjugate gradient. This is due to the fact that we are dealing with very

large matrices and as such, the GMRES algorithm needs to orthogonalize against

a rather large number of vectors, becoming increasingly more expensive.

Given the clever idea of pressure projection we are able to solve the N-S equa-

tions by solving Laplaces equation for each of the parameters (u, v, p, q) for each

instance in time. This in turn provides us with the opportunity of implementing

fast numerical algorithms that exist for these type of methods. In this case we

implemented a two-dimensional multigrid algorithm, however, there are other

fast numerical methods that we did not considered, such as spectral methods.

Additionally, it would be interesting to implement some useful preconditions in

order to study how they affect conjugate gradient.

12
In general, we consider that the methods used in this project have been proved

effective for the solution of the 2D incompressible Navier-Stokes equations.

13
References

[1] A.J. Chorin, Numerical solution of the Navier-Stokes equations. Math. Com-

put. 22, 745762, 1968.

[2] G. Strang, Computational Science and Engineering, First Edition. Wellesley

Cambridge Press, 2007.

[3] Y. Saad. Iterative methods for sparse linear systems. Society for Industrial

and Applied Mathematics, 2003.

[4] MIT OpenCourseWare: Mathematical Methods for Engineers II. Classnotes.

14

También podría gustarte