12a6744ebSBarry Smith 22a6744ebSBarry Smith /* 32a6744ebSBarry Smith Defines a preconditioner defined by R^T S R 42a6744ebSBarry Smith */ 5af0996ceSBarry Smith #include <petsc/private/pcimpl.h> 6c6db04a5SJed Brown #include <petscksp.h> /*I "petscksp.h" I*/ 72a6744ebSBarry Smith 82a6744ebSBarry Smith typedef struct { 92a6744ebSBarry Smith KSP ksp; 102a6744ebSBarry Smith Mat R, P; 112a6744ebSBarry Smith Vec b, x; 12b3402f20SBarry Smith PetscErrorCode (*computeasub)(PC, Mat, Mat, Mat *, void *); 13b3402f20SBarry Smith void *computeasub_ctx; 142a6744ebSBarry Smith } PC_Galerkin; 152a6744ebSBarry Smith 16d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCApply_Galerkin(PC pc, Vec x, Vec y) 17d71ae5a4SJacob Faibussowitsch { 182a6744ebSBarry Smith PC_Galerkin *jac = (PC_Galerkin *)pc->data; 192a6744ebSBarry Smith 202a6744ebSBarry Smith PetscFunctionBegin; 212fa5cd67SKarl Rupp if (jac->R) { 229566063dSJacob Faibussowitsch PetscCall(MatRestrict(jac->R, x, jac->b)); 232fa5cd67SKarl Rupp } else { 249566063dSJacob Faibussowitsch PetscCall(MatRestrict(jac->P, x, jac->b)); 252fa5cd67SKarl Rupp } 269566063dSJacob Faibussowitsch PetscCall(KSPSolve(jac->ksp, jac->b, jac->x)); 279566063dSJacob Faibussowitsch PetscCall(KSPCheckSolve(jac->ksp, pc, jac->x)); 282fa5cd67SKarl Rupp if (jac->P) { 299566063dSJacob Faibussowitsch PetscCall(MatInterpolate(jac->P, jac->x, y)); 302fa5cd67SKarl Rupp } else { 319566063dSJacob Faibussowitsch PetscCall(MatInterpolate(jac->R, jac->x, y)); 322fa5cd67SKarl Rupp } 332a6744ebSBarry Smith PetscFunctionReturn(0); 342a6744ebSBarry Smith } 352a6744ebSBarry Smith 36d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCSetUp_Galerkin(PC pc) 37d71ae5a4SJacob Faibussowitsch { 382a6744ebSBarry Smith PC_Galerkin *jac = (PC_Galerkin *)pc->data; 39ace3abfcSBarry Smith PetscBool a; 40906ed7ccSBarry Smith Vec *xx, *yy; 412a6744ebSBarry Smith 422a6744ebSBarry Smith PetscFunctionBegin; 43b3402f20SBarry Smith if (jac->computeasub) { 44b3402f20SBarry Smith Mat Ap; 45b3402f20SBarry Smith if (!pc->setupcalled) { 469566063dSJacob Faibussowitsch PetscCall((*jac->computeasub)(pc, pc->pmat, NULL, &Ap, jac->computeasub_ctx)); 479566063dSJacob Faibussowitsch PetscCall(KSPSetOperators(jac->ksp, Ap, Ap)); 489566063dSJacob Faibussowitsch PetscCall(MatDestroy(&Ap)); 49b3402f20SBarry Smith } else { 509566063dSJacob Faibussowitsch PetscCall(KSPGetOperators(jac->ksp, NULL, &Ap)); 519566063dSJacob Faibussowitsch PetscCall((*jac->computeasub)(pc, pc->pmat, Ap, NULL, jac->computeasub_ctx)); 52b3402f20SBarry Smith } 53b3402f20SBarry Smith } 54b3402f20SBarry Smith 552a6744ebSBarry Smith if (!jac->x) { 569566063dSJacob Faibussowitsch PetscCall(KSPGetOperatorsSet(jac->ksp, &a, NULL)); 5728b400f6SJacob Faibussowitsch PetscCheck(a, PetscObjectComm((PetscObject)pc), PETSC_ERR_ARG_WRONGSTATE, "Must set operator of PCGALERKIN KSP with PCGalerkinGetKSP()/KSPSetOperators()"); 589566063dSJacob Faibussowitsch PetscCall(KSPCreateVecs(jac->ksp, 1, &xx, 1, &yy)); 59906ed7ccSBarry Smith jac->x = *xx; 60906ed7ccSBarry Smith jac->b = *yy; 619566063dSJacob Faibussowitsch PetscCall(PetscFree(xx)); 629566063dSJacob Faibussowitsch PetscCall(PetscFree(yy)); 632a6744ebSBarry Smith } 647827d75bSBarry Smith PetscCheck(jac->R || jac->P, PetscObjectComm((PetscObject)pc), PETSC_ERR_ARG_WRONGSTATE, "Must set restriction or interpolation of PCGALERKIN with PCGalerkinSetRestriction()/Interpolation()"); 652a6744ebSBarry Smith /* should check here that sizes of R/P match size of a */ 66b3402f20SBarry Smith 672a6744ebSBarry Smith PetscFunctionReturn(0); 682a6744ebSBarry Smith } 692a6744ebSBarry Smith 70d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCReset_Galerkin(PC pc) 71d71ae5a4SJacob Faibussowitsch { 722a6744ebSBarry Smith PC_Galerkin *jac = (PC_Galerkin *)pc->data; 732a6744ebSBarry Smith 742a6744ebSBarry Smith PetscFunctionBegin; 759566063dSJacob Faibussowitsch PetscCall(MatDestroy(&jac->R)); 769566063dSJacob Faibussowitsch PetscCall(MatDestroy(&jac->P)); 779566063dSJacob Faibussowitsch PetscCall(VecDestroy(&jac->x)); 789566063dSJacob Faibussowitsch PetscCall(VecDestroy(&jac->b)); 799566063dSJacob Faibussowitsch PetscCall(KSPReset(jac->ksp)); 80a06653b4SBarry Smith PetscFunctionReturn(0); 81a06653b4SBarry Smith } 82a06653b4SBarry Smith 83d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCDestroy_Galerkin(PC pc) 84d71ae5a4SJacob Faibussowitsch { 85a06653b4SBarry Smith PC_Galerkin *jac = (PC_Galerkin *)pc->data; 86a06653b4SBarry Smith 87a06653b4SBarry Smith PetscFunctionBegin; 889566063dSJacob Faibussowitsch PetscCall(PCReset_Galerkin(pc)); 899566063dSJacob Faibussowitsch PetscCall(KSPDestroy(&jac->ksp)); 909566063dSJacob Faibussowitsch PetscCall(PetscFree(pc->data)); 912a6744ebSBarry Smith PetscFunctionReturn(0); 922a6744ebSBarry Smith } 932a6744ebSBarry Smith 94d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCView_Galerkin(PC pc, PetscViewer viewer) 95d71ae5a4SJacob Faibussowitsch { 962a6744ebSBarry Smith PC_Galerkin *jac = (PC_Galerkin *)pc->data; 97ace3abfcSBarry Smith PetscBool iascii; 982a6744ebSBarry Smith 992a6744ebSBarry Smith PetscFunctionBegin; 1009566063dSJacob Faibussowitsch PetscCall(PetscObjectTypeCompare((PetscObject)viewer, PETSCVIEWERASCII, &iascii)); 1012a6744ebSBarry Smith if (iascii) { 1029566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, " KSP on Galerkin follow\n")); 1039566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, " ---------------------------------\n")); 1042a6744ebSBarry Smith } 1059566063dSJacob Faibussowitsch PetscCall(KSPView(jac->ksp, viewer)); 1062a6744ebSBarry Smith PetscFunctionReturn(0); 1072a6744ebSBarry Smith } 1082a6744ebSBarry Smith 109d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCGalerkinGetKSP_Galerkin(PC pc, KSP *ksp) 110d71ae5a4SJacob Faibussowitsch { 1112a6744ebSBarry Smith PC_Galerkin *jac = (PC_Galerkin *)pc->data; 1122a6744ebSBarry Smith 1132a6744ebSBarry Smith PetscFunctionBegin; 1142a6744ebSBarry Smith *ksp = jac->ksp; 1152a6744ebSBarry Smith PetscFunctionReturn(0); 1162a6744ebSBarry Smith } 1172a6744ebSBarry Smith 118d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCGalerkinSetRestriction_Galerkin(PC pc, Mat R) 119d71ae5a4SJacob Faibussowitsch { 1202a6744ebSBarry Smith PC_Galerkin *jac = (PC_Galerkin *)pc->data; 1212a6744ebSBarry Smith 1222a6744ebSBarry Smith PetscFunctionBegin; 1239566063dSJacob Faibussowitsch PetscCall(PetscObjectReference((PetscObject)R)); 1249566063dSJacob Faibussowitsch PetscCall(MatDestroy(&jac->R)); 1252a6744ebSBarry Smith jac->R = R; 1262a6744ebSBarry Smith PetscFunctionReturn(0); 1272a6744ebSBarry Smith } 1282a6744ebSBarry Smith 129d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCGalerkinSetInterpolation_Galerkin(PC pc, Mat P) 130d71ae5a4SJacob Faibussowitsch { 1312a6744ebSBarry Smith PC_Galerkin *jac = (PC_Galerkin *)pc->data; 1322a6744ebSBarry Smith 1332a6744ebSBarry Smith PetscFunctionBegin; 1349566063dSJacob Faibussowitsch PetscCall(PetscObjectReference((PetscObject)P)); 1359566063dSJacob Faibussowitsch PetscCall(MatDestroy(&jac->P)); 1362a6744ebSBarry Smith jac->P = P; 1372a6744ebSBarry Smith PetscFunctionReturn(0); 1382a6744ebSBarry Smith } 1392a6744ebSBarry Smith 140d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCGalerkinSetComputeSubmatrix_Galerkin(PC pc, PetscErrorCode (*computeAsub)(PC, Mat, Mat, Mat *, void *), void *ctx) 141d71ae5a4SJacob Faibussowitsch { 142b3402f20SBarry Smith PC_Galerkin *jac = (PC_Galerkin *)pc->data; 143b3402f20SBarry Smith 144b3402f20SBarry Smith PetscFunctionBegin; 145b3402f20SBarry Smith jac->computeasub = computeAsub; 146b3402f20SBarry Smith jac->computeasub_ctx = ctx; 147b3402f20SBarry Smith PetscFunctionReturn(0); 148b3402f20SBarry Smith } 149b3402f20SBarry Smith 1502a6744ebSBarry Smith /*@ 151f1580f4eSBarry Smith PCGalerkinSetRestriction - Sets the restriction operator for the `PCGALERKIN` preconditioner 1522a6744ebSBarry Smith 153*c3339decSBarry Smith Logically Collective 1542a6744ebSBarry Smith 155d8d19677SJose E. Roman Input Parameters: 1562a6744ebSBarry Smith + pc - the preconditioner context 1572a6744ebSBarry Smith - R - the restriction operator 1582a6744ebSBarry Smith 159f1580f4eSBarry Smith Note: 160f1580f4eSBarry Smith Either this or `PCGalerkinSetInterpolation()` or both must be called 1612a6744ebSBarry Smith 1622a6744ebSBarry Smith Level: Intermediate 1632a6744ebSBarry Smith 164db781477SPatrick Sanan .seealso: `PCCreate()`, `PCSetType()`, `PCType`, `PCGALERKIN`, 165db781477SPatrick Sanan `PCGalerkinSetInterpolation()`, `PCGalerkinGetKSP()` 1662a6744ebSBarry Smith @*/ 167d71ae5a4SJacob Faibussowitsch PetscErrorCode PCGalerkinSetRestriction(PC pc, Mat R) 168d71ae5a4SJacob Faibussowitsch { 1692a6744ebSBarry Smith PetscFunctionBegin; 1700700a824SBarry Smith PetscValidHeaderSpecific(pc, PC_CLASSID, 1); 171cac4c232SBarry Smith PetscTryMethod(pc, "PCGalerkinSetRestriction_C", (PC, Mat), (pc, R)); 1722a6744ebSBarry Smith PetscFunctionReturn(0); 1732a6744ebSBarry Smith } 1742a6744ebSBarry Smith 1752a6744ebSBarry Smith /*@ 176f1580f4eSBarry Smith PCGalerkinSetInterpolation - Sets the interpolation operator for the `PCGALERKIN` preconditioner 1772a6744ebSBarry Smith 178*c3339decSBarry Smith Logically Collective 1792a6744ebSBarry Smith 180d8d19677SJose E. Roman Input Parameters: 1812a6744ebSBarry Smith + pc - the preconditioner context 1822a6744ebSBarry Smith - R - the interpolation operator 1832a6744ebSBarry Smith 184f1580f4eSBarry Smith Note: 185f1580f4eSBarry Smith Either this or `PCGalerkinSetRestriction()` or both must be called 1862a6744ebSBarry Smith 1872a6744ebSBarry Smith Level: Intermediate 1882a6744ebSBarry Smith 189db781477SPatrick Sanan .seealso: `PCCreate()`, `PCSetType()`, `PCType`, `PCGALERKIN`, 190db781477SPatrick Sanan `PCGalerkinSetRestriction()`, `PCGalerkinGetKSP()` 1912a6744ebSBarry Smith @*/ 192d71ae5a4SJacob Faibussowitsch PetscErrorCode PCGalerkinSetInterpolation(PC pc, Mat P) 193d71ae5a4SJacob Faibussowitsch { 1942a6744ebSBarry Smith PetscFunctionBegin; 1950700a824SBarry Smith PetscValidHeaderSpecific(pc, PC_CLASSID, 1); 196cac4c232SBarry Smith PetscTryMethod(pc, "PCGalerkinSetInterpolation_C", (PC, Mat), (pc, P)); 1972a6744ebSBarry Smith PetscFunctionReturn(0); 1982a6744ebSBarry Smith } 1992a6744ebSBarry Smith 2002a6744ebSBarry Smith /*@ 201b3402f20SBarry Smith PCGalerkinSetComputeSubmatrix - Provide a routine that will be called to compute the Galerkin submatrix 202b3402f20SBarry Smith 203b3402f20SBarry Smith Logically Collective 204b3402f20SBarry Smith 205d8d19677SJose E. Roman Input Parameters: 206b3402f20SBarry Smith + pc - the preconditioner context 207b3402f20SBarry Smith . computeAsub - routine that computes the submatrix from the global matrix 208b3402f20SBarry Smith - ctx - context used by the routine, or NULL 209b3402f20SBarry Smith 210b3402f20SBarry Smith Calling sequence of computeAsub: 211b3402f20SBarry Smith $ computeAsub(PC pc,Mat A, Mat Ap, Mat *cAP,void *ctx); 212b3402f20SBarry Smith 213f1580f4eSBarry Smith + PC - the `PCGALERKIN` 214f1580f4eSBarry Smith . A - the matrix in the `PCGALERKIN` 215b3402f20SBarry Smith . Ap - the computed submatrix from any previous computation, if NULL it has not previously been computed 216b3402f20SBarry Smith . cAp - the submatrix computed by this routine 217b3402f20SBarry Smith - ctx - optional user-defined function context 218b3402f20SBarry Smith 219b3402f20SBarry Smith Level: Intermediate 220b3402f20SBarry Smith 22195452b02SPatrick Sanan Notes: 222f1580f4eSBarry Smith Instead of providing this routine you can call `PCGalerkinGetKSP()` and then `KSPSetOperators()` to provide the submatrix, 223f1580f4eSBarry Smith but that will not work for multiple `KSPSolve()`s with different matrices unless you call it for each solve. 224b3402f20SBarry Smith 225910cf402Sprj- This routine is called each time the outer matrix is changed. In the first call the Ap argument is NULL and the routine should create the 226b3402f20SBarry Smith matrix and computes its values in cAp. On each subsequent call the routine should up the Ap matrix. 227b3402f20SBarry Smith 228f1580f4eSBarry Smith Developer Note: 229f1580f4eSBarry Smith If the user does not call this routine nor call `PCGalerkinGetKSP()` and `KSPSetOperators()` then `PCGALERKIN` 230f1580f4eSBarry Smith could automatically compute the submatrix via calls to `MatGalerkin()` or `MatRARt()` 231b3402f20SBarry Smith 232db781477SPatrick Sanan .seealso: `PCCreate()`, `PCSetType()`, `PCType`, `PCGALERKIN`, 233db781477SPatrick Sanan `PCGalerkinSetRestriction()`, `PCGalerkinSetInterpolation()`, `PCGalerkinGetKSP()` 234b3402f20SBarry Smith @*/ 235d71ae5a4SJacob Faibussowitsch PetscErrorCode PCGalerkinSetComputeSubmatrix(PC pc, PetscErrorCode (*computeAsub)(PC, Mat, Mat, Mat *, void *), void *ctx) 236d71ae5a4SJacob Faibussowitsch { 237b3402f20SBarry Smith PetscFunctionBegin; 238b3402f20SBarry Smith PetscValidHeaderSpecific(pc, PC_CLASSID, 1); 239cac4c232SBarry Smith PetscTryMethod(pc, "PCGalerkinSetComputeSubmatrix_C", (PC, PetscErrorCode(*)(PC, Mat, Mat, Mat *, void *), void *), (pc, computeAsub, ctx)); 240b3402f20SBarry Smith PetscFunctionReturn(0); 241b3402f20SBarry Smith } 242b3402f20SBarry Smith 243b3402f20SBarry Smith /*@ 244f1580f4eSBarry Smith PCGalerkinGetKSP - Gets the `KSP` object in the `PCGALERKIN` 2452a6744ebSBarry Smith 2462a6744ebSBarry Smith Not Collective 2472a6744ebSBarry Smith 2482a6744ebSBarry Smith Input Parameter: 2492a6744ebSBarry Smith . pc - the preconditioner context 2502a6744ebSBarry Smith 251f1580f4eSBarry Smith Output Parameter: 252f1580f4eSBarry Smith . ksp - the `KSP` object 2532a6744ebSBarry Smith 2542a6744ebSBarry Smith Level: Intermediate 2552a6744ebSBarry Smith 256f1580f4eSBarry Smith Note: 257f1580f4eSBarry Smith Once you have called this routine you can call `KSPSetOperators()` on the resulting ksp to provide the operator for the Galerkin problem, 258f1580f4eSBarry Smith an alternative is to use `PCGalerkinSetComputeSubmatrix()` to provide a routine that computes the submatrix as needed. 259b3402f20SBarry Smith 260db781477SPatrick Sanan .seealso: `PCCreate()`, `PCSetType()`, `PCType`, `PCGALERKIN`, 261db781477SPatrick Sanan `PCGalerkinSetRestriction()`, `PCGalerkinSetInterpolation()`, `PCGalerkinSetComputeSubmatrix()` 2622a6744ebSBarry Smith @*/ 263d71ae5a4SJacob Faibussowitsch PetscErrorCode PCGalerkinGetKSP(PC pc, KSP *ksp) 264d71ae5a4SJacob Faibussowitsch { 2652a6744ebSBarry Smith PetscFunctionBegin; 2660700a824SBarry Smith PetscValidHeaderSpecific(pc, PC_CLASSID, 1); 2672a6744ebSBarry Smith PetscValidPointer(ksp, 2); 268cac4c232SBarry Smith PetscUseMethod(pc, "PCGalerkinGetKSP_C", (PC, KSP *), (pc, ksp)); 2692a6744ebSBarry Smith PetscFunctionReturn(0); 2702a6744ebSBarry Smith } 2712a6744ebSBarry Smith 272d71ae5a4SJacob Faibussowitsch static PetscErrorCode PCSetFromOptions_Galerkin(PC pc, PetscOptionItems *PetscOptionsObject) 273d71ae5a4SJacob Faibussowitsch { 2744ac220ccSBarry Smith PC_Galerkin *jac = (PC_Galerkin *)pc->data; 2754ac220ccSBarry Smith const char *prefix; 2764ac220ccSBarry Smith PetscBool flg; 2774ac220ccSBarry Smith 2784ac220ccSBarry Smith PetscFunctionBegin; 2799566063dSJacob Faibussowitsch PetscCall(KSPGetOptionsPrefix(jac->ksp, &prefix)); 2809566063dSJacob Faibussowitsch PetscCall(PetscStrendswith(prefix, "galerkin_", &flg)); 2814ac220ccSBarry Smith if (!flg) { 2829566063dSJacob Faibussowitsch PetscCall(PCGetOptionsPrefix(pc, &prefix)); 2839566063dSJacob Faibussowitsch PetscCall(KSPSetOptionsPrefix(jac->ksp, prefix)); 2849566063dSJacob Faibussowitsch PetscCall(KSPAppendOptionsPrefix(jac->ksp, "galerkin_")); 2854ac220ccSBarry Smith } 2864ac220ccSBarry Smith 287d0609cedSBarry Smith PetscOptionsHeadBegin(PetscOptionsObject, "Galerkin options"); 2881baa6e33SBarry Smith if (jac->ksp) PetscCall(KSPSetFromOptions(jac->ksp)); 289d0609cedSBarry Smith PetscOptionsHeadEnd(); 2904ac220ccSBarry Smith PetscFunctionReturn(0); 2914ac220ccSBarry Smith } 2922a6744ebSBarry Smith 2932a6744ebSBarry Smith /*MC 2942a6744ebSBarry Smith PCGALERKIN - Build (part of) a preconditioner by P S R (where P is often R^T) 2952a6744ebSBarry Smith 296f1580f4eSBarry Smith Use `PCGalerkinSetRestriction`(pc,R) and/or `PCGalerkinSetInterpolation`(pc,P) followed by `PCGalerkinGetKSP`(pc,&ksp); `KSPSetOperators`(ksp,A,....) 2972a6744ebSBarry Smith 2982a6744ebSBarry Smith Level: intermediate 2992a6744ebSBarry Smith 300f1580f4eSBarry Smith Developer Notes: 301f1580f4eSBarry Smith If `KSPSetOperators()` has not been called on the inner `KSP` then `PCGALERKIN` could use `MatRARt()` or `MatPtAP()` to compute 3027817a140SBarry Smith the operators automatically. 303f1580f4eSBarry Smith 304f1580f4eSBarry Smith Should there be a prefix for the inner `KSP`? 305f1580f4eSBarry Smith 306f1580f4eSBarry Smith There is no `KSPSetFromOptions_Galerkin()` that calls `KSPSetFromOptions()` on the inner `KSP` 3077817a140SBarry Smith 308db781477SPatrick Sanan .seealso: `PCCreate()`, `PCSetType()`, `PCType`, `PC`, 309db781477SPatrick Sanan `PCSHELL`, `PCKSP`, `PCGalerkinSetRestriction()`, `PCGalerkinSetInterpolation()`, `PCGalerkinGetKSP()` 3102a6744ebSBarry Smith M*/ 3112a6744ebSBarry Smith 312d71ae5a4SJacob Faibussowitsch PETSC_EXTERN PetscErrorCode PCCreate_Galerkin(PC pc) 313d71ae5a4SJacob Faibussowitsch { 3142a6744ebSBarry Smith PC_Galerkin *jac; 3152a6744ebSBarry Smith 3162a6744ebSBarry Smith PetscFunctionBegin; 3174dfa11a4SJacob Faibussowitsch PetscCall(PetscNew(&jac)); 3182fa5cd67SKarl Rupp 3192a6744ebSBarry Smith pc->ops->apply = PCApply_Galerkin; 3202a6744ebSBarry Smith pc->ops->setup = PCSetUp_Galerkin; 321a06653b4SBarry Smith pc->ops->reset = PCReset_Galerkin; 3222a6744ebSBarry Smith pc->ops->destroy = PCDestroy_Galerkin; 3232a6744ebSBarry Smith pc->ops->view = PCView_Galerkin; 3244ac220ccSBarry Smith pc->ops->setfromoptions = PCSetFromOptions_Galerkin; 3254ac220ccSBarry Smith pc->ops->applyrichardson = NULL; 3262a6744ebSBarry Smith 3279566063dSJacob Faibussowitsch PetscCall(KSPCreate(PetscObjectComm((PetscObject)pc), &jac->ksp)); 3289566063dSJacob Faibussowitsch PetscCall(KSPSetErrorIfNotConverged(jac->ksp, pc->erroriffailure)); 3299566063dSJacob Faibussowitsch PetscCall(PetscObjectIncrementTabLevel((PetscObject)jac->ksp, (PetscObject)pc, 1)); 3302a6744ebSBarry Smith 3312a6744ebSBarry Smith pc->data = (void *)jac; 3322a6744ebSBarry Smith 3339566063dSJacob Faibussowitsch PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCGalerkinSetRestriction_C", PCGalerkinSetRestriction_Galerkin)); 3349566063dSJacob Faibussowitsch PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCGalerkinSetInterpolation_C", PCGalerkinSetInterpolation_Galerkin)); 3359566063dSJacob Faibussowitsch PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCGalerkinGetKSP_C", PCGalerkinGetKSP_Galerkin)); 3369566063dSJacob Faibussowitsch PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCGalerkinSetComputeSubmatrix_C", PCGalerkinSetComputeSubmatrix_Galerkin)); 3372a6744ebSBarry Smith PetscFunctionReturn(0); 3382a6744ebSBarry Smith } 339