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