PCSetOperators#

Sets the matrix associated with the linear system and a (possibly) different one from which the preconditioner will be constructed.

Synopsis#

#include "petscksp.h" 
PetscErrorCode PCSetOperators(PC pc, Mat Amat, Mat Pmat)

Logically Collective

Input Parameters#

  • pc - the PC preconditioner context

  • Amat - the matrix that defines the linear system

  • Pmat - the matrix to be used in constructing the preconditioner, usually the same as Amat.

Notes#

Using this routine directly is rarely needed, the preferred, and equivalent, usage is KSPSetOperators().

Passing a NULL for Amat or Pmat removes the matrix that is currently used.

If you wish to replace either Amat or Pmat but leave the other one untouched then first call KSPGetOperators() to get the one you wish to keep, call PetscObjectReference() on it and then pass it back in in your call to KSPSetOperators().

More Notes about Repeated Solution of Linear Systems#

PETSc does NOT reset the matrix entries of either Amat or Pmat to zero after a linear solve; the user is completely responsible for matrix assembly. See the routine MatZeroEntries() if desiring to zero all elements of a matrix.

See Also#

KSP: Linear System Solvers, PC, PCGetOperators(), MatZeroEntries()

Level#

advanced

Location#

src/ksp/pc/interface/precon.c

Examples#

src/ksp/pc/tutorials/ex4.c


Index of all PC routines
Table of Contents for all manual pages
Index of all manual pages