petsc-3.12.4 2020-02-04
Report Typos and Errors

# PCKSP

Defines a preconditioner that can consist of any KSP solver. This allows, for example, embedding a Krylov method inside a preconditioner.

### Options Database Key

-pc_use_amat -use the matrix that defines the linear system, Amat as the matrix for the inner solver, otherwise by default it uses the matrix used to construct the preconditioner, Pmat (see PCSetOperators())

### Notes

Using a Krylov method inside another Krylov method can be dangerous (you get divergence or the incorrect answer) unless you use KSPFGMRES as the other Krylov method

### Developer Notes

If the outer Krylov method has a nonzero initial guess it will compute a new residual based on that initial guess and pass that as the right hand side into this KSP (and hence this KSP will always have a zero initial guess). For all outer Krylov methods except Richardson this is neccessary since Krylov methods, even the flexible ones, need to "see" the result of the action of the preconditioner on the input (current residual) vector, the action of the preconditioner cannot depend also on some other vector (the "initial guess"). For KSPRICHARDSON it is possible to provide a PCApplyRichardson_PCKSP() that short circuits returning to the KSP object at each iteration to compute the residual, see for example PCApplyRichardson_SOR(). We do not implement a PCApplyRichardson_PCKSP() because (1) using a KSP directly inside a Richardson is not an efficient algorithm anyways and (2) implementing it for its > 1 would essentially require that we implement Richardson (reimplementing the Richardson code) inside the PCApplyRichardson_PCKSP() leading to duplicate code.

### See Also

PCCreate(), PCSetType(), PCType (for list of available types), PC,
PCSHELL, PCCOMPOSITE, PCSetUseAmat(), PCKSPGetKSP()

### Level

intermediate

### Location

src/ksp/pc/impls/ksp/pcksp.c

### Examples

src/ksp/ksp/examples/tutorials/ex71.c.html
Index of all PC routines
Table of Contents for all manual pages
Index of all manual pages