1 /* 2 Identity preconditioner, simply copies vector x to y. 3 */ 4 #include <petsc/private/pcimpl.h> /*I "petscpc.h" I*/ 5 6 static PetscErrorCode PCApply_None(PC pc, Vec x, Vec y) 7 { 8 PetscFunctionBegin; 9 PetscCall(VecCopy(x, y)); 10 PetscFunctionReturn(PETSC_SUCCESS); 11 } 12 13 static PetscErrorCode PCMatApply_None(PC pc, Mat X, Mat Y) 14 { 15 PetscFunctionBegin; 16 PetscCall(MatCopy(X, Y, SAME_NONZERO_PATTERN)); 17 PetscFunctionReturn(PETSC_SUCCESS); 18 } 19 20 /*MC 21 PCNONE - This is used when you wish to employ a nonpreconditioned 22 Krylov method. 23 24 Level: beginner 25 26 Developer Note: 27 This is implemented by a `VecCopy()`. It would be nice if the `KSP` implementations could be organized to avoid this copy without making them 28 more complex. 29 30 .seealso: [](ch_ksp), `PCCreate()`, `PCSetType()`, `PCType`, `PC` 31 M*/ 32 33 PETSC_EXTERN PetscErrorCode PCCreate_None(PC pc) 34 { 35 PetscFunctionBegin; 36 pc->ops->apply = PCApply_None; 37 pc->ops->matapply = PCMatApply_None; 38 pc->ops->applytranspose = PCApply_None; 39 pc->ops->matapplytranspose = PCMatApply_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