Lines Matching full:pc

2      This file implements a Jacobi preconditioner in PETSc as part of PC.
66 static PetscErrorCode PCReset_Jacobi(PC);
68 static PetscErrorCode PCJacobiSetType_Jacobi(PC pc, PCJacobiType type) in PCJacobiSetType_Jacobi() argument
70 PC_Jacobi *j = (PC_Jacobi *)pc->data; in PCJacobiSetType_Jacobi()
74 PetscCall(PCJacobiGetType(pc, &old_type)); in PCJacobiSetType_Jacobi()
76 PetscCall(PCReset_Jacobi(pc)); in PCJacobiSetType_Jacobi()
81 static PetscErrorCode PCJacobiGetUseAbs_Jacobi(PC pc, PetscBool *flg) in PCJacobiGetUseAbs_Jacobi() argument
83 PC_Jacobi *j = (PC_Jacobi *)pc->data; in PCJacobiGetUseAbs_Jacobi()
90 static PetscErrorCode PCJacobiSetUseAbs_Jacobi(PC pc, PetscBool flg) in PCJacobiSetUseAbs_Jacobi() argument
92 PC_Jacobi *j = (PC_Jacobi *)pc->data; in PCJacobiSetUseAbs_Jacobi()
99 static PetscErrorCode PCJacobiGetType_Jacobi(PC pc, PCJacobiType *type) in PCJacobiGetType_Jacobi() argument
101 PC_Jacobi *j = (PC_Jacobi *)pc->data; in PCJacobiGetType_Jacobi()
108 static PetscErrorCode PCJacobiSetRowl1Scale_Jacobi(PC pc, PetscReal flg) in PCJacobiSetRowl1Scale_Jacobi() argument
110 PC_Jacobi *j = (PC_Jacobi *)pc->data; in PCJacobiSetRowl1Scale_Jacobi()
117 static PetscErrorCode PCJacobiGetRowl1Scale_Jacobi(PC pc, PetscReal *flg) in PCJacobiGetRowl1Scale_Jacobi() argument
119 PC_Jacobi *j = (PC_Jacobi *)pc->data; in PCJacobiGetRowl1Scale_Jacobi()
126 static PetscErrorCode PCJacobiSetFixDiagonal_Jacobi(PC pc, PetscBool flg) in PCJacobiSetFixDiagonal_Jacobi() argument
128 PC_Jacobi *j = (PC_Jacobi *)pc->data; in PCJacobiSetFixDiagonal_Jacobi()
135 static PetscErrorCode PCJacobiGetFixDiagonal_Jacobi(PC pc, PetscBool *flg) in PCJacobiGetFixDiagonal_Jacobi() argument
137 PC_Jacobi *j = (PC_Jacobi *)pc->data; in PCJacobiGetFixDiagonal_Jacobi()
144 static PetscErrorCode PCJacobiGetDiagonal_Jacobi(PC pc, Vec diag, Vec diagsqrt) in PCJacobiGetDiagonal_Jacobi() argument
146 PC_Jacobi *j = (PC_Jacobi *)pc->data; in PCJacobiGetDiagonal_Jacobi()
147 MPI_Comm comm = PetscObjectComm((PetscObject)pc); in PCJacobiGetDiagonal_Jacobi()
151 …g), comm, PETSC_ERR_ARG_WRONGSTATE, "Jacobi diagonal not available. Check if PC is non-symmetric"); in PCJacobiGetDiagonal_Jacobi()
152 …m, PETSC_ERR_ARG_WRONGSTATE, "Jacobi diagonal squareroot not available. Check if PC is symmetric"); in PCJacobiGetDiagonal_Jacobi()
164 . pc - the preconditioner context
172 static PetscErrorCode PCSetUp_Jacobi(PC pc) in PCSetUp_Jacobi() argument
174 PC_Jacobi *jac = (PC_Jacobi *)pc->data; in PCSetUp_Jacobi()
183 if (!pc->setupcalled) { allocate space the first time this is ever called in PCSetUp_Jacobi()
184 PetscCall(MatCreateVecs(pc->mat,&jac->diag)); in PCSetUp_Jacobi()
209 PetscCall(MatGetDiagonal(pc->pmat, diag)); in PCSetUp_Jacobi()
212 PetscCall(MatGetRowMaxAbs(pc->pmat, diag, NULL)); in PCSetUp_Jacobi()
215 PetscCall(MatGetRowSumAbs(pc->pmat, diag)); in PCSetUp_Jacobi()
217 PetscCall(MatIsSPDKnown(pc->pmat, &isset, &isspd)); in PCSetUp_Jacobi()
223 PetscCall(MatGetDiagonal(pc->pmat, true_diag)); in PCSetUp_Jacobi()
235 …PetscCheck(!jac->useabs || !negflag, PetscObjectComm((PetscObject)pc), PETSC_ERR_ARG_INCOMP, "Jaco… in PCSetUp_Jacobi()
241 PetscCall(MatGetDiagonal(pc->pmat, true_diag)); in PCSetUp_Jacobi()
249 PetscCall(MatGetRowSum(pc->pmat, diag)); in PCSetUp_Jacobi()
254 PetscCall(MatIsSPDKnown(pc->pmat, &isset, &isspd)); in PCSetUp_Jacobi()
275 PetscCall(MatGetDiagonal(pc->pmat, diagsqrt)); in PCSetUp_Jacobi()
278 PetscCall(MatGetRowMaxAbs(pc->pmat, diagsqrt, NULL)); in PCSetUp_Jacobi()
281 PetscCall(MatGetRowSumAbs(pc->pmat, diagsqrt)); in PCSetUp_Jacobi()
284 PetscCall(MatGetRowSum(pc->pmat, diagsqrt)); in PCSetUp_Jacobi()
300 …if (zeroflag) PetscCall(PetscInfo(pc, "Zero detected in diagonal of matrix, using 1 at those locat… in PCSetUp_Jacobi()
310 . pc - the preconditioner context
312 static PetscErrorCode PCSetUp_Jacobi_Symmetric(PC pc) in PCSetUp_Jacobi_Symmetric() argument
314 PC_Jacobi *jac = (PC_Jacobi *)pc->data; in PCSetUp_Jacobi_Symmetric()
317 PetscCall(MatCreateVecs(pc->pmat, &jac->diagsqrt, NULL)); in PCSetUp_Jacobi_Symmetric()
319 PetscCall(PCSetUp_Jacobi(pc)); in PCSetUp_Jacobi_Symmetric()
329 . pc - the preconditioner context
331 static PetscErrorCode PCSetUp_Jacobi_NonSymmetric(PC pc) in PCSetUp_Jacobi_NonSymmetric() argument
333 PC_Jacobi *jac = (PC_Jacobi *)pc->data; in PCSetUp_Jacobi_NonSymmetric()
336 PetscCall(MatCreateVecs(pc->pmat, &jac->diag, NULL)); in PCSetUp_Jacobi_NonSymmetric()
338 PetscCall(PCSetUp_Jacobi(pc)); in PCSetUp_Jacobi_NonSymmetric()
346 . pc - the preconditioner context
354 static PetscErrorCode PCApply_Jacobi(PC pc, Vec x, Vec y) in PCApply_Jacobi() argument
356 PC_Jacobi *jac = (PC_Jacobi *)pc->data; in PCApply_Jacobi()
359 if (!jac->diag) PetscCall(PCSetUp_Jacobi_NonSymmetric(pc)); in PCApply_Jacobi()
369 . pc - the preconditioner context
377 static PetscErrorCode PCApplySymmetricLeftOrRight_Jacobi(PC pc, Vec x, Vec y) in PCApplySymmetricLeftOrRight_Jacobi() argument
379 PC_Jacobi *jac = (PC_Jacobi *)pc->data; in PCApplySymmetricLeftOrRight_Jacobi()
382 if (!jac->diagsqrt) PetscCall(PCSetUp_Jacobi_Symmetric(pc)); in PCApplySymmetricLeftOrRight_Jacobi()
387 static PetscErrorCode PCReset_Jacobi(PC pc) in PCReset_Jacobi() argument
389 PC_Jacobi *jac = (PC_Jacobi *)pc->data; in PCReset_Jacobi()
404 . pc - the preconditioner context
408 static PetscErrorCode PCDestroy_Jacobi(PC pc) in PCDestroy_Jacobi() argument
411 PetscCall(PCReset_Jacobi(pc)); in PCDestroy_Jacobi()
412 PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCJacobiSetType_C", NULL)); in PCDestroy_Jacobi()
413 PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCJacobiGetType_C", NULL)); in PCDestroy_Jacobi()
414 PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCJacobiSetUseAbs_C", NULL)); in PCDestroy_Jacobi()
415 PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCJacobiGetUseAbs_C", NULL)); in PCDestroy_Jacobi()
416 PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCJacobiSetRowl1Scale_C", NULL)); in PCDestroy_Jacobi()
417 PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCJacobiGetRowl1Scale_C", NULL)); in PCDestroy_Jacobi()
418 PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCJacobiSetFixDiagonal_C", NULL)); in PCDestroy_Jacobi()
419 PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCJacobiGetFixDiagonal_C", NULL)); in PCDestroy_Jacobi()
420 PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCJacobiGetDiagonal_C", NULL)); in PCDestroy_Jacobi()
423 Free the private data structure that was hanging off the PC in PCDestroy_Jacobi()
425 PetscCall(PetscFree(pc->data)); in PCDestroy_Jacobi()
429 static PetscErrorCode PCSetFromOptions_Jacobi(PC pc, PetscOptionItems PetscOptionsObject) in PCSetFromOptions_Jacobi() argument
431 PC_Jacobi *jac = (PC_Jacobi *)pc->data; in PCSetFromOptions_Jacobi()
436 PetscCall(PCJacobiGetType(pc, &deflt)); in PCSetFromOptions_Jacobi()
439 if (flg) PetscCall(PCJacobiSetType(pc, type)); in PCSetFromOptions_Jacobi()
447 static PetscErrorCode PCView_Jacobi(PC pc, PetscViewer viewer) in PCView_Jacobi() argument
449 PC_Jacobi *jac = (PC_Jacobi *)pc->data; in PCView_Jacobi()
460 PetscCall(PCJacobiGetType(pc, &type)); in PCView_Jacobi()
461 PetscCall(PCJacobiGetUseAbs(pc, &useAbs)); in PCView_Jacobi()
462 PetscCall(PCJacobiGetFixDiagonal(pc, &fixdiag)); in PCView_Jacobi()
463 PetscCall(PCJacobiGetRowl1Scale(pc, &scale)); in PCView_Jacobi()
476 context, PC, that was created within PCCreate().
479 . pc - the preconditioner context
503 .seealso: `PCCreate()`, `PCSetType()`, `PCType`, `PC`,
509 PETSC_EXTERN PetscErrorCode PCCreate_Jacobi(PC pc) in PCCreate_Jacobi() argument
516 attach it to the PC object. in PCCreate_Jacobi()
519 pc->data = (void *)jac; in PCCreate_Jacobi()
539 pc->ops->apply = PCApply_Jacobi; in PCCreate_Jacobi()
540 pc->ops->applytranspose = PCApply_Jacobi; in PCCreate_Jacobi()
541 pc->ops->setup = PCSetUp_Jacobi; in PCCreate_Jacobi()
542 pc->ops->reset = PCReset_Jacobi; in PCCreate_Jacobi()
543 pc->ops->destroy = PCDestroy_Jacobi; in PCCreate_Jacobi()
544 pc->ops->setfromoptions = PCSetFromOptions_Jacobi; in PCCreate_Jacobi()
545 pc->ops->view = PCView_Jacobi; in PCCreate_Jacobi()
546 pc->ops->applyrichardson = NULL; in PCCreate_Jacobi()
547 pc->ops->applysymmetricleft = PCApplySymmetricLeftOrRight_Jacobi; in PCCreate_Jacobi()
548 pc->ops->applysymmetricright = PCApplySymmetricLeftOrRight_Jacobi; in PCCreate_Jacobi()
550 …PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCJacobiSetType_C", PCJacobiSetType_Jacobi)… in PCCreate_Jacobi()
551 …PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCJacobiGetType_C", PCJacobiGetType_Jacobi)… in PCCreate_Jacobi()
552 …PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCJacobiSetRowl1Scale_C", PCJacobiSetRowl1S… in PCCreate_Jacobi()
553 …PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCJacobiGetRowl1Scale_C", PCJacobiGetRowl1S… in PCCreate_Jacobi()
554 …PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCJacobiSetUseAbs_C", PCJacobiSetUseAbs_Jac… in PCCreate_Jacobi()
555 …PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCJacobiGetUseAbs_C", PCJacobiGetUseAbs_Jac… in PCCreate_Jacobi()
556 …PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCJacobiSetFixDiagonal_C", PCJacobiSetFixDi… in PCCreate_Jacobi()
557 …PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCJacobiGetFixDiagonal_C", PCJacobiGetFixDi… in PCCreate_Jacobi()
558 …PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCJacobiGetDiagonal_C", PCJacobiGetDiagonal… in PCCreate_Jacobi()
569 + pc - the preconditioner context
582 PetscErrorCode PCJacobiSetUseAbs(PC pc, PetscBool flg) in PCJacobiSetUseAbs() argument
585 PetscValidHeaderSpecific(pc, PC_CLASSID, 1); in PCJacobiSetUseAbs()
586 PetscTryMethod(pc, "PCJacobiSetUseAbs_C", (PC, PetscBool), (pc, flg)); in PCJacobiSetUseAbs()
597 . pc - the preconditioner context
606 PetscErrorCode PCJacobiGetUseAbs(PC pc, PetscBool *flg) in PCJacobiGetUseAbs() argument
609 PetscValidHeaderSpecific(pc, PC_CLASSID, 1); in PCJacobiGetUseAbs()
610 PetscUseMethod(pc, "PCJacobiGetUseAbs_C", (PC, PetscBool *), (pc, flg)); in PCJacobiGetUseAbs()
621 + pc - the preconditioner context
631 PetscErrorCode PCJacobiSetRowl1Scale(PC pc, PetscReal scale) in PCJacobiSetRowl1Scale() argument
634 PetscValidHeaderSpecific(pc, PC_CLASSID, 1); in PCJacobiSetRowl1Scale()
635 PetscTryMethod(pc, "PCJacobiSetRowl1Scale_C", (PC, PetscReal), (pc, scale)); in PCJacobiSetRowl1Scale()
645 . pc - the preconditioner context
654 PetscErrorCode PCJacobiGetRowl1Scale(PC pc, PetscReal *scale) in PCJacobiGetRowl1Scale() argument
657 PetscValidHeaderSpecific(pc, PC_CLASSID, 1); in PCJacobiGetRowl1Scale()
658 PetscUseMethod(pc, "PCJacobiGetRowl1Scale_C", (PC, PetscReal *), (pc, scale)); in PCJacobiGetRowl1Scale()
668 + pc - the preconditioner context
681 PetscErrorCode PCJacobiSetFixDiagonal(PC pc, PetscBool flg) in PCJacobiSetFixDiagonal() argument
684 PetscValidHeaderSpecific(pc, PC_CLASSID, 1); in PCJacobiSetFixDiagonal()
685 PetscTryMethod(pc, "PCJacobiSetFixDiagonal_C", (PC, PetscBool), (pc, flg)); in PCJacobiSetFixDiagonal()
695 . pc - the preconditioner context
707 PetscErrorCode PCJacobiGetFixDiagonal(PC pc, PetscBool *flg) in PCJacobiGetFixDiagonal() argument
710 PetscValidHeaderSpecific(pc, PC_CLASSID, 1); in PCJacobiGetFixDiagonal()
711 PetscUseMethod(pc, "PCJacobiGetFixDiagonal_C", (PC, PetscBool *), (pc, flg)); in PCJacobiGetFixDiagonal()
721 . pc - the preconditioner context
731 PetscErrorCode PCJacobiGetDiagonal(PC pc, Vec diagonal, Vec diagonal_sqrt) in PCJacobiGetDiagonal() argument
734 PetscValidHeaderSpecific(pc, PC_CLASSID, 1); in PCJacobiGetDiagonal()
735 PetscUseMethod(pc, "PCJacobiGetDiagonal_C", (PC, Vec, Vec), (pc, diagonal, diagonal_sqrt)); in PCJacobiGetDiagonal()
746 + pc - the preconditioner context
759 PetscErrorCode PCJacobiSetType(PC pc, PCJacobiType type) in PCJacobiSetType() argument
762 PetscValidHeaderSpecific(pc, PC_CLASSID, 1); in PCJacobiSetType()
763 PetscTryMethod(pc, "PCJacobiSetType_C", (PC, PCJacobiType), (pc, type)); in PCJacobiSetType()
773 . pc - the preconditioner context
782 PetscErrorCode PCJacobiGetType(PC pc, PCJacobiType *type) in PCJacobiGetType() argument
785 PetscValidHeaderSpecific(pc, PC_CLASSID, 1); in PCJacobiGetType()
786 PetscUseMethod(pc, "PCJacobiGetType_C", (PC, PCJacobiType *), (pc, type)); in PCJacobiGetType()