Questions |Objectives |Key Points
--------------------------|-------------------------------|-------------------------------------
Does the preconditioner | See that the preconditioner | Through a single interface,
affect the convergence | can be crucial for | PETSc supports runtime choices
rate of Krylov solvers? | convergence. | of algorithms and options.
| |
How can I choose algs. | Learn the basics of using | Experimenting with
and options at runtime | PETSc solvers & understanding | algorithms is essential
when using PETSc? | output. | for good performance.
Before running the examples, you must switch to the bash shell by using
bash
This code uses MFEM and PETSc/TAO to demonstrate the convergence of Krylov methods.
The source code is included in ex2p.c
Notes: Normally PETSc options can be passed as command line arguments. But because MFEM turns off this capability, PETSc options must be passed either in a file or in the PETSC_OPTIONS environmental variable. See the file rc_ex2p for the PETSc options that are supplied to the application in these examples.
PETSC_OPTIONS="-pc_type jacobi -ksp_max_it 25" ./ex2p -petscopts rc_ex2p --mesh /projects/ATPESC2017/NumericalPackages/handson/mfem/data/beam-tri.mesh
The first column of the output is the residual norm. The next two are the maximum and minimum estimated eigenvalues of the operator and the final column is the condition number.
Is the iteration converging?
Read the output at the bottom from -ksp_view ... What Krylov method and preconditioner are being used?
./ex2p -petscopts rc_ex2p --mesh /projects/ATPESC2017/NumericalPackages/handson/mfem/data/beam-tri.mesh
Is the iteration now converging?
Read the output at the bottom from -ksp_view ... What Krylov method and preconditioner are being used?
PETSC_OPTIONS="-ksp_norm_type preconditioned -ksp_type richardson -ksp_max_it 25" ./ex2p -petscopts rc_ex2p --mesh /projects/ATPESC2017/NumericalPackages/handson/mfem/data/beam-tri.mesh
Is the iteration now converging?
PETSC_OPTIONS="-ksp_norm_type preconditioned -ksp_type gmres -ksp_gmres_restart 10" ./ex2p -petscopts rc_ex2p --mesh /projects/ATPESC2017/NumericalPackages/handson/mfem/data/beam-tri.mesh
Now run with a gmres restart of 30
PETSC_OPTIONS="-ksp_norm_type preconditioned -ksp_type gmres -ksp_gmres_restart 30" ./ex2p -petscopts rc_ex2p --mesh /projects/ATPESC2017/NumericalPackages/handson/mfem/data/beam-tri.mesh
Note the convergence is now very similar to that with CG.
Now attempt to run this in parallel and obtain solver performance data
PETSC_OPTIONS="-log_view -ksp_norm_type preconditioned -ksp_type gmres -ksp_gmres_restart 30" ${MPIEXEC_OMPI} -n 4 ./ex2p -petscopts rc_ex2p --mesh /projects/ATPESC2017/NumericalPackages/handson/mfem/data/beam-tri.mesh
PETSC_OPTS="-snes_rtol 1.e-10 -snes_view -pc_type bjacobi -sub_pc_type ilu " ${MPIEXEC_OMPI} -n 4 ./ex10p -m ../../data/beam-quad.mesh --petscopts rc_ex10p -s 3 -rs 2 -dt 3 | more
Note the quadratic convergence; the residual norm exponent doubles until it runs out of digits to double.
We have used PETSc to demonstrate the use of preconditioned Krylov methods. Many examples are available for various aspects of PETSc functionality, including