Lines Matching full:pc

9   PC               pc;  member
23 static PetscErrorCode PCApply_Composite_Multiplicative(PC pc, Vec x, Vec y) in PCApply_Composite_Multiplicative() argument
25 PC_Composite *jac = (PC_Composite *)pc->data; in PCApply_Composite_Multiplicative()
27 Mat mat = pc->pmat; in PCApply_Composite_Multiplicative()
30 …PetscCheck(next, PetscObjectComm((PetscObject)pc), PETSC_ERR_ARG_WRONGSTATE, "No composite precond… in PCApply_Composite_Multiplicative()
34 PetscCall(PCSetReusePreconditioner(next->pc, pc->reusepreconditioner)); in PCApply_Composite_Multiplicative()
42 if (pc->useAmat) mat = pc->mat; in PCApply_Composite_Multiplicative()
43 PetscCall(PCApply(next->pc, x, y)); /* y <- B x */ in PCApply_Composite_Multiplicative()
48 PetscCall(PCApply(next->pc, jac->work2, jac->work1)); /* work1 <- C work2 */ in PCApply_Composite_Multiplicative()
56 PetscCall(PCApply(next->pc, jac->work2, jac->work1)); in PCApply_Composite_Multiplicative()
63 static PetscErrorCode PCApplyTranspose_Composite_Multiplicative(PC pc, Vec x, Vec y) in PCApplyTranspose_Composite_Multiplicative() argument
65 PC_Composite *jac = (PC_Composite *)pc->data; in PCApplyTranspose_Composite_Multiplicative()
67 Mat mat = pc->pmat; in PCApplyTranspose_Composite_Multiplicative()
70 …PetscCheck(next, PetscObjectComm((PetscObject)pc), PETSC_ERR_ARG_WRONGSTATE, "No composite precond… in PCApplyTranspose_Composite_Multiplicative()
74 if (pc->useAmat) mat = pc->mat; in PCApplyTranspose_Composite_Multiplicative()
75 /* locate last PC */ in PCApplyTranspose_Composite_Multiplicative()
77 PetscCall(PCApplyTranspose(next->pc, x, y)); in PCApplyTranspose_Composite_Multiplicative()
82 PetscCall(PCApplyTranspose(next->pc, jac->work2, jac->work1)); in PCApplyTranspose_Composite_Multiplicative()
91 PetscCall(PCApplyTranspose(next->pc, jac->work2, jac->work1)); in PCApplyTranspose_Composite_Multiplicative()
103 static PetscErrorCode PCApply_Composite_Special(PC pc, Vec x, Vec y) in PCApply_Composite_Special() argument
105 PC_Composite *jac = (PC_Composite *)pc->data; in PCApply_Composite_Special()
109 …PetscCheck(next, PetscObjectComm((PetscObject)pc), PETSC_ERR_ARG_WRONGSTATE, "No composite precond… in PCApply_Composite_Special()
110 …PetscCheck(next->next && !next->next->next, PetscObjectComm((PetscObject)pc), PETSC_ERR_ARG_WRONGS… in PCApply_Composite_Special()
113 PetscCall(PCSetReusePreconditioner(next->pc, pc->reusepreconditioner)); in PCApply_Composite_Special()
114 PetscCall(PCSetReusePreconditioner(next->next->pc, pc->reusepreconditioner)); in PCApply_Composite_Special()
116 PetscCall(PCApply(next->pc, x, jac->work1)); in PCApply_Composite_Special()
120 PetscCall(PCApply(next->next->pc, jac->work2, y)); in PCApply_Composite_Special()
121 } else PetscCall(PCApply(next->next->pc, jac->work1, y)); in PCApply_Composite_Special()
125 static PetscErrorCode PCApply_Composite_Additive(PC pc, Vec x, Vec y) in PCApply_Composite_Additive() argument
127 PC_Composite *jac = (PC_Composite *)pc->data; in PCApply_Composite_Additive()
131 …PetscCheck(next, PetscObjectComm((PetscObject)pc), PETSC_ERR_ARG_WRONGSTATE, "No composite precond… in PCApply_Composite_Additive()
135 PetscCall(PCSetReusePreconditioner(next->pc, pc->reusepreconditioner)); in PCApply_Composite_Additive()
140 PetscCall(PCApply(next->pc, x, y)); in PCApply_Composite_Additive()
143 PetscCall(PCApply(next->pc, x, jac->work1)); in PCApply_Composite_Additive()
149 static PetscErrorCode PCApplyTranspose_Composite_Additive(PC pc, Vec x, Vec y) in PCApplyTranspose_Composite_Additive() argument
151 PC_Composite *jac = (PC_Composite *)pc->data; in PCApplyTranspose_Composite_Additive()
155 …PetscCheck(next, PetscObjectComm((PetscObject)pc), PETSC_ERR_ARG_WRONGSTATE, "No composite precond… in PCApplyTranspose_Composite_Additive()
156 PetscCall(PCApplyTranspose(next->pc, x, y)); in PCApplyTranspose_Composite_Additive()
159 PetscCall(PCApplyTranspose(next->pc, x, jac->work1)); in PCApplyTranspose_Composite_Additive()
165 static PetscErrorCode PCSetUp_Composite(PC pc) in PCSetUp_Composite() argument
167 PC_Composite *jac = (PC_Composite *)pc->data; in PCSetUp_Composite()
172 if (!jac->work1) PetscCall(MatCreateVecs(pc->pmat, &jac->work1, NULL)); in PCSetUp_Composite()
173 PetscCall(PCGetDM(pc, &dm)); in PCSetUp_Composite()
175 if (!next->pc->dm) PetscCall(PCSetDM(next->pc, dm)); in PCSetUp_Composite()
176 if (!next->pc->mat) PetscCall(PCSetOperators(next->pc, pc->mat, pc->pmat)); in PCSetUp_Composite()
182 static PetscErrorCode PCSetUpOnBlocks_Composite(PC pc) in PCSetUpOnBlocks_Composite() argument
184 PC_Composite *jac = (PC_Composite *)pc->data; in PCSetUpOnBlocks_Composite()
190 PetscCall(PCSetUp(next->pc)); in PCSetUpOnBlocks_Composite()
191 PetscCall(PCGetFailedReason(next->pc, &reason)); in PCSetUpOnBlocks_Composite()
192 if (reason) pc->failedreason = reason; in PCSetUpOnBlocks_Composite()
198 static PetscErrorCode PCReset_Composite(PC pc) in PCReset_Composite() argument
200 PC_Composite *jac = (PC_Composite *)pc->data; in PCReset_Composite()
205 PetscCall(PCReset(next->pc)); in PCReset_Composite()
214 static PetscErrorCode PCDestroy_Composite(PC pc) in PCDestroy_Composite() argument
216 PC_Composite *jac = (PC_Composite *)pc->data; in PCDestroy_Composite()
220 PetscCall(PCReset_Composite(pc)); in PCDestroy_Composite()
222 PetscCall(PCDestroy(&next->pc)); in PCDestroy_Composite()
227 PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCCompositeSetType_C", NULL)); in PCDestroy_Composite()
228 PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCCompositeGetType_C", NULL)); in PCDestroy_Composite()
229 PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCCompositeAddPCType_C", NULL)); in PCDestroy_Composite()
230 PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCCompositeAddPC_C", NULL)); in PCDestroy_Composite()
231 PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCCompositeGetNumberPC_C", NULL)); in PCDestroy_Composite()
232 PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCCompositeGetPC_C", NULL)); in PCDestroy_Composite()
233 PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCCompositeSpecialSetAlpha_C", NULL)); in PCDestroy_Composite()
234 PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCCompositeSpecialSetAlphaMat_C", NULL)); in PCDestroy_Composite()
235 PetscCall(PetscFree(pc->data)); in PCDestroy_Composite()
239 static PetscErrorCode PCSetFromOptions_Composite(PC pc, PetscOptionItems PetscOptionsObject) in PCSetFromOptions_Composite() argument
241 PC_Composite *jac = (PC_Composite *)pc->data; in PCSetFromOptions_Composite()
250 if (flg) PetscCall(PCCompositeSetType(pc, jac->type)); in PCSetFromOptions_Composite()
255 PetscCall(PCCompositeAddPCType(pc, pcs[i])); in PCSetFromOptions_Composite()
263 PetscCall(PCSetFromOptions(next->pc)); in PCSetFromOptions_Composite()
269 static PetscErrorCode PCView_Composite(PC pc, PetscViewer viewer) in PCView_Composite() argument
271 PC_Composite *jac = (PC_Composite *)pc->data; in PCView_Composite()
278 …PetscCall(PetscViewerASCIIPrintf(viewer, "Composite PC type - %s\n", PCCompositeTypes[jac->type])); in PCView_Composite()
284 PetscCall(PCView(next->pc, viewer)); in PCView_Composite()
294 static PetscErrorCode PCCompositeSpecialSetAlpha_Composite(PC pc, PetscScalar alpha) in PCCompositeSpecialSetAlpha_Composite() argument
296 PC_Composite *jac = (PC_Composite *)pc->data; in PCCompositeSpecialSetAlpha_Composite()
303 static PetscErrorCode PCCompositeSpecialSetAlphaMat_Composite(PC pc, Mat alpha_mat) in PCCompositeSpecialSetAlphaMat_Composite() argument
305 PC_Composite *jac = (PC_Composite *)pc->data; in PCCompositeSpecialSetAlphaMat_Composite()
317 static PetscErrorCode PCCompositeSetType_Composite(PC pc, PCCompositeType type) in PCCompositeSetType_Composite() argument
319 PC_Composite *jac = (PC_Composite *)pc->data; in PCCompositeSetType_Composite()
323 pc->ops->apply = PCApply_Composite_Additive; in PCCompositeSetType_Composite()
324 pc->ops->applytranspose = PCApplyTranspose_Composite_Additive; in PCCompositeSetType_Composite()
326 pc->ops->apply = PCApply_Composite_Multiplicative; in PCCompositeSetType_Composite()
327 pc->ops->applytranspose = PCApplyTranspose_Composite_Multiplicative; in PCCompositeSetType_Composite()
329 pc->ops->apply = PCApply_Composite_Special; in PCCompositeSetType_Composite()
330 pc->ops->applytranspose = NULL; in PCCompositeSetType_Composite()
331 …} else SETERRQ(PetscObjectComm((PetscObject)pc), PETSC_ERR_ARG_WRONG, "Unknown composite precondit… in PCCompositeSetType_Composite()
336 static PetscErrorCode PCCompositeGetType_Composite(PC pc, PCCompositeType *type) in PCCompositeGetType_Composite() argument
338 PC_Composite *jac = (PC_Composite *)pc->data; in PCCompositeGetType_Composite()
345 static PetscErrorCode PCCompositeAddPC_Composite(PC pc, PC subpc) in PCCompositeAddPC_Composite() argument
356 ilink->pc = subpc; in PCCompositeAddPC_Composite()
358 jac = (PC_Composite *)pc->data; in PCCompositeAddPC_Composite()
372 PetscCall(PCGetOptionsPrefix(pc, &prefix)); in PCCompositeAddPC_Composite()
380 static PetscErrorCode PCCompositeAddPCType_Composite(PC pc, PCType type) in PCCompositeAddPCType_Composite() argument
382 PC subpc; in PCCompositeAddPCType_Composite()
385 PetscCall(PCCreate(PetscObjectComm((PetscObject)pc), &subpc)); in PCCompositeAddPCType_Composite()
386 PetscCall(PetscObjectIncrementTabLevel((PetscObject)subpc, (PetscObject)pc, 1)); in PCCompositeAddPCType_Composite()
387 PetscCall(PCCompositeAddPC_Composite(pc, subpc)); in PCCompositeAddPCType_Composite()
394 static PetscErrorCode PCCompositeGetNumberPC_Composite(PC pc, PetscInt *n) in PCCompositeGetNumberPC_Composite() argument
400 jac = (PC_Composite *)pc->data; in PCCompositeGetNumberPC_Composite()
410 static PetscErrorCode PCCompositeGetPC_Composite(PC pc, PetscInt n, PC *subpc) in PCCompositeGetPC_Composite() argument
417 jac = (PC_Composite *)pc->data; in PCCompositeGetPC_Composite()
420 …PetscCheck(next->next, PetscObjectComm((PetscObject)pc), PETSC_ERR_ARG_INCOMP, "Not enough PCs in … in PCCompositeGetPC_Composite()
423 *subpc = next->pc; in PCCompositeGetPC_Composite()
433 + pc - the preconditioner context
444 PetscErrorCode PCCompositeSetType(PC pc, PCCompositeType type) in PCCompositeSetType() argument
447 PetscValidHeaderSpecific(pc, PC_CLASSID, 1); in PCCompositeSetType()
448 PetscValidLogicalCollectiveEnum(pc, type, 2); in PCCompositeSetType()
449 PetscTryMethod(pc, "PCCompositeSetType_C", (PC, PCCompositeType), (pc, type)); in PCCompositeSetType()
459 . pc - the preconditioner context
469 PetscErrorCode PCCompositeGetType(PC pc, PCCompositeType *type) in PCCompositeGetType() argument
472 PetscValidHeaderSpecific(pc, PC_CLASSID, 1); in PCCompositeGetType()
473 PetscUseMethod(pc, "PCCompositeGetType_C", (PC, PCCompositeType *), (pc, type)); in PCCompositeGetType()
484 + pc - the preconditioner context
492 PetscErrorCode PCCompositeSpecialSetAlpha(PC pc, PetscScalar alpha) in PCCompositeSpecialSetAlpha() argument
495 PetscValidHeaderSpecific(pc, PC_CLASSID, 1); in PCCompositeSpecialSetAlpha()
496 PetscValidLogicalCollectiveScalar(pc, alpha, 2); in PCCompositeSpecialSetAlpha()
497 PetscTryMethod(pc, "PCCompositeSpecialSetAlpha_C", (PC, PetscScalar), (pc, alpha)); in PCCompositeSpecialSetAlpha()
501 PetscErrorCode PCCompositeSpecialSetAlphaMat(PC pc, Mat alpha_mat) in PCCompositeSpecialSetAlphaMat() argument
504 PetscValidHeaderSpecific(pc, PC_CLASSID, 1); in PCCompositeSpecialSetAlphaMat()
505 PetscTryMethod(pc, "PCCompositeSpecialSetAlphaMat_C", (PC, Mat), (pc, alpha_mat)); in PCCompositeSpecialSetAlphaMat()
510 PCCompositeAddPCType - Adds another `PC` of the given type to the composite `PC`.
515 + pc - the preconditioner context
522 PetscErrorCode PCCompositeAddPCType(PC pc, PCType type) in PCCompositeAddPCType() argument
525 PetscValidHeaderSpecific(pc, PC_CLASSID, 1); in PCCompositeAddPCType()
526 PetscTryMethod(pc, "PCCompositeAddPCType_C", (PC, PCType), (pc, type)); in PCCompositeAddPCType()
531 PCCompositeAddPC - Adds another `PC` to the composite `PC`.
536 + pc - the preconditioner context
543 PetscErrorCode PCCompositeAddPC(PC pc, PC subpc) in PCCompositeAddPC() argument
546 PetscValidHeaderSpecific(pc, PC_CLASSID, 1); in PCCompositeAddPC()
548 PetscTryMethod(pc, "PCCompositeAddPC_C", (PC, PC), (pc, subpc)); in PCCompositeAddPC()
553 PCCompositeGetNumberPC - Gets the number of `PC` objects in the composite `PC`.
558 . pc - the preconditioner context
567 PetscErrorCode PCCompositeGetNumberPC(PC pc, PetscInt *num) in PCCompositeGetNumberPC() argument
570 PetscValidHeaderSpecific(pc, PC_CLASSID, 1); in PCCompositeGetNumberPC()
572 PetscUseMethod(pc, "PCCompositeGetNumberPC_C", (PC, PetscInt *), (pc, num)); in PCCompositeGetNumberPC()
577 PCCompositeGetPC - Gets one of the `PC` objects in the composite `PC`.
582 + pc - the preconditioner context
583 - n - the number of the pc requested
586 . subpc - the PC requested
592 call `PCSetOperators()` on that `PC`.
596 PetscErrorCode PCCompositeGetPC(PC pc, PetscInt n, PC *subpc) in PCCompositeGetPC() argument
599 PetscValidHeaderSpecific(pc, PC_CLASSID, 1); in PCCompositeGetPC()
601 PetscUseMethod(pc, "PCCompositeGetPC_C", (PC, PetscInt, PC *), (pc, n, subpc)); in PCCompositeGetPC()
617 …inner `PC`s to be `PCKSP`. Using a Krylov method inside another Krylov method can be dangerous (yo…
621 call `PCSetOperators()` on that `PC`.
623 .seealso: [](ch_ksp), `PCCreate()`, `PCSetType()`, `PCType`, `PC`,
628 PETSC_EXTERN PetscErrorCode PCCreate_Composite(PC pc) in PCCreate_Composite() argument
635 pc->ops->apply = PCApply_Composite_Additive; in PCCreate_Composite()
636 pc->ops->applytranspose = PCApplyTranspose_Composite_Additive; in PCCreate_Composite()
637 pc->ops->setup = PCSetUp_Composite; in PCCreate_Composite()
638 pc->ops->setuponblocks = PCSetUpOnBlocks_Composite; in PCCreate_Composite()
639 pc->ops->reset = PCReset_Composite; in PCCreate_Composite()
640 pc->ops->destroy = PCDestroy_Composite; in PCCreate_Composite()
641 pc->ops->setfromoptions = PCSetFromOptions_Composite; in PCCreate_Composite()
642 pc->ops->view = PCView_Composite; in PCCreate_Composite()
643 pc->ops->applyrichardson = NULL; in PCCreate_Composite()
645 pc->data = (void *)jac; in PCCreate_Composite()
652 …PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCCompositeSetType_C", PCCompositeSetType_C… in PCCreate_Composite()
653 …PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCCompositeGetType_C", PCCompositeGetType_C… in PCCreate_Composite()
654 …PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCCompositeAddPCType_C", PCCompositeAddPCTy… in PCCreate_Composite()
655 …PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCCompositeAddPC_C", PCCompositeAddPC_Compo… in PCCreate_Composite()
656 …PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCCompositeGetNumberPC_C", PCCompositeGetNu… in PCCreate_Composite()
657 …PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCCompositeGetPC_C", PCCompositeGetPC_Compo… in PCCreate_Composite()
658 …PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCCompositeSpecialSetAlpha_C", PCCompositeS… in PCCreate_Composite()
659 …PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCCompositeSpecialSetAlphaMat_C", PCComposi… in PCCreate_Composite()