newton_solver.h
Go to the documentation of this file.00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2012 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 00037 class LinearSolutionMonitor { 00038 public: 00039 virtual void operator() (const NumericVector<Number>& delta_u, const double &norm_delta_u, 00040 const NumericVector<Number>& u, const double &norm_u) = 0; 00041 virtual ~LinearSolutionMonitor(); 00042 }; 00043 00044 inline LinearSolutionMonitor::~LinearSolutionMonitor() {} 00045 00046 00059 // ------------------------------------------------------------ 00060 // Solver class definition 00061 class NewtonSolver : public DiffSolver 00062 { 00063 public: 00068 explicit 00069 NewtonSolver (sys_type& system); 00070 00074 virtual ~NewtonSolver (); 00075 00076 typedef DiffSolver Parent; 00077 00082 virtual void reinit (); 00083 00088 virtual unsigned int solve (); 00089 00097 bool require_residual_reduction; 00098 00106 bool require_finite_residual; 00107 00119 bool brent_line_search; 00120 00127 Real minsteplength; 00128 00133 Real linear_tolerance_multiplier; 00134 00138 AutoPtr<LinearSolutionMonitor> linear_solution_monitor; 00139 00140 protected: 00141 00148 AutoPtr<LinearSolver<Number> > linear_solver; 00149 00156 Real line_search(Real tol, Real last_residual, Real& current_residual, 00157 NumericVector<Number> &newton_iterate, 00158 const NumericVector<Number> &linear_solution); 00159 00164 void print_convergence(unsigned int step_num, 00165 Real current_residual, 00166 Real step_norm, 00167 bool linear_solve_finished); 00168 00173 bool test_convergence(Real current_residual, 00174 Real step_norm, 00175 bool linear_solve_finished); 00176 }; 00177 00178 00179 } // namespace libMesh 00180 00181 00182 #endif // LIBMESH_NEWTON_SOLVER_H
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:48 UTC
Hosted By: