Date: 2025-03-29T05:58:30+00:00

Actual source code: none.c

      1: /*
      2:     Identity preconditioner, simply copies vector x to y.
      3: */
      4: #include <petsc/private/pcimpl.h>

      6: static PetscErrorCode PCApply_None(PC pc, Vec x, Vec y)
      7: {
      8:   PetscFunctionBegin;
      9:   PetscCall(VecCopy(x, y));
     10:   PetscFunctionReturn(PETSC_SUCCESS);
     11: }

     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: }

     20: /*MC
     21:      PCNONE - This is used when you wish to employ a nonpreconditioned
     22:              Krylov method.

     24:    Level: beginner

     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.

     30: .seealso: [](ch_ksp), `PCCreate()`, `PCSetType()`, `PCType`, `PC`
     31: M*/

     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->destroy             = NULL;
     40:   pc->ops->setup               = NULL;
     41:   pc->ops->view                = NULL;
     42:   pc->ops->applysymmetricleft  = PCApply_None;
     43:   pc->ops->applysymmetricright = PCApply_None;

     45:   pc->data = NULL;
     46:   PetscFunctionReturn(PETSC_SUCCESS);
     47: }