libMesh
nonlinear_implicit_system.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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 
28 namespace libMesh
29 {
30 
31 
32 // Forward declarations
33 class DiffSolver;
34 template<typename T> class NonlinearSolver;
35 
36 
50 {
51 public:
52 
58  const std::string & name,
59  const unsigned int number);
60 
64  virtual ~NonlinearImplicitSystem ();
65 
70 
75 
81  {
82  public:
83  virtual ~ComputeResidual () {}
88  virtual void residual (const NumericVector<Number> & X,
90  sys_type & S) = 0;
91  };
92 
93 
99  {
100  public:
101  virtual ~ComputeJacobian () {}
102 
107  virtual void jacobian (const NumericVector<Number> & X,
109  sys_type & S) = 0;
110  };
111 
112 
118  {
119  public:
120  virtual ~ComputeBounds () {}
121 
126  virtual void bounds (NumericVector<Number> & XL,
128  sys_type & S) = 0;
129  };
130 
143  {
144  public:
146 
152  virtual void operator()(std::vector<NumericVector<Number> *> & sp,
153  sys_type & s) = 0;
154  };
155 
161  {
162  public:
164 
170  virtual void residual_and_jacobian (const NumericVector<Number> & X,
173  sys_type & S) = 0;
174  };
175 
183  {
184  public:
185  virtual ~ComputePostCheck () {}
186 
197  virtual void postcheck (const NumericVector<Number> & old_soln,
198  NumericVector<Number> & search_direction,
199  NumericVector<Number> & new_soln,
200  bool & changed_search_direction,
201  bool & changed_new_soln,
202  sys_type & S) = 0;
203  };
204 
208  sys_type & system () { return *this; }
209 
214  virtual void clear () libmesh_override;
215 
220  virtual void reinit () libmesh_override;
221 
225  virtual void solve () libmesh_override;
226 
232  virtual std::pair<unsigned int, Real>
233  get_linear_solve_parameters() const libmesh_override;
234 
239  virtual void assembly(bool get_residual,
240  bool get_jacobian,
241  bool apply_heterogeneous_constraints = false,
242  bool apply_no_constraints = false) libmesh_override;
243 
248  virtual std::string system_type () const libmesh_override { return "NonlinearImplicit"; }
249 
257 
263 
268  unsigned int n_nonlinear_iterations() const { return _n_nonlinear_iterations; }
269 
274 
281 
282 
283 protected:
284 
288  void set_solver_parameters();
289 
295 
300 };
301 
302 } // namespace libMesh
303 
304 #endif // LIBMESH_NONLINEAR_IMPLICIT_SYSTEM_H
void set_solver_parameters()
Copies system parameters into nonlinear solver parameters.
This is the EquationSystems class.
virtual void residual(const NumericVector< Number > &X, NumericVector< Number > &R, sys_type &S)=0
Residual function.
virtual std::string system_type() const libmesh_override
unsigned get_current_nonlinear_iteration_number() const
If called during the solve(), for example by the user-specified residual or Jacobian function...
NonlinearImplicitSystem(EquationSystems &es, const std::string &name, const unsigned int number)
Constructor.
The libMesh namespace provides an interface to certain functionality in the library.
Abstract base class to be used to calculate the bounds on the degrees of freedom of a nonlinear syste...
const std::string & name() const
Definition: system.h:1998
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
Abstract base class to be used to calculate the residual of a nonlinear system.
UniquePtr< NonlinearSolver< Number > > nonlinear_solver
The NonlinearSolver defines the default interface used to solve the nonlinear_implicit system...
Abstract base class to be used to calculate the Jacobian of a nonlinear system.
unsigned int _n_nonlinear_iterations
The number of nonlinear iterations required to solve the nonlinear system R(x)=0. ...
ImplicitSystem Parent
The type of the parent.
Real _final_nonlinear_residual
The final residual for the nonlinear system R(x)
This class provides a specific system class.
virtual void solve() libmesh_override
Assembles & solves the nonlinear system R(x) = 0.
NonlinearImplicitSystem sys_type
The type of system.
Abstract base class to be used to calculate the residual and Jacobian simultaneously of a nonlinear s...
virtual std::pair< unsigned int, Real > get_linear_solve_parameters() const libmesh_override
virtual void reinit() libmesh_override
Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be use...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
unsigned int number() const
Definition: system.h:2006
virtual void assembly(bool get_residual, bool get_jacobian, bool apply_heterogeneous_constraints=false, bool apply_no_constraints=false) libmesh_override
Assembles a residual in rhs and/or a jacobian in matrix, as requested.
virtual void clear() libmesh_override
Clear all the data structures associated with the system.
UniquePtr< DiffSolver > diff_solver
The DiffSolver defines an optional interface used to solve the nonlinear_implicit system...
Abstract base class to be used for applying user modifications to the solution vector and/or Newton u...
Callable abstract base class to be used as a callback to provide the solver with a basis for the syst...
This class provides a specific system class.