xref: /petsc/src/ksp/pc/impls/shell/shellpc.c (revision 04c3f3b8f563eff258c1de90d4e02d41e6027585)
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
29*04c3f3b8SBarry Smith   PCShellGetContext - Returns the user-provided context associated with a shell `PC` that was provided with `PCShellSetContext()`
30be29d3c6SBarry Smith 
31be29d3c6SBarry Smith   Not Collective
32be29d3c6SBarry Smith 
33be29d3c6SBarry Smith   Input Parameter:
34*04c3f3b8SBarry Smith . pc - of type `PCSHELL`
35be29d3c6SBarry Smith 
36be29d3c6SBarry Smith   Output Parameter:
37be29d3c6SBarry Smith . ctx - the user provided context
38be29d3c6SBarry Smith 
39be29d3c6SBarry Smith   Level: advanced
40be29d3c6SBarry Smith 
41f1580f4eSBarry Smith   Note:
42*04c3f3b8SBarry Smith   This routine is intended for use within the various user provided shell routines such as `PCShellSetAppy()`
43be29d3c6SBarry Smith 
44*04c3f3b8SBarry Smith   Fortran Note:
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 
48*04c3f3b8SBarry Smith .seealso: `PC`, `PCSHELL`, `PCShellSetContext()`, `PCShellSetAppy()`, `PCShellSetDestroy()`
49be29d3c6SBarry Smith @*/
50d71ae5a4SJacob Faibussowitsch PetscErrorCode PCShellGetContext(PC pc, void *ctx)
51d71ae5a4SJacob Faibussowitsch {
52ace3abfcSBarry Smith   PetscBool flg;
53be29d3c6SBarry Smith 
54be29d3c6SBarry Smith   PetscFunctionBegin;
550700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
564f572ea9SToby Isaac   PetscAssertPointer(ctx, 2);
579566063dSJacob Faibussowitsch   PetscCall(PetscObjectTypeCompare((PetscObject)pc, PCSHELL, &flg));
583ec1f749SStefano Zampini   if (!flg) *(void **)ctx = NULL;
593ec1f749SStefano Zampini   else *(void **)ctx = ((PC_Shell *)(pc->data))->ctx;
603ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
61be29d3c6SBarry Smith }
62be29d3c6SBarry Smith 
639dd1005fSJed Brown /*@
64*04c3f3b8SBarry Smith   PCShellSetContext - sets the context for a shell `PC` that can be accessed with `PCShellGetContext()`
65be29d3c6SBarry Smith 
66c3339decSBarry Smith   Logically Collective
67be29d3c6SBarry Smith 
68be29d3c6SBarry Smith   Input Parameters:
69f1580f4eSBarry Smith + pc  - the `PC` of type `PCSHELL`
70be29d3c6SBarry Smith - ctx - the context
71be29d3c6SBarry Smith 
72be29d3c6SBarry Smith   Level: advanced
73be29d3c6SBarry Smith 
74*04c3f3b8SBarry Smith   Notes:
75*04c3f3b8SBarry Smith   This routine is intended for use within the various user-provided shell routines such as `PCShellSetAppy()`
76*04c3f3b8SBarry Smith 
77*04c3f3b8SBarry Smith   One should also provide a routine to destroy the context when `pc` is destroyed with `PCShellSetDestroy()`
78*04c3f3b8SBarry Smith 
79feefa0e1SJacob Faibussowitsch   Fortran Notes:
8095452b02SPatrick Sanan   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 
83*04c3f3b8SBarry Smith .seealso: `PC`, `PCShellGetContext()`, `PCSHELL`, `PCShellSetAppy()`, `PCShellSetDestroy()`
84be29d3c6SBarry Smith @*/
85d71ae5a4SJacob Faibussowitsch PetscErrorCode PCShellSetContext(PC pc, void *ctx)
86d71ae5a4SJacob Faibussowitsch {
87c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell *)pc->data;
88ace3abfcSBarry Smith   PetscBool flg;
89be29d3c6SBarry Smith 
90be29d3c6SBarry Smith   PetscFunctionBegin;
910700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
929566063dSJacob Faibussowitsch   PetscCall(PetscObjectTypeCompare((PetscObject)pc, PCSHELL, &flg));
932fa5cd67SKarl Rupp   if (flg) shell->ctx = ctx;
943ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
95be29d3c6SBarry Smith }
96be29d3c6SBarry Smith 
97d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCSetUp_Shell(PC pc)
98d71ae5a4SJacob Faibussowitsch {
99c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell *)pc->data;
1004b9ad928SBarry Smith 
1014b9ad928SBarry Smith   PetscFunctionBegin;
10228b400f6SJacob Faibussowitsch   PetscCheck(shell->setup, PetscObjectComm((PetscObject)pc), PETSC_ERR_USER, "No setup() routine provided to Shell PC");
10325e27a38SBarry Smith   PetscCallBack("PCSHELL callback setup", (*shell->setup)(pc));
1043ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
1054b9ad928SBarry Smith }
1064b9ad928SBarry Smith 
107d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCApply_Shell(PC pc, Vec x, Vec y)
108d71ae5a4SJacob Faibussowitsch {
109c5ae4b9aSBarry Smith   PC_Shell        *shell = (PC_Shell *)pc->data;
110e3f487b0SBarry Smith   PetscObjectState instate, outstate;
1114b9ad928SBarry Smith 
1124b9ad928SBarry Smith   PetscFunctionBegin;
11328b400f6SJacob Faibussowitsch   PetscCheck(shell->apply, PetscObjectComm((PetscObject)pc), PETSC_ERR_USER, "No apply() routine provided to Shell PC");
1149566063dSJacob Faibussowitsch   PetscCall(PetscObjectStateGet((PetscObject)y, &instate));
11525e27a38SBarry Smith   PetscCallBack("PCSHELL callback apply", (*shell->apply)(pc, x, y));
1169566063dSJacob Faibussowitsch   PetscCall(PetscObjectStateGet((PetscObject)y, &outstate));
1171e66621cSBarry Smith   /* increase the state of the output vector if the user did not update its state themself as should have been done */
1181e66621cSBarry Smith   if (instate == outstate) PetscCall(PetscObjectStateIncrease((PetscObject)y));
1193ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
1204b9ad928SBarry Smith }
1214b9ad928SBarry Smith 
122d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCMatApply_Shell(PC pc, Mat X, Mat Y)
123d71ae5a4SJacob Faibussowitsch {
1247b6e2003SPierre Jolivet   PC_Shell        *shell = (PC_Shell *)pc->data;
1257b6e2003SPierre Jolivet   PetscObjectState instate, outstate;
1267b6e2003SPierre Jolivet 
1277b6e2003SPierre Jolivet   PetscFunctionBegin;
12828b400f6SJacob Faibussowitsch   PetscCheck(shell->matapply, PetscObjectComm((PetscObject)pc), PETSC_ERR_USER, "No apply() routine provided to Shell PC");
1299566063dSJacob Faibussowitsch   PetscCall(PetscObjectStateGet((PetscObject)Y, &instate));
13025e27a38SBarry Smith   PetscCallBack("PCSHELL callback apply", (*shell->matapply)(pc, X, Y));
1319566063dSJacob Faibussowitsch   PetscCall(PetscObjectStateGet((PetscObject)Y, &outstate));
1321e66621cSBarry Smith   /* increase the state of the output vector if the user did not update its state themself as should have been done */
1331e66621cSBarry Smith   if (instate == outstate) PetscCall(PetscObjectStateIncrease((PetscObject)Y));
1343ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
1357b6e2003SPierre Jolivet }
1367b6e2003SPierre Jolivet 
137d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCApplySymmetricLeft_Shell(PC pc, Vec x, Vec y)
138d71ae5a4SJacob Faibussowitsch {
1391b581b66SBarry Smith   PC_Shell *shell = (PC_Shell *)pc->data;
1401b581b66SBarry Smith 
1411b581b66SBarry Smith   PetscFunctionBegin;
14228b400f6SJacob Faibussowitsch   PetscCheck(shell->applysymmetricleft, PetscObjectComm((PetscObject)pc), PETSC_ERR_USER, "No apply() routine provided to Shell PC");
14325e27a38SBarry Smith   PetscCallBack("PCSHELL callback apply symmetric left", (*shell->applysymmetricleft)(pc, x, y));
1443ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
1451b581b66SBarry Smith }
1461b581b66SBarry Smith 
147d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCApplySymmetricRight_Shell(PC pc, Vec x, Vec y)
148d71ae5a4SJacob Faibussowitsch {
1491b581b66SBarry Smith   PC_Shell *shell = (PC_Shell *)pc->data;
1501b581b66SBarry Smith 
1511b581b66SBarry Smith   PetscFunctionBegin;
15228b400f6SJacob Faibussowitsch   PetscCheck(shell->applysymmetricright, PetscObjectComm((PetscObject)pc), PETSC_ERR_USER, "No apply() routine provided to Shell PC");
15325e27a38SBarry Smith   PetscCallBack("PCSHELL callback apply symmetric right", (*shell->applysymmetricright)(pc, x, y));
1543ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
1551b581b66SBarry Smith }
1561b581b66SBarry Smith 
157d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCApplyBA_Shell(PC pc, PCSide side, Vec x, Vec y, Vec w)
158d71ae5a4SJacob Faibussowitsch {
159c5ae4b9aSBarry Smith   PC_Shell        *shell = (PC_Shell *)pc->data;
160e3f487b0SBarry Smith   PetscObjectState instate, outstate;
1612bb17772SBarry Smith 
1622bb17772SBarry Smith   PetscFunctionBegin;
16328b400f6SJacob Faibussowitsch   PetscCheck(shell->applyBA, PetscObjectComm((PetscObject)pc), PETSC_ERR_USER, "No applyBA() routine provided to Shell PC");
1649566063dSJacob Faibussowitsch   PetscCall(PetscObjectStateGet((PetscObject)w, &instate));
16525e27a38SBarry Smith   PetscCallBack("PCSHELL callback applyBA", (*shell->applyBA)(pc, side, x, y, w));
1669566063dSJacob Faibussowitsch   PetscCall(PetscObjectStateGet((PetscObject)w, &outstate));
1671e66621cSBarry Smith   /* increase the state of the output vector if the user did not update its state themself as should have been done */
1681e66621cSBarry Smith   if (instate == outstate) PetscCall(PetscObjectStateIncrease((PetscObject)w));
1693ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
1702bb17772SBarry Smith }
1712bb17772SBarry Smith 
172d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCPreSolveChangeRHS_Shell(PC pc, PetscBool *change)
173d71ae5a4SJacob Faibussowitsch {
174a06fd7f2SStefano Zampini   PetscFunctionBegin;
175a06fd7f2SStefano Zampini   *change = PETSC_TRUE;
1763ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
177a06fd7f2SStefano Zampini }
178a06fd7f2SStefano Zampini 
179d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCPreSolve_Shell(PC pc, KSP ksp, Vec b, Vec x)
180d71ae5a4SJacob Faibussowitsch {
181c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell *)pc->data;
1827cdd61b2SBarry Smith 
1837cdd61b2SBarry Smith   PetscFunctionBegin;
18428b400f6SJacob Faibussowitsch   PetscCheck(shell->presolve, PetscObjectComm((PetscObject)pc), PETSC_ERR_USER, "No presolve() routine provided to Shell PC");
18525e27a38SBarry Smith   PetscCallBack("PCSHELL callback presolve", (*shell->presolve)(pc, ksp, b, x));
1863ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
1877cdd61b2SBarry Smith }
1887cdd61b2SBarry Smith 
189d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCPostSolve_Shell(PC pc, KSP ksp, Vec b, Vec x)
190d71ae5a4SJacob Faibussowitsch {
191c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell *)pc->data;
1927cdd61b2SBarry Smith 
1937cdd61b2SBarry Smith   PetscFunctionBegin;
19428b400f6SJacob Faibussowitsch   PetscCheck(shell->postsolve, PetscObjectComm((PetscObject)pc), PETSC_ERR_USER, "No postsolve() routine provided to Shell PC");
19525e27a38SBarry Smith   PetscCallBack("PCSHELL callback postsolve()", (*shell->postsolve)(pc, ksp, b, x));
1963ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
1977cdd61b2SBarry Smith }
1987cdd61b2SBarry Smith 
199d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCApplyTranspose_Shell(PC pc, Vec x, Vec y)
200d71ae5a4SJacob Faibussowitsch {
201c5ae4b9aSBarry Smith   PC_Shell        *shell = (PC_Shell *)pc->data;
202e3f487b0SBarry Smith   PetscObjectState instate, outstate;
2034b9ad928SBarry Smith 
2044b9ad928SBarry Smith   PetscFunctionBegin;
20528b400f6SJacob Faibussowitsch   PetscCheck(shell->applytranspose, PetscObjectComm((PetscObject)pc), PETSC_ERR_USER, "No applytranspose() routine provided to Shell PC");
2069566063dSJacob Faibussowitsch   PetscCall(PetscObjectStateGet((PetscObject)y, &instate));
20725e27a38SBarry Smith   PetscCallBack("PCSHELL callback applytranspose", (*shell->applytranspose)(pc, x, y));
2089566063dSJacob Faibussowitsch   PetscCall(PetscObjectStateGet((PetscObject)y, &outstate));
2091e66621cSBarry Smith   /* increase the state of the output vector if the user did not update its state themself as should have been done */
2101e66621cSBarry Smith   if (instate == outstate) PetscCall(PetscObjectStateIncrease((PetscObject)y));
2113ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
2124b9ad928SBarry Smith }
2134b9ad928SBarry Smith 
214d71ae5a4SJacob Faibussowitsch 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)
215d71ae5a4SJacob Faibussowitsch {
216c5ae4b9aSBarry Smith   PC_Shell        *shell = (PC_Shell *)pc->data;
217e3f487b0SBarry Smith   PetscObjectState instate, outstate;
2184b9ad928SBarry Smith 
2194b9ad928SBarry Smith   PetscFunctionBegin;
22028b400f6SJacob Faibussowitsch   PetscCheck(shell->applyrich, PetscObjectComm((PetscObject)pc), PETSC_ERR_USER, "No applyrichardson() routine provided to Shell PC");
2219566063dSJacob Faibussowitsch   PetscCall(PetscObjectStateGet((PetscObject)y, &instate));
22225e27a38SBarry Smith   PetscCallBack("PCSHELL callback applyrichardson", (*shell->applyrich)(pc, x, y, w, rtol, abstol, dtol, it, guesszero, outits, reason));
2239566063dSJacob Faibussowitsch   PetscCall(PetscObjectStateGet((PetscObject)y, &outstate));
224e3f487b0SBarry Smith   /* increase the state of the output vector since the user did not update its state themself as should have been done */
2251e66621cSBarry Smith   if (instate == outstate) PetscCall(PetscObjectStateIncrease((PetscObject)y));
2263ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
2274b9ad928SBarry Smith }
2284b9ad928SBarry Smith 
229d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCDestroy_Shell(PC pc)
230d71ae5a4SJacob Faibussowitsch {
2314b9ad928SBarry Smith   PC_Shell *shell = (PC_Shell *)pc->data;
2324b9ad928SBarry Smith 
2334b9ad928SBarry Smith   PetscFunctionBegin;
2349566063dSJacob Faibussowitsch   PetscCall(PetscFree(shell->name));
23525e27a38SBarry Smith   if (shell->destroy) PetscCallBack("PCSHELL callback destroy", (*shell->destroy)(pc));
2369566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetDestroy_C", NULL));
2379566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetSetUp_C", NULL));
2389566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetApply_C", NULL));
2399566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetMatApply_C", NULL));
2409566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetApplySymmetricLeft_C", NULL));
2419566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetApplySymmetricRight_C", NULL));
2429566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetApplyBA_C", NULL));
2439566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetPreSolve_C", NULL));
2449566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetPostSolve_C", NULL));
2459566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetView_C", NULL));
2469566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetApplyTranspose_C", NULL));
2479566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetName_C", NULL));
2489566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellGetName_C", NULL));
2499566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetApplyRichardson_C", NULL));
2509566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCPreSolveChangeRHS_C", NULL));
2519566063dSJacob Faibussowitsch   PetscCall(PetscFree(pc->data));
2523ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
2534b9ad928SBarry Smith }
2544b9ad928SBarry Smith 
255d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCView_Shell(PC pc, PetscViewer viewer)
256d71ae5a4SJacob Faibussowitsch {
2574b9ad928SBarry Smith   PC_Shell *shell = (PC_Shell *)pc->data;
258ace3abfcSBarry Smith   PetscBool iascii;
2594b9ad928SBarry Smith 
2604b9ad928SBarry Smith   PetscFunctionBegin;
2619566063dSJacob Faibussowitsch   PetscCall(PetscObjectTypeCompare((PetscObject)viewer, PETSCVIEWERASCII, &iascii));
26232077d6dSBarry Smith   if (iascii) {
2631e66621cSBarry Smith     if (shell->name) PetscCall(PetscViewerASCIIPrintf(viewer, "  %s\n", shell->name));
2641e66621cSBarry Smith     else PetscCall(PetscViewerASCIIPrintf(viewer, "  no name\n"));
2654b9ad928SBarry Smith   }
2664b9ad928SBarry Smith   if (shell->view) {
2679566063dSJacob Faibussowitsch     PetscCall(PetscViewerASCIIPushTab(viewer));
2689566063dSJacob Faibussowitsch     PetscCall((*shell->view)(pc, viewer));
2699566063dSJacob Faibussowitsch     PetscCall(PetscViewerASCIIPopTab(viewer));
2704b9ad928SBarry Smith   }
2713ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
2724b9ad928SBarry Smith }
2734b9ad928SBarry Smith 
274d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCShellSetDestroy_Shell(PC pc, PetscErrorCode (*destroy)(PC))
275d71ae5a4SJacob Faibussowitsch {
276c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell *)pc->data;
27718be62a5SSatish Balay 
27818be62a5SSatish Balay   PetscFunctionBegin;
27918be62a5SSatish Balay   shell->destroy = destroy;
2803ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
28118be62a5SSatish Balay }
28218be62a5SSatish Balay 
283d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCShellSetSetUp_Shell(PC pc, PetscErrorCode (*setup)(PC))
284d71ae5a4SJacob Faibussowitsch {
285feb237baSPierre Jolivet   PC_Shell *shell = (PC_Shell *)pc->data;
2864b9ad928SBarry Smith 
2874b9ad928SBarry Smith   PetscFunctionBegin;
2884b9ad928SBarry Smith   shell->setup = setup;
289d01c8aa3SLisandro Dalcin   if (setup) pc->ops->setup = PCSetUp_Shell;
2900a545947SLisandro Dalcin   else pc->ops->setup = NULL;
2913ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
2924b9ad928SBarry Smith }
2934b9ad928SBarry Smith 
294d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCShellSetApply_Shell(PC pc, PetscErrorCode (*apply)(PC, Vec, Vec))
295d71ae5a4SJacob Faibussowitsch {
296c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell *)pc->data;
2974b9ad928SBarry Smith 
2984b9ad928SBarry Smith   PetscFunctionBegin;
2994b9ad928SBarry Smith   shell->apply = apply;
3003ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
3014b9ad928SBarry Smith }
3024b9ad928SBarry Smith 
303d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCShellSetMatApply_Shell(PC pc, PetscErrorCode (*matapply)(PC, Mat, Mat))
304d71ae5a4SJacob Faibussowitsch {
3057b6e2003SPierre Jolivet   PC_Shell *shell = (PC_Shell *)pc->data;
3067b6e2003SPierre Jolivet 
3077b6e2003SPierre Jolivet   PetscFunctionBegin;
3087b6e2003SPierre Jolivet   shell->matapply = matapply;
3090e0fe96bSStefano Zampini   if (matapply) pc->ops->matapply = PCMatApply_Shell;
3100e0fe96bSStefano Zampini   else pc->ops->matapply = NULL;
3113ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
3127b6e2003SPierre Jolivet }
3137b6e2003SPierre Jolivet 
314d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCShellSetApplySymmetricLeft_Shell(PC pc, PetscErrorCode (*apply)(PC, Vec, Vec))
315d71ae5a4SJacob Faibussowitsch {
3161b581b66SBarry Smith   PC_Shell *shell = (PC_Shell *)pc->data;
3171b581b66SBarry Smith 
3181b581b66SBarry Smith   PetscFunctionBegin;
3191b581b66SBarry Smith   shell->applysymmetricleft = apply;
3203ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
3211b581b66SBarry Smith }
3221b581b66SBarry Smith 
323d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCShellSetApplySymmetricRight_Shell(PC pc, PetscErrorCode (*apply)(PC, Vec, Vec))
324d71ae5a4SJacob Faibussowitsch {
3251b581b66SBarry Smith   PC_Shell *shell = (PC_Shell *)pc->data;
3261b581b66SBarry Smith 
3271b581b66SBarry Smith   PetscFunctionBegin;
3281b581b66SBarry Smith   shell->applysymmetricright = apply;
3293ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
3301b581b66SBarry Smith }
3311b581b66SBarry Smith 
332d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCShellSetApplyBA_Shell(PC pc, PetscErrorCode (*applyBA)(PC, PCSide, Vec, Vec, Vec))
333d71ae5a4SJacob Faibussowitsch {
334c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell *)pc->data;
3352bb17772SBarry Smith 
3362bb17772SBarry Smith   PetscFunctionBegin;
337d01c8aa3SLisandro Dalcin   shell->applyBA = applyBA;
338d01c8aa3SLisandro Dalcin   if (applyBA) pc->ops->applyBA = PCApplyBA_Shell;
3390a545947SLisandro Dalcin   else pc->ops->applyBA = NULL;
3403ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
3412bb17772SBarry Smith }
3422bb17772SBarry Smith 
343d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCShellSetPreSolve_Shell(PC pc, PetscErrorCode (*presolve)(PC, KSP, Vec, Vec))
344d71ae5a4SJacob Faibussowitsch {
345c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell *)pc->data;
3467cdd61b2SBarry Smith 
3477cdd61b2SBarry Smith   PetscFunctionBegin;
3487cdd61b2SBarry Smith   shell->presolve = presolve;
349a06fd7f2SStefano Zampini   if (presolve) {
350a06fd7f2SStefano Zampini     pc->ops->presolve = PCPreSolve_Shell;
3519566063dSJacob Faibussowitsch     PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCPreSolveChangeRHS_C", PCPreSolveChangeRHS_Shell));
352a06fd7f2SStefano Zampini   } else {
3530a545947SLisandro Dalcin     pc->ops->presolve = NULL;
3549566063dSJacob Faibussowitsch     PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCPreSolveChangeRHS_C", NULL));
355a06fd7f2SStefano Zampini   }
3563ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
3577cdd61b2SBarry Smith }
3587cdd61b2SBarry Smith 
359d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCShellSetPostSolve_Shell(PC pc, PetscErrorCode (*postsolve)(PC, KSP, Vec, Vec))
360d71ae5a4SJacob Faibussowitsch {
361c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell *)pc->data;
3627cdd61b2SBarry Smith 
3637cdd61b2SBarry Smith   PetscFunctionBegin;
3647cdd61b2SBarry Smith   shell->postsolve = postsolve;
365d01c8aa3SLisandro Dalcin   if (postsolve) pc->ops->postsolve = PCPostSolve_Shell;
3660a545947SLisandro Dalcin   else pc->ops->postsolve = NULL;
3673ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
3687cdd61b2SBarry Smith }
3697cdd61b2SBarry Smith 
370d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCShellSetView_Shell(PC pc, PetscErrorCode (*view)(PC, PetscViewer))
371d71ae5a4SJacob Faibussowitsch {
372c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell *)pc->data;
3734b9ad928SBarry Smith 
3744b9ad928SBarry Smith   PetscFunctionBegin;
3754b9ad928SBarry Smith   shell->view = view;
3763ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
3774b9ad928SBarry Smith }
3784b9ad928SBarry Smith 
379d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCShellSetApplyTranspose_Shell(PC pc, PetscErrorCode (*applytranspose)(PC, Vec, Vec))
380d71ae5a4SJacob Faibussowitsch {
381c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell *)pc->data;
3824b9ad928SBarry Smith 
3834b9ad928SBarry Smith   PetscFunctionBegin;
3844b9ad928SBarry Smith   shell->applytranspose = applytranspose;
385d01c8aa3SLisandro Dalcin   if (applytranspose) pc->ops->applytranspose = PCApplyTranspose_Shell;
3860a545947SLisandro Dalcin   else pc->ops->applytranspose = NULL;
3873ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
388d01c8aa3SLisandro Dalcin }
389d01c8aa3SLisandro Dalcin 
390d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCShellSetApplyRichardson_Shell(PC pc, PetscErrorCode (*applyrich)(PC, Vec, Vec, Vec, PetscReal, PetscReal, PetscReal, PetscInt, PetscBool, PetscInt *, PCRichardsonConvergedReason *))
391d71ae5a4SJacob Faibussowitsch {
392c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell *)pc->data;
393d01c8aa3SLisandro Dalcin 
394d01c8aa3SLisandro Dalcin   PetscFunctionBegin;
395d01c8aa3SLisandro Dalcin   shell->applyrich = applyrich;
396d01c8aa3SLisandro Dalcin   if (applyrich) pc->ops->applyrichardson = PCApplyRichardson_Shell;
3970a545947SLisandro Dalcin   else pc->ops->applyrichardson = NULL;
3983ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
3994b9ad928SBarry Smith }
4004b9ad928SBarry Smith 
401d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCShellSetName_Shell(PC pc, const char name[])
402d71ae5a4SJacob Faibussowitsch {
403c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell *)pc->data;
4044b9ad928SBarry Smith 
4054b9ad928SBarry Smith   PetscFunctionBegin;
4069566063dSJacob Faibussowitsch   PetscCall(PetscFree(shell->name));
4079566063dSJacob Faibussowitsch   PetscCall(PetscStrallocpy(name, &shell->name));
4083ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
4094b9ad928SBarry Smith }
4104b9ad928SBarry Smith 
411d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCShellGetName_Shell(PC pc, const char *name[])
412d71ae5a4SJacob Faibussowitsch {
413c5ae4b9aSBarry Smith   PC_Shell *shell = (PC_Shell *)pc->data;
4144b9ad928SBarry Smith 
4154b9ad928SBarry Smith   PetscFunctionBegin;
4164b9ad928SBarry Smith   *name = shell->name;
4173ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
4184b9ad928SBarry Smith }
4194b9ad928SBarry Smith 
42018be62a5SSatish Balay /*@C
421*04c3f3b8SBarry Smith   PCShellSetDestroy - Sets routine to use to destroy the user-provided application context that was provided with `PCShellSetContext()`
42218be62a5SSatish Balay 
423c3339decSBarry Smith   Logically Collective
42418be62a5SSatish Balay 
42518be62a5SSatish Balay   Input Parameters:
42618be62a5SSatish Balay + pc      - the preconditioner context
427a2b725a8SWilliam Gropp - destroy - the application-provided destroy routine
42818be62a5SSatish Balay 
42920f4b53cSBarry Smith   Calling sequence of `destroy`:
430*04c3f3b8SBarry Smith . pc - the preconditioner
4314aa34b0aSBarry Smith 
432f1580f4eSBarry Smith   Level: intermediate
43318be62a5SSatish Balay 
434*04c3f3b8SBarry Smith .seealso: `PCSHELL`, `PCShellSetApply()`, `PCShellSetContext()`, `PCShellGetContext()`
43518be62a5SSatish Balay @*/
436*04c3f3b8SBarry Smith PetscErrorCode PCShellSetDestroy(PC pc, PetscErrorCode (*destroy)(PC pc))
437d71ae5a4SJacob Faibussowitsch {
43818be62a5SSatish Balay   PetscFunctionBegin;
4390700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
440cac4c232SBarry Smith   PetscTryMethod(pc, "PCShellSetDestroy_C", (PC, PetscErrorCode(*)(PC)), (pc, destroy));
4413ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
44218be62a5SSatish Balay }
44318be62a5SSatish Balay 
4444b9ad928SBarry Smith /*@C
4454b9ad928SBarry Smith   PCShellSetSetUp - Sets routine to use to "setup" the preconditioner whenever the
4464b9ad928SBarry Smith   matrix operator is changed.
4474b9ad928SBarry Smith 
448c3339decSBarry Smith   Logically Collective
4494b9ad928SBarry Smith 
4504b9ad928SBarry Smith   Input Parameters:
4514b9ad928SBarry Smith + pc    - the preconditioner context
452a2b725a8SWilliam Gropp - setup - the application-provided setup routine
4534b9ad928SBarry Smith 
45420f4b53cSBarry Smith   Calling sequence of `setup`:
455*04c3f3b8SBarry Smith . pc - the preconditioner
4564aa34b0aSBarry Smith 
457f1580f4eSBarry Smith   Level: intermediate
4584b9ad928SBarry Smith 
459*04c3f3b8SBarry Smith   Note:
460*04c3f3b8SBarry Smith   You can get the `PCSHELL` context set with `PCShellSetContext()` using `PCShellGetContext()` if needed by `setup`.
461*04c3f3b8SBarry Smith 
462*04c3f3b8SBarry Smith .seealso: `PCSHELL`, `PCShellSetApplyRichardson()`, `PCShellSetApply()`, `PCShellSetContext()`, , `PCShellGetContext()`
4634b9ad928SBarry Smith @*/
464*04c3f3b8SBarry Smith PetscErrorCode PCShellSetSetUp(PC pc, PetscErrorCode (*setup)(PC pc))
465d71ae5a4SJacob Faibussowitsch {
4664b9ad928SBarry Smith   PetscFunctionBegin;
4670700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
468cac4c232SBarry Smith   PetscTryMethod(pc, "PCShellSetSetUp_C", (PC, PetscErrorCode(*)(PC)), (pc, setup));
4693ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
4704b9ad928SBarry Smith }
4714b9ad928SBarry Smith 
4724b9ad928SBarry Smith /*@C
473*04c3f3b8SBarry Smith   PCShellSetView - Sets routine to use as viewer of a `PCSHELL` shell preconditioner
4744b9ad928SBarry Smith 
475c3339decSBarry Smith   Logically Collective
4764b9ad928SBarry Smith 
4774b9ad928SBarry Smith   Input Parameters:
4784b9ad928SBarry Smith + pc   - the preconditioner context
4794b9ad928SBarry Smith - view - the application-provided view routine
4804b9ad928SBarry Smith 
48120f4b53cSBarry Smith   Calling sequence of `view`:
482*04c3f3b8SBarry Smith + pc - the preconditioner
4834b9ad928SBarry Smith - v  - viewer
4844b9ad928SBarry Smith 
485f1580f4eSBarry Smith   Level: advanced
4864b9ad928SBarry Smith 
487*04c3f3b8SBarry Smith   Note:
488*04c3f3b8SBarry Smith   You can get the `PCSHELL` context set with `PCShellSetContext()` using `PCShellGetContext()` if needed by `view`.
489*04c3f3b8SBarry Smith 
490*04c3f3b8SBarry Smith .seealso: `PC`, `PCSHELL`, `PCShellSetApplyRichardson()`, `PCShellSetSetUp()`, `PCShellSetApplyTranspose()`, `PCShellSetContext()`, `PCShellGetContext()`
4914b9ad928SBarry Smith @*/
492*04c3f3b8SBarry Smith PetscErrorCode PCShellSetView(PC pc, PetscErrorCode (*view)(PC pc, PetscViewer v))
493d71ae5a4SJacob Faibussowitsch {
4944b9ad928SBarry Smith   PetscFunctionBegin;
4950700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
496cac4c232SBarry Smith   PetscTryMethod(pc, "PCShellSetView_C", (PC, PetscErrorCode(*)(PC, PetscViewer)), (pc, view));
4973ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
4984b9ad928SBarry Smith }
4994b9ad928SBarry Smith 
5004b9ad928SBarry Smith /*@C
5014b9ad928SBarry Smith   PCShellSetApply - Sets routine to use as preconditioner.
5024b9ad928SBarry Smith 
503c3339decSBarry Smith   Logically Collective
5044b9ad928SBarry Smith 
5054b9ad928SBarry Smith   Input Parameters:
5064b9ad928SBarry Smith + pc    - the preconditioner context
507be29d3c6SBarry Smith - apply - the application-provided preconditioning routine
5084b9ad928SBarry Smith 
50920f4b53cSBarry Smith   Calling sequence of `apply`:
51020f4b53cSBarry Smith + pc   - the preconditioner, get the application context with `PCShellGetContext()`
5114b9ad928SBarry Smith . xin  - input vector
5124b9ad928SBarry Smith - xout - output vector
5134b9ad928SBarry Smith 
514f1580f4eSBarry Smith   Level: intermediate
5154b9ad928SBarry Smith 
516*04c3f3b8SBarry Smith   Note:
517*04c3f3b8SBarry Smith   You can get the `PCSHELL` context set with `PCShellSetContext()` using `PCShellGetContext()` if needed by `apply`.
518*04c3f3b8SBarry Smith 
519*04c3f3b8SBarry Smith .seealso: `PCSHELL`, `PCShellSetApplyRichardson()`, `PCShellSetSetUp()`, `PCShellSetApplyTranspose()`, `PCShellSetContext()`, `PCShellSetApplyBA()`, `PCShellSetApplySymmetricRight()`, `PCShellSetApplySymmetricLeft()`, `PCShellGetContext()`
5204b9ad928SBarry Smith @*/
521*04c3f3b8SBarry Smith PetscErrorCode PCShellSetApply(PC pc, PetscErrorCode (*apply)(PC pc, Vec xin, Vec xout))
522d71ae5a4SJacob Faibussowitsch {
5234b9ad928SBarry Smith   PetscFunctionBegin;
5240700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
525cac4c232SBarry Smith   PetscTryMethod(pc, "PCShellSetApply_C", (PC, PetscErrorCode(*)(PC, Vec, Vec)), (pc, apply));
5263ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
5274b9ad928SBarry Smith }
5284b9ad928SBarry Smith 
5291b581b66SBarry Smith /*@C
5306437efc7SEric Chamberland   PCShellSetMatApply - Sets routine to use as preconditioner on a block of vectors.
5317b6e2003SPierre Jolivet 
532c3339decSBarry Smith   Logically Collective
5337b6e2003SPierre Jolivet 
5347b6e2003SPierre Jolivet   Input Parameters:
5357b6e2003SPierre Jolivet + pc       - the preconditioner context
536*04c3f3b8SBarry Smith - matapply - the application-provided preconditioning routine
5377b6e2003SPierre Jolivet 
538*04c3f3b8SBarry Smith   Calling sequence of `matapply`:
539*04c3f3b8SBarry Smith + pc   - the preconditioner
540*04c3f3b8SBarry Smith . Xin  - input block of vectors represented as a dense `Mat`
541*04c3f3b8SBarry Smith - Xout - output block of vectors represented as a dense `Mat`
5427b6e2003SPierre Jolivet 
543f1580f4eSBarry Smith   Level: advanced
5447b6e2003SPierre Jolivet 
545*04c3f3b8SBarry Smith   Note:
546*04c3f3b8SBarry Smith   You can get the `PCSHELL` context set with `PCShellSetContext()` using `PCShellGetContext()` if needed by `matapply`.
547*04c3f3b8SBarry Smith 
548*04c3f3b8SBarry Smith .seealso: `PCSHELL`, `PCShellSetApply()`, `PCShellSetContext()`, `PCShellGetContext()`
5497b6e2003SPierre Jolivet @*/
550*04c3f3b8SBarry Smith PetscErrorCode PCShellSetMatApply(PC pc, PetscErrorCode (*matapply)(PC pc, Mat Xin, Mat Xout))
551d71ae5a4SJacob Faibussowitsch {
5527b6e2003SPierre Jolivet   PetscFunctionBegin;
5537b6e2003SPierre Jolivet   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
554cac4c232SBarry Smith   PetscTryMethod(pc, "PCShellSetMatApply_C", (PC, PetscErrorCode(*)(PC, Mat, Mat)), (pc, matapply));
5553ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
5567b6e2003SPierre Jolivet }
5577b6e2003SPierre Jolivet 
5587b6e2003SPierre Jolivet /*@C
559f1580f4eSBarry Smith   PCShellSetApplySymmetricLeft - Sets routine to use as left preconditioner (when the `PC_SYMMETRIC` is used).
5601b581b66SBarry Smith 
561c3339decSBarry Smith   Logically Collective
5621b581b66SBarry Smith 
5631b581b66SBarry Smith   Input Parameters:
5641b581b66SBarry Smith + pc    - the preconditioner context
5651b581b66SBarry Smith - apply - the application-provided left preconditioning routine
5661b581b66SBarry Smith 
56720f4b53cSBarry Smith   Calling sequence of `apply`:
568*04c3f3b8SBarry Smith + pc   - the preconditioner
5691b581b66SBarry Smith . xin  - input vector
5701b581b66SBarry Smith - xout - output vector
5711b581b66SBarry Smith 
572f1580f4eSBarry Smith   Level: advanced
5731b581b66SBarry Smith 
574*04c3f3b8SBarry Smith   Note:
575*04c3f3b8SBarry Smith   You can get the `PCSHELL` context set with `PCShellSetContext()` using `PCShellGetContext()` if needed by `apply`.
576*04c3f3b8SBarry Smith 
57742747ad1SJacob Faibussowitsch .seealso: `PCSHELL`, `PCShellSetApply()`, `PCShellSetSetUp()`, `PCShellSetApplyTranspose()`, `PCShellSetContext()`
5781b581b66SBarry Smith @*/
579*04c3f3b8SBarry Smith PetscErrorCode PCShellSetApplySymmetricLeft(PC pc, PetscErrorCode (*apply)(PC pc, Vec xin, Vec xout))
580d71ae5a4SJacob Faibussowitsch {
5811b581b66SBarry Smith   PetscFunctionBegin;
5821b581b66SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
583cac4c232SBarry Smith   PetscTryMethod(pc, "PCShellSetApplySymmetricLeft_C", (PC, PetscErrorCode(*)(PC, Vec, Vec)), (pc, apply));
5843ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
5851b581b66SBarry Smith }
5861b581b66SBarry Smith 
5871b581b66SBarry Smith /*@C
588f1580f4eSBarry Smith   PCShellSetApplySymmetricRight - Sets routine to use as right preconditioner (when the `PC_SYMMETRIC` is used).
5891b581b66SBarry Smith 
590c3339decSBarry Smith   Logically Collective
5911b581b66SBarry Smith 
5921b581b66SBarry Smith   Input Parameters:
5931b581b66SBarry Smith + pc    - the preconditioner context
5941b581b66SBarry Smith - apply - the application-provided right preconditioning routine
5951b581b66SBarry Smith 
59620f4b53cSBarry Smith   Calling sequence of `apply`:
597*04c3f3b8SBarry Smith + pc   - the preconditioner
5981b581b66SBarry Smith . xin  - input vector
5991b581b66SBarry Smith - xout - output vector
6001b581b66SBarry Smith 
601f1580f4eSBarry Smith   Level: advanced
6021b581b66SBarry Smith 
603*04c3f3b8SBarry Smith   Note:
604*04c3f3b8SBarry Smith   You can get the `PCSHELL` context set with `PCShellSetContext()` using `PCShellGetContext()` if needed by `apply`.
605*04c3f3b8SBarry Smith 
606*04c3f3b8SBarry Smith .seealso: `PCSHELL`, `PCShellSetApply()`, `PCShellSetApplySymmetricLeft()`, `PCShellSetSetUp()`, `PCShellSetApplyTranspose()`, `PCShellSetContext()`, `PCShellGetContext()`
6071b581b66SBarry Smith @*/
608*04c3f3b8SBarry Smith PetscErrorCode PCShellSetApplySymmetricRight(PC pc, PetscErrorCode (*apply)(PC pc, Vec xin, Vec xout))
609d71ae5a4SJacob Faibussowitsch {
6101b581b66SBarry Smith   PetscFunctionBegin;
6111b581b66SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
612cac4c232SBarry Smith   PetscTryMethod(pc, "PCShellSetApplySymmetricRight_C", (PC, PetscErrorCode(*)(PC, Vec, Vec)), (pc, apply));
6133ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
6141b581b66SBarry Smith }
6151b581b66SBarry Smith 
6162bb17772SBarry Smith /*@C
617*04c3f3b8SBarry Smith   PCShellSetApplyBA - Sets routine to use as the preconditioner times the operator.
6182bb17772SBarry Smith 
619c3339decSBarry Smith   Logically Collective
6202bb17772SBarry Smith 
6212bb17772SBarry Smith   Input Parameters:
6222bb17772SBarry Smith + pc      - the preconditioner context
6232bb17772SBarry Smith - applyBA - the application-provided BA routine
6242bb17772SBarry Smith 
62520f4b53cSBarry Smith   Calling sequence of `applyBA`:
626*04c3f3b8SBarry Smith + pc   - the preconditioner
627*04c3f3b8SBarry Smith . side - `PC_LEFT`, `PC_RIGHT`, or `PC_SYMMETRIC`
6282bb17772SBarry Smith . xin  - input vector
629*04c3f3b8SBarry Smith . xout - output vector
630*04c3f3b8SBarry Smith - w    - work vector
6312bb17772SBarry Smith 
632f1580f4eSBarry Smith   Level: intermediate
6332bb17772SBarry Smith 
634*04c3f3b8SBarry Smith   Note:
635*04c3f3b8SBarry Smith   You can get the `PCSHELL` context set with `PCShellSetContext()` using `PCShellGetContext()` if needed by `applyBA`.
636*04c3f3b8SBarry Smith 
637*04c3f3b8SBarry Smith .seealso: `PCSHELL`, `PCShellSetApplyRichardson()`, `PCShellSetSetUp()`, `PCShellSetApplyTranspose()`, `PCShellSetContext()`, `PCShellSetApply()`, `PCShellGetContext()`, `PCSide`
6382bb17772SBarry Smith @*/
639*04c3f3b8SBarry Smith PetscErrorCode PCShellSetApplyBA(PC pc, PetscErrorCode (*applyBA)(PC pc, PCSide side, Vec xin, Vec xout, Vec w))
640d71ae5a4SJacob Faibussowitsch {
6412bb17772SBarry Smith   PetscFunctionBegin;
6420700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
643cac4c232SBarry Smith   PetscTryMethod(pc, "PCShellSetApplyBA_C", (PC, PetscErrorCode(*)(PC, PCSide, Vec, Vec, Vec)), (pc, applyBA));
6443ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
6452bb17772SBarry Smith }
6462bb17772SBarry Smith 
6474b9ad928SBarry Smith /*@C
6484b9ad928SBarry Smith   PCShellSetApplyTranspose - Sets routine to use as preconditioner transpose.
6494b9ad928SBarry Smith 
650c3339decSBarry Smith   Logically Collective
6514b9ad928SBarry Smith 
6524b9ad928SBarry Smith   Input Parameters:
6534b9ad928SBarry Smith + pc             - the preconditioner context
65420f4b53cSBarry Smith - applytranspose - the application-provided preconditioning transpose routine
6554b9ad928SBarry Smith 
65620f4b53cSBarry Smith   Calling sequence of `applytranspose`:
657*04c3f3b8SBarry Smith + pc   - the preconditioner
6584b9ad928SBarry Smith . xin  - input vector
6594b9ad928SBarry Smith - xout - output vector
6604b9ad928SBarry Smith 
661f1580f4eSBarry Smith   Level: intermediate
6624b9ad928SBarry Smith 
663f1580f4eSBarry Smith   Note:
664*04c3f3b8SBarry Smith   You can get the `PCSHELL` context set with `PCShellSetContext()` using `PCShellGetContext()` if needed by `applytranspose`.
6654b9ad928SBarry Smith 
666*04c3f3b8SBarry Smith .seealso: `PCSHELL`, `PCShellSetApplyRichardson()`, `PCShellSetSetUp()`, `PCShellSetApply()`, `PCSetContext()`, `PCShellSetApplyBA()`, `PCGetContext()`
6674b9ad928SBarry Smith @*/
668*04c3f3b8SBarry Smith PetscErrorCode PCShellSetApplyTranspose(PC pc, PetscErrorCode (*applytranspose)(PC pc, Vec xin, Vec xout))
669d71ae5a4SJacob Faibussowitsch {
6704b9ad928SBarry Smith   PetscFunctionBegin;
6710700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
672cac4c232SBarry Smith   PetscTryMethod(pc, "PCShellSetApplyTranspose_C", (PC, PetscErrorCode(*)(PC, Vec, Vec)), (pc, applytranspose));
6733ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
6744b9ad928SBarry Smith }
6754b9ad928SBarry Smith 
6767cdd61b2SBarry Smith /*@C
677f1580f4eSBarry Smith   PCShellSetPreSolve - Sets routine to apply to the operators/vectors before a `KSPSolve()` is
6787cdd61b2SBarry Smith   applied. This usually does something like scale the linear system in some application
6797cdd61b2SBarry Smith   specific way.
6807cdd61b2SBarry Smith 
681c3339decSBarry Smith   Logically Collective
6827cdd61b2SBarry Smith 
6837cdd61b2SBarry Smith   Input Parameters:
6847cdd61b2SBarry Smith + pc       - the preconditioner context
6857cdd61b2SBarry Smith - presolve - the application-provided presolve routine
6867cdd61b2SBarry Smith 
68720f4b53cSBarry Smith   Calling sequence of `presolve`:
688*04c3f3b8SBarry Smith + pc   - the preconditioner
689*04c3f3b8SBarry Smith . ksp  - the `KSP` that contains `pc`
6907cdd61b2SBarry Smith . xin  - input vector
6917cdd61b2SBarry Smith - xout - output vector
6927cdd61b2SBarry Smith 
693f1580f4eSBarry Smith   Level: advanced
6947cdd61b2SBarry Smith 
695*04c3f3b8SBarry Smith   Note:
696*04c3f3b8SBarry Smith   You can get the `PCSHELL` context set with `PCShellSetContext()` using `PCShellGetContext()` if needed by `presolve`.
697*04c3f3b8SBarry Smith 
698*04c3f3b8SBarry Smith .seealso: `PCSHELL`, `PCShellSetApplyRichardson()`, `PCShellSetSetUp()`, `PCShellSetApplyTranspose()`, `PCShellSetPostSolve()`, `PCShellSetContext()`, `PCGetContext()`
6997cdd61b2SBarry Smith @*/
700*04c3f3b8SBarry Smith PetscErrorCode PCShellSetPreSolve(PC pc, PetscErrorCode (*presolve)(PC pc, KSP ksp, Vec xin, Vec xout))
701d71ae5a4SJacob Faibussowitsch {
7027cdd61b2SBarry Smith   PetscFunctionBegin;
7030700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
704cac4c232SBarry Smith   PetscTryMethod(pc, "PCShellSetPreSolve_C", (PC, PetscErrorCode(*)(PC, KSP, Vec, Vec)), (pc, presolve));
7053ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
7067cdd61b2SBarry Smith }
7077cdd61b2SBarry Smith 
7087cdd61b2SBarry Smith /*@C
709*04c3f3b8SBarry Smith   PCShellSetPostSolve - Sets routine to apply to the operators/vectors after a `KSPSolve()` is
7107cdd61b2SBarry Smith   applied. This usually does something like scale the linear system in some application
7117cdd61b2SBarry Smith   specific way.
7127cdd61b2SBarry Smith 
713c3339decSBarry Smith   Logically Collective
7147cdd61b2SBarry Smith 
7157cdd61b2SBarry Smith   Input Parameters:
7167cdd61b2SBarry Smith + pc        - the preconditioner context
7177cdd61b2SBarry Smith - postsolve - the application-provided presolve routine
7187cdd61b2SBarry Smith 
71920f4b53cSBarry Smith   Calling sequence of `postsolve`:
720*04c3f3b8SBarry Smith + pc   - the preconditioner
721*04c3f3b8SBarry Smith . ksp  - the `KSP` that contains `pc`
7227cdd61b2SBarry Smith . xin  - input vector
7237cdd61b2SBarry Smith - xout - output vector
7247cdd61b2SBarry Smith 
725f1580f4eSBarry Smith   Level: advanced
7267cdd61b2SBarry Smith 
727*04c3f3b8SBarry Smith   Note:
728*04c3f3b8SBarry Smith   You can get the `PCSHELL` context set with `PCShellSetContext()` using `PCShellGetContext()` if needed by `postsolve`.
729*04c3f3b8SBarry Smith 
730*04c3f3b8SBarry Smith .seealso: `PCSHELL`, `PCShellSetApplyRichardson()`, `PCShellSetSetUp()`, `PCShellSetApplyTranspose()`, `PCShellSetPreSolve()`, `PCShellSetContext()`, `PCGetContext()`
7317cdd61b2SBarry Smith @*/
732*04c3f3b8SBarry Smith PetscErrorCode PCShellSetPostSolve(PC pc, PetscErrorCode (*postsolve)(PC pc, KSP ksp, Vec xin, Vec xout))
733d71ae5a4SJacob Faibussowitsch {
7347cdd61b2SBarry Smith   PetscFunctionBegin;
7350700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
736cac4c232SBarry Smith   PetscTryMethod(pc, "PCShellSetPostSolve_C", (PC, PetscErrorCode(*)(PC, KSP, Vec, Vec)), (pc, postsolve));
7373ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
7387cdd61b2SBarry Smith }
7397cdd61b2SBarry Smith 
7404b9ad928SBarry Smith /*@C
741f1580f4eSBarry Smith   PCShellSetName - Sets an optional name to associate with a `PCSHELL`
7424b9ad928SBarry Smith   preconditioner.
7434b9ad928SBarry Smith 
7444b9ad928SBarry Smith   Not Collective
7454b9ad928SBarry Smith 
7464b9ad928SBarry Smith   Input Parameters:
7474b9ad928SBarry Smith + pc   - the preconditioner context
7484b9ad928SBarry Smith - name - character string describing shell preconditioner
7494b9ad928SBarry Smith 
750f1580f4eSBarry Smith   Level: intermediate
7514b9ad928SBarry Smith 
752*04c3f3b8SBarry Smith   Note:
753*04c3f3b8SBarry Smith   This is seperate from the name you can provide with `PetscObjectSetName()`
754*04c3f3b8SBarry Smith 
755*04c3f3b8SBarry Smith .seealso: `PCSHELL`, `PCShellGetName()`, `PetscObjectSetName()`, `PetscObjectGetName()`
7564b9ad928SBarry Smith @*/
757d71ae5a4SJacob Faibussowitsch PetscErrorCode PCShellSetName(PC pc, const char name[])
758d71ae5a4SJacob Faibussowitsch {
7594b9ad928SBarry Smith   PetscFunctionBegin;
7600700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
761cac4c232SBarry Smith   PetscTryMethod(pc, "PCShellSetName_C", (PC, const char[]), (pc, name));
7623ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
7634b9ad928SBarry Smith }
7644b9ad928SBarry Smith 
7654b9ad928SBarry Smith /*@C
766*04c3f3b8SBarry Smith   PCShellGetName - Gets an optional name that the user has set for a `PCSHELL` with `PCShellSetName()`
7674b9ad928SBarry Smith   preconditioner.
7684b9ad928SBarry Smith 
7694b9ad928SBarry Smith   Not Collective
7704b9ad928SBarry Smith 
7714b9ad928SBarry Smith   Input Parameter:
7724b9ad928SBarry Smith . pc - the preconditioner context
7734b9ad928SBarry Smith 
7744b9ad928SBarry Smith   Output Parameter:
7754b9ad928SBarry Smith . name - character string describing shell preconditioner (you should not free this)
7764b9ad928SBarry Smith 
777f1580f4eSBarry Smith   Level: intermediate
7784b9ad928SBarry Smith 
779*04c3f3b8SBarry Smith .seealso: `PCSHELL`, `PCShellSetName()`, `PetscObjectSetName()`, `PetscObjectGetName()`
7804b9ad928SBarry Smith @*/
781d71ae5a4SJacob Faibussowitsch PetscErrorCode PCShellGetName(PC pc, const char *name[])
782d71ae5a4SJacob Faibussowitsch {
7834b9ad928SBarry Smith   PetscFunctionBegin;
7840700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
7854f572ea9SToby Isaac   PetscAssertPointer(name, 2);
786cac4c232SBarry Smith   PetscUseMethod(pc, "PCShellGetName_C", (PC, const char *[]), (pc, name));
7873ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
7884b9ad928SBarry Smith }
7894b9ad928SBarry Smith 
7904b9ad928SBarry Smith /*@C
7914b9ad928SBarry Smith   PCShellSetApplyRichardson - Sets routine to use as preconditioner
7924b9ad928SBarry Smith   in Richardson iteration.
7934b9ad928SBarry Smith 
794c3339decSBarry Smith   Logically Collective
7954b9ad928SBarry Smith 
7964b9ad928SBarry Smith   Input Parameters:
7974b9ad928SBarry Smith + pc    - the preconditioner context
798be29d3c6SBarry Smith - apply - the application-provided preconditioning routine
7994b9ad928SBarry Smith 
80020f4b53cSBarry Smith   Calling sequence of `apply`:
801*04c3f3b8SBarry Smith + pc               - the preconditioner
8024b9ad928SBarry Smith . b                - right-hand-side
8034b9ad928SBarry Smith . x                - current iterate
8044b9ad928SBarry Smith . r                - work space
8054b9ad928SBarry Smith . rtol             - relative tolerance of residual norm to stop at
80670441072SBarry Smith . abstol           - absolute tolerance of residual norm to stop at
8074b9ad928SBarry Smith . dtol             - if residual norm increases by this factor than return
808*04c3f3b8SBarry Smith . maxits           - number of iterations to run
809*04c3f3b8SBarry Smith . zeroinitialguess - `PETSC_TRUE` if `x` is known to be initially zero
810*04c3f3b8SBarry Smith . its              - returns the number of iterations used
811*04c3f3b8SBarry Smith - reason           - returns the reason the iteration has converged
8124b9ad928SBarry Smith 
813f1580f4eSBarry Smith   Level: advanced
8144b9ad928SBarry Smith 
815*04c3f3b8SBarry Smith   Note:
816*04c3f3b8SBarry Smith   You can get the `PCSHELL` context set with `PCShellSetContext()` using `PCShellGetContext()` if needed by `apply`.
817*04c3f3b8SBarry Smith 
818*04c3f3b8SBarry Smith .seealso: `PCSHELL`, `PCShellSetApply()`, `PCShellSetContext()`, `PCRichardsonConvergedReason()`, `PCShellGetContext()`
8194b9ad928SBarry Smith @*/
820*04c3f3b8SBarry Smith PetscErrorCode PCShellSetApplyRichardson(PC pc, PetscErrorCode (*apply)(PC pc, Vec b, Vec x, Vec r, PetscReal rtol, PetscReal abstol, PetscReal dtol, PetscInt maxits, PetscBool zeroinitialguess, PetscInt *its, PCRichardsonConvergedReason *reason))
821d71ae5a4SJacob Faibussowitsch {
8224b9ad928SBarry Smith   PetscFunctionBegin;
8230700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
824cac4c232SBarry Smith   PetscTryMethod(pc, "PCShellSetApplyRichardson_C", (PC, PetscErrorCode(*)(PC, Vec, Vec, Vec, PetscReal, PetscReal, PetscReal, PetscInt, PetscBool, PetscInt *, PCRichardsonConvergedReason *)), (pc, apply));
8253ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
8264b9ad928SBarry Smith }
8274b9ad928SBarry Smith 
8284b9ad928SBarry Smith /*MC
829f1580f4eSBarry Smith    PCSHELL - Creates a new preconditioner class for use with a users
830f1580f4eSBarry Smith               own private data storage format and preconditioner application code
8314b9ad928SBarry Smith 
8324b9ad928SBarry Smith    Level: advanced
833e0bb08deSStefano Zampini 
8344b9ad928SBarry Smith   Usage:
835f1580f4eSBarry Smith .vb
836f1580f4eSBarry Smith        extern PetscErrorCode apply(PC,Vec,Vec);
837f1580f4eSBarry Smith        extern PetscErrorCode applyba(PC,PCSide,Vec,Vec,Vec);
838f1580f4eSBarry Smith        extern PetscErrorCode applytranspose(PC,Vec,Vec);
839f1580f4eSBarry Smith        extern PetscErrorCode setup(PC);
840f1580f4eSBarry Smith        extern PetscErrorCode destroy(PC);
841f1580f4eSBarry Smith 
842f1580f4eSBarry Smith        PCCreate(comm,&pc);
843f1580f4eSBarry Smith        PCSetType(pc,PCSHELL);
844f1580f4eSBarry Smith        PCShellSetContext(pc,ctx)
845f1580f4eSBarry Smith        PCShellSetApply(pc,apply);
846f1580f4eSBarry Smith        PCShellSetApplyBA(pc,applyba);               (optional)
847f1580f4eSBarry Smith        PCShellSetApplyTranspose(pc,applytranspose); (optional)
848f1580f4eSBarry Smith        PCShellSetSetUp(pc,setup);                   (optional)
849f1580f4eSBarry Smith        PCShellSetDestroy(pc,destroy);               (optional)
850f1580f4eSBarry Smith .ve
8514b9ad928SBarry Smith 
852*04c3f3b8SBarry Smith    Note:
853*04c3f3b8SBarry Smith    Information required for the preconditioner and its internal datastructures can be set with `PCShellSetContext()` and then accessed
854*04c3f3b8SBarry Smith    with `PCShellGetContext()` inside the routines provided above
855*04c3f3b8SBarry Smith 
856db781477SPatrick Sanan .seealso: `PCCreate()`, `PCSetType()`, `PCType`, `PC`,
857f1580f4eSBarry Smith           `MATSHELL`, `PCShellSetSetUp()`, `PCShellSetApply()`, `PCShellSetView()`, `PCShellSetDestroy()`, `PCShellSetPostSolve()`,
858f1580f4eSBarry Smith           `PCShellSetApplyTranspose()`, `PCShellSetName()`, `PCShellSetApplyRichardson()`, `PCShellSetPreSolve()`, `PCShellSetView()`,
859f1580f4eSBarry Smith           `PCShellGetName()`, `PCShellSetContext()`, `PCShellGetContext()`, `PCShellSetApplyBA()`, `MATSHELL`, `PCShellSetMatApply()`,
8604b9ad928SBarry Smith M*/
8614b9ad928SBarry Smith 
862d71ae5a4SJacob Faibussowitsch PETSC_EXTERN PetscErrorCode PCCreate_Shell(PC pc)
863d71ae5a4SJacob Faibussowitsch {
8644b9ad928SBarry Smith   PC_Shell *shell;
8654b9ad928SBarry Smith 
8664b9ad928SBarry Smith   PetscFunctionBegin;
8674dfa11a4SJacob Faibussowitsch   PetscCall(PetscNew(&shell));
8684b9ad928SBarry Smith   pc->data = (void *)shell;
8694b9ad928SBarry Smith 
870d01c8aa3SLisandro Dalcin   pc->ops->destroy             = PCDestroy_Shell;
8714b9ad928SBarry Smith   pc->ops->view                = PCView_Shell;
872d01c8aa3SLisandro Dalcin   pc->ops->apply               = PCApply_Shell;
8731b581b66SBarry Smith   pc->ops->applysymmetricleft  = PCApplySymmetricLeft_Shell;
8741b581b66SBarry Smith   pc->ops->applysymmetricright = PCApplySymmetricRight_Shell;
8750e0fe96bSStefano Zampini   pc->ops->matapply            = NULL;
8760a545947SLisandro Dalcin   pc->ops->applytranspose      = NULL;
8770a545947SLisandro Dalcin   pc->ops->applyrichardson     = NULL;
8780a545947SLisandro Dalcin   pc->ops->setup               = NULL;
8790a545947SLisandro Dalcin   pc->ops->presolve            = NULL;
8800a545947SLisandro Dalcin   pc->ops->postsolve           = NULL;
8814b9ad928SBarry Smith 
8820a545947SLisandro Dalcin   shell->apply               = NULL;
8830a545947SLisandro Dalcin   shell->applytranspose      = NULL;
8840a545947SLisandro Dalcin   shell->name                = NULL;
8850a545947SLisandro Dalcin   shell->applyrich           = NULL;
8860a545947SLisandro Dalcin   shell->presolve            = NULL;
8870a545947SLisandro Dalcin   shell->postsolve           = NULL;
8880a545947SLisandro Dalcin   shell->ctx                 = NULL;
8890a545947SLisandro Dalcin   shell->setup               = NULL;
8900a545947SLisandro Dalcin   shell->view                = NULL;
8910a545947SLisandro Dalcin   shell->destroy             = NULL;
8920a545947SLisandro Dalcin   shell->applysymmetricleft  = NULL;
8930a545947SLisandro Dalcin   shell->applysymmetricright = NULL;
8944b9ad928SBarry Smith 
8959566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetDestroy_C", PCShellSetDestroy_Shell));
8969566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetSetUp_C", PCShellSetSetUp_Shell));
8979566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetApply_C", PCShellSetApply_Shell));
8989566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetMatApply_C", PCShellSetMatApply_Shell));
8999566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetApplySymmetricLeft_C", PCShellSetApplySymmetricLeft_Shell));
9009566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetApplySymmetricRight_C", PCShellSetApplySymmetricRight_Shell));
9019566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetApplyBA_C", PCShellSetApplyBA_Shell));
9029566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetPreSolve_C", PCShellSetPreSolve_Shell));
9039566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetPostSolve_C", PCShellSetPostSolve_Shell));
9049566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetView_C", PCShellSetView_Shell));
9059566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetApplyTranspose_C", PCShellSetApplyTranspose_Shell));
9069566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetName_C", PCShellSetName_Shell));
9079566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellGetName_C", PCShellGetName_Shell));
9089566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCShellSetApplyRichardson_C", PCShellSetApplyRichardson_Shell));
9093ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
9104b9ad928SBarry Smith }
911