Multigrid Tutorial
Multigrid Tutorial
U-Boulder 2 of 312
Sources
MGNet http://www.mgnet.org/
Newsletter
Software repository
Copper Mountain Conference
March 30--April 4, 2003
We hope to support your attendance.
1: 3,4 6: 1, 2, 6
3: 2-6 8: 2, 6, 8
4: 6, 7, 11 9: 1, 3
U-Boulder 4 of 312
Computing assignments
Due 2 weeks after the relevant chapter is covered.
Start assignments very early: computers are merciless!!!
Use whatever computing language/platform you like.
2: 20 4: 13, 15 6: 6 by computer!!!
U-Boulder 5 of 312
Project & presentation
Due at the end of the semester.
U-Boulder 6 of 312
My thoughts on what’s good science
in order of importance to me
• Attitude
– You can do it! Be positive.
– But is it really right? Be critical.
– Think, think, think! Don’t just hope or guess.
– Control your emotions! Expect ups & downs in order to control them.
• Method
– Start simply. Reduce issue to the simplest possible case.
– Think with tiny steps, but keep the big picture in mind.
– Study concrete examples.
– Look for analogies. Can A be done in any way like how B was done?
• Creativity
– What do you really want? What end are you really aiming for?
– What do you really need? What you’re trying may be sufficient to do
what you want, but would an easier-to-prove weaker result do instead?
• Intelligence
– OK, so it doesn’t hurt to try to be “smart” too.
U-Boulder 7 of 312
A Multigrid Tutorial
2nd Edition, 2nd Printing
By
William L. Briggs
CU-Denver
Van Emden Henson
LLNL ← THANKS!
Steve McCormick
CU-Boulder
U-Boulder 8 of 312
Outline
by chapter
U-Boulder 9 of 312
Suggested reading
CHECK MY MG LIBRARY & MGNET REPOSITORY
U-Boulder 10 of 312
Multilevel methods have been
developed for...
• PDEs, CFD, porous media, elasticity, electromagnetics.
• Purely algebraic problems, with no physical grid; for
example, network & geodetic survey problems.
• Image reconstruction & tomography.
• Optimization (e.g., the traveling salesman & long
transportation problems).
• Statistical mechanics, Ising spin models.
• Quantum chromo dynamics.
• Quadrature & generalized FFTs.
• Integral equations.
U-Boulder 11 of 312
Everyone uses multilevel methods
• Multigrid, multilevel, multiscale, multiphysics, …
Use local “governing rules” on the finest level to
resolve the state of the system at these detailed
scales, but--recognizing that these “rules” have
broader implications that are hard to determine
there--use coarser levels to resolve larger scales.
Continual feedback is essential because improving
one scale impacts other scales.
• Common uses
Sight, art, politics, thinking (scientific research),
cooking, team sports, …
U-Boulder 12 of 312
1. Model problems
• 1-D boundary value problem:
v i ≈ u( x i ) f i ≈ f ( xi ) i = 0, 1, . . . N
u( x i + 1 ) − 2 u( x i ) + u( x i − 1 )
u″ ( x i ) = + O( h 2)
h2
U-Boulder 14 of 312
Approximate equation via
finite differences
• Approximate the BVP
− vi − 1 + 2 vi − vi + 1
+ σ vi = f i i = 1, 2, . . . N − 1
2
h
v0 = vN = 0
U-Boulder 15 of 312
Discrete model problem
T&
Letting v = ( v 1, v 2, . . . , v N − 1 )
T
f = ( f 1, f 2, . . . , f N − 1 )
we obtain the matrix equation Av = f, where A
is (N-1) x (N-1), symmetric, positive definite, &
2 + σh2 −1 f1
v1
− 1 2 + σh 2 v2 f
−1 2
1 2
− 1 2 + σh − 1 v3 f
A= , v= , f = 3
2
h
2 N −2
v f N −2
− 1 2 + σ h − 1 v
N − 1 f
− 1 2 + σh2 N −1
U-Boulder 16 of 312
Stencil notation
A = [-1 2 -1]
dropping h -2 & σ for convenience
-1
-1
U-Boulder 17 of 312
Basic solution methods
• Direct
– Gaussian elimination
– Factorization
– Fast Poisson solvers (FFT-based, reduction-based, …)
• Iterative
– Richardson, Jacobi, Gauss-Seidel, …
– Steepest Descent, Conjugate Gradients, …
– Incomplete Factorization, ...
• Notes:
– This simple 1-D problem can be solved efficiently in many ways.
Pretend it can’t & that it’s very hard, because it shares many
characteristics with some very hard problems. If we keep things
as simple as possible by studying this model, we’ve got a chance
to really understand what’s going on.
– But, to keep our feet on the ground, let’s go to 2-D anyway…
U-Boulder 18 of 312
2-D model problem
• Consider the problem
T
v = (v1,1 , v1,2 ,..., v1,N −1 , v2 ,1 , v2 , 2 ,..., v2 ,N−1 ,..., vM−1,1 ,vM−1,2 ,..., vM−1,N−1 )
U-Boulder 20 of 312
Resulting linear system
• We obtain a block-tridiagonal system Av = f :
A1 − Iy v1 f1
−I A − I
y 2 y 2
v f
2
− Iy A3 − Iy v3 f
= 3
− Iy AN − 2 − Iy
vN − 1 f
Iy is a diagonal
where − Imatrix
y A N − 1 with on
Nthe
−1
diagonal & 1
hy2
2 + 2 +σ −
1
hx2 hy2 hx2
1 2 2 1
− 2 + 2 +σ −
hx2 hx hy hx2
Ai = 1 2 2 1
− 2 + +σ −
hx hx2 hy2 hx2
1 2 2
− 2 2 + 2 +σ
U-Boulder hx hx hy 21 of 312
Stencils
preferred for grid issues
U-Boulder 22 of 312
Outline
Chapters 1-5: Chapters 6-10:
• √ Model Problems • Nonlinear Problems
• Basic Iterative Methods – Full approximation scheme
– Convergence tests • Selected Applications
– Analysis – Neumann boundaries
– Anisotropic problems
• Elements of Multigrid
– Variable meshes
– Relaxation
– Variable coefficients
– Coarsening
• Algebraic Multigrid (AMG)
• Implementation
– Matrix coarsening
– Complexity • Multilevel Adaptive Methods
– Diagnostics – FAC
• Some Theory • Finite Elements
– Spectral vs. algebraic – Variational methodology
U-Boulder 23 of 312
2. Basic iterative methods
U-Boulder 25 of 312
Relaxation
− ui − 1 +2 ui − ui + 1 = h 2 f i 1 ≤ i ≤ N −1 u0 = uN = 0
( ) 1 ( o ld)
vi n e w = ( v i − 1 + v i( +ol1d) + h 2 f i ) 1 ≤ i ≤ N −1
2
U-Boulder 26 of 312
Jacobi in matrix form
• Let A = D - L - U, where D is diagonal & L & U are
the strictly lower & upper triangular parts of A.
• Then becomes
Au = f
(D −L −U) u = f
D u = ( L + U) u + f
• Let u = D − 1.( L + U) u + D − 1 f
– RJR is = − 1the error propagation =orDiteration
-1(D-A) matrix.
I D-1A
J
called
D ( L + U) J = -
• Then the iteration is
v ( n ew) = R J v ( o ld ) + D − 1 f
U-Boulder 27 of 312
Error propagation matrix & the error
• From the derivation,
u = D − 1 ( L + U) u + D − 1 f
u = RJ u + D − 1 f
• the iteration is
v ( n ew) = R v ( o ld ) + D − 1 f
• subtracting, J
• or
u − v ( n ew) = R J u + D − 1 f − ( R J v ( o ld) + D − 1 f )
• hence
u − v ( n ew) = R J u − R J v ( o ld)
U-Boulder 29 of 312
But…
U-Boulder 30 of 312
Another matrix look at Jacobi
v (new) ← D-1 (L + U) v (old) + D-1 f (L + U = D-A)
= (I - D-1 A) v (old) + D-1 f
v (new) = v (old) - D-1 (Av (old) - f) = v (old) - D-1 r
U-Boulder 31 of 312
Weighted Jacobi • • •
safer (0<ω<1) changes; politics in the ‘hood • o •
• • •
• Consider the iteration
( ) ( ) ω ( o ld )
vi n e w ← ( 1 − ω) v i o l d + ( v i − 1 + v i( +o l1d) + h 2f i )
2
= R ω v ( old) + ω h 2D − 1f
• Note that
R ω = [ ( 1 − ω) I +ω R J ]
( a ppro x )
• It is easy to see that if e ≡ u ( ex a c t ) − u , then
e ( n ew) = R ω e ( o ld)
U-Boulder 32 of 312
Gauss-Seidel (1-D)
• Solve equation i for ui & update immediately.
• Equivalently: set each component of r to zero in turn.
• Component form: for i = 1, 2, . . . N − 1, set
1
vi ← ( vi − 1 + vi + 1 + h 2 f i )
• Matrix form: 2
A = (D −L −U)
( D − L) u = U u + f
• Let u = ( D − L) − 1 U u + ( D − L) − 1 f
• ThenRiterate:
= ( D − L ) − 1U
G
v ( n ew) ← R G v ( old) + ( D − L ) − 1f
• Error propagation:
e ( n ew) ← R G e ( o ld)
U-Boulder 33 of 312
Red-black Gauss-Seidel
• Update the EVEN points:
1
v 2i ← ( v 2i − 1 + v 2i + 1 + h 2 f 2i )
2
• Update the ODD points:
1
v 2i + 1 ← ( v 2i + v 2i + 2 + h 2 f 2i + 1 )
2
x0 xN
• 2-D:
U-Boulder 34 of 312
Numerical experiments
• Solve A u = 0 , − ui − 1 + 2 u i − u i + 1 = 0
• Use Fourier modes as initial iterates, with N = 64:
ikπ 1 ≤ i ≤ N − 1, 1 ≤ k ≤ N −1
vk = ( v i ) k = sin
N component mode
sin(kπx), x =i/N k =1
1
0.8
0.6
k =3
0.4
0.2
0
-0.2
-0.4
k =6
-0.6
-0.8
-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
U-Boulder 35 of 312
Convergence factors differ for
different error components
Error, ||e||∞ , in weighted (ω=2/3) Jacobi on Au = 0
for 100 iterations using initial guesses v1, v3, & v6
1
k =1
0.9
0.8
0.7
0.6
0.5
0.4
k =3
0.3
0.2
k =6
0.1
0
0 20 40 60 80 100 120
U-Boulder 36 of 312
Stalling convergence
relaxation shoots itself in the foot
a b c 4
I can deal with 24, but d e f ???
g h i
a b c 4
What if d e f
e = 24 e ???
g h i
U-Boulder 38 of 312
Quick review of
eigenvectors & eigenvalues
• The number λ is an eigenvalue of a matrix B & w ≠ 0
its associated eigenvector if Bw = λw.
• The eigenvalues & eigenvectors are characteristics
of a given matrix.
• Eigenvectors are linearly independent, & if there is a
complete set of N distinct eigenvectors for an NxN
matrix, then they form a basis: for any v, there exist
unique scalars vk such that
N
• Propagation: v= Σ k
vk
k=1
w Why is an
eigenvector
N useful???
n
Σ
n
B v= λ vk wk
U-Boulder k=1 39 of 312
“Fundamental Theorem of Iteration”
• R is convergent (Rn → 0 as n → ∞) iff
.
ρ(R) = max1≤k≤N λk < 1
Thus, e(n) = Rne(0) → 0 for any initial vector v (0)
iff ρ(R)<1.
U-Boulder 40 of 312
Rayleigh quotient vs. spectral radius
assume A is symmetric (wk orthogonal) & nonnegative definite (λ ≥ 0)
• ||R||2 = ρ1/2(RTR):
||R||22 = supe≠0 ||Re||22 /||e||22
= supe≠0 <Re,Re >/<e,e>
= supe≠0 <RTRe,e >/<e,e> = ρ(RTR)
note: ||Re||2 ≤ ||R||2·||e||2
U-Boulder 42 of 312
ρ(R) vs. ||R||2
ρ(R) = sup |λ(R)|. ||R||2=supe≠0 ||Re||2 /||e||2= ρ1/2(RTR).
ρ(R) = ||R||2
for symmetric R.
U-Boulder 43 of 312
Example: R = ( ), K large
ρ(R) = 0 but ||R||2 = K !
(1) (0 )
0 e 2 Re
= ⇒ ( 0) = (0 )
( 0)
e 2
=K
1 e 2 e 2
U-Boulder 44 of 312
Convergence factor & rate
• How many iterations are needed to reduce the initial error
by 10-d ?
e (n ) n n −d
(0 ) ≤ R ≤ R ~ 10
e
• So, we have
d
n~
− log10 ρ( R)
• Convergence factor = ||R|| or ρ(R).
= I − ωD − 1 A
2 −1
−1 2 −1
ω
Rω = I − −1 2 −1 1-D
2 ⋅⋅ ⋅⋅ ⋅⋅
⋅ ⋅ ⋅
−1 2
N = 64 0.2
0
-0.2
0.2
0
-0.2
-0.4 -0.4
-0.6 -0.6
-0.8 -0.8
-1 -1
0 10 20 30 40 50 60 0 10 20 30 40 50 60
k = 1 k = 2
1 1 1
0.8 0.8 0.8
0.6 0.6 0.6
0.4 0.4 0.4
0.2 0.2 0.2
0 0 0
-0.2 -0.2 -0.2
-0.4 -0.4 -0.4
-0.6 -0.6 -0.6
-0.8 -0.8 -0.8
-1 -1 -1
0 10 20 30 40 50 60 0 10 20 30 40 50 60 0 10 20 30 40 50 60
k = 4 k = 8 k = 16
U-Boulder 47 of 312
Eigenvectors of Rω = eigenvectors of A
kπ
λk ( R ω ) = 1 − 2 ω sin2 2N
U-Boulder 48 of 312
Relaxation suppresses eigenmodes unevenly
0.8
Note that if 0 < ω ≤ 1,
0.6 ω = 1/3
then | λ ( R ω ) | < 1 for
k
.
0.4 k = 1, 2, . . . , N − 1
0.2 ω = 1/ 2 For 0 < ω ≤ 1,
λ 0
N
π
-0.2
2 λ1 = 1 − 2 ω sin 2
2N
-0.4
ω=1
ω = 2/ 3
-0.6 πh
= 1 − 2 ω s in
2
-0.8
2
-1
= 1 − O ( h2) ≈ 1
0 k N
U-Boulder 49 of 312
Low frequencies are “undamped”
Notice that no value of ω will efficiently damp out
long waves or low frequencies.
1
What value of ω gives
0.8
the best damping of
0.6 ω = 1/3
short waves or high
0.4
frequencies N/2≤k≤N-1?
λ
0.2
ω = 1/ 2
axis 0
-0.2
N Choose such that
-0.4
2
ω
ω=1
-0.6
ω = 2/ 3 λN ( R ω ) = − λN ( R ω )
-0.8 2
2
-1 ⇒ ω=
0 N 3
U-Boulder
k axis 50 of 312
Smoothing factor
U-Boulder 51 of 312
Convergence of Jacobi on Au = 0
100 100
Unweighted Jacobi Weighted Jacobi
90 90
80 80
70 70
60 60
50 50
40 40
30 30
20 20
10 10
0
0 0 10 20 30 40 50 60
0 10 20 30 40 50 60
Wavenumber, k Wavenumber, k
• Jacobi on Au = 0 with N = 64. Number of iterations
needed to reduce initial error ||e||∞ by 0.01.
• Initial guess :
jkπ
vkj = sin
N
U-Boulder 52 of 312
Weighted Jacobi = smoother (error)
2j π 1 16j π 1 32j π
• Initial error: v k j = sin
N + 2 sin N + 2 sin N
2
-1
Many relaxation schemes
-2
are smoothers:
0 0 .5 1 oscillatory error modes
are quickly eliminated,
• Error after 35 iteration sweeps: but
smooth modes are slowly
2
damped.
1
-1
-2
0 0 .5 1
U-Boulder 53 of 312
Similar analysis for other smoothers
• Gauss-Seidel relaxation applied to the 3-point
difference matrix A (1-D model problem):
−1
RG = ( D − L ) U
• A little algebra & trigonometry shows that
kπ kπ jkπ
λk (RG ) = cos2 wk , j = cos j sin
N N N
1
1
0.8
0.8
0.6 π xj )
sin(3π
0.4
0.2
0.6
0
j
0.4 λk -0.2
-0.4
λ3 sin(3π
πxj )
-0.6
0.2
-0.8
-1
0
0 10 20 30 40 50 60
k 0 10 20 30
j 40 50 60
U-Boulder
What’s wk look like for large k ? 54 of 312
Gauss-Seidel eigenvectors
1 0.1
0.8 0.08
0.06
0.6
k=1,n=64 0.04
0.4
0.02
k=30,n=64
0.2 0
0 −0.02
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
0.2 1
0.1 k=60,n=64
0.5
0
−0.1
0
−0.2 k=48,n=64
−0.3
−0.5
−0.4
−0.5 −1
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
U-Boulder 55 of 312
Gauss-Seidel convergence
Au = 0
Eigenvectors of RG are not the same as those of A.
Gauss-Seidel mixes the modes of A.
80
N = 64. Number of iterations
70 needed to reduce initial error
60
50
||e||∞ by 0.01.
40
10
0
jkπ
vkj = sin
0 10 20 30 40 50 60
N
U-Boulder 56 of 312
Outline
Chapters 1-5: Chapters 6-10:
• √ Model Problems • Nonlinear Problems
• Basic Iterative Methods – Full approximation scheme
√ • Selected Applications
– Convergence tests
– Analysis – Neumann boundaries
– Anisotropic problems
• Elements of Multigrid
– Variable meshes
– Relaxation
– Variable coefficients
– Coarsening
• Algebraic Multigrid (AMG)
• Implementation
– Matrix coarsening
– Complexity • Multilevel Adaptive Methods
– Diagnostics – FAC
• Some Theory • Finite Elements
– Spectral vs. algebraic – Variational methodology
U-Boulder 57 of 312
3. Elements of multigrid
1st observation toward multigrid
• Many relaxation schemes have the smoothing
property: oscillatory error modes are quickly
eliminated, while smooth modes are often very
slow to disappear.
• We’ll turn this adversity around: the idea is to
use coarse grids to take advantage of smoothing.
x0 xN
Ωh
2h
x0 xN Ω
2
How?
U-Boulder 58 of 312
Reason #1 for coarse grids:
Nested iteration
• Coarse grids can be used to compute an improved
initial guess for the fine-grid relaxation. This is
advantageous because:
instead of
1 − O( 4h 2 ) 1 − O ( h 2)
U-Boulder 59 of 312
Idea! Nested iteration
•
•
•
• Relax on Au = f on Ω4h to obtain initial guess v2h.
• Relax on Au = f on Ω2h to obtain initial guess vh.
• Relax on Au = f on Ωh to obtain … final solution???
U-Boulder 60 of 312
Reason #2 for coarse grids:
Smooth error becomes more oscillatory
• A smooth function:
1
On the coarse grid, the
smooth error appears to
0 . 5 be relatively higher in
0
frequency: in this example
it is the 4-mode out of
- 0 . 5 a possible 15 on the fine
grid, ~1/4 the way up the
- 1
0 0 . 5 1 spectrum. On the coarse
grid, it is the 4-mode out
of a possible 7, ~1/2 the
can be represented by linear way up the spectrum.
interpolation from a coarser grid:
Relaxation on 2h is
(cheaper &) faster
on this mode!!!
U-Boulder 61 of 312
For k=1,2,…N/2, the kth mode is
preserved on the coarse grid.
2j k π j kπ
1
0.8
wk , 2j = sin
h
= sin = wk2,hj 0.6
N N /2
0.4
0.2
0
-0.2
1
0.8
0.6
0.4
N
0.4
0.2
0
-0.2
π ( N − k) j
-0.4
-0.6
= − sin -0.8
N / 2
-1
0 1 2 3 4 5 6
k=3 mode, N=12 grid
= − ( wN
2h )
−k j
U-Boulder 63 of 312
1-D interpolation (prolongation)
to migrate from coarse to fine grids
I 2hh : Ω 2h → Ω h
• Let , be defined on h, . Then
2h
vh v 2h Ω Ω
where I 2hh v 2h = v h
v 2hi = v i2h
v 2hi + 1
1 2h
= ( v i + v i2h+ 1 )
2
} for 0≤i ≤
N
2
− 1.
U-Boulder 64 of 312
1-D interpolation (prolongation)
• Values at points on the coarse grid map unchanged
to the fine grid.
• Values at fine-grid points NOT on the coarse grid
are the averages of their coarse-grid neighbors.
U-Boulder 65 of 312
1-D prolongation operator P
h
• P = I 2h is a linear operator: ℜN/2-1 ℜN-1 .
v 1h
• N = 8: 1/2
1 v 2h
1/2 1/2 v 2h
1 v 3h
2h h
1 2 v = v4
1/2 1/2 v 2h h
3 3x 1 v5
1 h
v6
1/2 7x 3
vh
• has full rank, so η(P ) = {0} . 7 7x 1
I 2hh
When is I 2hh v2h = 0?
U-Boulder 66 of 312
“Give To” stencil for P
] 1/2 1 1/2 [
o x o x o x o
1/2 1 1/2
U-Boulder 67 of 312
How well could v 2h approximate u?
U-Boulder 68 of 312
How well could v 2h approximate u?
U-Boulder 69 of 312
Moral
• If what we want to compute is smooth, a
coarse-grid interpolant could do very well.
• If what we want to compute is oscillatory, a
coarse-grid interpolant cannot do very well.
• What if u is not smooth? Can we make it so?
• Can we make something smooth?
U-Boulder 72 of 312
Idea! Coarse-grid correction
2-grid
h to get an approximation
• Relax on Au = f on Ω .
• Compute r = f − A v h .
• Relax on Ae = r on 2h to obtain an approximation to
Ω
the error, .
e 2h
• Correct the approximation v h ← v h + e2h.
I 2hh
U-Boulder 73 of 312
1-D restriction by injection
• Mapping from the fine grid to the coarse grid:
I h2h : Ω h → Ω 2h
• Let , be defined on ,
h 2h
. Then
vh v 2h Ω Ω
2h h
where I
. h v = v 2h
v i2h = v 2hi
Ωh
Ω 2h
U-Boulder 74 of 312
1-D restriction by full weighting
Ωh
Ω 2h
U-Boulder 75 of 312
1-D restriction (full-weighting)
2h
• R = I h is a linear operator: ℜN-1 ℜN/2-1 .
v 1h
• N = 8:
v 2h
1/4 1/2 1/4 v 3h v 12h
h 2h
1/4 1/2 1/4 v4 = v2
1/4 1/2 1/4 v h 2h
5 v3
h
v6
vh
• has rank , so dim(η(R)) 7 .
2h N N
Ih ∼ ∼
2 2
Look at the columns of R associated with grid 2h.
U-Boulder 76 of 312
Prolongation & restriction are
often nicely related
• For the 1-D examples, linear interpolation & full
weighting are
1
2
1 1 1 2 1
1 2h 1
I 2hh = 2 Ih = 1 2 1
2 4
1 1 1 2 1
2
1
• So they’re related by the variational condition
for c in ℜ.
T
I 2hh = c ( I h2h )
U-Boulder 77 of 312
2-D prolongation
1 1 1
4 2 4
1 2h 1 1
v 2i + 1, 2j = ( v i j + v ih+ 1, j )
h
1
2 2 2
1 2h
v 2hi , 2j + 1 = ( v i j + v ih, j + 1 ) 1 1 1
2 4 2 4
1 2h
v 2i + 1, 2j + 1 = ( v i j + v ih+ 1, j + v ih, j + 1 + v ih+ 1, j + 1 )
h
4
[1/2 1/2]
1/4 1/4
1/4 1/4
U-Boulder 79 of 312
2-D restriction (full weighting)
1 1 1
16 8 16
1 1 1
8 4 8
1 1 1
16 8 16
• Nested Iteration
– effective on smooth solution (components).
• Relaxation
– effective on oscillatory error (components).
• Residual Equation
– characterizes the error.
– enables nested iteration for smooth error (components)!!!
U-Boulder 81 of 312
2-grid coarse-grid correction
v h ← CG ( v h , f h ) , α1 , α2
U-Boulder 82 of 312
2-grid coarse-grid correction
Correct
Relax on Ah v h = f h
Compute r h = f h− Ahv h vh ← vh + eh
Restrict Interpolate
r 2h = I h2h r h eh = I2hh e2h
2h 2h
Solve A e = r2h
e 2h = ( A 2h) − 1 r 2h
U-Boulder 83 of 312
What is A2h?
U-Boulder 84 of 312
How do we “solve” the coarse-
grid residual equation? Recursion!
α1 h h α2 = 0
vh ← G (v , f ) v h ← v h + eh
h
f
2h 2h
← Ih ( f
h h
−A v )
h
e h ← I 2h v 2h
v 2h ← Gα1( 0 , f
2h 2h
) v 2h ← v 2h + e 2h
4h 4h 2h 2h
f ← I2h ( f − A v 2h ) 2h
e 2h ← I 4h v 4h
v 4h ← Gα1( 0
4h
,f
4h
) v 4h ← v 4h + e 4h
8h 8h 4h 4h
4h 4h
f ← I4h ( f −A v ) e 4h ← I 8h v 8h
v 8h ← Gα1( 0 , f
8h 8h
) v 8h ← v 8h + e 8h
1 H
vH = eH = ( A ) − f
H
U-Boulder 85 of 312
V-cycle (recursive form)
v h ← M V h ( v h , f h ) , α 1, α2
α2 A h uh = f h vh
U-Boulder 86 of 312
Outline
Chapters 1-5: Chapters 6-10:
• √ Model Problems • Nonlinear Problems
• Basic Iterative Methods – Full approximation scheme
√ • Selected Applications
– Convergence tests
– Analysis – Neumann boundaries
– Anisotropic problems
• Elements of Multigrid
– Variable meshes
√ – Relaxation
– Variable coefficients
– Coarsening
• Algebraic Multigrid (AMG)
• Implementation
– Matrix coarsening
– Complexity • Multilevel Adaptive Methods
– Diagnostics – FAC
• Some Theory • Finite Elements
– Spectral vs. algebraic – Variational methodology
U-Boulder 87 of 312
4. Implementation
Storage cost: vh & fh on each level.
In 1-D, a coarse grid has about half as many
points as the fine grid.
−d − 2d − 3d − Md 2N d
d
Total storage cost: 2N ( 1 + 2 +2 +2 + …+2 ) <
1 − 2− d
less than 2, 4/3, & 8/7 the cost of storage on the fine
grid for 1-D, 2-D, & 3-D problems, respectively.
U-Boulder 88 of 312
Computational cost
• Let one Work Unit (WU) be the cost of one
relaxation sweep on the fine grid.
• Ignore the cost of restriction & interpolation
(typically about 20% of the total cost).
• Consider a V-cycle with 1 pre-Coarse-Grid (α1 = 1)
correction sweep & 1 post-Coarse-Grid (α2 = 1)
correction sweep.
• Cost of a V-cycle (in WUs):
2− d 2 − 2d 2 − 3d 2− Md
2
2 ( 1+ + + + ... + ) <
1 − 2− d
• Cost is about 4, 8/3, & 16/7 WUs per
V-cycle in 1, 2, & 3 dimensions.
U-Boulder 89 of 312
Convergence analysis
• First, a heuristic argument:
– The convergence factor for the oscillatory error modes
(smoothing factor) is small & bounded uniformly in h.
smooth oscillatory
k=1 k=N/2 k=N
U-Boulder 91 of 312
We can satisfy the convergence
objective by imposing two conditions
U-Boulder 93 of 312
Work to converge to the level
of discretization error
• Using θ V-cycles with convergence factor γ gives an
overall convergence factor of γ θ.
• We must therefore have γθ ∼ O( N − p),
or .
θ ∼ O( l og N )
• Since 1 V-cycle costs O(1) WUs & 1 WUs is O(N d ),
then converging to the level of discretization error
using the MV method costs
d
O( N direct
• This compares to fast )
l og Nmethods (fast Poisson
solvers). But we’ll see that MV can do even better.
U-Boulder 94 of 312
Numerical example
− ux x − uy y = 2 ( 1 − 6x 2) y 2 ( 1 − y 2) + ( 1 − 6y 2) x 2 ( 1 − x 2)
in the unit square, with u = 0 Dirichlet boundary.
u( x , y ) = ( x 2 − x 4 ) ( y 4 − y 2)
U-Boulder 95 of 312
Numerical results
MV cycling
U-Boulder 97 of 312
Reconsideration
You want to approximate uh.
A good iteration is the V-cycle.
What’s a good way to start it?
Can you do better than vh ← 0?
Start on the coarse grid!
Use nested iteration for the V-cycle!
U-Boulder 98 of 312
Look again at nested iteration
• Idea: It’s cheaper to solve a problem (fewer iterations)
if the initial guess is good.
U-Boulder 99 of 312
Full multigrid (FMG)
v h ← FM G ( f h )
• Initialize f h , f 2h , f 4h , . . . , f H
1) Initialize f h , f 2h , f 4h , . . . , f H
• Property: || P e 2h || ≤ β|| e 2h ||
• Reasoning:
|| P e 2h || ≤ ||P|| || e 2h ||
= ||PT P||1/2 || e 2h ||
⇒ ||PT P||1/2 ≤ √2
− ux x − uy y = 2 ( 1 − 6x 2) y 2 ( 1 − y 2) + ( 1 − 6y 2) x 2 ( 1 − x 2)
inside the unit square, with u = 0 on the boundary.
1.03e-04
2.58e-05
6.44e-06
1.61e-06
• Start with two levels if you can, using a direct solver or lots
u 2h
I 2hh u 2h
h h 2h
A I 2h u
2h 2h h h
A = I h A I 2h A2h = RAP
i −1 i i +1
2h
0 1 0 ei
1 1 h 2h
0 2 1 2 0 I 2h e i
1 1 1 h h 2h
− 0 0 − A I 2h e i
2 2
2h h 2h 2
1 1 1 2h h h 2h
− − I h A I 2h e i
2 2
4h 2h 4h 2
U-Boulder 132 of 312
The i th row of A 2h looks a
lot like the i th row of A h !
• The i th row of 2h is 1
A −1 2 −1 ,
( 2h) 2
which is the 2h version of h.
Ω A
• Note that IF relaxation on h leaves only error
in the range of interpolation,Ωthen solving
A 2h u 2h = f 2h
determines the error exactly!
• This is generally not feasible, but this logic
leads to a very plausible representation for .
A 2h
U-Boulder 133 of 312
Variational properties of coarsening
• The definition for A 2h that resulted from the
foregoing line of reasoning is useful for both
theoretical & practical reasons. Together with
the commonly used relationship between
restriction & prolongation, we have the
variational properties:
h 2h T
I 2h = c ( I h ) for c in ℜ.
U-Boulder 134 of 312
Properties of restriction
in a little more detail…
2h h 2h or
• Full Weighting: Ih :Ω → Ω
2h ℜN-1 ℜN/2-1
Ih :
• N = 8:
1 2 1
2h 1
Ih = 1 2 1
4
1 2 1 3× 7
kπ 2h
( I h2h wkh ) = co s 2 2N wk , j
j
for 1 ≤ k ≤ N/2. ≡ c k wk2,hj
• • •
• h : N = 8, k = 2
• • Ω
• • •
I h2h
• : N = 4, k = 2
• • • Ω 2h
•
U-Boulder 137 of 312
Spectral properties (cont’d)
N N
• Let k ′ = N − k for 1 ≤ k < , so that < k′ < N .
2 2
kπ 2h
( I h2h wkh′ ) = − sin 2
2N wk , j
j
≡ s k wk2,hj
•
• 2h
• Ω
•
U-Boulder 139 of 312
Spectral properties (cont’d)
• Summarizing:
I h2h wkh = c k wk2h
}{
N
1<k <
2
I h2h wkh′ = − s k wk2h k′ = N − k
I h2h wN
h
/2 = 0
• Complementary modes:
I h2h W k → {wk2h}∞
• Let ηi = Ahêih.
• Interpolation: I h : Ω 2h → Ω h or
2h
h : ℜN/2-1 ℜN-1
I 2h
• N = 8: 1
2
1 1
1
I 2hh = 2
2
1 1
2
• has full rank & null space
1 {0}.
I 2hh
U-Boulder 142 of 312
Spectral properties of interpolation
• Consider j kπ , 1 ≤ k ≤ N/2-1,
( wk ) = sin
2h
j N / 2 0 ≤ j ≤ N/2.
kπ h kπ h
I 2hh wk2h = co s 2
2N wk − sin 2N
2
wk ′
= c k wkh − s k wkh′
U-Boulder 143 of 312
Spectral properties of interpolation
I2hh wk2h = ck wkh − sk wkh′
• is 2nd-order
≈w interpolation.
h
k
h
I 2h
U-Boulder 144 of 312
Range of interpolation
N −1
h
bk wkh ,
ξi = ∑ bk ≠ 0
=
k 1
• All the Fourier modes of are needed to represent
Range( ).
Ah
h
I 2h
U-Boulder 145 of 312
Use all the facts to analyze the
coarse-grid correction scheme
relax only before correction
1) Relax once on Ωh : vh ← R vh + B f h
2) Compute & restrict residual f 2h ← I h2h ( f h − A h v h )
3) Solve residual equation
2h − 1 2h
v =(A )
2h f
4) Correct fine-grid solution .
v h ← v h + I h v 2h
• The entire process appears as 2h
v hexactα vh h 2h − 1 2h h h
• The ← R solution
I satisfies
+ 2h ( A ) Ih ( f − A ( R v h + B f h ))
v h = R uh + I2hh ( A 2h ) − 1 Ih2h ( f h − A h ( R uh + B f h ))
U-Boulder 146 of 312
CG error propagation
h 2h − 1 2h h
eh ← I − I2h ( A ) Ih A R e h
e h ← CG e h
• How does CG act on the modes of ? Assume e h
consists of the modes & Ah
for
& . wkh h
wk′ 1 ≤ k ≤ N /2
k′ = N − k
• We know how
act on & .α h 2h 2h − 1
R , A , I , (A )h , Ih 2h
wkh h
wk′
kπ kπ
c k = co s 2 s k = sin2
2N 2N
k2 k2
wk → O + O
2 k 2 k′
w w
N N
k2 k2
wk ′ → 1 − O + 1 − O
2 k 2 k′
w w
N N
• Hence, CG eliminates the smooth modes but does
not damp the oscillatory modes of the error!
wk → λk sk wk + λk sk wk ′ Small!
wk ′ → λk ′ ck wk + λk ′ ck wk ′ Small!
2h 2h h h
A = I h A I 2h Galerkin Condition
h 2h T
I 2h = c ( Ih ) for c in ℜ.
Ω h = R ( I 2hh ) ⊕ N ( I h2h A h )
2h − 1 2h h
CGsh = I h
− I2h ( A ) Ih A h 2h
I2h q =0
• It follows that N(CG)=R( ), that is, 2htheby null
A Galerkin property
space of CG is the range ofh interpolation.
I2h
h h 2h − 1 2h h h
CG t = I − I2h ( A ) Ih A t
0
h h
⇒ CG t = t
• Thus, CG is the identity on .
2h h
N ( Ih A )
that is,
h
Ω = L ⊕ H
or
h h 2h h
Ω = R ( I 2h ) ⊕ N( Ih A )
U-Boulder 158 of 312
Actually, each view is just part
of the picture
• The operations we have examined work on different
spaces!
eh
th
R ( I 2hh )
sh
h
t L
eh
R ( I 2hh )
sh
h
t L
eh
R ( I 2hh )
sh
We A u −rely
can’t A v on=this
f −now ⇒ Aa enonlinear
A v since = r A(u)
generally means
A ( u ) − A ( v ) ≠ A ( e)
U-Boulder 165 of 312
The nonlinear residual equation
A ( u) = f
A ( u) − A ( v ) = f − A ( v )
A ( u) − A ( v ) = r
• How can we use this equation as the basis for a
solution method?
F( x + s) = F( x) + sF ′( x) + s 2 F ″ ( ξ)
• Dropping higher order terms (hot), if x + s is a solution,
= F(arrive
• We0thus x) + sat
F ′Newton’s
( x) ∴ s = − F( x ) / F ′ ( x )
method:
F( x )
x← x −
F ′( x)
U-Boulder 167 of 312
Newton’s method for systems
• The system A(u) = f in vector form is
A ( v + e) = A ( v ) + J( v ) e + hot
∂a
J(u) = i
U-Boulder
∂u j 168 of 312
Newton for systems (cont’d)
• J(v) is the Jacobian
∂a1 ∂a1 ∂a1
∂u L
∂u2 ∂u N
1
∂a2 ∂a2
L
∂a2
J(v) = ∂u1 ∂u2 ∂u N
M M O M
∂a N ∂a N ∂a N
L
∂ ∂
• If u = v + e is a solution,
u u ∂
2 f = A(v)N + J(v)e + hot, so
u
1
u=v
e ≈ [J(v)]-1(f - A(v))
• This leads to the iteration
v ← v + [J(v)]-1(f - A(v))
U-Boulder 169 of 312
Newton’s via the residual equation
• The nonlinear residual equation is
A ( v + e) − A ( v ) = r
• Expanding A(v + e) in a two-term Taylor series about v
& ignoring hot:
A ( v ) +J( v ) e − A ( v ) = r
• Newton’s method is J( v)
thus: e =r
r = f − A( v)
−1
v ← v + J( v) r
U-Boulder 170 of 312
How does multigrid fit in?
For each j = 1, 2, …, N :
Set the jth component of the residual to 0
& solve for vj . That is, solve (A(v))j = fj .
• Equivalently,
For each j = 1, 2, …, N :
Find s ∈ ℜ such that ,
where εj is the canonical jth unit basis vector.
( A ( v + s εj ) ) j = f j
• Example: ( ) may be
− uso″ (that
discretized x ) + u( x ) e u x =isf given
, by
( A( v) ) j = f j
− v j − 1 + 2v j − v j + 1
vj
2
1 ≤ j ≤ N −1
+ vj e = fj
h iteration for v is given by
• Newton j
− vj − 1 + 2 vj − vj + 1 vj
2
+ vj e − fj
h
vj ← vj −
2 vj
2
+ e ( 1 + vj)
U-Boulder
h 173 of 312
How do we do coarsening for
nonlinear multigrid?
• Recall the nonlinear residual equation
A ( v + e) − A ( v ) = r
• In multigrid, we obtain an approximate solution vh
on the fine grid, then solve the residual equation
on the coarse grid.
A 2h ( v 2h + e 2h ) − A 2h ( v 2h ) = r 2h
r 2h = I h2h ( f h − A h ( v h ) )
• For v2h we restrict vh by
v 2h = I h2h v h
Thus,
u 2h f 2h
coarse-grid unknown all quantities are known
• We solve for &
obtain A 2h ( u2h) = f 2h u 2h = I h2h v h + e 2h
e 2the
• We then apply u 2h − I h2h v h
h = correction:
h 2h
vh = vh + I 2h e
U-Boulder 176 of 312
Full approximation scheme (FAS)
2-grid form
• Perform nonlinear relaxation on A h( u h) = f h to
obtain an approximation v h .
• Restrict the approximation & its residual
v 2h = I 2h v h r 2h = I 2h ( f h − A ( v h ) )
• Solve the coarse-grid
h equation h
• Extract 2Ah2happroximation
( u 2h) = A 2h( vto2hh) error
+ r 2h
• Interpolate & correct
e 2h = u 2h − v 2h
v h = v h + I 2hh e 2h
U-Boulder 177 of 312
A few observations about FAS
A 2h ( Ih2h v h + e2h ) = A 2h ( Ih2h v h ) + Ih2h ( f h − A h( v h) )
A 2is
• The tau correction ( u ) = f 2halter the coarse-
h as 2ah way to
grid equation to enhance its approximation properties.
• Consider
u( x, y)
− ∆u( x, y) + γ u( x, y) e = f ( x, y)
on the unit square [0,1] x [0,1] with homogeneous
Dirichlet boundary conditions & a regular h = 1/128
Cartesian grid.
u( x, y) = ( x 2 − x 3 ) sin ( 3 π y)
h
A ( u h)
• Relaxation is given by
( A h( u h) ) − f i, j
i, j
uih, j ← uih, j −
4 uhi, j
2
+ γ ( 1 + ui , j ) e
h
h
γ
1 10 100 1000
convergence factor 4.00E-05 7.00E-05 3.00E-04 2.00E-04
number of Newton iterations 3 3 3 4
Outer Inner
Method iterations iterations Megaflops
Newton 3 1660.6
Newton-MG 3 20 56.4
Newton-MG 4 10 38.5
Newton-MG 5 5 25.1
Newton-MG 10 2 22.3
Newton-MG 19 1 24.6
FAS 11 27.1
U-Boulder 187 of 312
Comparing FMG-FAS & FMG-Newton
u( x, y)
− ∆u( x, y) + γ u( x, y) e = f ( x, y)
h 2h
Ih2hAI2he = I2hr
h
h h fewer equations
A2h
U-Boulder 190 of 312
Motivating FAS for nonlinear A
A(v + e) = f → A2h(v2h + e2h) = f2h
2h 2h h 2h 2h h 2h h h
A ( Ih v + e 2h ) = A ( Ih v ) + Ih ( f − A ( v h) )
A(v)
U-Boulder 191 of 312
Differential residual equation
γ (v’e + ve’ + ee’ ) - e’’ = f - A(v) ≡ r(v)
h h 2h 2h 2h 2h 2h 2h 2h
v −v
2j+2 2j−2 2h h e
j +1 −e
j −1 2h e j +1 −e j −1 −e
j +1 + 2e − e
j j −1 2h h
γ e + γv
j 2j + γe
j + 2 = (I r ) j
h
4h 4h 4h (2h)
• FAS
2h 2h h 2h 2h h2h 2h h h
h
A ( Ih v + e ) − A ( Ih v ) = Ih ( f − A (v ) )
− u ″ ( x ) + u( x ) e u( x ) = f ,
• Discretization:
− v j − 1 + 2v j − v j + 1
vj
+ vj e = fj
2
h
2h 2h 2h
−e j −1 + 2e j − e j +1 −e2 j −1 + 2e2 j − e2 j +1
• Step
+ + 2j
(1 v )e
v 2j 2h
e j = 2j −
r (
3: Correct the grid h Newton correction:
(2h)
2
h
2 + + 2j
(1 v ) e
v2j
e2 j )
• Step 4: Stop if you’vee “solved” hthe2 hlinear equation well
← + 2h e
e I
enough for Newton correction e & set v ← v + e. Else,
leave v alone & return to Step 1.
2h 2h 2h
−e j −1 + 2e j − e j +1 h 2h v2h j + e 2h h
h v2 j 2h h
+ ( + ) − = ( h r )j
j
2 v2j e j e v2j e I
(2h) the grid h approximation v :
• Step 3: Correct
0 x 1
u1 − u − 1 − uj − 1 + 2 uj − uj + 1 uN + 2 − uN
u′ ( 0) ≈ u″ ( x ) ≈ u′ ( 1) ≈
• This yields
2h the system
j
h2 2h
− uj − 1 + 2 uj − uj + 1
= fj 0 ≤ j ≤ N +1
h2
u1 − u − 1 uN + 2 − uN
=0 =0
2h 2h
− uj − 1 + 2 uj − uj + 1
= fj 0 ≤ j ≤ N +1
h2
− u ″ ( x) = f ( x) 0<x <1
u ′ ( 0) = u ′ ( 1) = 0
1
⌠ u( x ) dx = 0
• The last says:
⌡ of all possible solutions u(x) + constant,
we choose0 the one with zero mean.
h hence h h
dim(N S( A ) ) = 1 N S( A ) = spa n ( 1 )
• By the Fundamental Theorem of Linear Algebra,
has a solution if & only if Ah
f h ⊥ N S ( ( A h) T )
• It is easy to show that
h T T
• Thus, N S ( ( A ) ) = c (
has a solution if & only if 1/ 2, 1, 1, . . . , 1, 1/ 2)
h h h
A
• That is, u = f
h
f ⊥ c ( 1/2, 1, 1, . . . , 1, 1/2) T
1 h N 1 h
f 0 + ∑ f j + f N +1 = 0
h
2 j =1
2
U-Boulder 204 of 312
We have two issues to consider
x 02h 2h
xN 2h
xN
/4 /2
• Relaxation is performed at all points, including endpoints:
h
v jh − 1 + + v jh+ 1 + h 2 f j
2 h 2 h
1 ← v N + h on
v 0 ←add
h v 1 + ah global
h h h
• We f0 Gram-Schmidt
v jh ←
2step after
v N +relaxation f N +1
each level to enforce the zero-mean condition
v h, 1h
vh ← vh − 1h
1h, 1h
U-Boulder 208 of 312
Interpolation must include the
endpoints
• We use linear interpolation:
1
1/2 1/2
1
1/2 1/2
I 2hh = 1
1/2 1/2
1
1/2 1/2
1
U-Boulder 209 of 312
Restriction also treats the
endpoints
1 h T
• For restriction, we use I 2h = ( I 2h) , yielding the
h 2
values
2h 1 h 1 h
f 0 = f0 + f1
2 4
2h 1 h 1 h 1 h
f j = f 2j − 1 + f 2j + f 2j + 1
4 2 4
2h 1 h 1 h
f N +1 = f N + f N +1
4 2
− ux x − α uyy = f
discretized on a uniform grid with spacing h .
1
hx = h =
N
hy hx
hy =
α
U-Boulder hx 215 of 312
Both problems lead to the same
stencil
− u j − 1, k +2 u j , k − u j + 1, k − uj , k − 1 + 2 uj , k − uj , k + 1
+α
2
h h2
−α
h 1
A = − 1 2 + 2α − 1
2
h −α
− u j − 1, k +2 u j , k − u j + 1, k − uj , k − 1 + 2 uj , k − uj , k + 1
+
2 2
h h
α
U-Boulder 216 of 312
Why standard multigrid fails
−α
h 1
A = − 1 2 + 2α − 1
h2 −α
• Note that Ah has weak connections in the y-direction.
MG convergence factors degrade as α gets small, with
poor performance already at α = 0.1 .
• Consider the limiting case α ⇒ 0: 0
h 1
A ⇒ − 1 2 +22α − 1
2
• Collection of disconnected 1-D problems!h 0
• Point relaxation will smooth oscillatory errors in the
x-direction (strong connections), but with no
connections in the y-direction, the errors in that
direction will generally be random; point relaxation
provides no smoothing in the y-direction.
1 1
1 0.9 0.9
0.7 0.7
0.6
0.6 0.6
0.4
0.5 0.5
0.2
0.4 0.4
0 15
0 0.3 0.3
10 0 2 4 6 8 10 12 14 16 0 2 4 6 8 10 12 14 16
5
10
15
5
l i l
i
0 l
k
h
Ω Ω 2h
v 2h j , k = v 2h j , k + v j2,hk
v j2,hk + v j2h+ 1, k
v 2h j + 1, k = v 2h j + 1, k +
2
D − cI
− cI D − cI
Ah = − cI D − cI
⋅⋅ ⋅⋅
⋅ ⋅ − cI
where − cI D
&
2 + 2α − 1
α 1 − 1 2 + 2α − 1
c = D = ⋅⋅
h2 h2 ⋅
− 1 2 + 2α
U-Boulder 222 of 312
Line relaxation
• One sweep of line relaxation consists of solving a
tridiagonal system for each line of constant y.
h α
( gk ) j = f j , k +
h ( v jh, k − 1 + v jh, k + 1 )
2
h
• Because D is tridiagonal, the kth system can be solved
very efficiently.
0.8 0.8
0.8
0
0.2
0.2
-0.2
0
15 0
15
10
10 -0.2
5 -0.2
5
0 2 4 6 8 10 12 14 16
0 0
l
0 2 4 6 8 10 12 14 16
i i l
−α or −1
1 h 1
A1 h = − 1 2 + 2α − 1 A2 = − α 2 + 2α − α
2 2
h
h −α −1
−α
1
Ah = − 1 2 + 2α − 1
2
h −α
• Suppose so the exact
solution isfgiven
( x, y) by
= 2 ( y − y 2) + 2 α ( x − x 2)
u( x, y) = ( y − y 2) ( x − x 2)
• Observe that if α is small, the x-direction dominates,
while if α is large, the y-direction dominates
0.1
0.08
0.06
0.1 0.04
0.02
0.08
00
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0.06
Error along line of constant x
0.04
0.02
0.12
0 0.1
1 0.08
1
0.8 0.06
0.5 0.6 0.04
0.4
y 0 0
0.2
x
0.02
x =0
x0 xj − 1 xj xj + 1 xN
h j + 1/2 ≡ x j + 1 − x j j = 0, 1, ... , N − 1
h j + 1/2
x0 xj − 1 xj xj + 1 xN
’’ = (uj+1/2
uj-1/2 ’ - uj-1/2
’ )/hj
uj-1 ↓ uj ↓
uj+1
| |
hj-1/2 hj+1/2
hj = (hj-1/2 + hj+1/2)/2
u0h = uN
h = 0
where
h 2 h 2
=hαj βj = h
j − 1/ 2 ( hj − 1/ 2 + hj + 1/2 ) j + 1/2 ( hj − 1/2 + hj + 1/2 )
• Multiply by (hj-1/2 + hj+1/2)/2 yields an SPD matrix.
2h
xN
x 02h x 2h
j /2
• In [x0 , x2 ], linear means
h h
u( 0 ) = u( 1 ) = 0
where a(x) is a positive function on [0,1]
• We seek to develop a conservative, or self-adjoint,
method for discretizing this problem.
• Assume we have available to us the values of a(x)
at the midpoints of the grid
a j + 1/2 ≡ a( x j + 1/2 )
x 0h x jh− 1 x jh h
xN
x jh + 1
U-Boulder 240 of 312
We discretize using central differences
x 0h x jh − 1 h
x jh x jh + 1 xN
U-Boulder 241 of 312
We discretize using central differences
(cont’d)
Points used to
evaluate u’ at Points used to evaluate (au’ )’ at xj
x j + 1/2
x 0h x jh − 1 x jh h
xN
x jh + 1
U-Boulder 242 of 312
The basic stencil
u0 = uN = 0
• Variable mesh
1 h 1 1 h 1 h h
− uj −1 + ( + )uj + uj +1 = ηj f j
hj −1/ 2 h j −1/ 2 hj +1/ 2 h j +1/ 2
• Variable coefficients
1 h
( − aj − 1/2 uj − 1 + ( a j − 1/2 + aj + 1/2 ) uj − a j + 1/2 uj + 1 ) = h f j
h
• Correspondence
1 aj −1/ 2 1 aj +1/ 2
⇔ ⇔
hj −1/ 2 h h j +1/ 2 h
-(au’ )’ = f
-u’’ = f
• But simple averaging won’t accurately represent smooth
components if is close to but far from .
h
x 2j +1 x 2h j x 2h j + 2
x 2h j h
x 2j +1 x 2h j + 2
x j2h x j2h+ 1
U-Boulder 246 of 312
One remedy is to apply
operator interpolation
• Assume that relaxation does not change smooth
error, so the residual is approximately zero.
Applying at x h yields
2j + 1
− a 2h j + 1/2 e2h j + ( a 2h j + 1/2 + a 2h j + 3/2 ) e2h j + 1 − a 2h j + 3/2 e2h j + 2
2
=0
h
• Solving for :
h
e2j +1
v 2h j = v j2h
2h 2h h h 2h h T
A = I h A I 2h I h = c( I 2h )
U-Boulder 248 of 312
A variable coefficient example
• We use V(2,1) cycle, full weighting, linear interpolation.
• We use a(x) = 1 + ρ sin(kπx) & a(x) = 1 + ρ rand(kπx)
C-point selected
(point with
largest “value”)
Neighbors of
C-point
become F-
points
Next C-point
selected (after
updating “values”)
F-points
selected, etc.
U-Boulder 257 of 312
Examples: Laplacian operator
5-pt FD, 9-pt FE (quads), & 9-pt FE (stretched quads)
9-pt FE
(stretched quads)
−1 −1 − 1 −1
−1 4 −1 −1 8 −1
−1 −1 − 1 −1
−1 −4 −1
5-pt FD 9-pt FE (quads)
2 8 2
−1 −4 −1
U-Boulder 258 of 312
Prolongation is based on smooth
error, strong connections (from
M-matrices)
Smooth error is given by:
∑
C
F
F
ri = a i i ei + a i j ej ≈ 0
j ∈N i
i Prolongation :
C
C
ei , i∈C
( P e) =
i ∑ ωik ek , i∈F
F
k∈Ci
k4 ∈ Cj
k 3 ∈ Ci i j
k 2 ∈ Ci
U-Boulder k 2 ∈ Cj 264 of 312
Is there a fix?
A Gauss-Seidel-like iterative approach to weight
definition is implemented. Usually, two passes
suffice. But does it work? Yes, frequently:
convergence factors
2D Laplacian, N = 10,000,
stretched quadrilaterals θ standard iterative
0.25 0.47 0.14
∆ x = 10 ∆ y 0.5 0.24 0.14
0 .0 6 0 .0 5 5
0 .0 4
0 .0 2
0
0 500000 1000000
0 .3
0 .2 5 0 .2 5 3
0 .2 2 3
0 .2
0 .1 7 5
0 .1 5
0 .1 1 1
0 .1 0 .0 9 7
0 .0 5
0
0 20000 40000 60000
Convergence factor
0.3
0.2754
0.25
0.2198 0.2237
0.2
0.1888
0.1715
0.15
0.1 0.1002
0.05
0
0 50000 100000 150000 200000 250000 300000 350000
Gridpoints
v ← ( A 22 ) − 1 ( g − A 21 u )
adaptive interpolation
to determine sense of smoothness
+
adaptive C-point choice
to determine strength of connection
e j = ∑ a j k ek ⁄ ∑ a j k
*** smooth ≈ 1 *** k ∈Ci k ∈Ci
ej = ei
a i i ei ≈ − ∑ aij ej − ∑s aij ej − ∑waij ej
j ∈Ci j ∈Di j ∈Di
Strong C Strong F Weak pts.
j∈Ci j∈Ci
Relax on Ax = 0 !!!
U-Boulder 275 of 312
Adaptive C-point choice
• AMG uses the ansatz that residuals are 0 at F-points.
• What if we had rf = 0 exactly?
A ff A fc e f 0 e f −A−1
ff A fc
= ⇒ A ff e f + A fcec = 0 ⇒ = ec
Acf Acc ec rc ec I
−1
= Pec − P[P AP] [P AP]ec = 0.
T T
two-spike problem
0 1
y= f(x)
O
fine grid ( = interface)
coarse grid
• Adaptivity
• Error estimates
• Norms (proper scaling)
• Multiple dimensions
– Slave points
– More complicated stencils
• Data structures
• Parallel algorithms (AFAC)
• Time-space
FD methodology
FE methodology
method
method method
•
• • ••
• •
• •
U-Boulder 291 of 312
Localize
•
What choice
do you have?
•
• • ••
• •
• •
••• •• •••
a general piecewise linear
function can be represented by
uh = Σi uihε(hi)
•
• • ••
• •
• •
U-Boulder 295 of 312
Weak form!
−u"= f
⇒ − u"v = fv ∀v
⇒ ∫ (−u")vdx = ∫ fvdx ∀v
⇒ ∫ u'v' dx − u'v | = ∫ fvdx
1
0 ∀v
⇒ ∫ u'v' dx = ∫ fvdx ∀v ∋ v(0) = v(1) = 0
⇒ (u',v') = ( f ,v ) ∀v ∋ v(0) = v(1) = 0
↓ ↓
h
Σjuj ε(j)
h h
ε(i)
U-Boulder 296 of 312
FE basics
• Model problem Ω ⊂ ℜ2
Lu ≡ - uxx - uyy = f in Ω • Duality: Solving Lu = f is
u = 0 on ∂Ω equivalent to minimizing
the functional
• Sobolev spaces
F(u) = “(Lu, u)”/2 - (f, u)
L2(Ω) = {u : ∫Ωu2dΩ < ∞}
( ) = {u : u, ux , uy ε L2(Ω),
H01(Ω) ( ), u|∂Ω = 0} • Short story:
ux
∇u =
U-Boulder
uy 297 of 312
Long story
Using symmetry & linearity of L & bilinearity of the inner product:
F(u + v) = (L(u + v), u + v)/2 - (f, u + v)
= [(Lu, u) + 2(Lu, v) + (Lv, v)]/2
- (f, u) - (f, v)
= F(u) + (Lu, v) - (f, v) + (Lv, v)/2
= F(u) + (Lu - f, v) + (Lv, v)/2
•
•
• Note:
(∇u, ∇v) = ∫Ω(uxvx + uyvy)dΩ.
actually,
Bh fh
uh = (uijh) & fh = (h2f(xkl)) (mass matrix)
U-Boulder 303 of 312
The matrix equation
Ahuh = fh
where
uh = (uij) & fh = (h2f(xkl))
h
−1 −1 −1
1
Aij = −1 8 −1.
h
stiffness matrix
3
−1 −1 −1
U-Boulder 304 of 312
Some matrix properties
−1 −1 −1
1
Aij = −1 8 −1
h
3
−1 −1 −1
• Symmetric! ij “reaches” to i±1j±1 as i±1j±1 to ij.
• Singular? Ah 1 = 0 ?! Not next to boundaries!
3
• Positive definite! −1 −1
Diagonally dominant (strictly so @ boundaries).