Lecture 21
MA471 Fall 03
Recall Jacobi Smoothing
• We recall that the relaxed Jacobi scheme:
• Smooths out the highest frequency modes fastest
1 11m m m x x f D A D x
Two Grid Algorithm
• First we smooth the solution for a number of steps:
1
1
for 1:
1
end
m
i
x x f D A D x
Next We Apply a Coarse Grid Correction
• Now suppose the current approximation xk satisfies the Ax=b system approximately:
• For some r
• We can figure out how much xk needs to be corrected by:
k r b Ax
1
1
k
k
r AA r b Ax
A x A r b
cont
• So in an ideal world we could compute:
• And we would be done, as x solves Ax=b
• However, we noted before that the relaxed Jacobi solver does a good job of reducing the error in high-frequency modes so we can assume that the correction is a low frequency correction, so let’s compute the correction in * on a coarse grid.
1k x x A r*
1kc x x P A Rr
Restriction Step (Rr)
• The first step is to compute the residual r on the fine mesh and transfer it to the coarse mesh:
Periodic length
Fine
Coarse
The arrows indicate which fine nodes are linearly combined to obtain the coarse version
Formula For Restriction
2 1 2 2 1
12
4cn n n n r r r r
This is the restriction operator corresponding to the above formula for8 fine nodes and 4 coarse nodes:
We use a weighted average of the residual on the fine grid:
The Coarse System Ac
• There is a certain freedom in how to build the coarse approximation to the system.
• A simple approach is to set up a matrix for the discrete heat equation, but using the coarse nodes.
Prolongation
• After having computed the correction on the coarse grid we need to transfer it to the fine grid.
• In this case we will preserve the correction values at nodes which belong to both coarse and fine grid.
• For other nodes we will use averaging.
Fine
Coarse
Formula For Prolongation of a Vector v
2 1
2 1
1
2
cn n
c cn n n
v v
v v v
Prolongation operator mapping a vector of 4 coarsevalues to 8 fine values.
Comparison of Prolongation and Restriction Matrices
Note R = 0.5*transpose(P)
Summary of Two-Grid Scheme
• Smooth a few times on the fine grid (using relaxed Jacobi iterations).
• Restrict the r=b-Ax residual to the coarse grid (Rr)
• Solve the coarse grid problem• Prolongate this correction to the fine grid ( )• Update the solution• Smooth a few more times to remove high-
frequency errors from prolongation and restriction
1c c A Rr
c x x PδcPδ
Summary:of a single stage of the two
grid iterative
algorithm
1
1
2
1
for 1:
1
end
for 1:
1
end
c
c
i
i
c
1c c
x x D b A D x
r b Ax
r Rr
δ A r
x x Pδ
x x D b A D x
1
1
2
1
for 1:
1
end
for 1:
1
end
c
c
i
i
c
1c c
x x D b A D x
r b Ax
r Rr
δ A r
x x Pδ
x x D b A D x
1) Presmoothing:
2) Fine grid residual
3) Fine to coarse gridrestriction
4) Solving the coarsegrid analog
5) Prolongation andcoarse grid correction
6) Post smoothing:
Example: 1D Heat Equation
• I wrote a simple matlab code which solves the 1D equation (see previous lectures):
• On the unit interval [0,1) with periodicity.
2
2
dY f x
dx
Heatmatrix1d Routine
Set up fine grid system
• Set up coarse grid system
• Set up sparse restriction and prolongation matrices
80-82) presmooth
85) Coarse grid residual
88) Restriction and coarse gridcorrection solve
91) Prolongation and adding coarse grid correction to finegrid solution
94-96) post smoothing
98) Compute residual
Worst Possible Case
• So to see if the multigrid is working as advertised I set b=sin(2*pi*x) with initial guess x=0
• i.e. I activated one of the lowest frequency error modes.
• I ran relaxed Jacobi – which applies very little damping to the lowest error mode.
• I then ran the two-grid solver…
Comparison of Relaxed Jacobi and the Two Grid Solver
Two-grid: N=2560015 iterations and 2.694 seconds to achieve 10 decimal place convergence.
Relaxed Jacobi: N=25600590 iterations and 89.5680 seconds to achieve 10 decimal place convergence.
Summary
• By design the two-grid solver does indeed increase the decay rate for the lower frequency error modes.
• The results seem great for the two-grid solver – however, in this case we used an exact solve for the coarse grid problem. In reality this would normally be very expensive (although much less expensive than solving the full problem).
• In a multigrid solver we would replace the coarse grid solve with recursively applied smoothing on a sequence of successively coarser grids and apply the coarse grid correction on an extremely coarse grid.
Next Time
• Spectral methods for solving simple PDE’s
• Description of final project options.