20#ifndef LIBMESH_SYSTEM_H
21#define LIBMESH_SYSTEM_H
24#include "libmesh/elem_range.h"
25#include "libmesh/enum_subset_solve_mode.h"
26#include "libmesh/enum_parallel_type.h"
27#include "libmesh/fem_function_base.h"
28#include "libmesh/libmesh_common.h"
29#include "libmesh/parallel_object.h"
30#include "libmesh/parameters.h"
31#include "libmesh/qoi_set.h"
32#include "libmesh/reference_counted_object.h"
33#include "libmesh/tensor_value.h"
34#include "libmesh/enum_matrix_build_type.h"
47#if defined(LIBMESH_HAVE_PETSC) || \
48 defined(LIBMESH_HAVE_EIGEN) || \
49 defined(LIBMESH_HAVE_LASPACK) || \
50 defined(LIBMESH_TRILINOS_HAVE_AZTECOO)
51#define LIBMESH_HAVE_SOLVER 1
63template <
typename Output>
class FunctionBase;
68template <
typename T>
class NumericVector;
69template <
typename T>
class SparseMatrix;
70template <
typename T>
class VectorValue;
108 const std::string &
name,
109 const unsigned int number);
243 bool include_liftfunc,
244 bool apply_constraints) = 0;
261 virtual void clear ();
322 bool include_liftfunc =
true,
323 bool apply_constraints =
true);
360 virtual std::pair<unsigned int, Real>
373 virtual std::pair<unsigned int, Real>
387 virtual std::pair<unsigned int, Real>
404 virtual std::pair<unsigned int, Real>
497 const Real threshold,
498 const bool verbose)
const;
503 const std::string &
name ()
const;
525 std::optional<ConstElemRange> active_local_range = std::nullopt,
526 std::optional<std::vector<unsigned int>> variable_numbers = std::nullopt)
const;
541 std::optional<ConstElemRange> active_local_range = std::nullopt,
542 std::optional<std::vector<unsigned int>> variable_numbers = std::nullopt)
const;
553 const std::string & sys_name,
554 const std::string & unknown_name);
557 const std::string & sys_name,
558 const std::string & unknown_name);
562 std::optional<ConstElemRange> active_local_range = std::nullopt,
563 std::optional<std::vector<unsigned int>> variable_numbers = std::nullopt)
const;
584 std::optional<ConstElemRange> active_local_range = std::nullopt,
585 std::optional<std::vector<unsigned int>> variable_numbers = std::nullopt)
const;
606 std::optional<ConstElemRange> active_local_range = std::nullopt,
607 std::optional<std::vector<unsigned int>> variable_numbers = std::nullopt)
const;
629 std::optional<ConstElemRange> active_local_range = std::nullopt,
630 std::optional<std::vector<unsigned int>> variable_numbers = std::nullopt)
const;
647 const std::vector<unsigned int> & variables,
650 std::optional<ConstElemRange> active_local_range = std::nullopt);
667 const std::vector<unsigned int> & variables,
671 std::optional<ConstElemRange> active_local_range = std::nullopt);
691 const std::vector<unsigned int> & variables,
696 std::optional<ConstElemRange> active_local_range = std::nullopt)
const;
716 const std::vector<unsigned int> & variables,
722 std::optional<ConstElemRange> active_local_range = std::nullopt)
const;
727 unsigned int number ()
const;
803 typedef std::map<std::string, std::unique_ptr<NumericVector<Number>>, std::less<>>::iterator
vectors_iterator;
804 typedef std::map<std::string, std::unique_ptr<NumericVector<Number>>, std::less<>>::const_iterator
const_vectors_iterator;
829 typedef std::map<std::string, std::unique_ptr<SparseMatrix<Number>>, std::less<>>::iterator
matrices_iterator;
871 const bool projections=
true,
891 bool have_vector (std::string_view vec_name)
const;
951 const std::string &
vector_name (
const unsigned int vec_num)
const;
1132 unsigned int n_vars()
const;
1185 const std::set<subdomain_id_type> *
const active_subdomains =
nullptr);
1199 const std::set<subdomain_id_type> *
const active_subdomains =
nullptr,
1200 const bool p_refinement =
true);
1210 unsigned int add_variables (
const std::vector<std::string> & vars,
1212 const std::set<subdomain_id_type> *
const active_subdomains =
nullptr);
1234 const std::set<subdomain_id_type> *
const active_subdomains =
nullptr);
1245 unsigned int add_variables (
const std::vector<std::string> & vars,
1248 const std::set<subdomain_id_type> *
const active_subdomains =
nullptr,
1249 const bool p_refinement =
true);
1269 const std::string &
variable_name(
const unsigned int i)
const;
1294 unsigned int component)
const;
1307 unsigned int component)
const;
1338 std::set<unsigned int> * skip_dimensions=
nullptr)
const;
1346 std::set<unsigned int> * skip_dimensions=
nullptr)
const;
1352 std::string_view version,
1354 const bool read_additional_data=
true,
1355 const bool read_legacy_format=
false);
1361 template <
typename ValType>
1363 const bool read_additional_data=
true);
1371 const bool read_additional_data=
true)
1372 { read_serialized_data<Number>(io, read_additional_data); }
1379 template <
typename InValType>
1392 {
return read_serialized_vectors<Number>(io, vectors); }
1400 template <
typename InValType>
1402 const bool read_additional_data);
1413 const bool read_additional_data)
1414 { read_parallel_data<Number>(io, read_additional_data); }
1420 std::string_view version,
1421 const bool write_additional_data)
const;
1428 const bool write_additional_data =
true)
const;
1445 const bool write_additional_data)
const;
1457 const std::string &
name));
1471 const std::string &
name));
1483 const std::string &
name));
1511 const std::string &
name,
1512 const QoISet & qoi_indices));
1526 const std::string &
name,
1527 const QoISet & qoi_indices,
1528 bool include_liftfunc,
1529 bool apply_constraints));
1567 bool include_liftfunc =
true,
1568 bool apply_constraints =
true);
1682 unsigned int n_qois()
const;
1694 void set_qoi(std::vector<Number> new_qoi);
1726 const bool insist_on_success =
true,
1762 const bool insist_on_success =
true,
1793 const bool insist_on_success =
true,
1826 std::set<dof_id_type> & var_indices)
const;
1854#ifdef LIBMESH_HAVE_METAPHYSICL
1904 template <
template <
typename>
class>
2001 int is_adjoint = -1)
const;
2038 int is_adjoint = -1,
2039 std::optional<ConstElemRange> active_local_range = std::nullopt,
2040 std::optional<std::vector<unsigned int>> variable_numbers = std::nullopt)
const;
2052 int is_adjoint = -1,
2053 std::optional<ConstElemRange> active_local_range = std::nullopt,
2054 std::optional<std::vector<unsigned int>> variable_numbers = std::nullopt)
const;
2085 template <
typename iterator_type,
typename InValType>
2087 const iterator_type begin,
2088 const iterator_type end,
2089 const InValType dummy,
2114 template <
typename InValType>
2128 {
return read_serialized_vector<Number>(io, &vec); }
2136 template <
typename iterator_type>
2139 const iterator_type begin,
2140 const iterator_type end,
2150 const unsigned int var,
2166 const std::string &
name);
2177 const std::string &
name);
2188 const std::string &
name);
2199 const std::string &
name,
2200 const QoISet & qoi_indices);
2211 const std::string &
name,
2212 const QoISet & qoi_indices,
2213 bool include_liftfunc,
2214 bool apply_constraints);
2260 std::map<std::string, std::unique_ptr<NumericVector<Number>>, std::less<>>
_vectors;
2277 std::map<std::string, std::unique_ptr<SparseMatrix<Number>>, std::less<>>
_matrices;
2475 unsigned int component)
const
2501 return cast_int<unsigned int>(
_vectors.size());
2555 libmesh_not_implemented();
2564 libmesh_assert_equal_to(this->
_qoi.size(), this->_qoi_error_estimates.size());
2566 return cast_int<unsigned int>(this->
_qoi.size());
2570std::pair<unsigned int, Real>
2573 libmesh_not_implemented();
2577std::pair<unsigned int, Real>
2581 libmesh_not_implemented();
2585std::pair<unsigned int, Real>
2588 libmesh_not_implemented();
2592std::pair<unsigned int, Real>
2597 libmesh_not_implemented();
2606 libmesh_not_implemented();
2615 libmesh_not_implemented();
2624 libmesh_not_implemented();
2634 libmesh_not_implemented();
2640 return cast_int<unsigned int>(
_matrices.size());
2643template <
template <
typename>
class MatrixType>
2650 auto it = this->
_matrices.find(mat_name);
2655 auto pr =
_matrices.emplace(mat_name, std::make_unique<MatrixType<Number>>(this->
comm()));
2669 libmesh_error_msg_if(
2671 "System::prefer_hash_table_matrix_assembly() should be called before matrices are initialized");
void ErrorVector unsigned int
This class handles the numbering of degrees of freedom on a mesh.
This is the base class from which all geometric element types are derived.
This is the EquationSystems class.
FEMFunctionBase is a base class from which users can derive in order to define "function-like" object...
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Base class for functors that can be evaluated at a point and (optionally) time.
This is the MeshBase class.
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
An object whose state is distributed along a set of processors.
const Parallel::Communicator & comm() const
Data structure for specifying which Parameters should be independent variables in a parameter sensiti...
This class provides the ability to map between arbitrary, user-defined strings and several data types...
A Point defines a location in LIBMESH_DIM dimensional Real space.
Data structure for specifying which Quantities of Interest should be calculated in an adjoint or a pa...
This class implements reference counting.
static unsigned int n_objects()
Prints the number of outstanding (created, but not yet destroyed) objects.
Data structure for holding completed parameter sensitivity calculations.
This class defines a norm/seminorm to be applied to a NumericVector which contains coefficients in a ...
This is a base class for classes which represent subsets of the dofs of a System.
Abstract base class to be used for system assembly.
virtual void assemble()=0
Assembly function.
virtual ~Assembly()=default
Destructor.
Abstract base class to be used for system constraints.
virtual ~Constraint()=default
Destructor.
virtual void constrain()=0
Constraint function.
Abstract base class to be used for system initialization.
virtual ~Initialization()=default
Destructor.
virtual void initialize()=0
Initialization function.
Abstract base class to be used for derivatives of quantities of interest.
virtual void qoi_derivative(const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)=0
Quantity of interest derivative function.
virtual ~QOIDerivative()=default
Destructor.
Abstract base class to be used for quantities of interest.
virtual void qoi(const QoISet &qoi_indices)=0
Quantity of interest function.
virtual ~QOI()=default
Destructor.
Manages consistently variables, degrees of freedom, and coefficient vectors.
unsigned int n_vectors() const
std::size_t read_serialized_blocked_dof_objects(const dof_id_type n_objects, const iterator_type begin, const iterator_type end, const InValType dummy, Xdr &io, const std::vector< NumericVector< Number > * > &vecs, const unsigned int var_to_read=libMesh::invalid_uint) const
Reads an input vector from the stream io and assigns the values to a set of DofObjects.
virtual void user_QOI_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
Calls user's attached quantity of interest derivative function, or is overridden by the user in deriv...
Constraint & get_constraint_object()
Return the user object for imposing constraints.
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> >::iterator matrices_iterator
Matrix iterator typedefs.
bool can_add_matrices() const
int extra_quadrature_order
A member int that can be employed to indicate increased or reduced quadrature order.
std::map< std::string, int, std::less<> > _vector_is_adjoint
Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs,...
bool identify_variable_groups() const
bool _is_initialized
true when additional vectors and variables do not require immediate initialization,...
SparseMatrix< Number > & add_matrix(std::string_view mat_name, ParallelType type=PARALLEL, MatrixBuildType mat_build_type=MatrixBuildType::AUTOMATIC)
Adds the additional matrix mat_name to this system.
virtual void assemble_qoi_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
Calls user qoi derivative function.
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Function that initializes the system.
bool _hide_output
Are we allowed to write this system to file? If _hide_output is true, then EquationSystems::write wil...
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Function to impose constraints.
const std::string & name() const
std::size_t read_serialized_vectors(Xdr &io, const std::vector< NumericVector< Number > * > &vectors) const
Read a number of identically distributed vectors.
void attach_assemble_object(Assembly &assemble)
Register a user object to use in assembling the system matrix and RHS.
virtual bool compare(const System &other_system, const Real threshold, const bool verbose) const
void attach_constraint_function(void fptr(EquationSystems &es, const std::string &name))
Register a user function for imposing constraints.
void solve_for_unconstrained_dofs(NumericVector< Number > &, int is_adjoint=-1) const
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> >::const_iterator const_matrices_iterator
virtual std::pair< unsigned int, Real > weighted_sensitivity_solve(const ParameterVector ¶meters, const ParameterVector &weights)
Assembles & solves the linear system(s) (dR/du)*u_w = sum(w_p*-dR/dp), for those parameters p contain...
NumericVector< Number > & add_weighted_sensitivity_adjoint_solution(unsigned int i=0)
virtual void adjoint_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector ¶meters, SensitivityData &sensitivities)
Solves for parameter sensitivities using the adjoint method.
void read_parallel_data(Xdr &io, const bool read_additional_data)
Non-templated version for backward compatibility.
virtual void reinit()
Reinitializes degrees of freedom and other required data on the current mesh.
virtual void assemble_residual_derivatives(const ParameterVector ¶meters)
Calls residual parameter derivative function.
const unsigned int _sys_number
The number associated with this system.
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1, std::optional< ConstElemRange > active_local_range=std::nullopt, std::optional< std::vector< unsigned int > > variable_numbers=std::nullopt) const
Projects arbitrary functions onto a vector of degree of freedom values for the current system.
bool use_fixed_solution
A boolean to be set to true by systems using elem_fixed_solution, for optional use by e....
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, std::optional< ConstElemRange > active_local_range=std::nullopt, std::optional< std::vector< unsigned int > > variable_numbers=std::nullopt) const
Projects arbitrary functions onto the current solution.
Number current_solution(const dof_id_type global_dof_number) const
const SparseMatrix< Number > & get_matrix(std::string_view mat_name) const
virtual void qoi_parameter_hessian_vector_product(const QoISet &qoi_indices, const ParameterVector ¶meters, const ParameterVector &vector, SensitivityData &product)
For each of the system's quantities of interest q in qoi[qoi_indices], and for a vector of parameters...
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Assembly * _assemble_system_object
Object that assembles the system.
virtual void restrict_solve_to(const SystemSubset *subset, const SubsetSolveMode subset_solve_mode=SUBSET_ZERO)
After calling this method, any solve will be restricted to the given subdomain.
void boundary_project_vector(const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1, std::optional< ConstElemRange > active_local_range=std::nullopt) const
Projects arbitrary boundary functions onto a vector of degree of freedom values for the current syste...
std::size_t write_serialized_blocked_dof_objects(const std::vector< const NumericVector< Number > * > &vecs, const dof_id_type n_objects, const iterator_type begin, const iterator_type end, Xdr &io, const unsigned int var_to_write=libMesh::invalid_uint) const
Writes an output vector to the stream io for a set of DofObjects.
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
vectors_iterator vectors_begin()
Beginning of vectors container.
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> >::iterator vectors_iterator
Vector iterator typedefs.
void set_qoi(unsigned int qoi_index, Number qoi_value)
void activate()
Activates the system.
void write_parallel_data(Xdr &io, const bool write_additional_data) const
Writes additional data, namely vectors, for this System.
dof_id_type write_serialized_vector(Xdr &io, const NumericVector< Number > &vec) const
Writes a vector for this System.
void remove_matrix(std::string_view mat_name)
Removes the additional matrix mat_name from this system.
Constraint * _constrain_system_object
Object that constrains the system.
void read_serialized_data(Xdr &io, const bool read_additional_data=true)
Reads additional data, namely vectors, for this System.
void get_all_variable_numbers(std::vector< unsigned int > &all_variable_numbers) const
Fills all_variable_numbers with all the variable numbers for the variables that have been added to th...
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
bool prefix_with_name() const
virtual void user_QOI(const QoISet &qoi_indices)
Calls user's attached quantity of interest function, or is overridden by the user in derived classes.
Real discrete_var_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type) const
Finds the discrete norm for the entries in the vector corresponding to Dofs associated with var.
std::string get_info() const
virtual void disable_cache()
Avoids use of any cached data that might affect any solve result.
bool is_initialized() const
void remove_vector(std::string_view vec_name)
Removes the additional vector vec_name from this system.
NumericVector< Number > & get_weighted_sensitivity_adjoint_solution(unsigned int i=0)
virtual void create_static_condensation()
Request that static condensation be performed for this system.
numeric_index_type read_serialized_vector(Xdr &io, NumericVector< Number > *vec)
Reads a vector for this System.
virtual void qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector ¶meters, SensitivityData &sensitivities)
Solves for the derivative of each of the system's quantities of interest q in qoi[qoi_indices] with r...
dof_id_type n_dofs() const
std::vector< unsigned int > _written_var_indices
This vector is used only when reading in a system from file.
const std::string & vector_name(const unsigned int vec_num) const
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
matrices_iterator matrices_end()
End of matrices container.
const FEType & variable_type(const unsigned int i) const
void boundary_project_solution(const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, std::optional< ConstElemRange > active_local_range=std::nullopt)
Projects arbitrary boundary functions onto a vector of degree of freedom values for the current syste...
virtual void reinit_mesh()
Reinitializes the system with a new mesh.
virtual void prolong_vectors()
Prolong vectors after the mesh has refined.
matrices_iterator matrices_begin()
Beginning of matrices container.
std::vector< Number > _qoi_error_estimates
Vector to hold error estimates for qois, either from a steady state calculation, or from a single uns...
void prefix_with_name(bool value)
Instructs this system to prefix solve options with its name for solvers that leverage prefixes.
virtual void user_initialization()
Calls user's attached initialization function, or is overridden by the user in derived classes.
unsigned int read_SCALAR_dofs(const unsigned int var, Xdr &io, NumericVector< Number > *vec) const
Reads the SCALAR dofs from the stream io and assigns the values to the appropriate entries of vec.
void attach_assemble_function(void fptr(EquationSystems &es, const std::string &name))
Register a user function to use in assembling the system matrix and RHS.
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> >::const_iterator const_vectors_iterator
void attach_QOI_function(void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices))
Register a user function for evaluating the quantities of interest, whose values should be placed in ...
NumericVector< Number > & add_sensitivity_rhs(unsigned int i=0)
void write_header(Xdr &io, std::string_view version, const bool write_additional_data) const
Writes the basic data header for this System.
QOI * _qoi_evaluate_object
Object to compute quantities of interest.
Number(* ValueFunctionPointer)(const Point &p, const Parameters &Parameters, const std::string &sys_name, const std::string &unknown_name)
Projects arbitrary functions onto the current solution.
bool has_constraint_object() const
bool get_project_with_constraints()
Setter and getter functions for project_with_constraints boolean.
void attach_init_function(void fptr(EquationSystems &es, const std::string &name))
Register a user function to use in initializing the system.
int vector_is_adjoint(std::string_view vec_name) const
bool _basic_system_only
Holds true if the components of more advanced system types (e.g.
MeshBase & _mesh
Constant reference to the mesh data structure used for the simulation.
bool assemble_before_solve
Flag which tells the system to whether or not to call the user assembly function during each call to ...
void set_vector_as_adjoint(const std::string &vec_name, int qoi_num)
Allows one to set the QoI index controlling whether the vector identified by vec_name represents a so...
virtual std::pair< unsigned int, Real > adjoint_solve(const QoISet &qoi_indices=QoISet())
Solves the adjoint system, for the specified qoi indices, or for every qoi if qoi_indices is nullptr.
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
bool _solution_projection
Holds true if the solution vector should be projected onto a changed grid, false if it should be zero...
unsigned int add_variable_array(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds variables vars to the list of variables for this system.
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
void set_vector_preservation(const std::string &vec_name, bool preserve)
Allows one to set the boolean controlling whether the vector identified by vec_name should be "preser...
const NumericVector< Number > * request_vector(std::string_view vec_name) const
void local_dof_indices(const unsigned int var, std::set< dof_id_type > &var_indices) const
Fills the std::set with the degrees of freedom on the local processor corresponding the the variable ...
System & operator=(const System &)=delete
virtual void restrict_vectors()
Restrict vectors after the mesh has coarsened.
virtual void user_assembly()
Calls user's attached assembly function, or is overridden by the user in derived classes.
unsigned int n_matrices() const
virtual std::pair< unsigned int, Real > weighted_sensitivity_adjoint_solve(const ParameterVector ¶meters, const ParameterVector &weights, const QoISet &qoi_indices=QoISet())
Assembles & solves the linear system(s) (dR/du)^T*z_w = sum(w_p*(d^2q/dudp - d^2R/dudp*z)),...
virtual void assemble()
Prepares matrix and _dof_map for matrix assembly.
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Function to evaluate quantity of interest.
bool _prefer_hash_table_matrix_assembly
Whether to use hash table matrix assembly if the matrix sub-classes support it.
QOIDerivative * _qoi_evaluate_derivative_object
Object to compute derivatives of quantities of interest.
Initialization * _init_system_object
Object that initializes the system.
EquationSystems & get_equation_systems()
dof_id_type n_active_dofs() const
dof_id_type n_local_dofs() const
virtual std::string system_type() const
void zero_variable(NumericVector< Number > &v, unsigned int var_num) const
Zeroes all dofs in v that correspond to variable number var_num.
dof_id_type n_constrained_dofs() const
Number get_qoi_value(unsigned int qoi_index) const
unsigned int n_components() const
std::vector< Number > get_qoi_values() const
Returns a copy of qoi, not a reference.
System sys_type
The type of system.
std::size_t write_serialized_vectors(Xdr &io, const std::vector< const NumericVector< Number > * > &vectors) const
Serialize & write a number of identically distributed vectors.
NumericVector< Number > & add_sensitivity_solution(unsigned int i=0)
void init_qois(unsigned int n_qois)
Accessors for qoi and qoi_error_estimates vectors.
virtual void clear()
Clear all the data structures associated with the system.
vectors_iterator vectors_end()
End of vectors container.
std::map< std::string, bool, std::less<> > _vector_projections
Holds true if a vector by that name should be projected onto a changed grid, false if it should be ze...
virtual void user_constrain()
Calls user's attached constraint function, or is overridden by the user in derived classes.
void set_adjoint_already_solved(bool setting)
Setter for the adjoint_already_solved boolean.
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
NumericVector< Number > & get_sensitivity_solution(unsigned int i=0)
virtual void add_matrices()
Insertion point for adding matrices in derived classes before init_matrices() is called.
virtual void qoi_parameter_hessian(const QoISet &qoi_indices, const ParameterVector ¶meters, SensitivityData &hessian)
For each of the system's quantities of interest q in qoi[qoi_indices], and for a vector of parameters...
virtual void re_update()
Re-update the local values when the mesh has changed.
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc... and degrees of freedom.
EquationSystems & _equation_systems
Constant reference to the EquationSystems object used for the simulation.
bool have_matrix(std::string_view mat_name) const
void deactivate()
Deactivates the system.
void init()
Initializes degrees of freedom on the current mesh.
virtual std::pair< unsigned int, Real > sensitivity_solve(const ParameterVector ¶meters)
Solves the sensitivity system, for the provided parameters.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
virtual void init_matrices()
Initializes the matrices associated with this system.
void prefer_hash_table_matrix_assembly(bool preference)
Sets whether to use hash table matrix assembly if the matrix sub-classes support it.
const VariableGroup & variable_group(unsigned int vg) const
Return a constant reference to VariableGroup vg.
const std::string _sys_name
A name associated with this system.
Gradient(* GradientFunctionPointer)(const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name)
Tensor point_hessian(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
virtual void init_data()
Initializes the data for the system.
bool _matrices_initialized
false when additional matrices being added require initialization, true otherwise.
bool & project_solution_on_reinit(void)
Tells the System whether or not to project the solution vector onto new grids when the system is rein...
const std::string & variable_name(const unsigned int i) const
void attach_init_object(Initialization &init)
Register a user class to use to initialize the system.
unsigned int n_qois() const
Number of currently active quantities of interest.
virtual void solve()
Solves the system.
NumericVector< Number > & get_sensitivity_rhs(unsigned int i=0)
virtual bool condense_constrained_dofs() const
Whether this object should condense out constrained degrees of freedom.
System(System &&)=default
virtual void forward_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector ¶meters, SensitivityData &sensitivities)
Solves for parameter sensitivities using the forward method.
NumericVector< Number > & add_adjoint_rhs(unsigned int i=0)
void set_basic_system_only()
Sets the system to be "basic only": i.e.
NumericVector< Number > & add_adjoint_solution(unsigned int i=0)
virtual void assemble_qoi(const QoISet &qoi_indices=QoISet())
Calls user qoi function.
unsigned int variable_scalar_number(std::string_view var, unsigned int component) const
bool vector_preservation(std::string_view vec_name) const
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Function that assembles the system.
virtual void update()
Update the local values to reflect the solution on neighboring processors.
std::vector< Number > _qoi
Values of the quantities of interest.
unsigned int variable_number(std::string_view var) const
unsigned int n_variable_groups() const
unsigned int add_variables(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variables vars to the list of variables for this system.
bool has_static_condensation() const
System(const System &)=delete
Special functions.
void set_qoi_error_estimate(unsigned int qoi_index, Number qoi_error_estimate)
dof_id_type n_local_constrained_dofs() const
void projection_matrix(SparseMatrix< Number > &proj_mat) const
This method creates a projection matrix which corresponds to the operation of project_vector between ...
Parameters parameters
Parameters for the system. If a parameter is not provided, it should be retrieved from the EquationSy...
bool is_adjoint_already_solved() const
Accessor for the adjoint_already_solved boolean.
bool has_variable(std::string_view var) const
bool adjoint_already_solved
Has the adjoint problem already been solved? If the user sets adjoint_already_solved to true,...
virtual void reinit_constraints()
Reinitializes the constraints for this system.
Gradient point_gradient(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
void attach_constraint_object(Constraint &constrain)
Register a user object for imposing constraints.
NumericVector< Number > & get_weighted_sensitivity_solution()
void update_global_solution(std::vector< Number > &global_soln) const
Fill the input vector global_soln so that it contains the global solution on all processors.
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
void attach_QOI_object(QOI &qoi)
Register a user object for evaluating the quantities of interest, whose values should be placed in Sy...
bool _require_sparsity_pattern
Whether any of our matrices require an initial sparsity pattern computation in order to determine pre...
void set_project_with_constraints(bool _project_with_constraints)
void read_parallel_data(Xdr &io, const bool read_additional_data)
Reads additional data, namely vectors, for this System.
bool project_with_constraints
Do we want to apply constraints while projecting vectors ?
Number get_qoi_error_estimate_value(unsigned int qoi_index) const
std::string prefix() const
bool _prefix_with_name
Whether we are name prefixing solver options.
NumericVector< Number > & add_weighted_sensitivity_solution()
std::map< std::string, ParallelType, std::less<> > _matrix_types
Holds the types of the matrices.
unsigned int n_vars() const
const DofMap & get_dof_map() const
void attach_QOI_derivative(void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints))
Register a user function for evaluating derivatives of a quantity of interest with respect to test fu...
unsigned int _additional_data_written
This flag is used only when reading in a system from file.
NumericVector< Number > & get_adjoint_solution(unsigned int i=0)
void attach_QOI_derivative_object(QOIDerivative &qoi_derivative)
Register a user object for evaluating derivatives of a quantity of interest with respect to test func...
bool _active
Flag stating if the system is active or not.
void read_header(Xdr &io, std::string_view version, const bool read_header=true, const bool read_additional_data=true, const bool read_legacy_format=false)
Reads the basic data header for this System.
numeric_index_type read_serialized_vector(Xdr &io, NumericVector< Number > &vec)
Non-templated version for backward compatibility.
unsigned int number() const
const EquationSystems & get_equation_systems() const
void late_matrix_init(SparseMatrix< Number > &mat, ParallelType type)
Helper function to keep DofMap forward declarable in system.h.
const NumericVector< Number > & get_vector(std::string_view vec_name) const
unsigned int write_SCALAR_dofs(const NumericVector< Number > &vec, const unsigned int var, Xdr &io) const
Writes the SCALAR dofs associated with var to the stream io.
void(* _qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
Function to evaluate quantity of interest derivative.
bool have_vector(std::string_view vec_name) const
const MeshBase & get_mesh() const
void read_serialized_data(Xdr &io, const bool read_additional_data=true)
Non-templated version for backward compatibility.
void write_serialized_data(Xdr &io, const bool write_additional_data=true) const
Writes additional data, namely vectors, for this System.
std::size_t read_serialized_vectors(Xdr &io, const std::vector< NumericVector< Number > * > &vectors) const
Non-templated version for backward compatibility.
const SparseMatrix< Number > * request_matrix(std::string_view mat_name) const
NumericVector< Number > & get_adjoint_rhs(unsigned int i=0)
This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space.
This class defines a logically grouped set of variables in the system.
This class defines the notion of a variable in the system.
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
This class implements a C++ interface to the XDR (eXternal Data Representation) format.
The libMesh namespace provides an interface to certain functionality in the library.
ParallelType
Defines an enum for parallel data structure types.
SubsetSolveMode
defines an enum for the question what happens to the dofs outside the given subset when a system is s...
NumberVectorValue Gradient
MatrixBuildType
Defines an enum for matrix build types.
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
dof_id_type numeric_index_type
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
uint8_t processor_id_type
VectorValue< Number > NumberVectorValue
Gradient gptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)