1 2 #include <petsc/private/pcimpl.h> /*I "petscpc.h" I*/ 3 4 static PetscErrorCode PCApply_Mat(PC pc, Vec x, Vec y) { 5 PetscFunctionBegin; 6 PetscCall(MatMult(pc->pmat, x, y)); 7 PetscFunctionReturn(0); 8 } 9 10 static PetscErrorCode PCMatApply_Mat(PC pc, Mat X, Mat Y) { 11 PetscFunctionBegin; 12 PetscCall(MatMatMult(pc->pmat, X, MAT_REUSE_MATRIX, PETSC_DEFAULT, &Y)); 13 PetscFunctionReturn(0); 14 } 15 16 static PetscErrorCode PCApplyTranspose_Mat(PC pc, Vec x, Vec y) { 17 PetscFunctionBegin; 18 PetscCall(MatMultTranspose(pc->pmat, x, y)); 19 PetscFunctionReturn(0); 20 } 21 22 static PetscErrorCode PCDestroy_Mat(PC pc) { 23 PetscFunctionBegin; 24 PetscFunctionReturn(0); 25 } 26 27 /*MC 28 PCMAT - A preconditioner obtained by multiplying by the preconditioner matrix supplied 29 in PCSetOperators() or KSPSetOperators() 30 31 Notes: 32 This one is a little strange. One rarely has an explicit matrix that approximates the 33 inverse of the matrix they wish to solve for. 34 35 Level: intermediate 36 37 .seealso: `PCCreate()`, `PCSetType()`, `PCType`, `PC`, 38 `PCSHELL` 39 40 M*/ 41 42 PETSC_EXTERN PetscErrorCode PCCreate_Mat(PC pc) { 43 PetscFunctionBegin; 44 pc->ops->apply = PCApply_Mat; 45 pc->ops->matapply = PCMatApply_Mat; 46 pc->ops->applytranspose = PCApplyTranspose_Mat; 47 pc->ops->setup = NULL; 48 pc->ops->destroy = PCDestroy_Mat; 49 pc->ops->setfromoptions = NULL; 50 pc->ops->view = NULL; 51 pc->ops->applyrichardson = NULL; 52 pc->ops->applysymmetricleft = NULL; 53 pc->ops->applysymmetricright = NULL; 54 PetscFunctionReturn(0); 55 } 56