Actual source code: richscale.c

petsc-3.14.6 2021-03-30
Report Typos and Errors

  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 on ksp

 10:     Input Parameters:
 11: +   ksp - the iterative context
 12: -   scale - the relaxation factor

 14:     Options Database Keys:
 15: . -ksp_richardson_self <scale> - Set the scale factor

 17:     Level: intermediate

 19:     .seealso: KSPRICHARDSON, KSPRichardsonSetSelfScale()
 20: @*/
 21: PetscErrorCode  KSPRichardsonSetScale(KSP ksp,PetscReal scale)
 22: {

 28:   PetscTryMethod(ksp,"KSPRichardsonSetScale_C",(KSP,PetscReal),(ksp,scale));
 29:   return(0);
 30: }

 32: /*@
 33:     KSPRichardsonSetSelfScale - Sets Richardson to automatically determine optimal scaling at each iteration to minimize the 2-norm of the
 34:        preconditioned residual

 36:     Logically Collective on ksp

 38:     Input Parameters:
 39: +   ksp - the iterative context
 40: -   scale - PETSC_TRUE or the default of PETSC_FALSE

 42:     Options Database Keys:
 43: . -ksp_richardson_self_scale - Use self-scaling

 45:     Level: intermediate

 47:     Notes:
 48:     Requires two extra work vectors. Uses an extra VecAXPY() and VecDotNorm2() per iteration.

 50:     Developer Notes:
 51:     Could also minimize the 2-norm of the true residual with one less work vector

 53:     .seealso: KSPRICHARDSON, KSPRichardsonSetScale()
 54: @*/
 55: PetscErrorCode  KSPRichardsonSetSelfScale(KSP ksp,PetscBool scale)
 56: {

 62:   PetscTryMethod(ksp,"KSPRichardsonSetSelfScale_C",(KSP,PetscBool),(ksp,scale));
 63:   return(0);
 64: }