:orphan:
# SNESGetKSP
Returns the `KSP` context for a `SNES` solver.
## Synopsis
```
#include "petscsnes.h"
PetscErrorCode SNESGetKSP(SNES snes, KSP *ksp)
```
Not Collective, but if snes is parallel, then ksp is parallel
## Input Parameter
- ***snes -*** the `SNES` context
## Output Parameter
- ***ksp -*** the `KSP` context
## Notes
The user can then directly manipulate the `KSP` context to set various
options, etc. Likewise, the user can then extract and manipulate the
`PC` contexts as well.
Some `SNESType`s do not use a `KSP` but a `KSP` is still returned by this function
## See Also
[](ch_snes), `SNES`, `KSP`, `PC`, `KSPGetPC()`, `SNESCreate()`, `KSPCreate()`, `SNESSetKSP()`
## Level
beginner
## Location
src/snes/interface/snes.c
## Examples
src/snes/tutorials/ex1.c
src/snes/tutorials/ex12.c
src/snes/tutorials/ex1f.F90
src/snes/tutorials/ex28.c
src/snes/tutorials/ex3.c
src/snes/tutorials/ex30.c
src/snes/tutorials/ex31.c
src/snes/tutorials/ex5.c
src/snes/tutorials/ex55.c
src/snes/tutorials/ex56.c
src/snes/tutorials/ex6.c
---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/snes/interface/snes.c)
[Index of all SNES routines](index.md)
[Table of Contents for all manual pages](/manualpages/index.md)
[Index of all manual pages](/manualpages/singleindex.md)