libMesh
nonlinear_implicit_system.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2019 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 
55 {
56 public:
57 
63  const std::string & name,
64  const unsigned int number);
65 
69  virtual ~NonlinearImplicitSystem ();
70 
75 
80 
86  {
87  public:
88  virtual ~ComputeResidual () {}
93  virtual void residual (const NumericVector<Number> & X,
95  sys_type & S) = 0;
96  };
97 
98 
104  {
105  public:
106  virtual ~ComputeJacobian () {}
107 
112  virtual void jacobian (const NumericVector<Number> & X,
114  sys_type & S) = 0;
115  };
116 
117 
123  {
124  public:
125  virtual ~ComputeBounds () {}
126 
131  virtual void bounds (NumericVector<Number> & XL,
133  sys_type & S) = 0;
134  };
135 
148  {
149  public:
151 
157  virtual void operator()(std::vector<NumericVector<Number> *> & sp,
158  sys_type & s) = 0;
159  };
160 
166  {
167  public:
169 
175  virtual void residual_and_jacobian (const NumericVector<Number> & X,
178  sys_type & S) = 0;
179  };
180 
188  {
189  public:
190  virtual ~ComputePostCheck () {}
191 
202  virtual void postcheck (const NumericVector<Number> & old_soln,
203  NumericVector<Number> & search_direction,
204  NumericVector<Number> & new_soln,
205  bool & changed_search_direction,
206  bool & changed_new_soln,
207  sys_type & S) = 0;
208  };
209 
213  sys_type & system () { return *this; }
214 
219  virtual void clear () override;
220 
225  virtual void reinit () override;
226 
230  virtual void solve () override;
231 
237  virtual std::pair<unsigned int, Real>
238  get_linear_solve_parameters() const override;
239 
244  virtual void assembly(bool get_residual,
245  bool get_jacobian,
246  bool apply_heterogeneous_constraints = false,
247  bool apply_no_constraints = false) override;
248 
253  virtual std::string system_type () const override { return "NonlinearImplicit"; }
254 
261  std::unique_ptr<NonlinearSolver<Number>> nonlinear_solver;
262 
267  std::unique_ptr<DiffSolver> diff_solver;
268 
273  unsigned int n_nonlinear_iterations() const { return _n_nonlinear_iterations; }
274 
279 
286 
287 
288 protected:
289 
293  void set_solver_parameters();
294 
300 
305 };
306 
307 } // namespace libMesh
308 
309 #endif // LIBMESH_NONLINEAR_IMPLICIT_SYSTEM_H
libMesh::NonlinearImplicitSystem::sys_type
NonlinearImplicitSystem sys_type
The type of system.
Definition: nonlinear_implicit_system.h:74
libMesh::NonlinearImplicitSystem::~NonlinearImplicitSystem
virtual ~NonlinearImplicitSystem()
Destructor.
Definition: nonlinear_implicit_system.C:63
libMesh::NonlinearImplicitSystem::final_nonlinear_residual
Real final_nonlinear_residual() const
Definition: nonlinear_implicit_system.h:278
libMesh::ImplicitSystem
Manages consistently variables, degrees of freedom, coefficient vectors, and matrices for implicit sy...
Definition: implicit_system.h:57
libMesh::NonlinearImplicitSystem::ComputeJacobian::jacobian
virtual void jacobian(const NumericVector< Number > &X, SparseMatrix< Number > &J, sys_type &S)=0
Jacobian function.
libMesh::NonlinearImplicitSystem::_final_nonlinear_residual
Real _final_nonlinear_residual
The final residual for the nonlinear system R(x)
Definition: nonlinear_implicit_system.h:304
libMesh::NonlinearImplicitSystem::reinit
virtual void reinit() override
Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be use...
Definition: nonlinear_implicit_system.C:82
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::NonlinearImplicitSystem::_n_nonlinear_iterations
unsigned int _n_nonlinear_iterations
The number of nonlinear iterations required to solve the nonlinear system R(x)=0.
Definition: nonlinear_implicit_system.h:299
libMesh::NonlinearImplicitSystem::ComputePostCheck::~ComputePostCheck
virtual ~ComputePostCheck()
Definition: nonlinear_implicit_system.h:190
libMesh::NonlinearImplicitSystem::ComputeResidual::residual
virtual void residual(const NumericVector< Number > &X, NumericVector< Number > &R, sys_type &S)=0
Residual function.
libMesh::System::number
unsigned int number() const
Definition: system.h:2075
libMesh::NonlinearImplicitSystem::system_type
virtual std::string system_type() const override
Definition: nonlinear_implicit_system.h:253
libMesh::NonlinearImplicitSystem
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and non-linear solv...
Definition: nonlinear_implicit_system.h:54
libMesh::SparseMatrix< Number >
libMesh::NonlinearImplicitSystem::ComputeBounds
Abstract base class to be used to calculate the bounds on the degrees of freedom of a nonlinear syste...
Definition: nonlinear_implicit_system.h:122
libMesh::NonlinearImplicitSystem::solve
virtual void solve() override
Assembles & solves the nonlinear system R(x) = 0.
Definition: nonlinear_implicit_system.C:161
libMesh::NumericVector< Number >
libMesh::NonlinearImplicitSystem::diff_solver
std::unique_ptr< DiffSolver > diff_solver
The DiffSolver defines an optional interface used to solve the nonlinear_implicit system.
Definition: nonlinear_implicit_system.h:267
libMesh::NonlinearImplicitSystem::set_solver_parameters
void set_solver_parameters()
Copies system parameters into nonlinear solver parameters.
Definition: nonlinear_implicit_system.C:96
libMesh::NonlinearImplicitSystem::ComputeJacobian::~ComputeJacobian
virtual ~ComputeJacobian()
Definition: nonlinear_implicit_system.h:106
libMesh::NonlinearImplicitSystem::ComputeVectorSubspace::operator()
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).
libMesh::NonlinearImplicitSystem::assembly
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.
Definition: nonlinear_implicit_system.C:216
libMesh::NonlinearImplicitSystem::ComputeResidualandJacobian::~ComputeResidualandJacobian
virtual ~ComputeResidualandJacobian()
Definition: nonlinear_implicit_system.h:168
libMesh::NonlinearImplicitSystem::get_linear_solve_parameters
virtual std::pair< unsigned int, Real > get_linear_solve_parameters() const override
Definition: nonlinear_implicit_system.C:205
libMesh::NonlinearImplicitSystem::n_nonlinear_iterations
unsigned int n_nonlinear_iterations() const
Definition: nonlinear_implicit_system.h:273
libMesh::NonlinearImplicitSystem::ComputeBounds::bounds
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...
libMesh::NonlinearImplicitSystem::ComputeVectorSubspace
Callable abstract base class to be used as a callback to provide the solver with a basis for the syst...
Definition: nonlinear_implicit_system.h:147
libMesh::NonlinearImplicitSystem::ComputeResidualandJacobian
Abstract base class to be used to calculate the residual and Jacobian simultaneously of a nonlinear s...
Definition: nonlinear_implicit_system.h:165
libMesh::EquationSystems
This is the EquationSystems class.
Definition: equation_systems.h:74
libMesh::NonlinearImplicitSystem::nonlinear_solver
std::unique_ptr< NonlinearSolver< Number > > nonlinear_solver
The NonlinearSolver defines the default interface used to solve the nonlinear_implicit system.
Definition: nonlinear_implicit_system.h:261
libMesh::ExplicitSystem
Manages consistently variables, degrees of freedom, and coefficient vectors for explicit systems.
Definition: explicit_system.h:48
libMesh::NonlinearImplicitSystem::ComputeVectorSubspace::~ComputeVectorSubspace
virtual ~ComputeVectorSubspace()
Definition: nonlinear_implicit_system.h:150
libMesh::NonlinearImplicitSystem::ComputeBounds::~ComputeBounds
virtual ~ComputeBounds()
Definition: nonlinear_implicit_system.h:125
libMesh::System::name
const std::string & name() const
Definition: system.h:2067
libMesh::NonlinearImplicitSystem::ComputeJacobian
Abstract base class to be used to calculate the Jacobian of a nonlinear system.
Definition: nonlinear_implicit_system.h:103
libMesh::NonlinearImplicitSystem::ComputePostCheck::postcheck
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...
libMesh::NonlinearImplicitSystem::NonlinearImplicitSystem
NonlinearImplicitSystem(EquationSystems &es, const std::string &name, const unsigned int number)
Constructor.
Definition: nonlinear_implicit_system.C:35
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::NonlinearImplicitSystem::get_current_nonlinear_iteration_number
unsigned get_current_nonlinear_iteration_number() const
If called during the solve(), for example by the user-specified residual or Jacobian function,...
Definition: nonlinear_implicit_system.C:287
libMesh::NonlinearImplicitSystem::Parent
ImplicitSystem Parent
The type of the parent.
Definition: nonlinear_implicit_system.h:79
libMesh::NonlinearImplicitSystem::ComputeResidual
Abstract base class to be used to calculate the residual of a nonlinear system.
Definition: nonlinear_implicit_system.h:85
libMesh::NonlinearImplicitSystem::system
sys_type & system()
Definition: nonlinear_implicit_system.h:213
libMesh::NonlinearImplicitSystem::clear
virtual void clear() override
Clear all the data structures associated with the system.
Definition: nonlinear_implicit_system.C:71
libMesh::NonlinearImplicitSystem::ComputeResidual::~ComputeResidual
virtual ~ComputeResidual()
Definition: nonlinear_implicit_system.h:88
libMesh::NonlinearImplicitSystem::ComputePostCheck
Abstract base class to be used for applying user modifications to the solution vector and/or Newton u...
Definition: nonlinear_implicit_system.h:187
libMesh::NonlinearImplicitSystem::ComputeResidualandJacobian::residual_and_jacobian
virtual void residual_and_jacobian(const NumericVector< Number > &X, NumericVector< Number > *R, SparseMatrix< Number > *J, sys_type &S)=0
Residual & Jacobian function, calculated simultaneously.