Lines Matching full:pc

9   PC                 pc;                    /* actual preconditioner used on each processor */  member
10 … /* vectors of a subcommunicator to hold parallel vectors of PetscObjectComm((PetscObject)pc) */
21 static PetscErrorCode PCFactorSetShiftType_Redundant(PC pc, MatFactorShiftType shifttype) in PCFactorSetShiftType_Redundant() argument
23 PC_Redundant *red = (PC_Redundant *)pc->data; in PCFactorSetShiftType_Redundant()
27 PC pc; in PCFactorSetShiftType_Redundant() local
28 PetscCall(KSPGetPC(red->ksp, &pc)); in PCFactorSetShiftType_Redundant()
29 PetscCall(PCFactorSetShiftType(pc, shifttype)); in PCFactorSetShiftType_Redundant()
37 static PetscErrorCode PCView_Redundant(PC pc, PetscViewer viewer) in PCView_Redundant() argument
39 PC_Redundant *red = (PC_Redundant *)pc->data; in PCView_Redundant()
51 PetscCall(PetscViewerGetSubViewer(viewer, ((PetscObject)red->pc)->comm, &subviewer)); in PCView_Redundant()
52 if (!red->psubcomm->color) { /* only view first redundant pc */ in PCView_Redundant()
57 PetscCall(PetscViewerRestoreSubViewer(viewer, ((PetscObject)red->pc)->comm, &subviewer)); in PCView_Redundant()
66 static PetscErrorCode PCSetUp_Redundant(PC pc) in PCSetUp_Redundant() argument
68 PC_Redundant *red = (PC_Redundant *)pc->data; in PCSetUp_Redundant()
75 PetscCall(PetscObjectGetComm((PetscObject)pc, &comm)); in PCSetUp_Redundant()
81 if (!pc->setupcalled) { in PCSetUp_Redundant()
83 if (!red->psubcomm) { /* create red->psubcomm, new ksp and pc over subcomm */ in PCSetUp_Redundant()
85 PetscCall(PCRedundantGetKSP(pc, &ksp)); in PCSetUp_Redundant()
91 …PetscCall(MatCreateRedundantMatrix(pc->pmat, red->psubcomm->n, subcomm, MAT_INITIAL_MATRIX, &red->… in PCSetUp_Redundant()
102 if (!foundpack) { /* reset default ksp and pc */ in PCSetUp_Redundant()
104 PetscCall(PCSetType(red->pc, PCBJACOBI)); in PCSetUp_Redundant()
106 PetscCall(PCFactorSetMatSolverType(red->pc, NULL)); in PCSetUp_Redundant()
118 Note: we use communicator dupcomm, not PetscObjectComm((PetscObject)pc)! */ in PCSetUp_Redundant()
128 PetscCall(MatCreateVecs(pc->pmat, &x, NULL)); in PCSetUp_Redundant()
156 PetscCall(KSPSetOperators(red->ksp, pc->mat, pc->pmat)); in PCSetUp_Redundant()
158 } else { /* pc->setupcalled */ in PCSetUp_Redundant()
162 if (pc->flag == DIFFERENT_NONZERO_PATTERN) { in PCSetUp_Redundant()
169 …PetscCall(MatCreateRedundantMatrix(pc->pmat, red->psubcomm->n, PetscSubcommChild(red->psubcomm), r… in PCSetUp_Redundant()
172 PetscCall(KSPSetOperators(red->ksp, pc->mat, pc->pmat)); in PCSetUp_Redundant()
176 if (pc->setfromoptionscalled) PetscCall(KSPSetFromOptions(red->ksp)); in PCSetUp_Redundant()
180 static PetscErrorCode PCApply_Redundant(PC pc, Vec x, Vec y) in PCApply_Redundant() argument
182 PC_Redundant *red = (PC_Redundant *)pc->data; in PCApply_Redundant()
188 PetscCall(KSPCheckSolve(red->ksp, pc, y)); in PCApply_Redundant()
202 PetscCall(KSPCheckSolve(red->ksp, pc, red->ysub)); in PCApply_Redundant()
218 static PetscErrorCode PCApplyTranspose_Redundant(PC pc, Vec x, Vec y) in PCApplyTranspose_Redundant() argument
220 PC_Redundant *red = (PC_Redundant *)pc->data; in PCApplyTranspose_Redundant()
226 PetscCall(KSPCheckSolve(red->ksp, pc, y)); in PCApplyTranspose_Redundant()
240 PetscCall(KSPCheckSolve(red->ksp, pc, red->ysub)); in PCApplyTranspose_Redundant()
256 static PetscErrorCode PCReset_Redundant(PC pc) in PCReset_Redundant() argument
258 PC_Redundant *red = (PC_Redundant *)pc->data; in PCReset_Redundant()
274 static PetscErrorCode PCDestroy_Redundant(PC pc) in PCDestroy_Redundant() argument
276 PC_Redundant *red = (PC_Redundant *)pc->data; in PCDestroy_Redundant()
279 PetscCall(PCReset_Redundant(pc)); in PCDestroy_Redundant()
282 PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCRedundantSetScatter_C", NULL)); in PCDestroy_Redundant()
283 PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCRedundantSetNumber_C", NULL)); in PCDestroy_Redundant()
284 PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCRedundantGetKSP_C", NULL)); in PCDestroy_Redundant()
285 PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCRedundantGetOperators_C", NULL)); in PCDestroy_Redundant()
286 PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetShiftType_C", NULL)); in PCDestroy_Redundant()
287 PetscCall(PetscFree(pc->data)); in PCDestroy_Redundant()
291 static PetscErrorCode PCSetFromOptions_Redundant(PC pc, PetscOptionItems PetscOptionsObject) in PCSetFromOptions_Redundant() argument
293 PC_Redundant *red = (PC_Redundant *)pc->data; in PCSetFromOptions_Redundant()
297 …PetscCall(PetscOptionsInt("-pc_redundant_number", "Number of redundant pc", "PCRedundantSetNumber"… in PCSetFromOptions_Redundant()
302 static PetscErrorCode PCRedundantSetNumber_Redundant(PC pc, PetscInt nreds) in PCRedundantSetNumber_Redundant() argument
304 PC_Redundant *red = (PC_Redundant *)pc->data; in PCRedundantSetNumber_Redundant()
317 + pc - the preconditioner context
325 PetscErrorCode PCRedundantSetNumber(PC pc, PetscInt nredundant) in PCRedundantSetNumber() argument
328 PetscValidHeaderSpecific(pc, PC_CLASSID, 1); in PCRedundantSetNumber()
329 …scCheck(nredundant > 0, PetscObjectComm((PetscObject)pc), PETSC_ERR_ARG_WRONG, "num of redundant p… in PCRedundantSetNumber()
330 PetscTryMethod(pc, "PCRedundantSetNumber_C", (PC, PetscInt), (pc, nredundant)); in PCRedundantSetNumber()
334 static PetscErrorCode PCRedundantSetScatter_Redundant(PC pc, VecScatter in, VecScatter out) in PCRedundantSetScatter_Redundant() argument
336 PC_Redundant *red = (PC_Redundant *)pc->data; in PCRedundantSetScatter_Redundant()
358 + pc - the preconditioner context
366 PetscErrorCode PCRedundantSetScatter(PC pc, VecScatter in, VecScatter out) in PCRedundantSetScatter() argument
369 PetscValidHeaderSpecific(pc, PC_CLASSID, 1); in PCRedundantSetScatter()
372 PetscTryMethod(pc, "PCRedundantSetScatter_C", (PC, VecScatter, VecScatter), (pc, in, out)); in PCRedundantSetScatter()
376 static PetscErrorCode PCRedundantGetKSP_Redundant(PC pc, KSP *innerksp) in PCRedundantGetKSP_Redundant() argument
378 PC_Redundant *red = (PC_Redundant *)pc->data; in PCRedundantGetKSP_Redundant()
385 PetscCall(PCGetOptionsPrefix(pc, &prefix)); in PCRedundantGetKSP_Redundant()
387 PetscCall(PetscObjectGetComm((PetscObject)pc, &comm)); in PCRedundantGetKSP_Redundant()
395 /* create a new PC that processors in each subcomm have copy of */ in PCRedundantGetKSP_Redundant()
399 PetscCall(KSPSetNestLevel(red->ksp, pc->kspnestlevel)); in PCRedundantGetKSP_Redundant()
400 PetscCall(KSPSetErrorIfNotConverged(red->ksp, pc->erroriffailure)); in PCRedundantGetKSP_Redundant()
401 PetscCall(PetscObjectIncrementTabLevel((PetscObject)red->ksp, (PetscObject)pc, 1)); in PCRedundantGetKSP_Redundant()
403 PetscCall(KSPGetPC(red->ksp, &red->pc)); in PCRedundantGetKSP_Redundant()
404 PetscCall(PetscObjectTypeCompare((PetscObject)pc->pmat, MATSEQSBAIJ, &issbaij)); in PCRedundantGetKSP_Redundant()
405 if (!issbaij) PetscCall(PetscObjectTypeCompare((PetscObject)pc->pmat, MATMPISBAIJ, &issbaij)); in PCRedundantGetKSP_Redundant()
407 PetscCall(PCSetType(red->pc, PCLU)); in PCRedundantGetKSP_Redundant()
409 PetscCall(PCSetType(red->pc, PCCHOLESKY)); in PCRedundantGetKSP_Redundant()
412 PetscCall(PCFactorSetShiftType(red->pc, red->shifttype)); in PCRedundantGetKSP_Redundant()
423 PCRedundantGetKSP - Gets the less parallel `KSP` created by the redundant `PC`.
428 . pc - the preconditioner context
437 PetscErrorCode PCRedundantGetKSP(PC pc, KSP *innerksp) in PCRedundantGetKSP() argument
440 PetscValidHeaderSpecific(pc, PC_CLASSID, 1); in PCRedundantGetKSP()
442 PetscUseMethod(pc, "PCRedundantGetKSP_C", (PC, KSP *), (pc, innerksp)); in PCRedundantGetKSP()
446 static PetscErrorCode PCRedundantGetOperators_Redundant(PC pc, Mat *mat, Mat *pmat) in PCRedundantGetOperators_Redundant() argument
448 PC_Redundant *red = (PC_Redundant *)pc->data; in PCRedundantGetOperators_Redundant()
462 . pc - the preconditioner context
472 PetscErrorCode PCRedundantGetOperators(PC pc, Mat *mat, Mat *pmat) in PCRedundantGetOperators() argument
475 PetscValidHeaderSpecific(pc, PC_CLASSID, 1); in PCRedundantGetOperators()
478 PetscUseMethod(pc, "PCRedundantGetOperators_C", (PC, Mat *, Mat *), (pc, mat, pmat)); in PCRedundantGetOperators()
494 …The default `KSP` is preonly and the default `PC` is `PCLU` or `PCCHOLESKY` if Pmat is of type `MA…
496 …`PCFactorSetShiftType()` applied to this `PC` will convey they shift type into the inner `PC` if i…
505 PETSC_EXTERN PetscErrorCode PCCreate_Redundant(PC pc) in PCCreate_Redundant() argument
512 PetscCallMPI(MPI_Comm_size(PetscObjectComm((PetscObject)pc), &size)); in PCCreate_Redundant()
516 pc->data = (void *)red; in PCCreate_Redundant()
518 pc->ops->apply = PCApply_Redundant; in PCCreate_Redundant()
519 pc->ops->applytranspose = PCApplyTranspose_Redundant; in PCCreate_Redundant()
520 pc->ops->setup = PCSetUp_Redundant; in PCCreate_Redundant()
521 pc->ops->destroy = PCDestroy_Redundant; in PCCreate_Redundant()
522 pc->ops->reset = PCReset_Redundant; in PCCreate_Redundant()
523 pc->ops->setfromoptions = PCSetFromOptions_Redundant; in PCCreate_Redundant()
524 pc->ops->view = PCView_Redundant; in PCCreate_Redundant()
526 …PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCRedundantSetScatter_C", PCRedundantSetSca… in PCCreate_Redundant()
527 …PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCRedundantSetNumber_C", PCRedundantSetNumb… in PCCreate_Redundant()
528 …PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCRedundantGetKSP_C", PCRedundantGetKSP_Red… in PCCreate_Redundant()
529 …PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCRedundantGetOperators_C", PCRedundantGetO… in PCCreate_Redundant()
530 …PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetShiftType_C", PCFactorSetShiftTy… in PCCreate_Redundant()