libMesh
linear_implicit_system.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2024 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_LINEAR_IMPLICIT_SYSTEM_H
21 #define LIBMESH_LINEAR_IMPLICIT_SYSTEM_H
22 
23 // Local Includes
24 #include "libmesh/implicit_system.h"
25 
26 // C++ includes
27 #include <cstddef>
28 
29 namespace libMesh
30 {
31 
32 
33 // Forward Declarations
34 template <typename T> class LinearSolver;
35 template <typename T> class ShellMatrix;
36 
37 
56 {
57 public:
58 
63  const std::string & name,
64  const unsigned int number);
65 
71  LinearImplicitSystem (const LinearImplicitSystem &) = delete;
75  virtual ~LinearImplicitSystem ();
76 
81 
86 
90  sys_type & system () { return *this; }
91 
96  virtual void clear () override;
97 
101  virtual void init_data () override;
102 
107  virtual void reinit () override;
108 
115  virtual void assemble () override { ImplicitSystem::assemble(); }
116 
122  virtual void restrict_solve_to (const SystemSubset * subset,
123  const SubsetSolveMode subset_solve_mode=SUBSET_ZERO) override;
124 
128  virtual void solve () override;
129 
134  virtual LinearSolver<Number> * get_linear_solver() const override;
135 
140  virtual void assembly(bool get_residual,
141  bool get_jacobian,
142  bool apply_heterogeneous_constraints = false,
143  bool apply_no_constraints = false) override;
144 
149  virtual std::string system_type () const override { return "LinearImplicit"; }
150 
155  unsigned int n_linear_iterations() const { return _n_linear_iterations; }
156 
161 
171  void attach_shell_matrix (ShellMatrix<Number> * shell_matrix);
172 
177 
183 
184 protected:
185 
190  unsigned int _n_linear_iterations;
191 
196 
201 
206 
212 };
213 
214 } // namespace libMesh
215 
216 #endif // LIBMESH_LINEAR_IMPLICIT_SYSTEM_H
virtual void restrict_solve_to(const SystemSubset *subset, const SubsetSolveMode subset_solve_mode=SUBSET_ZERO) override
After calling this method, any solve will be limited to the given subset.
ShellMatrix< Number > * get_shell_matrix()
void attach_shell_matrix(ShellMatrix< Number > *shell_matrix)
This function enables the user to provide a shell matrix, i.e.
virtual void assemble() override
Prepares matrix and _dof_map for matrix assembly.
This is the EquationSystems class.
ShellMatrix< Number > * _shell_matrix
User supplies shell matrix or nullptr if no shell matrix is used.
unsigned int _n_linear_iterations
The number of linear iterations required to solve the linear system Ax=b.
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
LinearImplicitSystem(EquationSystems &es, const std::string &name, const unsigned int number)
Constructor.
virtual void reinit() override
Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be use...
SubsetSolveMode _subset_solve_mode
If restrict-solve-to-subset mode is active, this member decides what happens with the dofs outside th...
virtual std::string system_type() const override
virtual LinearSolver< Number > * get_linear_solver() const override
The libMesh namespace provides an interface to certain functionality in the library.
virtual void solve() override
Assembles & solves the linear system A*x=b.
unsigned int number() const
Definition: system.h:2269
virtual void init_data() override
Initializes new data members of the system.
unsigned int n_linear_iterations() const
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.
This is a base class for classes which represent subsets of the dofs of a System. ...
Definition: system_subset.h:42
ImplicitSystem Parent
The type of the parent.
Real _final_linear_residual
The final residual for the linear system Ax=b.
LinearImplicitSystem sys_type
The type of system.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
LinearImplicitSystem & operator=(const LinearImplicitSystem &)=delete
virtual void clear() override
Clear all the data structures associated with the system.
void detach_shell_matrix()
Detaches a shell matrix.
virtual void assemble() override
Prepares matrix and rhs for system assembly, then calls user assembly function.
const SystemSubset * _subset
The current subset on which to solve (or nullptr if none).
const std::string & name() const
Definition: system.h:2261
SubsetSolveMode
defines an enum for the question what happens to the dofs outside the given subset when a system is s...
Manages consistently variables, degrees of freedom, and coefficient vectors for explicit systems...
Manages consistently variables, degrees of freedom, coefficient vectors, and matrices for implicit sy...