Skip to main content
`Ctrl`+`K`

# PCRegister

Adds a method (`PCType`) to the PETSc preconditioner package.

## Synopsis

    #include "petscksp.h"
    PetscErrorCode PCRegister(const char sname[], PetscErrorCode (*function)(PC))

Not collective. No Fortran Support

## Input Parameters

- sname - name of a new user-defined solver

- function - routine to create the method context which will be stored in a `PC` when `PCSetType()` is called

## Example Usage

       PCRegister("my_solver", MySolverCreate);

Then, your solver can be chosen with the procedural interface via

      PCSetType(pc, "my_solver")

or at runtime via the option

      -pc_type my_solver

## Note

A simpler alternative to using `PCRegister()` for an application specific preconditioner is to use a `PC` of `PCType` `PCSHELL` and provide your customizations with `PCShellSetContext()` and `PCShellSetApply()`

`PCRegister()` may be called multiple times to add several user-defined preconditioners.

## See Also

KSP: Linear System Solvers, `PC`, `PCType`, `PCRegisterAll()`, `PCSetType()`, `PCShellSetContext()`, `PCShellSetApply()`, `PCSHELL`

## Level

advanced

## Location

src/ksp/pc/interface/precon.c

## Examples

src/ksp/ksp/tutorials/ex12.c

Index of all PC routines
Table of Contents for all manual pages
Index of all manual pages