:orphan:
# PCRegister
Adds a method to the preconditioner package.
## Synopsis
```
#include "petscksp.h"
PetscErrorCode PCRegister(const char sname[], PetscErrorCode (*function)(PC))
```
Not collective
## Input Parameters
- ***sname -*** name of a new user-defined solver
- ***function -*** routine to create method context
## Sample usage
```none
PCRegister("my_solver", MySolverCreate);
```
Then, your solver can be chosen with the procedural interface via
```none
PCSetType(pc, "my_solver")
```
or at runtime via the option
```none
-pc_type my_solver
```
## Note
`PCRegister()` may be called multiple times to add several user-defined preconditioners.
## See Also
`PC`, `PCType`, `PCRegisterAll()`
## Level
advanced
## Location
src/ksp/pc/interface/precon.c
## Examples
src/ksp/ksp/tutorials/ex12.c
---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/ksp/pc/interface/precon.c)
[Index of all PC routines](index.md)
[Table of Contents for all manual pages](/manualpages/index.md)
[Index of all manual pages](/manualpages/singleindex.md)