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,n;
25: double glnorm;
28: info=VecNorm(GL,NORM_2,&glnorm); CHKERRQ(info);
29: info=VecGetSize(GL,&n); CHKERRQ(info);
30: *flag=PETSC_FALSE;
31: if (glnorm/sqrt((double)n) < taoapp->grtol) *flag=PETSC_TRUE;
32: return(0);
33: }
38: /*@C
39: TaoAppSetRelativeTolerance - Set convergence tolerance
41: Collective on TAO_APPLICATION
43: Input Parameters:
44: + taoapp - the TAO_APPLICATION context
45: . grtol - relative tolerance
47: Level: intermediate
49: .keywords: TAO_APPLICATION, monitor
51: @*/
52: int TaoAppSetRelativeTolerance(TAO_APPLICATION taoapp, double grtol){
55: taoapp->grtol=grtol;
56: return(0);
57: }