Linear Solution of Equations
See the KSP, and PC manual pages as well as the detailed discussion of the Linear Solvers in the PETSc users manual for details.
Additional KSP example programs are available at ${PETSC_DIR}/src/ksp/examples/tutorials
Get the code ${PETSC_DIR}/src/ksp/examples/tutorials/ex23.c
Objective: To demonstrate basic linear solver use
Runtime command:
% mpiexec -np 2 ex23 -ksp_monitor
where
-ksp_monitor : print residual norm at each iteration
Comments:
Note that the program calls KSPView(), which displays
information about the particular solvers used at runtime.
Objective: To demonstrate setting different preconditioners and
Krylov methods at runtime.
Runtime command:
% mpiexec -np 2 ex23 -ksp_monitor -pc_type asm -ksp_type tfqmr -optionsleft
where
-ksp_type tfqmr : set Krylov method to transpose-free QMR
-pc_type asm : set preconditioner to additive Schwarz
Comments:
Use the -help option for a complete list of solver options.
Objective: To produce a summary of program performance.
Runtime command:
% mpiexec -np 4 ex23 -n 1259 -log_summary
where
-n <dimension> : set the problem dimension
Comments:
The performance summary output is wide, so use an xterm with
120 columns; either resize one or use "xterm -geometry 120x24".
See the chapter "Hints for Performance Tuning" in the PETSc users
manual for help in interpreting this output.
Try using additional solver options as well, and note the
effects on performance. For example,
-ksp_rtol 1.e-10 : set convergence tolerance