# TSGetKSP
Returns the `KSP` (linear solver) associated with a `TS` (timestepper) context. 
## Synopsis
```
#include "petscts.h"  
PetscErrorCode TSGetKSP(TS ts, KSP *ksp)
```
Not Collective, but ksp is parallel if ts is parallel


## Input Parameter

- ***ts -*** the `TS` context obtained from `TSCreate()`



## Output Parameter

- ***ksp -*** the nonlinear solver 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` context as well.

`TSGetKSP()` does not work for integrators that do not use `KSP`;
in this case `TSGetKSP()` returns NULL in ksp.


## See Also
 [](chapter_ts), `TS`, `SNES`, `KSP`, `TSCreate()`, `TSSetUp()`, `TSSolve()`, `TSGetSNES()`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/interface/ts.c.html#TSGetKSP">src/ts/interface/ts.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/ts/interface/ts.c)


[Index of all TS routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
