KSPSetPC — PETSc 3.23.0 documentation

Skip to main content
`Ctrl`+`K`

# KSPSetPC

Sets the preconditioner to be used to calculate the application of the preconditioner on a vector into a `KSP`.

## Synopsis

    #include "petscksp.h"
    #include "petscmat.h"
    PetscErrorCode KSPSetPC(KSP ksp, PC pc)

Collective

## Input Parameters

- ksp - the `KSP` iterative solver obtained from `KSPCreate()`

- pc - the preconditioner object (if `NULL` it returns the `PC` currently held by the `KSP`)

## Note

This routine is almost never used since `KSP` creates its own `PC` when needed. Use `KSPGetPC()` to retrieve the preconditioner context instead of creating a new one.

## See Also

KSP: Linear System Solvers, `KSPGetPC()`, `KSP`

## Level

developer

## Location

src/ksp/ksp/interface/itfunc.c

## Examples

src/ksp/ksp/tutorials/ex59.c

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