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__ 180*a06fd7f2SStefano Zampini #define __FUNCT__ "PCPreSolveChangeRHS_Shell" 181*a06fd7f2SStefano Zampini static PetscErrorCode PCPreSolveChangeRHS_Shell(PC pc,PetscBool* change) 182*a06fd7f2SStefano Zampini { 183*a06fd7f2SStefano Zampini PetscFunctionBegin; 184*a06fd7f2SStefano Zampini *change = PETSC_TRUE; 185*a06fd7f2SStefano Zampini PetscFunctionReturn(0); 186*a06fd7f2SStefano Zampini } 187*a06fd7f2SStefano Zampini 188*a06fd7f2SStefano 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)); 264*a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetDestroy_C",NULL);CHKERRQ(ierr); 265*a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetSetUp_C",NULL);CHKERRQ(ierr); 266*a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApply_C",NULL);CHKERRQ(ierr); 267*a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplySymmetricLeft_C",NULL);CHKERRQ(ierr); 268*a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplySymmetricRight_C",NULL);CHKERRQ(ierr); 269*a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplyBA_C",NULL);CHKERRQ(ierr); 270*a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetPreSolve_C",NULL);CHKERRQ(ierr); 271*a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetPostSolve_C",NULL);CHKERRQ(ierr); 272*a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetView_C",NULL);CHKERRQ(ierr); 273*a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplyTranspose_C",NULL);CHKERRQ(ierr); 274*a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetName_C",NULL);CHKERRQ(ierr); 275*a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellGetName_C",NULL);CHKERRQ(ierr); 276*a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplyRichardson_C",NULL);CHKERRQ(ierr); 277*a06fd7f2SStefano 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; 383*a06fd7f2SStefano Zampini PetscErrorCode ierr; 3847cdd61b2SBarry Smith 3857cdd61b2SBarry Smith PetscFunctionBegin; 3867cdd61b2SBarry Smith shell->presolve = presolve; 387*a06fd7f2SStefano Zampini if (presolve) { 388*a06fd7f2SStefano Zampini pc->ops->presolve = PCPreSolve_Shell; 389*a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCPreSolveChangeRHS_C",PCPreSolveChangeRHS_Shell);CHKERRQ(ierr); 390*a06fd7f2SStefano Zampini } else { 391*a06fd7f2SStefano Zampini pc->ops->presolve = 0; 392*a06fd7f2SStefano Zampini ierr = PetscObjectComposeFunction((PetscObject)pc,"PCPreSolveChangeRHS_C",NULL);CHKERRQ(ierr); 393*a06fd7f2SStefano 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 608292fb18eSBarry Smith Developer Notes: There should also be a PCShellSetApplySymmetricRight() and PCShellSetApplySymmetricLeft(). 609292fb18eSBarry Smith 6104b9ad928SBarry Smith Level: developer 6114b9ad928SBarry Smith 6124b9ad928SBarry Smith .keywords: PC, shell, set, apply, user-provided 6134b9ad928SBarry Smith 6142bb17772SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetContext(), PCShellSetApplyBA() 6154b9ad928SBarry Smith @*/ 6167087cfbeSBarry Smith PetscErrorCode PCShellSetApply(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec)) 6174b9ad928SBarry Smith { 6184ac538c5SBarry Smith PetscErrorCode ierr; 6194b9ad928SBarry Smith 6204b9ad928SBarry Smith PetscFunctionBegin; 6210700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 6224ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCShellSetApply_C",(PC,PetscErrorCode (*)(PC,Vec,Vec)),(pc,apply));CHKERRQ(ierr); 6234b9ad928SBarry Smith PetscFunctionReturn(0); 6244b9ad928SBarry Smith } 6254b9ad928SBarry Smith 6264b9ad928SBarry Smith #undef __FUNCT__ 6271b581b66SBarry Smith #define __FUNCT__ "PCShellSetApplySymmetricLeft" 6281b581b66SBarry Smith /*@C 6291b581b66SBarry Smith PCShellSetApplySymmetricLeft - Sets routine to use as left preconditioner (when the PC_SYMMETRIC is used). 6301b581b66SBarry Smith 6311b581b66SBarry Smith Logically Collective on PC 6321b581b66SBarry Smith 6331b581b66SBarry Smith Input Parameters: 6341b581b66SBarry Smith + pc - the preconditioner context 6351b581b66SBarry Smith - apply - the application-provided left preconditioning routine 6361b581b66SBarry Smith 6371b581b66SBarry Smith Calling sequence of apply: 6381b581b66SBarry Smith .vb 6391b581b66SBarry Smith PetscErrorCode apply (PC pc,Vec xin,Vec xout) 6401b581b66SBarry Smith .ve 6411b581b66SBarry Smith 6421b581b66SBarry Smith + pc - the preconditioner, get the application context with PCShellGetContext() 6431b581b66SBarry Smith . xin - input vector 6441b581b66SBarry Smith - xout - output vector 6451b581b66SBarry Smith 6461b581b66SBarry Smith Notes: the function MUST return an error code of 0 on success and nonzero on failure. 6471b581b66SBarry Smith 6481b581b66SBarry Smith Level: developer 6491b581b66SBarry Smith 6501b581b66SBarry Smith .keywords: PC, shell, set, apply, user-provided 6511b581b66SBarry Smith 6521b581b66SBarry Smith .seealso: PCShellSetApply(), PCShellSetApplySymmetricLeft(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetContext() 6531b581b66SBarry Smith @*/ 6541b581b66SBarry Smith PetscErrorCode PCShellSetApplySymmetricLeft(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec)) 6551b581b66SBarry Smith { 6561b581b66SBarry Smith PetscErrorCode ierr; 6571b581b66SBarry Smith 6581b581b66SBarry Smith PetscFunctionBegin; 6591b581b66SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 6601b581b66SBarry Smith ierr = PetscTryMethod(pc,"PCShellSetApplySymmetricLeft_C",(PC,PetscErrorCode (*)(PC,Vec,Vec)),(pc,apply));CHKERRQ(ierr); 6611b581b66SBarry Smith PetscFunctionReturn(0); 6621b581b66SBarry Smith } 6631b581b66SBarry Smith 6641b581b66SBarry Smith #undef __FUNCT__ 6651b581b66SBarry Smith #define __FUNCT__ "PCShellSetApplySymmetricRight" 6661b581b66SBarry Smith /*@C 6671b581b66SBarry Smith PCShellSetApply - Sets routine to use as right preconditioner (when the PC_SYMMETRIC is used). 6681b581b66SBarry Smith 6691b581b66SBarry Smith Logically Collective on PC 6701b581b66SBarry Smith 6711b581b66SBarry Smith Input Parameters: 6721b581b66SBarry Smith + pc - the preconditioner context 6731b581b66SBarry Smith - apply - the application-provided right preconditioning routine 6741b581b66SBarry Smith 6751b581b66SBarry Smith Calling sequence of apply: 6761b581b66SBarry Smith .vb 6771b581b66SBarry Smith PetscErrorCode apply (PC pc,Vec xin,Vec xout) 6781b581b66SBarry Smith .ve 6791b581b66SBarry Smith 6801b581b66SBarry Smith + pc - the preconditioner, get the application context with PCShellGetContext() 6811b581b66SBarry Smith . xin - input vector 6821b581b66SBarry Smith - xout - output vector 6831b581b66SBarry Smith 6841b581b66SBarry Smith Notes: the function MUST return an error code of 0 on success and nonzero on failure. 6851b581b66SBarry Smith 6861b581b66SBarry Smith Level: developer 6871b581b66SBarry Smith 6881b581b66SBarry Smith .keywords: PC, shell, set, apply, user-provided 6891b581b66SBarry Smith 6901b581b66SBarry Smith .seealso: PCShellSetApply(), PCShellSetApplySymmetricLeft(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetContext() 6911b581b66SBarry Smith @*/ 6921b581b66SBarry Smith PetscErrorCode PCShellSetApplySymmetricRight(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec)) 6931b581b66SBarry Smith { 6941b581b66SBarry Smith PetscErrorCode ierr; 6951b581b66SBarry Smith 6961b581b66SBarry Smith PetscFunctionBegin; 6971b581b66SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 6981b581b66SBarry Smith ierr = PetscTryMethod(pc,"PCShellSetApplySymmetricRight_C",(PC,PetscErrorCode (*)(PC,Vec,Vec)),(pc,apply));CHKERRQ(ierr); 6991b581b66SBarry Smith PetscFunctionReturn(0); 7001b581b66SBarry Smith } 7011b581b66SBarry Smith 7021b581b66SBarry Smith #undef __FUNCT__ 7032bb17772SBarry Smith #define __FUNCT__ "PCShellSetApplyBA" 7042bb17772SBarry Smith /*@C 7052bb17772SBarry Smith PCShellSetApplyBA - Sets routine to use as preconditioner times operator. 7062bb17772SBarry Smith 7073f9fe445SBarry Smith Logically Collective on PC 7082bb17772SBarry Smith 7092bb17772SBarry Smith Input Parameters: 7102bb17772SBarry Smith + pc - the preconditioner context 7112bb17772SBarry Smith - applyBA - the application-provided BA routine 7122bb17772SBarry Smith 7132bb17772SBarry Smith Calling sequence of apply: 7142bb17772SBarry Smith .vb 7156891c3e4SJed Brown PetscErrorCode applyBA (PC pc,Vec xin,Vec xout) 7162bb17772SBarry Smith .ve 7172bb17772SBarry Smith 7186891c3e4SJed Brown + pc - the preconditioner, get the application context with PCShellGetContext() 7192bb17772SBarry Smith . xin - input vector 7202bb17772SBarry Smith - xout - output vector 7212bb17772SBarry Smith 7224aa34b0aSBarry Smith Notes: the function MUST return an error code of 0 on success and nonzero on failure. 7234aa34b0aSBarry Smith 7242bb17772SBarry Smith Level: developer 7252bb17772SBarry Smith 7262bb17772SBarry Smith .keywords: PC, shell, set, apply, user-provided 7272bb17772SBarry Smith 7282bb17772SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetContext(), PCShellSetApply() 7292bb17772SBarry Smith @*/ 7307087cfbeSBarry Smith PetscErrorCode PCShellSetApplyBA(PC pc,PetscErrorCode (*applyBA)(PC,PCSide,Vec,Vec,Vec)) 7312bb17772SBarry Smith { 7324ac538c5SBarry Smith PetscErrorCode ierr; 7332bb17772SBarry Smith 7342bb17772SBarry Smith PetscFunctionBegin; 7350700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 7364ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCShellSetApplyBA_C",(PC,PetscErrorCode (*)(PC,PCSide,Vec,Vec,Vec)),(pc,applyBA));CHKERRQ(ierr); 7372bb17772SBarry Smith PetscFunctionReturn(0); 7382bb17772SBarry Smith } 7392bb17772SBarry Smith 7402bb17772SBarry Smith #undef __FUNCT__ 7414b9ad928SBarry Smith #define __FUNCT__ "PCShellSetApplyTranspose" 7424b9ad928SBarry Smith /*@C 7434b9ad928SBarry Smith PCShellSetApplyTranspose - Sets routine to use as preconditioner transpose. 7444b9ad928SBarry Smith 7453f9fe445SBarry Smith Logically Collective on PC 7464b9ad928SBarry Smith 7474b9ad928SBarry Smith Input Parameters: 7484b9ad928SBarry Smith + pc - the preconditioner context 7494b9ad928SBarry Smith - apply - the application-provided preconditioning transpose routine 7504b9ad928SBarry Smith 7514b9ad928SBarry Smith Calling sequence of apply: 7524b9ad928SBarry Smith .vb 7536891c3e4SJed Brown PetscErrorCode applytranspose (PC pc,Vec xin,Vec xout) 7544b9ad928SBarry Smith .ve 7554b9ad928SBarry Smith 7566891c3e4SJed Brown + pc - the preconditioner, get the application context with PCShellGetContext() 7574b9ad928SBarry Smith . xin - input vector 7584b9ad928SBarry Smith - xout - output vector 7594b9ad928SBarry Smith 7604aa34b0aSBarry Smith Notes: the function MUST return an error code of 0 on success and nonzero on failure. 7614aa34b0aSBarry Smith 7624b9ad928SBarry Smith Level: developer 7634b9ad928SBarry Smith 7644b9ad928SBarry Smith Notes: 7654b9ad928SBarry Smith Uses the same context variable as PCShellSetApply(). 7664b9ad928SBarry Smith 7674b9ad928SBarry Smith .keywords: PC, shell, set, apply, user-provided 7684b9ad928SBarry Smith 7692bb17772SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApply(), PCSetContext(), PCShellSetApplyBA() 7704b9ad928SBarry Smith @*/ 7717087cfbeSBarry Smith PetscErrorCode PCShellSetApplyTranspose(PC pc,PetscErrorCode (*applytranspose)(PC,Vec,Vec)) 7724b9ad928SBarry Smith { 7734ac538c5SBarry Smith PetscErrorCode ierr; 7744b9ad928SBarry Smith 7754b9ad928SBarry Smith PetscFunctionBegin; 7760700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 7774ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCShellSetApplyTranspose_C",(PC,PetscErrorCode (*)(PC,Vec,Vec)),(pc,applytranspose));CHKERRQ(ierr); 7784b9ad928SBarry Smith PetscFunctionReturn(0); 7794b9ad928SBarry Smith } 7804b9ad928SBarry Smith 7814b9ad928SBarry Smith #undef __FUNCT__ 7827cdd61b2SBarry Smith #define __FUNCT__ "PCShellSetPreSolve" 7837cdd61b2SBarry Smith /*@C 7847cdd61b2SBarry Smith PCShellSetPreSolve - Sets routine to apply to the operators/vectors before a KSPSolve() is 7857cdd61b2SBarry Smith applied. This usually does something like scale the linear system in some application 7867cdd61b2SBarry Smith specific way. 7877cdd61b2SBarry Smith 7883f9fe445SBarry Smith Logically Collective on PC 7897cdd61b2SBarry Smith 7907cdd61b2SBarry Smith Input Parameters: 7917cdd61b2SBarry Smith + pc - the preconditioner context 7927cdd61b2SBarry Smith - presolve - the application-provided presolve routine 7937cdd61b2SBarry Smith 7947cdd61b2SBarry Smith Calling sequence of presolve: 7957cdd61b2SBarry Smith .vb 7966891c3e4SJed Brown PetscErrorCode presolve (PC,KSP ksp,Vec b,Vec x) 7977cdd61b2SBarry Smith .ve 7987cdd61b2SBarry Smith 7996891c3e4SJed Brown + pc - the preconditioner, get the application context with PCShellGetContext() 8007cdd61b2SBarry Smith . xin - input vector 8017cdd61b2SBarry Smith - xout - output vector 8027cdd61b2SBarry Smith 8034aa34b0aSBarry Smith Notes: the function MUST return an error code of 0 on success and nonzero on failure. 8044aa34b0aSBarry Smith 8057cdd61b2SBarry Smith Level: developer 8067cdd61b2SBarry Smith 8077cdd61b2SBarry Smith .keywords: PC, shell, set, apply, user-provided 8087cdd61b2SBarry Smith 809be29d3c6SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetPostSolve(), PCShellSetContext() 8107cdd61b2SBarry Smith @*/ 8117087cfbeSBarry Smith PetscErrorCode PCShellSetPreSolve(PC pc,PetscErrorCode (*presolve)(PC,KSP,Vec,Vec)) 8127cdd61b2SBarry Smith { 8134ac538c5SBarry Smith PetscErrorCode ierr; 8147cdd61b2SBarry Smith 8157cdd61b2SBarry Smith PetscFunctionBegin; 8160700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 8174ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCShellSetPreSolve_C",(PC,PetscErrorCode (*)(PC,KSP,Vec,Vec)),(pc,presolve));CHKERRQ(ierr); 8187cdd61b2SBarry Smith PetscFunctionReturn(0); 8197cdd61b2SBarry Smith } 8207cdd61b2SBarry Smith 8217cdd61b2SBarry Smith #undef __FUNCT__ 8227cdd61b2SBarry Smith #define __FUNCT__ "PCShellSetPostSolve" 8237cdd61b2SBarry Smith /*@C 8247cdd61b2SBarry Smith PCShellSetPostSolve - Sets routine to apply to the operators/vectors before a KSPSolve() is 8257cdd61b2SBarry Smith applied. This usually does something like scale the linear system in some application 8267cdd61b2SBarry Smith specific way. 8277cdd61b2SBarry Smith 8283f9fe445SBarry Smith Logically Collective on PC 8297cdd61b2SBarry Smith 8307cdd61b2SBarry Smith Input Parameters: 8317cdd61b2SBarry Smith + pc - the preconditioner context 8327cdd61b2SBarry Smith - postsolve - the application-provided presolve routine 8337cdd61b2SBarry Smith 8347cdd61b2SBarry Smith Calling sequence of postsolve: 8357cdd61b2SBarry Smith .vb 8366891c3e4SJed Brown PetscErrorCode postsolve(PC,KSP ksp,Vec b,Vec x) 8377cdd61b2SBarry Smith .ve 8387cdd61b2SBarry Smith 8396891c3e4SJed Brown + pc - the preconditioner, get the application context with PCShellGetContext() 8407cdd61b2SBarry Smith . xin - input vector 8417cdd61b2SBarry Smith - xout - output vector 8427cdd61b2SBarry Smith 8434aa34b0aSBarry Smith Notes: the function MUST return an error code of 0 on success and nonzero on failure. 8444aa34b0aSBarry Smith 8457cdd61b2SBarry Smith Level: developer 8467cdd61b2SBarry Smith 8477cdd61b2SBarry Smith .keywords: PC, shell, set, apply, user-provided 8487cdd61b2SBarry Smith 849be29d3c6SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetPreSolve(), PCShellSetContext() 8507cdd61b2SBarry Smith @*/ 8517087cfbeSBarry Smith PetscErrorCode PCShellSetPostSolve(PC pc,PetscErrorCode (*postsolve)(PC,KSP,Vec,Vec)) 8527cdd61b2SBarry Smith { 8534ac538c5SBarry Smith PetscErrorCode ierr; 8547cdd61b2SBarry Smith 8557cdd61b2SBarry Smith PetscFunctionBegin; 8560700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 8574ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCShellSetPostSolve_C",(PC,PetscErrorCode (*)(PC,KSP,Vec,Vec)),(pc,postsolve));CHKERRQ(ierr); 8587cdd61b2SBarry Smith PetscFunctionReturn(0); 8597cdd61b2SBarry Smith } 8607cdd61b2SBarry Smith 8617cdd61b2SBarry Smith #undef __FUNCT__ 8624b9ad928SBarry Smith #define __FUNCT__ "PCShellSetName" 8634b9ad928SBarry Smith /*@C 8644b9ad928SBarry Smith PCShellSetName - Sets an optional name to associate with a shell 8654b9ad928SBarry Smith preconditioner. 8664b9ad928SBarry Smith 8674b9ad928SBarry Smith Not Collective 8684b9ad928SBarry Smith 8694b9ad928SBarry Smith Input Parameters: 8704b9ad928SBarry Smith + pc - the preconditioner context 8714b9ad928SBarry Smith - name - character string describing shell preconditioner 8724b9ad928SBarry Smith 8734b9ad928SBarry Smith Level: developer 8744b9ad928SBarry Smith 8754b9ad928SBarry Smith .keywords: PC, shell, set, name, user-provided 8764b9ad928SBarry Smith 8774b9ad928SBarry Smith .seealso: PCShellGetName() 8784b9ad928SBarry Smith @*/ 8797087cfbeSBarry Smith PetscErrorCode PCShellSetName(PC pc,const char name[]) 8804b9ad928SBarry Smith { 8814ac538c5SBarry Smith PetscErrorCode ierr; 8824b9ad928SBarry Smith 8834b9ad928SBarry Smith PetscFunctionBegin; 8840700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 8854ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCShellSetName_C",(PC,const char []),(pc,name));CHKERRQ(ierr); 8864b9ad928SBarry Smith PetscFunctionReturn(0); 8874b9ad928SBarry Smith } 8884b9ad928SBarry Smith 8894b9ad928SBarry Smith #undef __FUNCT__ 8904b9ad928SBarry Smith #define __FUNCT__ "PCShellGetName" 8914b9ad928SBarry Smith /*@C 8924b9ad928SBarry Smith PCShellGetName - Gets an optional name that the user has set for a shell 8934b9ad928SBarry Smith preconditioner. 8944b9ad928SBarry Smith 8954b9ad928SBarry Smith Not Collective 8964b9ad928SBarry Smith 8974b9ad928SBarry Smith Input Parameter: 8984b9ad928SBarry Smith . pc - the preconditioner context 8994b9ad928SBarry Smith 9004b9ad928SBarry Smith Output Parameter: 9014b9ad928SBarry Smith . name - character string describing shell preconditioner (you should not free this) 9024b9ad928SBarry Smith 9034b9ad928SBarry Smith Level: developer 9044b9ad928SBarry Smith 9054b9ad928SBarry Smith .keywords: PC, shell, get, name, user-provided 9064b9ad928SBarry Smith 9074b9ad928SBarry Smith .seealso: PCShellSetName() 9084b9ad928SBarry Smith @*/ 909ccaf0856SBarry Smith PetscErrorCode PCShellGetName(PC pc,const char *name[]) 9104b9ad928SBarry Smith { 9114ac538c5SBarry Smith PetscErrorCode ierr; 9124b9ad928SBarry Smith 9134b9ad928SBarry Smith PetscFunctionBegin; 9140700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 9154482741eSBarry Smith PetscValidPointer(name,2); 916ccaf0856SBarry Smith ierr = PetscUseMethod(pc,"PCShellGetName_C",(PC,const char*[]),(pc,name));CHKERRQ(ierr); 9174b9ad928SBarry Smith PetscFunctionReturn(0); 9184b9ad928SBarry Smith } 9194b9ad928SBarry Smith 9204b9ad928SBarry Smith #undef __FUNCT__ 9214b9ad928SBarry Smith #define __FUNCT__ "PCShellSetApplyRichardson" 9224b9ad928SBarry Smith /*@C 9234b9ad928SBarry Smith PCShellSetApplyRichardson - Sets routine to use as preconditioner 9244b9ad928SBarry Smith in Richardson iteration. 9254b9ad928SBarry Smith 9263f9fe445SBarry Smith Logically Collective on PC 9274b9ad928SBarry Smith 9284b9ad928SBarry Smith Input Parameters: 9294b9ad928SBarry Smith + pc - the preconditioner context 930be29d3c6SBarry Smith - apply - the application-provided preconditioning routine 9314b9ad928SBarry Smith 9324b9ad928SBarry Smith Calling sequence of apply: 9334b9ad928SBarry Smith .vb 9346891c3e4SJed Brown PetscErrorCode apply (PC pc,Vec b,Vec x,Vec r,PetscReal rtol,PetscReal abstol,PetscReal dtol,PetscInt maxits) 9354b9ad928SBarry Smith .ve 9364b9ad928SBarry Smith 9376891c3e4SJed Brown + pc - the preconditioner, get the application context with PCShellGetContext() 9384b9ad928SBarry Smith . b - right-hand-side 9394b9ad928SBarry Smith . x - current iterate 9404b9ad928SBarry Smith . r - work space 9414b9ad928SBarry Smith . rtol - relative tolerance of residual norm to stop at 94270441072SBarry Smith . abstol - absolute tolerance of residual norm to stop at 9434b9ad928SBarry Smith . dtol - if residual norm increases by this factor than return 9444b9ad928SBarry Smith - maxits - number of iterations to run 9454b9ad928SBarry Smith 9464aa34b0aSBarry Smith Notes: the function MUST return an error code of 0 on success and nonzero on failure. 9474aa34b0aSBarry Smith 9484b9ad928SBarry Smith Level: developer 9494b9ad928SBarry Smith 9504b9ad928SBarry Smith .keywords: PC, shell, set, apply, Richardson, user-provided 9514b9ad928SBarry Smith 952be29d3c6SBarry Smith .seealso: PCShellSetApply(), PCShellSetContext() 9534b9ad928SBarry Smith @*/ 9547087cfbeSBarry Smith PetscErrorCode PCShellSetApplyRichardson(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec,Vec,PetscReal,PetscReal,PetscReal,PetscInt,PetscBool,PetscInt*,PCRichardsonConvergedReason*)) 9554b9ad928SBarry Smith { 9564ac538c5SBarry Smith PetscErrorCode ierr; 9574b9ad928SBarry Smith 9584b9ad928SBarry Smith PetscFunctionBegin; 9590700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 9604ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCShellSetApplyRichardson_C",(PC,PetscErrorCode (*)(PC,Vec,Vec,Vec,PetscReal,PetscReal,PetscReal,PetscInt,PetscBool,PetscInt*,PCRichardsonConvergedReason*)),(pc,apply));CHKERRQ(ierr); 9614b9ad928SBarry Smith PetscFunctionReturn(0); 9624b9ad928SBarry Smith } 9634b9ad928SBarry Smith 9644b9ad928SBarry Smith /*MC 9654b9ad928SBarry Smith PCSHELL - Creates a new preconditioner class for use with your 9664b9ad928SBarry Smith own private data storage format. 9674b9ad928SBarry Smith 9684b9ad928SBarry Smith Level: advanced 96990198e61SBarry Smith > 9704b9ad928SBarry Smith Concepts: providing your own preconditioner 9714b9ad928SBarry Smith 9724b9ad928SBarry Smith Usage: 9736891c3e4SJed Brown $ extern PetscErrorCode apply(PC,Vec,Vec); 9746891c3e4SJed Brown $ extern PetscErrorCode applyba(PC,PCSide,Vec,Vec,Vec); 9756891c3e4SJed Brown $ extern PetscErrorCode applytranspose(PC,Vec,Vec); 9766891c3e4SJed Brown $ extern PetscErrorCode setup(PC); 9776891c3e4SJed Brown $ extern PetscErrorCode destroy(PC); 9786891c3e4SJed Brown $ 9794b9ad928SBarry Smith $ PCCreate(comm,&pc); 9804b9ad928SBarry Smith $ PCSetType(pc,PCSHELL); 981be29d3c6SBarry Smith $ PCShellSetContext(pc,ctx) 9826891c3e4SJed Brown $ PCShellSetApply(pc,apply); 9836891c3e4SJed Brown $ PCShellSetApplyBA(pc,applyba); (optional) 9846891c3e4SJed Brown $ PCShellSetApplyTranspose(pc,applytranspose); (optional) 9854b9ad928SBarry Smith $ PCShellSetSetUp(pc,setup); (optional) 986d01c8aa3SLisandro Dalcin $ PCShellSetDestroy(pc,destroy); (optional) 9874b9ad928SBarry Smith 9884b9ad928SBarry Smith .seealso: PCCreate(), PCSetType(), PCType (for list of available types), PC, 989fd2d0fe1Svictor MATSHELL, PCShellSetSetUp(), PCShellSetApply(), PCShellSetView(), 990fd2d0fe1Svictor PCShellSetApplyTranspose(), PCShellSetName(), PCShellSetApplyRichardson(), 9912bb17772SBarry Smith PCShellGetName(), PCShellSetContext(), PCShellGetContext(), PCShellSetApplyBA() 9924b9ad928SBarry Smith M*/ 9934b9ad928SBarry Smith 9944b9ad928SBarry Smith #undef __FUNCT__ 9954b9ad928SBarry Smith #define __FUNCT__ "PCCreate_Shell" 9968cc058d9SJed Brown PETSC_EXTERN PetscErrorCode PCCreate_Shell(PC pc) 9974b9ad928SBarry Smith { 998dfbe8321SBarry Smith PetscErrorCode ierr; 9994b9ad928SBarry Smith PC_Shell *shell; 10004b9ad928SBarry Smith 10014b9ad928SBarry Smith PetscFunctionBegin; 1002b00a9115SJed Brown ierr = PetscNewLog(pc,&shell);CHKERRQ(ierr); 10034b9ad928SBarry Smith pc->data = (void*)shell; 10044b9ad928SBarry Smith 1005d01c8aa3SLisandro Dalcin pc->ops->destroy = PCDestroy_Shell; 10064b9ad928SBarry Smith pc->ops->view = PCView_Shell; 1007d01c8aa3SLisandro Dalcin pc->ops->apply = PCApply_Shell; 10081b581b66SBarry Smith pc->ops->applysymmetricleft = PCApplySymmetricLeft_Shell; 10091b581b66SBarry Smith pc->ops->applysymmetricright = PCApplySymmetricRight_Shell; 1010d01c8aa3SLisandro Dalcin pc->ops->applytranspose = 0; 10114b9ad928SBarry Smith pc->ops->applyrichardson = 0; 1012d01c8aa3SLisandro Dalcin pc->ops->setup = 0; 10139bbb2c88SBarry Smith pc->ops->presolve = 0; 10149bbb2c88SBarry Smith pc->ops->postsolve = 0; 10154b9ad928SBarry Smith 10164b9ad928SBarry Smith shell->apply = 0; 10174b9ad928SBarry Smith shell->applytranspose = 0; 10184b9ad928SBarry Smith shell->name = 0; 10194b9ad928SBarry Smith shell->applyrich = 0; 10207cdd61b2SBarry Smith shell->presolve = 0; 10217cdd61b2SBarry Smith shell->postsolve = 0; 10224b9ad928SBarry Smith shell->ctx = 0; 10234b9ad928SBarry Smith shell->setup = 0; 10244b9ad928SBarry Smith shell->view = 0; 102518be62a5SSatish Balay shell->destroy = 0; 10261b581b66SBarry Smith shell->applysymmetricleft = 0; 10271b581b66SBarry Smith shell->applysymmetricright = 0; 10284b9ad928SBarry Smith 1029bdf89e91SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetDestroy_C",PCShellSetDestroy_Shell);CHKERRQ(ierr); 1030bdf89e91SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetSetUp_C",PCShellSetSetUp_Shell);CHKERRQ(ierr); 1031bdf89e91SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApply_C",PCShellSetApply_Shell);CHKERRQ(ierr); 10321b581b66SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplySymmetricLeft_C",PCShellSetApplySymmetricLeft_Shell);CHKERRQ(ierr); 10331b581b66SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplySymmetricRight_C",PCShellSetApplySymmetricRight_Shell);CHKERRQ(ierr); 1034bdf89e91SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplyBA_C",PCShellSetApplyBA_Shell);CHKERRQ(ierr); 1035bdf89e91SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetPreSolve_C",PCShellSetPreSolve_Shell);CHKERRQ(ierr); 1036bdf89e91SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetPostSolve_C",PCShellSetPostSolve_Shell);CHKERRQ(ierr); 1037bdf89e91SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetView_C",PCShellSetView_Shell);CHKERRQ(ierr); 1038bdf89e91SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplyTranspose_C",PCShellSetApplyTranspose_Shell);CHKERRQ(ierr); 1039bdf89e91SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetName_C",PCShellSetName_Shell);CHKERRQ(ierr); 1040bdf89e91SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellGetName_C",PCShellGetName_Shell);CHKERRQ(ierr); 1041bdf89e91SBarry Smith ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplyRichardson_C",PCShellSetApplyRichardson_Shell);CHKERRQ(ierr); 10424b9ad928SBarry Smith PetscFunctionReturn(0); 10434b9ad928SBarry Smith } 10444b9ad928SBarry Smith 10454b9ad928SBarry Smith 10464b9ad928SBarry Smith 10474b9ad928SBarry Smith 10484b9ad928SBarry Smith 10494b9ad928SBarry Smith 1050