# Diff of /trunk/paso/src/NewtonGMRES.c

revision 1651 by phornby, Tue Jul 15 09:33:48 2008 UTC revision 1798 by gross, Wed Sep 17 06:21:12 2008 UTC
# Line 78  err_t Paso_Solver_NewtonGMRES( Line 78  err_t Paso_Solver_NewtonGMRES(
78        * stoping criterium:        * stoping criterium:
79        */        */
80       stop_tol=atol + rtol*norm_f;       stop_tol=atol + rtol*norm_f;
81       iteration_count=0;       iteration_count=1;
82       if (debug) printf("Start Jacobi-free Newton scheme:\n\ttolerance = %e\n\tstoping tolerance = %e\n",rtol,stop_tol);       if (debug) printf("Start Jacobi-free Newton scheme:\n\ttolerance = %e\n\tstopping tolerance = %e\n",rtol,stop_tol);
83       /*       /*
84        *  main iteration loop        *  main iteration loop
85        */        */
# Line 88  err_t Paso_Solver_NewtonGMRES( Line 88  err_t Paso_Solver_NewtonGMRES(
88            * keep track of the ratio (reduction_f = norm_f/frnmo) of successive residual norms and            * keep track of the ratio (reduction_f = norm_f/frnmo) of successive residual norms and
89            * the iteration counter (iteration_count)            * the iteration counter (iteration_count)
90            */            */
iteration_count++;
91           if (debug) printf("iteration step %d: norm of F =%lg\n",iteration_count,norm_f);           if (debug) printf("iteration step %d: norm of F =%lg\n",iteration_count,norm_f);
92           /*           /*
93            * call GMRES to get increment            * call GMRES to get increment
# Line 113  err_t Paso_Solver_NewtonGMRES( Line 112  err_t Paso_Solver_NewtonGMRES(
112              /*              /*
114               */               */
116                   old_inner_tolerance=inner_tolerance;                   old_inner_tolerance=inner_tolerance;
117                   inner_tolerance=inner_tolerance_safety * reduction_f * reduction_f;                   inner_tolerance=inner_tolerance_safety * reduction_f * reduction_f;
118                   rtmp=inner_tolerance_safety * old_inner_tolerance * old_inner_tolerance;                   rtmp=inner_tolerance_safety * old_inner_tolerance * old_inner_tolerance;
119                   if (rtmp>.1) inner_tolerance=MAX(inner_tolerance,rtmp);                   if (rtmp>.1) inner_tolerance=MAX(inner_tolerance,rtmp);
120                   inner_tolerance=MAX(MIN(inner_tolerance,max_inner_tolerance), .5*stop_tol/norm_f);                   inner_tolerance=MAX(MIN(inner_tolerance,max_inner_tolerance), .5*stop_tol/norm_f);
121                }              }
122                convergeFlag = (norm_f <= stop_tol);              convergeFlag = (norm_f <= stop_tol);
123           } else {           } else {
124             breakFlag=TRUE;              breakFlag=TRUE;
125           }           }
126           maxIterFlag = (iteration_count > maxit);           maxIterFlag = (iteration_count > maxit);
127        }        }
128          if (debug) {
129               if (convergeFlag) printf("convergence reached after %d steps with residual %e.\n",iteration_count,norm_f);
130               if (breakFlag)  printf("iteration break down after %d steps.\n",iteration_count);
131               if (maxIterFlag)  printf("maximum number of iteration step %s is reached.\n",maxit);
132          }
133          if (breakFlag) Status=SOLVER_BREAKDOWN;
134          if (maxIterFlag) Status=SOLVER_MAXITER_REACHED;
135    }    }
136    TMPMEMFREE(f);    TMPMEMFREE(f);
137    TMPMEMFREE(step);    TMPMEMFREE(step);
138    printf("STATUS return = %d\n",Status);
139    return Status;    return Status;
140  }  }

Legend:
 Removed from v.1651 changed lines Added in v.1798