xref: /petsc/src/ksp/pc/impls/none/none.c (revision e0f5bfbec699682fa3e8b8532b1176849ea4e12a)
1 
2 /*
3     Identity preconditioner, simply copies vector x to y.
4 */
5 #include <petsc/private/pcimpl.h> /*I "petscpc.h" I*/
6 
7 PetscErrorCode PCApply_None(PC pc, Vec x, Vec y) {
8   PetscFunctionBegin;
9   PetscCall(VecCopy(x, y));
10   PetscFunctionReturn(0);
11 }
12 
13 PetscErrorCode PCMatApply_None(PC pc, Mat X, Mat Y) {
14   PetscFunctionBegin;
15   PetscCall(MatCopy(X, Y, SAME_NONZERO_PATTERN));
16   PetscFunctionReturn(0);
17 }
18 
19 /*MC
20      PCNONE - This is used when you wish to employ a nonpreconditioned
21              Krylov method.
22 
23    Level: beginner
24 
25   Developer Note:
26   This is implemented by a `VecCopy()`. It would be nice if the `KSP` implementations could be organized to avoid this copy without making them
27   more complex.
28 
29 .seealso: `PCCreate()`, `PCSetType()`, `PCType`, `PC`
30 M*/
31 
32 PETSC_EXTERN PetscErrorCode PCCreate_None(PC pc) {
33   PetscFunctionBegin;
34   pc->ops->apply               = PCApply_None;
35   pc->ops->matapply            = PCMatApply_None;
36   pc->ops->applytranspose      = PCApply_None;
37   pc->ops->destroy             = NULL;
38   pc->ops->setup               = NULL;
39   pc->ops->view                = NULL;
40   pc->ops->applysymmetricleft  = PCApply_None;
41   pc->ops->applysymmetricright = PCApply_None;
42 
43   pc->data = NULL;
44   PetscFunctionReturn(0);
45 }
46