Actual source code: shellpc.c
petsc-3.3-p7 2013-05-11
2: /*
3: This provides a simple shell for Fortran (and C programmers) to
4: create their own preconditioner without writing much interface code.
5: */
7: #include <petsc-private/pcimpl.h> /*I "petscpc.h" I*/
8: #include <petsc-private/vecimpl.h>
10: EXTERN_C_BEGIN
11: typedef struct {
12: void *ctx; /* user provided contexts for preconditioner */
13: PetscErrorCode (*destroy)(PC);
14: PetscErrorCode (*setup)(PC);
15: PetscErrorCode (*apply)(PC,Vec,Vec);
16: PetscErrorCode (*applyBA)(PC,PCSide,Vec,Vec,Vec);
17: PetscErrorCode (*presolve)(PC,KSP,Vec,Vec);
18: PetscErrorCode (*postsolve)(PC,KSP,Vec,Vec);
19: PetscErrorCode (*view)(PC,PetscViewer);
20: PetscErrorCode (*applytranspose)(PC,Vec,Vec);
21: PetscErrorCode (*applyrich)(PC,Vec,Vec,Vec,PetscReal,PetscReal,PetscReal,PetscInt,PetscBool ,PetscInt*,PCRichardsonConvergedReason*);
22: char *name;
23: } PC_Shell;
24: EXTERN_C_END
28: /*@C
29: PCShellGetContext - Returns the user-provided context associated with a shell PC
31: Not Collective
33: Input Parameter:
34: . pc - should have been created with PCSetType(pc,shell)
36: Output Parameter:
37: . ctx - the user provided context
39: Level: advanced
41: Notes:
42: This routine is intended for use within various shell routines
43:
44: .keywords: PC, shell, get, context
46: .seealso: PCShellSetContext()
47: @*/
48: PetscErrorCode PCShellGetContext(PC pc,void **ctx)
49: {
51: PetscBool flg;
56: PetscObjectTypeCompare((PetscObject)pc,PCSHELL,&flg);
57: if (!flg) *ctx = 0;
58: else *ctx = ((PC_Shell*)(pc->data))->ctx;
59: return(0);
60: }
64: /*@
65: PCShellSetContext - sets the context for a shell PC
67: Logically Collective on PC
69: Input Parameters:
70: + pc - the shell PC
71: - ctx - the context
73: Level: advanced
75: Fortran Notes: The context can only be an integer or a PetscObject
76: unfortunately it cannot be a Fortran array or derived type.
79: .seealso: PCShellGetContext(), PCSHELL
80: @*/
81: PetscErrorCode PCShellSetContext(PC pc,void *ctx)
82: {
83: PC_Shell *shell = (PC_Shell*)pc->data;
85: PetscBool flg;
89: PetscObjectTypeCompare((PetscObject)pc,PCSHELL,&flg);
90: if (flg) {
91: shell->ctx = ctx;
92: }
93: return(0);
94: }
98: static PetscErrorCode PCSetUp_Shell(PC pc)
99: {
100: PC_Shell *shell = (PC_Shell*)pc->data;
104: if (!shell->setup) SETERRQ(((PetscObject)pc)->comm,PETSC_ERR_USER,"No setup() routine provided to Shell PC");
105: PetscStackCall("PCSHELL user function setup()",(*shell->setup)(pc);CHKERRQ(ierr));
106: return(0);
107: }
111: static PetscErrorCode PCApply_Shell(PC pc,Vec x,Vec y)
112: {
113: PC_Shell *shell = (PC_Shell*)pc->data;
117: if (!shell->apply) SETERRQ(((PetscObject)pc)->comm,PETSC_ERR_USER,"No apply() routine provided to Shell PC");
118: PetscStackCall("PCSHELL user function apply()",(*shell->apply)(pc,x,y);CHKERRQ(ierr));
119: return(0);
120: }
124: static PetscErrorCode PCApplyBA_Shell(PC pc,PCSide side,Vec x,Vec y,Vec w)
125: {
126: PC_Shell *shell = (PC_Shell*)pc->data;
130: if (!shell->applyBA) SETERRQ(((PetscObject)pc)->comm,PETSC_ERR_USER,"No applyBA() routine provided to Shell PC");
131: PetscStackCall("PCSHELL user function applyBA()",(*shell->applyBA)(pc,side,x,y,w);CHKERRQ(ierr));
132: return(0);
133: }
137: static PetscErrorCode PCPreSolve_Shell(PC pc,KSP ksp,Vec b,Vec x)
138: {
139: PC_Shell *shell = (PC_Shell*)pc->data;
143: if (!shell->presolve) SETERRQ(((PetscObject)pc)->comm,PETSC_ERR_USER,"No presolve() routine provided to Shell PC");
144: PetscStackCall("PCSHELL user function presolve()",(*shell->presolve)(pc,ksp,b,x);CHKERRQ(ierr));
145: return(0);
146: }
150: static PetscErrorCode PCPostSolve_Shell(PC pc,KSP ksp,Vec b,Vec x)
151: {
152: PC_Shell *shell = (PC_Shell*)pc->data;
156: if (!shell->postsolve) SETERRQ(((PetscObject)pc)->comm,PETSC_ERR_USER,"No postsolve() routine provided to Shell PC");
157: PetscStackCall("PCSHELL user function postsolve()",(*shell->postsolve)(pc,ksp,b,x);CHKERRQ(ierr));
158: return(0);
159: }
163: static PetscErrorCode PCApplyTranspose_Shell(PC pc,Vec x,Vec y)
164: {
165: PC_Shell *shell = (PC_Shell*)pc->data;
169: if (!shell->applytranspose) SETERRQ(((PetscObject)pc)->comm,PETSC_ERR_USER,"No applytranspose() routine provided to Shell PC");
170: PetscStackCall("PCSHELL user function applytranspose()",(*shell->applytranspose)(pc,x,y);CHKERRQ(ierr));
171: return(0);
172: }
176: 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)
177: {
179: PC_Shell *shell = (PC_Shell*)pc->data;
182: if (!shell->applyrich) SETERRQ(((PetscObject)pc)->comm,PETSC_ERR_USER,"No applyrichardson() routine provided to Shell PC");
183: PetscStackCall("PCSHELL user function applyrichardson()",(*shell->applyrich)(pc,x,y,w,rtol,abstol,dtol,it,guesszero,outits,reason);CHKERRQ(ierr));
184: return(0);
185: }
189: static PetscErrorCode PCDestroy_Shell(PC pc)
190: {
191: PC_Shell *shell = (PC_Shell*)pc->data;
195: PetscFree(shell->name);
196: if (shell->destroy) {
197: PetscStackCall("PCSHELL user function destroy()",(*shell->destroy)(pc);CHKERRQ(ierr));
198: }
199: PetscFree(pc->data);
200: return(0);
201: }
205: static PetscErrorCode PCView_Shell(PC pc,PetscViewer viewer)
206: {
207: PC_Shell *shell = (PC_Shell*)pc->data;
209: PetscBool iascii;
212: PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&iascii);
213: if (iascii) {
214: if (shell->name) {PetscViewerASCIIPrintf(viewer," Shell: %s\n",shell->name);}
215: else {PetscViewerASCIIPrintf(viewer," Shell: no name\n");}
216: }
217: if (shell->view) {
218: PetscViewerASCIIPushTab(viewer);
219: (*shell->view)(pc,viewer);
220: PetscViewerASCIIPopTab(viewer);
221: }
222: return(0);
223: }
225: /* ------------------------------------------------------------------------------*/
226: EXTERN_C_BEGIN
229: PetscErrorCode PCShellSetDestroy_Shell(PC pc, PetscErrorCode (*destroy)(PC))
230: {
231: PC_Shell *shell= (PC_Shell*)pc->data;
234: shell->destroy = destroy;
235: return(0);
236: }
237: EXTERN_C_END
239: EXTERN_C_BEGIN
242: PetscErrorCode PCShellSetSetUp_Shell(PC pc, PetscErrorCode (*setup)(PC))
243: {
244: PC_Shell *shell = (PC_Shell*)pc->data;;
247: shell->setup = setup;
248: if (setup) pc->ops->setup = PCSetUp_Shell;
249: else pc->ops->setup = 0;
250: return(0);
251: }
252: EXTERN_C_END
254: EXTERN_C_BEGIN
257: PetscErrorCode PCShellSetApply_Shell(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec))
258: {
259: PC_Shell *shell = (PC_Shell*)pc->data;
262: shell->apply = apply;
263: return(0);
264: }
265: EXTERN_C_END
267: EXTERN_C_BEGIN
270: PetscErrorCode PCShellSetApplyBA_Shell(PC pc,PetscErrorCode (*applyBA)(PC,PCSide,Vec,Vec,Vec))
271: {
272: PC_Shell *shell = (PC_Shell*)pc->data;
275: shell->applyBA = applyBA;
276: if (applyBA) pc->ops->applyBA = PCApplyBA_Shell;
277: else pc->ops->applyBA = 0;
278: return(0);
279: }
280: EXTERN_C_END
282: EXTERN_C_BEGIN
285: PetscErrorCode PCShellSetPreSolve_Shell(PC pc,PetscErrorCode (*presolve)(PC,KSP,Vec,Vec))
286: {
287: PC_Shell *shell = (PC_Shell*)pc->data;
290: shell->presolve = presolve;
291: if (presolve) pc->ops->presolve = PCPreSolve_Shell;
292: else pc->ops->presolve = 0;
293: return(0);
294: }
295: EXTERN_C_END
297: EXTERN_C_BEGIN
300: PetscErrorCode PCShellSetPostSolve_Shell(PC pc,PetscErrorCode (*postsolve)(PC,KSP,Vec,Vec))
301: {
302: PC_Shell *shell = (PC_Shell*)pc->data;
305: shell->postsolve = postsolve;
306: if (postsolve) pc->ops->postsolve = PCPostSolve_Shell;
307: else pc->ops->postsolve = 0;
308: return(0);
309: }
310: EXTERN_C_END
312: EXTERN_C_BEGIN
315: PetscErrorCode PCShellSetView_Shell(PC pc,PetscErrorCode (*view)(PC,PetscViewer))
316: {
317: PC_Shell *shell = (PC_Shell*)pc->data;
320: shell->view = view;
321: return(0);
322: }
323: EXTERN_C_END
325: EXTERN_C_BEGIN
328: PetscErrorCode PCShellSetApplyTranspose_Shell(PC pc,PetscErrorCode (*applytranspose)(PC,Vec,Vec))
329: {
330: PC_Shell *shell = (PC_Shell*)pc->data;
333: shell->applytranspose = applytranspose;
334: if (applytranspose) pc->ops->applytranspose = PCApplyTranspose_Shell;
335: else pc->ops->applytranspose = 0;
336: return(0);
337: }
338: EXTERN_C_END
340: EXTERN_C_BEGIN
343: PetscErrorCode PCShellSetApplyRichardson_Shell(PC pc,PetscErrorCode (*applyrich)(PC,Vec,Vec,Vec,PetscReal,PetscReal,PetscReal,PetscInt,PetscBool ,PetscInt*,PCRichardsonConvergedReason*))
344: {
345: PC_Shell *shell = (PC_Shell*)pc->data;
348: shell->applyrich = applyrich;
349: if (applyrich) pc->ops->applyrichardson = PCApplyRichardson_Shell;
350: else pc->ops->applyrichardson = 0;
351: return(0);
352: }
353: EXTERN_C_END
355: EXTERN_C_BEGIN
358: PetscErrorCode PCShellSetName_Shell(PC pc,const char name[])
359: {
360: PC_Shell *shell = (PC_Shell*)pc->data;
364: PetscFree(shell->name);
365: PetscStrallocpy(name,&shell->name);
366: return(0);
367: }
368: EXTERN_C_END
370: EXTERN_C_BEGIN
373: PetscErrorCode PCShellGetName_Shell(PC pc,const char *name[])
374: {
375: PC_Shell *shell = (PC_Shell*)pc->data;
378: *name = shell->name;
379: return(0);
380: }
381: EXTERN_C_END
383: /* -------------------------------------------------------------------------------*/
387: /*@C
388: PCShellSetDestroy - Sets routine to use to destroy the user-provided
389: application context.
391: Logically Collective on PC
393: Input Parameters:
394: + pc - the preconditioner context
395: . destroy - the application-provided destroy routine
397: Calling sequence of destroy:
398: .vb
399: PetscErrorCode destroy (PC)
400: .ve
402: . ptr - the application context
404: Notes: the function MUST return an error code of 0 on success and nonzero on failure.
406: Level: developer
408: .keywords: PC, shell, set, destroy, user-provided
410: .seealso: PCShellSetApply(), PCShellSetContext()
411: @*/
412: PetscErrorCode PCShellSetDestroy(PC pc,PetscErrorCode (*destroy)(PC))
413: {
418: PetscTryMethod(pc,"PCShellSetDestroy_C",(PC,PetscErrorCode (*)(PC)),(pc,destroy));
419: return(0);
420: }
425: /*@C
426: PCShellSetSetUp - Sets routine to use to "setup" the preconditioner whenever the
427: matrix operator is changed.
429: Logically Collective on PC
431: Input Parameters:
432: + pc - the preconditioner context
433: . setup - the application-provided setup routine
435: Calling sequence of setup:
436: .vb
437: PetscErrorCode setup (PC pc)
438: .ve
440: . pc - the preconditioner, get the application context with PCShellGetContext()
442: Notes: the function MUST return an error code of 0 on success and nonzero on failure.
444: Level: developer
446: .keywords: PC, shell, set, setup, user-provided
448: .seealso: PCShellSetApplyRichardson(), PCShellSetApply(), PCShellSetContext()
449: @*/
450: PetscErrorCode PCShellSetSetUp(PC pc,PetscErrorCode (*setup)(PC))
451: {
456: PetscTryMethod(pc,"PCShellSetSetUp_C",(PC,PetscErrorCode (*)(PC)),(pc,setup));
457: return(0);
458: }
463: /*@C
464: PCShellSetView - Sets routine to use as viewer of shell preconditioner
466: Logically Collective on PC
468: Input Parameters:
469: + pc - the preconditioner context
470: - view - the application-provided view routine
472: Calling sequence of apply:
473: .vb
474: PetscErrorCode view(PC pc,PetscViewer v)
475: .ve
477: + pc - the preconditioner, get the application context with PCShellGetContext()
478: - v - viewer
480: Notes: the function MUST return an error code of 0 on success and nonzero on failure.
482: Level: developer
484: .keywords: PC, shell, set, apply, user-provided
486: .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose()
487: @*/
488: PetscErrorCode PCShellSetView(PC pc,PetscErrorCode (*view)(PC,PetscViewer))
489: {
494: PetscTryMethod(pc,"PCShellSetView_C",(PC,PetscErrorCode (*)(PC,PetscViewer)),(pc,view));
495: return(0);
496: }
500: /*@C
501: PCShellSetApply - Sets routine to use as preconditioner.
503: Logically Collective on PC
505: Input Parameters:
506: + pc - the preconditioner context
507: - apply - the application-provided preconditioning routine
509: Calling sequence of apply:
510: .vb
511: PetscErrorCode apply (PC pc,Vec xin,Vec xout)
512: .ve
514: + pc - the preconditioner, get the application context with PCShellGetContext()
515: . xin - input vector
516: - xout - output vector
518: Notes: the function MUST return an error code of 0 on success and nonzero on failure.
520: Developer Notes: There should also be a PCShellSetApplySymmetricRight() and PCShellSetApplySymmetricLeft().
522: Level: developer
524: .keywords: PC, shell, set, apply, user-provided
526: .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetContext(), PCShellSetApplyBA()
527: @*/
528: PetscErrorCode PCShellSetApply(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec))
529: {
534: PetscTryMethod(pc,"PCShellSetApply_C",(PC,PetscErrorCode (*)(PC,Vec,Vec)),(pc,apply));
535: return(0);
536: }
540: /*@C
541: PCShellSetApplyBA - Sets routine to use as preconditioner times operator.
543: Logically Collective on PC
545: Input Parameters:
546: + pc - the preconditioner context
547: - applyBA - the application-provided BA routine
549: Calling sequence of apply:
550: .vb
551: PetscErrorCode applyBA (PC pc,Vec xin,Vec xout)
552: .ve
554: + pc - the preconditioner, get the application context with PCShellGetContext()
555: . xin - input vector
556: - xout - output vector
558: Notes: the function MUST return an error code of 0 on success and nonzero on failure.
560: Level: developer
562: .keywords: PC, shell, set, apply, user-provided
564: .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetContext(), PCShellSetApply()
565: @*/
566: PetscErrorCode PCShellSetApplyBA(PC pc,PetscErrorCode (*applyBA)(PC,PCSide,Vec,Vec,Vec))
567: {
572: PetscTryMethod(pc,"PCShellSetApplyBA_C",(PC,PetscErrorCode (*)(PC,PCSide,Vec,Vec,Vec)),(pc,applyBA));
573: return(0);
574: }
578: /*@C
579: PCShellSetApplyTranspose - Sets routine to use as preconditioner transpose.
581: Logically Collective on PC
583: Input Parameters:
584: + pc - the preconditioner context
585: - apply - the application-provided preconditioning transpose routine
587: Calling sequence of apply:
588: .vb
589: PetscErrorCode applytranspose (PC pc,Vec xin,Vec xout)
590: .ve
592: + pc - the preconditioner, get the application context with PCShellGetContext()
593: . xin - input vector
594: - xout - output vector
596: Notes: the function MUST return an error code of 0 on success and nonzero on failure.
598: Level: developer
600: Notes:
601: Uses the same context variable as PCShellSetApply().
603: .keywords: PC, shell, set, apply, user-provided
605: .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApply(), PCSetContext(), PCShellSetApplyBA()
606: @*/
607: PetscErrorCode PCShellSetApplyTranspose(PC pc,PetscErrorCode (*applytranspose)(PC,Vec,Vec))
608: {
613: PetscTryMethod(pc,"PCShellSetApplyTranspose_C",(PC,PetscErrorCode (*)(PC,Vec,Vec)),(pc,applytranspose));
614: return(0);
615: }
619: /*@C
620: PCShellSetPreSolve - Sets routine to apply to the operators/vectors before a KSPSolve() is
621: applied. This usually does something like scale the linear system in some application
622: specific way.
624: Logically Collective on PC
626: Input Parameters:
627: + pc - the preconditioner context
628: - presolve - the application-provided presolve routine
630: Calling sequence of presolve:
631: .vb
632: PetscErrorCode presolve (PC,KSP ksp,Vec b,Vec x)
633: .ve
635: + pc - the preconditioner, get the application context with PCShellGetContext()
636: . xin - input vector
637: - xout - output vector
639: Notes: the function MUST return an error code of 0 on success and nonzero on failure.
641: Level: developer
643: .keywords: PC, shell, set, apply, user-provided
645: .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetPostSolve(), PCShellSetContext()
646: @*/
647: PetscErrorCode PCShellSetPreSolve(PC pc,PetscErrorCode (*presolve)(PC,KSP,Vec,Vec))
648: {
653: PetscTryMethod(pc,"PCShellSetPreSolve_C",(PC,PetscErrorCode (*)(PC,KSP,Vec,Vec)),(pc,presolve));
654: return(0);
655: }
659: /*@C
660: PCShellSetPostSolve - Sets routine to apply to the operators/vectors before a KSPSolve() is
661: applied. This usually does something like scale the linear system in some application
662: specific way.
664: Logically Collective on PC
666: Input Parameters:
667: + pc - the preconditioner context
668: - postsolve - the application-provided presolve routine
670: Calling sequence of postsolve:
671: .vb
672: PetscErrorCode postsolve(PC,KSP ksp,Vec b,Vec x)
673: .ve
675: + pc - the preconditioner, get the application context with PCShellGetContext()
676: . xin - input vector
677: - xout - output vector
679: Notes: the function MUST return an error code of 0 on success and nonzero on failure.
681: Level: developer
683: .keywords: PC, shell, set, apply, user-provided
685: .seealso: PCShellSetApplyRichardson(), PCShellSetSetUp(), PCShellSetApplyTranspose(), PCShellSetPreSolve(), PCShellSetContext()
686: @*/
687: PetscErrorCode PCShellSetPostSolve(PC pc,PetscErrorCode (*postsolve)(PC,KSP,Vec,Vec))
688: {
693: PetscTryMethod(pc,"PCShellSetPostSolve_C",(PC,PetscErrorCode (*)(PC,KSP,Vec,Vec)),(pc,postsolve));
694: return(0);
695: }
699: /*@C
700: PCShellSetName - Sets an optional name to associate with a shell
701: preconditioner.
703: Not Collective
705: Input Parameters:
706: + pc - the preconditioner context
707: - name - character string describing shell preconditioner
709: Level: developer
711: .keywords: PC, shell, set, name, user-provided
713: .seealso: PCShellGetName()
714: @*/
715: PetscErrorCode PCShellSetName(PC pc,const char name[])
716: {
721: PetscTryMethod(pc,"PCShellSetName_C",(PC,const char []),(pc,name));
722: return(0);
723: }
727: /*@C
728: PCShellGetName - Gets an optional name that the user has set for a shell
729: preconditioner.
731: Not Collective
733: Input Parameter:
734: . pc - the preconditioner context
736: Output Parameter:
737: . name - character string describing shell preconditioner (you should not free this)
739: Level: developer
741: .keywords: PC, shell, get, name, user-provided
743: .seealso: PCShellSetName()
744: @*/
745: PetscErrorCode PCShellGetName(PC pc,const char *name[])
746: {
752: PetscUseMethod(pc,"PCShellGetName_C",(PC,const char *[]),(pc,name));
753: return(0);
754: }
758: /*@C
759: PCShellSetApplyRichardson - Sets routine to use as preconditioner
760: in Richardson iteration.
762: Logically Collective on PC
764: Input Parameters:
765: + pc - the preconditioner context
766: - apply - the application-provided preconditioning routine
768: Calling sequence of apply:
769: .vb
770: PetscErrorCode apply (PC pc,Vec b,Vec x,Vec r,PetscReal rtol,PetscReal abstol,PetscReal dtol,PetscInt maxits)
771: .ve
773: + pc - the preconditioner, get the application context with PCShellGetContext()
774: . b - right-hand-side
775: . x - current iterate
776: . r - work space
777: . rtol - relative tolerance of residual norm to stop at
778: . abstol - absolute tolerance of residual norm to stop at
779: . dtol - if residual norm increases by this factor than return
780: - maxits - number of iterations to run
782: Notes: the function MUST return an error code of 0 on success and nonzero on failure.
784: Level: developer
786: .keywords: PC, shell, set, apply, Richardson, user-provided
788: .seealso: PCShellSetApply(), PCShellSetContext()
789: @*/
790: PetscErrorCode PCShellSetApplyRichardson(PC pc,PetscErrorCode (*apply)(PC,Vec,Vec,Vec,PetscReal,PetscReal,PetscReal,PetscInt,PetscBool ,PetscInt*,PCRichardsonConvergedReason*))
791: {
796: PetscTryMethod(pc,"PCShellSetApplyRichardson_C",(PC,PetscErrorCode (*)(PC,Vec,Vec,Vec,PetscReal,PetscReal,PetscReal,PetscInt,PetscBool ,PetscInt*,PCRichardsonConvergedReason*)),(pc,apply));
797: return(0);
798: }
800: /*MC
801: PCSHELL - Creates a new preconditioner class for use with your
802: own private data storage format.
804: Level: advanced
805: >
806: Concepts: providing your own preconditioner
808: Usage:
809: $ extern PetscErrorCode apply(PC,Vec,Vec);
810: $ extern PetscErrorCode applyba(PC,PCSide,Vec,Vec,Vec);
811: $ extern PetscErrorCode applytranspose(PC,Vec,Vec);
812: $ extern PetscErrorCode setup(PC);
813: $ extern PetscErrorCode destroy(PC);
814: $
815: $ PCCreate(comm,&pc);
816: $ PCSetType(pc,PCSHELL);
817: $ PCShellSetContext(pc,ctx)
818: $ PCShellSetApply(pc,apply);
819: $ PCShellSetApplyBA(pc,applyba); (optional)
820: $ PCShellSetApplyTranspose(pc,applytranspose); (optional)
821: $ PCShellSetSetUp(pc,setup); (optional)
822: $ PCShellSetDestroy(pc,destroy); (optional)
824: .seealso: PCCreate(), PCSetType(), PCType (for list of available types), PC,
825: MATSHELL, PCShellSetSetUp(), PCShellSetApply(), PCShellSetView(),
826: PCShellSetApplyTranspose(), PCShellSetName(), PCShellSetApplyRichardson(),
827: PCShellGetName(), PCShellSetContext(), PCShellGetContext(), PCShellSetApplyBA()
828: M*/
830: EXTERN_C_BEGIN
833: PetscErrorCode PCCreate_Shell(PC pc)
834: {
836: PC_Shell *shell;
839: PetscNewLog(pc,PC_Shell,&shell);
840: pc->data = (void*)shell;
842: pc->ops->destroy = PCDestroy_Shell;
843: pc->ops->view = PCView_Shell;
844: pc->ops->apply = PCApply_Shell;
845: pc->ops->applytranspose = 0;
846: pc->ops->applyrichardson = 0;
847: pc->ops->setup = 0;
848: pc->ops->presolve = 0;
849: pc->ops->postsolve = 0;
851: shell->apply = 0;
852: shell->applytranspose = 0;
853: shell->name = 0;
854: shell->applyrich = 0;
855: shell->presolve = 0;
856: shell->postsolve = 0;
857: shell->ctx = 0;
858: shell->setup = 0;
859: shell->view = 0;
860: shell->destroy = 0;
862: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCShellSetDestroy_C","PCShellSetDestroy_Shell",
863: PCShellSetDestroy_Shell);
864: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCShellSetSetUp_C","PCShellSetSetUp_Shell",
865: PCShellSetSetUp_Shell);
866: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCShellSetApply_C","PCShellSetApply_Shell",
867: PCShellSetApply_Shell);
868: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCShellSetApplyBA_C","PCShellSetApplyBA_Shell",
869: PCShellSetApplyBA_Shell);
870: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCShellSetPreSolve_C","PCShellSetPreSolve_Shell",
871: PCShellSetPreSolve_Shell);
872: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCShellSetPostSolve_C","PCShellSetPostSolve_Shell",
873: PCShellSetPostSolve_Shell);
874: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCShellSetView_C","PCShellSetView_Shell",
875: PCShellSetView_Shell);
876: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCShellSetApplyTranspose_C","PCShellSetApplyTranspose_Shell",
877: PCShellSetApplyTranspose_Shell);
878: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCShellSetName_C","PCShellSetName_Shell",
879: PCShellSetName_Shell);
880: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCShellGetName_C","PCShellGetName_Shell",
881: PCShellGetName_Shell);
882: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCShellSetApplyRichardson_C","PCShellSetApplyRichardson_Shell",
883: PCShellSetApplyRichardson_Shell);
884: return(0);
885: }
886: EXTERN_C_END