KSPGetOperators#

Gets the matrix associated with the linear system and a (possibly) different one used to construct the preconditioner from the KSP context

Synopsis#

#include "petscksp.h" 
PetscErrorCode KSPGetOperators(KSP ksp, Mat *Amat, Mat *Pmat)

Collective

Input Parameter#

  • ksp - the KSP context

Output Parameters#

  • Amat - the matrix that defines the linear system

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

Notes#

If KSPSetOperators() has not been called then the KSP object will attempt to automatically create the matrix Amat and return it

Use KSPGetOperatorsSet() to determine if matrices have been provided. After KSPSolveTranspose() or KSPMatSolveTranspose() with explicit transposition enabled by KSPSetUseExplicitTranspose(), this function returns the explicitly transposed operators until a non-transpose solve restores their parent operators. These explicitly transposed operators are owned by the KSP and may be destroyed by KSPSetUseExplicitTranspose(ksp, PETSC_FALSE), by KSPReset(), or by a non-transpose solve after KSPSetOperators() changes the operators.

DOES NOT increase the reference counts of the matrix, so you should NOT destroy them.

See Also#

KSP: Linear System Solvers, KSP, KSPSolve(), KSPGetPC(), PCSetOperators(), KSPSetOperators(), KSPGetOperatorsSet(), KSPSetUseExplicitTranspose()

Level#

intermediate

Location#

src/ksp/ksp/interface/itcreate.c

Examples#

src/ksp/ksp/tutorials/ex42.c
src/ksp/ksp/tutorials/ex34.c
src/ksp/ksp/tutorials/ex27.c
src/ksp/ksp/tutorials/ex56.c
src/ksp/ksp/tutorials/ex59.c
src/ksp/ksp/tutorials/ex45.c
src/ksp/ksp/tutorials/ex25.c


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