libMesh
Loading...
Searching...
No Matches
newton_solver.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18
19
20#ifndef LIBMESH_NEWTON_SOLVER_H
21#define LIBMESH_NEWTON_SOLVER_H
22
23// Local includes
24#include "libmesh/libmesh_common.h"
25#include "libmesh/linear_solver.h"
26#include "libmesh/reference_counted_object.h"
27#include "libmesh/diff_solver.h"
28
29// C++ includes
30
31namespace libMesh
32{
33
47{
48public:
53 explicit
55
59 virtual ~NewtonSolver ();
60
62
67 virtual void init () override;
68
73 virtual void reinit () override;
74
79 virtual unsigned int solve () override;
80
85
90
99
108
121
130
138
144
145protected:
146
153 std::unique_ptr<LinearSolver<Number>> _linear_solver;
154
163 Real last_residual,
164 Real & current_residual,
165 NumericVector<Number> & newton_iterate,
166 const NumericVector<Number> & linear_solution);
167
172 void print_convergence(unsigned int step_num,
173 Real current_residual,
174 Real step_norm,
175 bool linear_solve_finished);
176
181 bool test_convergence(Real current_residual,
182 Real step_norm,
183 bool linear_solve_finished);
184};
185
186
187} // namespace libMesh
188
189
190#endif // LIBMESH_NEWTON_SOLVER_H
This is a generic class that defines a solver to handle ImplicitSystem classes, including NonlinearIm...
Definition diff_solver.h:70
const sys_type & system() const
Manages consistently variables, degrees of freedom, coefficient vectors, and matrices for implicit sy...
This base class can be inherited from to provide interfaces to linear solvers from different packages...
This class defines a solver which uses the default libMesh linear solver in a quasiNewton method to h...
bool require_residual_reduction
If this is set to true, the solver is forced to test the residual after each Newton step,...
double linear_tolerance_multiplier
The tolerance for linear solves is kept below this multiplier (which defaults to 1e-3) times the norm...
bool test_convergence(Real current_residual, Real step_norm, bool linear_solve_finished)
virtual void reinit() override
The reinitialization function.
bool require_finite_residual
If this is set to true, the solver is forced to test the residual after each Newton step,...
void print_convergence(unsigned int step_num, Real current_residual, Real step_norm, bool linear_solve_finished)
This prints output for the convergence criteria based on by the given residual and step size.
Real minsteplength
If the quasi-Newton step length must be reduced to below this factor to give a residual reduction,...
bool track_linear_convergence
If set to true, check for convergence of the linear solve.
virtual void init() override
The initialization function.
Real line_search(Real tol, Real last_residual, Real &current_residual, NumericVector< Number > &newton_iterate, const NumericVector< Number > &linear_solution)
This does a line search in the direction opposite linear_solution to try and minimize the residual of...
virtual ~NewtonSolver()
Destructor.
bool brent_line_search
If require_residual_reduction is true, the solver may reduce step lengths when required.
const LinearSolver< Number > & get_linear_solver() const
LinearSolver< Number > & get_linear_solver()
virtual unsigned int solve() override
This method performs a solve, using an inexact Newton-Krylov method with line search.
std::unique_ptr< LinearSolver< Number > > _linear_solver
The LinearSolver defines the interface used to solve the linear_implicit system.
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
The libMesh namespace provides an interface to certain functionality in the library.
libmesh_assert(ctx)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real