xref: /petsc/src/ksp/pc/impls/shell/shellpc.c (revision 1b581b665160bc053f1db6f623a6eaab6b98fcae)
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);
16*1b581b66SBarry Smith   PetscErrorCode (*applysymmetricleft)(PC,Vec,Vec);
17*1b581b66SBarry 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__
134*1b581b66SBarry Smith #define __FUNCT__ "PCApplySymmetricLeft_Shell"
135*1b581b66SBarry Smith static PetscErrorCode PCApplySymmetricLeft_Shell(PC pc,Vec x,Vec y)
136*1b581b66SBarry Smith {
137*1b581b66SBarry Smith   PC_Shell       *shell = (PC_Shell*)pc->data;
138*1b581b66SBarry Smith   PetscErrorCode ierr;
139*1b581b66SBarry Smith 
140*1b581b66SBarry Smith   PetscFunctionBegin;
141*1b581b66SBarry Smith   if (!shell->applysymmetricleft) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No apply() routine provided to Shell PC");
142*1b581b66SBarry Smith   PetscStackCall("PCSHELL user function apply()",ierr = (*shell->applysymmetricleft)(pc,x,y);CHKERRQ(ierr));
143*1b581b66SBarry Smith   PetscFunctionReturn(0);
144*1b581b66SBarry Smith }
145*1b581b66SBarry Smith 
146*1b581b66SBarry Smith #undef __FUNCT__
147*1b581b66SBarry Smith #define __FUNCT__ "PCApplySymmetricRight_Shell"
148*1b581b66SBarry Smith static PetscErrorCode PCApplySymmetricRight_Shell(PC pc,Vec x,Vec y)
149*1b581b66SBarry Smith {
150*1b581b66SBarry Smith   PC_Shell       *shell = (PC_Shell*)pc->data;
151*1b581b66SBarry Smith   PetscErrorCode ierr;
152*1b581b66SBarry Smith 
153*1b581b66SBarry Smith   PetscFunctionBegin;
154*1b581b66SBarry Smith   if (!shell->applysymmetricright) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No apply() routine provided to Shell PC");
155*1b581b66SBarry Smith   PetscStackCall("PCSHELL user function apply()",ierr = (*shell->applysymmetricright)(pc,x,y);CHKERRQ(ierr));
156*1b581b66SBarry Smith   PetscFunctionReturn(0);
157*1b581b66SBarry Smith }
158*1b581b66SBarry Smith 
159*1b581b66SBarry 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__
1807cdd61b2SBarry Smith #define __FUNCT__ "PCPreSolve_Shell"
1817cdd61b2SBarry Smith static PetscErrorCode PCPreSolve_Shell(PC pc,KSP ksp,Vec b,Vec x)
1827cdd61b2SBarry Smith {
183c5ae4b9aSBarry Smith   PC_Shell       *shell = (PC_Shell*)pc->data;
1847cdd61b2SBarry Smith   PetscErrorCode ierr;
1857cdd61b2SBarry Smith 
1867cdd61b2SBarry Smith   PetscFunctionBegin;
187ce94432eSBarry Smith   if (!shell->presolve) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No presolve() routine provided to Shell PC");
188eb6b5d47SBarry Smith   PetscStackCall("PCSHELL user function presolve()",ierr = (*shell->presolve)(pc,ksp,b,x);CHKERRQ(ierr));
1897cdd61b2SBarry Smith   PetscFunctionReturn(0);
1907cdd61b2SBarry Smith }
1917cdd61b2SBarry Smith 
1927cdd61b2SBarry Smith #undef __FUNCT__
1937cdd61b2SBarry Smith #define __FUNCT__ "PCPostSolve_Shell"
1947cdd61b2SBarry Smith static PetscErrorCode PCPostSolve_Shell(PC pc,KSP ksp,Vec b,Vec x)
1957cdd61b2SBarry Smith {
196c5ae4b9aSBarry Smith   PC_Shell       *shell = (PC_Shell*)pc->data;
1977cdd61b2SBarry Smith   PetscErrorCode ierr;
1987cdd61b2SBarry Smith 
1997cdd61b2SBarry Smith   PetscFunctionBegin;
200ce94432eSBarry Smith   if (!shell->postsolve) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No postsolve() routine provided to Shell PC");
201eb6b5d47SBarry Smith   PetscStackCall("PCSHELL user function postsolve()",ierr = (*shell->postsolve)(pc,ksp,b,x);CHKERRQ(ierr));
2027cdd61b2SBarry Smith   PetscFunctionReturn(0);
2037cdd61b2SBarry Smith }
2047cdd61b2SBarry Smith 
2057cdd61b2SBarry Smith #undef __FUNCT__
2064b9ad928SBarry Smith #define __FUNCT__ "PCApplyTranspose_Shell"
2076849ba73SBarry Smith static PetscErrorCode PCApplyTranspose_Shell(PC pc,Vec x,Vec y)
2084b9ad928SBarry Smith {
209c5ae4b9aSBarry Smith   PC_Shell         *shell = (PC_Shell*)pc->data;
210dfbe8321SBarry Smith   PetscErrorCode   ierr;
211e3f487b0SBarry Smith   PetscObjectState instate,outstate;
2124b9ad928SBarry Smith 
2134b9ad928SBarry Smith   PetscFunctionBegin;
214ce94432eSBarry Smith   if (!shell->applytranspose) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No applytranspose() routine provided to Shell PC");
215e3f487b0SBarry Smith   ierr = PetscObjectStateGet((PetscObject)y, &instate);CHKERRQ(ierr);
216eb6b5d47SBarry Smith   PetscStackCall("PCSHELL user function applytranspose()",ierr = (*shell->applytranspose)(pc,x,y);CHKERRQ(ierr));
217e3f487b0SBarry Smith   ierr = PetscObjectStateGet((PetscObject)y, &outstate);CHKERRQ(ierr);
218e3f487b0SBarry Smith   if (instate == outstate) {
219e3f487b0SBarry Smith     /* increase the state of the output vector since the user did not update its state themself as should have been done */
220e3f487b0SBarry Smith     ierr = PetscObjectStateIncrease((PetscObject)y);CHKERRQ(ierr);
221e3f487b0SBarry Smith   }
2224b9ad928SBarry Smith   PetscFunctionReturn(0);
2234b9ad928SBarry Smith }
2244b9ad928SBarry Smith 
2254b9ad928SBarry Smith #undef __FUNCT__
2264b9ad928SBarry Smith #define __FUNCT__ "PCApplyRichardson_Shell"
227ace3abfcSBarry 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)
2284b9ad928SBarry Smith {
229dfbe8321SBarry Smith   PetscErrorCode   ierr;
230c5ae4b9aSBarry Smith   PC_Shell         *shell = (PC_Shell*)pc->data;
231e3f487b0SBarry Smith   PetscObjectState instate,outstate;
2324b9ad928SBarry Smith 
2334b9ad928SBarry Smith   PetscFunctionBegin;
234ce94432eSBarry Smith   if (!shell->applyrich) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_USER,"No applyrichardson() routine provided to Shell PC");
235e3f487b0SBarry Smith   ierr = PetscObjectStateGet((PetscObject)y, &instate);CHKERRQ(ierr);
236eb6b5d47SBarry Smith   PetscStackCall("PCSHELL user function applyrichardson()",ierr = (*shell->applyrich)(pc,x,y,w,rtol,abstol,dtol,it,guesszero,outits,reason);CHKERRQ(ierr));
237e3f487b0SBarry Smith   ierr = PetscObjectStateGet((PetscObject)y, &outstate);CHKERRQ(ierr);
238e3f487b0SBarry Smith   if (instate == outstate) {
239e3f487b0SBarry Smith     /* increase the state of the output vector since the user did not update its state themself as should have been done */
240e3f487b0SBarry Smith     ierr = PetscObjectStateIncrease((PetscObject)y);CHKERRQ(ierr);
241e3f487b0SBarry Smith   }
2424b9ad928SBarry Smith   PetscFunctionReturn(0);
2434b9ad928SBarry Smith }
2444b9ad928SBarry Smith 
2454b9ad928SBarry Smith #undef __FUNCT__
2464b9ad928SBarry Smith #define __FUNCT__ "PCDestroy_Shell"
2476849ba73SBarry Smith static PetscErrorCode PCDestroy_Shell(PC pc)
2484b9ad928SBarry Smith {
2494b9ad928SBarry Smith   PC_Shell       *shell = (PC_Shell*)pc->data;
250dfbe8321SBarry Smith   PetscErrorCode ierr;
2514b9ad928SBarry Smith 
2524b9ad928SBarry Smith   PetscFunctionBegin;
253503cfb0cSBarry Smith   ierr = PetscFree(shell->name);CHKERRQ(ierr);
2542fa5cd67SKarl Rupp   if (shell->destroy) PetscStackCall("PCSHELL user function destroy()",ierr = (*shell->destroy)(pc);CHKERRQ(ierr));
255c31cb41cSBarry Smith   ierr = PetscFree(pc->data);CHKERRQ(ierr);
2564b9ad928SBarry Smith   PetscFunctionReturn(0);
2574b9ad928SBarry Smith }
2584b9ad928SBarry Smith 
2594b9ad928SBarry Smith #undef __FUNCT__
2604b9ad928SBarry Smith #define __FUNCT__ "PCView_Shell"
2616849ba73SBarry Smith static PetscErrorCode PCView_Shell(PC pc,PetscViewer viewer)
2624b9ad928SBarry Smith {
2634b9ad928SBarry Smith   PC_Shell       *shell = (PC_Shell*)pc->data;
264dfbe8321SBarry Smith   PetscErrorCode ierr;
265ace3abfcSBarry Smith   PetscBool      iascii;
2664b9ad928SBarry Smith 
2674b9ad928SBarry Smith   PetscFunctionBegin;
268251f4c67SDmitry Karpeev   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&iascii);CHKERRQ(ierr);
26932077d6dSBarry Smith   if (iascii) {
2702fa5cd67SKarl Rupp     if (shell->name) {
2712fa5cd67SKarl Rupp       ierr = PetscViewerASCIIPrintf(viewer,"  Shell: %s\n",shell->name);CHKERRQ(ierr);
2722fa5cd67SKarl Rupp     } else {
2732fa5cd67SKarl Rupp       ierr = PetscViewerASCIIPrintf(viewer,"  Shell: no name\n");CHKERRQ(ierr);
2742fa5cd67SKarl Rupp     }
2754b9ad928SBarry Smith   }
2764b9ad928SBarry Smith   if (shell->view) {
2774b9ad928SBarry Smith     ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
2786891c3e4SJed Brown     ierr = (*shell->view)(pc,viewer);CHKERRQ(ierr);
2794b9ad928SBarry Smith     ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
2804b9ad928SBarry Smith   }
2814b9ad928SBarry Smith   PetscFunctionReturn(0);
2824b9ad928SBarry Smith }
2834b9ad928SBarry Smith 
2844b9ad928SBarry Smith /* ------------------------------------------------------------------------------*/
2854b9ad928SBarry Smith #undef __FUNCT__
28618be62a5SSatish Balay #define __FUNCT__ "PCShellSetDestroy_Shell"
287f7a08781SBarry Smith static PetscErrorCode  PCShellSetDestroy_Shell(PC pc, PetscErrorCode (*destroy)(PC))
28818be62a5SSatish Balay {
289c5ae4b9aSBarry Smith   PC_Shell *shell= (PC_Shell*)pc->data;
29018be62a5SSatish Balay 
29118be62a5SSatish Balay   PetscFunctionBegin;
29218be62a5SSatish Balay   shell->destroy = destroy;
29318be62a5SSatish Balay   PetscFunctionReturn(0);
29418be62a5SSatish Balay }
29518be62a5SSatish Balay 
29618be62a5SSatish Balay #undef __FUNCT__
2974b9ad928SBarry Smith #define __FUNCT__ "PCShellSetSetUp_Shell"
298f7a08781SBarry Smith static PetscErrorCode  PCShellSetSetUp_Shell(PC pc, PetscErrorCode (*setup)(PC))
2994b9ad928SBarry Smith {
300c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell*)pc->data;;
3014b9ad928SBarry Smith 
3024b9ad928SBarry Smith   PetscFunctionBegin;
3034b9ad928SBarry Smith   shell->setup = setup;
304d01c8aa3SLisandro Dalcin   if (setup) pc->ops->setup = PCSetUp_Shell;
305d01c8aa3SLisandro Dalcin   else       pc->ops->setup = 0;
3064b9ad928SBarry Smith   PetscFunctionReturn(0);
3074b9ad928SBarry Smith }
3084b9ad928SBarry Smith 
3094b9ad928SBarry Smith #undef __FUNCT__
3104b9ad928SBarry Smith #define __FUNCT__ "PCShellSetApply_Shell"
311f7a08781SBarry Smith static PetscErrorCode  PCShellSetApply_Shell(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec))
3124b9ad928SBarry Smith {
313c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell*)pc->data;
3144b9ad928SBarry Smith 
3154b9ad928SBarry Smith   PetscFunctionBegin;
3164b9ad928SBarry Smith   shell->apply = apply;
3174b9ad928SBarry Smith   PetscFunctionReturn(0);
3184b9ad928SBarry Smith }
3194b9ad928SBarry Smith 
3204b9ad928SBarry Smith #undef __FUNCT__
321*1b581b66SBarry Smith #define __FUNCT__ "PCShellSetApplySymmetricLeft_Shell"
322*1b581b66SBarry Smith static PetscErrorCode  PCShellSetApplySymmetricLeft_Shell(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec))
323*1b581b66SBarry Smith {
324*1b581b66SBarry Smith   PC_Shell *shell = (PC_Shell*)pc->data;
325*1b581b66SBarry Smith 
326*1b581b66SBarry Smith   PetscFunctionBegin;
327*1b581b66SBarry Smith   shell->applysymmetricleft = apply;
328*1b581b66SBarry Smith   PetscFunctionReturn(0);
329*1b581b66SBarry Smith }
330*1b581b66SBarry Smith 
331*1b581b66SBarry Smith #undef __FUNCT__
332*1b581b66SBarry Smith #define __FUNCT__ "PCShellSetApplySymmetricRight_Shell"
333*1b581b66SBarry Smith static PetscErrorCode  PCShellSetApplySymmetricRight_Shell(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec))
334*1b581b66SBarry Smith {
335*1b581b66SBarry Smith   PC_Shell *shell = (PC_Shell*)pc->data;
336*1b581b66SBarry Smith 
337*1b581b66SBarry Smith   PetscFunctionBegin;
338*1b581b66SBarry Smith   shell->applysymmetricright = apply;
339*1b581b66SBarry Smith   PetscFunctionReturn(0);
340*1b581b66SBarry Smith }
341*1b581b66SBarry Smith 
342*1b581b66SBarry Smith #undef __FUNCT__
3432bb17772SBarry Smith #define __FUNCT__ "PCShellSetApplyBA_Shell"
344f7a08781SBarry Smith static PetscErrorCode  PCShellSetApplyBA_Shell(PC pc,PetscErrorCode (*applyBA)(PC,PCSide,Vec,Vec,Vec))
3452bb17772SBarry Smith {
346c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell*)pc->data;
3472bb17772SBarry Smith 
3482bb17772SBarry Smith   PetscFunctionBegin;
349d01c8aa3SLisandro Dalcin   shell->applyBA = applyBA;
350d01c8aa3SLisandro Dalcin   if (applyBA) pc->ops->applyBA  = PCApplyBA_Shell;
351aef0136fSBarry Smith   else         pc->ops->applyBA  = 0;
3522bb17772SBarry Smith   PetscFunctionReturn(0);
3532bb17772SBarry Smith }
3542bb17772SBarry Smith 
3552bb17772SBarry Smith #undef __FUNCT__
3567cdd61b2SBarry Smith #define __FUNCT__ "PCShellSetPreSolve_Shell"
357f7a08781SBarry Smith static PetscErrorCode  PCShellSetPreSolve_Shell(PC pc,PetscErrorCode (*presolve)(PC,KSP,Vec,Vec))
3587cdd61b2SBarry Smith {
359c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell*)pc->data;
3607cdd61b2SBarry Smith 
3617cdd61b2SBarry Smith   PetscFunctionBegin;
3627cdd61b2SBarry Smith   shell->presolve = presolve;
363d01c8aa3SLisandro Dalcin   if (presolve) pc->ops->presolve = PCPreSolve_Shell;
364d01c8aa3SLisandro Dalcin   else          pc->ops->presolve = 0;
3657cdd61b2SBarry Smith   PetscFunctionReturn(0);
3667cdd61b2SBarry Smith }
3677cdd61b2SBarry Smith 
3687cdd61b2SBarry Smith #undef __FUNCT__
3697cdd61b2SBarry Smith #define __FUNCT__ "PCShellSetPostSolve_Shell"
370f7a08781SBarry Smith static PetscErrorCode  PCShellSetPostSolve_Shell(PC pc,PetscErrorCode (*postsolve)(PC,KSP,Vec,Vec))
3717cdd61b2SBarry Smith {
372c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell*)pc->data;
3737cdd61b2SBarry Smith 
3747cdd61b2SBarry Smith   PetscFunctionBegin;
3757cdd61b2SBarry Smith   shell->postsolve = postsolve;
376d01c8aa3SLisandro Dalcin   if (postsolve) pc->ops->postsolve = PCPostSolve_Shell;
377d01c8aa3SLisandro Dalcin   else           pc->ops->postsolve = 0;
3787cdd61b2SBarry Smith   PetscFunctionReturn(0);
3797cdd61b2SBarry Smith }
3807cdd61b2SBarry Smith 
3817cdd61b2SBarry Smith #undef __FUNCT__
3824b9ad928SBarry Smith #define __FUNCT__ "PCShellSetView_Shell"
383f7a08781SBarry Smith static PetscErrorCode  PCShellSetView_Shell(PC pc,PetscErrorCode (*view)(PC,PetscViewer))
3844b9ad928SBarry Smith {
385c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell*)pc->data;
3864b9ad928SBarry Smith 
3874b9ad928SBarry Smith   PetscFunctionBegin;
3884b9ad928SBarry Smith   shell->view = view;
3894b9ad928SBarry Smith   PetscFunctionReturn(0);
3904b9ad928SBarry Smith }
3914b9ad928SBarry Smith 
3924b9ad928SBarry Smith #undef __FUNCT__
3934b9ad928SBarry Smith #define __FUNCT__ "PCShellSetApplyTranspose_Shell"
394f7a08781SBarry Smith static PetscErrorCode  PCShellSetApplyTranspose_Shell(PC pc,PetscErrorCode (*applytranspose)(PC,Vec,Vec))
3954b9ad928SBarry Smith {
396c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell*)pc->data;
3974b9ad928SBarry Smith 
3984b9ad928SBarry Smith   PetscFunctionBegin;
3994b9ad928SBarry Smith   shell->applytranspose = applytranspose;
400d01c8aa3SLisandro Dalcin   if (applytranspose) pc->ops->applytranspose = PCApplyTranspose_Shell;
401d01c8aa3SLisandro Dalcin   else                pc->ops->applytranspose = 0;
402d01c8aa3SLisandro Dalcin   PetscFunctionReturn(0);
403d01c8aa3SLisandro Dalcin }
404d01c8aa3SLisandro Dalcin 
405d01c8aa3SLisandro Dalcin #undef __FUNCT__
406d01c8aa3SLisandro Dalcin #define __FUNCT__ "PCShellSetApplyRichardson_Shell"
407f7a08781SBarry Smith static PetscErrorCode  PCShellSetApplyRichardson_Shell(PC pc,PetscErrorCode (*applyrich)(PC,Vec,Vec,Vec,PetscReal,PetscReal,PetscReal,PetscInt,PetscBool ,PetscInt*,PCRichardsonConvergedReason*))
408d01c8aa3SLisandro Dalcin {
409c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell*)pc->data;
410d01c8aa3SLisandro Dalcin 
411d01c8aa3SLisandro Dalcin   PetscFunctionBegin;
412d01c8aa3SLisandro Dalcin   shell->applyrich = applyrich;
413d01c8aa3SLisandro Dalcin   if (applyrich) pc->ops->applyrichardson = PCApplyRichardson_Shell;
414d01c8aa3SLisandro Dalcin   else           pc->ops->applyrichardson = 0;
4154b9ad928SBarry Smith   PetscFunctionReturn(0);
4164b9ad928SBarry Smith }
4174b9ad928SBarry Smith 
4184b9ad928SBarry Smith #undef __FUNCT__
4194b9ad928SBarry Smith #define __FUNCT__ "PCShellSetName_Shell"
420f7a08781SBarry Smith static PetscErrorCode  PCShellSetName_Shell(PC pc,const char name[])
4214b9ad928SBarry Smith {
422c5ae4b9aSBarry Smith   PC_Shell       *shell = (PC_Shell*)pc->data;
423dfbe8321SBarry Smith   PetscErrorCode ierr;
4244b9ad928SBarry Smith 
4254b9ad928SBarry Smith   PetscFunctionBegin;
426503cfb0cSBarry Smith   ierr = PetscFree(shell->name);CHKERRQ(ierr);
4274b9ad928SBarry Smith   ierr = PetscStrallocpy(name,&shell->name);CHKERRQ(ierr);
4284b9ad928SBarry Smith   PetscFunctionReturn(0);
4294b9ad928SBarry Smith }
4304b9ad928SBarry Smith 
4314b9ad928SBarry Smith #undef __FUNCT__
4324b9ad928SBarry Smith #define __FUNCT__ "PCShellGetName_Shell"
433f7a08781SBarry Smith static PetscErrorCode  PCShellGetName_Shell(PC pc,const char *name[])
4344b9ad928SBarry Smith {
435c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell*)pc->data;
4364b9ad928SBarry Smith 
4374b9ad928SBarry Smith   PetscFunctionBegin;
4384b9ad928SBarry Smith   *name = shell->name;
4394b9ad928SBarry Smith   PetscFunctionReturn(0);
4404b9ad928SBarry Smith }
4414b9ad928SBarry Smith 
4424b9ad928SBarry Smith /* -------------------------------------------------------------------------------*/
4434b9ad928SBarry Smith 
4444b9ad928SBarry Smith #undef __FUNCT__
44518be62a5SSatish Balay #define __FUNCT__ "PCShellSetDestroy"
44618be62a5SSatish Balay /*@C
44718be62a5SSatish Balay    PCShellSetDestroy - Sets routine to use to destroy the user-provided
44818be62a5SSatish Balay    application context.
44918be62a5SSatish Balay 
4503f9fe445SBarry Smith    Logically Collective on PC
45118be62a5SSatish Balay 
45218be62a5SSatish Balay    Input Parameters:
45318be62a5SSatish Balay +  pc - the preconditioner context
45418be62a5SSatish Balay .  destroy - the application-provided destroy routine
45518be62a5SSatish Balay 
45618be62a5SSatish Balay    Calling sequence of destroy:
45718be62a5SSatish Balay .vb
4586891c3e4SJed Brown    PetscErrorCode destroy (PC)
45918be62a5SSatish Balay .ve
46018be62a5SSatish Balay 
46118be62a5SSatish Balay .  ptr - the application context
46218be62a5SSatish Balay 
4634aa34b0aSBarry Smith    Notes: 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 .keywords: PC, shell, set, destroy, user-provided
46818be62a5SSatish Balay 
46918be62a5SSatish Balay .seealso: PCShellSetApply(), PCShellSetContext()
47018be62a5SSatish Balay @*/
4717087cfbeSBarry Smith PetscErrorCode  PCShellSetDestroy(PC pc,PetscErrorCode (*destroy)(PC))
47218be62a5SSatish Balay {
4734ac538c5SBarry Smith   PetscErrorCode ierr;
47418be62a5SSatish Balay 
47518be62a5SSatish Balay   PetscFunctionBegin;
4760700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
4774ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetDestroy_C",(PC,PetscErrorCode (*)(PC)),(pc,destroy));CHKERRQ(ierr);
47818be62a5SSatish Balay   PetscFunctionReturn(0);
47918be62a5SSatish Balay }
48018be62a5SSatish Balay 
48118be62a5SSatish Balay 
48218be62a5SSatish Balay #undef __FUNCT__
4834b9ad928SBarry Smith #define __FUNCT__ "PCShellSetSetUp"
4844b9ad928SBarry Smith /*@C
4854b9ad928SBarry Smith    PCShellSetSetUp - Sets routine to use to "setup" the preconditioner whenever the
4864b9ad928SBarry Smith    matrix operator is changed.
4874b9ad928SBarry Smith 
4883f9fe445SBarry Smith    Logically Collective on PC
4894b9ad928SBarry Smith 
4904b9ad928SBarry Smith    Input Parameters:
4914b9ad928SBarry Smith +  pc - the preconditioner context
4924b9ad928SBarry Smith .  setup - the application-provided setup routine
4934b9ad928SBarry Smith 
4944b9ad928SBarry Smith    Calling sequence of setup:
4954b9ad928SBarry Smith .vb
4966891c3e4SJed Brown    PetscErrorCode setup (PC pc)
4974b9ad928SBarry Smith .ve
4984b9ad928SBarry Smith 
4996891c3e4SJed Brown .  pc - the preconditioner, get the application context with PCShellGetContext()
5004b9ad928SBarry Smith 
5014aa34b0aSBarry Smith    Notes: the function MUST return an error code of 0 on success and nonzero on failure.
5024aa34b0aSBarry Smith 
5034b9ad928SBarry Smith    Level: developer
5044b9ad928SBarry Smith 
5054b9ad928SBarry Smith .keywords: PC, shell, set, setup, user-provided
5064b9ad928SBarry Smith 
507be29d3c6SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetApply(), PCShellSetContext()
5084b9ad928SBarry Smith @*/
5097087cfbeSBarry Smith PetscErrorCode  PCShellSetSetUp(PC pc,PetscErrorCode (*setup)(PC))
5104b9ad928SBarry Smith {
5114ac538c5SBarry Smith   PetscErrorCode ierr;
5124b9ad928SBarry Smith 
5134b9ad928SBarry Smith   PetscFunctionBegin;
5140700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
5154ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetSetUp_C",(PC,PetscErrorCode (*)(PC)),(pc,setup));CHKERRQ(ierr);
5164b9ad928SBarry Smith   PetscFunctionReturn(0);
5174b9ad928SBarry Smith }
5184b9ad928SBarry Smith 
5194b9ad928SBarry Smith 
5204b9ad928SBarry Smith #undef __FUNCT__
5214b9ad928SBarry Smith #define __FUNCT__ "PCShellSetView"
5224b9ad928SBarry Smith /*@C
5234b9ad928SBarry Smith    PCShellSetView - Sets routine to use as viewer of shell preconditioner
5244b9ad928SBarry Smith 
5253f9fe445SBarry Smith    Logically Collective on PC
5264b9ad928SBarry Smith 
5274b9ad928SBarry Smith    Input Parameters:
5284b9ad928SBarry Smith +  pc - the preconditioner context
5294b9ad928SBarry Smith -  view - the application-provided view routine
5304b9ad928SBarry Smith 
5314b9ad928SBarry Smith    Calling sequence of apply:
5324b9ad928SBarry Smith .vb
5336891c3e4SJed Brown    PetscErrorCode view(PC pc,PetscViewer v)
5344b9ad928SBarry Smith .ve
5354b9ad928SBarry Smith 
5366891c3e4SJed Brown +  pc - the preconditioner, get the application context with PCShellGetContext()
5374b9ad928SBarry Smith -  v   - viewer
5384b9ad928SBarry Smith 
5394aa34b0aSBarry Smith    Notes: the function MUST return an error code of 0 on success and nonzero on failure.
5404aa34b0aSBarry Smith 
5414b9ad928SBarry Smith    Level: developer
5424b9ad928SBarry Smith 
5434b9ad928SBarry Smith .keywords: PC, shell, set, apply, user-provided
5444b9ad928SBarry Smith 
5454b9ad928SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose()
5464b9ad928SBarry Smith @*/
5477087cfbeSBarry Smith PetscErrorCode  PCShellSetView(PC pc,PetscErrorCode (*view)(PC,PetscViewer))
5484b9ad928SBarry Smith {
5494ac538c5SBarry Smith   PetscErrorCode ierr;
5504b9ad928SBarry Smith 
5514b9ad928SBarry Smith   PetscFunctionBegin;
5520700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
5534ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetView_C",(PC,PetscErrorCode (*)(PC,PetscViewer)),(pc,view));CHKERRQ(ierr);
5544b9ad928SBarry Smith   PetscFunctionReturn(0);
5554b9ad928SBarry Smith }
5564b9ad928SBarry Smith 
5574b9ad928SBarry Smith #undef __FUNCT__
5584b9ad928SBarry Smith #define __FUNCT__ "PCShellSetApply"
5594b9ad928SBarry Smith /*@C
5604b9ad928SBarry Smith    PCShellSetApply - Sets routine to use as preconditioner.
5614b9ad928SBarry Smith 
5623f9fe445SBarry Smith    Logically Collective on PC
5634b9ad928SBarry Smith 
5644b9ad928SBarry Smith    Input Parameters:
5654b9ad928SBarry Smith +  pc - the preconditioner context
566be29d3c6SBarry Smith -  apply - the application-provided preconditioning routine
5674b9ad928SBarry Smith 
5684b9ad928SBarry Smith    Calling sequence of apply:
5694b9ad928SBarry Smith .vb
5706891c3e4SJed Brown    PetscErrorCode apply (PC pc,Vec xin,Vec xout)
5714b9ad928SBarry Smith .ve
5724b9ad928SBarry Smith 
5736891c3e4SJed Brown +  pc - the preconditioner, get the application context with PCShellGetContext()
5744b9ad928SBarry Smith .  xin - input vector
5754b9ad928SBarry Smith -  xout - output vector
5764b9ad928SBarry Smith 
5774aa34b0aSBarry Smith    Notes: the function MUST return an error code of 0 on success and nonzero on failure.
5784aa34b0aSBarry Smith 
579292fb18eSBarry Smith    Developer Notes: There should also be a PCShellSetApplySymmetricRight() and PCShellSetApplySymmetricLeft().
580292fb18eSBarry Smith 
5814b9ad928SBarry Smith    Level: developer
5824b9ad928SBarry Smith 
5834b9ad928SBarry Smith .keywords: PC, shell, set, apply, user-provided
5844b9ad928SBarry Smith 
5852bb17772SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetContext(), PCShellSetApplyBA()
5864b9ad928SBarry Smith @*/
5877087cfbeSBarry Smith PetscErrorCode  PCShellSetApply(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec))
5884b9ad928SBarry Smith {
5894ac538c5SBarry Smith   PetscErrorCode ierr;
5904b9ad928SBarry Smith 
5914b9ad928SBarry Smith   PetscFunctionBegin;
5920700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
5934ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetApply_C",(PC,PetscErrorCode (*)(PC,Vec,Vec)),(pc,apply));CHKERRQ(ierr);
5944b9ad928SBarry Smith   PetscFunctionReturn(0);
5954b9ad928SBarry Smith }
5964b9ad928SBarry Smith 
5974b9ad928SBarry Smith #undef __FUNCT__
598*1b581b66SBarry Smith #define __FUNCT__ "PCShellSetApplySymmetricLeft"
599*1b581b66SBarry Smith /*@C
600*1b581b66SBarry Smith    PCShellSetApplySymmetricLeft - Sets routine to use as left preconditioner (when the PC_SYMMETRIC is used).
601*1b581b66SBarry Smith 
602*1b581b66SBarry Smith    Logically Collective on PC
603*1b581b66SBarry Smith 
604*1b581b66SBarry Smith    Input Parameters:
605*1b581b66SBarry Smith +  pc - the preconditioner context
606*1b581b66SBarry Smith -  apply - the application-provided left preconditioning routine
607*1b581b66SBarry Smith 
608*1b581b66SBarry Smith    Calling sequence of apply:
609*1b581b66SBarry Smith .vb
610*1b581b66SBarry Smith    PetscErrorCode apply (PC pc,Vec xin,Vec xout)
611*1b581b66SBarry Smith .ve
612*1b581b66SBarry Smith 
613*1b581b66SBarry Smith +  pc - the preconditioner, get the application context with PCShellGetContext()
614*1b581b66SBarry Smith .  xin - input vector
615*1b581b66SBarry Smith -  xout - output vector
616*1b581b66SBarry Smith 
617*1b581b66SBarry Smith    Notes: the function MUST return an error code of 0 on success and nonzero on failure.
618*1b581b66SBarry Smith 
619*1b581b66SBarry Smith    Level: developer
620*1b581b66SBarry Smith 
621*1b581b66SBarry Smith .keywords: PC, shell, set, apply, user-provided
622*1b581b66SBarry Smith 
623*1b581b66SBarry Smith .seealso: PCShellSetApply(), PCShellSetApplySymmetricLeft(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetContext()
624*1b581b66SBarry Smith @*/
625*1b581b66SBarry Smith PetscErrorCode  PCShellSetApplySymmetricLeft(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec))
626*1b581b66SBarry Smith {
627*1b581b66SBarry Smith   PetscErrorCode ierr;
628*1b581b66SBarry Smith 
629*1b581b66SBarry Smith   PetscFunctionBegin;
630*1b581b66SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
631*1b581b66SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetApplySymmetricLeft_C",(PC,PetscErrorCode (*)(PC,Vec,Vec)),(pc,apply));CHKERRQ(ierr);
632*1b581b66SBarry Smith   PetscFunctionReturn(0);
633*1b581b66SBarry Smith }
634*1b581b66SBarry Smith 
635*1b581b66SBarry Smith #undef __FUNCT__
636*1b581b66SBarry Smith #define __FUNCT__ "PCShellSetApplySymmetricRight"
637*1b581b66SBarry Smith /*@C
638*1b581b66SBarry Smith    PCShellSetApply - Sets routine to use as right preconditioner (when the PC_SYMMETRIC is used).
639*1b581b66SBarry Smith 
640*1b581b66SBarry Smith    Logically Collective on PC
641*1b581b66SBarry Smith 
642*1b581b66SBarry Smith    Input Parameters:
643*1b581b66SBarry Smith +  pc - the preconditioner context
644*1b581b66SBarry Smith -  apply - the application-provided right preconditioning routine
645*1b581b66SBarry Smith 
646*1b581b66SBarry Smith    Calling sequence of apply:
647*1b581b66SBarry Smith .vb
648*1b581b66SBarry Smith    PetscErrorCode apply (PC pc,Vec xin,Vec xout)
649*1b581b66SBarry Smith .ve
650*1b581b66SBarry Smith 
651*1b581b66SBarry Smith +  pc - the preconditioner, get the application context with PCShellGetContext()
652*1b581b66SBarry Smith .  xin - input vector
653*1b581b66SBarry Smith -  xout - output vector
654*1b581b66SBarry Smith 
655*1b581b66SBarry Smith    Notes: the function MUST return an error code of 0 on success and nonzero on failure.
656*1b581b66SBarry Smith 
657*1b581b66SBarry Smith    Level: developer
658*1b581b66SBarry Smith 
659*1b581b66SBarry Smith .keywords: PC, shell, set, apply, user-provided
660*1b581b66SBarry Smith 
661*1b581b66SBarry Smith .seealso: PCShellSetApply(), PCShellSetApplySymmetricLeft(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetContext()
662*1b581b66SBarry Smith @*/
663*1b581b66SBarry Smith PetscErrorCode  PCShellSetApplySymmetricRight(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec))
664*1b581b66SBarry Smith {
665*1b581b66SBarry Smith   PetscErrorCode ierr;
666*1b581b66SBarry Smith 
667*1b581b66SBarry Smith   PetscFunctionBegin;
668*1b581b66SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
669*1b581b66SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetApplySymmetricRight_C",(PC,PetscErrorCode (*)(PC,Vec,Vec)),(pc,apply));CHKERRQ(ierr);
670*1b581b66SBarry Smith   PetscFunctionReturn(0);
671*1b581b66SBarry Smith }
672*1b581b66SBarry Smith 
673*1b581b66SBarry Smith #undef __FUNCT__
6742bb17772SBarry Smith #define __FUNCT__ "PCShellSetApplyBA"
6752bb17772SBarry Smith /*@C
6762bb17772SBarry Smith    PCShellSetApplyBA - Sets routine to use as preconditioner times operator.
6772bb17772SBarry Smith 
6783f9fe445SBarry Smith    Logically Collective on PC
6792bb17772SBarry Smith 
6802bb17772SBarry Smith    Input Parameters:
6812bb17772SBarry Smith +  pc - the preconditioner context
6822bb17772SBarry Smith -  applyBA - the application-provided BA routine
6832bb17772SBarry Smith 
6842bb17772SBarry Smith    Calling sequence of apply:
6852bb17772SBarry Smith .vb
6866891c3e4SJed Brown    PetscErrorCode applyBA (PC pc,Vec xin,Vec xout)
6872bb17772SBarry Smith .ve
6882bb17772SBarry Smith 
6896891c3e4SJed Brown +  pc - the preconditioner, get the application context with PCShellGetContext()
6902bb17772SBarry Smith .  xin - input vector
6912bb17772SBarry Smith -  xout - output vector
6922bb17772SBarry Smith 
6934aa34b0aSBarry Smith    Notes: the function MUST return an error code of 0 on success and nonzero on failure.
6944aa34b0aSBarry Smith 
6952bb17772SBarry Smith    Level: developer
6962bb17772SBarry Smith 
6972bb17772SBarry Smith .keywords: PC, shell, set, apply, user-provided
6982bb17772SBarry Smith 
6992bb17772SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetContext(), PCShellSetApply()
7002bb17772SBarry Smith @*/
7017087cfbeSBarry Smith PetscErrorCode  PCShellSetApplyBA(PC pc,PetscErrorCode (*applyBA)(PC,PCSide,Vec,Vec,Vec))
7022bb17772SBarry Smith {
7034ac538c5SBarry Smith   PetscErrorCode ierr;
7042bb17772SBarry Smith 
7052bb17772SBarry Smith   PetscFunctionBegin;
7060700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
7074ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetApplyBA_C",(PC,PetscErrorCode (*)(PC,PCSide,Vec,Vec,Vec)),(pc,applyBA));CHKERRQ(ierr);
7082bb17772SBarry Smith   PetscFunctionReturn(0);
7092bb17772SBarry Smith }
7102bb17772SBarry Smith 
7112bb17772SBarry Smith #undef __FUNCT__
7124b9ad928SBarry Smith #define __FUNCT__ "PCShellSetApplyTranspose"
7134b9ad928SBarry Smith /*@C
7144b9ad928SBarry Smith    PCShellSetApplyTranspose - Sets routine to use as preconditioner transpose.
7154b9ad928SBarry Smith 
7163f9fe445SBarry Smith    Logically Collective on PC
7174b9ad928SBarry Smith 
7184b9ad928SBarry Smith    Input Parameters:
7194b9ad928SBarry Smith +  pc - the preconditioner context
7204b9ad928SBarry Smith -  apply - the application-provided preconditioning transpose routine
7214b9ad928SBarry Smith 
7224b9ad928SBarry Smith    Calling sequence of apply:
7234b9ad928SBarry Smith .vb
7246891c3e4SJed Brown    PetscErrorCode applytranspose (PC pc,Vec xin,Vec xout)
7254b9ad928SBarry Smith .ve
7264b9ad928SBarry Smith 
7276891c3e4SJed Brown +  pc - the preconditioner, get the application context with PCShellGetContext()
7284b9ad928SBarry Smith .  xin - input vector
7294b9ad928SBarry Smith -  xout - output vector
7304b9ad928SBarry Smith 
7314aa34b0aSBarry Smith    Notes: the function MUST return an error code of 0 on success and nonzero on failure.
7324aa34b0aSBarry Smith 
7334b9ad928SBarry Smith    Level: developer
7344b9ad928SBarry Smith 
7354b9ad928SBarry Smith    Notes:
7364b9ad928SBarry Smith    Uses the same context variable as PCShellSetApply().
7374b9ad928SBarry Smith 
7384b9ad928SBarry Smith .keywords: PC, shell, set, apply, user-provided
7394b9ad928SBarry Smith 
7402bb17772SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApply(), PCSetContext(), PCShellSetApplyBA()
7414b9ad928SBarry Smith @*/
7427087cfbeSBarry Smith PetscErrorCode  PCShellSetApplyTranspose(PC pc,PetscErrorCode (*applytranspose)(PC,Vec,Vec))
7434b9ad928SBarry Smith {
7444ac538c5SBarry Smith   PetscErrorCode ierr;
7454b9ad928SBarry Smith 
7464b9ad928SBarry Smith   PetscFunctionBegin;
7470700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
7484ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetApplyTranspose_C",(PC,PetscErrorCode (*)(PC,Vec,Vec)),(pc,applytranspose));CHKERRQ(ierr);
7494b9ad928SBarry Smith   PetscFunctionReturn(0);
7504b9ad928SBarry Smith }
7514b9ad928SBarry Smith 
7524b9ad928SBarry Smith #undef __FUNCT__
7537cdd61b2SBarry Smith #define __FUNCT__ "PCShellSetPreSolve"
7547cdd61b2SBarry Smith /*@C
7557cdd61b2SBarry Smith    PCShellSetPreSolve - Sets routine to apply to the operators/vectors before a KSPSolve() is
7567cdd61b2SBarry Smith       applied. This usually does something like scale the linear system in some application
7577cdd61b2SBarry Smith       specific way.
7587cdd61b2SBarry Smith 
7593f9fe445SBarry Smith    Logically Collective on PC
7607cdd61b2SBarry Smith 
7617cdd61b2SBarry Smith    Input Parameters:
7627cdd61b2SBarry Smith +  pc - the preconditioner context
7637cdd61b2SBarry Smith -  presolve - the application-provided presolve routine
7647cdd61b2SBarry Smith 
7657cdd61b2SBarry Smith    Calling sequence of presolve:
7667cdd61b2SBarry Smith .vb
7676891c3e4SJed Brown    PetscErrorCode presolve (PC,KSP ksp,Vec b,Vec x)
7687cdd61b2SBarry Smith .ve
7697cdd61b2SBarry Smith 
7706891c3e4SJed Brown +  pc - the preconditioner, get the application context with PCShellGetContext()
7717cdd61b2SBarry Smith .  xin - input vector
7727cdd61b2SBarry Smith -  xout - output vector
7737cdd61b2SBarry Smith 
7744aa34b0aSBarry Smith    Notes: the function MUST return an error code of 0 on success and nonzero on failure.
7754aa34b0aSBarry Smith 
7767cdd61b2SBarry Smith    Level: developer
7777cdd61b2SBarry Smith 
7787cdd61b2SBarry Smith .keywords: PC, shell, set, apply, user-provided
7797cdd61b2SBarry Smith 
780be29d3c6SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetPostSolve(), PCShellSetContext()
7817cdd61b2SBarry Smith @*/
7827087cfbeSBarry Smith PetscErrorCode  PCShellSetPreSolve(PC pc,PetscErrorCode (*presolve)(PC,KSP,Vec,Vec))
7837cdd61b2SBarry Smith {
7844ac538c5SBarry Smith   PetscErrorCode ierr;
7857cdd61b2SBarry Smith 
7867cdd61b2SBarry Smith   PetscFunctionBegin;
7870700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
7884ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetPreSolve_C",(PC,PetscErrorCode (*)(PC,KSP,Vec,Vec)),(pc,presolve));CHKERRQ(ierr);
7897cdd61b2SBarry Smith   PetscFunctionReturn(0);
7907cdd61b2SBarry Smith }
7917cdd61b2SBarry Smith 
7927cdd61b2SBarry Smith #undef __FUNCT__
7937cdd61b2SBarry Smith #define __FUNCT__ "PCShellSetPostSolve"
7947cdd61b2SBarry Smith /*@C
7957cdd61b2SBarry Smith    PCShellSetPostSolve - Sets routine to apply to the operators/vectors before a KSPSolve() is
7967cdd61b2SBarry Smith       applied. This usually does something like scale the linear system in some application
7977cdd61b2SBarry Smith       specific way.
7987cdd61b2SBarry Smith 
7993f9fe445SBarry Smith    Logically Collective on PC
8007cdd61b2SBarry Smith 
8017cdd61b2SBarry Smith    Input Parameters:
8027cdd61b2SBarry Smith +  pc - the preconditioner context
8037cdd61b2SBarry Smith -  postsolve - the application-provided presolve routine
8047cdd61b2SBarry Smith 
8057cdd61b2SBarry Smith    Calling sequence of postsolve:
8067cdd61b2SBarry Smith .vb
8076891c3e4SJed Brown    PetscErrorCode postsolve(PC,KSP ksp,Vec b,Vec x)
8087cdd61b2SBarry Smith .ve
8097cdd61b2SBarry Smith 
8106891c3e4SJed Brown +  pc - the preconditioner, get the application context with PCShellGetContext()
8117cdd61b2SBarry Smith .  xin - input vector
8127cdd61b2SBarry Smith -  xout - output vector
8137cdd61b2SBarry Smith 
8144aa34b0aSBarry Smith    Notes: the function MUST return an error code of 0 on success and nonzero on failure.
8154aa34b0aSBarry Smith 
8167cdd61b2SBarry Smith    Level: developer
8177cdd61b2SBarry Smith 
8187cdd61b2SBarry Smith .keywords: PC, shell, set, apply, user-provided
8197cdd61b2SBarry Smith 
820be29d3c6SBarry Smith .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetPreSolve(), PCShellSetContext()
8217cdd61b2SBarry Smith @*/
8227087cfbeSBarry Smith PetscErrorCode  PCShellSetPostSolve(PC pc,PetscErrorCode (*postsolve)(PC,KSP,Vec,Vec))
8237cdd61b2SBarry Smith {
8244ac538c5SBarry Smith   PetscErrorCode ierr;
8257cdd61b2SBarry Smith 
8267cdd61b2SBarry Smith   PetscFunctionBegin;
8270700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
8284ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetPostSolve_C",(PC,PetscErrorCode (*)(PC,KSP,Vec,Vec)),(pc,postsolve));CHKERRQ(ierr);
8297cdd61b2SBarry Smith   PetscFunctionReturn(0);
8307cdd61b2SBarry Smith }
8317cdd61b2SBarry Smith 
8327cdd61b2SBarry Smith #undef __FUNCT__
8334b9ad928SBarry Smith #define __FUNCT__ "PCShellSetName"
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 .keywords: PC, shell, set, name, user-provided
8474b9ad928SBarry Smith 
8484b9ad928SBarry Smith .seealso: PCShellGetName()
8494b9ad928SBarry Smith @*/
8507087cfbeSBarry Smith PetscErrorCode  PCShellSetName(PC pc,const char name[])
8514b9ad928SBarry Smith {
8524ac538c5SBarry Smith   PetscErrorCode ierr;
8534b9ad928SBarry Smith 
8544b9ad928SBarry Smith   PetscFunctionBegin;
8550700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
8564ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetName_C",(PC,const char []),(pc,name));CHKERRQ(ierr);
8574b9ad928SBarry Smith   PetscFunctionReturn(0);
8584b9ad928SBarry Smith }
8594b9ad928SBarry Smith 
8604b9ad928SBarry Smith #undef __FUNCT__
8614b9ad928SBarry Smith #define __FUNCT__ "PCShellGetName"
8624b9ad928SBarry Smith /*@C
8634b9ad928SBarry Smith    PCShellGetName - Gets an optional name that the user has set for a shell
8644b9ad928SBarry Smith    preconditioner.
8654b9ad928SBarry Smith 
8664b9ad928SBarry Smith    Not Collective
8674b9ad928SBarry Smith 
8684b9ad928SBarry Smith    Input Parameter:
8694b9ad928SBarry Smith .  pc - the preconditioner context
8704b9ad928SBarry Smith 
8714b9ad928SBarry Smith    Output Parameter:
8724b9ad928SBarry Smith .  name - character string describing shell preconditioner (you should not free this)
8734b9ad928SBarry Smith 
8744b9ad928SBarry Smith    Level: developer
8754b9ad928SBarry Smith 
8764b9ad928SBarry Smith .keywords: PC, shell, get, name, user-provided
8774b9ad928SBarry Smith 
8784b9ad928SBarry Smith .seealso: PCShellSetName()
8794b9ad928SBarry Smith @*/
880ccaf0856SBarry Smith PetscErrorCode  PCShellGetName(PC pc,const char *name[])
8814b9ad928SBarry Smith {
8824ac538c5SBarry Smith   PetscErrorCode ierr;
8834b9ad928SBarry Smith 
8844b9ad928SBarry Smith   PetscFunctionBegin;
8850700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
8864482741eSBarry Smith   PetscValidPointer(name,2);
887ccaf0856SBarry Smith   ierr = PetscUseMethod(pc,"PCShellGetName_C",(PC,const char*[]),(pc,name));CHKERRQ(ierr);
8884b9ad928SBarry Smith   PetscFunctionReturn(0);
8894b9ad928SBarry Smith }
8904b9ad928SBarry Smith 
8914b9ad928SBarry Smith #undef __FUNCT__
8924b9ad928SBarry Smith #define __FUNCT__ "PCShellSetApplyRichardson"
8934b9ad928SBarry Smith /*@C
8944b9ad928SBarry Smith    PCShellSetApplyRichardson - Sets routine to use as preconditioner
8954b9ad928SBarry Smith    in Richardson iteration.
8964b9ad928SBarry Smith 
8973f9fe445SBarry Smith    Logically Collective on PC
8984b9ad928SBarry Smith 
8994b9ad928SBarry Smith    Input Parameters:
9004b9ad928SBarry Smith +  pc - the preconditioner context
901be29d3c6SBarry Smith -  apply - the application-provided preconditioning routine
9024b9ad928SBarry Smith 
9034b9ad928SBarry Smith    Calling sequence of apply:
9044b9ad928SBarry Smith .vb
9056891c3e4SJed Brown    PetscErrorCode apply (PC pc,Vec b,Vec x,Vec r,PetscReal rtol,PetscReal abstol,PetscReal dtol,PetscInt maxits)
9064b9ad928SBarry Smith .ve
9074b9ad928SBarry Smith 
9086891c3e4SJed Brown +  pc - the preconditioner, get the application context with PCShellGetContext()
9094b9ad928SBarry Smith .  b - right-hand-side
9104b9ad928SBarry Smith .  x - current iterate
9114b9ad928SBarry Smith .  r - work space
9124b9ad928SBarry Smith .  rtol - relative tolerance of residual norm to stop at
91370441072SBarry Smith .  abstol - absolute tolerance of residual norm to stop at
9144b9ad928SBarry Smith .  dtol - if residual norm increases by this factor than return
9154b9ad928SBarry Smith -  maxits - number of iterations to run
9164b9ad928SBarry Smith 
9174aa34b0aSBarry Smith    Notes: the function MUST return an error code of 0 on success and nonzero on failure.
9184aa34b0aSBarry Smith 
9194b9ad928SBarry Smith    Level: developer
9204b9ad928SBarry Smith 
9214b9ad928SBarry Smith .keywords: PC, shell, set, apply, Richardson, user-provided
9224b9ad928SBarry Smith 
923be29d3c6SBarry Smith .seealso: PCShellSetApply(), PCShellSetContext()
9244b9ad928SBarry Smith @*/
9257087cfbeSBarry Smith PetscErrorCode  PCShellSetApplyRichardson(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec,Vec,PetscReal,PetscReal,PetscReal,PetscInt,PetscBool,PetscInt*,PCRichardsonConvergedReason*))
9264b9ad928SBarry Smith {
9274ac538c5SBarry Smith   PetscErrorCode ierr;
9284b9ad928SBarry Smith 
9294b9ad928SBarry Smith   PetscFunctionBegin;
9300700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
9314ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCShellSetApplyRichardson_C",(PC,PetscErrorCode (*)(PC,Vec,Vec,Vec,PetscReal,PetscReal,PetscReal,PetscInt,PetscBool,PetscInt*,PCRichardsonConvergedReason*)),(pc,apply));CHKERRQ(ierr);
9324b9ad928SBarry Smith   PetscFunctionReturn(0);
9334b9ad928SBarry Smith }
9344b9ad928SBarry Smith 
9354b9ad928SBarry Smith /*MC
9364b9ad928SBarry Smith    PCSHELL - Creates a new preconditioner class for use with your
9374b9ad928SBarry Smith               own private data storage format.
9384b9ad928SBarry Smith 
9394b9ad928SBarry Smith    Level: advanced
94090198e61SBarry Smith >
9414b9ad928SBarry Smith    Concepts: providing your own preconditioner
9424b9ad928SBarry Smith 
9434b9ad928SBarry Smith   Usage:
9446891c3e4SJed Brown $             extern PetscErrorCode apply(PC,Vec,Vec);
9456891c3e4SJed Brown $             extern PetscErrorCode applyba(PC,PCSide,Vec,Vec,Vec);
9466891c3e4SJed Brown $             extern PetscErrorCode applytranspose(PC,Vec,Vec);
9476891c3e4SJed Brown $             extern PetscErrorCode setup(PC);
9486891c3e4SJed Brown $             extern PetscErrorCode destroy(PC);
9496891c3e4SJed Brown $
9504b9ad928SBarry Smith $             PCCreate(comm,&pc);
9514b9ad928SBarry Smith $             PCSetType(pc,PCSHELL);
952be29d3c6SBarry Smith $             PCShellSetContext(pc,ctx)
9536891c3e4SJed Brown $             PCShellSetApply(pc,apply);
9546891c3e4SJed Brown $             PCShellSetApplyBA(pc,applyba);               (optional)
9556891c3e4SJed Brown $             PCShellSetApplyTranspose(pc,applytranspose); (optional)
9564b9ad928SBarry Smith $             PCShellSetSetUp(pc,setup);                   (optional)
957d01c8aa3SLisandro Dalcin $             PCShellSetDestroy(pc,destroy);               (optional)
9584b9ad928SBarry Smith 
9594b9ad928SBarry Smith .seealso:  PCCreate(), PCSetType(), PCType (for list of available types), PC,
960fd2d0fe1Svictor            MATSHELL, PCShellSetSetUp(), PCShellSetApply(), PCShellSetView(),
961fd2d0fe1Svictor            PCShellSetApplyTranspose(), PCShellSetName(), PCShellSetApplyRichardson(),
9622bb17772SBarry Smith            PCShellGetName(), PCShellSetContext(), PCShellGetContext(), PCShellSetApplyBA()
9634b9ad928SBarry Smith M*/
9644b9ad928SBarry Smith 
9654b9ad928SBarry Smith #undef __FUNCT__
9664b9ad928SBarry Smith #define __FUNCT__ "PCCreate_Shell"
9678cc058d9SJed Brown PETSC_EXTERN PetscErrorCode PCCreate_Shell(PC pc)
9684b9ad928SBarry Smith {
969dfbe8321SBarry Smith   PetscErrorCode ierr;
9704b9ad928SBarry Smith   PC_Shell       *shell;
9714b9ad928SBarry Smith 
9724b9ad928SBarry Smith   PetscFunctionBegin;
973b00a9115SJed Brown   ierr     = PetscNewLog(pc,&shell);CHKERRQ(ierr);
9744b9ad928SBarry Smith   pc->data = (void*)shell;
9754b9ad928SBarry Smith 
976d01c8aa3SLisandro Dalcin   pc->ops->destroy         = PCDestroy_Shell;
9774b9ad928SBarry Smith   pc->ops->view            = PCView_Shell;
978d01c8aa3SLisandro Dalcin   pc->ops->apply           = PCApply_Shell;
979*1b581b66SBarry Smith   pc->ops->applysymmetricleft  = PCApplySymmetricLeft_Shell;
980*1b581b66SBarry Smith   pc->ops->applysymmetricright = PCApplySymmetricRight_Shell;
981d01c8aa3SLisandro Dalcin   pc->ops->applytranspose  = 0;
9824b9ad928SBarry Smith   pc->ops->applyrichardson = 0;
983d01c8aa3SLisandro Dalcin   pc->ops->setup           = 0;
9849bbb2c88SBarry Smith   pc->ops->presolve        = 0;
9859bbb2c88SBarry Smith   pc->ops->postsolve       = 0;
9864b9ad928SBarry Smith 
9874b9ad928SBarry Smith   shell->apply          = 0;
9884b9ad928SBarry Smith   shell->applytranspose = 0;
9894b9ad928SBarry Smith   shell->name           = 0;
9904b9ad928SBarry Smith   shell->applyrich      = 0;
9917cdd61b2SBarry Smith   shell->presolve       = 0;
9927cdd61b2SBarry Smith   shell->postsolve      = 0;
9934b9ad928SBarry Smith   shell->ctx            = 0;
9944b9ad928SBarry Smith   shell->setup          = 0;
9954b9ad928SBarry Smith   shell->view           = 0;
99618be62a5SSatish Balay   shell->destroy        = 0;
997*1b581b66SBarry Smith   shell->applysymmetricleft  = 0;
998*1b581b66SBarry Smith   shell->applysymmetricright = 0;
9994b9ad928SBarry Smith 
1000bdf89e91SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetDestroy_C",PCShellSetDestroy_Shell);CHKERRQ(ierr);
1001bdf89e91SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetSetUp_C",PCShellSetSetUp_Shell);CHKERRQ(ierr);
1002bdf89e91SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApply_C",PCShellSetApply_Shell);CHKERRQ(ierr);
1003*1b581b66SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplySymmetricLeft_C",PCShellSetApplySymmetricLeft_Shell);CHKERRQ(ierr);
1004*1b581b66SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplySymmetricRight_C",PCShellSetApplySymmetricRight_Shell);CHKERRQ(ierr);
1005bdf89e91SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplyBA_C",PCShellSetApplyBA_Shell);CHKERRQ(ierr);
1006bdf89e91SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetPreSolve_C",PCShellSetPreSolve_Shell);CHKERRQ(ierr);
1007bdf89e91SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetPostSolve_C",PCShellSetPostSolve_Shell);CHKERRQ(ierr);
1008bdf89e91SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetView_C",PCShellSetView_Shell);CHKERRQ(ierr);
1009bdf89e91SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplyTranspose_C",PCShellSetApplyTranspose_Shell);CHKERRQ(ierr);
1010bdf89e91SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetName_C",PCShellSetName_Shell);CHKERRQ(ierr);
1011bdf89e91SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellGetName_C",PCShellGetName_Shell);CHKERRQ(ierr);
1012bdf89e91SBarry Smith   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCShellSetApplyRichardson_C",PCShellSetApplyRichardson_Shell);CHKERRQ(ierr);
10134b9ad928SBarry Smith   PetscFunctionReturn(0);
10144b9ad928SBarry Smith }
10154b9ad928SBarry Smith 
10164b9ad928SBarry Smith 
10174b9ad928SBarry Smith 
10184b9ad928SBarry Smith 
10194b9ad928SBarry Smith 
10204b9ad928SBarry Smith 
1021