xref: /petsc/src/ksp/pc/impls/none/none.c (revision f1580f4e3ce5d5b2393648fd039d0d41b440385d)
1dba47a55SKris Buschelman 
24b9ad928SBarry Smith /*
34b9ad928SBarry Smith     Identity preconditioner, simply copies vector x to y.
44b9ad928SBarry Smith */
5af0996ceSBarry Smith #include <petsc/private/pcimpl.h> /*I "petscpc.h" I*/
64b9ad928SBarry Smith 
79371c9d4SSatish Balay PetscErrorCode PCApply_None(PC pc, Vec x, Vec y) {
84b9ad928SBarry Smith   PetscFunctionBegin;
99566063dSJacob Faibussowitsch   PetscCall(VecCopy(x, y));
104b9ad928SBarry Smith   PetscFunctionReturn(0);
114b9ad928SBarry Smith }
124b9ad928SBarry Smith 
139371c9d4SSatish Balay PetscErrorCode PCMatApply_None(PC pc, Mat X, Mat Y) {
147b6e2003SPierre Jolivet   PetscFunctionBegin;
159566063dSJacob Faibussowitsch   PetscCall(MatCopy(X, Y, SAME_NONZERO_PATTERN));
167b6e2003SPierre Jolivet   PetscFunctionReturn(0);
177b6e2003SPierre Jolivet }
187b6e2003SPierre Jolivet 
194b9ad928SBarry Smith /*MC
204b9ad928SBarry Smith      PCNONE - This is used when you wish to employ a nonpreconditioned
214b9ad928SBarry Smith              Krylov method.
224b9ad928SBarry Smith 
234b9ad928SBarry Smith    Level: beginner
244b9ad928SBarry Smith 
25*f1580f4eSBarry Smith   Developer Note:
26*f1580f4eSBarry Smith   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*f1580f4eSBarry Smith   more complex.
284b9ad928SBarry Smith 
29db781477SPatrick Sanan .seealso: `PCCreate()`, `PCSetType()`, `PCType`, `PC`
304b9ad928SBarry Smith M*/
314b9ad928SBarry Smith 
329371c9d4SSatish Balay PETSC_EXTERN PetscErrorCode PCCreate_None(PC pc) {
334b9ad928SBarry Smith   PetscFunctionBegin;
344b9ad928SBarry Smith   pc->ops->apply               = PCApply_None;
357b6e2003SPierre Jolivet   pc->ops->matapply            = PCMatApply_None;
364b9ad928SBarry Smith   pc->ops->applytranspose      = PCApply_None;
370a545947SLisandro Dalcin   pc->ops->destroy             = NULL;
380a545947SLisandro Dalcin   pc->ops->setup               = NULL;
390a545947SLisandro Dalcin   pc->ops->view                = NULL;
404b9ad928SBarry Smith   pc->ops->applysymmetricleft  = PCApply_None;
414b9ad928SBarry Smith   pc->ops->applysymmetricright = PCApply_None;
424b9ad928SBarry Smith 
430a545947SLisandro Dalcin   pc->data = NULL;
444b9ad928SBarry Smith   PetscFunctionReturn(0);
454b9ad928SBarry Smith }
46