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