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 Keys:
 15: . -ksp_richardson_self <scale> - Set the scale factor

 17:     Level: intermediate

 19:  .seealso: [](chapter_ksp), `KSPRICHARDSON`, `KSPRichardsonSetSelfScale()`
 20: @*/
 21: PetscErrorCode KSPRichardsonSetScale(KSP ksp, PetscReal scale)
 22: {
 25:   PetscTryMethod(ksp, "KSPRichardsonSetScale_C", (KSP, PetscReal), (ksp, scale));
 26:   return 0;
 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 Keys:
 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 Note:
 48:     Could also minimize the 2-norm of the true residual with one less work vector

 50: .seealso: [](chapter_ksp), `KSPRICHARDSON`, `KSPRichardsonSetScale()`
 51: @*/
 52: PetscErrorCode KSPRichardsonSetSelfScale(KSP ksp, PetscBool scale)
 53: {
 56:   PetscTryMethod(ksp, "KSPRichardsonSetSelfScale_C", (KSP, PetscBool), (ksp, scale));
 57:   return 0;
 58: }