Actual source code: tao_app_monitor.c

  1: #include "tao_app_impl.h"     /*I  "tao.h"  I*/

  6: /*@C
  7:    TaoAppCheckConvergence - Check convergence of application.

  9:    Collective on TAO_APPLICATION

 11:    Input Parameters:
 12: +  taoapp - the TAO_APPLICATION context
 13: .  GL - the gradient of the Lagrangian function

 15:    Output Parameters:
 16: .  flag - set to PETSC_TRUE if the TAO solver should stop.

 18:    Level: developer

 20: .keywords: TAO_APPLICATION, monitor

 22: @*/
 23: int TaoAppCheckConvergence(TAO_APPLICATION taoapp, Vec GL, PetscTruth *flag){
 24:   int info;
 25:   PetscInt n;
 26:   double glnorm;
 29:   info=VecNorm(GL,NORM_2,&glnorm);  CHKERRQ(info);
 30:   info=VecGetSize(GL,&n);  CHKERRQ(info);
 31:   *flag=PETSC_FALSE;
 32:   if (glnorm/sqrt((double)n) < taoapp->grtol) *flag=PETSC_TRUE;
 33:   return(0);
 34: }


 39: /*@C
 40:    TaoAppSetRelativeTolerance - Set convergence tolerance

 42:    Collective on TAO_APPLICATION

 44:    Input Parameters:
 45: +  taoapp - the TAO_APPLICATION context
 46: .  grtol - relative tolerance

 48:    Level: intermediate

 50: .keywords: TAO_APPLICATION, monitor

 52: @*/
 53: int TaoAppSetRelativeTolerance(TAO_APPLICATION taoapp, double grtol){
 56:   taoapp->grtol=grtol;
 57:   return(0);
 58: }