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