:orphan:
# PCKSPGetKSP
Gets the `KSP` context for a `PCKSP`.
## Synopsis
```
#include "petscksp.h"
PetscErrorCode PCKSPGetKSP(PC pc, KSP *ksp)
```
Not Collective but ksp returned is parallel if pc was parallel
## Input Parameter
- ***pc -*** the preconditioner context
## Output Parameter
- ***ksp -*** the `KSP` solver
## Note
If the `PC` is not a `PCKSP` object it raises an error
## See Also
`PCKSP`, `PCKSPSetKSP()`
## Level
advanced
## Location
src/ksp/pc/impls/ksp/pcksp.c
## Examples
src/ksp/ksp/tutorials/ex71.c
## Implementations
PCKSPGetKSP_KSP in src/ksp/pc/impls/ksp/pcksp.c
---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/ksp/pc/impls/ksp/pcksp.c)
[Index of all PC routines](index.md)
[Table of Contents for all manual pages](/manualpages/index.md)
[Index of all manual pages](/manualpages/singleindex.md)