libMesh
Loading...
Searching...
No Matches
nonlinear_implicit_system.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_NONLINEAR_IMPLICIT_SYSTEM_H
21#define LIBMESH_NONLINEAR_IMPLICIT_SYSTEM_H
22
23// Local Includes
24#include "libmesh/implicit_system.h"
25
26// C++ includes
27
28namespace libMesh
29{
30
31
32// Forward declarations
33class DiffSolver;
34template<typename T> class NonlinearSolver;
35
36
55{
56public:
57
62 const std::string & name,
63 const unsigned int number);
64
75
80
85
91 {
92 public:
93 virtual ~ComputeResidual () = default;
98 virtual void residual (const NumericVector<Number> & X,
100 sys_type & S) = 0;
101 };
102
103
109 {
110 public:
111 virtual ~ComputeJacobian () = default;
112
117 virtual void jacobian (const NumericVector<Number> & X,
119 sys_type & S) = 0;
120 };
121
122
128 {
129 public:
130 virtual ~ComputeBounds () = default;
131
136 virtual void bounds (NumericVector<Number> & XL,
138 sys_type & S) = 0;
139 };
140
153 {
154 public:
155 virtual ~ComputeVectorSubspace () = default;
156
162 virtual void operator()(std::vector<NumericVector<Number> *> & sp,
163 sys_type & s) = 0;
164 };
165
171 {
172 public:
173 virtual ~ComputeResidualandJacobian () = default;
174
183 sys_type & S) = 0;
184 };
185
193 {
194 public:
195 virtual ~ComputePostCheck () = default;
196
207 virtual void postcheck (const NumericVector<Number> & old_soln,
208 NumericVector<Number> & search_direction,
209 NumericVector<Number> & new_soln,
210 bool & changed_search_direction,
211 bool & changed_new_soln,
212 sys_type & S) = 0;
213 };
214
220 {
221 public:
222 virtual ~ComputePreCheck () = default;
223
236 virtual void precheck(const NumericVector<Number> & precheck_soln,
237 NumericVector<Number> & search_direction,
238 bool & changed,
239 sys_type & S) = 0;
240 };
241
245 sys_type & system () { return *this; }
246
251 virtual void clear () override;
252
257 virtual void reinit () override;
258
262 virtual void solve () override;
263
269 virtual std::pair<unsigned int, Real>
270 get_linear_solve_parameters() const override;
271
276 virtual void assembly(bool get_residual,
277 bool get_jacobian,
278 bool apply_heterogeneous_constraints = false,
279 bool apply_no_constraints = false) override;
280
285 virtual std::string system_type () const override { return "NonlinearImplicit"; }
286
293 std::unique_ptr<NonlinearSolver<Number>> nonlinear_solver;
294
299 std::unique_ptr<DiffSolver> diff_solver;
300
305 unsigned int n_nonlinear_iterations() const { return _n_nonlinear_iterations; }
306
311
318
319 virtual void create_static_condensation() override;
320
321protected:
322
327
333
338};
339
340} // namespace libMesh
341
342#endif // LIBMESH_NONLINEAR_IMPLICIT_SYSTEM_H
This is the EquationSystems class.
Manages consistently variables, degrees of freedom, coefficient vectors, and matrices for implicit sy...
Abstract base class to be used to calculate the bounds on the degrees of freedom of a nonlinear syste...
virtual void bounds(NumericVector< Number > &XL, NumericVector< Number > &XU, sys_type &S)=0
This function will be called to compute the bounds vector and must be implemented by the user in a de...
Abstract base class to be used to calculate the Jacobian of a nonlinear system.
virtual void jacobian(const NumericVector< Number > &X, SparseMatrix< Number > &J, sys_type &S)=0
Jacobian function.
Abstract base class to be used for applying user modifications to the solution vector and/or Newton u...
virtual void postcheck(const NumericVector< Number > &old_soln, NumericVector< Number > &search_direction, NumericVector< Number > &new_soln, bool &changed_search_direction, bool &changed_new_soln, sys_type &S)=0
This interface, which is inspired by PETSc's, passes the user: .) A constant reference to the "old" s...
Abstract base class to be used for applying user modifications to the Newton search direction \emph b...
virtual void precheck(const NumericVector< Number > &precheck_soln, NumericVector< Number > &search_direction, bool &changed, sys_type &S)=0
Abstract precheck method that users must override.
Abstract base class to be used to calculate the residual of a nonlinear system.
virtual void residual(const NumericVector< Number > &X, NumericVector< Number > &R, sys_type &S)=0
Residual function.
Abstract base class to be used to calculate the residual and Jacobian simultaneously of a nonlinear s...
virtual void residual_and_jacobian(const NumericVector< Number > &X, NumericVector< Number > *R, SparseMatrix< Number > *J, sys_type &S)=0
Residual & Jacobian function, calculated simultaneously.
Callable abstract base class to be used as a callback to provide the solver with a basis for the syst...
virtual void operator()(std::vector< NumericVector< Number > * > &sp, sys_type &s)=0
This function will be called to compute the subspace basis (e.g., nullspace or nearnullspace).
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and non-linear solv...
NonlinearImplicitSystem(const NonlinearImplicitSystem &)=delete
Special functions.
NonlinearImplicitSystem sys_type
The type of system.
void set_solver_parameters()
Copies system parameters into nonlinear solver parameters.
virtual void solve() override
Assembles & solves the nonlinear system R(x) = 0.
virtual std::pair< unsigned int, Real > get_linear_solve_parameters() const override
virtual void reinit() override
Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be use...
unsigned get_current_nonlinear_iteration_number() const
If called during the solve(), for example by the user-specified residual or Jacobian function,...
virtual std::string system_type() const override
unsigned int _n_nonlinear_iterations
The number of nonlinear iterations required to solve the nonlinear system R(x)=0.
virtual void assembly(bool get_residual, bool get_jacobian, bool apply_heterogeneous_constraints=false, bool apply_no_constraints=false) override
Assembles a residual in rhs and/or a jacobian in matrix, as requested.
std::unique_ptr< NonlinearSolver< Number > > nonlinear_solver
The NonlinearSolver defines the default interface used to solve the nonlinear_implicit system.
NonlinearImplicitSystem(NonlinearImplicitSystem &&)=default
std::unique_ptr< DiffSolver > diff_solver
The DiffSolver defines an optional interface used to solve the nonlinear_implicit system.
NonlinearImplicitSystem & operator=(const NonlinearImplicitSystem &)=delete
Real _final_nonlinear_residual
The final residual for the nonlinear system R(x)
ImplicitSystem Parent
The type of the parent.
virtual void create_static_condensation() override
Request that static condensation be performed for this system.
virtual void clear() override
Clear all the data structures associated with the system.
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
Generic sparse matrix.
const std::string & name() const
Definition system.h:2385
unsigned int number() const
Definition system.h:2393
The libMesh namespace provides an interface to certain functionality in the library.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real