# PCSetType
Builds PC for a particular preconditioner type 
## Synopsis
```
#include "petscpc.h" 
PetscErrorCode PCSetType(PC pc, PCType type)
```
Collective


## Input Parameters

- ***pc -*** the preconditioner context.
- ***type -*** a known method



## Options Database Key

- ***-pc_type <type> -*** Sets PC type


Use -help for a list of available methods (for instance,
jacobi or bjacobi)


## Notes
See "petsc/include/petscpc.h" for available methods (for instance,
PCJACOBI, PCILU, or PCBJACOBI).

Normally, it is best to use the KSPSetFromOptions() command and
then set the PC type from the options database rather than by using
this routine.  Using the options database provides the user with
maximum flexibility in evaluating the many different preconditioners.
The PCSetType() routine is provided for those situations where it
is necessary to set the preconditioner independently of the command
line or options database.  This might be the case, for example, when
the choice of preconditioner changes during the execution of the
program, and the user's application is taking responsibility for
choosing the appropriate preconditioner.  In other words, this
routine is not for beginners.



Developer Note: PCRegister() is used to add preconditioner types to PCList from which they
are accessed by PCSetType().


## See Also
 `KSPSetType()`, `PCType`, `PCRegister()`, `PCCreate()`, `KSPGetPC()`


## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/pc/interface/pcset.c.html#PCSetType">src/ksp/pc/interface/pcset.c</A>

## Examples
<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/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/ksp/tutorials/ex1.c.html">src/ksp/ksp/tutorials/ex1.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex100.c.html">src/ksp/ksp/tutorials/ex100.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex100f.F90.html">src/ksp/ksp/tutorials/ex100f.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex12.c.html">src/ksp/ksp/tutorials/ex12.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex13.c.html">src/ksp/ksp/tutorials/ex13.c.html</A><BR>


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


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