Вы находитесь на странице: 1из 16

An Introduction to Multigrid

41319 - Computational Fluid Dynamics

Fall, 2016

1 / 16
Iterative solution of sparse linear systems revisited
For report 2, we are solving
Z Z
n (Pe uT T ) dS = ST d
S
Discretization (CDS or UDS)
AT = s

The linear system is then solved either:


1. Directly: T(:)=A\s(:), or
2. Iteratively: Choose a splitting of A and an initial guess

A = M N, T0

Iterate until convergence to get the solution

M T k = N T k 1 + s, k = 1, 2, . . .

For this problem, the direct solution is faster than SOR.

2 / 16
To beat the direct solution, we need MULTIGRID 1
The essential principle of multigrid methods

Consider the 1D, periodic pure diffusion model problem


Z 2
d T
Z
dx = f (x ) dx , x [0, 1], T (0) = T (1) (1)
dx 2

An FV CDS discretization on the grid xj = (j 21 )x , x = 1/n gives

Tj1 2Tj + Tj+1 = sj j = 1, 2, ..., n

The Gauss-Seidel iterative scheme for the m-th iteration:

T1k = 21 (s1 Tnk 1 T2k 1 )


k 1
Tjk = 21 (sj Tj1
k
Tj+1 ) j = 2, 3, ..., n 1
Tnk = 12 (sn Tn1
k
T1k )

1 A good introduction to this topic is: Pieter Wesseling, An Introduction to Multigrid

Methods. Philadelphia: R.T. Edwards, Inc., 2004


3 / 16
Analysis of the error
The error ejk = Tjk Tj satisfies:

k k 1
ej1 2ejk + ej+1 =0 (2)

Expand the error in a Fourier series:


n/2
X 2
ejk = ck exp (i j ), = = 2x (3)
n
=0

4 / 16
Analysis of the error

=4
exp (ij )

=3

=2

=1

0 0.2 0.4 0.6 0.8 1


jx

5 / 16
Analysis of the error
The error ejk = Tjk Tj satisfies:

k k 1
ej1 2ejk + ej+1 =0 (2)

Expand the error in a Fourier series:


n/2
X 2
ejk = ck exp (i j ), = = 2x (3)
n
=0

Plug into (2) (due to orthogonality, each mode can be considered


independently)
exp (i )
ck = k 1
2exp (i ) c = g( ) ck 1 (4)

g( ) is the amplification factor for this error mode.

1
|g( )| = p
(5 4 cos )

6 / 16
Analysis of the error
Taylor expand this to get:

|g( )| = 1 4 2 2 x 2 + O(x 4 ) (5)

which shows that |g( )| decreases as increases. Convergence


deteriorates as x .
Long wavelengths (smooth errors) decay slowly.
short wavelengths (non-smooth errors) decay quickly.

Convergence can be improved by multigrid.

The essential multigrid principle is to approximate the smooth errors


on coarser grids where they become non-smooth and are quickly
reduced.

In multigrid terminology, the basic iterative scheme is called a


smoother.

7 / 16
The basic two-grid algorithm
Define a coarse grid with xj = (j 12 )x , x = 2/n, the original grid
is called the fine grid. Three operators are needed:
1. A prolongation operator, the matrix P, which linearly interpolates
from the coarse to the fine grid using

3 1 3 1
T2j = Tj + Tj+1 ; T2j+1 = Tj+1 + Tj
4 4 4 4
2. A restriction operator, the matrix R, which takes a weighted
average on the fine grid to obtain values on the coarse grid

1 3 3 1
Tj = T2j2 + T2j1 + T2j + T2j+1
8 8 8 8
One choice is the Galerkin
3. A coarse grid smoother, the matrix A.
coarse grid smoother
T = s
A ; = RAP
A

8 / 16
Prolongation, restriction and coarse grid operators
Linear interpolation (unit spaced, periodic grid):


3/4 1/4
2 1 1
3/4 1/4

1 2 1 1/4 3/4

A=
. . .
P=
. . .

1 2 1
3/4 1/4

1 1 2 1/4 3/4
1/4 3/4


3/8 3/8 1/8 1/8
1/8 3/8 3/8 1/8

R= . . .

1/8 3/8 3/8 1/8
1/8 1/8 3/8 3/8
= RAP
A

9 / 16
Coarse grid correction
Let T be a fine grid approximation to the solution T , then the error is
e = T T . Apply A to both sides:
A e = AT AT = s AT = r
So, solve for the coarse grid error and correct:
e
A = Rr T = T + P e

The basic algorithm:
% Produce the initial guess T0(1:n)
for (iter < maxiter) & (res > tol)
% Smooth times on the fine grid.
% Form the fine grid residual
% Restrict the residual and solve for the error.
% Prolong error, correct the fine grid solution.
% Smooth times on the fine grid.
% Compute the relative change in the solution
end

10 / 16
Two-grid analysis
For the 1-D periodic case, a two-grid analysis shows that
convergence is independent of the mesh size x .
2T
An example: x 2
= 4 2 cos (2x ), T (x ) = cos (2x )
The exact solution on the two grids
1

0.8

0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8 Fine, n=16


Coarse, n=8
-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

11 / 16
Iteration counts for Gauss-Seidel vs. two-grid (1-D ex.)
6 Iteration count, 1-D periodic example
10
Two-grid
Gauss-Seidel
5
10
Fine grid iteration count

4
10 Gauss-Seidel slope=1.7207

3
10

2
10

1
10 0 1 2 3 4
10 10 10 10 10
N
12 / 16
Multigrid

Consider a sequence of increasingly finer grids:

{k = 1, 2, . . . , K }, nk +1 = 2nk

Each grid has a solution T k , along with a prolongation and a


restriction operator:

P k : T k 1 T k , R k : T k T k 1 .

The problem to be solved on grid k is:

Ak T k = b k .

The Galerkin coarse grid approximation for grid k 1 :

Ak 1 = R k Ak P k .

13 / 16
The linear multigrid algorithm (recursive)

1 function T = LMG(T , f , , k )
2 % The recursive linear multigrid algorithm.
3 if k = 1
4 T k = A\f k
5 else
7 T k = S(T , f , , k )
8 r k = f k Ak T k
9 f k 1 = R k 1 r k
k 1
10 T =0
11 T k 1 = LMG(T , f , k 1)
12 T k = T k + P k T k 1
13 T k = S(T , f , , k )
14 end

The symbol S(T , f , , k ) represents smoothing operations applied


to the system Ak T = f k .

14 / 16
A pure diffusion problem in 2D

15 / 16
Pseudo-multigrid (suggestion for Report 2)

To improve the performance of the SOR iterative method, without the


full complexity of multigrid:
When solving for a given value N = n2 , n = 2k + 1, k = 1, 2, ...
Use SOR to solve for T 1
Prolong T 1 up to grid k = 2 to provide the initial guess on this
grid (use interp2() with extrapolation)
Repeat until you reach the grid you want to solve for

16 / 16

Вам также может понравиться