# KSPHPDDMSetType
Sets the type of Krylov method used in `KSPHPDDM`. 
## Synopsis
```
#include "petscksp.h" 
PetscErrorCode KSPHPDDMSetType(KSP ksp, KSPHPDDMType type)
```
Collective


## Input Parameters

- ***ksp -*** iterative context
- ***type -*** any of gmres, bgmres, cg, bcg, gcrodr, bgcrodr, bfbcg, or preonly





## Notes
Unlike `KSPReset()`, this function does not destroy any deflation space attached to the `KSP`.


## As an example, in the following sequence
```none
     KSPHPDDMSetType(ksp, KSPGCRODR);
     KSPSolve(ksp, b, x);
     KSPHPDDMSetType(ksp, KSPGMRES);
     KSPHPDDMSetType(ksp, KSPGCRODR);
     KSPSolve(ksp, b, x);
```

the recycled space is reused in the second `KSPSolve()`.


## See Also
 [](chapter_ksp), `KSPCreate()`, `KSPType`, `KSPHPDDMType`, `KSPHPDDMGetType()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/hpddm/hpddm.cxx.html#KSPHPDDMSetType">src/ksp/ksp/impls/hpddm/hpddm.cxx</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex78.c.html">src/ksp/ksp/tutorials/ex78.c.html</A><BR>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/hpddm/hpddm.cxx.html#KSPHPDDMSetType_HPDDM">KSPHPDDMSetType_HPDDM in src/ksp/ksp/impls/hpddm/hpddm.cxx</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/ksp/ksp/impls/hpddm/hpddm.cxx)


[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)  
