libMesh
Loading...
Searching...
No Matches
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_IMPLICIT_SYSTEM_H
21#define LIBMESH_IMPLICIT_SYSTEM_H
22
23// Local Includes
24#include "libmesh/explicit_system.h"
25
26// C++ includes
27#include <cstddef>
28#include <memory>
29
30namespace libMesh
31{
32
33// Forward declarations
34template <typename T> class LinearSolver;
35class StaticCondensation;
36
58{
59public:
60
65 const std::string & name,
66 const unsigned int number);
67
73 ImplicitSystem (const ImplicitSystem &) = delete;
77 virtual ~ImplicitSystem ();
78
83
87 sys_type & system () { return *this; }
88
93
98 virtual void clear () override;
99
105 virtual void assemble () override;
106
111 virtual void disable_cache () override;
112
117 virtual std::string system_type () const override { return "Implicit"; }
118
134 virtual LinearSolver<Number> * get_linear_solver() const;
135
141 virtual std::pair<unsigned int, Real>
143
151 virtual void assembly (bool /* get_residual */,
152 bool /* get_jacobian */,
153 bool /* apply_heterogeneous_constraints */ = false,
154 bool /* apply_no_constraints */ = false)
155 { libmesh_not_implemented(); }
156
168 virtual void assemble_residual_derivatives (const ParameterVector & parameters) override;
169
175 virtual void solve () override
176 { libmesh_not_implemented(); }
177
185 virtual std::pair<unsigned int, Real>
187
196 virtual std::pair<unsigned int, Real>
198 const ParameterVector & weights) override;
199
209 virtual std::pair<unsigned int, Real>
210 adjoint_solve (const QoISet & qoi_indices = QoISet()) override;
211
224 virtual std::pair<unsigned int, Real>
226 const ParameterVector & weights,
227 const QoISet & qoi_indices = QoISet()) override;
228
240 virtual void adjoint_qoi_parameter_sensitivity (const QoISet & qoi_indices,
242 SensitivityData & sensitivities) override;
243
255 virtual void forward_qoi_parameter_sensitivity (const QoISet & qoi_indices,
257 SensitivityData & sensitivities) override;
258
274 virtual void qoi_parameter_hessian(const QoISet & qoi_indices,
276 SensitivityData & hessian) override;
277
288 virtual void qoi_parameter_hessian_vector_product(const QoISet & qoi_indices,
290 const ParameterVector & vector,
291 SensitivityData & product) override;
292
297
302
312
319
328 mutable std::unique_ptr<LinearSolver<Number>> linear_solver;
329
330 virtual void create_static_condensation() override;
331
336
337protected:
341 virtual void add_matrices() override;
342
346 template <typename T>
348
349private:
354
359};
360
361inline
367
368} // namespace libMesh
369
370#endif // LIBMESH_IMPLICIT_SYSTEM_H
This is the EquationSystems class.
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...
virtual void assemble() override
Prepares matrix and rhs for system assembly, then calls user assembly function.
bool zero_out_matrix_and_rhs
By default, the system will zero out the matrix and the right hand side.
virtual std::pair< unsigned int, Real > weighted_sensitivity_solve(const ParameterVector &parameters, const ParameterVector &weights) override
Assembles & solves the linear system(s) (dR/du)*u_w = sum(w_p*-dR/dp), for those parameters p contain...
virtual std::pair< unsigned int, Real > get_linear_solve_parameters() const
const SparseMatrix< Number > & get_system_matrix() const
StaticCondensation * _sc_system_matrix
The system matrix for static condensation problems.
void create_static_condensation_system_matrix()
Create the static condensation system matrix.
ImplicitSystem sys_type
The type of system.
StaticCondensation & get_static_condensation()
virtual LinearSolver< Number > * get_linear_solver() const
virtual void assemble_residual_derivatives(const ParameterVector &parameters) override
Residual parameter derivative function.
SparseMatrix< Number > * matrix
The system matrix.
virtual void clear() override
Clear all the data structures associated with the system.
ExplicitSystem Parent
The type of the parent.
virtual std::string system_type() const override
ImplicitSystem(const ImplicitSystem &)=delete
Special functions.
ImplicitSystem(ImplicitSystem &&)=default
virtual void adjoint_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities) override
Solves for the derivative of each of the system's quantities of interest q in qoi[qoi_indices] with r...
virtual void disable_cache() override
Avoids use of any cached data that might affect any solve result.
virtual void qoi_parameter_hessian_vector_product(const QoISet &qoi_indices, const ParameterVector &parameters, const ParameterVector &vector, SensitivityData &product) override
For each of the system's quantities of interest q in qoi[qoi_indices], and for a vector of parameters...
virtual std::pair< unsigned int, Real > adjoint_solve(const QoISet &qoi_indices=QoISet()) override
Assembles & solves the linear system (dR/du)^T*z = dq/du, for those quantities of interest q specifie...
virtual std::pair< unsigned int, Real > weighted_sensitivity_adjoint_solve(const ParameterVector &parameters, const ParameterVector &weights, const QoISet &qoi_indices=QoISet()) override
Assembles & solves the linear system(s) (dR/du)^T*z_w = sum(w_p*(d^2q/dudp - d^2R/dudp*z)),...
virtual void create_static_condensation() override
Request that static condensation be performed for this system.
virtual std::pair< unsigned int, Real > sensitivity_solve(const ParameterVector &parameters) override
Assembles & solves the linear system(s) (dR/du)*u_p = -dR/dp, for those parameters contained within p...
virtual void qoi_parameter_hessian(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &hessian) override
For each of the system's quantities of interest q in qoi[qoi_indices], and for a vector of parameters...
void setup_static_condensation_preconditioner(T &solver)
Sets up the static condensation preconditioner for the supplied solver.
virtual void assembly(bool, bool, bool=false, bool=false)
Assembles a residual in rhs and/or a jacobian in matrix, as requested.
std::unique_ptr< LinearSolver< Number > > linear_solver
This class handles all the details of interfacing with various linear algebra packages like PETSc or ...
virtual void add_matrices() override
Adds the system matrix.
virtual void solve() override
For explicit systems, just assemble and solve the system A*x=b.
ImplicitSystem & operator=(const ImplicitSystem &)=delete
virtual void forward_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities) override
Solves for the derivative of each of the system's quantities of interest q in qoi[qoi_indices] with r...
This base class can be inherited from to provide interfaces to linear solvers from different packages...
Data structure for specifying which Parameters should be independent variables in a parameter sensiti...
Data structure for specifying which Quantities of Interest should be calculated in an adjoint or a pa...
Definition qoi_set.h:46
Data structure for holding completed parameter sensitivity calculations.
Generic sparse matrix.
const std::string & name() const
Definition system.h:2385
Parameters parameters
Parameters for the system. If a parameter is not provided, it should be retrieved from the EquationSy...
Definition system.h:1588
unsigned int number() const
Definition system.h:2393
The libMesh namespace provides an interface to certain functionality in the library.
libmesh_assert(ctx)