:orphan: # SNESSetKSP Sets a `KSP` context for the `SNES` object to use ## Synopsis ``` #include "petscsnes.h" PetscErrorCode SNESSetKSP(SNES snes, KSP ksp) ``` Not Collective, but the `SNES` and `KSP` objects must live on the same MPI_Comm ## Input Parameters - ***snes -*** the `SNES` context - ***ksp -*** the `KSP` context ## Notes The `SNES` object already has its `KSP` object, you can obtain with `SNESGetKSP()` so this routine is rarely needed. The `KSP` object that is already in the `SNES` object has its reference count decreased by one. ## See Also [](ch_snes), `SNES`, `KSP`, `KSPGetPC()`, `SNESCreate()`, `KSPCreate()`, `SNESSetKSP()` ## Level developer ## Location src/snes/interface/snes.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)