Actual source code: richscale.c
2: #include <../src/ksp/ksp/impls/rich/richardsonimpl.h>
4: /*@
5: KSPRichardsonSetScale - Set the damping factor; if this routine is not called, the factor
6: defaults to 1.0.
8: Logically Collective
10: Input Parameters:
11: + ksp - the iterative context
12: - scale - the damping factor
14: Options Database Key:
15: . -ksp_richardson_scale <scale> - Set the scale factor
17: Level: intermediate
19: .seealso: [](ch_ksp), `KSPRICHARDSON`, `KSPRichardsonSetSelfScale()`
20: @*/
21: PetscErrorCode KSPRichardsonSetScale(KSP ksp, PetscReal scale)
22: {
23: PetscFunctionBegin;
26: PetscTryMethod(ksp, "KSPRichardsonSetScale_C", (KSP, PetscReal), (ksp, scale));
27: PetscFunctionReturn(PETSC_SUCCESS);
28: }
30: /*@
31: KSPRichardsonSetSelfScale - Sets Richardson to automatically determine optimal scaling at each iteration to minimize the 2-norm of the
32: preconditioned residual
34: Logically Collective
36: Input Parameters:
37: + ksp - the iterative context
38: - scale - `PETSC_TRUE` or the default of `PETSC_FALSE`
40: Options Database Key:
41: . -ksp_richardson_self_scale - Use self-scaling
43: Level: intermediate
45: Note:
46: Requires two extra work vectors. Uses an extra `VecAXPY()` and `VecDotNorm2()` per iteration.
48: Developer Note:
49: Could also minimize the 2-norm of the true residual with one less work vector
51: .seealso: [](ch_ksp), `KSPRICHARDSON`, `KSPRichardsonSetScale()`
52: @*/
53: PetscErrorCode KSPRichardsonSetSelfScale(KSP ksp, PetscBool scale)
54: {
55: PetscFunctionBegin;
58: PetscTryMethod(ksp, "KSPRichardsonSetSelfScale_C", (KSP, PetscBool), (ksp, scale));
59: PetscFunctionReturn(PETSC_SUCCESS);
60: }