Project: Fast Solvers for Stokes Equations
The purpose of this project is to implement fast solvers for solving finite element and finite difference discretization of Stokes equations.
Part I: Block Preconditioner
Given a triangulation, use codes in Project: Finite Element Methods for Stokes Equation to generate matrices for isoP2-P0 and P1CR-P0 for Stokes equations.
Step 1: Direct solvers in preconditioner
Use $\begin{pmatrix} A^{-1} & 0\ 0 & Mp^{-1}\end{pmatrix}$ as the preconditioner and call minres
.
Do not use inv(A)
to form the inverse. Instead the preconditioner can be coded as a subroutine and use backslash to invert A
.
For isoP2-P0 and P1CR-P0, the mass matrix for pressure is a diagonal matrix. The inverse of Mp can be realized by a vector multiplication.
Refine the triangulation several times and list the iteration steps of
minres
and cpu time. The steps should be uniform but the time may not be
linearly scaled due to the direct solver used in the preconditioner. Use
showrate
to check the scaling of cpu time vs size of problems.
Step 2: Replace direct solver by multigrid solver
The direct solver of A
can be replaced by multigrid solvers included in
ifem. Try help mg
or help amg
.
To use mg
, the mesh structure elem
should be provided. So you need to
modify the matrices to build in the Dirichlet boundary condition. If you
only take out submatrices associated to free dofs, you can use amg
.
Redo the test in step 1. You should get the same iteration steps and now the cpu time scales linearly.
Step 3: Replace exact multigrid solver by V-cycles
Set option.maxIt = 3
and redo the test. The iteration steps could
increase but cpu time is saved instead. How about option.maxIt = 1
?
Part II: Block-triangular Preconditoner
Use $\begin{pmatrix}A & B’\ 0 & -Mp \end{pmatrix}^{-1}$ as the preconditioner and call gmres
.
Repeat three steps in Part I and compare the cpu time for these two preconditioners.
Comments