$extrastylesheet
newton_solver.h
Go to the documentation of this file.
00001 // The libMesh Finite Element Library.
00002 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
00003 
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2.1 of the License, or (at your option) any later version.
00008 
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Lesser General Public License for more details.
00013 
00014 // You should have received a copy of the GNU Lesser General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018 
00019 
00020 #ifndef LIBMESH_NEWTON_SOLVER_H
00021 #define LIBMESH_NEWTON_SOLVER_H
00022 
00023 // Local includes
00024 #include "libmesh/libmesh_common.h"
00025 #include "libmesh/linear_solver.h"
00026 #include "libmesh/reference_counted_object.h"
00027 #include "libmesh/diff_solver.h"
00028 
00029 // C++ includes
00030 
00031 namespace libMesh
00032 {
00033 
00046 // ------------------------------------------------------------
00047 // Solver class definition
00048 class NewtonSolver : public DiffSolver
00049 {
00050 public:
00055   explicit
00056   NewtonSolver (sys_type& system);
00057 
00061   virtual ~NewtonSolver ();
00062 
00063   typedef DiffSolver Parent;
00064 
00069   virtual void init ();
00070 
00075   virtual void reinit ();
00076 
00081   virtual unsigned int solve ();
00082 
00090   bool require_residual_reduction;
00091 
00099   bool require_finite_residual;
00100 
00112   bool brent_line_search;
00113 
00121   bool track_linear_convergence;
00122 
00129   Real minsteplength;
00130 
00135   Real linear_tolerance_multiplier;
00136 
00137 protected:
00138 
00145   UniquePtr<LinearSolver<Number> > linear_solver;
00146 
00153   Real line_search(Real tol, Real last_residual, Real& current_residual,
00154                    NumericVector<Number> &newton_iterate,
00155                    const NumericVector<Number> &linear_solution);
00156 
00161   void print_convergence(unsigned int step_num,
00162                          Real current_residual,
00163                          Real step_norm,
00164                          bool linear_solve_finished);
00165 
00170   bool test_convergence(Real current_residual,
00171                         Real step_norm,
00172                         bool linear_solve_finished);
00173 };
00174 
00175 
00176 } // namespace libMesh
00177 
00178 
00179 #endif // LIBMESH_NEWTON_SOLVER_H