xref: /petsc/src/ksp/pc/impls/shell/shellpc.c (revision 2c71b3e237ead271e4f3aa1505f92bf476e3413d)
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*/
84b9ad928SBarry Smith 
94b9ad928SBarry Smith typedef struct {
10be29d3c6SBarry Smith   void *ctx;                     /* user provided contexts for preconditioner */
112fa5cd67SKarl Rupp 
126891c3e4SJed Brown   PetscErrorCode (*destroy)(PC);
136891c3e4SJed Brown   PetscErrorCode (*setup)(PC);
146891c3e4SJed Brown   PetscErrorCode (*apply)(PC,Vec,Vec);
157b6e2003SPierre Jolivet   PetscErrorCode (*matapply)(PC,Mat,Mat);
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 
28b29801fcSSatish Balay /*@C
29be29d3c6SBarry Smith     PCShellGetContext - Returns the user-provided context associated with a shell PC
30be29d3c6SBarry Smith 
31be29d3c6SBarry Smith     Not Collective
32be29d3c6SBarry Smith 
33be29d3c6SBarry Smith     Input Parameter:
34c5ae4b9aSBarry Smith .   pc - should have been created with PCSetType(pc,shell)
35be29d3c6SBarry Smith 
36be29d3c6SBarry Smith     Output Parameter:
37be29d3c6SBarry Smith .   ctx - the user provided context
38be29d3c6SBarry Smith 
39be29d3c6SBarry Smith     Level: advanced
40be29d3c6SBarry Smith 
41be29d3c6SBarry Smith     Notes:
42be29d3c6SBarry Smith     This routine is intended for use within various shell routines
43be29d3c6SBarry Smith 
4495452b02SPatrick Sanan    Fortran Notes:
4595452b02SPatrick Sanan     To use this from Fortran you must write a Fortran interface definition for this
46daf670e6SBarry Smith     function that tells Fortran the Fortran derived data type that you are passing in as the ctx argument.
47daf670e6SBarry Smith 
48c5ae4b9aSBarry Smith .seealso: PCShellSetContext()
49be29d3c6SBarry Smith @*/
503ec1f749SStefano Zampini PetscErrorCode  PCShellGetContext(PC pc,void *ctx)
51be29d3c6SBarry Smith {
52be29d3c6SBarry Smith   PetscErrorCode ierr;
53ace3abfcSBarry Smith   PetscBool      flg;
54be29d3c6SBarry Smith 
55be29d3c6SBarry Smith   PetscFunctionBegin;
560700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
57be29d3c6SBarry Smith   PetscValidPointer(ctx,2);
58251f4c67SDmitry Karpeev   ierr = PetscObjectTypeCompare((PetscObject)pc,PCSHELL,&flg);CHKERRQ(ierr);
593ec1f749SStefano Zampini   if (!flg) *(void**)ctx = NULL;
603ec1f749SStefano Zampini   else      *(void**)ctx = ((PC_Shell*)(pc->data))->ctx;
61be29d3c6SBarry Smith   PetscFunctionReturn(0);
62be29d3c6SBarry Smith }
63be29d3c6SBarry Smith 
649dd1005fSJed Brown /*@
65be29d3c6SBarry Smith     PCShellSetContext - sets the context for a shell PC
66be29d3c6SBarry Smith 
673f9fe445SBarry Smith    Logically Collective on PC
68be29d3c6SBarry Smith 
69be29d3c6SBarry Smith     Input Parameters:
70be29d3c6SBarry Smith +   pc - the shell PC
71be29d3c6SBarry Smith -   ctx - the context
72be29d3c6SBarry Smith 
73be29d3c6SBarry Smith    Level: advanced
74be29d3c6SBarry Smith 
7595452b02SPatrick Sanan    Fortran Notes:
7695452b02SPatrick Sanan     To use this from Fortran you must write a Fortran interface definition for this
77daf670e6SBarry Smith     function that tells Fortran the Fortran derived data type that you are passing in as the ctx argument.
78daf670e6SBarry Smith 
79c5ae4b9aSBarry Smith .seealso: PCShellGetContext(), PCSHELL
80be29d3c6SBarry Smith @*/
817087cfbeSBarry Smith PetscErrorCode  PCShellSetContext(PC pc,void *ctx)
82be29d3c6SBarry Smith {
83c5ae4b9aSBarry Smith   PC_Shell       *shell = (PC_Shell*)pc->data;
84be29d3c6SBarry Smith   PetscErrorCode ierr;
85ace3abfcSBarry Smith   PetscBool      flg;
86be29d3c6SBarry Smith 
87be29d3c6SBarry Smith   PetscFunctionBegin;
880700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
89251f4c67SDmitry Karpeev   ierr = PetscObjectTypeCompare((PetscObject)pc,PCSHELL,&flg);CHKERRQ(ierr);
902fa5cd67SKarl Rupp   if (flg) shell->ctx = ctx;
91be29d3c6SBarry Smith   PetscFunctionReturn(0);
92be29d3c6SBarry Smith }
93be29d3c6SBarry Smith 
946849ba73SBarry Smith static PetscErrorCode PCSetUp_Shell(PC pc)
954b9ad928SBarry Smith {
96c5ae4b9aSBarry Smith   PC_Shell       *shell = (PC_Shell*)pc->data;
97dfbe8321SBarry Smith   PetscErrorCode ierr;
984b9ad928SBarry Smith 
994b9ad928SBarry Smith   PetscFunctionBegin;
100*2c71b3e2SJacob Faibussowitsch   PetscCheckFalse(!shell->setup,PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No setup() routine provided to Shell PC");
101eb6b5d47SBarry Smith   PetscStackCall("PCSHELL user function setup()",ierr = (*shell->setup)(pc);CHKERRQ(ierr));
1024b9ad928SBarry Smith   PetscFunctionReturn(0);
1034b9ad928SBarry Smith }
1044b9ad928SBarry Smith 
1056849ba73SBarry Smith static PetscErrorCode PCApply_Shell(PC pc,Vec x,Vec y)
1064b9ad928SBarry Smith {
107c5ae4b9aSBarry Smith   PC_Shell         *shell = (PC_Shell*)pc->data;
108dfbe8321SBarry Smith   PetscErrorCode   ierr;
109e3f487b0SBarry Smith   PetscObjectState instate,outstate;
1104b9ad928SBarry Smith 
1114b9ad928SBarry Smith   PetscFunctionBegin;
112*2c71b3e2SJacob Faibussowitsch   PetscCheckFalse(!shell->apply,PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No apply() routine provided to Shell PC");
113e3f487b0SBarry Smith   ierr = PetscObjectStateGet((PetscObject)y, &instate);CHKERRQ(ierr);
114eb6b5d47SBarry Smith   PetscStackCall("PCSHELL user function apply()",ierr = (*shell->apply)(pc,x,y);CHKERRQ(ierr));
115e3f487b0SBarry Smith   ierr = PetscObjectStateGet((PetscObject)y, &outstate);CHKERRQ(ierr);
116e3f487b0SBarry Smith   if (instate == outstate) {
117e3f487b0SBarry Smith     /* increase the state of the output vector since the user did not update its state themselve as should have been done */
118e3f487b0SBarry Smith     ierr = PetscObjectStateIncrease((PetscObject)y);CHKERRQ(ierr);
119e3f487b0SBarry Smith   }
1204b9ad928SBarry Smith   PetscFunctionReturn(0);
1214b9ad928SBarry Smith }
1224b9ad928SBarry Smith 
1237b6e2003SPierre Jolivet static PetscErrorCode PCMatApply_Shell(PC pc,Mat X,Mat Y)
1247b6e2003SPierre Jolivet {
1257b6e2003SPierre Jolivet   PC_Shell         *shell = (PC_Shell*)pc->data;
1267b6e2003SPierre Jolivet   PetscErrorCode   ierr;
1277b6e2003SPierre Jolivet   PetscObjectState instate,outstate;
1287b6e2003SPierre Jolivet 
1297b6e2003SPierre Jolivet   PetscFunctionBegin;
130*2c71b3e2SJacob Faibussowitsch   PetscCheckFalse(!shell->matapply,PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No apply() routine provided to Shell PC");
1317b6e2003SPierre Jolivet   ierr = PetscObjectStateGet((PetscObject)Y, &instate);CHKERRQ(ierr);
1327b6e2003SPierre Jolivet   PetscStackCall("PCSHELL user function apply()",ierr = (*shell->matapply)(pc,X,Y);CHKERRQ(ierr));
1337b6e2003SPierre Jolivet   ierr = PetscObjectStateGet((PetscObject)Y, &outstate);CHKERRQ(ierr);
1347b6e2003SPierre Jolivet   if (instate == outstate) {
1357b6e2003SPierre Jolivet     /* increase the state of the output vector since the user did not update its state themselve as should have been done */
1367b6e2003SPierre Jolivet     ierr = PetscObjectStateIncrease((PetscObject)Y);CHKERRQ(ierr);
1377b6e2003SPierre Jolivet   }
1387b6e2003SPierre Jolivet   PetscFunctionReturn(0);
1397b6e2003SPierre Jolivet }
1407b6e2003SPierre Jolivet 
1411b581b66SBarry Smith static PetscErrorCode PCApplySymmetricLeft_Shell(PC pc,Vec x,Vec y)
1421b581b66SBarry Smith {
1431b581b66SBarry Smith   PC_Shell       *shell = (PC_Shell*)pc->data;
1441b581b66SBarry Smith   PetscErrorCode ierr;
1451b581b66SBarry Smith 
1461b581b66SBarry Smith   PetscFunctionBegin;
147*2c71b3e2SJacob Faibussowitsch   PetscCheckFalse(!shell->applysymmetricleft,PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No apply() routine provided to Shell PC");
1481b581b66SBarry Smith   PetscStackCall("PCSHELL user function apply()",ierr = (*shell->applysymmetricleft)(pc,x,y);CHKERRQ(ierr));
1491b581b66SBarry Smith   PetscFunctionReturn(0);
1501b581b66SBarry Smith }
1511b581b66SBarry Smith 
1521b581b66SBarry Smith static PetscErrorCode PCApplySymmetricRight_Shell(PC pc,Vec x,Vec y)
1531b581b66SBarry Smith {
1541b581b66SBarry Smith   PC_Shell       *shell = (PC_Shell*)pc->data;
1551b581b66SBarry Smith   PetscErrorCode ierr;
1561b581b66SBarry Smith 
1571b581b66SBarry Smith   PetscFunctionBegin;
158*2c71b3e2SJacob Faibussowitsch   PetscCheckFalse(!shell->applysymmetricright,PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No apply() routine provided to Shell PC");
1591b581b66SBarry Smith   PetscStackCall("PCSHELL user function apply()",ierr = (*shell->applysymmetricright)(pc,x,y);CHKERRQ(ierr));
1601b581b66SBarry Smith   PetscFunctionReturn(0);
1611b581b66SBarry Smith }
1621b581b66SBarry Smith 
1632bb17772SBarry Smith static PetscErrorCode PCApplyBA_Shell(PC pc,PCSide side,Vec x,Vec y,Vec w)
1642bb17772SBarry Smith {
165c5ae4b9aSBarry Smith   PC_Shell         *shell = (PC_Shell*)pc->data;
1662bb17772SBarry Smith   PetscErrorCode   ierr;
167e3f487b0SBarry Smith   PetscObjectState instate,outstate;
1682bb17772SBarry Smith 
1692bb17772SBarry Smith   PetscFunctionBegin;
170*2c71b3e2SJacob Faibussowitsch   PetscCheckFalse(!shell->applyBA,PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No applyBA() routine provided to Shell PC");
171e3f487b0SBarry Smith   ierr = PetscObjectStateGet((PetscObject)w, &instate);CHKERRQ(ierr);
172eb6b5d47SBarry Smith   PetscStackCall("PCSHELL user function applyBA()",ierr = (*shell->applyBA)(pc,side,x,y,w);CHKERRQ(ierr));
173e3f487b0SBarry Smith   ierr = PetscObjectStateGet((PetscObject)w, &outstate);CHKERRQ(ierr);
174e3f487b0SBarry Smith   if (instate == outstate) {
175e3f487b0SBarry Smith     /* increase the state of the output vector since the user did not update its state themselve as should have been done */
176e3f487b0SBarry Smith     ierr = PetscObjectStateIncrease((PetscObject)w);CHKERRQ(ierr);
177e3f487b0SBarry Smith   }
1782bb17772SBarry Smith   PetscFunctionReturn(0);
1792bb17772SBarry Smith }
1802bb17772SBarry Smith 
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 
1887cdd61b2SBarry Smith static PetscErrorCode PCPreSolve_Shell(PC pc,KSP ksp,Vec b,Vec x)
1897cdd61b2SBarry Smith {
190c5ae4b9aSBarry Smith   PC_Shell       *shell = (PC_Shell*)pc->data;
1917cdd61b2SBarry Smith   PetscErrorCode ierr;
1927cdd61b2SBarry Smith 
1937cdd61b2SBarry Smith   PetscFunctionBegin;
194*2c71b3e2SJacob Faibussowitsch   PetscCheckFalse(!shell->presolve,PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No presolve() routine provided to Shell PC");
195eb6b5d47SBarry Smith   PetscStackCall("PCSHELL user function presolve()",ierr = (*shell->presolve)(pc,ksp,b,x);CHKERRQ(ierr));
1967cdd61b2SBarry Smith   PetscFunctionReturn(0);
1977cdd61b2SBarry Smith }
1987cdd61b2SBarry Smith 
1997cdd61b2SBarry Smith static PetscErrorCode PCPostSolve_Shell(PC pc,KSP ksp,Vec b,Vec x)
2007cdd61b2SBarry Smith {
201c5ae4b9aSBarry Smith   PC_Shell       *shell = (PC_Shell*)pc->data;
2027cdd61b2SBarry Smith   PetscErrorCode ierr;
2037cdd61b2SBarry Smith 
2047cdd61b2SBarry Smith   PetscFunctionBegin;
205*2c71b3e2SJacob Faibussowitsch   PetscCheckFalse(!shell->postsolve,PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No postsolve() routine provided to Shell PC");
206eb6b5d47SBarry Smith   PetscStackCall("PCSHELL user function postsolve()",ierr = (*shell->postsolve)(pc,ksp,b,x);CHKERRQ(ierr));
2077cdd61b2SBarry Smith   PetscFunctionReturn(0);
2087cdd61b2SBarry Smith }
2097cdd61b2SBarry Smith 
2106849ba73SBarry Smith static PetscErrorCode PCApplyTranspose_Shell(PC pc,Vec x,Vec y)
2114b9ad928SBarry Smith {
212c5ae4b9aSBarry Smith   PC_Shell         *shell = (PC_Shell*)pc->data;
213dfbe8321SBarry Smith   PetscErrorCode   ierr;
214e3f487b0SBarry Smith   PetscObjectState instate,outstate;
2154b9ad928SBarry Smith 
2164b9ad928SBarry Smith   PetscFunctionBegin;
217*2c71b3e2SJacob Faibussowitsch   PetscCheckFalse(!shell->applytranspose,PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No applytranspose() routine provided to Shell PC");
218e3f487b0SBarry Smith   ierr = PetscObjectStateGet((PetscObject)y, &instate);CHKERRQ(ierr);
219eb6b5d47SBarry Smith   PetscStackCall("PCSHELL user function applytranspose()",ierr = (*shell->applytranspose)(pc,x,y);CHKERRQ(ierr));
220e3f487b0SBarry Smith   ierr = PetscObjectStateGet((PetscObject)y, &outstate);CHKERRQ(ierr);
221e3f487b0SBarry Smith   if (instate == outstate) {
222e3f487b0SBarry Smith     /* increase the state of the output vector since the user did not update its state themself as should have been done */
223e3f487b0SBarry Smith     ierr = PetscObjectStateIncrease((PetscObject)y);CHKERRQ(ierr);
224e3f487b0SBarry Smith   }
2254b9ad928SBarry Smith   PetscFunctionReturn(0);
2264b9ad928SBarry Smith }
2274b9ad928SBarry Smith 
228ace3abfcSBarry 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)
2294b9ad928SBarry Smith {
230dfbe8321SBarry Smith   PetscErrorCode   ierr;
231c5ae4b9aSBarry Smith   PC_Shell         *shell = (PC_Shell*)pc->data;
232e3f487b0SBarry Smith   PetscObjectState instate,outstate;
2334b9ad928SBarry Smith 
2344b9ad928SBarry Smith   PetscFunctionBegin;
235*2c71b3e2SJacob Faibussowitsch   PetscCheckFalse(!shell->applyrich,PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No applyrichardson() routine provided to Shell PC");
236e3f487b0SBarry Smith   ierr = PetscObjectStateGet((PetscObject)y, &instate);CHKERRQ(ierr);
237eb6b5d47SBarry Smith   PetscStackCall("PCSHELL user function applyrichardson()",ierr = (*shell->applyrich)(pc,x,y,w,rtol,abstol,dtol,it,guesszero,outits,reason);CHKERRQ(ierr));
238e3f487b0SBarry Smith   ierr = PetscObjectStateGet((PetscObject)y, &outstate);CHKERRQ(ierr);
239e3f487b0SBarry Smith   if (instate == outstate) {
240e3f487b0SBarry Smith     /* increase the state of the output vector since the user did not update its state themself as should have been done */
241e3f487b0SBarry Smith     ierr = PetscObjectStateIncrease((PetscObject)y);CHKERRQ(ierr);
242e3f487b0SBarry Smith   }
2434b9ad928SBarry Smith   PetscFunctionReturn(0);
2444b9ad928SBarry Smith }
2454b9ad928SBarry Smith 
2466849ba73SBarry Smith static PetscErrorCode PCDestroy_Shell(PC pc)
2474b9ad928SBarry Smith {
2484b9ad928SBarry Smith   PC_Shell       *shell = (PC_Shell*)pc->data;
249dfbe8321SBarry Smith   PetscErrorCode ierr;
2504b9ad928SBarry Smith 
2514b9ad928SBarry Smith   PetscFunctionBegin;
252503cfb0cSBarry Smith   ierr = PetscFree(shell->name);CHKERRQ(ierr);
2532fa5cd67SKarl Rupp   if (shell->destroy) PetscStackCall("PCSHELL user function destroy()",ierr = (*shell->destroy)(pc);CHKERRQ(ierr));
254a06fd7f2SStefano Zampini   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetDestroy_C",NULL);CHKERRQ(ierr);
255a06fd7f2SStefano Zampini   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetSetUp_C",NULL);CHKERRQ(ierr);
256a06fd7f2SStefano Zampini   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApply_C",NULL);CHKERRQ(ierr);
2577b6e2003SPierre Jolivet   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetMatApply_C",NULL);CHKERRQ(ierr);
258a06fd7f2SStefano Zampini   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplySymmetricLeft_C",NULL);CHKERRQ(ierr);
259a06fd7f2SStefano Zampini   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplySymmetricRight_C",NULL);CHKERRQ(ierr);
260a06fd7f2SStefano Zampini   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplyBA_C",NULL);CHKERRQ(ierr);
261a06fd7f2SStefano Zampini   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetPreSolve_C",NULL);CHKERRQ(ierr);
262a06fd7f2SStefano Zampini   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetPostSolve_C",NULL);CHKERRQ(ierr);
263a06fd7f2SStefano Zampini   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetView_C",NULL);CHKERRQ(ierr);
264a06fd7f2SStefano Zampini   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplyTranspose_C",NULL);CHKERRQ(ierr);
265a06fd7f2SStefano Zampini   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetName_C",NULL);CHKERRQ(ierr);
266a06fd7f2SStefano Zampini   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellGetName_C",NULL);CHKERRQ(ierr);
267a06fd7f2SStefano Zampini   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplyRichardson_C",NULL);CHKERRQ(ierr);
268a06fd7f2SStefano Zampini   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCPreSolveChangeRHS_C",NULL);CHKERRQ(ierr);
269c31cb41cSBarry Smith   ierr = PetscFree(pc->data);CHKERRQ(ierr);
2704b9ad928SBarry Smith   PetscFunctionReturn(0);
2714b9ad928SBarry Smith }
2724b9ad928SBarry Smith 
2736849ba73SBarry Smith static PetscErrorCode PCView_Shell(PC pc,PetscViewer viewer)
2744b9ad928SBarry Smith {
2754b9ad928SBarry Smith   PC_Shell       *shell = (PC_Shell*)pc->data;
276dfbe8321SBarry Smith   PetscErrorCode ierr;
277ace3abfcSBarry Smith   PetscBool      iascii;
2784b9ad928SBarry Smith 
2794b9ad928SBarry Smith   PetscFunctionBegin;
280251f4c67SDmitry Karpeev   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&iascii);CHKERRQ(ierr);
28132077d6dSBarry Smith   if (iascii) {
2822fa5cd67SKarl Rupp     if (shell->name) {
283efd4aadfSBarry Smith       ierr = PetscViewerASCIIPrintf(viewer,"  %s\n",shell->name);CHKERRQ(ierr);
2842fa5cd67SKarl Rupp     } else {
285efd4aadfSBarry Smith       ierr = PetscViewerASCIIPrintf(viewer,"  no name\n");CHKERRQ(ierr);
2862fa5cd67SKarl Rupp     }
2874b9ad928SBarry Smith   }
2884b9ad928SBarry Smith   if (shell->view) {
2894b9ad928SBarry Smith     ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
2906891c3e4SJed Brown     ierr = (*shell->view)(pc,viewer);CHKERRQ(ierr);
2914b9ad928SBarry Smith     ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
2924b9ad928SBarry Smith   }
2934b9ad928SBarry Smith   PetscFunctionReturn(0);
2944b9ad928SBarry Smith }
2954b9ad928SBarry Smith 
2964b9ad928SBarry Smith /* ------------------------------------------------------------------------------*/
297f7a08781SBarry Smith static PetscErrorCode  PCShellSetDestroy_Shell(PC pc, PetscErrorCode (*destroy)(PC))
29818be62a5SSatish Balay {
299c5ae4b9aSBarry Smith   PC_Shell *shell= (PC_Shell*)pc->data;
30018be62a5SSatish Balay 
30118be62a5SSatish Balay   PetscFunctionBegin;
30218be62a5SSatish Balay   shell->destroy = destroy;
30318be62a5SSatish Balay   PetscFunctionReturn(0);
30418be62a5SSatish Balay }
30518be62a5SSatish Balay 
306f7a08781SBarry Smith static PetscErrorCode  PCShellSetSetUp_Shell(PC pc, PetscErrorCode (*setup)(PC))
3074b9ad928SBarry Smith {
308feb237baSPierre Jolivet   PC_Shell *shell = (PC_Shell*)pc->data;
3094b9ad928SBarry Smith 
3104b9ad928SBarry Smith   PetscFunctionBegin;
3114b9ad928SBarry Smith   shell->setup = setup;
312d01c8aa3SLisandro Dalcin   if (setup) pc->ops->setup = PCSetUp_Shell;
3130a545947SLisandro Dalcin   else       pc->ops->setup = NULL;
3144b9ad928SBarry Smith   PetscFunctionReturn(0);
3154b9ad928SBarry Smith }
3164b9ad928SBarry Smith 
317f7a08781SBarry Smith static PetscErrorCode  PCShellSetApply_Shell(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec))
3184b9ad928SBarry Smith {
319c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell*)pc->data;
3204b9ad928SBarry Smith 
3214b9ad928SBarry Smith   PetscFunctionBegin;
3224b9ad928SBarry Smith   shell->apply = apply;
3234b9ad928SBarry Smith   PetscFunctionReturn(0);
3244b9ad928SBarry Smith }
3254b9ad928SBarry Smith 
3267b6e2003SPierre Jolivet static PetscErrorCode  PCShellSetMatApply_Shell(PC pc,PetscErrorCode (*matapply)(PC,Mat,Mat))
3277b6e2003SPierre Jolivet {
3287b6e2003SPierre Jolivet   PC_Shell *shell = (PC_Shell*)pc->data;
3297b6e2003SPierre Jolivet 
3307b6e2003SPierre Jolivet   PetscFunctionBegin;
3317b6e2003SPierre Jolivet   shell->matapply = matapply;
3327b6e2003SPierre Jolivet   PetscFunctionReturn(0);
3337b6e2003SPierre Jolivet }
3347b6e2003SPierre Jolivet 
3351b581b66SBarry Smith static PetscErrorCode  PCShellSetApplySymmetricLeft_Shell(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec))
3361b581b66SBarry Smith {
3371b581b66SBarry Smith   PC_Shell *shell = (PC_Shell*)pc->data;
3381b581b66SBarry Smith 
3391b581b66SBarry Smith   PetscFunctionBegin;
3401b581b66SBarry Smith   shell->applysymmetricleft = apply;
3411b581b66SBarry Smith   PetscFunctionReturn(0);
3421b581b66SBarry Smith }
3431b581b66SBarry Smith 
3441b581b66SBarry Smith static PetscErrorCode  PCShellSetApplySymmetricRight_Shell(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec))
3451b581b66SBarry Smith {
3461b581b66SBarry Smith   PC_Shell *shell = (PC_Shell*)pc->data;
3471b581b66SBarry Smith 
3481b581b66SBarry Smith   PetscFunctionBegin;
3491b581b66SBarry Smith   shell->applysymmetricright = apply;
3501b581b66SBarry Smith   PetscFunctionReturn(0);
3511b581b66SBarry Smith }
3521b581b66SBarry Smith 
353f7a08781SBarry Smith static PetscErrorCode  PCShellSetApplyBA_Shell(PC pc,PetscErrorCode (*applyBA)(PC,PCSide,Vec,Vec,Vec))
3542bb17772SBarry Smith {
355c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell*)pc->data;
3562bb17772SBarry Smith 
3572bb17772SBarry Smith   PetscFunctionBegin;
358d01c8aa3SLisandro Dalcin   shell->applyBA = applyBA;
359d01c8aa3SLisandro Dalcin   if (applyBA) pc->ops->applyBA  = PCApplyBA_Shell;
3600a545947SLisandro Dalcin   else         pc->ops->applyBA  = NULL;
3612bb17772SBarry Smith   PetscFunctionReturn(0);
3622bb17772SBarry Smith }
3632bb17772SBarry Smith 
364f7a08781SBarry Smith static PetscErrorCode  PCShellSetPreSolve_Shell(PC pc,PetscErrorCode (*presolve)(PC,KSP,Vec,Vec))
3657cdd61b2SBarry Smith {
366c5ae4b9aSBarry Smith   PC_Shell       *shell = (PC_Shell*)pc->data;
367a06fd7f2SStefano Zampini   PetscErrorCode ierr;
3687cdd61b2SBarry Smith 
3697cdd61b2SBarry Smith   PetscFunctionBegin;
3707cdd61b2SBarry Smith   shell->presolve = presolve;
371a06fd7f2SStefano Zampini   if (presolve) {
372a06fd7f2SStefano Zampini     pc->ops->presolve = PCPreSolve_Shell;
373a06fd7f2SStefano Zampini     ierr = PetscObjectComposeFunction((PetscObject)pc,"PCPreSolveChangeRHS_C",PCPreSolveChangeRHS_Shell);CHKERRQ(ierr);
374a06fd7f2SStefano Zampini   } else {
3750a545947SLisandro Dalcin     pc->ops->presolve = NULL;
376a06fd7f2SStefano Zampini     ierr = PetscObjectComposeFunction((PetscObject)pc,"PCPreSolveChangeRHS_C",NULL);CHKERRQ(ierr);
377a06fd7f2SStefano Zampini   }
3787cdd61b2SBarry Smith   PetscFunctionReturn(0);
3797cdd61b2SBarry Smith }
3807cdd61b2SBarry Smith 
381f7a08781SBarry Smith static PetscErrorCode  PCShellSetPostSolve_Shell(PC pc,PetscErrorCode (*postsolve)(PC,KSP,Vec,Vec))
3827cdd61b2SBarry Smith {
383c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell*)pc->data;
3847cdd61b2SBarry Smith 
3857cdd61b2SBarry Smith   PetscFunctionBegin;
3867cdd61b2SBarry Smith   shell->postsolve = postsolve;
387d01c8aa3SLisandro Dalcin   if (postsolve) pc->ops->postsolve = PCPostSolve_Shell;
3880a545947SLisandro Dalcin   else           pc->ops->postsolve = NULL;
3897cdd61b2SBarry Smith   PetscFunctionReturn(0);
3907cdd61b2SBarry Smith }
3917cdd61b2SBarry Smith 
392f7a08781SBarry Smith static PetscErrorCode  PCShellSetView_Shell(PC pc,PetscErrorCode (*view)(PC,PetscViewer))
3934b9ad928SBarry Smith {
394c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell*)pc->data;
3954b9ad928SBarry Smith 
3964b9ad928SBarry Smith   PetscFunctionBegin;
3974b9ad928SBarry Smith   shell->view = view;
3984b9ad928SBarry Smith   PetscFunctionReturn(0);
3994b9ad928SBarry Smith }
4004b9ad928SBarry Smith 
401f7a08781SBarry Smith static PetscErrorCode  PCShellSetApplyTranspose_Shell(PC pc,PetscErrorCode (*applytranspose)(PC,Vec,Vec))
4024b9ad928SBarry Smith {
403c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell*)pc->data;
4044b9ad928SBarry Smith 
4054b9ad928SBarry Smith   PetscFunctionBegin;
4064b9ad928SBarry Smith   shell->applytranspose = applytranspose;
407d01c8aa3SLisandro Dalcin   if (applytranspose) pc->ops->applytranspose = PCApplyTranspose_Shell;
4080a545947SLisandro Dalcin   else                pc->ops->applytranspose = NULL;
409d01c8aa3SLisandro Dalcin   PetscFunctionReturn(0);
410d01c8aa3SLisandro Dalcin }
411d01c8aa3SLisandro Dalcin 
412f7a08781SBarry Smith static PetscErrorCode  PCShellSetApplyRichardson_Shell(PC pc,PetscErrorCode (*applyrich)(PC,Vec,Vec,Vec,PetscReal,PetscReal,PetscReal,PetscInt,PetscBool ,PetscInt*,PCRichardsonConvergedReason*))
413d01c8aa3SLisandro Dalcin {
414c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell*)pc->data;
415d01c8aa3SLisandro Dalcin 
416d01c8aa3SLisandro Dalcin   PetscFunctionBegin;
417d01c8aa3SLisandro Dalcin   shell->applyrich = applyrich;
418d01c8aa3SLisandro Dalcin   if (applyrich) pc->ops->applyrichardson = PCApplyRichardson_Shell;
4190a545947SLisandro Dalcin   else           pc->ops->applyrichardson = NULL;
4204b9ad928SBarry Smith   PetscFunctionReturn(0);
4214b9ad928SBarry Smith }
4224b9ad928SBarry Smith 
423f7a08781SBarry Smith static PetscErrorCode  PCShellSetName_Shell(PC pc,const char name[])
4244b9ad928SBarry Smith {
425c5ae4b9aSBarry Smith   PC_Shell       *shell = (PC_Shell*)pc->data;
426dfbe8321SBarry Smith   PetscErrorCode ierr;
4274b9ad928SBarry Smith 
4284b9ad928SBarry Smith   PetscFunctionBegin;
429503cfb0cSBarry Smith   ierr = PetscFree(shell->name);CHKERRQ(ierr);
4304b9ad928SBarry Smith   ierr = PetscStrallocpy(name,&shell->name);CHKERRQ(ierr);
4314b9ad928SBarry Smith   PetscFunctionReturn(0);
4324b9ad928SBarry Smith }
4334b9ad928SBarry Smith 
434f7a08781SBarry Smith static PetscErrorCode  PCShellGetName_Shell(PC pc,const char *name[])
4354b9ad928SBarry Smith {
436c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell*)pc->data;
4374b9ad928SBarry Smith 
4384b9ad928SBarry Smith   PetscFunctionBegin;
4394b9ad928SBarry Smith   *name = shell->name;
4404b9ad928SBarry Smith   PetscFunctionReturn(0);
4414b9ad928SBarry Smith }
4424b9ad928SBarry Smith 
4434b9ad928SBarry Smith /* -------------------------------------------------------------------------------*/
4444b9ad928SBarry Smith 
44518be62a5SSatish Balay /*@C
44618be62a5SSatish Balay    PCShellSetDestroy - Sets routine to use to destroy the user-provided
44718be62a5SSatish Balay    application context.
44818be62a5SSatish Balay 
4493f9fe445SBarry Smith    Logically Collective on PC
45018be62a5SSatish Balay 
45118be62a5SSatish Balay    Input Parameters:
45218be62a5SSatish Balay +  pc - the preconditioner context
453a2b725a8SWilliam Gropp -  destroy - the application-provided destroy routine
45418be62a5SSatish Balay 
45518be62a5SSatish Balay    Calling sequence of destroy:
45618be62a5SSatish Balay .vb
4576891c3e4SJed Brown    PetscErrorCode destroy (PC)
45818be62a5SSatish Balay .ve
45918be62a5SSatish Balay 
46018be62a5SSatish Balay .  ptr - the application context
46118be62a5SSatish Balay 
46295452b02SPatrick Sanan    Notes:
46395452b02SPatrick Sanan     the function MUST return an error code of 0 on success and nonzero on failure.
4644aa34b0aSBarry Smith 
46518be62a5SSatish Balay    Level: developer
46618be62a5SSatish Balay 
46718be62a5SSatish Balay .seealso: PCShellSetApply(), PCShellSetContext()
46818be62a5SSatish Balay @*/
4697087cfbeSBarry Smith PetscErrorCode  PCShellSetDestroy(PC pc,PetscErrorCode (*destroy)(PC))
47018be62a5SSatish Balay {
4714ac538c5SBarry Smith   PetscErrorCode ierr;
47218be62a5SSatish Balay 
47318be62a5SSatish Balay   PetscFunctionBegin;
4740700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
4754ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetDestroy_C",(PC,PetscErrorCode (*)(PC)),(pc,destroy));CHKERRQ(ierr);
47618be62a5SSatish Balay   PetscFunctionReturn(0);
47718be62a5SSatish Balay }
47818be62a5SSatish Balay 
4794b9ad928SBarry Smith /*@C
4804b9ad928SBarry Smith    PCShellSetSetUp - Sets routine to use to "setup" the preconditioner whenever the
4814b9ad928SBarry Smith    matrix operator is changed.
4824b9ad928SBarry Smith 
4833f9fe445SBarry Smith    Logically Collective on PC
4844b9ad928SBarry Smith 
4854b9ad928SBarry Smith    Input Parameters:
4864b9ad928SBarry Smith +  pc - the preconditioner context
487a2b725a8SWilliam Gropp -  setup - the application-provided setup routine
4884b9ad928SBarry Smith 
4894b9ad928SBarry Smith    Calling sequence of setup:
4904b9ad928SBarry Smith .vb
4916891c3e4SJed Brown    PetscErrorCode setup (PC pc)
4924b9ad928SBarry Smith .ve
4934b9ad928SBarry Smith 
4946891c3e4SJed Brown .  pc - the preconditioner, get the application context with PCShellGetContext()
4954b9ad928SBarry Smith 
49695452b02SPatrick Sanan    Notes:
49795452b02SPatrick Sanan     the function MUST return an error code of 0 on success and nonzero on failure.
4984aa34b0aSBarry Smith 
4994b9ad928SBarry Smith    Level: developer
5004b9ad928SBarry Smith 
501be29d3c6SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetApply(), PCShellSetContext()
5024b9ad928SBarry Smith @*/
5037087cfbeSBarry Smith PetscErrorCode  PCShellSetSetUp(PC pc,PetscErrorCode (*setup)(PC))
5044b9ad928SBarry Smith {
5054ac538c5SBarry Smith   PetscErrorCode ierr;
5064b9ad928SBarry Smith 
5074b9ad928SBarry Smith   PetscFunctionBegin;
5080700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
5094ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetSetUp_C",(PC,PetscErrorCode (*)(PC)),(pc,setup));CHKERRQ(ierr);
5104b9ad928SBarry Smith   PetscFunctionReturn(0);
5114b9ad928SBarry Smith }
5124b9ad928SBarry Smith 
5134b9ad928SBarry Smith /*@C
5144b9ad928SBarry Smith    PCShellSetView - Sets routine to use as viewer of shell preconditioner
5154b9ad928SBarry Smith 
5163f9fe445SBarry Smith    Logically Collective on PC
5174b9ad928SBarry Smith 
5184b9ad928SBarry Smith    Input Parameters:
5194b9ad928SBarry Smith +  pc - the preconditioner context
5204b9ad928SBarry Smith -  view - the application-provided view routine
5214b9ad928SBarry Smith 
52253a7a830SPatrick Sanan    Calling sequence of view:
5234b9ad928SBarry Smith .vb
5246891c3e4SJed Brown    PetscErrorCode view(PC pc,PetscViewer v)
5254b9ad928SBarry Smith .ve
5264b9ad928SBarry Smith 
5276891c3e4SJed Brown +  pc - the preconditioner, get the application context with PCShellGetContext()
5284b9ad928SBarry Smith -  v   - viewer
5294b9ad928SBarry Smith 
53095452b02SPatrick Sanan    Notes:
53195452b02SPatrick Sanan     the function MUST return an error code of 0 on success and nonzero on failure.
5324aa34b0aSBarry Smith 
5334b9ad928SBarry Smith    Level: developer
5344b9ad928SBarry Smith 
5354b9ad928SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose()
5364b9ad928SBarry Smith @*/
5377087cfbeSBarry Smith PetscErrorCode  PCShellSetView(PC pc,PetscErrorCode (*view)(PC,PetscViewer))
5384b9ad928SBarry Smith {
5394ac538c5SBarry Smith   PetscErrorCode ierr;
5404b9ad928SBarry Smith 
5414b9ad928SBarry Smith   PetscFunctionBegin;
5420700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
5434ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetView_C",(PC,PetscErrorCode (*)(PC,PetscViewer)),(pc,view));CHKERRQ(ierr);
5444b9ad928SBarry Smith   PetscFunctionReturn(0);
5454b9ad928SBarry Smith }
5464b9ad928SBarry Smith 
5474b9ad928SBarry Smith /*@C
5484b9ad928SBarry Smith    PCShellSetApply - Sets routine to use as preconditioner.
5494b9ad928SBarry Smith 
5503f9fe445SBarry Smith    Logically Collective on PC
5514b9ad928SBarry Smith 
5524b9ad928SBarry Smith    Input Parameters:
5534b9ad928SBarry Smith +  pc - the preconditioner context
554be29d3c6SBarry Smith -  apply - the application-provided preconditioning routine
5554b9ad928SBarry Smith 
5564b9ad928SBarry Smith    Calling sequence of apply:
5574b9ad928SBarry Smith .vb
5586891c3e4SJed Brown    PetscErrorCode apply (PC pc,Vec xin,Vec xout)
5594b9ad928SBarry Smith .ve
5604b9ad928SBarry Smith 
5616891c3e4SJed Brown +  pc - the preconditioner, get the application context with PCShellGetContext()
5624b9ad928SBarry Smith .  xin - input vector
5634b9ad928SBarry Smith -  xout - output vector
5644b9ad928SBarry Smith 
56595452b02SPatrick Sanan    Notes:
56695452b02SPatrick Sanan     the function MUST return an error code of 0 on success and nonzero on failure.
5674aa34b0aSBarry Smith 
5684b9ad928SBarry Smith    Level: developer
5694b9ad928SBarry Smith 
570a4c07401SPatrick Sanan .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetContext(), PCShellSetApplyBA(), PCShellSetApplySymmetricRight(),PCShellSetApplySymmetricLeft()
5714b9ad928SBarry Smith @*/
5727087cfbeSBarry Smith PetscErrorCode  PCShellSetApply(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec))
5734b9ad928SBarry Smith {
5744ac538c5SBarry Smith   PetscErrorCode ierr;
5754b9ad928SBarry Smith 
5764b9ad928SBarry Smith   PetscFunctionBegin;
5770700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
5784ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetApply_C",(PC,PetscErrorCode (*)(PC,Vec,Vec)),(pc,apply));CHKERRQ(ierr);
5794b9ad928SBarry Smith   PetscFunctionReturn(0);
5804b9ad928SBarry Smith }
5814b9ad928SBarry Smith 
5821b581b66SBarry Smith /*@C
5836437efc7SEric Chamberland    PCShellSetMatApply - Sets routine to use as preconditioner on a block of vectors.
5847b6e2003SPierre Jolivet 
5857b6e2003SPierre Jolivet    Logically Collective on PC
5867b6e2003SPierre Jolivet 
5877b6e2003SPierre Jolivet    Input Parameters:
5887b6e2003SPierre Jolivet +  pc - the preconditioner context
5897b6e2003SPierre Jolivet -  apply - the application-provided preconditioning routine
5907b6e2003SPierre Jolivet 
5917b6e2003SPierre Jolivet    Calling sequence of apply:
5927b6e2003SPierre Jolivet .vb
5937b6e2003SPierre Jolivet    PetscErrorCode apply (PC pc,Mat Xin,Mat Xout)
5947b6e2003SPierre Jolivet .ve
5957b6e2003SPierre Jolivet 
5967b6e2003SPierre Jolivet +  pc - the preconditioner, get the application context with PCShellGetContext()
5977b6e2003SPierre Jolivet .  Xin - input block of vectors
5987b6e2003SPierre Jolivet -  Xout - output block of vectors
5997b6e2003SPierre Jolivet 
6007b6e2003SPierre Jolivet    Notes:
6017b6e2003SPierre Jolivet     the function MUST return an error code of 0 on success and nonzero on failure.
6027b6e2003SPierre Jolivet 
6037b6e2003SPierre Jolivet    Level: developer
6047b6e2003SPierre Jolivet 
6057b6e2003SPierre Jolivet .seealso: PCShellSetApply()
6067b6e2003SPierre Jolivet @*/
6077b6e2003SPierre Jolivet PetscErrorCode  PCShellSetMatApply(PC pc,PetscErrorCode (*matapply)(PC,Mat,Mat))
6087b6e2003SPierre Jolivet {
6097b6e2003SPierre Jolivet   PetscErrorCode ierr;
6107b6e2003SPierre Jolivet 
6117b6e2003SPierre Jolivet   PetscFunctionBegin;
6127b6e2003SPierre Jolivet   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
6137b6e2003SPierre Jolivet   ierr = PetscTryMethod(pc,"PCShellSetMatApply_C",(PC,PetscErrorCode (*)(PC,Mat,Mat)),(pc,matapply));CHKERRQ(ierr);
6147b6e2003SPierre Jolivet   PetscFunctionReturn(0);
6157b6e2003SPierre Jolivet }
6167b6e2003SPierre Jolivet 
6177b6e2003SPierre Jolivet /*@C
6181b581b66SBarry Smith    PCShellSetApplySymmetricLeft - Sets routine to use as left preconditioner (when the PC_SYMMETRIC is used).
6191b581b66SBarry Smith 
6201b581b66SBarry Smith    Logically Collective on PC
6211b581b66SBarry Smith 
6221b581b66SBarry Smith    Input Parameters:
6231b581b66SBarry Smith +  pc - the preconditioner context
6241b581b66SBarry Smith -  apply - the application-provided left preconditioning routine
6251b581b66SBarry Smith 
6261b581b66SBarry Smith    Calling sequence of apply:
6271b581b66SBarry Smith .vb
6281b581b66SBarry Smith    PetscErrorCode apply (PC pc,Vec xin,Vec xout)
6291b581b66SBarry Smith .ve
6301b581b66SBarry Smith 
6311b581b66SBarry Smith +  pc - the preconditioner, get the application context with PCShellGetContext()
6321b581b66SBarry Smith .  xin - input vector
6331b581b66SBarry Smith -  xout - output vector
6341b581b66SBarry Smith 
63595452b02SPatrick Sanan    Notes:
63695452b02SPatrick Sanan     the function MUST return an error code of 0 on success and nonzero on failure.
6371b581b66SBarry Smith 
6381b581b66SBarry Smith    Level: developer
6391b581b66SBarry Smith 
6401b581b66SBarry Smith .seealso: PCShellSetApply(), PCShellSetApplySymmetricLeft(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetContext()
6411b581b66SBarry Smith @*/
6421b581b66SBarry Smith PetscErrorCode  PCShellSetApplySymmetricLeft(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec))
6431b581b66SBarry Smith {
6441b581b66SBarry Smith   PetscErrorCode ierr;
6451b581b66SBarry Smith 
6461b581b66SBarry Smith   PetscFunctionBegin;
6471b581b66SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
6481b581b66SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetApplySymmetricLeft_C",(PC,PetscErrorCode (*)(PC,Vec,Vec)),(pc,apply));CHKERRQ(ierr);
6491b581b66SBarry Smith   PetscFunctionReturn(0);
6501b581b66SBarry Smith }
6511b581b66SBarry Smith 
6521b581b66SBarry Smith /*@C
653a4c07401SPatrick Sanan    PCShellSetApplySymmetricRight - Sets routine to use as right preconditioner (when the PC_SYMMETRIC is used).
6541b581b66SBarry Smith 
6551b581b66SBarry Smith    Logically Collective on PC
6561b581b66SBarry Smith 
6571b581b66SBarry Smith    Input Parameters:
6581b581b66SBarry Smith +  pc - the preconditioner context
6591b581b66SBarry Smith -  apply - the application-provided right preconditioning routine
6601b581b66SBarry Smith 
6611b581b66SBarry Smith    Calling sequence of apply:
6621b581b66SBarry Smith .vb
6631b581b66SBarry Smith    PetscErrorCode apply (PC pc,Vec xin,Vec xout)
6641b581b66SBarry Smith .ve
6651b581b66SBarry Smith 
6661b581b66SBarry Smith +  pc - the preconditioner, get the application context with PCShellGetContext()
6671b581b66SBarry Smith .  xin - input vector
6681b581b66SBarry Smith -  xout - output vector
6691b581b66SBarry Smith 
67095452b02SPatrick Sanan    Notes:
67195452b02SPatrick Sanan     the function MUST return an error code of 0 on success and nonzero on failure.
6721b581b66SBarry Smith 
6731b581b66SBarry Smith    Level: developer
6741b581b66SBarry Smith 
6751b581b66SBarry Smith .seealso: PCShellSetApply(), PCShellSetApplySymmetricLeft(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetContext()
6761b581b66SBarry Smith @*/
6771b581b66SBarry Smith PetscErrorCode  PCShellSetApplySymmetricRight(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec))
6781b581b66SBarry Smith {
6791b581b66SBarry Smith   PetscErrorCode ierr;
6801b581b66SBarry Smith 
6811b581b66SBarry Smith   PetscFunctionBegin;
6821b581b66SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
6831b581b66SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetApplySymmetricRight_C",(PC,PetscErrorCode (*)(PC,Vec,Vec)),(pc,apply));CHKERRQ(ierr);
6841b581b66SBarry Smith   PetscFunctionReturn(0);
6851b581b66SBarry Smith }
6861b581b66SBarry Smith 
6872bb17772SBarry Smith /*@C
6882bb17772SBarry Smith    PCShellSetApplyBA - Sets routine to use as preconditioner times operator.
6892bb17772SBarry Smith 
6903f9fe445SBarry Smith    Logically Collective on PC
6912bb17772SBarry Smith 
6922bb17772SBarry Smith    Input Parameters:
6932bb17772SBarry Smith +  pc - the preconditioner context
6942bb17772SBarry Smith -  applyBA - the application-provided BA routine
6952bb17772SBarry Smith 
69653a7a830SPatrick Sanan    Calling sequence of applyBA:
6972bb17772SBarry Smith .vb
6986891c3e4SJed Brown    PetscErrorCode applyBA (PC pc,Vec xin,Vec xout)
6992bb17772SBarry Smith .ve
7002bb17772SBarry Smith 
7016891c3e4SJed Brown +  pc - the preconditioner, get the application context with PCShellGetContext()
7022bb17772SBarry Smith .  xin - input vector
7032bb17772SBarry Smith -  xout - output vector
7042bb17772SBarry Smith 
70595452b02SPatrick Sanan    Notes:
70695452b02SPatrick Sanan     the function MUST return an error code of 0 on success and nonzero on failure.
7074aa34b0aSBarry Smith 
7082bb17772SBarry Smith    Level: developer
7092bb17772SBarry Smith 
7102bb17772SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetContext(), PCShellSetApply()
7112bb17772SBarry Smith @*/
7127087cfbeSBarry Smith PetscErrorCode  PCShellSetApplyBA(PC pc,PetscErrorCode (*applyBA)(PC,PCSide,Vec,Vec,Vec))
7132bb17772SBarry Smith {
7144ac538c5SBarry Smith   PetscErrorCode ierr;
7152bb17772SBarry Smith 
7162bb17772SBarry Smith   PetscFunctionBegin;
7170700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
7184ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetApplyBA_C",(PC,PetscErrorCode (*)(PC,PCSide,Vec,Vec,Vec)),(pc,applyBA));CHKERRQ(ierr);
7192bb17772SBarry Smith   PetscFunctionReturn(0);
7202bb17772SBarry Smith }
7212bb17772SBarry Smith 
7224b9ad928SBarry Smith /*@C
7234b9ad928SBarry Smith    PCShellSetApplyTranspose - Sets routine to use as preconditioner transpose.
7244b9ad928SBarry Smith 
7253f9fe445SBarry Smith    Logically Collective on PC
7264b9ad928SBarry Smith 
7274b9ad928SBarry Smith    Input Parameters:
7284b9ad928SBarry Smith +  pc - the preconditioner context
7294b9ad928SBarry Smith -  apply - the application-provided preconditioning transpose routine
7304b9ad928SBarry Smith 
7314b9ad928SBarry Smith    Calling sequence of apply:
7324b9ad928SBarry Smith .vb
7336891c3e4SJed Brown    PetscErrorCode applytranspose (PC pc,Vec xin,Vec xout)
7344b9ad928SBarry Smith .ve
7354b9ad928SBarry Smith 
7366891c3e4SJed Brown +  pc - the preconditioner, get the application context with PCShellGetContext()
7374b9ad928SBarry Smith .  xin - input vector
7384b9ad928SBarry Smith -  xout - output vector
7394b9ad928SBarry Smith 
74095452b02SPatrick Sanan    Notes:
74195452b02SPatrick Sanan     the function MUST return an error code of 0 on success and nonzero on failure.
7424aa34b0aSBarry Smith 
7434b9ad928SBarry Smith    Level: developer
7444b9ad928SBarry Smith 
7454b9ad928SBarry Smith    Notes:
7464b9ad928SBarry Smith    Uses the same context variable as PCShellSetApply().
7474b9ad928SBarry Smith 
7482bb17772SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApply(), PCSetContext(), PCShellSetApplyBA()
7494b9ad928SBarry Smith @*/
7507087cfbeSBarry Smith PetscErrorCode  PCShellSetApplyTranspose(PC pc,PetscErrorCode (*applytranspose)(PC,Vec,Vec))
7514b9ad928SBarry Smith {
7524ac538c5SBarry Smith   PetscErrorCode ierr;
7534b9ad928SBarry Smith 
7544b9ad928SBarry Smith   PetscFunctionBegin;
7550700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
7564ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetApplyTranspose_C",(PC,PetscErrorCode (*)(PC,Vec,Vec)),(pc,applytranspose));CHKERRQ(ierr);
7574b9ad928SBarry Smith   PetscFunctionReturn(0);
7584b9ad928SBarry Smith }
7594b9ad928SBarry Smith 
7607cdd61b2SBarry Smith /*@C
7617cdd61b2SBarry Smith    PCShellSetPreSolve - Sets routine to apply to the operators/vectors before a KSPSolve() is
7627cdd61b2SBarry Smith       applied. This usually does something like scale the linear system in some application
7637cdd61b2SBarry Smith       specific way.
7647cdd61b2SBarry Smith 
7653f9fe445SBarry Smith    Logically Collective on PC
7667cdd61b2SBarry Smith 
7677cdd61b2SBarry Smith    Input Parameters:
7687cdd61b2SBarry Smith +  pc - the preconditioner context
7697cdd61b2SBarry Smith -  presolve - the application-provided presolve routine
7707cdd61b2SBarry Smith 
7717cdd61b2SBarry Smith    Calling sequence of presolve:
7727cdd61b2SBarry Smith .vb
7736891c3e4SJed Brown    PetscErrorCode presolve (PC,KSP ksp,Vec b,Vec x)
7747cdd61b2SBarry Smith .ve
7757cdd61b2SBarry Smith 
7766891c3e4SJed Brown +  pc - the preconditioner, get the application context with PCShellGetContext()
7777cdd61b2SBarry Smith .  xin - input vector
7787cdd61b2SBarry Smith -  xout - output vector
7797cdd61b2SBarry Smith 
78095452b02SPatrick Sanan    Notes:
78195452b02SPatrick Sanan     the function MUST return an error code of 0 on success and nonzero on failure.
7824aa34b0aSBarry Smith 
7837cdd61b2SBarry Smith    Level: developer
7847cdd61b2SBarry Smith 
785be29d3c6SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetPostSolve(), PCShellSetContext()
7867cdd61b2SBarry Smith @*/
7877087cfbeSBarry Smith PetscErrorCode  PCShellSetPreSolve(PC pc,PetscErrorCode (*presolve)(PC,KSP,Vec,Vec))
7887cdd61b2SBarry Smith {
7894ac538c5SBarry Smith   PetscErrorCode ierr;
7907cdd61b2SBarry Smith 
7917cdd61b2SBarry Smith   PetscFunctionBegin;
7920700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
7934ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetPreSolve_C",(PC,PetscErrorCode (*)(PC,KSP,Vec,Vec)),(pc,presolve));CHKERRQ(ierr);
7947cdd61b2SBarry Smith   PetscFunctionReturn(0);
7957cdd61b2SBarry Smith }
7967cdd61b2SBarry Smith 
7977cdd61b2SBarry Smith /*@C
7987cdd61b2SBarry Smith    PCShellSetPostSolve - Sets routine to apply to the operators/vectors before a KSPSolve() is
7997cdd61b2SBarry Smith       applied. This usually does something like scale the linear system in some application
8007cdd61b2SBarry Smith       specific way.
8017cdd61b2SBarry Smith 
8023f9fe445SBarry Smith    Logically Collective on PC
8037cdd61b2SBarry Smith 
8047cdd61b2SBarry Smith    Input Parameters:
8057cdd61b2SBarry Smith +  pc - the preconditioner context
8067cdd61b2SBarry Smith -  postsolve - the application-provided presolve routine
8077cdd61b2SBarry Smith 
8087cdd61b2SBarry Smith    Calling sequence of postsolve:
8097cdd61b2SBarry Smith .vb
8106891c3e4SJed Brown    PetscErrorCode postsolve(PC,KSP ksp,Vec b,Vec x)
8117cdd61b2SBarry Smith .ve
8127cdd61b2SBarry Smith 
8136891c3e4SJed Brown +  pc - the preconditioner, get the application context with PCShellGetContext()
8147cdd61b2SBarry Smith .  xin - input vector
8157cdd61b2SBarry Smith -  xout - output vector
8167cdd61b2SBarry Smith 
81795452b02SPatrick Sanan    Notes:
81895452b02SPatrick Sanan     the function MUST return an error code of 0 on success and nonzero on failure.
8194aa34b0aSBarry Smith 
8207cdd61b2SBarry Smith    Level: developer
8217cdd61b2SBarry Smith 
822be29d3c6SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetPreSolve(), PCShellSetContext()
8237cdd61b2SBarry Smith @*/
8247087cfbeSBarry Smith PetscErrorCode  PCShellSetPostSolve(PC pc,PetscErrorCode (*postsolve)(PC,KSP,Vec,Vec))
8257cdd61b2SBarry Smith {
8264ac538c5SBarry Smith   PetscErrorCode ierr;
8277cdd61b2SBarry Smith 
8287cdd61b2SBarry Smith   PetscFunctionBegin;
8290700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
8304ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetPostSolve_C",(PC,PetscErrorCode (*)(PC,KSP,Vec,Vec)),(pc,postsolve));CHKERRQ(ierr);
8317cdd61b2SBarry Smith   PetscFunctionReturn(0);
8327cdd61b2SBarry Smith }
8337cdd61b2SBarry Smith 
8344b9ad928SBarry Smith /*@C
8354b9ad928SBarry Smith    PCShellSetName - Sets an optional name to associate with a shell
8364b9ad928SBarry Smith    preconditioner.
8374b9ad928SBarry Smith 
8384b9ad928SBarry Smith    Not Collective
8394b9ad928SBarry Smith 
8404b9ad928SBarry Smith    Input Parameters:
8414b9ad928SBarry Smith +  pc - the preconditioner context
8424b9ad928SBarry Smith -  name - character string describing shell preconditioner
8434b9ad928SBarry Smith 
8444b9ad928SBarry Smith    Level: developer
8454b9ad928SBarry Smith 
8464b9ad928SBarry Smith .seealso: PCShellGetName()
8474b9ad928SBarry Smith @*/
8487087cfbeSBarry Smith PetscErrorCode  PCShellSetName(PC pc,const char name[])
8494b9ad928SBarry Smith {
8504ac538c5SBarry Smith   PetscErrorCode ierr;
8514b9ad928SBarry Smith 
8524b9ad928SBarry Smith   PetscFunctionBegin;
8530700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
8544ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetName_C",(PC,const char []),(pc,name));CHKERRQ(ierr);
8554b9ad928SBarry Smith   PetscFunctionReturn(0);
8564b9ad928SBarry Smith }
8574b9ad928SBarry Smith 
8584b9ad928SBarry Smith /*@C
8594b9ad928SBarry Smith    PCShellGetName - Gets an optional name that the user has set for a shell
8604b9ad928SBarry Smith    preconditioner.
8614b9ad928SBarry Smith 
8624b9ad928SBarry Smith    Not Collective
8634b9ad928SBarry Smith 
8644b9ad928SBarry Smith    Input Parameter:
8654b9ad928SBarry Smith .  pc - the preconditioner context
8664b9ad928SBarry Smith 
8674b9ad928SBarry Smith    Output Parameter:
8684b9ad928SBarry Smith .  name - character string describing shell preconditioner (you should not free this)
8694b9ad928SBarry Smith 
8704b9ad928SBarry Smith    Level: developer
8714b9ad928SBarry Smith 
8724b9ad928SBarry Smith .seealso: PCShellSetName()
8734b9ad928SBarry Smith @*/
874ccaf0856SBarry Smith PetscErrorCode  PCShellGetName(PC pc,const char *name[])
8754b9ad928SBarry Smith {
8764ac538c5SBarry Smith   PetscErrorCode ierr;
8774b9ad928SBarry Smith 
8784b9ad928SBarry Smith   PetscFunctionBegin;
8790700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
8804482741eSBarry Smith   PetscValidPointer(name,2);
881ccaf0856SBarry Smith   ierr = PetscUseMethod(pc,"PCShellGetName_C",(PC,const char*[]),(pc,name));CHKERRQ(ierr);
8824b9ad928SBarry Smith   PetscFunctionReturn(0);
8834b9ad928SBarry Smith }
8844b9ad928SBarry Smith 
8854b9ad928SBarry Smith /*@C
8864b9ad928SBarry Smith    PCShellSetApplyRichardson - Sets routine to use as preconditioner
8874b9ad928SBarry Smith    in Richardson iteration.
8884b9ad928SBarry Smith 
8893f9fe445SBarry Smith    Logically Collective on PC
8904b9ad928SBarry Smith 
8914b9ad928SBarry Smith    Input Parameters:
8924b9ad928SBarry Smith +  pc - the preconditioner context
893be29d3c6SBarry Smith -  apply - the application-provided preconditioning routine
8944b9ad928SBarry Smith 
8954b9ad928SBarry Smith    Calling sequence of apply:
8964b9ad928SBarry Smith .vb
8976891c3e4SJed Brown    PetscErrorCode apply (PC pc,Vec b,Vec x,Vec r,PetscReal rtol,PetscReal abstol,PetscReal dtol,PetscInt maxits)
8984b9ad928SBarry Smith .ve
8994b9ad928SBarry Smith 
9006891c3e4SJed Brown +  pc - the preconditioner, get the application context with PCShellGetContext()
9014b9ad928SBarry Smith .  b - right-hand-side
9024b9ad928SBarry Smith .  x - current iterate
9034b9ad928SBarry Smith .  r - work space
9044b9ad928SBarry Smith .  rtol - relative tolerance of residual norm to stop at
90570441072SBarry Smith .  abstol - absolute tolerance of residual norm to stop at
9064b9ad928SBarry Smith .  dtol - if residual norm increases by this factor than return
9074b9ad928SBarry Smith -  maxits - number of iterations to run
9084b9ad928SBarry Smith 
90995452b02SPatrick Sanan    Notes:
91095452b02SPatrick Sanan     the function MUST return an error code of 0 on success and nonzero on failure.
9114aa34b0aSBarry Smith 
9124b9ad928SBarry Smith    Level: developer
9134b9ad928SBarry Smith 
914be29d3c6SBarry Smith .seealso: PCShellSetApply(), PCShellSetContext()
9154b9ad928SBarry Smith @*/
9167087cfbeSBarry Smith PetscErrorCode  PCShellSetApplyRichardson(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec,Vec,PetscReal,PetscReal,PetscReal,PetscInt,PetscBool,PetscInt*,PCRichardsonConvergedReason*))
9174b9ad928SBarry Smith {
9184ac538c5SBarry Smith   PetscErrorCode ierr;
9194b9ad928SBarry Smith 
9204b9ad928SBarry Smith   PetscFunctionBegin;
9210700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
9224ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetApplyRichardson_C",(PC,PetscErrorCode (*)(PC,Vec,Vec,Vec,PetscReal,PetscReal,PetscReal,PetscInt,PetscBool,PetscInt*,PCRichardsonConvergedReason*)),(pc,apply));CHKERRQ(ierr);
9234b9ad928SBarry Smith   PetscFunctionReturn(0);
9244b9ad928SBarry Smith }
9254b9ad928SBarry Smith 
9264b9ad928SBarry Smith /*MC
9274b9ad928SBarry Smith    PCSHELL - Creates a new preconditioner class for use with your
9284b9ad928SBarry Smith               own private data storage format.
9294b9ad928SBarry Smith 
9304b9ad928SBarry Smith    Level: advanced
931e0bb08deSStefano Zampini 
9324b9ad928SBarry Smith   Usage:
9336891c3e4SJed Brown $             extern PetscErrorCode apply(PC,Vec,Vec);
9346891c3e4SJed Brown $             extern PetscErrorCode applyba(PC,PCSide,Vec,Vec,Vec);
9356891c3e4SJed Brown $             extern PetscErrorCode applytranspose(PC,Vec,Vec);
9366891c3e4SJed Brown $             extern PetscErrorCode setup(PC);
9376891c3e4SJed Brown $             extern PetscErrorCode destroy(PC);
9386891c3e4SJed Brown $
9394b9ad928SBarry Smith $             PCCreate(comm,&pc);
9404b9ad928SBarry Smith $             PCSetType(pc,PCSHELL);
941be29d3c6SBarry Smith $             PCShellSetContext(pc,ctx)
9426891c3e4SJed Brown $             PCShellSetApply(pc,apply);
9436891c3e4SJed Brown $             PCShellSetApplyBA(pc,applyba);               (optional)
9446891c3e4SJed Brown $             PCShellSetApplyTranspose(pc,applytranspose); (optional)
9454b9ad928SBarry Smith $             PCShellSetSetUp(pc,setup);                   (optional)
946d01c8aa3SLisandro Dalcin $             PCShellSetDestroy(pc,destroy);               (optional)
9474b9ad928SBarry Smith 
9484b9ad928SBarry Smith .seealso:  PCCreate(), PCSetType(), PCType (for list of available types), PC,
949fd2d0fe1Svictor            MATSHELL, PCShellSetSetUp(), PCShellSetApply(), PCShellSetView(),
950fd2d0fe1Svictor            PCShellSetApplyTranspose(), PCShellSetName(), PCShellSetApplyRichardson(),
9512bb17772SBarry Smith            PCShellGetName(), PCShellSetContext(), PCShellGetContext(), PCShellSetApplyBA()
9524b9ad928SBarry Smith M*/
9534b9ad928SBarry Smith 
9548cc058d9SJed Brown PETSC_EXTERN PetscErrorCode PCCreate_Shell(PC pc)
9554b9ad928SBarry Smith {
956dfbe8321SBarry Smith   PetscErrorCode ierr;
9574b9ad928SBarry Smith   PC_Shell       *shell;
9584b9ad928SBarry Smith 
9594b9ad928SBarry Smith   PetscFunctionBegin;
960b00a9115SJed Brown   ierr     = PetscNewLog(pc,&shell);CHKERRQ(ierr);
9614b9ad928SBarry Smith   pc->data = (void*)shell;
9624b9ad928SBarry Smith 
963d01c8aa3SLisandro Dalcin   pc->ops->destroy         = PCDestroy_Shell;
9644b9ad928SBarry Smith   pc->ops->view            = PCView_Shell;
965d01c8aa3SLisandro Dalcin   pc->ops->apply           = PCApply_Shell;
9667b6e2003SPierre Jolivet   pc->ops->matapply        = PCMatApply_Shell;
9671b581b66SBarry Smith   pc->ops->applysymmetricleft  = PCApplySymmetricLeft_Shell;
9681b581b66SBarry Smith   pc->ops->applysymmetricright = PCApplySymmetricRight_Shell;
9690a545947SLisandro Dalcin   pc->ops->applytranspose  = NULL;
9700a545947SLisandro Dalcin   pc->ops->applyrichardson = NULL;
9710a545947SLisandro Dalcin   pc->ops->setup           = NULL;
9720a545947SLisandro Dalcin   pc->ops->presolve        = NULL;
9730a545947SLisandro Dalcin   pc->ops->postsolve       = NULL;
9744b9ad928SBarry Smith 
9750a545947SLisandro Dalcin   shell->apply          = NULL;
9760a545947SLisandro Dalcin   shell->applytranspose = NULL;
9770a545947SLisandro Dalcin   shell->name           = NULL;
9780a545947SLisandro Dalcin   shell->applyrich      = NULL;
9790a545947SLisandro Dalcin   shell->presolve       = NULL;
9800a545947SLisandro Dalcin   shell->postsolve      = NULL;
9810a545947SLisandro Dalcin   shell->ctx            = NULL;
9820a545947SLisandro Dalcin   shell->setup          = NULL;
9830a545947SLisandro Dalcin   shell->view           = NULL;
9840a545947SLisandro Dalcin   shell->destroy        = NULL;
9850a545947SLisandro Dalcin   shell->applysymmetricleft  = NULL;
9860a545947SLisandro Dalcin   shell->applysymmetricright = NULL;
9874b9ad928SBarry Smith 
988bdf89e91SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetDestroy_C",PCShellSetDestroy_Shell);CHKERRQ(ierr);
989bdf89e91SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetSetUp_C",PCShellSetSetUp_Shell);CHKERRQ(ierr);
990bdf89e91SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApply_C",PCShellSetApply_Shell);CHKERRQ(ierr);
9917b6e2003SPierre Jolivet   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetMatApply_C",PCShellSetMatApply_Shell);CHKERRQ(ierr);
9921b581b66SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplySymmetricLeft_C",PCShellSetApplySymmetricLeft_Shell);CHKERRQ(ierr);
9931b581b66SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplySymmetricRight_C",PCShellSetApplySymmetricRight_Shell);CHKERRQ(ierr);
994bdf89e91SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplyBA_C",PCShellSetApplyBA_Shell);CHKERRQ(ierr);
995bdf89e91SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetPreSolve_C",PCShellSetPreSolve_Shell);CHKERRQ(ierr);
996bdf89e91SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetPostSolve_C",PCShellSetPostSolve_Shell);CHKERRQ(ierr);
997bdf89e91SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetView_C",PCShellSetView_Shell);CHKERRQ(ierr);
998bdf89e91SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplyTranspose_C",PCShellSetApplyTranspose_Shell);CHKERRQ(ierr);
999bdf89e91SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetName_C",PCShellSetName_Shell);CHKERRQ(ierr);
1000bdf89e91SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellGetName_C",PCShellGetName_Shell);CHKERRQ(ierr);
1001bdf89e91SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplyRichardson_C",PCShellSetApplyRichardson_Shell);CHKERRQ(ierr);
10024b9ad928SBarry Smith   PetscFunctionReturn(0);
10034b9ad928SBarry Smith }
1004