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/variable.h" 35 #include "libmesh/enum_matrix_build_type.h" 41 #include <string_view> 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 59 class EquationSystems;
63 template <
typename Output>
class FunctionBase;
64 class ParameterVector;
66 class SensitivityData;
68 template <
typename T>
class NumericVector;
69 template <
typename T>
class SparseMatrix;
70 template <
typename T>
class VectorValue;
106 const std::string &
name,
107 const unsigned int number);
209 virtual ~QOI () =
default;
216 virtual void qoi (
const QoISet & qoi_indices) = 0;
241 bool include_liftfunc,
242 bool apply_constraints) = 0;
259 virtual void clear ();
320 bool include_liftfunc =
true,
321 bool apply_constraints =
true);
358 virtual std::pair<unsigned int, Real>
371 virtual std::pair<unsigned int, Real>
385 virtual std::pair<unsigned int, Real>
402 virtual std::pair<unsigned int, Real>
495 const Real threshold,
496 const bool verbose)
const;
501 const std::string &
name ()
const;
539 const std::string & sys_name,
540 const std::string & unknown_name);
543 const std::string & sys_name,
544 const std::string & unknown_name);
563 int is_adjoint = -1)
const;
579 int is_adjoint = -1)
const;
596 int is_adjoint = -1)
const;
611 const std::vector<unsigned int> & variables,
628 const std::vector<unsigned int> & variables,
649 const std::vector<unsigned int> & variables,
653 int is_adjoint = -1)
const;
671 const std::vector<unsigned int> & variables,
676 int is_adjoint = -1)
const;
681 unsigned int number ()
const;
757 typedef std::map<std::string, std::unique_ptr<NumericVector<Number>>, std::less<>>::iterator
vectors_iterator;
758 typedef std::map<std::string, std::unique_ptr<NumericVector<Number>>, std::less<>>::const_iterator
const_vectors_iterator;
783 typedef std::map<std::string, std::unique_ptr<SparseMatrix<Number>>, std::less<>>::iterator
matrices_iterator;
825 const bool projections=
true,
845 bool have_vector (std::string_view vec_name)
const;
905 const std::string &
vector_name (
const unsigned int vec_num)
const;
1086 unsigned int n_vars()
const;
1139 const std::set<subdomain_id_type> *
const active_subdomains =
nullptr);
1151 const std::set<subdomain_id_type> *
const active_subdomains =
nullptr);
1161 unsigned int add_variables (
const std::vector<std::string> & vars,
1163 const std::set<subdomain_id_type> *
const active_subdomains =
nullptr);
1172 unsigned int add_variables (
const std::vector<std::string> & vars,
1175 const std::set<subdomain_id_type> *
const active_subdomains =
nullptr);
1195 const std::string &
variable_name(
const unsigned int i)
const;
1220 unsigned int component)
const;
1233 unsigned int component)
const;
1264 std::set<unsigned int> * skip_dimensions=
nullptr)
const;
1272 std::set<unsigned int> * skip_dimensions=
nullptr)
const;
1278 std::string_view version,
1280 const bool read_additional_data=
true,
1281 const bool read_legacy_format=
false);
1290 #ifdef LIBMESH_ENABLE_DEPRECATED 1292 const bool read_additional_data=
true);
1299 template <
typename ValType>
1301 const bool read_additional_data=
true);
1309 const bool read_additional_data=
true)
1310 { read_serialized_data<Number>(io, read_additional_data); }
1317 template <
typename InValType>
1330 {
return read_serialized_vectors<Number>(io, vectors); }
1338 template <
typename InValType>
1340 const bool read_additional_data);
1351 const bool read_additional_data)
1352 { read_parallel_data<Number>(io, read_additional_data); }
1358 std::string_view version,
1359 const bool write_additional_data)
const;
1366 const bool write_additional_data =
true)
const;
1383 const bool write_additional_data)
const;
1395 const std::string &
name));
1409 const std::string &
name));
1421 const std::string &
name));
1449 const std::string &
name,
1450 const QoISet & qoi_indices));
1464 const std::string &
name,
1465 const QoISet & qoi_indices,
1466 bool include_liftfunc,
1467 bool apply_constraints));
1505 bool include_liftfunc =
true,
1506 bool apply_constraints =
true);
1620 unsigned int n_qois()
const;
1622 #ifndef LIBMESH_ENABLE_DEPRECATED // We use accessors for these now 1640 #ifndef LIBMESH_ENABLE_DEPRECATED 1652 void set_qoi(std::vector<Number> new_qoi);
1684 const bool insist_on_success =
true,
1720 const bool insist_on_success =
true,
1751 const bool insist_on_success =
true,
1784 std::set<dof_id_type> & var_indices)
const;
1812 #ifdef LIBMESH_HAVE_METAPHYSICL 1824 #endif // LIBMESH_HAVE_METAPHYSICL 1862 template <
template <
typename>
class>
1985 int is_adjoint = -1)
const;
1997 int is_adjoint = -1)
const;
2008 int is_adjoint = -1)
const;
2039 template <
typename iterator_type,
typename InValType>
2041 const iterator_type begin,
2042 const iterator_type end,
2043 const InValType dummy,
2068 template <
typename InValType>
2082 {
return read_serialized_vector<Number>(io, &vec); }
2090 template <
typename iterator_type>
2093 const iterator_type begin,
2094 const iterator_type end,
2104 const unsigned int var,
2120 const std::string &
name);
2131 const std::string &
name);
2142 const std::string &
name);
2153 const std::string &
name,
2154 const QoISet & qoi_indices);
2165 const std::string &
name,
2166 const QoISet & qoi_indices,
2167 bool include_liftfunc,
2168 bool apply_constraints);
2230 std::map<std::string, std::unique_ptr<NumericVector<Number>>, std::less<>>
_vectors;
2247 std::map<std::string, std::unique_ptr<SparseMatrix<Number>>, std::less<>>
_matrices;
2432 return cast_int<unsigned int>(
_variables.size());
2490 unsigned int component)
const 2500 unsigned int component)
const 2502 return _variables[var_num].first_scalar_number() + component;
2560 return cast_int<unsigned int>(
_vectors.size());
2614 libmesh_not_implemented();
2623 #ifndef LIBMESH_ENABLE_DEPRECATED 2627 return cast_int<unsigned int>(this->
qoi.size());
2631 std::pair<unsigned int, Real>
2634 libmesh_not_implemented();
2638 std::pair<unsigned int, Real>
2642 libmesh_not_implemented();
2646 std::pair<unsigned int, Real>
2649 libmesh_not_implemented();
2653 std::pair<unsigned int, Real>
2658 libmesh_not_implemented();
2667 libmesh_not_implemented();
2676 libmesh_not_implemented();
2685 libmesh_not_implemented();
2695 libmesh_not_implemented();
2701 return cast_int<unsigned int>(
_matrices.size());
2704 template <
template <
typename>
class MatrixType>
2711 auto it = this->
_matrices.find(mat_name);
2716 auto pr =
_matrices.emplace(mat_name, std::make_unique<MatrixType<Number>>(this->comm()));
2730 libmesh_error_msg_if(
2732 "System::prefer_hash_table_matrix_assembly() should be called before matrices are initialized");
2738 #endif // LIBMESH_SYSTEM_H 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...
matrices_iterator matrices_begin()
Beginning of matrices container.
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
std::size_t read_serialized_vectors(Xdr &io, const std::vector< NumericVector< Number > *> &vectors) const
Non-templated version for backward compatibility.
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 variable var to the list of variables for this system.
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> >::iterator vectors_iterator
Vector iterator typedefs.
vectors_iterator vectors_end()
End of vectors container.
bool is_initialized() const
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
bool can_add_matrices() 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 ...
void write_serialized_data(Xdr &io, const bool write_additional_data=true) const
Writes additional data, namely vectors, for this System.
This is the EquationSystems class.
unsigned int variable_scalar_number(std::string_view var, unsigned int component) const
static unsigned int n_objects()
Prints the number of outstanding (created, but not yet destroyed) objects.
virtual void clear()
Clear all the data structures associated with the system.
Order
defines an enum for polynomial orders.
void read_parallel_data(Xdr &io, const bool read_additional_data)
Non-templated version for backward compatibility.
virtual void create_static_condensation()
Request that static condensation be performed for this system.
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.
Abstract base class to be used for system initialization.
void write_parallel_data(Xdr &io, const bool write_additional_data) const
Writes additional data, namely vectors, for this System.
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Assembly * _assemble_system_object
Object that assembles the system.
Gradient point_gradient(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
bool _basic_system_only
Holds true if the components of more advanced system types (e.g.
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
virtual void init_matrices()
Initializes the matrices associated with this system.
bool _is_initialized
true when additional vectors and variables do not require immediate initialization, false otherwise.
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Function to impose constraints.
void set_adjoint_already_solved(bool setting)
Setter for the adjoint_already_solved boolean.
This class provides the ability to map between arbitrary, user-defined strings and several data types...
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) const
Projects arbitrary boundary functions onto a vector of degree of freedom values for the current syste...
NumericVector< Number > & add_adjoint_solution(unsigned int i=0)
virtual bool condense_constrained_dofs() const
Whether this object should condense out constrained degrees of freedom.
virtual void forward_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector ¶meters, SensitivityData &sensitivities)
Solves for parameter sensitivities using the forward method.
Data structure for specifying which Parameters should be independent variables in a parameter sensiti...
virtual void assemble_residual_derivatives(const ParameterVector ¶meters)
Calls residual parameter derivative function.
void write_header(Xdr &io, std::string_view version, const bool write_additional_data) const
Writes the basic data header for this System.
Data structure for specifying which Quantities of Interest should be calculated in an adjoint or a pa...
Number get_qoi_value(unsigned int qoi_index) const
virtual void reinit()
Reinitializes degrees of freedom and other required data on the current mesh.
unsigned int n_qois() const
Number of currently active quantities of interest.
unsigned int n_components() const
virtual void disable_cache()
Avoids use of any cached data that might affect any solve result.
int extra_quadrature_order
A member int that can be employed to indicate increased or reduced quadrature order.
virtual void initialize()=0
Initialization function.
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.
NumericVector< Number > & get_sensitivity_solution(unsigned int i=0)
void read_serialized_data(Xdr &io, const bool read_additional_data=true)
Non-templated version for backward compatibility.
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.
const unsigned int _sys_number
The number associated with 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.
NumericVector< Number > & get_sensitivity_rhs(unsigned int i=0)
int vector_is_adjoint(std::string_view vec_name) const
virtual void assemble()=0
Assembly function.
Constraint * _constrain_system_object
Object that constrains the system.
const EquationSystems & get_equation_systems() const
unsigned int n_variable_groups() const
virtual void assemble()
Prepares matrix and _dof_map for matrix assembly.
void projection_matrix(SparseMatrix< Number > &proj_mat) const
This method creates a projection matrix which corresponds to the operation of project_vector between ...
virtual void init_data()
Initializes the data for the system.
This is the base class from which all geometric element types are derived.
FEMNormType
defines an enum for norms defined on vectors of finite element coefficients
void init_qois(unsigned int n_qois)
Accessors for qoi and qoi_error_estimates vectors.
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> >::iterator matrices_iterator
Matrix iterator typedefs.
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
virtual void user_initialization()
Calls user's attached initialization function, or is overridden by the user in derived classes...
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
bool _active
Flag stating if the system is active or not.
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.
std::vector< Variable > _variables
The Variable in 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...
This class defines a norm/seminorm to be applied to a NumericVector which contains coefficients in a ...
NumericVector< Number > & add_sensitivity_rhs(unsigned int i=0)
void read_legacy_data(Xdr &io, const bool read_additional_data=true)
Reads additional data, namely vectors, for this System.
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
bool has_static_condensation() const
The libMesh namespace provides an interface to certain functionality in the library.
vectors_iterator vectors_begin()
Beginning of vectors container.
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> >::const_iterator const_matrices_iterator
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...
virtual void adjoint_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector ¶meters, SensitivityData &sensitivities)
Solves for parameter sensitivities using the adjoint method.
dof_id_type n_local_dofs() const
Abstract base class to be used for system assembly.
NumericVector< Number > & add_weighted_sensitivity_solution()
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Function to evaluate quantity of interest.
const SparseMatrix< Number > * request_matrix(std::string_view mat_name) const
System sys_type
The type of system.
Parameters parameters
Parameters for the system. If a parameter is not provided, it should be retrieved from the EquationSy...
void init()
Initializes degrees of freedom on the current mesh.
const MeshBase & get_mesh() const
NumericVector< Number > & get_weighted_sensitivity_solution()
bool adjoint_already_solved
Has the adjoint problem already been solved? If the user sets adjoint_already_solved to true...
dof_id_type n_dofs() const
uint8_t processor_id_type
This is the MeshBase class.
virtual void prolong_vectors()
Prolong vectors after the mesh has refined.
Number current_solution(const dof_id_type global_dof_number) 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...
virtual ~Assembly()=default
Destructor.
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
unsigned int variable_number(std::string_view var) const
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
bool have_matrix(std::string_view mat_name) const
QOIDerivative * _qoi_evaluate_derivative_object
Object to compute derivatives of quantities of interest.
NumericVector< Number > & add_weighted_sensitivity_adjoint_solution(unsigned int i=0)
virtual void qoi_derivative(const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)=0
Quantity of interest derivative function.
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...
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...
void attach_constraint_object(Constraint &constrain)
Register a user object for imposing constraints.
This class handles the numbering of degrees of freedom on a mesh.
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr) const
Projects arbitrary functions onto the current solution.
void attach_init_object(Initialization &init)
Register a user class to use to initialize the system.
void set_basic_system_only()
Sets the system to be "basic only": i.e.
unsigned int first_scalar_number() const
bool has_variable(std::string_view var) const
unsigned int number() const
void remove_vector(std::string_view vec_name)
Removes the additional vector vec_name from this system.
This class defines the notion of a variable in the system.
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, -1 if primal.
Constraint & get_constraint_object()
Return the user object for imposing constraints.
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...
Data structure for holding completed parameter sensitivity calculations.
dof_id_type numeric_index_type
std::vector< Number > qoi
Values of the quantities of interest.
void deactivate()
Deactivates the system.
void remove_matrix(std::string_view mat_name)
Removes the additional matrix mat_name from this system.
unsigned int n_components() const
std::vector< VariableGroup > _variable_groups
The VariableGroup in this System.
std::string prefix() const
This is a base class for classes which represent subsets of the dofs of a System. ...
bool use_fixed_solution
A boolean to be set to true by systems using elem_fixed_solution, for optional use by e...
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.
unsigned int n_vectors() const
Manages consistently variables, degrees of freedom, and coefficient vectors.
void zero_variable(NumericVector< Number > &v, unsigned int var_num) const
Zeroes all dofs in v that correspond to variable number var_num.
System & operator=(const System &)=delete
bool _prefer_hash_table_matrix_assembly
Whether to use hash table matrix assembly if the matrix sub-classes support it.
virtual void add_matrices()
Insertion point for adding matrices in derived classes before init_matrices() is called.
bool has_constraint_object() const
std::string get_info() const
numeric_index_type read_serialized_vector(Xdr &io, NumericVector< Number > *vec)
Reads a vector for this System.
NumberVectorValue Gradient
virtual void qoi(const QoISet &qoi_indices)=0
Quantity of interest function.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
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...
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
bool project_with_constraints
Do we want to apply constraints while projecting vectors ?
bool have_vector(std::string_view vec_name) const
QOI * _qoi_evaluate_object
Object to compute quantities of interest.
virtual std::pair< unsigned int, Real > sensitivity_solve(const ParameterVector ¶meters)
Solves the sensitivity system, for the provided parameters.
Initialization * _init_system_object
Object that initializes the system.
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...
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 ...
bool _hide_output
Are we allowed to write this system to file? If _hide_output is true, then EquationSystems::write wil...
unsigned int _additional_data_written
This flag is used only when reading in a system from file.
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.
const std::string & variable_name(const unsigned int i) const
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Function that initializes the system.
dof_id_type n_active_dofs() const
std::map< std::string, ParallelType, std::less<> > _matrix_types
Holds the types of the matrices.
virtual void restrict_vectors()
Restrict vectors after the mesh has coarsened.
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::size_t read_serialized_vectors(Xdr &io, const std::vector< NumericVector< Number > *> &vectors) const
Read a number of identically distributed vectors.
unsigned int n_matrices() const
This class implements reference counting.
void set_project_with_constraints(bool _project_with_constraints)
An object whose state is distributed along a set of processors.
This class defines a logically grouped set of variables in the system.
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 activate()
Activates the system.
NumericVector< Number > & add_adjoint_rhs(unsigned int i=0)
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.
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...
virtual void reinit_constraints()
Reinitializes the constraints for this system.
bool identify_variable_groups() const
bool is_adjoint_already_solved() const
Accessor for the adjoint_already_solved boolean.
virtual void solve()
Solves the system.
This class implements a C++ interface to the XDR (eXternal Data Representation) format.
virtual void reinit_mesh()
Reinitializes the system with a new mesh.
const NumericVector< Number > * request_vector(std::string_view vec_name) const
EquationSystems & get_equation_systems()
void attach_assemble_object(Assembly &assemble)
Register a user object to use in assembling the system matrix and RHS.
bool _solution_projection
Holds true if the solution vector should be projected onto a changed grid, false if it should be zero...
EquationSystems & _equation_systems
Constant reference to the EquationSystems object used for the simulation.
std::size_t write_serialized_vectors(Xdr &io, const std::vector< const NumericVector< Number > *> &vectors) const
Serialize & write a number of identically distributed vectors.
virtual std::string system_type() const
virtual void constrain()=0
Constraint function.
void read_parallel_data(Xdr &io, const bool read_additional_data)
Reads additional data, namely vectors, for this System.
const std::string & vector_name(const unsigned int vec_num) const
void attach_QOI_object(QOI &qoi)
Register a user object for evaluating the quantities of interest, whose values should be placed in Sy...
void prefer_hash_table_matrix_assembly(bool preference)
Sets whether to use hash table matrix assembly if the matrix sub-classes support it.
virtual ~QOI()=default
Destructor.
virtual void user_assembly()
Calls user's attached assembly function, or is overridden by the user in derived classes.
virtual ~QOIDerivative()=default
Destructor.
virtual void update()
Update the local values to reflect the solution on neighboring processors.
const FEType & variable_type(const unsigned int i) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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...
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 _identify_variable_groups
true when VariableGroup structures should be automatically identified, false otherwise.
void set_qoi_error_estimate(unsigned int qoi_index, Number qoi_error_estimate)
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...
bool _matrices_initialized
false when additional matrices being added require initialization, true otherwise.
bool _require_sparsity_pattern
Whether any of our matrices require an initial sparsity pattern computation in order to determine pre...
const std::string _sys_name
A name associated with this system.
Tensor point_hessian(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
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...
std::map< std::string, unsigned int, std::less<> > _variable_numbers
The variable numbers corresponding to user-specified names, useful for name-based lookups...
Gradient gptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
NumericVector< Number > & get_adjoint_solution(unsigned int i=0)
virtual void re_update()
Re-update the local values when the mesh has changed.
Abstract base class to be used for system constraints.
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
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)), for those parameters p contained within parameters, weighted by the values w_p found within weights.
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
Projects arbitrary functions onto a vector of degree of freedom values for the current system...
virtual bool compare(const System &other_system, const Real threshold, const bool verbose) const
void set_qoi(unsigned int qoi_index, Number qoi_value)
dof_id_type n_local_constrained_dofs() 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)
Projects arbitrary boundary functions onto a vector of degree of freedom values for the current syste...
bool get_project_with_constraints()
Setter and getter functions for project_with_constraints boolean.
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...
const std::string & name() const
void attach_constraint_function(void fptr(EquationSystems &es, const std::string &name))
Register a user function for imposing constraints.
Gradient(* GradientFunctionPointer)(const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name)
virtual void user_constrain()
Calls user's attached constraint 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...
Number get_qoi_error_estimate_value(unsigned int qoi_index) const
virtual void assemble_qoi(const QoISet &qoi_indices=QoISet())
Calls user qoi function.
NumericVector< Number > & add_sensitivity_solution(unsigned int i=0)
FEFamily
defines an enum for finite element families.
unsigned int n_vars() const
VectorValue< Number > NumberVectorValue
virtual ~Initialization()=default
Destructor.
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Function that assembles the system.
MatrixBuildType
Defines an enum for matrix build types.
void prefix_with_name(bool value)
Instructs this system to prefix solve options with its name for solvers that leverage prefixes...
numeric_index_type read_serialized_vector(Xdr &io, NumericVector< Number > &vec)
Non-templated version for backward compatibility.
bool assemble_before_solve
Flag which tells the system to whether or not to call the user assembly function during each call to ...
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> >::const_iterator const_vectors_iterator
System(EquationSystems &es, const std::string &name, const unsigned int number)
Constructor.
bool vector_preservation(std::string_view vec_name) const
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.
SubsetSolveMode
defines an enum for the question what happens to the dofs outside the given subset when a system is s...
const DofMap & get_dof_map() const
void solve_for_unconstrained_dofs(NumericVector< Number > &, int is_adjoint=-1) const
bool _prefix_with_name
Whether we are name prefixing solver options.
void late_matrix_init(SparseMatrix< Number > &mat, ParallelType type)
Helper function to keep DofMap forward declarable in system.h.
const SparseMatrix< Number > & get_matrix(std::string_view mat_name) const
A Point defines a location in LIBMESH_DIM dimensional Real space.
MeshBase & _mesh
Constant reference to the mesh data structure used for the simulation.
void read_serialized_data(Xdr &io, const bool read_additional_data=true)
Reads additional data, namely vectors, for this System.
matrices_iterator matrices_end()
End of matrices container.
const VariableGroup & variable_group(unsigned int vg) const
Return a constant reference to VariableGroup vg.
void ErrorVector unsigned int
void attach_init_function(void fptr(EquationSystems &es, const std::string &name))
Register a user function to use in initializing the system.
virtual ~Constraint()=default
Destructor.
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...
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.
Abstract base class to be used for quantities of interest.
const NumericVector< Number > & get_vector(std::string_view vec_name) const
NumericVector< Number > & get_weighted_sensitivity_adjoint_solution(unsigned int i=0)
This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space.
dof_id_type n_constrained_dofs() const
std::vector< unsigned int > _written_var_indices
This vector is used only when reading in a system from file.
std::vector< Number > get_qoi_values() const
Returns a copy of qoi, not a reference.
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.
ParallelType
Defines an enum for parallel data structure types.
Abstract base class to be used for derivatives of quantities of interest.
NumericVector< Number > & get_adjoint_rhs(unsigned int i=0)
bool prefix_with_name() const
dof_id_type write_serialized_vector(Xdr &io, const NumericVector< Number > &vec) const
Writes a vector for this System.