Actual source code: richscale.c

petsc-3.4.5 2014-06-29
  2: #include <petsc-private/kspimpl.h>         /*I "petscksp.h" I*/
  3: #include <../src/ksp/ksp/impls/rich/richardsonimpl.h>


  8: /*@
  9:     KSPRichardsonSetScale - Set the damping factor; if this routine is not called, the factor
 10:     defaults to 1.0.

 12:     Logically Collective on KSP

 14:     Input Parameters:
 15: +   ksp - the iterative context
 16: -   scale - the relaxation factor

 18:     Level: intermediate

 20: .keywords: KSP, Richardson, set, scale
 21: @*/
 22: PetscErrorCode  KSPRichardsonSetScale(KSP ksp,PetscReal scale)
 23: {

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

 35: /*@
 36:     KSPRichardsonSetSelfScale - Sets Richardson to automatically determine optimal scaling at each iteration to minimize the 2-norm of the
 37:        preconditioned residual

 39:     Logically Collective on KSP

 41:     Input Parameters:
 42: +   ksp - the iterative context
 43: -   scale - PETSC_TRUE or the default of PETSC_FALSE

 45:     Level: intermediate

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

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


 52: .keywords: KSP, Richardson, set, scale
 53: @*/
 54: PetscErrorCode  KSPRichardsonSetSelfScale(KSP ksp,PetscBool scale)
 55: {

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