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 defaults to 1.0.
6: Logically Collective
8: Input Parameters:
9: + ksp - the iterative context
10: - scale - the damping factor
12: Options Database Key:
13: . -ksp_richardson_scale <scale> - Set the scale factor
15: Level: intermediate
17: .seealso: [](ch_ksp), `KSPRICHARDSON`, `KSPRichardsonSetSelfScale()`
18: @*/
19: PetscErrorCode KSPRichardsonSetScale(KSP ksp, PetscReal scale)
20: {
21: PetscFunctionBegin;
24: PetscTryMethod(ksp, "KSPRichardsonSetScale_C", (KSP, PetscReal), (ksp, scale));
25: PetscFunctionReturn(PETSC_SUCCESS);
26: }
28: /*@
29: KSPRichardsonSetSelfScale - Sets Richardson to automatically determine optimal scaling at each iteration to minimize the 2-norm of the
30: preconditioned residual
32: Logically Collective
34: Input Parameters:
35: + ksp - the iterative context
36: - scale - `PETSC_TRUE` or the default of `PETSC_FALSE`
38: Options Database Key:
39: . -ksp_richardson_self_scale - Use self-scaling
41: Level: intermediate
43: Note:
44: Requires two extra work vectors. Uses an extra `VecAXPY()` and `VecDotNorm2()` per iteration.
46: Developer Note:
47: Could also minimize the 2-norm of the true residual with one less work vector
49: .seealso: [](ch_ksp), `KSPRICHARDSON`, `KSPRichardsonSetScale()`
50: @*/
51: PetscErrorCode KSPRichardsonSetSelfScale(KSP ksp, PetscBool scale)
52: {
53: PetscFunctionBegin;
56: PetscTryMethod(ksp, "KSPRichardsonSetSelfScale_C", (KSP, PetscBool), (ksp, scale));
57: PetscFunctionReturn(PETSC_SUCCESS);
58: }