# KSPCreate
Creates the `KSP` context. 
## Synopsis
```
#include "petscksp.h" 
PetscErrorCode KSPCreate(MPI_Comm comm, KSP *inksp)
```
Collective


## Input Parameter

- ***comm -*** MPI communicator



## Output Parameter

- ***ksp -*** location to put the `KSP` context



## Note
The default `KSPType` is `KSPGMRES` with a restart of 30, using modified Gram-Schmidt orthogonalization.




## See Also
 [](chapter_ksp), `KSPSetUp()`, `KSPSolve()`, `KSPDestroy()`, `KSP`, `KSPGMRES`, `KSPType`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/interface/itcreate.c.html#KSPCreate">src/ksp/ksp/interface/itcreate.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/swarm/tutorials/ex1.c.html">src/dm/impls/swarm/tutorials/ex1.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/swarm/tutorials/ex1f90.F90.html">src/dm/impls/swarm/tutorials/ex1f90.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/stag/tutorials/ex1.c.html">src/dm/impls/stag/tutorials/ex1.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/stag/tutorials/ex2.c.html">src/dm/impls/stag/tutorials/ex2.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/stag/tutorials/ex3.c.html">src/dm/impls/stag/tutorials/ex3.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/stag/tutorials/ex4.c.html">src/dm/impls/stag/tutorials/ex4.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/stag/tutorials/ex8.c.html">src/dm/impls/stag/tutorials/ex8.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/pc/tutorials/ex1.c.html">src/ksp/pc/tutorials/ex1.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/pc/tutorials/ex2.c.html">src/ksp/pc/tutorials/ex2.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/pc/tutorials/ex3.c.html">src/ksp/pc/tutorials/ex3.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/bench_pcsetup.c.html">src/ksp/ksp/tutorials/bench_pcsetup.c.html</A><BR>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/bcgs/bcgs.c.html#KSPCreate_BCGS">KSPCreate_BCGS in src/ksp/ksp/impls/bcgs/bcgs.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/bcgs/fbcgs/fbcgs.c.html#KSPCreate_FBCGS">KSPCreate_FBCGS in src/ksp/ksp/impls/bcgs/fbcgs/fbcgs.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/bcgs/fbcgsr/fbcgsr.c.html#KSPCreate_FBCGSR">KSPCreate_FBCGSR in src/ksp/ksp/impls/bcgs/fbcgsr/fbcgsr.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/bcgs/pipebcgs/pipebcgs.c.html#KSPCreate_PIPEBCGS">KSPCreate_PIPEBCGS in src/ksp/ksp/impls/bcgs/pipebcgs/pipebcgs.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/bcgs/qmrcgs/qmrcgs.c.html#KSPCreate_QMRCGS">KSPCreate_QMRCGS in src/ksp/ksp/impls/bcgs/qmrcgs/qmrcgs.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/bcgsl/bcgsl.c.html#KSPCreate_BCGSL">KSPCreate_BCGSL in src/ksp/ksp/impls/bcgsl/bcgsl.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/bicg/bicg.c.html#KSPCreate_BiCG">KSPCreate_BiCG in src/ksp/ksp/impls/bicg/bicg.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/cg/cg.c.html#KSPCreate_CG">KSPCreate_CG in src/ksp/ksp/impls/cg/cg.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/cg/cgls.c.html#KSPCreate_CGLS">KSPCreate_CGLS in src/ksp/ksp/impls/cg/cgls.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/cg/cgne/cgne.c.html#KSPCreate_CGNE">KSPCreate_CGNE in src/ksp/ksp/impls/cg/cgne/cgne.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/cg/gltr/gltr.c.html#KSPCreate_GLTR">KSPCreate_GLTR in src/ksp/ksp/impls/cg/gltr/gltr.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/cg/groppcg/groppcg.c.html#KSPCreate_GROPPCG">KSPCreate_GROPPCG in src/ksp/ksp/impls/cg/groppcg/groppcg.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/cg/nash/nash.c.html#KSPCreate_NASH">KSPCreate_NASH in src/ksp/ksp/impls/cg/nash/nash.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/cg/pipecg/pipecg.c.html#KSPCreate_PIPECG">KSPCreate_PIPECG in src/ksp/ksp/impls/cg/pipecg/pipecg.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/cg/pipecg2/pipecg2.c.html#KSPCreate_PIPECG2">KSPCreate_PIPECG2 in src/ksp/ksp/impls/cg/pipecg2/pipecg2.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/cg/pipecgrr/pipecgrr.c.html#KSPCreate_PIPECGRR">KSPCreate_PIPECGRR in src/ksp/ksp/impls/cg/pipecgrr/pipecgrr.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/cg/pipelcg/pipelcg.c.html#KSPCreate_PIPELCG">KSPCreate_PIPELCG in src/ksp/ksp/impls/cg/pipelcg/pipelcg.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/cg/pipeprcg/pipeprcg.c.html#KSPCreate_PIPEPRCG">KSPCreate_PIPEPRCG in src/ksp/ksp/impls/cg/pipeprcg/pipeprcg.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/cg/stcg/stcg.c.html#KSPCreate_STCG">KSPCreate_STCG in src/ksp/ksp/impls/cg/stcg/stcg.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/cgs/cgs.c.html#KSPCreate_CGS">KSPCreate_CGS in src/ksp/ksp/impls/cgs/cgs.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/cheby/cheby.c.html#KSPCreate_Chebyshev">KSPCreate_Chebyshev in src/ksp/ksp/impls/cheby/cheby.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/cr/cr.c.html#KSPCreate_CR">KSPCreate_CR in src/ksp/ksp/impls/cr/cr.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/cr/pipecr/pipecr.c.html#KSPCreate_PIPECR">KSPCreate_PIPECR in src/ksp/ksp/impls/cr/pipecr/pipecr.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/fcg/fcg.c.html#KSPCreate_FCG">KSPCreate_FCG in src/ksp/ksp/impls/fcg/fcg.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/fcg/pipefcg/pipefcg.c.html#KSPCreate_PIPEFCG">KSPCreate_PIPEFCG in src/ksp/ksp/impls/fcg/pipefcg/pipefcg.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/fetidp/fetidp.c.html#KSPCreate_FETIDP">KSPCreate_FETIDP in src/ksp/ksp/impls/fetidp/fetidp.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/gcr/gcr.c.html#KSPCreate_GCR">KSPCreate_GCR in src/ksp/ksp/impls/gcr/gcr.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/gcr/pipegcr/pipegcr.c.html#KSPCreate_PIPEGCR">KSPCreate_PIPEGCR in src/ksp/ksp/impls/gcr/pipegcr/pipegcr.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/gmres/agmres/agmres.c.html#KSPCreate_AGMRES">KSPCreate_AGMRES in src/ksp/ksp/impls/gmres/agmres/agmres.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/gmres/dgmres/dgmres.c.html#KSPCreate_DGMRES">KSPCreate_DGMRES in src/ksp/ksp/impls/gmres/dgmres/dgmres.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/gmres/fgmres/fgmres.c.html#KSPCreate_FGMRES">KSPCreate_FGMRES in src/ksp/ksp/impls/gmres/fgmres/fgmres.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/gmres/gmres.c.html#KSPCreate_GMRES">KSPCreate_GMRES in src/ksp/ksp/impls/gmres/gmres.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/gmres/lgmres/lgmres.c.html#KSPCreate_LGMRES">KSPCreate_LGMRES in src/ksp/ksp/impls/gmres/lgmres/lgmres.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/gmres/pgmres/pgmres.c.html#KSPCreate_PGMRES">KSPCreate_PGMRES in src/ksp/ksp/impls/gmres/pgmres/pgmres.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/gmres/pipefgmres/pipefgmres.c.html#KSPCreate_PIPEFGMRES">KSPCreate_PIPEFGMRES in src/ksp/ksp/impls/gmres/pipefgmres/pipefgmres.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/hpddm/hpddm.cxx.html#KSPCreate_HPDDM">KSPCreate_HPDDM in src/ksp/ksp/impls/hpddm/hpddm.cxx</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/ibcgs/ibcgs.c.html#KSPCreate_IBCGS">KSPCreate_IBCGS in src/ksp/ksp/impls/ibcgs/ibcgs.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/lcd/lcd.c.html#KSPCreate_LCD">KSPCreate_LCD in src/ksp/ksp/impls/lcd/lcd.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/lsqr/lsqr.c.html#KSPCreate_LSQR">KSPCreate_LSQR in src/ksp/ksp/impls/lsqr/lsqr.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/minres/minres.c.html#KSPCreate_MINRES">KSPCreate_MINRES in src/ksp/ksp/impls/minres/minres.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/preonly/preonly.c.html#KSPCreate_PREONLY">KSPCreate_PREONLY in src/ksp/ksp/impls/preonly/preonly.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/qcg/qcg.c.html#KSPCreate_QCG">KSPCreate_QCG in src/ksp/ksp/impls/qcg/qcg.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/rich/rich.c.html#KSPCreate_Richardson">KSPCreate_Richardson in src/ksp/ksp/impls/rich/rich.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/symmlq/symmlq.c.html#KSPCreate_SYMMLQ">KSPCreate_SYMMLQ in src/ksp/ksp/impls/symmlq/symmlq.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/tcqmr/tcqmr.c.html#KSPCreate_TCQMR">KSPCreate_TCQMR in src/ksp/ksp/impls/tcqmr/tcqmr.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/tfqmr/tfqmr.c.html#KSPCreate_TFQMR">KSPCreate_TFQMR in src/ksp/ksp/impls/tfqmr/tfqmr.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/tsirm/tsirm.c.html#KSPCreate_TSIRM">KSPCreate_TSIRM in src/ksp/ksp/impls/tsirm/tsirm.c</A><BR>


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


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