/[escript]/trunk/paso/src/NewtonGMRES.c
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3641 by gross, Thu Apr 22 05:59:31 2010 UTC revision 3642 by caltinay, Thu Oct 27 03:41:51 2011 UTC
# Line 16  Line 16 
16  *  Purpose  *  Purpose
17  *  =======  *  =======
18  *  *
19  *  NewtonGMRES solves the non-linear system F(x)=0 using the  *  NewtonGMRES solves the nonlinear system F(x)=0 using the
20  *  restarted GMRES method.  *  restarted GMRES method.
21  *  *
22  *  Convergence test: norm(F(x))< rtol*norm(F(x0))+atol  *  Convergence test: norm(F(x))< rtol*norm(F(x0))+atol
# Line 24  Line 24 
24  *  x input initial guess  *  x input initial guess
25  *    output solution approximation  *    output solution approximation
26  *  *
27  *  based on code by C. T. Kelley, July 1, 1994.  *  Based on code by C. T. Kelley, July 1, 1994.
28  *  *
29  */  */
30    
# Line 53  err_t Paso_Solver_NewtonGMRES( Line 53  err_t Paso_Solver_NewtonGMRES(
53     const double atol=options->absolute_tolerance;  /* absolute tolerance */     const double atol=options->absolute_tolerance;  /* absolute tolerance */
54     const double rtol=options->tolerance;           /* relative tolerance */     const double rtol=options->tolerance;           /* relative tolerance */
55     const dim_t maxit=options->iter_max;            /* max iteration counter */     const dim_t maxit=options->iter_max;            /* max iteration counter */
56     const dim_t lmaxit=options->inner_iter_max*10;     /* max inner iteration counter */     const dim_t lmaxit=options->inner_iter_max*10;  /* max inner iteration counter */
57     const bool_t adapt_inner_tolerance=options->adapt_inner_tolerance;     const bool_t adapt_inner_tolerance=options->adapt_inner_tolerance;
58     const double max_inner_tolerance=options->inner_tolerance *1.e-11;       const double max_inner_tolerance=options->inner_tolerance *1.e-11;  
59     double inner_tolerance=max_inner_tolerance;     double inner_tolerance=max_inner_tolerance;
60    /*    /*
61     * max_inner_tolerance = Maximum error tolerance for residual in inner     * max_inner_tolerance = Maximum error tolerance for residual in inner
62     *              iteration. The inner iteration terminates     *              iteration. The inner iteration terminates
63     *              when the relative linear residual is smaller than inner_tolerance*| F(x_c) |. inner_tolerance is determined     *              when the relative linear residual is smaller than
64     *              by the modified Eisenstat-Walker formula, if adapt_inner_tolerance is set, otherwise     *              inner_tolerance*| F(x_c) |. Inner_tolerance is determined
65       *              by the modified Eisenstat-Walker formula, if
66       *              adapt_inner_tolerance is set, otherwise
67     *              inner_tolerance = max_inner_tolerance iteration.     *              inner_tolerance = max_inner_tolerance iteration.
68     */     */
69        
# Line 78  err_t Paso_Solver_NewtonGMRES( Line 80  err_t Paso_Solver_NewtonGMRES(
80       norm2_f=Paso_l2(n,f,F->mpi_info);       norm2_f=Paso_l2(n,f,F->mpi_info);
81       normsup_f=Paso_lsup(n,f,F->mpi_info);       normsup_f=Paso_lsup(n,f,F->mpi_info);
82       /*       /*
83        * stoping criterium:        * stopping criterion:
84        */        */
85       stop_tol=atol + rtol*normsup_f;       stop_tol=atol + rtol*normsup_f;
86       if (stop_tol<=0) {       if (stop_tol<=0) {
# Line 104  err_t Paso_Solver_NewtonGMRES( Line 106  err_t Paso_Solver_NewtonGMRES(
106          */          */
107         while (! (convergeFlag || maxIterFlag || breakFlag)) {         while (! (convergeFlag || maxIterFlag || breakFlag)) {
108           /*           /*
109            * keep track of the ratio (reduction_f = norm2_f/norm2_fo) of successive residual norms and            * keep track of the ratio (reduction_f = norm2_f/norm2_fo) of
110            * the iteration counter (iteration_count)            * successive residual norms and the iteration counter (iteration_count)
111            */            */
112           if (debug) printf("NewtonGMRES: iteration step %d: lsup-norm of F =%e\n",iteration_count,normsup_f);           if (debug) printf("NewtonGMRES: iteration step %d: lsup-norm of F =%e\n",iteration_count,normsup_f);
113           /*           /*
# Line 152  err_t Paso_Solver_NewtonGMRES( Line 154  err_t Paso_Solver_NewtonGMRES(
154                printf("NewtonGMRES: iteration step %d: lsup-norm of F =%e\n",iteration_count,normsup_f);                printf("NewtonGMRES: iteration step %d: lsup-norm of F =%e\n",iteration_count,normsup_f);
155    
156                if (convergeFlag) printf("NewtonGMRES: convergence reached after %d steps.\n",iteration_count);                if (convergeFlag) printf("NewtonGMRES: convergence reached after %d steps.\n",iteration_count);
157                if (breakFlag)  printf("NewtonGMRES: iteration break down after %d steps.\n",iteration_count);                if (breakFlag) printf("NewtonGMRES: iteration break down after %d steps.\n",iteration_count);
158                if (maxIterFlag)  printf("NewtonGMRES: maximum number of iteration step %d is reached.\n",maxit);                if (maxIterFlag) printf("NewtonGMRES: maximum number of iteration steps %d reached.\n",maxit);
159           }           }
160          if (breakFlag) Status=SOLVER_BREAKDOWN;          if (breakFlag) Status=SOLVER_BREAKDOWN;
161          if (maxIterFlag) Status=SOLVER_MAXITER_REACHED;          if (maxIterFlag) Status=SOLVER_MAXITER_REACHED;
# Line 161  err_t Paso_Solver_NewtonGMRES( Line 163  err_t Paso_Solver_NewtonGMRES(
163    }    }
164    TMPMEMFREE(f);    TMPMEMFREE(f);
165    TMPMEMFREE(step);    TMPMEMFREE(step);
166  if (debug) printf("NewtonGMRES: STATUS return = %d\n",Status);    if (debug) printf("NewtonGMRES: STATUS return = %d\n",Status);
167    return Status;    return Status;
168  }  }
169    

Legend:
Removed from v.3641  
changed lines
  Added in v.3642

  ViewVC Help
Powered by ViewVC 1.1.26