Actual source code: none.c


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

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

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

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

 25:    Level: beginner

 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.

 31: .seealso: `PCCreate()`, `PCSetType()`, `PCType`, `PC`
 32: M*/

 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;

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