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: 33 This one is a little strange. One rarely has an explict matrix that approximates the 34 inverse of the matrix they wish to solve for. 35 36 Level: intermediate 37 38 .seealso: PCCreate(), PCSetType(), PCType (for list of available types), PC, 39 PCSHELL 40 41 M*/ 42 43 PETSC_EXTERN PetscErrorCode PCCreate_Mat(PC pc) 44 { 45 PetscFunctionBegin; 46 pc->ops->apply = PCApply_Mat; 47 pc->ops->applytranspose = PCApplyTranspose_Mat; 48 pc->ops->setup = NULL; 49 pc->ops->destroy = PCDestroy_Mat; 50 pc->ops->setfromoptions = NULL; 51 pc->ops->view = NULL; 52 pc->ops->applyrichardson = NULL; 53 pc->ops->applysymmetricleft = NULL; 54 pc->ops->applysymmetricright = NULL; 55 PetscFunctionReturn(0); 56 } 57 58