petsc-3.7.1 2016-05-15
Report Typos and Errors

# KSPSetType

Builds KSP for a particular solver.

### Synopsis

    #include "petscksp.h"
    PetscErrorCode  KSPSetType(KSP ksp, KSPType type)

Logically Collective on KSP Many br

### Input Parameters

| ksp | - the Krylov space context Many br
| type | - a known method Many br

### Options Database Key

-ksp_type <method> -Sets the method; use -help for a list Many brof available methods (for instance, cg or gmres) Many br

### Notes

See "petsc/include/petscksp.h" for available methods (for instance, Many brKSPCG or KSPGMRES). Many br

Normally, it is best to use the KSPSetFromOptions() command and Many brthen set the KSP type from the options database rather than by using Many brthis routine. Using the options database provides the user with Many brmaximum flexibility in evaluating the many different Krylov methods. Many brThe KSPSetType() routine is provided for those situations where it Many bris necessary to set the iterative solver independently of the command Many brline or options database. This might be the case, for example, when Many brthe choice of iterative solver changes during the execution of the Many brprogram, and the user's application is taking responsibility for Many brchoosing the appropriate method. In other words, this routine is Many brnot for beginners. Many br

Many br

Developer Note: KSPRegister() is used to add Krylov types to KSPList from which they Many brare accessed by KSPSetType(). Many br

### Keywords

KSP, set, method

### See Also

PCSetType(), KSPType, KSPRegister(), KSPCreate()

Level:intermediate
Location:src/ksp/ksp/interface/itcreate.c
Index of all KSP routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/ksp/pc/examples/tutorials/ex1.c.html
src/ksp/pc/examples/tutorials/ex2.c.html
src/ksp/ksp/examples/tutorials/ex7.c.html
src/ksp/ksp/examples/tutorials/ex8.c.html
src/ksp/ksp/examples/tutorials/ex30.c.html
src/ksp/ksp/examples/tutorials/ex52.c.html
src/ksp/ksp/examples/tutorials/ex62.c.html
src/ksp/ksp/examples/tutorials/ex52f.F.html
src/tao/constrained/examples/tutorials/maros.c.html
src/tao/constrained/examples/tutorials/toy.c.html
src/tao/constrained/examples/tutorials/toyf.F.html