14d0a8057SBarry Smith 24b9ad928SBarry Smith /* 34b9ad928SBarry Smith This provides a simple shell for Fortran (and C programmers) to 44b9ad928SBarry Smith create their own preconditioner without writing much interface code. 54b9ad928SBarry Smith */ 64b9ad928SBarry Smith 7af0996ceSBarry Smith #include <petsc/private/pcimpl.h> /*I "petscpc.h" I*/ 8af0996ceSBarry Smith #include <petsc/private/vecimpl.h> 94b9ad928SBarry Smith 104b9ad928SBarry Smith typedef struct { 11be29d3c6SBarry Smith void *ctx; /* user provided contexts for preconditioner */ 122fa5cd67SKarl Rupp 136891c3e4SJed Brown PetscErrorCode (*destroy)(PC); 146891c3e4SJed Brown PetscErrorCode (*setup)(PC); 156891c3e4SJed Brown PetscErrorCode (*apply)(PC,Vec,Vec); 161b581b66SBarry Smith PetscErrorCode (*applysymmetricleft)(PC,Vec,Vec); 171b581b66SBarry Smith PetscErrorCode (*applysymmetricright)(PC,Vec,Vec); 186891c3e4SJed Brown PetscErrorCode (*applyBA)(PC,PCSide,Vec,Vec,Vec); 196891c3e4SJed Brown PetscErrorCode (*presolve)(PC,KSP,Vec,Vec); 206891c3e4SJed Brown PetscErrorCode (*postsolve)(PC,KSP,Vec,Vec); 216891c3e4SJed Brown PetscErrorCode (*view)(PC,PetscViewer); 226891c3e4SJed Brown PetscErrorCode (*applytranspose)(PC,Vec,Vec); 23ace3abfcSBarry Smith PetscErrorCode (*applyrich)(PC,Vec,Vec,Vec,PetscReal,PetscReal,PetscReal,PetscInt,PetscBool,PetscInt*,PCRichardsonConvergedReason*); 242fa5cd67SKarl Rupp 254b9ad928SBarry Smith char *name; 264b9ad928SBarry Smith } PC_Shell; 274b9ad928SBarry Smith 284b9ad928SBarry Smith #undef __FUNCT__ 29be29d3c6SBarry Smith #define __FUNCT__ "PCShellGetContext" 30b29801fcSSatish Balay /*@C 31be29d3c6SBarry Smith PCShellGetContext - Returns the user-provided context associated with a shell PC 32be29d3c6SBarry Smith 33be29d3c6SBarry Smith Not Collective 34be29d3c6SBarry Smith 35be29d3c6SBarry Smith Input Parameter: 36c5ae4b9aSBarry Smith . pc - should have been created with PCSetType(pc,shell) 37be29d3c6SBarry Smith 38be29d3c6SBarry Smith Output Parameter: 39be29d3c6SBarry Smith . ctx - the user provided context 40be29d3c6SBarry Smith 41be29d3c6SBarry Smith Level: advanced 42be29d3c6SBarry Smith 43be29d3c6SBarry Smith Notes: 44be29d3c6SBarry Smith This routine is intended for use within various shell routines 45be29d3c6SBarry Smith 46daf670e6SBarry Smith Fortran Notes: To use this from Fortran you must write a Fortran interface definition for this 47daf670e6SBarry Smith function that tells Fortran the Fortran derived data type that you are passing in as the ctx argument. 48daf670e6SBarry Smith 49be29d3c6SBarry Smith .keywords: PC, shell, get, context 50be29d3c6SBarry Smith 51c5ae4b9aSBarry Smith .seealso: PCShellSetContext() 52be29d3c6SBarry Smith @*/ 537087cfbeSBarry Smith PetscErrorCode PCShellGetContext(PC pc,void **ctx) 54be29d3c6SBarry Smith { 55be29d3c6SBarry Smith PetscErrorCode ierr; 56ace3abfcSBarry Smith PetscBool flg; 57be29d3c6SBarry Smith 58be29d3c6SBarry Smith PetscFunctionBegin; 590700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 60be29d3c6SBarry Smith PetscValidPointer(ctx,2); 61251f4c67SDmitry Karpeev ierr = PetscObjectTypeCompare((PetscObject)pc,PCSHELL,&flg);CHKERRQ(ierr); 62be29d3c6SBarry Smith if (!flg) *ctx = 0; 63be29d3c6SBarry Smith else *ctx = ((PC_Shell*)(pc->data))->ctx; 64be29d3c6SBarry Smith PetscFunctionReturn(0); 65be29d3c6SBarry Smith } 66be29d3c6SBarry Smith 67be29d3c6SBarry Smith #undef __FUNCT__ 68be29d3c6SBarry Smith #define __FUNCT__ "PCShellSetContext" 699dd1005fSJed Brown /*@ 70be29d3c6SBarry Smith PCShellSetContext - sets the context for a shell PC 71be29d3c6SBarry Smith 723f9fe445SBarry Smith Logically Collective on PC 73be29d3c6SBarry Smith 74be29d3c6SBarry Smith Input Parameters: 75be29d3c6SBarry Smith + pc - the shell PC 76be29d3c6SBarry Smith - ctx - the context 77be29d3c6SBarry Smith 78be29d3c6SBarry Smith Level: advanced 79be29d3c6SBarry Smith 80daf670e6SBarry Smith Fortran Notes: To use this from Fortran you must write a Fortran interface definition for this 81daf670e6SBarry Smith function that tells Fortran the Fortran derived data type that you are passing in as the ctx argument. 82daf670e6SBarry Smith 83be29d3c6SBarry Smith 846895c445SBarry Smith 85c5ae4b9aSBarry Smith .seealso: PCShellGetContext(), PCSHELL 86be29d3c6SBarry Smith @*/ 877087cfbeSBarry Smith PetscErrorCode PCShellSetContext(PC pc,void *ctx) 88be29d3c6SBarry Smith { 89c5ae4b9aSBarry Smith PC_Shell *shell = (PC_Shell*)pc->data; 90be29d3c6SBarry Smith PetscErrorCode ierr; 91ace3abfcSBarry Smith PetscBool flg; 92be29d3c6SBarry Smith 93be29d3c6SBarry Smith PetscFunctionBegin; 940700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 95251f4c67SDmitry Karpeev ierr = PetscObjectTypeCompare((PetscObject)pc,PCSHELL,&flg);CHKERRQ(ierr); 962fa5cd67SKarl Rupp if (flg) shell->ctx = ctx; 97be29d3c6SBarry Smith PetscFunctionReturn(0); 98be29d3c6SBarry Smith } 99be29d3c6SBarry Smith 100be29d3c6SBarry Smith #undef __FUNCT__ 10118be62a5SSatish Balay #define __FUNCT__ "PCSetUp_Shell" 1026849ba73SBarry Smith static PetscErrorCode PCSetUp_Shell(PC pc) 1034b9ad928SBarry Smith { 104c5ae4b9aSBarry Smith PC_Shell *shell = (PC_Shell*)pc->data; 105dfbe8321SBarry Smith PetscErrorCode ierr; 1064b9ad928SBarry Smith 1074b9ad928SBarry Smith PetscFunctionBegin; 108ce94432eSBarry Smith if (!shell->setup) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No setup() routine provided to Shell PC"); 109eb6b5d47SBarry Smith PetscStackCall("PCSHELL user function setup()",ierr = (*shell->setup)(pc);CHKERRQ(ierr)); 1104b9ad928SBarry Smith PetscFunctionReturn(0); 1114b9ad928SBarry Smith } 1124b9ad928SBarry Smith 1134b9ad928SBarry Smith #undef __FUNCT__ 1144b9ad928SBarry Smith #define __FUNCT__ "PCApply_Shell" 1156849ba73SBarry Smith static PetscErrorCode PCApply_Shell(PC pc,Vec x,Vec y) 1164b9ad928SBarry Smith { 117c5ae4b9aSBarry Smith PC_Shell *shell = (PC_Shell*)pc->data; 118dfbe8321SBarry Smith PetscErrorCode ierr; 119e3f487b0SBarry Smith PetscObjectState instate,outstate; 1204b9ad928SBarry Smith 1214b9ad928SBarry Smith PetscFunctionBegin; 122ce94432eSBarry Smith if (!shell->apply) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No apply() routine provided to Shell PC"); 123e3f487b0SBarry Smith ierr = PetscObjectStateGet((PetscObject)y, &instate);CHKERRQ(ierr); 124eb6b5d47SBarry Smith PetscStackCall("PCSHELL user function apply()",ierr = (*shell->apply)(pc,x,y);CHKERRQ(ierr)); 125e3f487b0SBarry Smith ierr = PetscObjectStateGet((PetscObject)y, &outstate);CHKERRQ(ierr); 126e3f487b0SBarry Smith if (instate == outstate) { 127e3f487b0SBarry Smith /* increase the state of the output vector since the user did not update its state themselve as should have been done */ 128e3f487b0SBarry Smith ierr = PetscObjectStateIncrease((PetscObject)y);CHKERRQ(ierr); 129e3f487b0SBarry Smith } 1304b9ad928SBarry Smith PetscFunctionReturn(0); 1314b9ad928SBarry Smith } 1324b9ad928SBarry Smith 1334b9ad928SBarry Smith #undef __FUNCT__ 1341b581b66SBarry Smith #define __FUNCT__ "PCApplySymmetricLeft_Shell" 1351b581b66SBarry Smith static PetscErrorCode PCApplySymmetricLeft_Shell(PC pc,Vec x,Vec y) 1361b581b66SBarry Smith { 1371b581b66SBarry Smith PC_Shell *shell = (PC_Shell*)pc->data; 1381b581b66SBarry Smith PetscErrorCode ierr; 1391b581b66SBarry Smith 1401b581b66SBarry Smith PetscFunctionBegin; 1411b581b66SBarry Smith if (!shell->applysymmetricleft) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No apply() routine provided to Shell PC"); 1421b581b66SBarry Smith PetscStackCall("PCSHELL user function apply()",ierr = (*shell->applysymmetricleft)(pc,x,y);CHKERRQ(ierr)); 1431b581b66SBarry Smith PetscFunctionReturn(0); 1441b581b66SBarry Smith } 1451b581b66SBarry Smith 1461b581b66SBarry Smith #undef __FUNCT__ 1471b581b66SBarry Smith #define __FUNCT__ "PCApplySymmetricRight_Shell" 1481b581b66SBarry Smith static PetscErrorCode PCApplySymmetricRight_Shell(PC pc,Vec x,Vec y) 1491b581b66SBarry Smith { 1501b581b66SBarry Smith PC_Shell *shell = (PC_Shell*)pc->data; 1511b581b66SBarry Smith PetscErrorCode ierr; 1521b581b66SBarry Smith 1531b581b66SBarry Smith PetscFunctionBegin; 1541b581b66SBarry Smith if (!shell->applysymmetricright) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No apply() routine provided to Shell PC"); 1551b581b66SBarry Smith PetscStackCall("PCSHELL user function apply()",ierr = (*shell->applysymmetricright)(pc,x,y);CHKERRQ(ierr)); 1561b581b66SBarry Smith PetscFunctionReturn(0); 1571b581b66SBarry Smith } 1581b581b66SBarry Smith 1591b581b66SBarry Smith #undef __FUNCT__ 1602bb17772SBarry Smith #define __FUNCT__ "PCApplyBA_Shell" 1612bb17772SBarry Smith static PetscErrorCode PCApplyBA_Shell(PC pc,PCSide side,Vec x,Vec y,Vec w) 1622bb17772SBarry Smith { 163c5ae4b9aSBarry Smith PC_Shell *shell = (PC_Shell*)pc->data; 1642bb17772SBarry Smith PetscErrorCode ierr; 165e3f487b0SBarry Smith PetscObjectState instate,outstate; 1662bb17772SBarry Smith 1672bb17772SBarry Smith PetscFunctionBegin; 168ce94432eSBarry Smith if (!shell->applyBA) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No applyBA() routine provided to Shell PC"); 169e3f487b0SBarry Smith ierr = PetscObjectStateGet((PetscObject)w, &instate);CHKERRQ(ierr); 170eb6b5d47SBarry Smith PetscStackCall("PCSHELL user function applyBA()",ierr = (*shell->applyBA)(pc,side,x,y,w);CHKERRQ(ierr)); 171e3f487b0SBarry Smith ierr = PetscObjectStateGet((PetscObject)w, &outstate);CHKERRQ(ierr); 172e3f487b0SBarry Smith if (instate == outstate) { 173e3f487b0SBarry Smith /* increase the state of the output vector since the user did not update its state themselve as should have been done */ 174e3f487b0SBarry Smith ierr = PetscObjectStateIncrease((PetscObject)w);CHKERRQ(ierr); 175e3f487b0SBarry Smith } 1762bb17772SBarry Smith PetscFunctionReturn(0); 1772bb17772SBarry Smith } 1782bb17772SBarry Smith 1792bb17772SBarry Smith #undef __FUNCT__ 180a06fd7f2SStefano Zampini #define __FUNCT__ "PCPreSolveChangeRHS_Shell" 181a06fd7f2SStefano Zampini static PetscErrorCode PCPreSolveChangeRHS_Shell(PC pc,PetscBool* change) 182a06fd7f2SStefano Zampini { 183a06fd7f2SStefano Zampini PetscFunctionBegin; 184a06fd7f2SStefano Zampini *change = PETSC_TRUE; 185a06fd7f2SStefano Zampini PetscFunctionReturn(0); 186a06fd7f2SStefano Zampini } 187a06fd7f2SStefano Zampini 188a06fd7f2SStefano Zampini #undef __FUNCT__ 1897cdd61b2SBarry Smith #define __FUNCT__ "PCPreSolve_Shell" 1907cdd61b2SBarry Smith static PetscErrorCode PCPreSolve_Shell(PC pc,KSP ksp,Vec b,Vec x) 1917cdd61b2SBarry Smith { 192c5ae4b9aSBarry Smith PC_Shell *shell = (PC_Shell*)pc->data; 1937cdd61b2SBarry Smith PetscErrorCode ierr; 1947cdd61b2SBarry Smith 1957cdd61b2SBarry Smith PetscFunctionBegin; 196ce94432eSBarry Smith if (!shell->presolve) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No presolve() routine provided to Shell PC"); 197eb6b5d47SBarry Smith PetscStackCall("PCSHELL user function presolve()",ierr = (*shell->presolve)(pc,ksp,b,x);CHKERRQ(ierr)); 1987cdd61b2SBarry Smith PetscFunctionReturn(0); 1997cdd61b2SBarry Smith } 2007cdd61b2SBarry Smith 2017cdd61b2SBarry Smith #undef __FUNCT__ 2027cdd61b2SBarry Smith #define __FUNCT__ "PCPostSolve_Shell" 2037cdd61b2SBarry Smith static PetscErrorCode PCPostSolve_Shell(PC pc,KSP ksp,Vec b,Vec x) 2047cdd61b2SBarry Smith { 205c5ae4b9aSBarry Smith PC_Shell *shell = (PC_Shell*)pc->data; 2067cdd61b2SBarry Smith PetscErrorCode ierr; 2077cdd61b2SBarry Smith 2087cdd61b2SBarry Smith PetscFunctionBegin; 209ce94432eSBarry Smith if (!shell->postsolve) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No postsolve() routine provided to Shell PC"); 210eb6b5d47SBarry Smith PetscStackCall("PCSHELL user function postsolve()",ierr = (*shell->postsolve)(pc,ksp,b,x);CHKERRQ(ierr)); 2117cdd61b2SBarry Smith PetscFunctionReturn(0); 2127cdd61b2SBarry Smith } 2137cdd61b2SBarry Smith 2147cdd61b2SBarry Smith #undef __FUNCT__ 2154b9ad928SBarry Smith #define __FUNCT__ "PCApplyTranspose_Shell" 2166849ba73SBarry Smith static PetscErrorCode PCApplyTranspose_Shell(PC pc,Vec x,Vec y) 2174b9ad928SBarry Smith { 218c5ae4b9aSBarry Smith PC_Shell *shell = (PC_Shell*)pc->data; 219dfbe8321SBarry Smith PetscErrorCode ierr; 220e3f487b0SBarry Smith PetscObjectState instate,outstate; 2214b9ad928SBarry Smith 2224b9ad928SBarry Smith PetscFunctionBegin; 223ce94432eSBarry Smith if (!shell->applytranspose) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No applytranspose() routine provided to Shell PC"); 224e3f487b0SBarry Smith ierr = PetscObjectStateGet((PetscObject)y, &instate);CHKERRQ(ierr); 225eb6b5d47SBarry Smith PetscStackCall("PCSHELL user function applytranspose()",ierr = (*shell->applytranspose)(pc,x,y);CHKERRQ(ierr)); 226e3f487b0SBarry Smith ierr = PetscObjectStateGet((PetscObject)y, &outstate);CHKERRQ(ierr); 227e3f487b0SBarry Smith if (instate == outstate) { 228e3f487b0SBarry Smith /* increase the state of the output vector since the user did not update its state themself as should have been done */ 229e3f487b0SBarry Smith ierr = PetscObjectStateIncrease((PetscObject)y);CHKERRQ(ierr); 230e3f487b0SBarry Smith } 2314b9ad928SBarry Smith PetscFunctionReturn(0); 2324b9ad928SBarry Smith } 2334b9ad928SBarry Smith 2344b9ad928SBarry Smith #undef __FUNCT__ 2354b9ad928SBarry Smith #define __FUNCT__ "PCApplyRichardson_Shell" 236ace3abfcSBarry Smith static PetscErrorCode PCApplyRichardson_Shell(PC pc,Vec x,Vec y,Vec w,PetscReal rtol,PetscReal abstol, PetscReal dtol,PetscInt it,PetscBool guesszero,PetscInt *outits,PCRichardsonConvergedReason *reason) 2374b9ad928SBarry Smith { 238dfbe8321SBarry Smith PetscErrorCode ierr; 239c5ae4b9aSBarry Smith PC_Shell *shell = (PC_Shell*)pc->data; 240e3f487b0SBarry Smith PetscObjectState instate,outstate; 2414b9ad928SBarry Smith 2424b9ad928SBarry Smith PetscFunctionBegin; 243ce94432eSBarry Smith if (!shell->applyrich) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No applyrichardson() routine provided to Shell PC"); 244e3f487b0SBarry Smith ierr = PetscObjectStateGet((PetscObject)y, &instate);CHKERRQ(ierr); 245eb6b5d47SBarry Smith PetscStackCall("PCSHELL user function applyrichardson()",ierr = (*shell->applyrich)(pc,x,y,w,rtol,abstol,dtol,it,guesszero,outits,reason);CHKERRQ(ierr)); 246e3f487b0SBarry Smith ierr = PetscObjectStateGet((PetscObject)y, &outstate);CHKERRQ(ierr); 247e3f487b0SBarry Smith if (instate == outstate) { 248e3f487b0SBarry Smith /* increase the state of the output vector since the user did not update its state themself as should have been done */ 249e3f487b0SBarry Smith ierr = PetscObjectStateIncrease((PetscObject)y);CHKERRQ(ierr); 250e3f487b0SBarry Smith } 2514b9ad928SBarry Smith PetscFunctionReturn(0); 2524b9ad928SBarry Smith } 2534b9ad928SBarry Smith 2544b9ad928SBarry Smith #undef __FUNCT__ 2554b9ad928SBarry Smith #define __FUNCT__ "PCDestroy_Shell" 2566849ba73SBarry Smith static PetscErrorCode PCDestroy_Shell(PC pc) 2574b9ad928SBarry Smith { 2584b9ad928SBarry Smith PC_Shell *shell = (PC_Shell*)pc->data; 259dfbe8321SBarry Smith PetscErrorCode ierr; 2604b9ad928SBarry Smith 2614b9ad928SBarry Smith PetscFunctionBegin; 262503cfb0cSBarry Smith ierr = PetscFree(shell->name);CHKERRQ(ierr); 2632fa5cd67SKarl Rupp if (shell->destroy) PetscStackCall("PCSHELL user function destroy()",ierr = (*shell->destroy)(pc);CHKERRQ(ierr)); 264a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetDestroy_C",NULL);CHKERRQ(ierr); 265a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetSetUp_C",NULL);CHKERRQ(ierr); 266a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApply_C",NULL);CHKERRQ(ierr); 267a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplySymmetricLeft_C",NULL);CHKERRQ(ierr); 268a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplySymmetricRight_C",NULL);CHKERRQ(ierr); 269a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplyBA_C",NULL);CHKERRQ(ierr); 270a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetPreSolve_C",NULL);CHKERRQ(ierr); 271a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetPostSolve_C",NULL);CHKERRQ(ierr); 272a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetView_C",NULL);CHKERRQ(ierr); 273a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplyTranspose_C",NULL);CHKERRQ(ierr); 274a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetName_C",NULL);CHKERRQ(ierr); 275a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellGetName_C",NULL);CHKERRQ(ierr); 276a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplyRichardson_C",NULL);CHKERRQ(ierr); 277a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCPreSolveChangeRHS_C",NULL);CHKERRQ(ierr); 278c31cb41cSBarry Smith ierr = PetscFree(pc->data);CHKERRQ(ierr); 2794b9ad928SBarry Smith PetscFunctionReturn(0); 2804b9ad928SBarry Smith } 2814b9ad928SBarry Smith 2824b9ad928SBarry Smith #undef __FUNCT__ 2834b9ad928SBarry Smith #define __FUNCT__ "PCView_Shell" 2846849ba73SBarry Smith static PetscErrorCode PCView_Shell(PC pc,PetscViewer viewer) 2854b9ad928SBarry Smith { 2864b9ad928SBarry Smith PC_Shell *shell = (PC_Shell*)pc->data; 287dfbe8321SBarry Smith PetscErrorCode ierr; 288ace3abfcSBarry Smith PetscBool iascii; 2894b9ad928SBarry Smith 2904b9ad928SBarry Smith PetscFunctionBegin; 291251f4c67SDmitry Karpeev ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&iascii);CHKERRQ(ierr); 29232077d6dSBarry Smith if (iascii) { 2932fa5cd67SKarl Rupp if (shell->name) { 2942fa5cd67SKarl Rupp ierr = PetscViewerASCIIPrintf(viewer," Shell: %s\n",shell->name);CHKERRQ(ierr); 2952fa5cd67SKarl Rupp } else { 2962fa5cd67SKarl Rupp ierr = PetscViewerASCIIPrintf(viewer," Shell: no name\n");CHKERRQ(ierr); 2972fa5cd67SKarl Rupp } 2984b9ad928SBarry Smith } 2994b9ad928SBarry Smith if (shell->view) { 3004b9ad928SBarry Smith ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); 3016891c3e4SJed Brown ierr = (*shell->view)(pc,viewer);CHKERRQ(ierr); 3024b9ad928SBarry Smith ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); 3034b9ad928SBarry Smith } 3044b9ad928SBarry Smith PetscFunctionReturn(0); 3054b9ad928SBarry Smith } 3064b9ad928SBarry Smith 3074b9ad928SBarry Smith /* ------------------------------------------------------------------------------*/ 3084b9ad928SBarry Smith #undef __FUNCT__ 30918be62a5SSatish Balay #define __FUNCT__ "PCShellSetDestroy_Shell" 310f7a08781SBarry Smith static PetscErrorCode PCShellSetDestroy_Shell(PC pc, PetscErrorCode (*destroy)(PC)) 31118be62a5SSatish Balay { 312c5ae4b9aSBarry Smith PC_Shell *shell= (PC_Shell*)pc->data; 31318be62a5SSatish Balay 31418be62a5SSatish Balay PetscFunctionBegin; 31518be62a5SSatish Balay shell->destroy = destroy; 31618be62a5SSatish Balay PetscFunctionReturn(0); 31718be62a5SSatish Balay } 31818be62a5SSatish Balay 31918be62a5SSatish Balay #undef __FUNCT__ 3204b9ad928SBarry Smith #define __FUNCT__ "PCShellSetSetUp_Shell" 321f7a08781SBarry Smith static PetscErrorCode PCShellSetSetUp_Shell(PC pc, PetscErrorCode (*setup)(PC)) 3224b9ad928SBarry Smith { 323c5ae4b9aSBarry Smith PC_Shell *shell = (PC_Shell*)pc->data;; 3244b9ad928SBarry Smith 3254b9ad928SBarry Smith PetscFunctionBegin; 3264b9ad928SBarry Smith shell->setup = setup; 327d01c8aa3SLisandro Dalcin if (setup) pc->ops->setup = PCSetUp_Shell; 328d01c8aa3SLisandro Dalcin else pc->ops->setup = 0; 3294b9ad928SBarry Smith PetscFunctionReturn(0); 3304b9ad928SBarry Smith } 3314b9ad928SBarry Smith 3324b9ad928SBarry Smith #undef __FUNCT__ 3334b9ad928SBarry Smith #define __FUNCT__ "PCShellSetApply_Shell" 334f7a08781SBarry Smith static PetscErrorCode PCShellSetApply_Shell(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec)) 3354b9ad928SBarry Smith { 336c5ae4b9aSBarry Smith PC_Shell *shell = (PC_Shell*)pc->data; 3374b9ad928SBarry Smith 3384b9ad928SBarry Smith PetscFunctionBegin; 3394b9ad928SBarry Smith shell->apply = apply; 3404b9ad928SBarry Smith PetscFunctionReturn(0); 3414b9ad928SBarry Smith } 3424b9ad928SBarry Smith 3434b9ad928SBarry Smith #undef __FUNCT__ 3441b581b66SBarry Smith #define __FUNCT__ "PCShellSetApplySymmetricLeft_Shell" 3451b581b66SBarry Smith static PetscErrorCode PCShellSetApplySymmetricLeft_Shell(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec)) 3461b581b66SBarry Smith { 3471b581b66SBarry Smith PC_Shell *shell = (PC_Shell*)pc->data; 3481b581b66SBarry Smith 3491b581b66SBarry Smith PetscFunctionBegin; 3501b581b66SBarry Smith shell->applysymmetricleft = apply; 3511b581b66SBarry Smith PetscFunctionReturn(0); 3521b581b66SBarry Smith } 3531b581b66SBarry Smith 3541b581b66SBarry Smith #undef __FUNCT__ 3551b581b66SBarry Smith #define __FUNCT__ "PCShellSetApplySymmetricRight_Shell" 3561b581b66SBarry Smith static PetscErrorCode PCShellSetApplySymmetricRight_Shell(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec)) 3571b581b66SBarry Smith { 3581b581b66SBarry Smith PC_Shell *shell = (PC_Shell*)pc->data; 3591b581b66SBarry Smith 3601b581b66SBarry Smith PetscFunctionBegin; 3611b581b66SBarry Smith shell->applysymmetricright = apply; 3621b581b66SBarry Smith PetscFunctionReturn(0); 3631b581b66SBarry Smith } 3641b581b66SBarry Smith 3651b581b66SBarry Smith #undef __FUNCT__ 3662bb17772SBarry Smith #define __FUNCT__ "PCShellSetApplyBA_Shell" 367f7a08781SBarry Smith static PetscErrorCode PCShellSetApplyBA_Shell(PC pc,PetscErrorCode (*applyBA)(PC,PCSide,Vec,Vec,Vec)) 3682bb17772SBarry Smith { 369c5ae4b9aSBarry Smith PC_Shell *shell = (PC_Shell*)pc->data; 3702bb17772SBarry Smith 3712bb17772SBarry Smith PetscFunctionBegin; 372d01c8aa3SLisandro Dalcin shell->applyBA = applyBA; 373d01c8aa3SLisandro Dalcin if (applyBA) pc->ops->applyBA = PCApplyBA_Shell; 374aef0136fSBarry Smith else pc->ops->applyBA = 0; 3752bb17772SBarry Smith PetscFunctionReturn(0); 3762bb17772SBarry Smith } 3772bb17772SBarry Smith 3782bb17772SBarry Smith #undef __FUNCT__ 3797cdd61b2SBarry Smith #define __FUNCT__ "PCShellSetPreSolve_Shell" 380f7a08781SBarry Smith static PetscErrorCode PCShellSetPreSolve_Shell(PC pc,PetscErrorCode (*presolve)(PC,KSP,Vec,Vec)) 3817cdd61b2SBarry Smith { 382c5ae4b9aSBarry Smith PC_Shell *shell = (PC_Shell*)pc->data; 383a06fd7f2SStefano Zampini PetscErrorCode ierr; 3847cdd61b2SBarry Smith 3857cdd61b2SBarry Smith PetscFunctionBegin; 3867cdd61b2SBarry Smith shell->presolve = presolve; 387a06fd7f2SStefano Zampini if (presolve) { 388a06fd7f2SStefano Zampini pc->ops->presolve = PCPreSolve_Shell; 389a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCPreSolveChangeRHS_C",PCPreSolveChangeRHS_Shell);CHKERRQ(ierr); 390a06fd7f2SStefano Zampini } else { 391a06fd7f2SStefano Zampini pc->ops->presolve = 0; 392a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCPreSolveChangeRHS_C",NULL);CHKERRQ(ierr); 393a06fd7f2SStefano Zampini } 3947cdd61b2SBarry Smith PetscFunctionReturn(0); 3957cdd61b2SBarry Smith } 3967cdd61b2SBarry Smith 3977cdd61b2SBarry Smith #undef __FUNCT__ 3987cdd61b2SBarry Smith #define __FUNCT__ "PCShellSetPostSolve_Shell" 399f7a08781SBarry Smith static PetscErrorCode PCShellSetPostSolve_Shell(PC pc,PetscErrorCode (*postsolve)(PC,KSP,Vec,Vec)) 4007cdd61b2SBarry Smith { 401c5ae4b9aSBarry Smith PC_Shell *shell = (PC_Shell*)pc->data; 4027cdd61b2SBarry Smith 4037cdd61b2SBarry Smith PetscFunctionBegin; 4047cdd61b2SBarry Smith shell->postsolve = postsolve; 405d01c8aa3SLisandro Dalcin if (postsolve) pc->ops->postsolve = PCPostSolve_Shell; 406d01c8aa3SLisandro Dalcin else pc->ops->postsolve = 0; 4077cdd61b2SBarry Smith PetscFunctionReturn(0); 4087cdd61b2SBarry Smith } 4097cdd61b2SBarry Smith 4107cdd61b2SBarry Smith #undef __FUNCT__ 4114b9ad928SBarry Smith #define __FUNCT__ "PCShellSetView_Shell" 412f7a08781SBarry Smith static PetscErrorCode PCShellSetView_Shell(PC pc,PetscErrorCode (*view)(PC,PetscViewer)) 4134b9ad928SBarry Smith { 414c5ae4b9aSBarry Smith PC_Shell *shell = (PC_Shell*)pc->data; 4154b9ad928SBarry Smith 4164b9ad928SBarry Smith PetscFunctionBegin; 4174b9ad928SBarry Smith shell->view = view; 4184b9ad928SBarry Smith PetscFunctionReturn(0); 4194b9ad928SBarry Smith } 4204b9ad928SBarry Smith 4214b9ad928SBarry Smith #undef __FUNCT__ 4224b9ad928SBarry Smith #define __FUNCT__ "PCShellSetApplyTranspose_Shell" 423f7a08781SBarry Smith static PetscErrorCode PCShellSetApplyTranspose_Shell(PC pc,PetscErrorCode (*applytranspose)(PC,Vec,Vec)) 4244b9ad928SBarry Smith { 425c5ae4b9aSBarry Smith PC_Shell *shell = (PC_Shell*)pc->data; 4264b9ad928SBarry Smith 4274b9ad928SBarry Smith PetscFunctionBegin; 4284b9ad928SBarry Smith shell->applytranspose = applytranspose; 429d01c8aa3SLisandro Dalcin if (applytranspose) pc->ops->applytranspose = PCApplyTranspose_Shell; 430d01c8aa3SLisandro Dalcin else pc->ops->applytranspose = 0; 431d01c8aa3SLisandro Dalcin PetscFunctionReturn(0); 432d01c8aa3SLisandro Dalcin } 433d01c8aa3SLisandro Dalcin 434d01c8aa3SLisandro Dalcin #undef __FUNCT__ 435d01c8aa3SLisandro Dalcin #define __FUNCT__ "PCShellSetApplyRichardson_Shell" 436f7a08781SBarry Smith static PetscErrorCode PCShellSetApplyRichardson_Shell(PC pc,PetscErrorCode (*applyrich)(PC,Vec,Vec,Vec,PetscReal,PetscReal,PetscReal,PetscInt,PetscBool ,PetscInt*,PCRichardsonConvergedReason*)) 437d01c8aa3SLisandro Dalcin { 438c5ae4b9aSBarry Smith PC_Shell *shell = (PC_Shell*)pc->data; 439d01c8aa3SLisandro Dalcin 440d01c8aa3SLisandro Dalcin PetscFunctionBegin; 441d01c8aa3SLisandro Dalcin shell->applyrich = applyrich; 442d01c8aa3SLisandro Dalcin if (applyrich) pc->ops->applyrichardson = PCApplyRichardson_Shell; 443d01c8aa3SLisandro Dalcin else pc->ops->applyrichardson = 0; 4444b9ad928SBarry Smith PetscFunctionReturn(0); 4454b9ad928SBarry Smith } 4464b9ad928SBarry Smith 4474b9ad928SBarry Smith #undef __FUNCT__ 4484b9ad928SBarry Smith #define __FUNCT__ "PCShellSetName_Shell" 449f7a08781SBarry Smith static PetscErrorCode PCShellSetName_Shell(PC pc,const char name[]) 4504b9ad928SBarry Smith { 451c5ae4b9aSBarry Smith PC_Shell *shell = (PC_Shell*)pc->data; 452dfbe8321SBarry Smith PetscErrorCode ierr; 4534b9ad928SBarry Smith 4544b9ad928SBarry Smith PetscFunctionBegin; 455503cfb0cSBarry Smith ierr = PetscFree(shell->name);CHKERRQ(ierr); 4564b9ad928SBarry Smith ierr = PetscStrallocpy(name,&shell->name);CHKERRQ(ierr); 4574b9ad928SBarry Smith PetscFunctionReturn(0); 4584b9ad928SBarry Smith } 4594b9ad928SBarry Smith 4604b9ad928SBarry Smith #undef __FUNCT__ 4614b9ad928SBarry Smith #define __FUNCT__ "PCShellGetName_Shell" 462f7a08781SBarry Smith static PetscErrorCode PCShellGetName_Shell(PC pc,const char *name[]) 4634b9ad928SBarry Smith { 464c5ae4b9aSBarry Smith PC_Shell *shell = (PC_Shell*)pc->data; 4654b9ad928SBarry Smith 4664b9ad928SBarry Smith PetscFunctionBegin; 4674b9ad928SBarry Smith *name = shell->name; 4684b9ad928SBarry Smith PetscFunctionReturn(0); 4694b9ad928SBarry Smith } 4704b9ad928SBarry Smith 4714b9ad928SBarry Smith /* -------------------------------------------------------------------------------*/ 4724b9ad928SBarry Smith 4734b9ad928SBarry Smith #undef __FUNCT__ 47418be62a5SSatish Balay #define __FUNCT__ "PCShellSetDestroy" 47518be62a5SSatish Balay /*@C 47618be62a5SSatish Balay PCShellSetDestroy - Sets routine to use to destroy the user-provided 47718be62a5SSatish Balay application context. 47818be62a5SSatish Balay 4793f9fe445SBarry Smith Logically Collective on PC 48018be62a5SSatish Balay 48118be62a5SSatish Balay Input Parameters: 48218be62a5SSatish Balay + pc - the preconditioner context 48318be62a5SSatish Balay . destroy - the application-provided destroy routine 48418be62a5SSatish Balay 48518be62a5SSatish Balay Calling sequence of destroy: 48618be62a5SSatish Balay .vb 4876891c3e4SJed Brown PetscErrorCode destroy (PC) 48818be62a5SSatish Balay .ve 48918be62a5SSatish Balay 49018be62a5SSatish Balay . ptr - the application context 49118be62a5SSatish Balay 4924aa34b0aSBarry Smith Notes: the function MUST return an error code of 0 on success and nonzero on failure. 4934aa34b0aSBarry Smith 49418be62a5SSatish Balay Level: developer 49518be62a5SSatish Balay 49618be62a5SSatish Balay .keywords: PC, shell, set, destroy, user-provided 49718be62a5SSatish Balay 49818be62a5SSatish Balay .seealso: PCShellSetApply(), PCShellSetContext() 49918be62a5SSatish Balay @*/ 5007087cfbeSBarry Smith PetscErrorCode PCShellSetDestroy(PC pc,PetscErrorCode (*destroy)(PC)) 50118be62a5SSatish Balay { 5024ac538c5SBarry Smith PetscErrorCode ierr; 50318be62a5SSatish Balay 50418be62a5SSatish Balay PetscFunctionBegin; 5050700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 5064ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCShellSetDestroy_C",(PC,PetscErrorCode (*)(PC)),(pc,destroy));CHKERRQ(ierr); 50718be62a5SSatish Balay PetscFunctionReturn(0); 50818be62a5SSatish Balay } 50918be62a5SSatish Balay 51018be62a5SSatish Balay 51118be62a5SSatish Balay #undef __FUNCT__ 5124b9ad928SBarry Smith #define __FUNCT__ "PCShellSetSetUp" 5134b9ad928SBarry Smith /*@C 5144b9ad928SBarry Smith PCShellSetSetUp - Sets routine to use to "setup" the preconditioner whenever the 5154b9ad928SBarry Smith matrix operator is changed. 5164b9ad928SBarry Smith 5173f9fe445SBarry Smith Logically Collective on PC 5184b9ad928SBarry Smith 5194b9ad928SBarry Smith Input Parameters: 5204b9ad928SBarry Smith + pc - the preconditioner context 5214b9ad928SBarry Smith . setup - the application-provided setup routine 5224b9ad928SBarry Smith 5234b9ad928SBarry Smith Calling sequence of setup: 5244b9ad928SBarry Smith .vb 5256891c3e4SJed Brown PetscErrorCode setup (PC pc) 5264b9ad928SBarry Smith .ve 5274b9ad928SBarry Smith 5286891c3e4SJed Brown . pc - the preconditioner, get the application context with PCShellGetContext() 5294b9ad928SBarry Smith 5304aa34b0aSBarry Smith Notes: the function MUST return an error code of 0 on success and nonzero on failure. 5314aa34b0aSBarry Smith 5324b9ad928SBarry Smith Level: developer 5334b9ad928SBarry Smith 5344b9ad928SBarry Smith .keywords: PC, shell, set, setup, user-provided 5354b9ad928SBarry Smith 536be29d3c6SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetApply(), PCShellSetContext() 5374b9ad928SBarry Smith @*/ 5387087cfbeSBarry Smith PetscErrorCode PCShellSetSetUp(PC pc,PetscErrorCode (*setup)(PC)) 5394b9ad928SBarry Smith { 5404ac538c5SBarry Smith PetscErrorCode ierr; 5414b9ad928SBarry Smith 5424b9ad928SBarry Smith PetscFunctionBegin; 5430700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 5444ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCShellSetSetUp_C",(PC,PetscErrorCode (*)(PC)),(pc,setup));CHKERRQ(ierr); 5454b9ad928SBarry Smith PetscFunctionReturn(0); 5464b9ad928SBarry Smith } 5474b9ad928SBarry Smith 5484b9ad928SBarry Smith 5494b9ad928SBarry Smith #undef __FUNCT__ 5504b9ad928SBarry Smith #define __FUNCT__ "PCShellSetView" 5514b9ad928SBarry Smith /*@C 5524b9ad928SBarry Smith PCShellSetView - Sets routine to use as viewer of shell preconditioner 5534b9ad928SBarry Smith 5543f9fe445SBarry Smith Logically Collective on PC 5554b9ad928SBarry Smith 5564b9ad928SBarry Smith Input Parameters: 5574b9ad928SBarry Smith + pc - the preconditioner context 5584b9ad928SBarry Smith - view - the application-provided view routine 5594b9ad928SBarry Smith 5604b9ad928SBarry Smith Calling sequence of apply: 5614b9ad928SBarry Smith .vb 5626891c3e4SJed Brown PetscErrorCode view(PC pc,PetscViewer v) 5634b9ad928SBarry Smith .ve 5644b9ad928SBarry Smith 5656891c3e4SJed Brown + pc - the preconditioner, get the application context with PCShellGetContext() 5664b9ad928SBarry Smith - v - viewer 5674b9ad928SBarry Smith 5684aa34b0aSBarry Smith Notes: the function MUST return an error code of 0 on success and nonzero on failure. 5694aa34b0aSBarry Smith 5704b9ad928SBarry Smith Level: developer 5714b9ad928SBarry Smith 5724b9ad928SBarry Smith .keywords: PC, shell, set, apply, user-provided 5734b9ad928SBarry Smith 5744b9ad928SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose() 5754b9ad928SBarry Smith @*/ 5767087cfbeSBarry Smith PetscErrorCode PCShellSetView(PC pc,PetscErrorCode (*view)(PC,PetscViewer)) 5774b9ad928SBarry Smith { 5784ac538c5SBarry Smith PetscErrorCode ierr; 5794b9ad928SBarry Smith 5804b9ad928SBarry Smith PetscFunctionBegin; 5810700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 5824ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCShellSetView_C",(PC,PetscErrorCode (*)(PC,PetscViewer)),(pc,view));CHKERRQ(ierr); 5834b9ad928SBarry Smith PetscFunctionReturn(0); 5844b9ad928SBarry Smith } 5854b9ad928SBarry Smith 5864b9ad928SBarry Smith #undef __FUNCT__ 5874b9ad928SBarry Smith #define __FUNCT__ "PCShellSetApply" 5884b9ad928SBarry Smith /*@C 5894b9ad928SBarry Smith PCShellSetApply - Sets routine to use as preconditioner. 5904b9ad928SBarry Smith 5913f9fe445SBarry Smith Logically Collective on PC 5924b9ad928SBarry Smith 5934b9ad928SBarry Smith Input Parameters: 5944b9ad928SBarry Smith + pc - the preconditioner context 595be29d3c6SBarry Smith - apply - the application-provided preconditioning routine 5964b9ad928SBarry Smith 5974b9ad928SBarry Smith Calling sequence of apply: 5984b9ad928SBarry Smith .vb 5996891c3e4SJed Brown PetscErrorCode apply (PC pc,Vec xin,Vec xout) 6004b9ad928SBarry Smith .ve 6014b9ad928SBarry Smith 6026891c3e4SJed Brown + pc - the preconditioner, get the application context with PCShellGetContext() 6034b9ad928SBarry Smith . xin - input vector 6044b9ad928SBarry Smith - xout - output vector 6054b9ad928SBarry Smith 6064aa34b0aSBarry Smith Notes: the function MUST return an error code of 0 on success and nonzero on failure. 6074aa34b0aSBarry Smith 6084b9ad928SBarry Smith Level: developer 6094b9ad928SBarry Smith 6104b9ad928SBarry Smith .keywords: PC, shell, set, apply, user-provided 6114b9ad928SBarry Smith 612*a4c07401SPatrick Sanan .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetContext(), PCShellSetApplyBA(), PCShellSetApplySymmetricRight(),PCShellSetApplySymmetricLeft() 6134b9ad928SBarry Smith @*/ 6147087cfbeSBarry Smith PetscErrorCode PCShellSetApply(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec)) 6154b9ad928SBarry Smith { 6164ac538c5SBarry Smith PetscErrorCode ierr; 6174b9ad928SBarry Smith 6184b9ad928SBarry Smith PetscFunctionBegin; 6190700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 6204ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCShellSetApply_C",(PC,PetscErrorCode (*)(PC,Vec,Vec)),(pc,apply));CHKERRQ(ierr); 6214b9ad928SBarry Smith PetscFunctionReturn(0); 6224b9ad928SBarry Smith } 6234b9ad928SBarry Smith 6244b9ad928SBarry Smith #undef __FUNCT__ 6251b581b66SBarry Smith #define __FUNCT__ "PCShellSetApplySymmetricLeft" 6261b581b66SBarry Smith /*@C 6271b581b66SBarry Smith PCShellSetApplySymmetricLeft - Sets routine to use as left preconditioner (when the PC_SYMMETRIC is used). 6281b581b66SBarry Smith 6291b581b66SBarry Smith Logically Collective on PC 6301b581b66SBarry Smith 6311b581b66SBarry Smith Input Parameters: 6321b581b66SBarry Smith + pc - the preconditioner context 6331b581b66SBarry Smith - apply - the application-provided left preconditioning routine 6341b581b66SBarry Smith 6351b581b66SBarry Smith Calling sequence of apply: 6361b581b66SBarry Smith .vb 6371b581b66SBarry Smith PetscErrorCode apply (PC pc,Vec xin,Vec xout) 6381b581b66SBarry Smith .ve 6391b581b66SBarry Smith 6401b581b66SBarry Smith + pc - the preconditioner, get the application context with PCShellGetContext() 6411b581b66SBarry Smith . xin - input vector 6421b581b66SBarry Smith - xout - output vector 6431b581b66SBarry Smith 6441b581b66SBarry Smith Notes: the function MUST return an error code of 0 on success and nonzero on failure. 6451b581b66SBarry Smith 6461b581b66SBarry Smith Level: developer 6471b581b66SBarry Smith 6481b581b66SBarry Smith .keywords: PC, shell, set, apply, user-provided 6491b581b66SBarry Smith 6501b581b66SBarry Smith .seealso: PCShellSetApply(), PCShellSetApplySymmetricLeft(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetContext() 6511b581b66SBarry Smith @*/ 6521b581b66SBarry Smith PetscErrorCode PCShellSetApplySymmetricLeft(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec)) 6531b581b66SBarry Smith { 6541b581b66SBarry Smith PetscErrorCode ierr; 6551b581b66SBarry Smith 6561b581b66SBarry Smith PetscFunctionBegin; 6571b581b66SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 6581b581b66SBarry Smith ierr = PetscTryMethod(pc,"PCShellSetApplySymmetricLeft_C",(PC,PetscErrorCode (*)(PC,Vec,Vec)),(pc,apply));CHKERRQ(ierr); 6591b581b66SBarry Smith PetscFunctionReturn(0); 6601b581b66SBarry Smith } 6611b581b66SBarry Smith 6621b581b66SBarry Smith #undef __FUNCT__ 6631b581b66SBarry Smith #define __FUNCT__ "PCShellSetApplySymmetricRight" 6641b581b66SBarry Smith /*@C 665*a4c07401SPatrick Sanan PCShellSetApplySymmetricRight - Sets routine to use as right preconditioner (when the PC_SYMMETRIC is used). 6661b581b66SBarry Smith 6671b581b66SBarry Smith Logically Collective on PC 6681b581b66SBarry Smith 6691b581b66SBarry Smith Input Parameters: 6701b581b66SBarry Smith + pc - the preconditioner context 6711b581b66SBarry Smith - apply - the application-provided right preconditioning routine 6721b581b66SBarry Smith 6731b581b66SBarry Smith Calling sequence of apply: 6741b581b66SBarry Smith .vb 6751b581b66SBarry Smith PetscErrorCode apply (PC pc,Vec xin,Vec xout) 6761b581b66SBarry Smith .ve 6771b581b66SBarry Smith 6781b581b66SBarry Smith + pc - the preconditioner, get the application context with PCShellGetContext() 6791b581b66SBarry Smith . xin - input vector 6801b581b66SBarry Smith - xout - output vector 6811b581b66SBarry Smith 6821b581b66SBarry Smith Notes: the function MUST return an error code of 0 on success and nonzero on failure. 6831b581b66SBarry Smith 6841b581b66SBarry Smith Level: developer 6851b581b66SBarry Smith 6861b581b66SBarry Smith .keywords: PC, shell, set, apply, user-provided 6871b581b66SBarry Smith 6881b581b66SBarry Smith .seealso: PCShellSetApply(), PCShellSetApplySymmetricLeft(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetContext() 6891b581b66SBarry Smith @*/ 6901b581b66SBarry Smith PetscErrorCode PCShellSetApplySymmetricRight(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec)) 6911b581b66SBarry Smith { 6921b581b66SBarry Smith PetscErrorCode ierr; 6931b581b66SBarry Smith 6941b581b66SBarry Smith PetscFunctionBegin; 6951b581b66SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 6961b581b66SBarry Smith ierr = PetscTryMethod(pc,"PCShellSetApplySymmetricRight_C",(PC,PetscErrorCode (*)(PC,Vec,Vec)),(pc,apply));CHKERRQ(ierr); 6971b581b66SBarry Smith PetscFunctionReturn(0); 6981b581b66SBarry Smith } 6991b581b66SBarry Smith 7001b581b66SBarry Smith #undef __FUNCT__ 7012bb17772SBarry Smith #define __FUNCT__ "PCShellSetApplyBA" 7022bb17772SBarry Smith /*@C 7032bb17772SBarry Smith PCShellSetApplyBA - Sets routine to use as preconditioner times operator. 7042bb17772SBarry Smith 7053f9fe445SBarry Smith Logically Collective on PC 7062bb17772SBarry Smith 7072bb17772SBarry Smith Input Parameters: 7082bb17772SBarry Smith + pc - the preconditioner context 7092bb17772SBarry Smith - applyBA - the application-provided BA routine 7102bb17772SBarry Smith 7112bb17772SBarry Smith Calling sequence of apply: 7122bb17772SBarry Smith .vb 7136891c3e4SJed Brown PetscErrorCode applyBA (PC pc,Vec xin,Vec xout) 7142bb17772SBarry Smith .ve 7152bb17772SBarry Smith 7166891c3e4SJed Brown + pc - the preconditioner, get the application context with PCShellGetContext() 7172bb17772SBarry Smith . xin - input vector 7182bb17772SBarry Smith - xout - output vector 7192bb17772SBarry Smith 7204aa34b0aSBarry Smith Notes: the function MUST return an error code of 0 on success and nonzero on failure. 7214aa34b0aSBarry Smith 7222bb17772SBarry Smith Level: developer 7232bb17772SBarry Smith 7242bb17772SBarry Smith .keywords: PC, shell, set, apply, user-provided 7252bb17772SBarry Smith 7262bb17772SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetContext(), PCShellSetApply() 7272bb17772SBarry Smith @*/ 7287087cfbeSBarry Smith PetscErrorCode PCShellSetApplyBA(PC pc,PetscErrorCode (*applyBA)(PC,PCSide,Vec,Vec,Vec)) 7292bb17772SBarry Smith { 7304ac538c5SBarry Smith PetscErrorCode ierr; 7312bb17772SBarry Smith 7322bb17772SBarry Smith PetscFunctionBegin; 7330700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 7344ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCShellSetApplyBA_C",(PC,PetscErrorCode (*)(PC,PCSide,Vec,Vec,Vec)),(pc,applyBA));CHKERRQ(ierr); 7352bb17772SBarry Smith PetscFunctionReturn(0); 7362bb17772SBarry Smith } 7372bb17772SBarry Smith 7382bb17772SBarry Smith #undef __FUNCT__ 7394b9ad928SBarry Smith #define __FUNCT__ "PCShellSetApplyTranspose" 7404b9ad928SBarry Smith /*@C 7414b9ad928SBarry Smith PCShellSetApplyTranspose - Sets routine to use as preconditioner transpose. 7424b9ad928SBarry Smith 7433f9fe445SBarry Smith Logically Collective on PC 7444b9ad928SBarry Smith 7454b9ad928SBarry Smith Input Parameters: 7464b9ad928SBarry Smith + pc - the preconditioner context 7474b9ad928SBarry Smith - apply - the application-provided preconditioning transpose routine 7484b9ad928SBarry Smith 7494b9ad928SBarry Smith Calling sequence of apply: 7504b9ad928SBarry Smith .vb 7516891c3e4SJed Brown PetscErrorCode applytranspose (PC pc,Vec xin,Vec xout) 7524b9ad928SBarry Smith .ve 7534b9ad928SBarry Smith 7546891c3e4SJed Brown + pc - the preconditioner, get the application context with PCShellGetContext() 7554b9ad928SBarry Smith . xin - input vector 7564b9ad928SBarry Smith - xout - output vector 7574b9ad928SBarry Smith 7584aa34b0aSBarry Smith Notes: the function MUST return an error code of 0 on success and nonzero on failure. 7594aa34b0aSBarry Smith 7604b9ad928SBarry Smith Level: developer 7614b9ad928SBarry Smith 7624b9ad928SBarry Smith Notes: 7634b9ad928SBarry Smith Uses the same context variable as PCShellSetApply(). 7644b9ad928SBarry Smith 7654b9ad928SBarry Smith .keywords: PC, shell, set, apply, user-provided 7664b9ad928SBarry Smith 7672bb17772SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApply(), PCSetContext(), PCShellSetApplyBA() 7684b9ad928SBarry Smith @*/ 7697087cfbeSBarry Smith PetscErrorCode PCShellSetApplyTranspose(PC pc,PetscErrorCode (*applytranspose)(PC,Vec,Vec)) 7704b9ad928SBarry Smith { 7714ac538c5SBarry Smith PetscErrorCode ierr; 7724b9ad928SBarry Smith 7734b9ad928SBarry Smith PetscFunctionBegin; 7740700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 7754ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCShellSetApplyTranspose_C",(PC,PetscErrorCode (*)(PC,Vec,Vec)),(pc,applytranspose));CHKERRQ(ierr); 7764b9ad928SBarry Smith PetscFunctionReturn(0); 7774b9ad928SBarry Smith } 7784b9ad928SBarry Smith 7794b9ad928SBarry Smith #undef __FUNCT__ 7807cdd61b2SBarry Smith #define __FUNCT__ "PCShellSetPreSolve" 7817cdd61b2SBarry Smith /*@C 7827cdd61b2SBarry Smith PCShellSetPreSolve - Sets routine to apply to the operators/vectors before a KSPSolve() is 7837cdd61b2SBarry Smith applied. This usually does something like scale the linear system in some application 7847cdd61b2SBarry Smith specific way. 7857cdd61b2SBarry Smith 7863f9fe445SBarry Smith Logically Collective on PC 7877cdd61b2SBarry Smith 7887cdd61b2SBarry Smith Input Parameters: 7897cdd61b2SBarry Smith + pc - the preconditioner context 7907cdd61b2SBarry Smith - presolve - the application-provided presolve routine 7917cdd61b2SBarry Smith 7927cdd61b2SBarry Smith Calling sequence of presolve: 7937cdd61b2SBarry Smith .vb 7946891c3e4SJed Brown PetscErrorCode presolve (PC,KSP ksp,Vec b,Vec x) 7957cdd61b2SBarry Smith .ve 7967cdd61b2SBarry Smith 7976891c3e4SJed Brown + pc - the preconditioner, get the application context with PCShellGetContext() 7987cdd61b2SBarry Smith . xin - input vector 7997cdd61b2SBarry Smith - xout - output vector 8007cdd61b2SBarry Smith 8014aa34b0aSBarry Smith Notes: the function MUST return an error code of 0 on success and nonzero on failure. 8024aa34b0aSBarry Smith 8037cdd61b2SBarry Smith Level: developer 8047cdd61b2SBarry Smith 8057cdd61b2SBarry Smith .keywords: PC, shell, set, apply, user-provided 8067cdd61b2SBarry Smith 807be29d3c6SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetPostSolve(), PCShellSetContext() 8087cdd61b2SBarry Smith @*/ 8097087cfbeSBarry Smith PetscErrorCode PCShellSetPreSolve(PC pc,PetscErrorCode (*presolve)(PC,KSP,Vec,Vec)) 8107cdd61b2SBarry Smith { 8114ac538c5SBarry Smith PetscErrorCode ierr; 8127cdd61b2SBarry Smith 8137cdd61b2SBarry Smith PetscFunctionBegin; 8140700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 8154ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCShellSetPreSolve_C",(PC,PetscErrorCode (*)(PC,KSP,Vec,Vec)),(pc,presolve));CHKERRQ(ierr); 8167cdd61b2SBarry Smith PetscFunctionReturn(0); 8177cdd61b2SBarry Smith } 8187cdd61b2SBarry Smith 8197cdd61b2SBarry Smith #undef __FUNCT__ 8207cdd61b2SBarry Smith #define __FUNCT__ "PCShellSetPostSolve" 8217cdd61b2SBarry Smith /*@C 8227cdd61b2SBarry Smith PCShellSetPostSolve - Sets routine to apply to the operators/vectors before a KSPSolve() is 8237cdd61b2SBarry Smith applied. This usually does something like scale the linear system in some application 8247cdd61b2SBarry Smith specific way. 8257cdd61b2SBarry Smith 8263f9fe445SBarry Smith Logically Collective on PC 8277cdd61b2SBarry Smith 8287cdd61b2SBarry Smith Input Parameters: 8297cdd61b2SBarry Smith + pc - the preconditioner context 8307cdd61b2SBarry Smith - postsolve - the application-provided presolve routine 8317cdd61b2SBarry Smith 8327cdd61b2SBarry Smith Calling sequence of postsolve: 8337cdd61b2SBarry Smith .vb 8346891c3e4SJed Brown PetscErrorCode postsolve(PC,KSP ksp,Vec b,Vec x) 8357cdd61b2SBarry Smith .ve 8367cdd61b2SBarry Smith 8376891c3e4SJed Brown + pc - the preconditioner, get the application context with PCShellGetContext() 8387cdd61b2SBarry Smith . xin - input vector 8397cdd61b2SBarry Smith - xout - output vector 8407cdd61b2SBarry Smith 8414aa34b0aSBarry Smith Notes: the function MUST return an error code of 0 on success and nonzero on failure. 8424aa34b0aSBarry Smith 8437cdd61b2SBarry Smith Level: developer 8447cdd61b2SBarry Smith 8457cdd61b2SBarry Smith .keywords: PC, shell, set, apply, user-provided 8467cdd61b2SBarry Smith 847be29d3c6SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetPreSolve(), PCShellSetContext() 8487cdd61b2SBarry Smith @*/ 8497087cfbeSBarry Smith PetscErrorCode PCShellSetPostSolve(PC pc,PetscErrorCode (*postsolve)(PC,KSP,Vec,Vec)) 8507cdd61b2SBarry Smith { 8514ac538c5SBarry Smith PetscErrorCode ierr; 8527cdd61b2SBarry Smith 8537cdd61b2SBarry Smith PetscFunctionBegin; 8540700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 8554ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCShellSetPostSolve_C",(PC,PetscErrorCode (*)(PC,KSP,Vec,Vec)),(pc,postsolve));CHKERRQ(ierr); 8567cdd61b2SBarry Smith PetscFunctionReturn(0); 8577cdd61b2SBarry Smith } 8587cdd61b2SBarry Smith 8597cdd61b2SBarry Smith #undef __FUNCT__ 8604b9ad928SBarry Smith #define __FUNCT__ "PCShellSetName" 8614b9ad928SBarry Smith /*@C 8624b9ad928SBarry Smith PCShellSetName - Sets an optional name to associate with a shell 8634b9ad928SBarry Smith preconditioner. 8644b9ad928SBarry Smith 8654b9ad928SBarry Smith Not Collective 8664b9ad928SBarry Smith 8674b9ad928SBarry Smith Input Parameters: 8684b9ad928SBarry Smith + pc - the preconditioner context 8694b9ad928SBarry Smith - name - character string describing shell preconditioner 8704b9ad928SBarry Smith 8714b9ad928SBarry Smith Level: developer 8724b9ad928SBarry Smith 8734b9ad928SBarry Smith .keywords: PC, shell, set, name, user-provided 8744b9ad928SBarry Smith 8754b9ad928SBarry Smith .seealso: PCShellGetName() 8764b9ad928SBarry Smith @*/ 8777087cfbeSBarry Smith PetscErrorCode PCShellSetName(PC pc,const char name[]) 8784b9ad928SBarry Smith { 8794ac538c5SBarry Smith PetscErrorCode ierr; 8804b9ad928SBarry Smith 8814b9ad928SBarry Smith PetscFunctionBegin; 8820700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 8834ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCShellSetName_C",(PC,const char []),(pc,name));CHKERRQ(ierr); 8844b9ad928SBarry Smith PetscFunctionReturn(0); 8854b9ad928SBarry Smith } 8864b9ad928SBarry Smith 8874b9ad928SBarry Smith #undef __FUNCT__ 8884b9ad928SBarry Smith #define __FUNCT__ "PCShellGetName" 8894b9ad928SBarry Smith /*@C 8904b9ad928SBarry Smith PCShellGetName - Gets an optional name that the user has set for a shell 8914b9ad928SBarry Smith preconditioner. 8924b9ad928SBarry Smith 8934b9ad928SBarry Smith Not Collective 8944b9ad928SBarry Smith 8954b9ad928SBarry Smith Input Parameter: 8964b9ad928SBarry Smith . pc - the preconditioner context 8974b9ad928SBarry Smith 8984b9ad928SBarry Smith Output Parameter: 8994b9ad928SBarry Smith . name - character string describing shell preconditioner (you should not free this) 9004b9ad928SBarry Smith 9014b9ad928SBarry Smith Level: developer 9024b9ad928SBarry Smith 9034b9ad928SBarry Smith .keywords: PC, shell, get, name, user-provided 9044b9ad928SBarry Smith 9054b9ad928SBarry Smith .seealso: PCShellSetName() 9064b9ad928SBarry Smith @*/ 907ccaf0856SBarry Smith PetscErrorCode PCShellGetName(PC pc,const char *name[]) 9084b9ad928SBarry Smith { 9094ac538c5SBarry Smith PetscErrorCode ierr; 9104b9ad928SBarry Smith 9114b9ad928SBarry Smith PetscFunctionBegin; 9120700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 9134482741eSBarry Smith PetscValidPointer(name,2); 914ccaf0856SBarry Smith ierr = PetscUseMethod(pc,"PCShellGetName_C",(PC,const char*[]),(pc,name));CHKERRQ(ierr); 9154b9ad928SBarry Smith PetscFunctionReturn(0); 9164b9ad928SBarry Smith } 9174b9ad928SBarry Smith 9184b9ad928SBarry Smith #undef __FUNCT__ 9194b9ad928SBarry Smith #define __FUNCT__ "PCShellSetApplyRichardson" 9204b9ad928SBarry Smith /*@C 9214b9ad928SBarry Smith PCShellSetApplyRichardson - Sets routine to use as preconditioner 9224b9ad928SBarry Smith in Richardson iteration. 9234b9ad928SBarry Smith 9243f9fe445SBarry Smith Logically Collective on PC 9254b9ad928SBarry Smith 9264b9ad928SBarry Smith Input Parameters: 9274b9ad928SBarry Smith + pc - the preconditioner context 928be29d3c6SBarry Smith - apply - the application-provided preconditioning routine 9294b9ad928SBarry Smith 9304b9ad928SBarry Smith Calling sequence of apply: 9314b9ad928SBarry Smith .vb 9326891c3e4SJed Brown PetscErrorCode apply (PC pc,Vec b,Vec x,Vec r,PetscReal rtol,PetscReal abstol,PetscReal dtol,PetscInt maxits) 9334b9ad928SBarry Smith .ve 9344b9ad928SBarry Smith 9356891c3e4SJed Brown + pc - the preconditioner, get the application context with PCShellGetContext() 9364b9ad928SBarry Smith . b - right-hand-side 9374b9ad928SBarry Smith . x - current iterate 9384b9ad928SBarry Smith . r - work space 9394b9ad928SBarry Smith . rtol - relative tolerance of residual norm to stop at 94070441072SBarry Smith . abstol - absolute tolerance of residual norm to stop at 9414b9ad928SBarry Smith . dtol - if residual norm increases by this factor than return 9424b9ad928SBarry Smith - maxits - number of iterations to run 9434b9ad928SBarry Smith 9444aa34b0aSBarry Smith Notes: the function MUST return an error code of 0 on success and nonzero on failure. 9454aa34b0aSBarry Smith 9464b9ad928SBarry Smith Level: developer 9474b9ad928SBarry Smith 9484b9ad928SBarry Smith .keywords: PC, shell, set, apply, Richardson, user-provided 9494b9ad928SBarry Smith 950be29d3c6SBarry Smith .seealso: PCShellSetApply(), PCShellSetContext() 9514b9ad928SBarry Smith @*/ 9527087cfbeSBarry Smith PetscErrorCode PCShellSetApplyRichardson(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec,Vec,PetscReal,PetscReal,PetscReal,PetscInt,PetscBool,PetscInt*,PCRichardsonConvergedReason*)) 9534b9ad928SBarry Smith { 9544ac538c5SBarry Smith PetscErrorCode ierr; 9554b9ad928SBarry Smith 9564b9ad928SBarry Smith PetscFunctionBegin; 9570700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 9584ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCShellSetApplyRichardson_C",(PC,PetscErrorCode (*)(PC,Vec,Vec,Vec,PetscReal,PetscReal,PetscReal,PetscInt,PetscBool,PetscInt*,PCRichardsonConvergedReason*)),(pc,apply));CHKERRQ(ierr); 9594b9ad928SBarry Smith PetscFunctionReturn(0); 9604b9ad928SBarry Smith } 9614b9ad928SBarry Smith 9624b9ad928SBarry Smith /*MC 9634b9ad928SBarry Smith PCSHELL - Creates a new preconditioner class for use with your 9644b9ad928SBarry Smith own private data storage format. 9654b9ad928SBarry Smith 9664b9ad928SBarry Smith Level: advanced 96790198e61SBarry Smith > 9684b9ad928SBarry Smith Concepts: providing your own preconditioner 9694b9ad928SBarry Smith 9704b9ad928SBarry Smith Usage: 9716891c3e4SJed Brown $ extern PetscErrorCode apply(PC,Vec,Vec); 9726891c3e4SJed Brown $ extern PetscErrorCode applyba(PC,PCSide,Vec,Vec,Vec); 9736891c3e4SJed Brown $ extern PetscErrorCode applytranspose(PC,Vec,Vec); 9746891c3e4SJed Brown $ extern PetscErrorCode setup(PC); 9756891c3e4SJed Brown $ extern PetscErrorCode destroy(PC); 9766891c3e4SJed Brown $ 9774b9ad928SBarry Smith $ PCCreate(comm,&pc); 9784b9ad928SBarry Smith $ PCSetType(pc,PCSHELL); 979be29d3c6SBarry Smith $ PCShellSetContext(pc,ctx) 9806891c3e4SJed Brown $ PCShellSetApply(pc,apply); 9816891c3e4SJed Brown $ PCShellSetApplyBA(pc,applyba); (optional) 9826891c3e4SJed Brown $ PCShellSetApplyTranspose(pc,applytranspose); (optional) 9834b9ad928SBarry Smith $ PCShellSetSetUp(pc,setup); (optional) 984d01c8aa3SLisandro Dalcin $ PCShellSetDestroy(pc,destroy); (optional) 9854b9ad928SBarry Smith 9864b9ad928SBarry Smith .seealso: PCCreate(), PCSetType(), PCType (for list of available types), PC, 987fd2d0fe1Svictor MATSHELL, PCShellSetSetUp(), PCShellSetApply(), PCShellSetView(), 988fd2d0fe1Svictor PCShellSetApplyTranspose(), PCShellSetName(), PCShellSetApplyRichardson(), 9892bb17772SBarry Smith PCShellGetName(), PCShellSetContext(), PCShellGetContext(), PCShellSetApplyBA() 9904b9ad928SBarry Smith M*/ 9914b9ad928SBarry Smith 9924b9ad928SBarry Smith #undef __FUNCT__ 9934b9ad928SBarry Smith #define __FUNCT__ "PCCreate_Shell" 9948cc058d9SJed Brown PETSC_EXTERN PetscErrorCode PCCreate_Shell(PC pc) 9954b9ad928SBarry Smith { 996dfbe8321SBarry Smith PetscErrorCode ierr; 9974b9ad928SBarry Smith PC_Shell *shell; 9984b9ad928SBarry Smith 9994b9ad928SBarry Smith PetscFunctionBegin; 1000b00a9115SJed Brown ierr = PetscNewLog(pc,&shell);CHKERRQ(ierr); 10014b9ad928SBarry Smith pc->data = (void*)shell; 10024b9ad928SBarry Smith 1003d01c8aa3SLisandro Dalcin pc->ops->destroy = PCDestroy_Shell; 10044b9ad928SBarry Smith pc->ops->view = PCView_Shell; 1005d01c8aa3SLisandro Dalcin pc->ops->apply = PCApply_Shell; 10061b581b66SBarry Smith pc->ops->applysymmetricleft = PCApplySymmetricLeft_Shell; 10071b581b66SBarry Smith pc->ops->applysymmetricright = PCApplySymmetricRight_Shell; 1008d01c8aa3SLisandro Dalcin pc->ops->applytranspose = 0; 10094b9ad928SBarry Smith pc->ops->applyrichardson = 0; 1010d01c8aa3SLisandro Dalcin pc->ops->setup = 0; 10119bbb2c88SBarry Smith pc->ops->presolve = 0; 10129bbb2c88SBarry Smith pc->ops->postsolve = 0; 10134b9ad928SBarry Smith 10144b9ad928SBarry Smith shell->apply = 0; 10154b9ad928SBarry Smith shell->applytranspose = 0; 10164b9ad928SBarry Smith shell->name = 0; 10174b9ad928SBarry Smith shell->applyrich = 0; 10187cdd61b2SBarry Smith shell->presolve = 0; 10197cdd61b2SBarry Smith shell->postsolve = 0; 10204b9ad928SBarry Smith shell->ctx = 0; 10214b9ad928SBarry Smith shell->setup = 0; 10224b9ad928SBarry Smith shell->view = 0; 102318be62a5SSatish Balay shell->destroy = 0; 10241b581b66SBarry Smith shell->applysymmetricleft = 0; 10251b581b66SBarry Smith shell->applysymmetricright = 0; 10264b9ad928SBarry Smith 1027bdf89e91SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetDestroy_C",PCShellSetDestroy_Shell);CHKERRQ(ierr); 1028bdf89e91SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetSetUp_C",PCShellSetSetUp_Shell);CHKERRQ(ierr); 1029bdf89e91SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApply_C",PCShellSetApply_Shell);CHKERRQ(ierr); 10301b581b66SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplySymmetricLeft_C",PCShellSetApplySymmetricLeft_Shell);CHKERRQ(ierr); 10311b581b66SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplySymmetricRight_C",PCShellSetApplySymmetricRight_Shell);CHKERRQ(ierr); 1032bdf89e91SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplyBA_C",PCShellSetApplyBA_Shell);CHKERRQ(ierr); 1033bdf89e91SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetPreSolve_C",PCShellSetPreSolve_Shell);CHKERRQ(ierr); 1034bdf89e91SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetPostSolve_C",PCShellSetPostSolve_Shell);CHKERRQ(ierr); 1035bdf89e91SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetView_C",PCShellSetView_Shell);CHKERRQ(ierr); 1036bdf89e91SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplyTranspose_C",PCShellSetApplyTranspose_Shell);CHKERRQ(ierr); 1037bdf89e91SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetName_C",PCShellSetName_Shell);CHKERRQ(ierr); 1038bdf89e91SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellGetName_C",PCShellGetName_Shell);CHKERRQ(ierr); 1039bdf89e91SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplyRichardson_C",PCShellSetApplyRichardson_Shell);CHKERRQ(ierr); 10404b9ad928SBarry Smith PetscFunctionReturn(0); 10414b9ad928SBarry Smith } 10424b9ad928SBarry Smith 10434b9ad928SBarry Smith 10444b9ad928SBarry Smith 10454b9ad928SBarry Smith 10464b9ad928SBarry Smith 10474b9ad928SBarry Smith 1048