libMesh
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Private Attributes | List of all members
SolidSystem Class Reference

#include <solid_system.h>

Inheritance diagram for SolidSystem:
[legend]

Public Types

typedef FEMSystem sys_type
 The type of system.
 
typedef DifferentiableSystem Parent
 The type of the parent.
 
typedef bool(TimeSolver::* TimeSolverResPtr) (bool, DiffContext &)
 Syntax sugar to make numerical_jacobian() declaration easier.
 
typedef 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.
 
typedef Gradient(* GradientFunctionPointer) (const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name)
 
typedef std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> >::iterator vectors_iterator
 Vector iterator typedefs.
 
typedef std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> >::const_iterator const_vectors_iterator
 
typedef std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> >::iterator matrices_iterator
 Matrix iterator typedefs.
 
typedef std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> >::const_iterator const_matrices_iterator
 

Public Member Functions

 SolidSystem (EquationSystems &es, const std::string &name, const unsigned int number)
 
virtual void init_data ()
 Initializes the member data fields associated with the system, so that, e.g., assemble() may be used.
 
virtual void init_context (DiffContext &context)
 
virtual bool element_time_derivative (bool request_jacobian, DiffContext &context)
 Compute contribution from internal forces in elem_residual and contribution from linearized internal forces (stiffness matrix) in elem_jacobian.
 
virtual bool side_time_derivative (bool request_jacobian, DiffContext &context)
 Adds the time derivative contribution on side of elem to elem_residual.
 
virtual bool eulerian_residual (bool, DiffContext &)
 Adds a pseudo-convection contribution on elem to elem_residual, if the nodes of elem are being translated by a moving mesh.
 
virtual std::string system_type () const
 
virtual void update ()
 Update the local values to reflect the solution on neighboring processors.
 
void save_initial_mesh ()
 
virtual void assembly (bool get_residual, bool get_jacobian, bool apply_heterogeneous_constraints=false, bool apply_no_constraints=false) override
 Prepares matrix or rhs for matrix assembly.
 
virtual void solve () override
 Invokes the solver associated with the system.
 
void mesh_position_get ()
 Tells the FEMSystem to set the degree of freedom coefficients which should correspond to mesh nodal coordinates.
 
void mesh_position_set ()
 Tells the FEMSystem to set the mesh nodal coordinates which should correspond to degree of freedom coefficients.
 
virtual std::unique_ptr< DiffContext > build_context () override
 Builds a FEMContext object with enough information to do evaluations on each element.
 
virtual void postprocess () override
 Runs a postprocessing loop over all elements, and if postprocess_sides is true over all sides.
 
virtual void assemble_qoi (const QoISet &indices=QoISet()) override
 Runs a qoi assembly loop over all elements, and if assemble_qoi_sides is true over all sides.
 
virtual void assemble_qoi_derivative (const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true) override
 Runs a qoi derivative assembly loop over all elements, and if assemble_qoi_sides is true over all sides.
 
Real numerical_jacobian_h_for_var (unsigned int var_num) const
 If numerical_jacobian_h_for_var(var_num) is changed from its default value (numerical_jacobian_h), the FEMSystem will perturb solution vector entries for variable var_num by that amount when calculating finite differences with respect to that variable.
 
void set_numerical_jacobian_h_for_var (unsigned int var_num, Real new_h)
 
void numerical_jacobian (TimeSolverResPtr res, FEMContext &context) const
 Uses the results of multiple res calls to numerically differentiate the corresponding jacobian.
 
void numerical_elem_jacobian (FEMContext &context) const
 Uses the results of multiple element_residual() calls to numerically differentiate the corresponding jacobian on an element.
 
void numerical_side_jacobian (FEMContext &context) const
 Uses the results of multiple side_residual() calls to numerically differentiate the corresponding jacobian on an element's side.
 
void numerical_nonlocal_jacobian (FEMContext &context) const
 Uses the results of multiple side_residual() calls to numerically differentiate the corresponding jacobian on nonlocal DoFs.
 
virtual void clear () override
 Clear all the data structures associated with the system.
 
virtual void reinit () override
 Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be used.
 
virtual void assemble () override
 Prepares matrix and rhs for matrix assembly.
 
virtual LinearSolver< Number > * get_linear_solver () const override
 
virtual std::pair< unsigned int, Real > get_linear_solve_parameters () const override
 
virtual std::pair< unsigned int, Real > adjoint_solve (const QoISet &qoi_indices=QoISet()) override
 This function sets the _is_adjoint boolean member of TimeSolver to true and then calls the adjoint_solve in implicit system.
 
virtual std::unique_ptr< DifferentiablePhysics > clone_physics () override
 We don't allow systems to be attached to each other.
 
virtual std::unique_ptr< DifferentiableQoI > clone () override
 We don't allow systems to be attached to each other.
 
const DifferentiablePhysics * get_physics () const
 
DifferentiablePhysics * get_physics ()
 
void attach_physics (DifferentiablePhysics *physics_in)
 Attach external Physics object.
 
void push_physics (DifferentiablePhysics &new_physics)
 Push a clone of a new physics object onto our stack, overriding the current physics until the new physics is popped off again (or until something else is pushed on top of it).
 
void pop_physics ()
 Pop a physics object off of our stack.
 
const DifferentiableQoI * get_qoi () const
 
DifferentiableQoI * get_qoi ()
 
void attach_qoi (DifferentiableQoI *qoi_in)
 Attach external QoI object.
 
void set_time_solver (std::unique_ptr< TimeSolver > _time_solver)
 Sets the time_solver FIXME: This code is a little dangerous as it transfers ownership from the TimeSolver creator to this class.
 
TimeSolver & get_time_solver ()
 
const TimeSolver & get_time_solver () const
 Non-const version of the above.
 
virtual void element_postprocess (DiffContext &)
 Does any work that needs to be done on elem in a postprocessing loop.
 
virtual void side_postprocess (DiffContext &)
 Does any work that needs to be done on side of elem in a postprocessing loop.
 
unsigned int get_second_order_dot_var (unsigned int var) const
 For a given second order (in time) variable var, this method will return the index to the corresponding "dot" variable.
 
bool have_first_order_scalar_vars () const
 Check for any first order vars that are also belong to FEFamily::SCALAR.
 
bool have_second_order_scalar_vars () const
 Check for any second order vars that are also belong to FEFamily::SCALAR.
 
virtual void set_constrain_in_solver (bool enable)
 set_constrain_in_solver to false to apply constraints only via residual terms in the systems to be solved.
 
virtual bool get_constrain_in_solver ()
 
sys_type & system ()
 
virtual void disable_cache () override
 Avoids use of any cached data that might affect any solve result.
 
virtual void assemble_residual_derivatives (const ParameterVector &parameters) override
 Residual parameter derivative function.
 
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 parameters.
 
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 contained within parameters weighted by the values w_p found within weights.
 
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)), for those parameters p contained within parameters, weighted by the values w_p found within weights.
 
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 respect to each parameter in parameters, placing the result for qoi i and parameter j into sensitivities[i][j].
 
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 respect to each parameter in parameters, placing the result for qoi i and parameter j into sensitivities[i][j].
 
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 p, the parameter sensitivity Hessian H_ij is defined as H_ij = (d^2 q)/(d p_i d p_j) This Hessian is the output of this method, where for each q_i, H_jk is stored in hessian.second_derivative(i,j,k).
 
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 p, the parameter sensitivity Hessian H_ij is defined as H_ij = (d^2 q)/(d p_i d p_j) The Hessian-vector product, for a vector v_k in parameter space, is S_j = H_jk v_k This product is the output of this method, where for each q_i, S_j is stored in sensitivities[i][j].
 
const SparseMatrix< Number > & get_system_matrix () const
 
SparseMatrix< Number > & get_system_matrix ()
 
virtual void create_static_condensation () override
 Request that static condensation be performed for this system.
 
StaticCondensation & get_static_condensation ()
 
void init ()
 Initializes degrees of freedom on the current mesh.
 
virtual void reinit_constraints ()
 Reinitializes the constraints for this system.
 
void reinit_dirichlet_constraint_values ()
 Recomputes the DirichletBoundary constraint values of this system at the current time.
 
virtual void reinit_mesh ()
 Reinitializes the system with a new mesh.
 
bool is_initialized () const
 
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.
 
bool is_adjoint_already_solved () const
 Accessor for the adjoint_already_solved boolean.
 
void set_adjoint_already_solved (bool setting)
 Setter for the adjoint_already_solved boolean.
 
virtual void qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
 Solves for the derivative of each of the system's quantities of interest q in qoi[qoi_indices] with respect to each parameter in parameters, placing the result for qoi i and parameter j into sensitivities[i][j].
 
virtual bool compare (const System &other_system, const Real threshold, const bool verbose) const
 
const std::string & name () const
 
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.
 
void project_solution (FEMFunctionBase< Number > *f, FEMFunctionBase< 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.
 
void project_solution (ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters, std::optional< ConstElemRange > active_local_range=std::nullopt, std::optional< std::vector< unsigned int > > variable_numbers=std::nullopt) const
 This method projects an arbitrary function onto the solution via L2 projections and nodal interpolations on each element.
 
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.
 
void project_vector (NumericVector< Number > &new_vector, FEMFunctionBase< Number > *f, FEMFunctionBase< 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.
 
void project_vector (ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters, NumericVector< Number > &new_vector, 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.
 
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 system.
 
void boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters, std::optional< ConstElemRange > active_local_range=std::nullopt)
 Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system.
 
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 system.
 
void boundary_project_vector (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters, NumericVector< Number > &new_vector, 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 system.
 
unsigned int number () const
 
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.
 
void update_global_solution (std::vector< Number > &global_soln, const processor_id_type dest_proc) const
 Fill the input vector global_soln so that it contains the global solution on processor dest_proc.
 
const MeshBase & get_mesh () const
 
MeshBase & get_mesh ()
 
const DofMap & get_dof_map () const
 
DofMap & get_dof_map ()
 
const EquationSystems & get_equation_systems () const
 
EquationSystems & get_equation_systems ()
 
bool active () const
 
void activate ()
 Activates the system.
 
void deactivate ()
 Deactivates the system.
 
void set_basic_system_only ()
 Sets the system to be "basic only": i.e.
 
vectors_iterator vectors_begin ()
 Beginning of vectors container.
 
const_vectors_iterator vectors_begin () const
 Beginning of vectors container.
 
vectors_iterator vectors_end ()
 End of vectors container.
 
const_vectors_iterator vectors_end () const
 End of vectors container.
 
matrices_iterator matrices_begin ()
 Beginning of matrices container.
 
const_matrices_iterator matrices_begin () const
 Beginning of matrices container.
 
matrices_iterator matrices_end ()
 End of matrices container.
 
const_matrices_iterator matrices_end () const
 End of matrices container.
 
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 remove_vector (std::string_view vec_name)
 Removes the additional vector vec_name from this system.
 
bool & project_solution_on_reinit (void)
 Tells the System whether or not to project the solution vector onto new grids when the system is reinitialized.
 
bool have_vector (std::string_view vec_name) const
 
const NumericVector< Number > * request_vector (std::string_view vec_name) const
 
NumericVector< Number > * request_vector (std::string_view vec_name)
 
const NumericVector< Number > * request_vector (const unsigned int vec_num) const
 
NumericVector< Number > * request_vector (const unsigned int vec_num)
 
const NumericVector< Number > & get_vector (std::string_view vec_name) const
 
NumericVector< Number > & get_vector (std::string_view vec_name)
 
const NumericVector< Number > & get_vector (const unsigned int vec_num) const
 
NumericVector< Number > & get_vector (const unsigned int vec_num)
 
const std::string & vector_name (const unsigned int vec_num) const
 
const std::string & vector_name (const NumericVector< Number > &vec_reference) const
 
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 solution from the adjoint (qoi_num >= 0) or primal (qoi_num == -1) space.
 
int vector_is_adjoint (std::string_view vec_name) const
 
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 "preserved": projected to new meshes, saved, etc.
 
bool vector_preservation (std::string_view vec_name) const
 
NumericVector< Number > & add_adjoint_solution (unsigned int i=0)
 
NumericVector< Number > & get_adjoint_solution (unsigned int i=0)
 
const NumericVector< Number > & get_adjoint_solution (unsigned int i=0) const
 
NumericVector< Number > & add_sensitivity_solution (unsigned int i=0)
 
NumericVector< Number > & get_sensitivity_solution (unsigned int i=0)
 
const NumericVector< Number > & get_sensitivity_solution (unsigned int i=0) const
 
NumericVector< Number > & add_weighted_sensitivity_adjoint_solution (unsigned int i=0)
 
NumericVector< Number > & get_weighted_sensitivity_adjoint_solution (unsigned int i=0)
 
const NumericVector< Number > & get_weighted_sensitivity_adjoint_solution (unsigned int i=0) const
 
NumericVector< Number > & add_weighted_sensitivity_solution ()
 
NumericVector< Number > & get_weighted_sensitivity_solution ()
 
const NumericVector< Number > & get_weighted_sensitivity_solution () const
 
NumericVector< Number > & add_adjoint_rhs (unsigned int i=0)
 
NumericVector< Number > & get_adjoint_rhs (unsigned int i=0)
 
const NumericVector< Number > & get_adjoint_rhs (unsigned int i=0) const
 
NumericVector< Number > & add_sensitivity_rhs (unsigned int i=0)
 
NumericVector< Number > & get_sensitivity_rhs (unsigned int i=0)
 
const NumericVector< Number > & get_sensitivity_rhs (unsigned int i=0) const
 
unsigned int n_vectors () const
 
unsigned int n_matrices () const
 
unsigned int n_vars () const
 
unsigned int n_variable_groups () const
 
unsigned int n_components () const
 
dof_id_type n_dofs () const
 
dof_id_type n_active_dofs () const
 
dof_id_type n_constrained_dofs () const
 
dof_id_type n_local_constrained_dofs () const
 
dof_id_type n_local_dofs () const
 
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.
 
unsigned int add_variable (std::string_view var, const Order order=FIRST, const FEFamily=LAGRANGE, const std::set< subdomain_id_type > *const active_subdomains=nullptr, const bool p_refinement=true)
 Adds the variable var to the list of variables for this system.
 
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.
 
unsigned int add_variables (const std::vector< std::string > &vars, const Order order=FIRST, const FEFamily=LAGRANGE, const std::set< subdomain_id_type > *const active_subdomains=nullptr, const bool p_refinement=true)
 Adds the variable var to the list of variables for this system.
 
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.
 
const Variable & variable (unsigned int var) const
 Return a constant reference to Variable var.
 
const VariableGroup & variable_group (unsigned int vg) const
 Return a constant reference to VariableGroup vg.
 
bool has_variable (std::string_view var) const
 
const std::string & variable_name (const unsigned int i) const
 
unsigned int variable_number (std::string_view var) const
 
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 this system.
 
unsigned int variable_scalar_number (std::string_view var, unsigned int component) const
 
unsigned int variable_scalar_number (unsigned int var_num, unsigned int component) const
 
const FEType & variable_type (const unsigned int i) const
 
const FEType & variable_type (std::string_view var) const
 
bool identify_variable_groups () const
 
void identify_variable_groups (const bool)
 Toggle automatic VariableGroup identification.
 
Real calculate_norm (const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
 
Real calculate_norm (const NumericVector< Number > &v, const SystemNorm &norm, std::set< unsigned int > *skip_dimensions=nullptr) const
 
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.
 
template<typename ValType >
void read_serialized_data (Xdr &io, const bool read_additional_data=true)
 Reads additional data, namely vectors, for this System.
 
void read_serialized_data (Xdr &io, const bool read_additional_data=true)
 Non-templated version for backward compatibility.
 
template<typename InValType >
std::size_t read_serialized_vectors (Xdr &io, const std::vector< NumericVector< Number > * > &vectors) const
 Read a number of identically distributed vectors.
 
std::size_t read_serialized_vectors (Xdr &io, const std::vector< NumericVector< Number > * > &vectors) const
 Non-templated version for backward compatibility.
 
template<typename InValType >
void read_parallel_data (Xdr &io, const bool read_additional_data)
 Reads additional data, namely vectors, for this System.
 
void read_parallel_data (Xdr &io, const bool read_additional_data)
 Non-templated version for backward compatibility.
 
void write_header (Xdr &io, std::string_view version, const bool write_additional_data) const
 Writes the basic data header for this System.
 
void write_serialized_data (Xdr &io, const bool write_additional_data=true) const
 Writes additional data, namely vectors, for this 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.
 
void write_parallel_data (Xdr &io, const bool write_additional_data) const
 Writes additional data, namely vectors, for this System.
 
std::string get_info () const
 
void attach_init_function (void fptr(EquationSystems &es, const std::string &name))
 Register a user function to use in initializing the system.
 
void attach_init_object (Initialization &init)
 Register a user class to use to initialize the system.
 
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.
 
void attach_assemble_object (Assembly &assemble)
 Register a user object to use in assembling the system matrix and RHS.
 
void attach_constraint_function (void fptr(EquationSystems &es, const std::string &name))
 Register a user function for imposing constraints.
 
void attach_constraint_object (Constraint &constrain)
 Register a user object for imposing constraints.
 
bool has_constraint_object () const
 
Constraint & get_constraint_object ()
 Return the user object for imposing constraints.
 
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 System::qoi.
 
void attach_QOI_object (QOI &qoi)
 Register a user object for evaluating the quantities of interest, whose values should be placed in System::qoi.
 
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 functions, whose values should be placed in System::rhs.
 
void attach_QOI_derivative_object (QOIDerivative &qoi_derivative)
 Register a user object for evaluating derivatives of a quantity of interest with respect to test functions, whose values should be placed in System::rhs.
 
virtual void user_initialization ()
 Calls user's attached initialization function, or is overridden by the user in derived classes.
 
virtual void user_assembly ()
 Calls user's attached assembly function, or is overridden by the user in derived classes.
 
virtual void user_constrain ()
 Calls user's attached constraint function, or is overridden by the user in derived classes.
 
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 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 derived classes.
 
virtual void re_update ()
 Re-update the local values when the mesh has changed.
 
virtual void restrict_vectors ()
 Restrict vectors after the mesh has coarsened.
 
virtual void prolong_vectors ()
 Prolong vectors after the mesh has refined.
 
Number current_solution (const dof_id_type global_dof_number) const
 
unsigned int n_qois () const
 Number of currently active quantities of interest.
 
void init_qois (unsigned int n_qois)
 Accessors for qoi and qoi_error_estimates vectors.
 
void set_qoi (unsigned int qoi_index, Number qoi_value)
 
void set_qoi (std::vector< Number > new_qoi)
 
Number get_qoi_value (unsigned int qoi_index) const
 
std::vector< Number > get_qoi_values () const
 Returns a copy of qoi, not a reference.
 
void set_qoi_error_estimate (unsigned int qoi_index, Number qoi_error_estimate)
 
Number get_qoi_error_estimate_value (unsigned int qoi_index) const
 
Number point_value (unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
 
Number point_value (unsigned int var, const Point &p, const Elem &e, const NumericVector< Number > *sol=nullptr) const
 
Number point_value (unsigned int var, const Point &p, const Elem *e) const
 Calls the version of point_value() which takes a reference.
 
Number point_value (unsigned int var, const Point &p, const NumericVector< Number > *sol) const
 Calls the parallel version of point_value().
 
Gradient point_gradient (unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
 
Gradient point_gradient (unsigned int var, const Point &p, const Elem &e, const NumericVector< Number > *sol=nullptr) const
 
Gradient point_gradient (unsigned int var, const Point &p, const Elem *e) const
 Calls the version of point_gradient() which takes a reference.
 
Gradient point_gradient (unsigned int var, const Point &p, const NumericVector< Number > *sol) const
 Calls the parallel version of point_gradient().
 
Tensor point_hessian (unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
 
Tensor point_hessian (unsigned int var, const Point &p, const Elem &e, const NumericVector< Number > *sol=nullptr) const
 
Tensor point_hessian (unsigned int var, const Point &p, const Elem *e) const
 Calls the version of point_hessian() which takes a reference.
 
Tensor point_hessian (unsigned int var, const Point &p, const NumericVector< Number > *sol) const
 Calls the parallel version of point_hessian().
 
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 number passed in.
 
void zero_variable (NumericVector< Number > &v, unsigned int var_num) const
 Zeroes all dofs in v that correspond to variable number var_num.
 
bool get_project_with_constraints ()
 Setter and getter functions for project_with_constraints boolean.
 
void set_project_with_constraints (bool _project_with_constraints)
 
bool & hide_output ()
 
void projection_matrix (SparseMatrix< Number > &proj_mat) const
 This method creates a projection matrix which corresponds to the operation of project_vector between old and new solution spaces.
 
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.
 
template<template< typename > class>
SparseMatrix< Number > & add_matrix (std::string_view mat_name, ParallelType=PARALLEL)
 Adds the additional matrix mat_name to this system.
 
SparseMatrix< Number > & add_matrix (std::string_view mat_name, std::unique_ptr< SparseMatrix< Number > > matrix, ParallelType type=PARALLEL)
 Adds the additional matrix mat_name to this system.
 
void remove_matrix (std::string_view mat_name)
 Removes the additional matrix mat_name from this system.
 
bool have_matrix (std::string_view mat_name) const
 
const SparseMatrix< Number > * request_matrix (std::string_view mat_name) const
 
SparseMatrix< Number > * request_matrix (std::string_view mat_name)
 
const SparseMatrix< Number > & get_matrix (std::string_view mat_name) const
 
SparseMatrix< Number > & get_matrix (std::string_view mat_name)
 
void prefer_hash_table_matrix_assembly (bool preference)
 Sets whether to use hash table matrix assembly if the matrix sub-classes support it.
 
void prefix_with_name (bool value)
 Instructs this system to prefix solve options with its name for solvers that leverage prefixes.
 
bool prefix_with_name () const
 
std::string prefix () const
 
void set_options_prefix (std::string options_prefix)
 Sets the solver-package options prefix of every vector and matrix this system owns, including ones added later.
 
const std::string & options_prefix () const
 
bool has_static_condensation () const
 
void solve_for_unconstrained_dofs (NumericVector< Number > &, int is_adjoint=-1) const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 
virtual void clear_physics ()
 Clear any data structures associated with the physics.
 
virtual void init_physics (const System &sys)
 Initialize any data structures associated with the physics.
 
virtual bool element_constraint (bool request_jacobian, DiffContext &)
 Adds the constraint contribution on elem to elem_residual.
 
virtual bool side_constraint (bool request_jacobian, DiffContext &)
 Adds the constraint contribution on side of elem to elem_residual.
 
virtual bool nonlocal_time_derivative (bool request_jacobian, DiffContext &)
 Adds any nonlocal time derivative contributions (e.g.
 
virtual bool nonlocal_constraint (bool request_jacobian, DiffContext &)
 Adds any nonlocal constraint contributions (e.g.
 
virtual void time_evolving (unsigned int var, unsigned int order)
 Tells the DiffSystem that variable var is evolving with respect to time.
 
bool is_time_evolving (unsigned int var) const
 
virtual bool mass_residual (bool request_jacobian, DiffContext &)
 Subtracts a mass vector contribution on elem from elem_residual.
 
virtual bool mass_residual (bool request_jacobian, DiffContext &) override
 Subtracts a mass vector contribution on elem from elem_residual.
 
virtual bool side_mass_residual (bool request_jacobian, DiffContext &)
 Subtracts a mass vector contribution on side of elem from elem_residual.
 
virtual bool nonlocal_mass_residual (bool request_jacobian, DiffContext &c)
 Subtracts any nonlocal mass vector contributions (e.g.
 
virtual bool damping_residual (bool request_jacobian, DiffContext &)
 Subtracts a damping vector contribution on elem from elem_residual.
 
virtual bool side_damping_residual (bool request_jacobian, DiffContext &)
 Subtracts a damping vector contribution on side of elem from elem_residual.
 
virtual bool nonlocal_damping_residual (bool request_jacobian, DiffContext &)
 Subtracts any nonlocal damping vector contributions (e.g.
 
virtual void set_mesh_system (System *sys)
 Tells the DifferentiablePhysics that system sys contains the isoparametric Lagrangian variables which correspond to the coordinates of mesh nodes, in problems where the mesh itself is expected to move in time.
 
const System * get_mesh_system () const
 
System * get_mesh_system ()
 
virtual void set_mesh_x_var (unsigned int var)
 Tells the DifferentiablePhysics that variable var from the mesh system should be used to update the x coordinate of mesh nodes, in problems where the mesh itself is expected to move in time.
 
unsigned int get_mesh_x_var () const
 
virtual void set_mesh_y_var (unsigned int var)
 Tells the DifferentiablePhysics that variable var from the mesh system should be used to update the y coordinate of mesh nodes.
 
unsigned int get_mesh_y_var () const
 
virtual void set_mesh_z_var (unsigned int var)
 Tells the DifferentiablePhysics that variable var from the mesh system should be used to update the z coordinate of mesh nodes.
 
unsigned int get_mesh_z_var () const
 
bool _eulerian_time_deriv (bool request_jacobian, DiffContext &)
 This method simply combines element_time_derivative() and eulerian_residual(), which makes its address useful as a pointer-to-member-function when refactoring.
 
bool have_first_order_vars () const
 
const std::set< unsigned int > & get_first_order_vars () const
 
bool is_first_order_var (unsigned int var) const
 
bool have_second_order_vars () const
 
const std::set< unsigned int > & get_second_order_vars () const
 
bool is_second_order_var (unsigned int var) const
 
virtual void init_qoi_count (System &)
 Initialize system qoi.
 
virtual void clear_qoi ()
 Clear all the data structures associated with the QoI.
 
virtual void element_qoi (DiffContext &, const QoISet &)
 Does any work that needs to be done on elem in a quantity of interest assembly loop, outputting to elem_qoi.
 
virtual void element_qoi_derivative (DiffContext &, const QoISet &)
 Does any work that needs to be done on elem in a quantity of interest derivative assembly loop, outputting to elem_qoi_derivative.
 
virtual void side_qoi (DiffContext &, const QoISet &)
 Does any work that needs to be done on side of elem in a quantity of interest assembly loop, outputting to elem_qoi.
 
virtual void side_qoi_derivative (DiffContext &, const QoISet &)
 Does any work that needs to be done on side of elem in a quantity of interest derivative assembly loop, outputting to elem_qoi_derivative.
 
virtual void thread_join (std::vector< Number > &qoi, const std::vector< Number > &other_qoi, const QoISet &qoi_indices)
 Method to combine thread-local qois.
 
virtual void parallel_op (const Parallel::Communicator &communicator, std::vector< Number > &sys_qoi, std::vector< Number > &local_qoi, const QoISet &qoi_indices)
 Method to populate system qoi data structure with process-local qoi.
 
virtual void finalize_derivative (NumericVector< Number > &derivatives, std::size_t qoi_index)
 Method to finalize qoi derivatives which require more than just a simple sum of element contributions.
 

Static Public Member Functions

static std::string get_info ()
 Gets a string containing the reference information.
 
static void print_info (std::ostream &out_stream=libMesh::out)
 Prints the reference information, by default to libMesh::out.
 
static unsigned int n_objects ()
 Prints the number of outstanding (created, but not yet destroyed) objects.
 
static void enable_print_counter_info ()
 Methods to enable/disable the reference counter output from print_info().
 
static void disable_print_counter_info ()
 

Public Attributes

GetPot args
 
unsigned int var [3]
 
unsigned int undefo_var [3]
 
bool fe_reinit_during_postprocess
 If fe_reinit_during_postprocess is true (it is true by default), FE objects will be reinit()ed with their default quadrature rules.
 
Real numerical_jacobian_h
 If calculating numeric jacobians is required, the FEMSystem will perturb each solution vector entry by numerical_jacobian_h when calculating finite differences.
 
Real verify_analytic_jacobians
 If verify_analytic_jacobian is equal to zero (as it is by default), no numeric jacobians will be calculated unless an overridden element_time_derivative(), element_constraint(), side_time_derivative(), or side_constraint() function cannot provide an analytic jacobian upon request.
 
std::unique_ptr< TimeSolver > time_solver
 A pointer to the solver object we're going to use.
 
Real deltat
 For time-dependent problems, this is the amount delta t to advance the solution in time.
 
bool postprocess_sides
 If postprocess_sides is true (it is false by default), the postprocessing loop will loop over all sides as well as all elements.
 
bool print_solution_norms
 Set print_residual_norms to true to print |U| whenever it is used in an assembly() call.
 
bool print_solutions
 Set print_solutions to true to print U whenever it is used in an assembly() call.
 
bool print_residual_norms
 Set print_residual_norms to true to print |F| whenever it is assembled.
 
bool print_residuals
 Set print_residuals to true to print F whenever it is assembled.
 
bool print_jacobian_norms
 Set print_jacobian_norms to true to print |J| whenever it is assembled.
 
bool print_jacobians
 Set print_jacobians to true to print J whenever it is assembled.
 
bool print_element_solutions
 Set print_element_solutions to true to print each U_elem input.
 
bool print_element_residuals
 Set print_element_residuals to true to print each R_elem contribution.
 
bool print_element_jacobians
 Set print_element_jacobians to true to print each J_elem contribution.
 
SparseMatrix< Number > * matrix
 The system matrix.
 
bool zero_out_matrix_and_rhs
 By default, the system will zero out the matrix and the right hand side.
 
std::unique_ptr< LinearSolver< Number > > linear_solver
 This class handles all the details of interfacing with various linear algebra packages like PETSc or LASPACK.
 
NumericVector< Number > * rhs
 The system matrix.
 
Parameters parameters
 Parameters for the system. If a parameter is not provided, it should be retrieved from the EquationSystems.
 
bool assemble_before_solve
 Flag which tells the system to whether or not to call the user assembly function during each call to solve().
 
bool use_fixed_solution
 A boolean to be set to true by systems using elem_fixed_solution, for optional use by e.g.
 
int extra_quadrature_order
 A member int that can be employed to indicate increased or reduced quadrature order.
 
std::unique_ptr< NumericVector< Number > > solution
 Data structure to hold solution values.
 
std::unique_ptr< NumericVector< Number > > current_local_solution
 All the values I need to compute my contribution to the simulation at hand.
 
Real time
 For time-dependent problems, this is the time t at the beginning of the current timestep.
 
bool compute_internal_sides
 compute_internal_sides is false by default, indicating that side_* computations will only be done on boundary sides.
 
bool assemble_qoi_sides
 If assemble_qoi_sides is true (it is false by default), the assembly loop for a quantity of interest or its derivatives will loop over domain boundary sides.
 
bool assemble_qoi_internal_sides
 If assemble_qoi_internal_sides is true (it is false by default), the assembly loop for a quantity of interest or its derivatives will loop over element sides which do not fall on domain boundaries.
 
bool assemble_qoi_elements
 If assemble_qoi_elements is false (it is true by default), the assembly loop for a quantity of interest or its derivatives will skip computing on mesh elements, and will only compute on mesh sides.
 

Protected Types

typedef std::map< std::string, std::pair< unsigned int, unsigned int > > Counts
 Data structure to log the information.
 

Protected Member Functions

void add_second_order_dot_vars ()
 Helper function to add "velocity" variables that are cousins to second order-in-time variables in the DifferentiableSystem.
 
void add_dot_var_dirichlet_bcs (unsigned int var_idx, unsigned int dot_var_idx)
 Helper function to and Dirichlet boundary conditions to "dot" variable cousins of second order variables in the system.
 
virtual void add_matrices () override
 Adds the system matrix.
 
template<typename T >
void setup_static_condensation_preconditioner (T &solver)
 Sets up the static condensation preconditioner for the supplied solver.
 
void project_vector (NumericVector< Number > &, int is_adjoint=-1, std::optional< ConstElemRange > active_local_range=std::nullopt, std::optional< std::vector< unsigned int > > variable_numbers=std::nullopt) const
 Projects the vector defined on the old mesh onto the new mesh.
 
void project_vector (const NumericVector< Number > &, NumericVector< Number > &, int is_adjoint=-1, std::optional< ConstElemRange > active_local_range=std::nullopt, std::optional< std::vector< unsigned int > > variable_numbers=std::nullopt) const
 Projects the vector defined on the old mesh onto the new mesh.
 
virtual void init_matrices ()
 Initializes the matrices associated with this system.
 
bool can_add_matrices () const
 
virtual bool condense_constrained_dofs () const
 Whether this object should condense out constrained degrees of freedom.
 
void increment_constructor_count (const std::string &name) noexcept
 Increments the construction counter.
 
void increment_destructor_count (const std::string &name) noexcept
 Increments the destruction counter.
 

Protected Attributes

bool _constrain_in_solver
 _constrain_in_solver defaults to true; if false then we apply constraints only via residual terms in the systems to be solved.
 
const Parallel::Communicator & _communicator
 
System * _mesh_sys
 System from which to acquire moving mesh information.
 
unsigned int _mesh_x_var
 Variables from which to acquire moving mesh information.
 
unsigned int _mesh_y_var
 
unsigned int _mesh_z_var
 
std::vector< unsigned int > _time_evolving
 Stores unsigned int to tell us which variables are evolving as first order in time (1), second order in time (2), or are not time evolving (0).
 
std::set< unsigned int > _first_order_vars
 Variable indices for those variables that are first order in time.
 
std::set< unsigned int > _second_order_vars
 Variable indices for those variables that are second order in time.
 
std::map< unsigned int, unsigned int > _second_order_dot_vars
 If the user adds any second order variables, then we need to also cache the map to their corresponding dot variable that will be added by this TimeSolver class.
 

Static Protected Attributes

static Counts _counts
 Actually holds the data.
 
static Threads::atomic< unsigned int > _n_objects
 The number of objects.
 
static Threads::spin_mutex _mutex
 Mutual exclusion object to enable thread-safe reference counting.
 
static bool _enable_print_counter = true
 Flag to control whether reference count information is printed when print_info is called.
 

Private Member Functions

void create_static_condensation_system_matrix ()
 Create the static condensation system matrix.
 
void add_system_rhs ()
 Add the system right-hand-side vector to the _vectors data structure.
 
void late_matrix_init (SparseMatrix< Number > &mat, ParallelType type)
 Helper function to keep DofMap forward declarable in system.h.
 
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.
 
template<typename iterator_type , typename InValType >
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.
 
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.
 
template<typename InValType >
numeric_index_type read_serialized_vector (Xdr &io, NumericVector< Number > *vec)
 Reads a vector for this System.
 
numeric_index_type read_serialized_vector (Xdr &io, NumericVector< Number > &vec)
 Non-templated version for backward compatibility.
 
template<typename iterator_type >
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.
 
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.
 
dof_id_type write_serialized_vector (Xdr &io, const NumericVector< Number > &vec) const
 Writes a vector for this System.
 

Private Attributes

std::vector< Real > _numerical_jacobian_h_for_var
 
std::stack< std::unique_ptr< DifferentiablePhysics >, std::vector< std::unique_ptr< DifferentiablePhysics > > > _diff_physics
 Stack of pointers to objects to use for physics assembly evaluations.
 
std::stack< std::unique_ptr< DifferentiableQoI >, std::vector< std::unique_ptr< DifferentiableQoI > > > _diff_qoi
 Pointer to object to use for quantity of interest assembly evaluations.
 
StaticCondensation * _sc_system_matrix
 The system matrix for static condensation problems.
 
void(* _init_system_function )(EquationSystems &es, const std::string &name)
 Function that initializes the system.
 
Initialization * _init_system_object
 Object that initializes the system.
 
void(* _assemble_system_function )(EquationSystems &es, const std::string &name)
 Function that assembles the system.
 
Assembly * _assemble_system_object
 Object that assembles the system.
 
void(* _constrain_system_function )(EquationSystems &es, const std::string &name)
 Function to impose constraints.
 
Constraint * _constrain_system_object
 Object that constrains the system.
 
void(* _qoi_evaluate_function )(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
 Function to evaluate quantity of interest.
 
QOI * _qoi_evaluate_object
 Object to compute quantities of interest.
 
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.
 
QOIDerivative * _qoi_evaluate_derivative_object
 Object to compute derivatives of quantities of interest.
 
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.
 
MeshBase & _mesh
 Constant reference to the mesh data structure used for the simulation.
 
const std::string _sys_name
 A name associated with this system.
 
const unsigned int _sys_number
 The number associated with this system.
 
bool _active
 Flag stating if the system is active or not.
 
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
 Some systems need an arbitrary number of vectors.
 
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 zeroed.
 
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.
 
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
 Some systems need an arbitrary number of matrices.
 
std::map< std::string, ParallelType, std::less<> > _matrix_types
 Holds the types of the matrices.
 
bool _matrices_initialized
 false when additional matrices being added require initialization, true otherwise.
 
bool _solution_projection
 Holds true if the solution vector should be projected onto a changed grid, false if it should be zeroed.
 
bool _basic_system_only
 Holds true if the components of more advanced system types (e.g.
 
bool _is_initialized
 true when additional vectors and variables do not require immediate initialization, false otherwise.
 
unsigned int _additional_data_written
 This flag is used only when reading in a system from file.
 
std::vector< unsigned int > _written_var_indices
 This vector is used only when reading in a system from file.
 
bool adjoint_already_solved
 Has the adjoint problem already been solved? If the user sets adjoint_already_solved to true, we won't waste time solving it again.
 
bool _hide_output
 Are we allowed to write this system to file? If _hide_output is true, then EquationSystems::write will ignore this system.
 
bool project_with_constraints
 Do we want to apply constraints while projecting vectors ?
 
bool _prefer_hash_table_matrix_assembly
 Whether to use hash table matrix assembly if the matrix sub-classes support it.
 
bool _require_sparsity_pattern
 Whether any of our matrices require an initial sparsity pattern computation in order to determine preallocation.
 
bool _prefix_with_name
 Whether we are name prefixing solver options.
 
std::string _options_prefix
 Solver-package options prefix of this system's vectors and matrices.
 
std::vector< Number > _qoi
 Values of the quantities of interest.
 
std::vector< Number > _qoi_error_estimates
 Vector to hold error estimates for qois, either from a steady state calculation, or from a single unsteady solver timestep.
 

Detailed Description

Definition at line 30 of file solid_system.h.

Member Typedef Documentation

◆ const_matrices_iterator

typedef std::map<std::string,std::unique_ptr<SparseMatrix<Number>>,std::less<>>::const_iterator libMesh::System::const_matrices_iterator
inherited

Definition at line 842 of file system.h.

◆ const_vectors_iterator

typedef std::map<std::string,std::unique_ptr<NumericVector<Number>>,std::less<>>::const_iterator libMesh::System::const_vectors_iterator
inherited

Definition at line 816 of file system.h.

◆ Counts

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts
protectedinherited

Data structure to log the information.

The log is identified by the class name.

Definition at line 119 of file reference_counter.h.

◆ GradientFunctionPointer

typedef Gradient(* libMesh::System::GradientFunctionPointer) (const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name)
inherited

Definition at line 567 of file system.h.

◆ matrices_iterator

typedef std::map<std::string,std::unique_ptr<SparseMatrix<Number>>,std::less<>>::iterator libMesh::System::matrices_iterator
inherited

Matrix iterator typedefs.

Definition at line 841 of file system.h.

◆ Parent

The type of the parent.

Definition at line 85 of file fem_system.h.

◆ sys_type

The type of system.

Definition at line 80 of file fem_system.h.

◆ TimeSolverResPtr

typedef bool(TimeSolver::* libMesh::FEMSystem::TimeSolverResPtr) (bool, DiffContext &)
inherited

Syntax sugar to make numerical_jacobian() declaration easier.

Definition at line 220 of file fem_system.h.

◆ ValueFunctionPointer

typedef Number(* libMesh::System::ValueFunctionPointer) (const Point &p, const Parameters &Parameters, const std::string &sys_name, const std::string &unknown_name)
inherited

Projects arbitrary functions onto the current solution.

The function value fptr and its gradient gptr are represented by function pointers. A gradient gptr is only required/used for projecting onto finite element spaces with continuous derivatives.

Definition at line 563 of file system.h.

◆ vectors_iterator

typedef std::map<std::string,std::unique_ptr<NumericVector<Number>>,std::less<>>::iterator libMesh::System::vectors_iterator
inherited

Vector iterator typedefs.

Definition at line 815 of file system.h.

Constructor & Destructor Documentation

◆ SolidSystem()

SolidSystem::SolidSystem ( EquationSystems &  es,
const std::string &  name,
const unsigned int  number 
)

Definition at line 48 of file solid_system.C.

50 :
51 FEMSystem(es, name_in, number_in)
52{
53
54 // Add a time solver. We are just looking at a steady state problem here.
55 this->time_solver = std::make_unique<SteadySolver>(*this);
56}
std::unique_ptr< TimeSolver > time_solver
A pointer to the solver object we're going to use.
This class provides a specific system class.
Definition fem_system.h:55

References libMesh::DifferentiableSystem::time_solver.

Member Function Documentation

◆ _eulerian_time_deriv()

bool libMesh::DifferentiablePhysics::_eulerian_time_deriv ( bool  request_jacobian,
DiffContext &  context 
)
inherited

This method simply combines element_time_derivative() and eulerian_residual(), which makes its address useful as a pointer-to-member-function when refactoring.

Definition at line 97 of file diff_physics.C.

99{
100 // For any problem we need time derivative terms
101 request_jacobian =
102 this->element_time_derivative(request_jacobian, context);
103
104 // For a moving mesh problem we may need the pseudoconvection term too
105 return this->eulerian_residual(request_jacobian, context) &&
106 request_jacobian;
107}
virtual bool element_time_derivative(bool request_jacobian, DiffContext &)
Adds the time derivative contribution on elem to elem_residual.
virtual bool eulerian_residual(bool request_jacobian, DiffContext &)
Adds a pseudo-convection contribution on elem to elem_residual, if the nodes of elem are being transl...

References libMesh::DifferentiablePhysics::element_time_derivative(), and libMesh::DifferentiablePhysics::eulerian_residual().

Referenced by libMesh::Euler2Solver::element_residual(), libMesh::EulerSolver::element_residual(), and libMesh::NewmarkSolver::element_residual().

◆ activate()

void libMesh::System::activate ( )
inlineinherited

Activates the system.

Only active systems are solved.

Definition at line 2472 of file system.h.

2473{
2474 _active = true;
2475}
bool _active
Flag stating if the system is active or not.
Definition system.h:2278

References libMesh::System::_active.

◆ active()

bool libMesh::System::active ( ) const
inlineinherited
Returns
true if the system is active, false otherwise. An active system will be solved.

Definition at line 2464 of file system.h.

2465{
2466 return _active;
2467}

References libMesh::System::_active.

◆ add_adjoint_rhs()

NumericVector< Number > & libMesh::System::add_adjoint_rhs ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's adjoint rhs vectors, by default the one corresponding to the first qoi. Creates the vector if it doesn't already exist.

Definition at line 1340 of file system.C.

1341{
1342 std::ostringstream adjoint_rhs_name;
1343 adjoint_rhs_name << "adjoint_rhs" << i;
1344
1345 return this->add_vector(adjoint_rhs_name.str(), false);
1346}
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.
Definition system.C:794

References libMesh::System::add_vector().

Referenced by libMesh::ExplicitSystem::assemble_qoi_derivative(), and libMesh::FEMSystem::assemble_qoi_derivative().

◆ add_adjoint_solution()

NumericVector< Number > & libMesh::System::add_adjoint_solution ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's adjoint solution vectors, by default the one corresponding to the first qoi. Creates the vector if it doesn't already exist.

Definition at line 1276 of file system.C.

1277{
1278 std::ostringstream adjoint_name;
1279 adjoint_name << "adjoint_solution" << i;
1280
1281 NumericVector<Number> & returnval = this->add_vector(adjoint_name.str());
1282 this->set_vector_as_adjoint(adjoint_name.str(), i);
1283 return returnval;
1284}
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...
Definition system.C:1203
template class LIBMESH_EXPORT NumericVector< Number >

References libMesh::System::add_vector(), and libMesh::System::set_vector_as_adjoint().

Referenced by libMesh::ImplicitSystem::adjoint_solve().

◆ add_dot_var_dirichlet_bcs()

void libMesh::DifferentiableSystem::add_dot_var_dirichlet_bcs ( unsigned int  var_idx,
unsigned int  dot_var_idx 
)
protectedinherited

Helper function to and Dirichlet boundary conditions to "dot" variable cousins of second order variables in the system.

The function takes the second order variable index, it's corresponding "dot" variable index and then searches for DirichletBoundary objects for var_idx and then adds a DirichletBoundary object for dot_var_idx using the same boundary ids and functors for the var_idx DirichletBoundary.

Definition at line 214 of file diff_system.C.

216{
217 // We're assuming that there could be a lot more variables than
218 // boundary conditions, so we search each of the boundary conditions
219 // for this variable rather than looping over boundary conditions
220 // in a separate loop and searching through all the variables.
221 const DirichletBoundaries * all_dbcs =
223
224 if (all_dbcs)
225 {
226 // We need to cache the DBCs to be added so that we add them
227 // after looping over the existing DBCs. Otherwise, we're polluting
228 // the thing we're looping over.
229 std::vector<DirichletBoundary> new_dbcs;
230
231 for (const auto & dbc : *all_dbcs)
232 {
233 libmesh_assert(dbc);
234
235 // Look for second order variable in the current
236 // DirichletBoundary object
237 std::vector<unsigned int>::const_iterator dbc_var_it =
238 std::find( dbc->variables.begin(), dbc->variables.end(), var_idx );
239
240 // If we found it, then we also need to add it's corresponding
241 // "dot" variable to a DirichletBoundary
242 std::vector<unsigned int> vars_to_add;
243 if (dbc_var_it != dbc->variables.end())
244 vars_to_add.push_back(dot_var_idx);
245
246 if (!vars_to_add.empty())
247 {
248 // We need to check if the boundary condition is time-dependent.
249 // Currently, we cannot automatically differentiate w.r.t. time
250 // so if the user supplies a time-dependent Dirichlet BC, then
251 // we can't automatically support the Dirichlet BC for the
252 // "velocity" boundary condition, so we error. Otherwise,
253 // the "velocity boundary condition will just be zero.
254 bool is_time_evolving_bc = false;
255 if (dbc->f)
256 is_time_evolving_bc = dbc->f->is_time_dependent();
257 else if (dbc->f_fem)
258 // We it's a FEMFunctionBase object, it will be implicitly
259 // time-dependent since it is assumed to depend on the solution.
260 is_time_evolving_bc = true;
261 else
262 libmesh_error_msg("Could not find valid boundary function!");
263
264 libmesh_error_msg_if(is_time_evolving_bc, "Cannot currently support time-dependent Dirichlet BC for dot variables!");
265 libmesh_error_msg_if(!dbc->f, "Expected valid DirichletBoundary function");
266
267 new_dbcs.emplace_back(dbc->b, vars_to_add, ZeroFunction<Number>());
268 }
269 }
270
271 // Let the DofMap make its own deep copy of the DirichletBC objects
272 for (const auto & dbc : new_dbcs)
273 this->get_dof_map().add_dirichlet_boundary(dbc);
274
275 } // if (all_dbcs)
276}
const DirichletBoundaries * get_dirichlet_boundaries() const
Definition dof_map.h:1671
const DofMap & get_dof_map() const
Definition system.h:2448
libmesh_assert(ctx)

References libMesh::DofMap::add_dirichlet_boundary(), libMesh::DofMap::get_dirichlet_boundaries(), libMesh::System::get_dof_map(), and libMesh::libmesh_assert().

Referenced by libMesh::DifferentiableSystem::add_second_order_dot_vars().

◆ add_matrices()

void libMesh::ImplicitSystem::add_matrices ( )
overrideprotectedvirtualinherited

Adds the system matrix.

Reimplemented from libMesh::System.

Definition at line 113 of file implicit_system.C.

114{
116
117 // Possible that we cleared the _matrices but
118 // forgot to update the matrix pointer?
119 if (this->n_matrices() == 0)
120 matrix = nullptr;
121
122 // Only need to add the matrix if it isn't there
123 // already!
124 if (matrix == nullptr)
125 matrix = &(this->add_matrix ("System Matrix"));
126
128}
SparseMatrix< Number > * matrix
The system matrix.
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.
Definition system.C:1038
unsigned int n_matrices() const
Definition system.h:2669
virtual void add_matrices()
Insertion point for adding matrices in derived classes before init_matrices() is called.
Definition system.h:2043

References libMesh::System::add_matrices(), libMesh::System::add_matrix(), libMesh::libmesh_assert(), libMesh::ImplicitSystem::matrix, and libMesh::System::n_matrices().

◆ add_matrix() [1/3]

SparseMatrix< Number > & libMesh::System::add_matrix ( std::string_view  mat_name,
ParallelType  type = PARALLEL,
MatrixBuildType  mat_build_type = MatrixBuildType::AUTOMATIC 
)
inherited

Adds the additional matrix mat_name to this system.

Only allowed prior to assemble(). All additional matrices have the same sparsity pattern as the matrix used during solution. When not System but the user wants to initialize the main/system matrix, then all the additional matrices, if existent, have to be initialized by the user, too.

This non-template method will add a derived matrix type corresponding to the solver package. If the user wishes to specify the matrix type to add, use the templated add_matrix method instead

Parameters
mat_nameA name for the matrix
typeThe serial/parallel/ghosted type of the matrix
mat_build_typeThe matrix type to build

Definition at line 1038 of file system.C.

1041{
1042 parallel_object_only();
1043
1044 libmesh_assert(this->comm().verify(std::string(mat_name)));
1045 libmesh_assert(this->comm().verify(int(type)));
1046 libmesh_assert(this->comm().verify(int(mat_build_type)));
1047
1048 // Return the matrix if it is already there.
1049 if (auto it = this->_matrices.find(mat_name);
1050 it != this->_matrices.end())
1051 return *it->second;
1052
1053 // Otherwise build the matrix to return.
1054 std::unique_ptr<SparseMatrix<Number>> matrix;
1055 if (this->has_static_condensation())
1056 {
1057 if (mat_build_type == MatrixBuildType::DIAGONAL)
1058 libmesh_error_msg(
1059 "We do not currently support static condensation of the diagonal matrix type");
1060 matrix = std::make_unique<StaticCondensation>(this->get_mesh(),
1061 *this,
1062 this->get_dof_map(),
1063 this->get_dof_map().get_static_condensation());
1064 }
1065 else
1067 auto & mat = *matrix;
1068 mat.set_options_prefix(_options_prefix);
1069
1070 _matrices.emplace(mat_name, std::move(matrix));
1071
1072 _matrix_types.emplace(mat_name, type);
1073
1074 // Initialize it first if we've already initialized the others.
1075 this->late_matrix_init(mat, type);
1076
1077 return mat;
1078}
const Parallel::Communicator & comm() const
static std::unique_ptr< SparseMatrix< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package(), const MatrixBuildType matrix_build_type=MatrixBuildType::AUTOMATIC)
Builds a SparseMatrix<T> using the linear solver package specified by solver_package.
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition system.h:2303
bool has_static_condensation() const
Definition system.C:2724
std::string _options_prefix
Solver-package options prefix of this system's vectors and matrices.
Definition system.h:2389
std::map< std::string, ParallelType, std::less<> > _matrix_types
Holds the types of the matrices.
Definition system.h:2308
void late_matrix_init(SparseMatrix< Number > &mat, ParallelType type)
Helper function to keep DofMap forward declarable in system.h.
Definition system.C:1105
const MeshBase & get_mesh() const
Definition system.h:2432
SolverPackage default_solver_package()
Definition libmesh.C:1064

References libMesh::System::_matrices, libMesh::System::_matrix_types, libMesh::System::_options_prefix, libMesh::SparseMatrix< T >::build(), libMesh::ParallelObject::comm(), libMesh::default_solver_package(), libMesh::DIAGONAL, libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::System::has_static_condensation(), libMesh::System::late_matrix_init(), and libMesh::libmesh_assert().

Referenced by libMesh::EigenSystem::add_matrices(), libMesh::ImplicitSystem::add_matrices(), alternative_fe_assembly(), libMesh::ClawSystem::assemble_boundary_condition_matrices(), libMesh::ImplicitSystem::create_static_condensation_system_matrix(), form_matrixA(), libMesh::EigenTimeSolver::init(), main(), libMesh::NewmarkSystem::NewmarkSystem(), and SystemsTest::testPetscOptionsPrefix().

◆ add_matrix() [2/3]

template<template< typename > class MatrixType>
SparseMatrix< Number > & libMesh::System::add_matrix ( std::string_view  mat_name,
ParallelType  type = PARALLEL 
)
inlineinherited

Adds the additional matrix mat_name to this system.

Only allowed prior to assemble(). All additional matrices have the same sparsity pattern as the matrix used during solution. When not System but the user wants to initialize the main/system matrix, then all the additional matrices, if existent, have to be initialized by the user, too.

This method will create add a derived matrix of type MatrixType<Number>. One can use the non-templated add_matrix method to add a matrix corresponding to the default solver package

Parameters
mat_nameA name for the matrix
typeThe serial/parallel/ghosted type of the matrix

Definition at line 2677 of file system.h.

2679{
2680 // Return the matrix if it is already there.
2681 auto it = this->_matrices.find(mat_name);
2682 if (it != this->_matrices.end())
2683 return *it->second;
2684
2685 // Otherwise build the matrix to return.
2686 auto pr = _matrices.emplace(mat_name, std::make_unique<MatrixType<Number>>(this->comm()));
2687 _matrix_types.emplace(mat_name, type);
2688
2689 SparseMatrix<Number> & mat = *(pr.first->second);
2690
2691 // Initialize it first if we've already initialized the others.
2692 this->late_matrix_init(mat, type);
2693
2694 return mat;
2695}
template class LIBMESH_EXPORT SparseMatrix< Number >

References libMesh::System::_matrices, libMesh::System::_matrix_types, libMesh::ParallelObject::comm(), and libMesh::System::late_matrix_init().

◆ add_matrix() [3/3]

SparseMatrix< Number > & libMesh::System::add_matrix ( std::string_view  mat_name,
std::unique_ptr< SparseMatrix< Number > >  matrix,
ParallelType  type = PARALLEL 
)
inherited

Adds the additional matrix mat_name to this system.

Only allowed prior to assemble(). All additional matrices have the same sparsity pattern as the matrix used during solution. When not System but the user wants to initialize the main/system matrix, then all the additional matrices, if existent, have to be initialized by the user, too.

Parameters
mat_nameA name for the matrix
matrixThe matrix we are handing over the System for ownership
typeThe serial/parallel/ghosted type of the matrix

Definition at line 1082 of file system.C.

1085{
1086 parallel_object_only();
1087
1088 const std::string namestr{mat_name};
1089
1090 libmesh_assert(this->comm().verify(namestr));
1091 libmesh_assert(this->comm().verify(int(type)));
1092
1093 SparseMatrix<Number> & mat = *matrix;
1094 mat.set_options_prefix(_options_prefix);
1095
1096 _matrices[namestr] = std::move(matrix);
1097 _matrix_types[namestr] = type;
1098
1099 // Initialize it first if we've already initialized the others.
1100 this->late_matrix_init(mat, type);
1101
1102 return mat;
1103}

References libMesh::System::_matrices, libMesh::System::_matrix_types, libMesh::System::_options_prefix, libMesh::ParallelObject::comm(), libMesh::System::late_matrix_init(), libMesh::libmesh_assert(), and libMesh::SparseMatrix< T >::set_options_prefix().

◆ add_second_order_dot_vars()

void libMesh::DifferentiableSystem::add_second_order_dot_vars ( )
protectedinherited

Helper function to add "velocity" variables that are cousins to second order-in-time variables in the DifferentiableSystem.

This function is only called if the TimeSolver is a FirstOrderUnsteadySolver.

Definition at line 182 of file diff_system.C.

183{
184 const std::set<unsigned int> & second_order_vars = this->get_second_order_vars();
185 if (!second_order_vars.empty())
186 {
187 for (const auto & var_id : second_order_vars)
188 {
189 const Variable & var = this->variable(var_id);
190 std::string new_var_name = std::string("dot_")+var.name();
191
192 unsigned int v_var_idx;
193
194 if (var.active_subdomains().empty())
195 v_var_idx = this->add_variable( new_var_name, var.type() );
196 else
197 v_var_idx = this->add_variable( new_var_name, var.type(), &var.active_subdomains() );
198
199 _second_order_dot_vars.insert(std::pair<unsigned int, unsigned int>(var_id, v_var_idx));
200
201 // The new velocities are time evolving variables of first order
202 this->time_evolving( v_var_idx, 1 );
203
204#ifdef LIBMESH_ENABLE_DIRICHLET
205 // And if there are any boundary conditions set on the second order
206 // variable, we also need to set it on its velocity variable.
207 this->add_dot_var_dirichlet_bcs(var_id, v_var_idx);
208#endif
209 }
210 }
211}
const std::set< unsigned int > & get_second_order_vars() const
std::map< unsigned int, unsigned int > _second_order_dot_vars
If the user adds any second order variables, then we need to also cache the map to their correspondin...
virtual void time_evolving(unsigned int var, unsigned int order)
Tells the DiffSystem that variable var is evolving with respect to time.
void add_dot_var_dirichlet_bcs(unsigned int var_idx, unsigned int dot_var_idx)
Helper function to and Dirichlet boundary conditions to "dot" variable cousins of second order variab...
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition system.C:2759
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.
Definition system.C:1400

References libMesh::DifferentiablePhysics::_second_order_dot_vars, libMesh::Variable::active_subdomains(), libMesh::DifferentiableSystem::add_dot_var_dirichlet_bcs(), libMesh::System::add_variable(), libMesh::DifferentiablePhysics::get_second_order_vars(), libMesh::Variable::name(), libMesh::DifferentiablePhysics::time_evolving(), libMesh::Variable::type(), and libMesh::System::variable().

Referenced by libMesh::DifferentiableSystem::init_data().

◆ add_sensitivity_rhs()

NumericVector< Number > & libMesh::System::add_sensitivity_rhs ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's sensitivity rhs vectors, by default the one corresponding to the first parameter. Creates the vector if it doesn't already exist.

Definition at line 1370 of file system.C.

1371{
1372 std::ostringstream sensitivity_rhs_name;
1373 sensitivity_rhs_name << "sensitivity_rhs" << i;
1374
1375 return this->add_vector(sensitivity_rhs_name.str(), false);
1376}

References libMesh::System::add_vector().

Referenced by libMesh::ImplicitSystem::assemble_residual_derivatives().

◆ add_sensitivity_solution()

NumericVector< Number > & libMesh::System::add_sensitivity_solution ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's solution sensitivity vectors, by default the one corresponding to the first parameter. Creates the vector if it doesn't already exist.

Definition at line 1225 of file system.C.

1226{
1227 std::ostringstream sensitivity_name;
1228 sensitivity_name << "sensitivity_solution" << i;
1229
1230 return this->add_vector(sensitivity_name.str());
1231}

References libMesh::System::add_vector().

Referenced by libMesh::ImplicitSystem::sensitivity_solve().

◆ add_system_rhs()

void libMesh::ExplicitSystem::add_system_rhs ( )
privateinherited

Add the system right-hand-side vector to the _vectors data structure.

Useful in initialization.

Definition at line 94 of file explicit_system.C.

95{
96 // Possible that we cleared the _vectors but
97 // forgot to update the rhs pointer?
98 if (this->n_vectors() == 0)
99 rhs = nullptr;
100
101
102 // Only need to add the rhs if it isn't there
103 // already!
104 if (rhs == nullptr)
105 rhs = &(this->add_vector ("RHS Vector", false));
106
108}
NumericVector< Number > * rhs
The system matrix.
unsigned int n_vectors() const
Definition system.h:2530

References libMesh::System::add_vector(), libMesh::libmesh_assert(), libMesh::System::n_vectors(), and libMesh::ExplicitSystem::rhs.

Referenced by libMesh::ExplicitSystem::clear(), and libMesh::ExplicitSystem::ExplicitSystem().

◆ add_variable() [1/2]

unsigned int libMesh::System::add_variable ( std::string_view  var,
const FEType &  type,
const std::set< subdomain_id_type > *const  active_subdomains = nullptr 
)
inherited

Adds the variable var to the list of variables for this system.

If active_subdomains is either nullptr (the default) or points to an empty set, then it will be assumed that var has no subdomain restrictions

Returns
The index number for the new variable.

Definition at line 1400 of file system.C.

1403{
1404 return this->get_dof_map().add_variable(*this, var, type, active_subdomains);
1405}
unsigned int add_variable(System &sys, 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.
Definition dof_map.C:3176

References libMesh::DofMap::add_variable(), and libMesh::System::get_dof_map().

Referenced by libMesh::DifferentiableSystem::add_second_order_dot_vars(), libMesh::System::add_variable(), assemble_and_solve(), DirichletConstraintValuesTest::checkUpdate(), OverlappingTestBase::init(), LaplaceSystem::init_data(), CoupledSystem::init_data(), HeatSystem::init_data(), PoissonSystem::init_data(), NavierSystem::init_data(), init_data(), ElasticitySystem::init_data(), SimpleRBConstruction::init_data(), SimpleEIMConstruction::init_data(), ElasticityRBConstruction::init_data(), CurlCurlSystem::init_data(), HilbertSystem::init_data(), NonlinearDiffusionSystem::init_data(), libMesh::AdvectionSystem::init_data(), FirstOrderScalarSystemBase::init_data(), SecondOrderScalarSystemSecondOrderTimeSolverBase::init_data(), NonManifoldCouplingTestBase::init_es(), main(), main(), libMesh::ErrorVector::plot_error(), libMesh::System::read_header(), libMesh::PetscPreconditioner< T >::set_hypre_ads_data(), libMesh::PetscPreconditioner< T >::set_hypre_ams_data(), RationalMapTest< elem_type >::setUp(), FETestBase< order, family, elem_type, build_nx, CaseName >::setUp(), SlitMeshRefinedSystemTest::setUp(), ParsedFEMFunctionTest::setUp(), WriteVecAndScalar::setupTests(), SystemsTest::simpleSetup(), MultiEvaluablePredTest::test(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), MeshFunctionTest::test_bad_gradient_var_with_out_of_mesh_value(), MeshFunctionTest::test_bad_hessian_var_with_out_of_mesh_value(), FEOrientationTestBase< order, family >::test_conformity_across_sides(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), ProjectSolutionTest::test_partial_project_solution(), MeshFunctionTest::test_subdomain_id_sets(), SystemsTest::testAssemblyWithDgFemContext(), DofMapTest::testBadElemFECombo(), EquationSystemsTest::testBadVarNames(), SystemsTest::testBlockRestrictedVarNDofs(), SystemsTest::testBoundaryProjectCube(), FEAMRConstraintTest< elem_type, order, family >::testConstrainedSpaceHoldsPolynomials(), DofMapTest::testConstraintLoopDetection(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testCopyNodalSolutionImpl(), ConstraintOperatorTest::testCoreform(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), SystemsTest::testDofCouplingWithVarGroups(), DofMapTest::testDofOwner(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusCopyHighOrderElementSolution(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), SystemsTest::testFirstScalarNumber(), DofMapTest::testGhostConstraintSendList(), MeshAssignTest::testMeshMoveAssign(), HeterogeneousNonlinearConstraintTest::testNonzeroDirichletValues(), PeriodicBCTest::testPeriodicBC(), PeriodicBCTest::testPeriodicSideHierarchic(), SystemsTest::testPetscOptionsPrefix(), EquationSystemsTest::testPostInitAddElem(), EquationSystemsTest::testPostInitAddRealSystem(), SystemsTest::testProjectCubeWithMeshFunction(), MeshInputTest::testProjectionRegression(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), SystemsTest::testProjectScalarCoarsening(), PeriodicBCTest::testRedistributeToGhosts(), InfFERadialTest::testRefinement(), EquationSystemsTest::testRefineThenReinitPreserveFlags(), EquationSystemsTest::testReinitWithNodeElem(), EquationSystemsTest::testRepartitionThenReinit(), EquationSystemsTest::testSelectivePRefine(), SystemsTest::testSetSystemParameterOverEquationSystem(), BoundaryInfoTest::testShellFaceConstraints(), MeshInputTest::testSingleElementImpl(), DirichletConstraintValuesTest::testSplineConstraintRows(), DisjointNeighborTest::testTempJump(), DisjointNeighborTest::testTempJumpRefine(), WriteVecAndScalar::testWriteExodus(), and WriteVecAndScalar::testWriteNemesis().

◆ add_variable() [2/2]

unsigned int libMesh::System::add_variable ( std::string_view  var,
const Order  order = FIRST,
const FEFamily  family = LAGRANGE,
const std::set< subdomain_id_type > *const  active_subdomains = nullptr,
const bool  p_refinement = true 
)
inherited

Adds the variable var to the list of variables for this system.

Same as before, but assumes LAGRANGE as default value for FEType.family. If active_subdomains is either nullptr (the default) or points to an empty set, then it will be assumed that var has no subdomain restrictions. If p_refinement is false, then even when on an Elem with non-zero p_level() this variable will not be p-refined.

Definition at line 1409 of file system.C.

1414{
1415 return this->add_variable(var,
1416 FEType(order, family).set_p_refinement(p_refinement),
1417 active_subdomains);
1418}

References libMesh::System::add_variable().

◆ add_variable_array()

unsigned int libMesh::System::add_variable_array ( const std::vector< std::string > &  vars,
const FEType &  type,
const std::set< subdomain_id_type > *const  active_subdomains = nullptr 
)
inherited

Adds variables vars to the list of variables for this system.

If active_subdomains is either nullptr (the default) or points to an empty set, then it will be assumed that the vars have no subdomain restrictions. This API will end up calling this->add_variables(). However, we will additionally store data that can be leveraged by the DofMap to build degrees of freedom containers corresponding to all the variables in this variable array

An 'array variable' is simply a sequence of contiguous variable numbers defined by pair where the first member of the pair is the first number in the variable sequence and the second member of the pair is the number of the last variable in the sequence plus one. Array variables may be used in tandem with variable grouping by downstream code to build optimized physics kernels since each variable in the array will have the same shape functions.

Returns
The index number for the last of the new variables.

Definition at line 1442 of file system.C.

1445{
1446 return this->get_dof_map().add_variable_array(*this, vars, type, active_subdomains);
1447}
unsigned int add_variable_array(System &sys, 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.
Definition dof_map.C:3407

References libMesh::DofMap::add_variable_array(), and libMesh::System::get_dof_map().

Referenced by DofMapTest::testArrayDofIndicesWithType().

◆ add_variables() [1/2]

unsigned int libMesh::System::add_variables ( const std::vector< std::string > &  vars,
const FEType &  type,
const std::set< subdomain_id_type > *const  active_subdomains = nullptr 
)
inherited

Adds the variables vars to the list of variables for this system.

If active_subdomains is either nullptr (the default) or points to an empty set, then it will be assumed that the vars have no subdomain restrictions

Returns
The index number for the last of the new variables.

Definition at line 1422 of file system.C.

1425{
1426 return this->get_dof_map().add_variables(*this, vars, type, active_subdomains);
1427}
unsigned int add_variables(System &sys, 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.
Definition dof_map.C:3283

References libMesh::DofMap::add_variables(), and libMesh::System::get_dof_map().

Referenced by libMesh::System::add_variables(), and SystemsTest::test100KVariables().

◆ add_variables() [2/2]

unsigned int libMesh::System::add_variables ( const std::vector< std::string > &  vars,
const Order  order = FIRST,
const FEFamily  family = LAGRANGE,
const std::set< subdomain_id_type > *const  active_subdomains = nullptr,
const bool  p_refinement = true 
)
inherited

Adds the variable var to the list of variables for this system.

Same as before, but assumes LAGRANGE as default value for FEType.family. If active_subdomains is either nullptr (the default) or points to an empty set, then it will be assumed that var has no subdomain restrictions. If p_refinement is false, then even when on an Elem with non-zero p_level() this variable will not be p-refined.

Definition at line 1431 of file system.C.

1436{
1437 return this->add_variables(vars,
1438 FEType(order, family).set_p_refinement(p_refinement),
1439 active_subdomains);
1440}
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.
Definition system.C:1422

References libMesh::System::add_variables().

◆ add_vector()

NumericVector< Number > & libMesh::System::add_vector ( std::string_view  vec_name,
const bool  projections = true,
const ParallelType  type = PARALLEL 
)
inherited

Adds the additional vector vec_name to this system.

All the additional vectors are similarly distributed, like the solution, and initialized to zero.

By default vectors added by add_vector are projected to changed grids by reinit(). To zero them instead (more efficient), pass "false" as the second argument

If the vector already exists, the existing vector is returned. after any upgrade to the projections or type has been made. We only handle upgrades (projections false->true, or type PARALLEL->GHOSTED) in this fashion, not downgrades, on the theory that if two codes have differing needs we want to support the union of those needs, not the intersection. Downgrades can only be accomplished manually, via set_vector_preservation() or by setting a vector type() and re-initializing.

Definition at line 794 of file system.C.

797{
798 parallel_object_only();
799
800 libmesh_assert(this->comm().verify(std::string(vec_name)));
801 libmesh_assert(this->comm().verify(int(type)));
802 libmesh_assert(this->comm().verify(projections));
803
804 // Return the vector if it is already there.
805 if (auto it = this->_vectors.find(vec_name);
806 it != this->_vectors.end())
807 {
808 // If the projection setting has *upgraded*, change it.
809 if (projections) // only do expensive lookup if needed
810 libmesh_map_find(_vector_projections, vec_name) = projections;
811
812 NumericVector<Number> & vec = *it->second;
813
814 // If we're in serial, our vectors are effectively SERIAL, so
815 // we'll ignore any type setting. If we're in parallel, we
816 // might have a type change to deal with.
817
818 if (this->n_processors() > 1)
819 {
820 // If the type setting has changed in a way we can't
821 // perceive as an upgrade or a downgrade, scream.
822 libmesh_assert_equal_to(type == SERIAL,
823 vec.type() == SERIAL);
824
825 // If the type setting has *upgraded*, change it.
826 if (type == GHOSTED && vec.type() == PARALLEL)
827 {
828 // A *really* late upgrade is expensive, but better not
829 // to risk zeroing data.
830 if (vec.initialized())
831 {
832 if (!vec.closed())
833 vec.close();
834
835 // Ideally we'd move parallel coefficients and then
836 // add ghosted coefficients, but copy and swap is
837 // simpler. If anyone actually ever uses this case
838 // for real we can look into optimizing it.
839 auto new_vec = NumericVector<Number>::build(this->comm());
840 new_vec->set_options_prefix(_options_prefix);
841#ifdef LIBMESH_ENABLE_GHOSTED
842 new_vec->init (this->n_dofs(), this->n_local_dofs(),
843 _dof_map->get_send_list(), /*fast=*/false,
844 GHOSTED);
845#else
846 libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
847#endif
848
849 *new_vec = vec;
850 vec.swap(*new_vec);
851 }
852 else
853 // The PARALLEL vec is not yet initialized, so we can
854 // just "upgrade" it to GHOSTED.
855 vec.set_type(type);
856 }
857 }
858
859 // Any upgrades are done; we're happy here.
860 return vec;
861 }
862
863 // Otherwise, build the vector. The following emplace() is
864 // guaranteed to succeed because, if we made it here, we don't
865 // already have a vector named "vec_name". We pass the user's
866 // requested ParallelType directly to NumericVector::build() so
867 // that, even if the vector is not initialized now, it will get the
868 // right type when it is initialized later.
869 auto pr =
870 _vectors.emplace(vec_name,
871 NumericVector<Number>::build(this->comm(),
873 type));
874 auto buf = pr.first->second.get();
875 buf->set_options_prefix(_options_prefix);
876 _vector_projections.emplace(vec_name, projections);
877
878 // Vectors are primal by default
879 _vector_is_adjoint.emplace(vec_name, -1);
880
881 // Initialize it if necessary
882 if (_is_initialized)
883 {
884 if (type == GHOSTED)
885 {
886#ifdef LIBMESH_ENABLE_GHOSTED
887 buf->init (this->n_dofs(), this->n_local_dofs(),
888 _dof_map->get_send_list(), /*fast=*/false,
889 GHOSTED);
890#else
891 libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
892#endif
893 }
894 else
895 buf->init (this->n_dofs(), this->n_local_dofs(), false, type);
896 }
897
898 return *buf;
899}
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, SolverPackage solver_package=libMesh::default_solver_package(), ParallelType parallel_type=AUTOMATIC)
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
processor_id_type n_processors() const
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,...
Definition system.h:2298
bool _is_initialized
true when additional vectors and variables do not require immediate initialization,...
Definition system.h:2332
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition system.h:2286
dof_id_type n_dofs() const
Definition system.C:120
dof_id_type n_local_dofs() const
Definition system.C:157
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...
Definition system.h:2292
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc... and degrees of freedom.
Definition system.h:2251

References libMesh::System::_dof_map, libMesh::System::_is_initialized, libMesh::System::_options_prefix, libMesh::System::_vector_is_adjoint, libMesh::System::_vector_projections, libMesh::System::_vectors, libMesh::NumericVector< T >::build(), libMesh::NumericVector< T >::close(), libMesh::NumericVector< T >::closed(), libMesh::ParallelObject::comm(), libMesh::default_solver_package(), libMesh::NumericVector< T >::get(), libMesh::GHOSTED, libMesh::NumericVector< T >::initialized(), libMesh::libmesh_assert(), libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::ParallelObject::n_processors(), libMesh::PARALLEL, libMesh::SERIAL, libMesh::NumericVector< T >::set_type(), libMesh::NumericVector< T >::swap(), and libMesh::NumericVector< T >::type().

Referenced by libMesh::System::add_adjoint_rhs(), libMesh::System::add_adjoint_solution(), libMesh::System::add_sensitivity_rhs(), libMesh::System::add_sensitivity_solution(), libMesh::ExplicitSystem::add_system_rhs(), libMesh::System::add_weighted_sensitivity_adjoint_solution(), libMesh::System::add_weighted_sensitivity_solution(), alternative_fe_assembly(), libMesh::AdjointRefinementEstimator::estimate_error(), fe_assembly(), form_functionA(), form_functionB(), libMesh::SecondOrderUnsteadySolver::init(), libMesh::UnsteadySolver::init(), libMesh::TimeSolver::init_adjoints(), libMesh::UnsteadySolver::init_adjoints(), libMesh::ContinuationSystem::init_data(), libMesh::OptimizationSystem::init_data(), main(), libMesh::NewmarkSystem::NewmarkSystem(), libMesh::System::read_header(), libMesh::FrequencySystem::set_frequencies(), libMesh::FrequencySystem::set_frequencies_by_range(), libMesh::FrequencySystem::set_frequencies_by_steps(), SystemsTest::testAddVectorProjChange(), SystemsTest::testAddVectorTypeChange(), SystemsTest::testPetscOptionsPrefix(), SystemsTest::testPostInitAddVector(), and SystemsTest::testPostInitAddVectorTypeChange().

◆ add_weighted_sensitivity_adjoint_solution()

NumericVector< Number > & libMesh::System::add_weighted_sensitivity_adjoint_solution ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's weighted sensitivity adjoint solution vectors, by default the one corresponding to the first qoi. Creates the vector if it doesn't already exist.

Definition at line 1308 of file system.C.

1309{
1310 std::ostringstream adjoint_name;
1311 adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1312
1313 NumericVector<Number> & returnval = this->add_vector(adjoint_name.str());
1314 this->set_vector_as_adjoint(adjoint_name.str(), i);
1315 return returnval;
1316}

References libMesh::System::add_vector(), and libMesh::System::set_vector_as_adjoint().

Referenced by libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().

◆ add_weighted_sensitivity_solution()

NumericVector< Number > & libMesh::System::add_weighted_sensitivity_solution ( )
inherited
Returns
A reference to the solution of the last weighted sensitivity solve Creates the vector if it doesn't already exist.

Definition at line 1255 of file system.C.

1256{
1257 return this->add_vector("weighted_sensitivity_solution");
1258}

References libMesh::System::add_vector().

Referenced by libMesh::ImplicitSystem::weighted_sensitivity_solve().

◆ adjoint_qoi_parameter_sensitivity()

void libMesh::ImplicitSystem::adjoint_qoi_parameter_sensitivity ( const QoISet &  qoi_indices,
const ParameterVector &  parameters,
SensitivityData &  sensitivities 
)
overridevirtualinherited

Solves for the derivative of each of the system's quantities of interest q in qoi[qoi_indices] with respect to each parameter in parameters, placing the result for qoi i and parameter j into sensitivities[i][j].

Uses adjoint_solve() and the adjoint sensitivity method.

Currently uses finite differenced derivatives (partial q / partial p) and (partial R / partial p).

Reimplemented from libMesh::System.

Definition at line 517 of file implicit_system.C.

520{
521 ParameterVector & parameters_vec =
522 const_cast<ParameterVector &>(parameters_in);
523
524 const unsigned int Np = cast_int<unsigned int>
525 (parameters_vec.size());
526 const unsigned int Nq = this->n_qois();
527
528 // An introduction to the problem:
529 //
530 // Residual R(u(p),p) = 0
531 // partial R / partial u = J = system matrix
532 //
533 // This implies that:
534 // d/dp(R) = 0
535 // (partial R / partial p) +
536 // (partial R / partial u) * (partial u / partial p) = 0
537
538 // We first do an adjoint solve:
539 // J^T * z = (partial q / partial u)
540 // if we haven't already or dont have an initial condition for the adjoint
541 if (!this->is_adjoint_already_solved())
542 {
543 this->adjoint_solve(qoi_indices);
544 }
545
546 this->assemble_residual_derivatives(parameters_in);
547
548 // Get ready to fill in sensitivities:
549 sensitivities.allocate_data(qoi_indices, *this, parameters_vec);
550
551 // We use the identities:
552 // dq/dp = (partial q / partial p) + (partial q / partial u) *
553 // (partial u / partial p)
554 // dq/dp = (partial q / partial p) + (J^T * z) *
555 // (partial u / partial p)
556 // dq/dp = (partial q / partial p) + z * J *
557 // (partial u / partial p)
558
559 // Leading to our final formula:
560 // dq/dp = (partial q / partial p) - z * (partial R / partial p)
561
562 // In the case of adjoints with heterogenous Dirichlet boundary
563 // function phi, where
564 // q := S(u) - R(u,phi)
565 // the final formula works out to:
566 // dq/dp = (partial S / partial p) - z * (partial R / partial p)
567 // Because we currently have no direct access to
568 // (partial S / partial p), we use the identity
569 // (partial S / partial p) = (partial q / partial p) +
570 // phi * (partial R / partial p)
571 // to derive an equivalent equation:
572 // dq/dp = (partial q / partial p) - (z-phi) * (partial R / partial p)
573
574 // Since z-phi degrees of freedom are zero for constrained indices,
575 // we can use the same constrained -(partial R / partial p) that we
576 // use for forward sensitivity solves, taking into account the
577 // differing sign convention.
578 //
579 // Since that vector is constrained, its constrained indices are
580 // zero, so its product with phi is zero, so we can neglect the
581 // evaluation of phi terms.
582
583 for (unsigned int j=0; j != Np; ++j)
584 {
585 // We currently get partial derivatives via central differencing
586
587 // (partial q / partial p) ~= (q(p+dp)-q(p-dp))/(2*dp)
588 // (partial R / partial p) ~= (rhs(p+dp) - rhs(p-dp))/(2*dp)
589
590 Number old_parameter = *parameters_vec[j];
591
592 const Real delta_p =
593 TOLERANCE * std::max(std::abs(old_parameter), 1e-3);
594
595 *parameters_vec[j] = old_parameter - delta_p;
596 this->assemble_qoi(qoi_indices);
597 const std::vector<Number> qoi_minus = this->get_qoi_values();
598
599 NumericVector<Number> & neg_partialR_partialp = this->get_sensitivity_rhs(j);
600
601 *parameters_vec[j] = old_parameter + delta_p;
602 this->assemble_qoi(qoi_indices);
603 const std::vector<Number> qoi_plus = this->get_qoi_values();
604
605 std::vector<Number> partialq_partialp(Nq, 0);
606 for (unsigned int i=0; i != Nq; ++i)
607 if (qoi_indices.has_index(i))
608 partialq_partialp[i] = (qoi_plus[i] - qoi_minus[i]) / (2.*delta_p);
609
610 // Don't leave the parameter changed
611 *parameters_vec[j] = old_parameter;
612
613 for (unsigned int i=0; i != Nq; ++i)
614 if (qoi_indices.has_index(i))
615 sensitivities[i][j] = partialq_partialp[i] +
616 neg_partialR_partialp.dot(this->get_adjoint_solution(i));
617 }
618
619 // All parameters_vec have been reset.
620 // Reset the original qoi.
621
622 this->assemble_qoi(qoi_indices);
623}
virtual void assemble_qoi(const QoISet &qoi_indices=QoISet()) override
Prepares qoi for quantity of interest assembly, then calls user qoi function.
virtual void assemble_residual_derivatives(const ParameterVector &parameters) override
Residual parameter derivative function.
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...
std::vector< Number > get_qoi_values() const
Returns a copy of qoi, not a reference.
Definition system.C:2246
unsigned int n_qois() const
Number of currently active quantities of interest.
Definition system.h:2593
NumericVector< Number > & get_sensitivity_rhs(unsigned int i=0)
Definition system.C:1380
bool is_adjoint_already_solved() const
Accessor for the adjoint_already_solved boolean.
Definition system.h:423
static constexpr Real TOLERANCE
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

References libMesh::ImplicitSystem::adjoint_solve(), libMesh::SensitivityData::allocate_data(), libMesh::ExplicitSystem::assemble_qoi(), libMesh::ImplicitSystem::assemble_residual_derivatives(), libMesh::NumericVector< T >::dot(), libMesh::System::get_qoi_values(), libMesh::System::get_sensitivity_rhs(), libMesh::QoISet::has_index(), libMesh::System::is_adjoint_already_solved(), libMesh::System::n_qois(), libMesh::Real, libMesh::ParameterVector::size(), and libMesh::TOLERANCE.

Referenced by libMesh::UnsteadySolver::integrate_adjoint_sensitivity(), and main().

◆ adjoint_solve()

std::pair< unsigned int, Real > libMesh::DifferentiableSystem::adjoint_solve ( const QoISet &  qoi_indices = QoISet())
overridevirtualinherited

This function sets the _is_adjoint boolean member of TimeSolver to true and then calls the adjoint_solve in implicit system.

Reimplemented from libMesh::ImplicitSystem.

Definition at line 150 of file diff_system.C.

151{
152 // Get the time solver object associated with the system, and tell it that
153 // we are solving the adjoint problem
154 this->get_time_solver().set_is_adjoint(true);
155
156 return time_solver->adjoint_solve(qoi_indices);
157
158 //return this->ImplicitSystem::adjoint_solve(qoi_indices);
159}
void set_is_adjoint(bool _is_adjoint_value)
Accessor for setting whether we need to do a primal or adjoint solve.

References libMesh::DifferentiableSystem::get_time_solver(), libMesh::TimeSolver::set_is_adjoint(), and libMesh::DifferentiableSystem::time_solver.

Referenced by main().

◆ assemble()

void libMesh::DifferentiableSystem::assemble ( )
overridevirtualinherited

Prepares matrix and rhs for matrix assembly.

Users should not reimplement this. Note that in some cases only current_local_solution is used during assembly, and, therefore, if solution has been altered without update() being called, then the user must call update() before calling this function.

Reimplemented from libMesh::ImplicitSystem.

Definition at line 131 of file diff_system.C.

132{
133 this->assembly(true, true);
134}
virtual void assembly(bool get_residual, bool get_jacobian, bool apply_heterogeneous_constraints=false, bool apply_no_constraints=false) override=0
Assembles a residual in rhs and/or a jacobian in matrix, as requested.

References libMesh::DifferentiableSystem::assembly().

◆ assemble_qoi()

void FEMSystem::assemble_qoi ( const QoISet &  indices = QoISet())
overridevirtualinherited

Runs a qoi assembly loop over all elements, and if assemble_qoi_sides is true over all sides.

Users may have to override this function if they have any quantities of interest that are not expressible as a sum of element qois.

Reimplemented from libMesh::ExplicitSystem.

Definition at line 1146 of file fem_system.C.

1147{
1148 LOG_SCOPE("assemble_qoi()", "FEMSystem");
1149
1150 const MeshBase & mesh = this->get_mesh();
1151
1153#if defined(DEBUG) && !defined(LIBMESH_ENABLE_DEPRECATED)
1155#endif
1156
1157 this->update();
1158
1159 const unsigned int Nq = this->n_qois();
1160
1161 // the quantity of interest is assumed to be a sum of element and
1162 // side terms
1163 for (unsigned int i=0; i != Nq; ++i)
1164 if (qoi_indices.has_index(i))
1165 this->set_qoi(i, 0);
1166
1167 // Create a non-temporary qoi_contributions object, so we can query
1168 // its results after the reduction
1169 QoIContributions qoi_contributions(*this, *(this->get_qoi()), qoi_indices);
1170
1171 // Loop over every active mesh element on this processor
1173 qoi_contributions);
1174
1175 std::vector<Number> global_qoi = this->get_qoi_values();
1176 this->get_qoi()->parallel_op( this->comm(), global_qoi, qoi_contributions.qoi, qoi_indices );
1177 this->set_qoi(std::move(global_qoi));
1178}
virtual void parallel_op(const Parallel::Communicator &communicator, std::vector< Number > &sys_qoi, std::vector< Number > &local_qoi, const QoISet &qoi_indices)
Method to populate system qoi data structure with process-local qoi.
Definition diff_qoi.C:41
const DifferentiableQoI * get_qoi() const
This is the MeshBase class.
Definition mesh_base.h:81
bool is_prepared() const
Definition mesh_base.C:1152
const ElemRange & active_local_element_stored_range()
Definition mesh_base.C:2098
void set_qoi(unsigned int qoi_index, Number qoi_value)
Definition system.C:2231
virtual void update()
Update the local values to reflect the solution on neighboring processors.
Definition system.C:521
MeshBase & mesh
void libmesh_assert_valid_is_prepared(const MeshBase &mesh)
The following functions, no-ops except in builds with NDEBUG undefined, are for asserting internal co...
Definition mesh_tools.h:662
void parallel_reduce(const Range &range, Body &body, unsigned int n_threads=libMesh::n_threads())
Execute the provided reduction operation in parallel on the specified range.

References libMesh::MeshBase::active_local_element_stored_range(), libMesh::ParallelObject::comm(), libMesh::System::get_mesh(), libMesh::DifferentiableSystem::get_qoi(), libMesh::System::get_qoi_values(), libMesh::QoISet::has_index(), libMesh::MeshBase::is_prepared(), libMesh::libmesh_assert(), libMesh::MeshTools::libmesh_assert_valid_is_prepared(), mesh, libMesh::System::n_qois(), libMesh::DifferentiableQoI::parallel_op(), libMesh::Threads::parallel_reduce(), libMesh::System::set_qoi(), and libMesh::System::update().

◆ assemble_qoi_derivative()

void FEMSystem::assemble_qoi_derivative ( const QoISet &  qoi_indices = QoISet(),
bool  include_liftfunc = true,
bool  apply_constraints = true 
)
overridevirtualinherited

Runs a qoi derivative assembly loop over all elements, and if assemble_qoi_sides is true over all sides.

Users may have to override this function for quantities of interest that are not expressible as a sum of element qois.

Reimplemented from libMesh::ExplicitSystem.

Definition at line 1182 of file fem_system.C.

1185{
1186 LOG_SCOPE("assemble_qoi_derivative()", "FEMSystem");
1187
1188 const MeshBase & mesh = this->get_mesh();
1189
1191#if defined(DEBUG) && !defined(LIBMESH_ENABLE_DEPRECATED)
1193#endif
1194
1195 this->update();
1196
1197 // The quantity of interest derivative assembly accumulates on
1198 // initially zero vectors
1199 for (auto i : make_range(this->n_qois()))
1200 if (qoi_indices.has_index(i))
1201 this->add_adjoint_rhs(i).zero();
1202
1203 // Loop over every active mesh element on this processor
1205 QoIDerivativeContributions(*this, qoi_indices,
1206 *(this->get_qoi()),
1207 include_liftfunc,
1208 apply_constraints));
1209
1210 for (auto i : make_range(this->n_qois()))
1211 if (qoi_indices.has_index(i))
1212 this->get_qoi()->finalize_derivative(this->get_adjoint_rhs(i),i);
1213}
virtual void finalize_derivative(NumericVector< Number > &derivatives, std::size_t qoi_index)
Method to finalize qoi derivatives which require more than just a simple sum of element contributions...
Definition diff_qoi.C:53
NumericVector< Number > & add_adjoint_rhs(unsigned int i=0)
Definition system.C:1340
NumericVector< Number > & get_adjoint_rhs(unsigned int i=0)
Definition system.C:1350
void parallel_for(const Range &range, const Body &body, unsigned int n_threads=libMesh::n_threads())
Execute the provided function object in parallel on the specified range.
const Number zero
.
Definition libmesh.h:297
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition int_range.h:176

References libMesh::MeshBase::active_local_element_stored_range(), libMesh::System::add_adjoint_rhs(), libMesh::DifferentiableQoI::finalize_derivative(), libMesh::System::get_adjoint_rhs(), libMesh::System::get_mesh(), libMesh::DifferentiableSystem::get_qoi(), libMesh::QoISet::has_index(), libMesh::MeshBase::is_prepared(), libMesh::libmesh_assert(), libMesh::MeshTools::libmesh_assert_valid_is_prepared(), libMesh::make_range(), mesh, libMesh::System::n_qois(), libMesh::Threads::parallel_for(), libMesh::System::update(), and libMesh::NumericVector< T >::zero().

◆ assemble_residual_derivatives()

void libMesh::ImplicitSystem::assemble_residual_derivatives ( const ParameterVector &  parameters)
overridevirtualinherited

Residual parameter derivative function.

Uses finite differences by default.

This will assemble the sensitivity rhs vectors to hold -(partial R / partial p_i), making them ready to solve the forward sensitivity equation.

Can be overridden in derived classes.

Reimplemented from libMesh::System.

Definition at line 474 of file implicit_system.C.

475{
476 ParameterVector & parameters_vec =
477 const_cast<ParameterVector &>(parameters_in);
478
479 const unsigned int Np = cast_int<unsigned int>
480 (parameters_vec.size());
481
482 for (unsigned int p=0; p != Np; ++p)
483 {
484 NumericVector<Number> & sensitivity_rhs = this->add_sensitivity_rhs(p);
485
486 // Approximate -(partial R / partial p) by
487 // (R(p-dp) - R(p+dp)) / (2*dp)
488
489 Number old_parameter = *parameters_vec[p];
490
491 const Real delta_p =
492 TOLERANCE * std::max(std::abs(old_parameter), 1e-3);
493
494 *parameters_vec[p] -= delta_p;
495
496 // this->assembly(true, false, true);
497 this->assembly(true, false, false);
498 this->rhs->close();
499 sensitivity_rhs = *this->rhs;
500
501 *parameters_vec[p] = old_parameter + delta_p;
502
503 // this->assembly(true, false, true);
504 this->assembly(true, false, false);
505 this->rhs->close();
506
507 sensitivity_rhs -= *this->rhs;
508 sensitivity_rhs /= (2*delta_p);
509 sensitivity_rhs.close();
510
511 *parameters_vec[p] = old_parameter;
512 }
513}
virtual void assembly(bool, bool, bool=false, bool=false)
Assembles a residual in rhs and/or a jacobian in matrix, as requested.
virtual void close()=0
Calls the NumericVector's internal assembly routines, ensuring that the values are consistent across ...
NumericVector< Number > & add_sensitivity_rhs(unsigned int i=0)
Definition system.C:1370

References libMesh::System::add_sensitivity_rhs(), libMesh::ImplicitSystem::assembly(), libMesh::NumericVector< T >::close(), libMesh::Real, libMesh::ExplicitSystem::rhs, libMesh::ParameterVector::size(), and libMesh::TOLERANCE.

Referenced by libMesh::ImplicitSystem::adjoint_qoi_parameter_sensitivity(), and libMesh::ImplicitSystem::sensitivity_solve().

◆ assembly()

void FEMSystem::assembly ( bool  get_residual,
bool  get_jacobian,
bool  apply_heterogeneous_constraints = false,
bool  apply_no_constraints = false 
)
overridevirtualinherited

Prepares matrix or rhs for matrix assembly.

Users may reimplement this to add pre- or post-assembly code before or after calling FEMSystem::assembly(). Note that in some cases only current_local_solution is used during assembly, and, therefore, if solution has been altered without update() being called, then the user must call update() before calling this function.

Implements libMesh::DifferentiableSystem.

Reimplemented in libMesh::VariationalSmootherSystem.

Definition at line 876 of file fem_system.C.

879{
880 libmesh_assert(get_residual || get_jacobian);
881
882 // Log residual and jacobian and combined performance separately
883#ifdef LIBMESH_ENABLE_PERFORMANCE_LOGGING
884 const char * log_name;
885 if (get_residual && get_jacobian)
886 log_name = "assembly()";
887 else if (get_residual)
888 log_name = "assembly(get_residual)";
889 else
890 log_name = "assembly(get_jacobian)";
891
892 LOG_SCOPE(log_name, "FEMSystem");
893#endif
894
895 const MeshBase & mesh = this->get_mesh();
896
898#if defined(DEBUG) && !defined(LIBMESH_ENABLE_DEPRECATED)
900#endif
901
903 {
904 this->solution->close();
905
906 std::streamsize old_precision = libMesh::out.precision();
908 libMesh::out << "|U| = "
909 << this->solution->l1_norm()
910 << std::endl;
911 libMesh::out.precision(old_precision);
912 }
913 if (print_solutions)
914 {
915 std::streamsize old_precision = libMesh::out.precision();
917 libMesh::out << "U = [" << *(this->solution)
918 << "];" << std::endl;
919 libMesh::out.precision(old_precision);
920 }
921
922 // Is this definitely necessary? [RHS]
923 // Yes. [RHS 2012]
924 if (get_jacobian)
925 matrix->zero();
926 if (get_residual)
927 rhs->zero();
928
929 // Stupid C++ lets you set *Real* verify_analytic_jacobians = true!
931 {
932 libMesh::err << "WARNING! verify_analytic_jacobians was set "
933 << "to absurdly large value of "
934 << verify_analytic_jacobians << std::endl;
935 libMesh::err << "Resetting to 1e-6!" << std::endl;
937 }
938
939 // In time-dependent problems, the nonlinear function we're trying
940 // to solve at each timestep may depend on the particular solver
941 // we're using
943
944 // Build the residual and jacobian contributions on every active
945 // mesh element on this processor
948 AssemblyContributions(*this, get_residual, get_jacobian,
949 apply_heterogeneous_constraints,
950 apply_no_constraints));
951
952 // Check and see if we have SCALAR variables
953 bool have_scalar = false;
954 for (auto i : make_range(this->n_variable_groups()))
955 {
956 if (this->variable_group(i).type().family == SCALAR)
957 {
958 have_scalar = true;
959 break;
960 }
961 }
962
963 // SCALAR dofs are stored on the last processor, so we'll evaluate
964 // their equation terms there and only if we have a SCALAR variable
965 if (this->processor_id() == (this->n_processors()-1) && have_scalar)
966 {
967 std::unique_ptr<DiffContext> con = this->build_context();
968 FEMContext & _femcontext = cast_ref<FEMContext &>(*con);
969 this->init_context(_femcontext);
970 _femcontext.pre_fe_reinit(*this, nullptr);
971
972 bool jacobian_computed =
973 this->time_solver->nonlocal_residual(get_jacobian, _femcontext);
974
975 // Nonlocal residuals are likely to be length 0, in which case we
976 // don't need to do any more. And we shouldn't try to do any
977 // more; lots of DenseVector/DenseMatrix code assumes rank>0.
978 if (_femcontext.get_elem_residual().size())
979 {
980 // Compute a numeric jacobian if we have to
981 if (get_jacobian && !jacobian_computed)
982 {
983 // Make sure we didn't compute a jacobian and lie about it
984 libmesh_assert_equal_to (_femcontext.get_elem_jacobian().l1_norm(), 0.0);
985 // Logging of numerical jacobians is done separately
986 this->numerical_nonlocal_jacobian(_femcontext);
987 }
988
989 // Compute a numeric jacobian if we're asked to verify the
990 // analytic jacobian we got
991 if (get_jacobian && jacobian_computed &&
992 this->verify_analytic_jacobians != 0.0)
993 {
994 DenseMatrix<Number> analytic_jacobian(_femcontext.get_elem_jacobian());
995
996 _femcontext.get_elem_jacobian().zero();
997 // Logging of numerical jacobians is done separately
998 this->numerical_nonlocal_jacobian(_femcontext);
999
1000 Real analytic_norm = analytic_jacobian.l1_norm();
1001 Real numerical_norm = _femcontext.get_elem_jacobian().l1_norm();
1002
1003 // If we can continue, we'll probably prefer the analytic jacobian
1004 analytic_jacobian.swap(_femcontext.get_elem_jacobian());
1005
1006 // The matrix "analytic_jacobian" will now hold the error matrix
1007 analytic_jacobian.add(-1.0, _femcontext.get_elem_jacobian());
1008 Real error_norm = analytic_jacobian.l1_norm();
1009
1010 Real relative_error = error_norm /
1011 std::max(analytic_norm, numerical_norm);
1012
1013 if (relative_error > this->verify_analytic_jacobians)
1014 {
1015 libMesh::err << "Relative error " << relative_error
1016 << " detected in analytic jacobian on nonlocal dofs!"
1017 << std::endl;
1018
1019 std::streamsize old_precision = libMesh::out.precision();
1021 libMesh::out << "J_analytic nonlocal = "
1022 << _femcontext.get_elem_jacobian() << std::endl;
1023 analytic_jacobian.add(1.0, _femcontext.get_elem_jacobian());
1024 libMesh::out << "J_numeric nonlocal = "
1025 << analytic_jacobian << std::endl;
1026
1027 libMesh::out.precision(old_precision);
1028
1029 libmesh_error_msg("Relative error too large, exiting!");
1030 }
1031 }
1032
1033 add_element_system
1034 (*this, get_residual, get_jacobian,
1035 apply_heterogeneous_constraints, apply_no_constraints, _femcontext);
1036 }
1037 }
1038
1039 if (get_residual && (print_residual_norms || print_residuals))
1040 this->rhs->close();
1041 if (get_residual && print_residual_norms)
1042 {
1043 std::streamsize old_precision = libMesh::out.precision();
1045 libMesh::out << "|F| = " << this->rhs->l1_norm() << std::endl;
1046 libMesh::out.precision(old_precision);
1047 }
1048 if (get_residual && print_residuals)
1049 {
1050 std::streamsize old_precision = libMesh::out.precision();
1052 libMesh::out << "F = [" << *(this->rhs) << "];" << std::endl;
1053 libMesh::out.precision(old_precision);
1054 }
1055
1056 if (get_jacobian && (print_jacobian_norms || print_jacobians))
1057 this->matrix->close();
1058 if (get_jacobian && print_jacobian_norms)
1059 {
1060 std::streamsize old_precision = libMesh::out.precision();
1062 libMesh::out << "|J| = " << this->matrix->l1_norm() << std::endl;
1063 libMesh::out.precision(old_precision);
1064 }
1065 if (get_jacobian && print_jacobians)
1066 {
1067 std::streamsize old_precision = libMesh::out.precision();
1069 libMesh::out << "J = [" << *(this->matrix) << "];" << std::endl;
1070 libMesh::out.precision(old_precision);
1071 }
1072}
std::streamsize precision() const
Get the associated write precision.
Defines a dense matrix for use in Finite Element-type computations.
std::enable_if< ScalarTraits< T2 >::value, void >::type add(const T2 factor, const DenseMatrix< T3 > &mat)
Adds factor times mat to this matrix.
virtual void zero() override final
Sets all elements of the matrix to 0 and resets any decomposition flag which may have been previously...
virtual unsigned int size() const override final
const DenseVector< Number > & get_elem_residual() const
Const accessor for element residual.
const DenseMatrix< Number > & get_elem_jacobian() const
Const accessor for element Jacobian.
bool print_jacobians
Set print_jacobians to true to print J whenever it is assembled.
bool print_residuals
Set print_residuals to true to print F whenever it is assembled.
bool print_solution_norms
Set print_residual_norms to true to print |U| whenever it is used in an assembly() call.
bool print_solutions
Set print_solutions to true to print U whenever it is used in an assembly() call.
bool print_residual_norms
Set print_residual_norms to true to print |F| whenever it is assembled.
bool print_jacobian_norms
Set print_jacobian_norms to true to print |J| whenever it is assembled.
This class provides all data required for a physics package (e.g.
Definition fem_context.h:64
virtual void pre_fe_reinit(const System &, const Elem *e)
Reinitializes local data vectors/matrices on the current geometric element.
virtual std::unique_ptr< DiffContext > build_context() override
Builds a FEMContext object with enough information to do evaluations on each element.
void numerical_nonlocal_jacobian(FEMContext &context) const
Uses the results of multiple side_residual() calls to numerically differentiate the corresponding jac...
virtual void init_context(DiffContext &) override
Real verify_analytic_jacobians
If verify_analytic_jacobian is equal to zero (as it is by default), no numeric jacobians will be calc...
Definition fem_system.h:215
virtual Real l1_norm() const =0
virtual void zero()=0
Set all entries to zero.
processor_id_type processor_id() const
virtual Real l1_norm() const =0
virtual void close()=0
Calls the SparseMatrix's internal assembly routines, ensuring that the values are consistent across p...
virtual void zero()=0
Set all entries to 0.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition system.h:1667
const VariableGroup & variable_group(unsigned int vg) const
Return a constant reference to VariableGroup vg.
Definition system.C:2764
unsigned int n_variable_groups() const
Definition system.C:2754
OStreamProxy err
OStreamProxy out

References libMesh::MeshBase::active_local_element_stored_range(), libMesh::DenseMatrix< T >::add(), libMesh::FEMSystem::build_context(), libMesh::NumericVector< T >::close(), libMesh::SparseMatrix< T >::close(), libMesh::err, libMesh::FEType::family, libMesh::DiffContext::get_elem_jacobian(), libMesh::DiffContext::get_elem_residual(), libMesh::System::get_mesh(), libMesh::FEMSystem::init_context(), libMesh::MeshBase::is_prepared(), libMesh::DenseMatrix< T >::l1_norm(), libMesh::NumericVector< T >::l1_norm(), libMesh::SparseMatrix< T >::l1_norm(), libMesh::libmesh_assert(), libMesh::MeshTools::libmesh_assert_valid_is_prepared(), libMesh::make_range(), libMesh::ImplicitSystem::matrix, mesh, libMesh::ParallelObject::n_processors(), libMesh::System::n_variable_groups(), libMesh::FEMSystem::numerical_nonlocal_jacobian(), libMesh::out, libMesh::Threads::parallel_for(), libMesh::FEMContext::pre_fe_reinit(), libMesh::BasicOStreamProxy< charT, traits >::precision(), libMesh::DifferentiableSystem::print_jacobian_norms, libMesh::DifferentiableSystem::print_jacobians, libMesh::DifferentiableSystem::print_residual_norms, libMesh::DifferentiableSystem::print_residuals, libMesh::DifferentiableSystem::print_solution_norms, libMesh::DifferentiableSystem::print_solutions, libMesh::ParallelObject::processor_id(), libMesh::Real, libMesh::ExplicitSystem::rhs, libMesh::SCALAR, libMesh::DenseVector< T >::size(), libMesh::System::solution, libMesh::DenseMatrix< T >::swap(), libMesh::DifferentiableSystem::time_solver, libMesh::Variable::type(), libMesh::System::variable_group(), libMesh::FEMSystem::verify_analytic_jacobians, libMesh::DenseMatrix< T >::zero(), libMesh::NumericVector< T >::zero(), and libMesh::SparseMatrix< T >::zero().

Referenced by libMesh::ContinuationSystem::continuation_solve(), HeatSystem::perturb_accumulate_residuals(), and libMesh::ContinuationSystem::solve_tangent().

◆ attach_assemble_function()

void libMesh::System::attach_assemble_function ( void   fptrEquationSystems &es, const std::string &name)
inherited

Register a user function to use in assembling the system matrix and RHS.

Definition at line 2014 of file system.C.

2016{
2018
2019 if (_assemble_system_object != nullptr)
2020 {
2021 libmesh_warning("WARNING: Cannot specify both assembly function and object!");
2022
2023 _assemble_system_object = nullptr;
2024 }
2025
2027}
Assembly * _assemble_system_object
Object that assembles the system.
Definition system.h:2208
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Function that assembles the system.
Definition system.h:2202
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition projection.C:81

References fptr(), and libMesh::libmesh_assert().

Referenced by assemble_and_solve(), main(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), SystemsTest::testAssemblyWithDgFemContext(), ConstraintOperatorTest::testCoreform(), SystemsTest::testDofCouplingWithVarGroups(), PeriodicBCTest::testPeriodicBC(), DisjointNeighborTest::testTempJump(), and DisjointNeighborTest::testTempJumpRefine().

◆ attach_assemble_object()

void libMesh::System::attach_assemble_object ( System::Assembly &  assemble_in)
inherited

Register a user object to use in assembling the system matrix and RHS.

Definition at line 2031 of file system.C.

2032{
2033 if (_assemble_system_function != nullptr)
2034 {
2035 libmesh_warning("WARNING: Cannot specify both assembly object and function!");
2036
2037 _assemble_system_function = nullptr;
2038 }
2039
2040 _assemble_system_object = &assemble_in;
2041}

Referenced by main().

◆ attach_constraint_function()

void libMesh::System::attach_constraint_function ( void   fptrEquationSystems &es, const std::string &name)
inherited

Register a user function for imposing constraints.

Definition at line 2045 of file system.C.

2047{
2049
2050 if (_constrain_system_object != nullptr)
2051 {
2052 libmesh_warning("WARNING: Cannot specify both constraint function and object!");
2053
2054 _constrain_system_object = nullptr;
2055 }
2056
2058}
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Function to impose constraints.
Definition system.h:2213
Constraint * _constrain_system_object
Object that constrains the system.
Definition system.h:2219

References fptr(), and libMesh::libmesh_assert().

◆ attach_constraint_object()

void libMesh::System::attach_constraint_object ( System::Constraint &  constrain)
inherited

Register a user object for imposing constraints.

Definition at line 2062 of file system.C.

2063{
2064 if (_constrain_system_function != nullptr)
2065 {
2066 libmesh_warning("WARNING: Cannot specify both constraint object and function!");
2067
2069 }
2070
2071 _constrain_system_object = &constrain;
2072}

Referenced by libMesh::VariationalMeshSmoother::setup(), DofMapTest::testConstraintLoopDetection(), and DofMapTest::testGhostConstraintSendList().

◆ attach_init_function()

void libMesh::System::attach_init_function ( void   fptrEquationSystems &es, const std::string &name)
inherited

Register a user function to use in initializing the system.

Definition at line 1983 of file system.C.

1985{
1987
1988 if (_init_system_object != nullptr)
1989 {
1990 libmesh_warning("WARNING: Cannot specify both initialization function and object!");
1991
1992 _init_system_object = nullptr;
1993 }
1994
1996}
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Function that initializes the system.
Definition system.h:2191
Initialization * _init_system_object
Object that initializes the system.
Definition system.h:2197

References fptr(), and libMesh::libmesh_assert().

Referenced by main(), and main().

◆ attach_init_object()

void libMesh::System::attach_init_object ( System::Initialization &  init_in)
inherited

Register a user class to use to initialize the system.

Note
This is exclusive with the attach_init_function.

Definition at line 2000 of file system.C.

2001{
2002 if (_init_system_function != nullptr)
2003 {
2004 libmesh_warning("WARNING: Cannot specify both initialization object and function!");
2005
2006 _init_system_function = nullptr;
2007 }
2008
2009 _init_system_object = &init_in;
2010}

◆ attach_physics()

void libMesh::DifferentiableSystem::attach_physics ( DifferentiablePhysics *  physics_in)
inlineinherited

Attach external Physics object.

Definition at line 200 of file diff_system.h.

201 { this->_diff_physics.push(physics_in->clone_physics());
202 this->_diff_physics.top()->init_physics(*this);}
std::stack< std::unique_ptr< DifferentiablePhysics >, std::vector< std::unique_ptr< DifferentiablePhysics > > > _diff_physics
Stack of pointers to objects to use for physics assembly evaluations.

References libMesh::DifferentiableSystem::_diff_physics, and libMesh::DifferentiablePhysics::clone_physics().

◆ attach_qoi()

void libMesh::DifferentiableSystem::attach_qoi ( DifferentiableQoI *  qoi_in)
inherited

Attach external QoI object.

Definition at line 279 of file diff_system.C.

280{
281 this->_diff_qoi = {};
282 this->_diff_qoi.push(qoi_in->clone());
283
284 auto & dq = this->_diff_qoi.top();
285 dq->init_qoi_count( *this );
286}
std::stack< std::unique_ptr< DifferentiableQoI >, std::vector< std::unique_ptr< DifferentiableQoI > > > _diff_qoi
Pointer to object to use for quantity of interest assembly evaluations.

References libMesh::DifferentiableSystem::_diff_qoi, and libMesh::DifferentiableQoI::clone().

Referenced by main().

◆ attach_QOI_derivative()

void libMesh::System::attach_QOI_derivative ( void   fptrEquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
inherited

Register a user function for evaluating derivatives of a quantity of interest with respect to test functions, whose values should be placed in System::rhs.

Definition at line 2119 of file system.C.

2121{
2123
2124 if (_qoi_evaluate_derivative_object != nullptr)
2125 {
2126 libmesh_warning("WARNING: Cannot specify both QOI derivative function and object!");
2127
2129 }
2130
2132}
QOIDerivative * _qoi_evaluate_derivative_object
Object to compute derivatives of quantities of interest.
Definition system.h:2245
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.
Definition system.h:2236

References fptr(), and libMesh::libmesh_assert().

◆ attach_QOI_derivative_object()

void libMesh::System::attach_QOI_derivative_object ( QOIDerivative &  qoi_derivative)
inherited

Register a user object for evaluating derivatives of a quantity of interest with respect to test functions, whose values should be placed in System::rhs.

Definition at line 2136 of file system.C.

2137{
2138 if (_qoi_evaluate_derivative_function != nullptr)
2139 {
2140 libmesh_warning("WARNING: Cannot specify both QOI derivative object and function!");
2141
2143 }
2144
2145 _qoi_evaluate_derivative_object = &qoi_derivative;
2146}

◆ attach_QOI_function()

void libMesh::System::attach_QOI_function ( void   fptrEquationSystems &es, const std::string &name, const QoISet &qoi_indices)
inherited

Register a user function for evaluating the quantities of interest, whose values should be placed in System::qoi.

Definition at line 2087 of file system.C.

2090{
2092
2093 if (_qoi_evaluate_object != nullptr)
2094 {
2095 libmesh_warning("WARNING: Cannot specify both QOI function and object!");
2096
2097 _qoi_evaluate_object = nullptr;
2098 }
2099
2101}
QOI * _qoi_evaluate_object
Object to compute quantities of interest.
Definition system.h:2231
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Function to evaluate quantity of interest.
Definition system.h:2224

References fptr(), and libMesh::libmesh_assert().

◆ attach_QOI_object()

void libMesh::System::attach_QOI_object ( QOI &  qoi)
inherited

Register a user object for evaluating the quantities of interest, whose values should be placed in System::qoi.

Definition at line 2105 of file system.C.

2106{
2107 if (_qoi_evaluate_function != nullptr)
2108 {
2109 libmesh_warning("WARNING: Cannot specify both QOI object and function!");
2110
2111 _qoi_evaluate_function = nullptr;
2112 }
2113
2114 _qoi_evaluate_object = &qoi_in;
2115}

◆ boundary_project_solution() [1/2]

void libMesh::System::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 
)
inherited

Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system.

This method projects an arbitrary boundary function onto the solution via L2 projections and nodal interpolations on each element.

Only degrees of freedom which affect the function's trace on a boundary in the set b are affected. Only degrees of freedom associated with the variables listed in the vector variables are projected. The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives. elem_range active_local_range, if provided, indicates the range of elements over which to perform the projection.

Definition at line 1297 of file system_projection.C.

1302{
1303 this->boundary_project_vector(b, variables, *solution, f, g, -1 /*is_adjoint*/, active_local_range);
1304
1305 solution->localize(*current_local_solution);
1306}
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition system.h:1679
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...
static const Real b

References b.

Referenced by SystemsTest::testBoundaryProjectCube().

◆ boundary_project_solution() [2/2]

void libMesh::System::boundary_project_solution ( const std::set< boundary_id_type > &  b,
const std::vector< unsigned int > &  variables,
ValueFunctionPointer  fptr,
GradientFunctionPointer  gptr,
const Parameters &  parameters,
std::optional< ConstElemRange >  active_local_range = std::nullopt 
)
inherited

Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system.

This method projects components of an arbitrary boundary function onto the solution via L2 projections and nodal interpolations on each element.

Only degrees of freedom which affect the function's trace on a boundary in the set b are affected. Only degrees of freedom associated with the variables listed in the vector variables are projected. The function value fptr and its gradient gptr are represented by function pointers. A gradient gptr is only required/used for projecting onto finite element spaces with continuous derivatives. elem_range active_local_range, if provided, indicates the range of elements over which to perform the projection.

Definition at line 1278 of file system_projection.C.

1285{
1286 WrappedFunction<Number> f(*this, fptr, &function_parameters);
1287 WrappedFunction<Gradient> g(*this, gptr, &function_parameters);
1288 this->boundary_project_solution(b, variables, &f, &g, active_local_range);
1289}
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...
Gradient gptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition projection.C:96

References b, fptr(), and gptr().

◆ boundary_project_vector() [1/2]

void libMesh::System::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
inherited

Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system.

This method projects an arbitrary function via L2 projections and nodal interpolations on each element.

Only degrees of freedom which affect the function's trace on a boundary in the set b are affected. Only degrees of freedom associated with the variables listed in the vector variables are projected. The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives. elem_range active_local_range, if provided, indicates the range of elements over which to perform the projection.

Constrain the new vector using the requested adjoint rather than primal constraints if is_adjoint is non-negative.

Definition at line 1335 of file system_projection.C.

1342{
1343 LOG_SCOPE ("boundary_project_vector()", "System");
1344
1345 const ConstElemRange & range =
1346 active_local_range ?
1347 active_local_range.value() :
1349
1351 (range,
1352 BoundaryProjectSolution(b, variables, *this, f, g,
1354 new_vector)
1355 );
1356
1357 // We don't do SCALAR dofs when just projecting the boundary, so
1358 // we're done here.
1359
1360 new_vector.close();
1361
1362#ifdef LIBMESH_ENABLE_CONSTRAINTS
1363 if (is_adjoint == -1)
1364 this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
1365 else if (is_adjoint >= 0)
1367 is_adjoint);
1368#else
1369 libmesh_ignore(is_adjoint);
1370#endif
1371}
void enforce_constraints_exactly(const System &system, NumericVector< Number > *v=nullptr, bool homogeneous=false) const
Constrains the numeric vector v, which represents a solution defined on the mesh.
Definition dof_map.h:2602
void enforce_adjoint_constraints_exactly(NumericVector< Number > &v, unsigned int q) const
Heterogeneously constrains the numeric vector v, which represents an adjoint solution defined on the ...
Definition dof_map.h:2606
Parameters parameters
Parameters for the system. If a parameter is not provided, it should be retrieved from the EquationSy...
Definition system.h:1600
const EquationSystems & get_equation_systems() const
Definition system.h:779
StoredRange< MeshBase::const_element_iterator, const Elem * > ConstElemRange
Definition elem_range.h:34
void libmesh_ignore(const Args &...)

References b, libMesh::NumericVector< T >::close(), and libMesh::libmesh_ignore().

◆ boundary_project_vector() [2/2]

void libMesh::System::boundary_project_vector ( const std::set< boundary_id_type > &  b,
const std::vector< unsigned int > &  variables,
ValueFunctionPointer  fptr,
GradientFunctionPointer  gptr,
const Parameters &  parameters,
NumericVector< Number > &  new_vector,
int  is_adjoint = -1,
std::optional< ConstElemRange >  active_local_range = std::nullopt 
) const
inherited

Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system.

This method projects an arbitrary boundary function via L2 projections and nodal interpolations on each element.

Only degrees of freedom which affect the function's trace on a boundary in the set b are affected. Only degrees of freedom associated with the variables listed in the vector variables are projected. The function value fptr and its gradient gptr are represented by function pointers. A gradient gptr is only required/used for projecting onto finite element spaces with continuous derivatives. elem_range active_local_range, if provided, indicates the range of elements over which to perform the projection.

Constrain the new vector using the requested adjoint rather than primal constraints if is_adjoint is non-negative.

Definition at line 1316 of file system_projection.C.

1324{
1325 WrappedFunction<Number> f(*this, fptr, &function_parameters);
1326 WrappedFunction<Gradient> g(*this, gptr, &function_parameters);
1327 this->boundary_project_vector(b, variables, new_vector, &f, &g,
1328 is_adjoint, active_local_range);
1329}

References b, fptr(), and gptr().

◆ build_context()

std::unique_ptr< DiffContext > FEMSystem::build_context ( )
overridevirtualinherited

Builds a FEMContext object with enough information to do evaluations on each element.

For most problems, the default FEMSystem implementation is correct; users who subclass FEMContext will need to also reimplement this method to build it.

Reimplemented from libMesh::DifferentiableSystem.

Definition at line 1353 of file fem_system.C.

1354{
1355 auto fc = std::make_unique<FEMContext>(*this);
1356
1357 DifferentiablePhysics * phys = this->get_physics();
1358
1359 libmesh_assert (phys);
1360
1361 // If we are solving a moving mesh problem, tell that to the Context
1362 fc->set_mesh_system(phys->get_mesh_system());
1363 fc->set_mesh_x_var(phys->get_mesh_x_var());
1364 fc->set_mesh_y_var(phys->get_mesh_y_var());
1365 fc->set_mesh_z_var(phys->get_mesh_z_var());
1366
1367 fc->set_deltat_pointer( &deltat );
1368
1369 // If we are solving the adjoint problem, tell that to the Context
1370 fc->is_adjoint() = this->get_time_solver().is_adjoint();
1371
1372 return fc;
1373}
This class provides a specific system class.
unsigned int get_mesh_y_var() const
unsigned int get_mesh_x_var() const
const System * get_mesh_system() const
unsigned int get_mesh_z_var() const
const DifferentiablePhysics * get_physics() const
Real deltat
For time-dependent problems, this is the amount delta t to advance the solution in time.
bool is_adjoint() const
Accessor for querying whether we need to do a primal or adjoint solve.

References libMesh::DifferentiableSystem::deltat, libMesh::DifferentiablePhysics::get_mesh_system(), libMesh::DifferentiablePhysics::get_mesh_x_var(), libMesh::DifferentiablePhysics::get_mesh_y_var(), libMesh::DifferentiablePhysics::get_mesh_z_var(), libMesh::DifferentiableSystem::get_physics(), libMesh::DifferentiableSystem::get_time_solver(), libMesh::TimeSolver::is_adjoint(), and libMesh::libmesh_assert().

Referenced by libMesh::FEMSystem::assembly(), libMesh::FEMSystem::mesh_position_get(), and libMesh::FEMSystem::mesh_position_set().

◆ calculate_norm() [1/2]

Real libMesh::System::calculate_norm ( const NumericVector< Number > &  v,
const SystemNorm &  norm,
std::set< unsigned int > *  skip_dimensions = nullptr 
) const
inherited
Returns
A norm of the vector v, using component_norm and component_scale to choose and weight the norms of each variable.

Definition at line 1588 of file system.C.

1591{
1592 // This function must be run on all processors at once
1593 parallel_object_only();
1594
1595 LOG_SCOPE ("calculate_norm()", "System");
1596
1597 // Zero the norm before summation
1598 Real v_norm = 0.;
1599
1600 if (norm.is_discrete())
1601 {
1602 //Check to see if all weights are 1.0 and all types are equal
1603 FEMNormType norm_type0 = norm.type(0);
1604 unsigned int check_var = 0, check_end = this->n_vars();
1605 for (; check_var != check_end; ++check_var)
1606 if ((norm.weight(check_var) != 1.0) || (norm.type(check_var) != norm_type0))
1607 break;
1608
1609 //All weights were 1.0 so just do the full vector discrete norm
1610 if (check_var == this->n_vars())
1611 {
1612 if (norm_type0 == DISCRETE_L1)
1613 return v.l1_norm();
1614 if (norm_type0 == DISCRETE_L2)
1615 return v.l2_norm();
1616 if (norm_type0 == DISCRETE_L_INF)
1617 return v.linfty_norm();
1618 else
1619 libmesh_error_msg("Invalid norm_type0 = " << Utility::enum_to_string(norm_type0));
1620 }
1621
1622 for (auto var : make_range(this->n_vars()))
1623 {
1624 // Skip any variables we don't need to integrate
1625 if (norm.weight(var) == 0.0)
1626 continue;
1627
1628 v_norm += norm.weight(var) * discrete_var_norm(v, var, norm.type(var));
1629 }
1630
1631 return v_norm;
1632 }
1633
1634 // Localize the potentially parallel vector
1635 std::unique_ptr<NumericVector<Number>> local_v = NumericVector<Number>::build(this->comm());
1636 local_v->init(v.size(), v.local_size(), _dof_map->get_send_list(),
1637 true, GHOSTED);
1638 v.localize (*local_v, _dof_map->get_send_list());
1639
1640 // I'm not sure how best to mix Hilbert norms on some variables (for
1641 // which we'll want to square then sum then square root) with norms
1642 // like L_inf (for which we'll just want to take an absolute value
1643 // and then sum).
1644 bool using_hilbert_norm = true,
1645 using_nonhilbert_norm = true;
1646
1647 // Loop over all variables
1648 for (auto var : make_range(this->n_vars()))
1649 {
1650 // Skip any variables we don't need to integrate
1651 Real norm_weight_sq = norm.weight_sq(var);
1652 if (norm_weight_sq == 0.0)
1653 continue;
1654 Real norm_weight = norm.weight(var);
1655
1656 // Check for unimplemented norms (rather than just returning 0).
1657 FEMNormType norm_type = norm.type(var);
1658 if ((norm_type==H1) ||
1659 (norm_type==H2) ||
1660 (norm_type==L2) ||
1661 (norm_type==H1_SEMINORM) ||
1662 (norm_type==H2_SEMINORM))
1663 {
1664 if (!using_hilbert_norm)
1665 libmesh_not_implemented();
1666 using_nonhilbert_norm = false;
1667 }
1668 else if ((norm_type==L1) ||
1669 (norm_type==L_INF) ||
1670 (norm_type==W1_INF_SEMINORM) ||
1671 (norm_type==W2_INF_SEMINORM))
1672 {
1673 if (!using_nonhilbert_norm)
1674 libmesh_not_implemented();
1675 using_hilbert_norm = false;
1676 }
1677 else
1678 libmesh_not_implemented();
1679
1680 const FEType & fe_type = this->get_dof_map().variable_type(var);
1681
1682 // Allow space for dims 0-3, and for both scalar and vector
1683 // elements, even if we don't use them all
1684 std::vector<std::unique_ptr<FEBase>> fe_ptrs(4);
1685 std::vector<std::unique_ptr<FEVectorBase>> vec_fe_ptrs(4);
1686 std::vector<std::unique_ptr<QBase>> q_rules(4);
1687
1688 const std::set<unsigned char> & elem_dims = _mesh.elem_dimensions();
1689
1690 // Prepare finite elements for each dimension present in the mesh
1691 for (const auto & dim : elem_dims)
1692 {
1693 if (skip_dimensions && skip_dimensions->find(dim) != skip_dimensions->end())
1694 continue;
1695
1696 // Construct quadrature and finite element objects
1697 q_rules[dim] = fe_type.default_quadrature_rule (dim);
1698
1699 const FEFieldType field_type = FEInterface::field_type(fe_type);
1700 if (field_type == TYPE_SCALAR)
1701 {
1702 fe_ptrs[dim] = FEBase::build(dim, fe_type);
1703 fe_ptrs[dim]->attach_quadrature_rule (q_rules[dim].get());
1704 }
1705 else
1706 {
1707 vec_fe_ptrs[dim] = FEVectorBase::build(dim, fe_type);
1708 vec_fe_ptrs[dim]->attach_quadrature_rule (q_rules[dim].get());
1709 libmesh_assert_equal_to(field_type, TYPE_VECTOR);
1710 }
1711
1712 }
1713
1714 std::vector<dof_id_type> dof_indices;
1715
1716 // Begin the loop over the elements
1717 for (const auto & elem : this->get_mesh().active_local_element_ptr_range())
1718 {
1719 const unsigned int dim = elem->dim();
1720
1721 // One way for implementing this would be to exchange the fe with the FEInterface- class.
1722 // However, it needs to be discussed whether integral-norms make sense for infinite elements.
1723 // or in which sense they could make sense.
1724 if (elem->infinite() )
1725 libmesh_not_implemented();
1726
1727 if (skip_dimensions && skip_dimensions->find(dim) != skip_dimensions->end())
1728 continue;
1729
1730 QBase * qrule = q_rules[dim].get();
1731 libmesh_assert(qrule);
1732
1733 this->get_dof_map().dof_indices (elem, dof_indices, var);
1734
1735 auto element_calculation = [&dof_indices, &elem,
1736 norm_type, norm_weight, norm_weight_sq, &qrule,
1737 &local_v, &v_norm](auto & fe) {
1738 typedef typename std::remove_reference<decltype(fe)>::type::OutputShape OutputShape;
1739 typedef typename TensorTools::MakeNumber<OutputShape>::type OutputNumberShape;
1740 typedef typename std::remove_reference<decltype(fe)>::type::OutputGradient OutputGradient;
1741 typedef typename TensorTools::MakeNumber<OutputGradient>::type OutputNumberGradient;
1742
1743 const std::vector<Real> & JxW = fe.get_JxW();
1744 const std::vector<std::vector<OutputShape>> * phi = nullptr;
1745 if (norm_type == H1 ||
1746 norm_type == H2 ||
1747 norm_type == L2 ||
1748 norm_type == L1 ||
1749 norm_type == L_INF)
1750 phi = &(fe.get_phi());
1751
1752 const std::vector<std::vector<OutputGradient>> * dphi = nullptr;
1753 if (norm_type == H1 ||
1754 norm_type == H2 ||
1755 norm_type == H1_SEMINORM ||
1756 norm_type == W1_INF_SEMINORM)
1757 dphi = &(fe.get_dphi());
1758
1759#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1760 typedef typename std::remove_reference<decltype(fe)>::type::OutputTensor OutputTensor;
1761
1762 const std::vector<std::vector<OutputTensor>> * d2phi = nullptr;
1763 if (norm_type == H2 ||
1764 norm_type == H2_SEMINORM ||
1765 norm_type == W2_INF_SEMINORM)
1766 d2phi = &(fe.get_d2phi());
1767#endif
1768
1769 fe.reinit (elem);
1770
1771 const unsigned int n_qp = qrule->n_points();
1772
1773 const unsigned int n_sf = cast_int<unsigned int>
1774 (dof_indices.size());
1775
1776 // Begin the loop over the Quadrature points.
1777 for (unsigned int qp=0; qp<n_qp; qp++)
1778 {
1779 if (norm_type == L1)
1780 {
1781 OutputNumberShape u_h = 0.;
1782 for (unsigned int i=0; i != n_sf; ++i)
1783 u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1784 v_norm += norm_weight *
1785 JxW[qp] * TensorTools::norm(u_h);
1786 }
1787
1788 if (norm_type == L_INF)
1789 {
1790 OutputNumberShape u_h = 0.;
1791 for (unsigned int i=0; i != n_sf; ++i)
1792 u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1793 v_norm = std::max(v_norm, norm_weight * TensorTools::norm(u_h));
1794 }
1795
1796 if (norm_type == H1 ||
1797 norm_type == H2 ||
1798 norm_type == L2)
1799 {
1800 OutputNumberShape u_h = 0.;
1801 for (unsigned int i=0; i != n_sf; ++i)
1802 u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1803 v_norm += norm_weight_sq *
1804 JxW[qp] * TensorTools::norm_sq(u_h);
1805 }
1806
1807 if (norm_type == H1 ||
1808 norm_type == H2 ||
1809 norm_type == H1_SEMINORM)
1810 {
1811 OutputNumberGradient grad_u_h;
1812 for (unsigned int i=0; i != n_sf; ++i)
1813 grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
1814 v_norm += norm_weight_sq *
1815 JxW[qp] * grad_u_h.norm_sq();
1816 }
1817
1818 if (norm_type == W1_INF_SEMINORM)
1819 {
1820 OutputNumberGradient grad_u_h;
1821 for (unsigned int i=0; i != n_sf; ++i)
1822 grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
1823 v_norm = std::max(v_norm, norm_weight * grad_u_h.norm());
1824 }
1825
1826#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1827 typedef typename TensorTools::MakeNumber<OutputTensor>::type OutputNumberTensor;
1828
1829 if (norm_type == H2 ||
1830 norm_type == H2_SEMINORM)
1831 {
1832 OutputNumberTensor hess_u_h;
1833 for (unsigned int i=0; i != n_sf; ++i)
1834 hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
1835 v_norm += norm_weight_sq *
1836 JxW[qp] * hess_u_h.norm_sq();
1837 }
1838
1839 if (norm_type == W2_INF_SEMINORM)
1840 {
1841 OutputNumberTensor hess_u_h;
1842 for (unsigned int i=0; i != n_sf; ++i)
1843 hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
1844 v_norm = std::max(v_norm, norm_weight * hess_u_h.norm());
1845 }
1846#endif
1847 }
1848 };
1849
1850 FEBase * scalar_fe = fe_ptrs[dim].get();
1851 FEVectorBase * vec_fe = vec_fe_ptrs[dim].get();
1852
1853 if (scalar_fe)
1854 {
1855 libmesh_assert(!vec_fe);
1856 element_calculation(*scalar_fe);
1857 }
1858
1859 if (vec_fe)
1860 {
1861 libmesh_assert(!scalar_fe);
1862 element_calculation(*vec_fe);
1863 }
1864 }
1865 }
1866
1867 if (using_hilbert_norm)
1868 {
1869 this->comm().sum(v_norm);
1870 v_norm = std::sqrt(v_norm);
1871 }
1872 else
1873 {
1874 this->comm().max(v_norm);
1875 }
1876
1877 return v_norm;
1878}
unsigned int dim
void max(const T &r, T &o, Request &req) const
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition dof_map.C:2231
const FEType & variable_type(const unsigned int i) const
Definition dof_map.h:2472
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
static FEFieldType field_type(const FEType &fe_type)
const std::set< unsigned char > & elem_dimensions() const
Definition mesh_base.h:2801
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.
virtual Real l2_norm() const =0
virtual numeric_index_type size() const =0
virtual Real linfty_norm() const =0
virtual numeric_index_type local_size() const =0
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.
Definition system.C:1547
MeshBase & _mesh
Constant reference to the mesh data structure used for the simulation.
Definition system.h:2263
unsigned int n_vars() const
Definition system.C:2729
const Elem & get(const ElemType type_in)
LIBMESH_DEVICE_INLINE auto norm_sq(const T &a)
LIBMESH_DEVICE_INLINE auto norm(const T &a)
std::string enum_to_string(const T e)
FEGenericBase< RealGradient > FEVectorBase
Definition fe_base.h:856
FEGenericBase< Real > FEBase

References libMesh::FEType::default_quadrature_rule(), dim, libMesh::DISCRETE_L1, libMesh::DISCRETE_L2, libMesh::DISCRETE_L_INF, libMesh::GHOSTED, libMesh::H1, libMesh::H1_SEMINORM, libMesh::H2, libMesh::H2_SEMINORM, libMesh::L1, libMesh::NumericVector< T >::l1_norm(), libMesh::L2, libMesh::NumericVector< T >::l2_norm(), libMesh::L_INF, libMesh::libmesh_assert(), libMesh::NumericVector< T >::linfty_norm(), libMesh::NumericVector< T >::local_size(), libMesh::NumericVector< T >::localize(), libMesh::make_range(), libMesh::QBase::n_points(), n_vars, libMesh::Real, libMesh::NumericVector< T >::size(), libMesh::TYPE_SCALAR, libMesh::TYPE_VECTOR, libMesh::W1_INF_SEMINORM, libMesh::W2_INF_SEMINORM, and libMesh::SystemNorm::weight().

◆ calculate_norm() [2/2]

Real libMesh::System::calculate_norm ( const NumericVector< Number > &  v,
unsigned int  var,
FEMNormType  norm_type,
std::set< unsigned int > *  skip_dimensions = nullptr 
) const
inherited
Returns
A norm of variable var in the vector v, in the specified norm (e.g. L2, L_INF, H1)

Definition at line 1566 of file system.C.

1570{
1571 //short circuit to save time
1572 if (norm_type == DISCRETE_L1 ||
1573 norm_type == DISCRETE_L2 ||
1574 norm_type == DISCRETE_L_INF)
1575 return discrete_var_norm(v,var,norm_type);
1576
1577 // Not a discrete norm
1578 std::vector<FEMNormType> norms(this->n_vars(), L2);
1579 std::vector<Real> weights(this->n_vars(), 0.0);
1580 norms[var] = norm_type;
1581 weights[var] = 1.0;
1582 Real val = this->calculate_norm(v, SystemNorm(norms, weights), skip_dimensions);
1583 return val;
1584}
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
Definition system.C:1566

References libMesh::DISCRETE_L1, libMesh::DISCRETE_L2, libMesh::DISCRETE_L_INF, libMesh::L2, n_vars, and libMesh::Real.

Referenced by libMesh::TwostepTimeSolver::adjoint_solve(), libMesh::AdaptiveTimeSolver::calculate_norm(), libMesh::UnsteadySolver::du(), main(), output_norms(), ConstraintOperatorTest::testCoreform(), and MeshInputTest::testProjectionRegression().

◆ can_add_matrices()

bool libMesh::System::can_add_matrices ( ) const
inlineprotectedinherited
Returns
Whether or not matrices can still be added without expensive per-matrix initialization.

Definition at line 2054 of file system.h.

2054{ return !_matrices_initialized; }
bool _matrices_initialized
false when additional matrices being added require initialization, true otherwise.
Definition system.h:2313

References libMesh::System::_matrices_initialized.

Referenced by libMesh::EigenSystem::set_eigenproblem_type().

◆ clear()

void libMesh::DifferentiableSystem::clear ( )
overridevirtualinherited

Clear all the data structures associated with the system.

Reimplemented from libMesh::ImplicitSystem.

Reimplemented in libMesh::ContinuationSystem.

Definition at line 64 of file diff_system.C.

65{
66 // If we had no attached Physics object, clear our own Physics data
67 if (this->_diff_physics.empty())
68 this->clear_physics();
69
70 this->_diff_physics = {}; // No stack::clear
71 this->_diff_qoi = {};
72
73 // If we had no attached QoI object, clear our own QoI data
74 if (this->_diff_qoi.empty())
75 this->clear_qoi();
76
77 use_fixed_solution = false;
78}
virtual void clear_physics()
Clear any data structures associated with the physics.
virtual void clear_qoi()
Clear all the data structures associated with the QoI.
Definition diff_qoi.h:77
bool use_fixed_solution
A boolean to be set to true by systems using elem_fixed_solution, for optional use by e....
Definition system.h:1637

References libMesh::DifferentiableSystem::_diff_physics, libMesh::DifferentiableSystem::_diff_qoi, libMesh::DifferentiablePhysics::clear_physics(), libMesh::DifferentiableQoI::clear_qoi(), and libMesh::System::use_fixed_solution.

Referenced by libMesh::ContinuationSystem::clear().

◆ clear_physics()

void libMesh::DifferentiablePhysics::clear_physics ( )
virtualinherited

Clear any data structures associated with the physics.

Definition at line 29 of file diff_physics.C.

30{
31 _time_evolving.resize(0);
32}
std::vector< unsigned int > _time_evolving
Stores unsigned int to tell us which variables are evolving as first order in time (1),...

References libMesh::DifferentiablePhysics::_time_evolving.

Referenced by libMesh::DifferentiableSystem::clear().

◆ clear_qoi()

virtual void libMesh::DifferentiableQoI::clear_qoi ( )
inlinevirtualinherited

Clear all the data structures associated with the QoI.

Definition at line 77 of file diff_qoi.h.

77{}

Referenced by libMesh::DifferentiableSystem::clear().

◆ clone()

virtual std::unique_ptr< DifferentiableQoI > libMesh::DifferentiableSystem::clone ( )
inlineoverridevirtualinherited

We don't allow systems to be attached to each other.

Implements libMesh::DifferentiableQoI.

Definition at line 168 of file diff_system.h.

169 {
170 libmesh_not_implemented();
171 // dummy to avoid compiler warnings, not a real implementation
172 return std::unique_ptr<DifferentiableQoI>(nullptr);
173 }

Referenced by libMesh::AdjointRefinementEstimator::estimate_error().

◆ clone_physics()

virtual std::unique_ptr< DifferentiablePhysics > libMesh::DifferentiableSystem::clone_physics ( )
inlineoverridevirtualinherited

We don't allow systems to be attached to each other.

Implements libMesh::DifferentiablePhysics.

Definition at line 158 of file diff_system.h.

159 {
160 libmesh_not_implemented();
161 // dummy to avoid compiler warnings, not a real implementation
162 return std::unique_ptr<DifferentiablePhysics>(nullptr);
163 }

◆ comm()

const Parallel::Communicator & libMesh::ParallelObject::comm ( ) const
inlineinherited
Returns
A reference to the Parallel::Communicator object used by this mesh.

Definition at line 97 of file parallel_object.h.

98 { return _communicator; }
const Parallel::Communicator & _communicator

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), libMesh::DofMap::add_constraints_to_send_list(), add_cube_convex_hull_to_mesh(), libMesh::PetscDMWrapper::add_dofs_helper(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::RBEIMEvaluation::add_interpolation_data(), libMesh::CondensedEigenSystem::add_matrices(), libMesh::EigenSystem::add_matrices(), libMesh::System::add_matrix(), libMesh::System::add_matrix(), libMesh::System::add_matrix(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::DofMap::add_variable(), libMesh::DofMap::add_variables(), libMesh::System::add_vector(), libMesh::MeshTools::Modification::all_tri(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::AdvectionSystem::assemble_claw_rhs(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshBase::assert_equal_to(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::MeshCommunication::assign_global_indices(), libMesh::Partitioner::assign_partitioning(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::Partitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_section(), libMesh::PetscDMWrapper::build_sf(), libMesh::BoundaryInfo::build_side_list_from_node_list(), libMesh::MeshBase::cache_elem_data(), centroid_l2_error(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::MeshTetInterface::check_hull_integrity(), MeshInputTest::checkHexPrismPolyhedron(), libMesh::MeshBase::complete_preparation(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::RBSCMConstruction::compute_SCM_bounds_on_training_set(), libMesh::DofMap::computed_sparsity_already(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), PetscSolverConfiguration::configure_solver(), libMesh::ContinuationSystem::ContinuationSystem(), libMesh::MeshBase::copy_constraint_rows(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::CondensedEigenSystem::copy_super_to_sub(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshBase::count_constraint_rows(), libMesh::MeshTools::create_bounding_box(), libMesh::DofMap::create_dof_constraints(), libMesh::MeshTools::create_nodal_bounding_box(), libMesh::MeshRefinement::create_parent_error_vector(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::MeshTools::create_subdomain_bounding_box(), libMesh::PetscMatrix< T >::create_submatrix_nosort(), create_wrapped_function(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::MeshBase::detect_interior_parents(), libMesh::RBEIMEvaluation::distribute_bfs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), DMVariableBounds_libMesh(), libMesh::DTKSolutionTransfer::DTKSolutionTransfer(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_nodes(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::EpetraVector< T >::EpetraVector(), AssembleOptimization::equality_constraints(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::SmoothnessEstimator::estimate_smoothness(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_error_tolerance(), libMesh::MeshRefinement::flag_elements_by_mean_stddev(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::DofMap::gather_constraints(), libMesh::MeshfreeInterpolation::gather_remote_data(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::RBEIMEvaluation::get_eim_basis_function_node_value(), libMesh::RBEIMEvaluation::get_eim_basis_function_side_value(), libMesh::RBEIMEvaluation::get_eim_basis_function_value(), libMesh::DofMap::get_info(), libMesh::MeshBase::get_info(), libMesh::RBEIMEvaluation::get_interior_basis_functions_as_vecs(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::RBEIMConstruction::get_max_abs_value(), libMesh::RBEIMConstruction::get_node_max_abs_value(), libMesh::RBEIMEvaluation::get_parametrized_function_node_value(), libMesh::RBEIMEvaluation::get_parametrized_function_side_value(), libMesh::RBEIMEvaluation::get_parametrized_function_value(), libMesh::RBEIMConstruction::get_random_point(), libMesh::RBEIMConstruction::get_random_point(), libMesh::RBEIMConstruction::get_random_point(), libMesh::MeshTetInterface::improve_hull_integrity(), AssembleOptimization::inequality_constraints(), AssembleOptimization::inequality_constraints_jacobian(), libMesh::StaticCondensation::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::LocationMap< T >::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), ElasticitySystem::init_data(), libMesh::AdvectionSystem::init_data(), libMesh::ClawSystem::init_data(), libMesh::PetscDMWrapper::init_petscdm(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set(), libMesh::RBEIMConstruction::inner_product(), integrate_function(), libMesh::MeshTools::Modification::interpolate_surface(), libMesh::MeshBase::Preparation::libmesh_assert_consistent(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_equal_connectivity(), libMesh::MeshTools::libmesh_assert_equal_points(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_constraint_rows(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_flags(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_p_levels(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::libmesh_petsc_linesearch_shellfunc(), libMesh::libmesh_petsc_preconditioner_apply(), libMesh::libmesh_petsc_snes_postcheck(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), libMesh::LinearImplicitSystem::LinearImplicitSystem(), main(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshCommunication::make_new_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_new_nodes_parallel_consistent(), libMesh::MeshCommunication::make_node_bcids_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_unique_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshCommunication::make_p_levels_parallel_consistent(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::FEMSystem::mesh_position_set(), libMesh::TriangulatorInterface::MeshedHole::MeshedHole(), LinearElasticityWithContact::move_mesh(), libMesh::DistributedMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::MeshTools::n_connected_components(), libMesh::DofMap::n_constrained_dofs(), libMesh::DofMap::n_dofs(), libMesh::DofMap::n_dofs_per_processor(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::MeshTools::n_levels(), MixedOrderTest::n_neighbor_links(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::SparsityPattern::Build::n_nonzeros(), libMesh::MeshTools::n_p_levels(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::RBEIMEvaluation::node_distribute_bfs(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::RBEIMConstruction::node_inner_product(), libMesh::PetscVector< T >::operator=(), libMesh::MeshBase::operator==(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::DistributedMesh::parallel_max_unique_id(), libMesh::ReplicatedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_n_elem(), libMesh::DistributedMesh::parallel_n_nodes(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::BoundaryInfo::parallel_sync_node_ids(), libMesh::BoundaryInfo::parallel_sync_side_ids(), libMesh::MeshTools::paranoid_n_levels(), libMesh::Partitioner::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::petsc_auto_fieldsplit(), MeshGenerationTest::polyhedronTetNeighbor(), LaplaceSystem::postprocess(), PoissonSystem::postprocess(), libMesh::MeshBase::print_constraint_rows(), libMesh::DofMap::print_dof_constraints(), libMesh::DofMap::process_mesh_constraint_rows(), libMesh::Partitioner::processor_pairs_to_interface_nodes(), libMesh::InterMeshProjection::project_system_vectors(), libMesh::XdrIO::read(), libMesh::Nemesis_IO::read(), FEMParameters::read(), libMesh::EquationSystems::read(), libMesh::CheckpointIO::read_header(), libMesh::ExodusII_IO::read_header(), libMesh::System::read_header(), libMesh::XdrIO::read_header(), libMesh::RBEIMEvaluation::read_in_interior_basis_functions(), libMesh::RBEIMEvaluation::read_in_node_basis_functions(), libMesh::RBEIMEvaluation::read_in_side_basis_functions(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::Nemesis_IO_Helper::read_var_names_impl(), MeshFunctionTest::read_variable_info_from_output_data(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::SimplexRefiner::refine_via_edges(), libMesh::StaticCondensationDofMap::reinit(), libMesh::DofMap::reinit_dirichlet_constraint_values(), libMesh::BoundaryInfo::remove_edge_id(), libMesh::BoundaryInfo::remove_node_id(), libMesh::BoundaryInfo::remove_shellface_id(), libMesh::BoundaryInfo::remove_side_id(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::DistributedMesh::renumber_nodes_and_elements(), LinearElasticityWithContact::residual_and_jacobian(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), scale_mesh_and_plot(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::send_and_insert_dof_values(), libMesh::TransientRBConstruction::set_error_temporal_data(), libMesh::Partitioner::set_interface_node_processor_ids_BFS(), libMesh::Partitioner::set_interface_node_processor_ids_linear(), libMesh::Partitioner::set_interface_node_processor_ids_petscpartitioner(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::PetscDiffSolver::setup_petsc_data(), libMesh::RBEIMEvaluation::side_distribute_bfs(), libMesh::RBEIMEvaluation::side_gather_bfs(), libMesh::RBEIMConstruction::side_inner_product(), libMesh::Partitioner::single_partition(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::VariationalMeshSmoother::smooth(), libMesh::NoxNonlinearSolver< Number >::solve(), libMesh::ClawSystem::solve_conservation_law(), libMesh::split_mesh(), libMesh::RBEIMConstruction::store_eim_solutions_for_training_set(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::MeshBase::sync_subdomain_name_map(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), MeshFunctionTest::test_bad_gradient_var_with_out_of_mesh_value(), MeshFunctionTest::test_bad_hessian_var_with_out_of_mesh_value(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), ExodusC0PolyhedronTest::test_write_and_read_hexagonal_prism(), ExodusC0PolygonTest::test_write_and_read_pentagon(), DofMapTest::testBadElemFECombo(), SystemsTest::testBlockRestrictedVarNDofs(), BoundaryInfoTest::testBoundaryOnChildrenErrors(), MeshGenerationTest::testBuildCube(), BoundaryInfoTest::testBuildSideListFromNodeListThinMesh(), CheckpointIOTest::testC0PolygonCheckpoint(), VolumeTest::testC0PolygonMethods(), CheckpointIOTest::testC0PolyhedronCheckpoint(), VolumeTest::testC0PolyhedronMethods(), ConstraintOperatorTest::testCoreform(), ConnectedComponentsTest::testEdge(), MeshInputTest::testExodusIGASidesets(), MeshTriangulationTest::testFoundCenters(), PointLocatorTest::testLocator(), BoundaryInfoTest::testMesh(), BoundaryMeshSubdomainTest::testPerBoundarySubdomain(), PointLocatorTest::testPlanar(), MeshTriangulationTest::testPoly2TriEdge3ToTri7CenterFixup(), MeshTriangulationTest::testPoly2TriLargeCocircular(), MeshTriangulationTest::testPoly2TriRefinementBase(), SystemsTest::testProjectCubeWithMeshFunction(), SystemsTest::testProjectScalarCoarsening(), BoundaryInfoTest::testRenumber(), BoundaryInfoTest::testSelectiveRenumber(), BoundaryMeshSubdomainTest::testSingleSubdomain(), DirichletConstraintValuesTest::testSplineConstraintRows(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), MeshTriangulationTest::testTriangulatorInterp(), MeshTriangulationTest::testTriangulatorMeshedHoles(), MeshTriangulationTest::testTriangulatorRoundHole(), MeshSmootherTest::testVariationalSmoother(), libMesh::MeshTools::total_weight(), libMesh::RBConstruction::train_reduced_basis_with_POD(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::Poly2TriTriangulator::triangulate(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::truth_assembly(), update_current_local_solution(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::MeshTools::volume(), libMesh::STLIO::write(), libMesh::XdrIO::write(), libMesh::NameBasedIO::write(), libMesh::VTKIO::write_nodal_data(), libMesh::RBEIMEvaluation::write_out_interior_basis_functions(), libMesh::RBEIMEvaluation::write_out_node_basis_functions(), libMesh::RBEIMEvaluation::write_out_side_basis_functions(), libMesh::RBEvaluation::write_out_vectors(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::TransientRBConstruction::write_riesz_representors_to_files(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::RBDataSerialization::RBEvaluationSerialization::write_to_file(), libMesh::RBDataSerialization::TransientRBEvaluationSerialization::write_to_file(), libMesh::RBDataSerialization::RBEIMEvaluationSerialization::write_to_file(), and libMesh::RBDataSerialization::RBSCMEvaluationSerialization::write_to_file().

◆ compare()

bool libMesh::System::compare ( const System &  other_system,
const Real  threshold,
const bool  verbose 
) const
virtualinherited
Returns
true when the other system contains identical data, up to the given threshold. Outputs some diagnostic info when verbose is set.

Definition at line 644 of file system.C.

647{
648 // we do not care for matrices, but for vectors
650 libmesh_assert (other_system._is_initialized);
651
652 if (verbose)
653 {
654 libMesh::out << " Systems \"" << _sys_name << "\"" << std::endl;
655 libMesh::out << " comparing matrices not supported." << std::endl;
656 libMesh::out << " comparing names...";
657 }
658
659 // compare the name: 0 means identical
660 const int name_result = _sys_name.compare(other_system.name());
661 if (verbose)
662 {
663 if (name_result == 0)
664 libMesh::out << " identical." << std::endl;
665 else
666 libMesh::out << " names not identical." << std::endl;
667 libMesh::out << " comparing solution vector...";
668 }
669
670
671 // compare the solution: -1 means identical
672 const int solu_result = solution->compare (*other_system.solution.get(),
673 threshold);
674
675 if (verbose)
676 {
677 if (solu_result == -1)
678 libMesh::out << " identical up to threshold." << std::endl;
679 else
680 libMesh::out << " first difference occurred at index = "
681 << solu_result << "." << std::endl;
682 }
683
684
685 // safety check, whether we handle at least the same number
686 // of vectors
687 std::vector<int> ov_result;
688
689 if (this->n_vectors() != other_system.n_vectors())
690 {
691 if (verbose)
692 {
693 libMesh::out << " Fatal difference. This system handles "
694 << this->n_vectors() << " add'l vectors," << std::endl
695 << " while the other system handles "
696 << other_system.n_vectors()
697 << " add'l vectors." << std::endl
698 << " Aborting comparison." << std::endl;
699 }
700 return false;
701 }
702 else if (this->n_vectors() == 0)
703 {
704 // there are no additional vectors...
705 ov_result.clear ();
706 }
707 else
708 {
709 // compare other vectors
710 for (auto & [vec_name, vec] : _vectors)
711 {
712 if (verbose)
713 libMesh::out << " comparing vector \""
714 << vec_name << "\" ...";
715
716 // assume they have the same name
717 const NumericVector<Number> & other_system_vector =
718 other_system.get_vector(vec_name);
719
720 ov_result.push_back(vec->compare(other_system_vector, threshold));
721
722 if (verbose)
723 {
724 if (ov_result[ov_result.size()-1] == -1)
725 libMesh::out << " identical up to threshold." << std::endl;
726 else
727 libMesh::out << " first difference occurred at" << std::endl
728 << " index = " << ov_result[ov_result.size()-1] << "." << std::endl;
729 }
730 }
731 } // finished comparing additional vectors
732
733
734 bool overall_result;
735
736 // sum up the results
737 if ((name_result==0) && (solu_result==-1))
738 {
739 if (ov_result.size()==0)
740 overall_result = true;
741 else
742 {
743 bool ov_identical;
744 unsigned int n = 0;
745 do
746 {
747 ov_identical = (ov_result[n]==-1);
748 n++;
749 }
750 while (ov_identical && n<ov_result.size());
751 overall_result = ov_identical;
752 }
753 }
754 else
755 overall_result = false;
756
757 if (verbose)
758 {
759 libMesh::out << " finished comparisons, ";
760 if (overall_result)
761 libMesh::out << "found no differences." << std::endl << std::endl;
762 else
763 libMesh::out << "found differences." << std::endl << std::endl;
764 }
765
766 return overall_result;
767}
const std::string _sys_name
A name associated with this system.
Definition system.h:2268

References libMesh::System::_is_initialized, libMesh::System::_sys_name, libMesh::System::_vectors, libMesh::System::get_vector(), libMesh::libmesh_assert(), libMesh::System::n_vectors(), libMesh::System::name(), libMesh::out, and libMesh::System::solution.

◆ condense_constrained_dofs()

virtual bool libMesh::System::condense_constrained_dofs ( ) const
inlineprotectedvirtualinherited

Whether this object should condense out constrained degrees of freedom.

Reimplemented in libMesh::CondensedEigenSystem.

Definition at line 2085 of file system.h.

2085{ return false; }

Referenced by libMesh::EigenSystem::init_matrices().

◆ create_static_condensation()

void libMesh::ImplicitSystem::create_static_condensation ( )
overridevirtualinherited

Request that static condensation be performed for this system.

Reimplemented from libMesh::System.

Reimplemented in libMesh::LinearImplicitSystem, and libMesh::NonlinearImplicitSystem.

Definition at line 64 of file implicit_system.C.

65{
68}
void create_static_condensation_system_matrix()
Create the static condensation system matrix.
virtual void create_static_condensation()
Request that static condensation be performed for this system.
Definition system.C:2719

References libMesh::System::create_static_condensation(), and libMesh::ImplicitSystem::create_static_condensation_system_matrix().

Referenced by libMesh::LinearImplicitSystem::create_static_condensation(), and libMesh::NonlinearImplicitSystem::create_static_condensation().

◆ create_static_condensation_system_matrix()

void libMesh::ImplicitSystem::create_static_condensation_system_matrix ( )
privateinherited

Create the static condensation system matrix.

Definition at line 57 of file implicit_system.C.

58{
59 auto sc_system_matrix = std::make_unique<StaticCondensation>(this->get_mesh(), *this, this->get_dof_map(), this->get_dof_map().get_static_condensation());
60 _sc_system_matrix = sc_system_matrix.get();
61 matrix = &(this->add_matrix ("System Matrix", std::move(sc_system_matrix)));
62}
StaticCondensation * _sc_system_matrix
The system matrix for static condensation problems.
StaticCondensation & get_static_condensation()

References libMesh::ImplicitSystem::_sc_system_matrix, libMesh::System::add_matrix(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::ImplicitSystem::get_static_condensation(), and libMesh::ImplicitSystem::matrix.

Referenced by libMesh::ImplicitSystem::clear(), libMesh::ImplicitSystem::create_static_condensation(), and libMesh::ImplicitSystem::ImplicitSystem().

◆ current_solution()

Number libMesh::System::current_solution ( const dof_id_type  global_dof_number) const
inherited

◆ damping_residual()

virtual bool libMesh::DifferentiablePhysics::damping_residual ( bool  request_jacobian,
DiffContext &   
)
inlinevirtualinherited

Subtracts a damping vector contribution on elem from elem_residual.

This method is not used in first-order-in-time problems. For second-order-in-time problems, this is the \( C(u,\ddot{u})\ddot{u} \) term. This method is only called for UnsteadySolver-based TimeSolvers.

If this method receives request_jacobian = true, then it should compute elem_jacobian and return true if possible. If elem_jacobian has not been computed then the method should return false.

If the problem has no damping, the default "do-nothing" is correct. Otherwise, this must be reimplemented.

Reimplemented in SecondOrderScalarSystemSecondOrderTimeSolverBase, and SecondOrderScalarSystemFirstOrderTimeSolverBase.

Definition at line 360 of file diff_physics.h.

362 {
363 return request_jacobian;
364 }

Referenced by libMesh::Euler2Solver::element_residual(), libMesh::EulerSolver::element_residual(), and libMesh::NewmarkSolver::element_residual().

◆ deactivate()

void libMesh::System::deactivate ( )
inlineinherited

Deactivates the system.

Only active systems are solved.

Definition at line 2480 of file system.h.

2481{
2482 _active = false;
2483}

References libMesh::System::_active.

◆ disable_cache()

void libMesh::ImplicitSystem::disable_cache ( )
overridevirtualinherited

Avoids use of any cached data that might affect any solve result.

Should be overridden in derived systems.

Reimplemented from libMesh::System.

Definition at line 132 of file implicit_system.C.

132 {
133 this->assemble_before_solve = true;
135}
virtual LinearSolver< Number > * get_linear_solver() const
virtual void reuse_preconditioner(bool)
Set the same_preconditioner flag, which indicates if we reuse the same preconditioner for subsequent ...
bool assemble_before_solve
Flag which tells the system to whether or not to call the user assembly function during each call to ...
Definition system.h:1621

References libMesh::System::assemble_before_solve, libMesh::ImplicitSystem::get_linear_solver(), and libMesh::LinearSolver< T >::reuse_preconditioner().

Referenced by libMesh::DifferentiableSystem::pop_physics(), and libMesh::DifferentiableSystem::push_physics().

◆ disable_print_counter_info()

void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 100 of file reference_counter.C.

101{
102 _enable_print_counter = false;
103 return;
104}
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called.

References libMesh::ReferenceCounter::_enable_print_counter.

◆ discrete_var_norm()

Real libMesh::System::discrete_var_norm ( const NumericVector< Number > &  v,
unsigned int  var,
FEMNormType  norm_type 
) const
privateinherited

Finds the discrete norm for the entries in the vector corresponding to Dofs associated with var.

Definition at line 1547 of file system.C.

1550{
1551 std::set<dof_id_type> var_indices;
1552 local_dof_indices(var, var_indices);
1553
1554 if (norm_type == DISCRETE_L1)
1555 return v.subset_l1_norm(var_indices);
1556 if (norm_type == DISCRETE_L2)
1557 return v.subset_l2_norm(var_indices);
1558 if (norm_type == DISCRETE_L_INF)
1559 return v.subset_linfty_norm(var_indices);
1560 else
1561 libmesh_error_msg("Invalid norm_type = " << Utility::enum_to_string(norm_type));
1562}
virtual Real subset_l1_norm(const std::set< numeric_index_type > &indices) const
virtual Real subset_l2_norm(const std::set< numeric_index_type > &indices) const
virtual Real subset_linfty_norm(const std::set< numeric_index_type > &indices) 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 ...
Definition system.C:1465

References libMesh::DISCRETE_L1, libMesh::DISCRETE_L2, libMesh::DISCRETE_L_INF, libMesh::Real, libMesh::NumericVector< T >::subset_l1_norm(), libMesh::NumericVector< T >::subset_l2_norm(), and libMesh::NumericVector< T >::subset_linfty_norm().

◆ element_constraint()

virtual bool libMesh::DifferentiablePhysics::element_constraint ( bool  request_jacobian,
DiffContext &   
)
inlinevirtualinherited

Adds the constraint contribution on elem to elem_residual.

If this method receives request_jacobian = true, then it should compute elem_jacobian and return true if possible. If elem_jacobian has not been computed then the method should return false.

Users may need to reimplement this for their particular PDE.

To implement the constraint 0 = G(u), the user should examine u = elem_solution and add (G(u), phi_i) to elem_residual in elem_constraint().

Reimplemented in CoupledSystem, and NavierSystem.

Definition at line 144 of file diff_physics.h.

146 {
147 return request_jacobian;
148 }

Referenced by libMesh::EigenTimeSolver::element_residual(), libMesh::Euler2Solver::element_residual(), libMesh::EulerSolver::element_residual(), libMesh::NewmarkSolver::element_residual(), and libMesh::SteadySolver::element_residual().

◆ element_postprocess()

virtual void libMesh::DifferentiableSystem::element_postprocess ( DiffContext &  )
inlinevirtualinherited

Does any work that needs to be done on elem in a postprocessing loop.

Reimplemented in LaplaceSystem, LaplaceSystem, and PoissonSystem.

Definition at line 293 of file diff_system.h.

293{}

◆ element_qoi()

virtual void libMesh::DifferentiableQoI::element_qoi ( DiffContext &  ,
const QoISet &   
)
inlinevirtualinherited

Does any work that needs to be done on elem in a quantity of interest assembly loop, outputting to elem_qoi.

Only qois included in the supplied QoISet need to be assembled.

Reimplemented in LaplaceQoI, and HeatSystem.

Definition at line 110 of file diff_qoi.h.

112 {}

◆ element_qoi_derivative()

virtual void libMesh::DifferentiableQoI::element_qoi_derivative ( DiffContext &  ,
const QoISet &   
)
inlinevirtualinherited

Does any work that needs to be done on elem in a quantity of interest derivative assembly loop, outputting to elem_qoi_derivative.

Only qois included in the supplied QoISet need their derivatives assembled.

Reimplemented in HeatSystem, HeatSystem, LaplaceSystem, LaplaceQoI, and LaplaceSystem.

Definition at line 122 of file diff_qoi.h.

124 {}

◆ element_time_derivative()

bool SolidSystem::element_time_derivative ( bool  request_jacobian,
DiffContext &  context 
)
virtual

Compute contribution from internal forces in elem_residual and contribution from linearized internal forces (stiffness matrix) in elem_jacobian.

Reimplemented from libMesh::DifferentiablePhysics.

Definition at line 171 of file solid_system.C.

173{
174 FEMContext & c = cast_ref<FEMContext &>(context);
175
176 // First we get some references to cell-specific data that
177 // will be used to assemble the linear system.
178 FEBase * elem_fe = nullptr;
179 c.get_element_fe(0, elem_fe);
180
181 // Element Jacobian * quadrature weights for interior integration
182 const std::vector<Real> & JxW = elem_fe->get_JxW();
183
184 // Element basis functions
185 const std::vector<std::vector<RealGradient>> & dphi = elem_fe->get_dphi();
186
187 // Dimension of the mesh
188 const unsigned int dim = this->get_mesh().mesh_dimension();
189
190 // The number of local degrees of freedom in each variable
191 const unsigned int n_u_dofs = c.n_dof_indices(var[0]);
192 libmesh_assert(n_u_dofs == c.n_dof_indices(var[1]));
193 if (dim == 3)
194 libmesh_assert(n_u_dofs == c.n_dof_indices(var[2]));
195
196 unsigned int n_qpoints = c.get_element_qrule().n_points();
197
198 // Some matrices and vectors for storing the results of the constitutive
199 // law
200 DenseMatrix<Real> stiff;
203
204 // Instantiate the constitutive law
205 // Just calculate jacobian contribution when we need to
206 NonlinearNeoHookeCurrentConfig material(dphi, args, request_jacobian);
207
208 // Get a reference to the auxiliary system
210 TransientExplicitSystem>("auxiliary");
211 std::vector<dof_id_type> undefo_index;
212
213 // Assume symmetry of local stiffness matrices
214 bool use_symmetry = args("assembly/use_symmetry", false);
215
216 // Now we will build the element Jacobian and residual.
217 // This must be calculated at each quadrature point by
218 // summing the solution degree-of-freedom values by
219 // the appropriate weight functions.
220 // This class just takes care of the assembly. The matrix of
221 // the jacobian and the residual vector are provided by the
222 // constitutive formulation.
223
224 for (unsigned int qp = 0; qp != n_qpoints; qp++)
225 {
226 // Compute the displacement gradient
227 grad_u(0) = grad_u(1) = grad_u(2) = 0;
228 for (unsigned int d = 0; d < dim; ++d)
229 {
230 std::vector<Number> u_undefo;
231 aux_system.get_dof_map().dof_indices(&c.get_elem(), undefo_index, undefo_var[d]);
232 aux_system.current_local_solution->get(undefo_index, u_undefo);
233 for (unsigned int l = 0; l != n_u_dofs; l++)
234 grad_u(d).add_scaled(dphi[l][qp], u_undefo[l]); // u_current(l)); // -
235 }
236
237 // initialize the constitutive formulation with the current displacement
238 // gradient
239 material.init_for_qp(grad_u, qp);
240
241 // Acquire, scale and assemble residual and stiffness
242 for (unsigned int i = 0; i < n_u_dofs; i++)
243 {
244 res.resize(dim);
245 material.get_residual(res, i);
246 res.scale(JxW[qp]);
247 for (unsigned int ii = 0; ii < dim; ++ii)
248 (c.get_elem_residual(ii))(i) += res(ii);
249
250 if (request_jacobian && c.elem_solution_derivative)
251 {
253 for (unsigned int j = (use_symmetry ? i : 0); j < n_u_dofs; j++)
254 {
255 material.get_linearized_stiffness(stiff, i, j);
256 stiff.scale(JxW[qp]);
257 for (unsigned int ii = 0; ii < dim; ++ii)
258 {
259 for (unsigned int jj = 0; jj < dim; ++jj)
260 {
261 (c.get_elem_jacobian(ii,jj))(i, j) += stiff(ii, jj);
262 if (use_symmetry && i != j)
263 (c.get_elem_jacobian(ii,jj))(j, i) += stiff(jj, ii);
264 }
265 }
266 }
267 }
268 }
269 } // end of the quadrature point qp-loop
270
271 return request_jacobian;
272}
This class implements a constitutive formulation for an Neo-Hookean elastic solid in terms of the cur...
unsigned int undefo_var[3]
unsigned int var[3]
void scale(const T factor)
Multiplies every element in the matrix by factor.
Defines a dense vector for use in Finite Element-type computations.
void resize(const unsigned int n)
Resize the vector.
void scale(const T factor)
Multiplies every element in the vector by factor.
Real elem_solution_derivative
The derivative of elem_solution with respect to the current nonlinear solution.
unsigned int n_dof_indices() const
Total number of dof indices on the element.
const T_sys & get_system(std::string_view name) const
virtual_for_inffe const std::vector< Real > & get_JxW() const
This class forms the foundation from which generic finite elements may be derived.
Definition fe_base.h:86
const std::vector< std::vector< OutputGradient > > & get_dphi() const
Definition fe_base.h:252
const QBase & get_element_qrule() const
Accessor for element interior quadrature rule for the dimension of the current _elem.
const Elem & get_elem() const
Accessor for current Elem object.
void get_element_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for interior finite element object for variable var for the largest dimension in the mesh.
unsigned int mesh_dimension() const
Definition mesh_base.C:515
unsigned int n_points() const
Definition quadrature.h:131
Manages storage and variables for transient systems.
LIBMESH_DEVICE_INLINE void add_scaled(const TypeVector< T2 > &, const T &)
Add a scaled value to this vector without creating a temporary.
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.

References libMesh::TypeVector< T >::add_scaled(), args, dim, libMesh::DiffContext::elem_solution_derivative, libMesh::FEGenericBase< OutputType >::get_dphi(), libMesh::FEMContext::get_elem(), libMesh::DiffContext::get_elem_jacobian(), libMesh::DiffContext::get_elem_residual(), libMesh::FEMContext::get_element_fe(), libMesh::FEMContext::get_element_qrule(), libMesh::System::get_equation_systems(), libMesh::FEAbstract::get_JxW(), NonlinearNeoHookeCurrentConfig::get_linearized_stiffness(), libMesh::System::get_mesh(), NonlinearNeoHookeCurrentConfig::get_residual(), libMesh::EquationSystems::get_system(), NonlinearNeoHookeCurrentConfig::init_for_qp(), libMesh::libmesh_assert(), libMesh::MeshBase::mesh_dimension(), libMesh::DiffContext::n_dof_indices(), libMesh::QBase::n_points(), libMesh::DenseVector< T >::resize(), libMesh::DenseMatrix< T >::scale(), libMesh::DenseVector< T >::scale(), undefo_var, and var.

◆ enable_print_counter_info()

void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

Methods to enable/disable the reference counter output from print_info().

Enabled by default.

Definition at line 94 of file reference_counter.C.

95{
97 return;
98}

References libMesh::ReferenceCounter::_enable_print_counter.

Referenced by libMesh::LibMeshInit::~LibMeshInit().

◆ eulerian_residual()

virtual bool SolidSystem::eulerian_residual ( bool  request_jacobian,
DiffContext &   
)
inlinevirtual

Adds a pseudo-convection contribution on elem to elem_residual, if the nodes of elem are being translated by a moving mesh.

The library provides a basic implementation in FEMPhysics::eulerian_residual()

Reimplemented from libMesh::DifferentiablePhysics.

Definition at line 52 of file solid_system.h.

53 {
54 return false;
55 }

◆ finalize_derivative()

void libMesh::DifferentiableQoI::finalize_derivative ( NumericVector< Number > &  derivatives,
std::size_t  qoi_index 
)
virtualinherited

Method to finalize qoi derivatives which require more than just a simple sum of element contributions.

Definition at line 53 of file diff_qoi.C.

54{
55 // by default, do nothing
56}

Referenced by libMesh::FEMSystem::assemble_qoi_derivative().

◆ forward_qoi_parameter_sensitivity()

void libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity ( const QoISet &  qoi_indices,
const ParameterVector &  parameters,
SensitivityData &  sensitivities 
)
overridevirtualinherited

Solves for the derivative of each of the system's quantities of interest q in qoi[qoi_indices] with respect to each parameter in parameters, placing the result for qoi i and parameter j into sensitivities[i][j].

Uses the forward sensitivity method.

Currently uses finite differenced derivatives (partial q / partial p) and (partial R / partial p).

Reimplemented from libMesh::System.

Definition at line 627 of file implicit_system.C.

630{
631 ParameterVector & parameters_vec =
632 const_cast<ParameterVector &>(parameters_in);
633
634 const unsigned int Np = cast_int<unsigned int>
635 (parameters_vec.size());
636 const unsigned int Nq = this->n_qois();
637
638 // An introduction to the problem:
639 //
640 // Residual R(u(p),p) = 0
641 // partial R / partial u = J = system matrix
642 //
643 // This implies that:
644 // d/dp(R) = 0
645 // (partial R / partial p) +
646 // (partial R / partial u) * (partial u / partial p) = 0
647
648 // We first solve for (partial u / partial p) for each parameter:
649 // J * (partial u / partial p) = - (partial R / partial p)
650
651 this->sensitivity_solve(parameters_vec);
652
653 // Get ready to fill in sensitivities:
654 sensitivities.allocate_data(qoi_indices, *this, parameters_vec);
655
656 // We use the identity:
657 // dq/dp = (partial q / partial p) + (partial q / partial u) *
658 // (partial u / partial p)
659
660 // We get (partial q / partial u) from the user
661 this->assemble_qoi_derivative(qoi_indices,
662 /* include_liftfunc = */ true,
663 /* apply_constraints = */ false);
664
665 // We don't need these to be closed() in this function, but libMesh
666 // standard practice is to have them closed() by the time the
667 // function exits
668 for (auto i : make_range(this->n_qois()))
669 if (qoi_indices.has_index(i))
670 this->get_adjoint_rhs(i).close();
671
672 for (unsigned int j=0; j != Np; ++j)
673 {
674 // We currently get partial derivatives via central differencing
675
676 // (partial q / partial p) ~= (q(p+dp)-q(p-dp))/(2*dp)
677
678 Number old_parameter = *parameters_vec[j];
679
680 const Real delta_p =
681 TOLERANCE * std::max(std::abs(old_parameter), 1e-3);
682
683 *parameters_vec[j] = old_parameter - delta_p;
684 this->assemble_qoi(qoi_indices);
685 const std::vector<Number> qoi_minus = this->get_qoi_values();
686
687 *parameters_vec[j] = old_parameter + delta_p;
688 this->assemble_qoi(qoi_indices);
689 const std::vector<Number> qoi_plus = this->get_qoi_values();
690
691 std::vector<Number> partialq_partialp(Nq, 0);
692 for (unsigned int i=0; i != Nq; ++i)
693 if (qoi_indices.has_index(i))
694 partialq_partialp[i] = (qoi_plus[i] - qoi_minus[i]) / (2.*delta_p);
695
696 // Don't leave the parameter changed
697 *parameters_vec[j] = old_parameter;
698
699 for (unsigned int i=0; i != Nq; ++i)
700 if (qoi_indices.has_index(i))
701 sensitivities[i][j] = partialq_partialp[i] +
703 }
704
705 // All parameters_vec have been reset.
706 // We didn't cache the original rhs or matrix for memory reasons,
707 // but we can restore them to a state consistent solution -
708 // principle of least surprise.
709 this->assembly(true, true);
710 this->rhs->close();
711 this->matrix->close();
712 this->assemble_qoi(qoi_indices);
713}
virtual void assemble_qoi_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true) override
Prepares adjoint_rhs for quantity of interest derivative assembly, then calls user qoi derivative fun...
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 T dot(const NumericVector< T > &v) const =0
NumericVector< Number > & get_sensitivity_solution(unsigned int i=0)
Definition system.C:1235

References libMesh::SensitivityData::allocate_data(), libMesh::ExplicitSystem::assemble_qoi(), libMesh::ExplicitSystem::assemble_qoi_derivative(), libMesh::ImplicitSystem::assembly(), libMesh::NumericVector< T >::close(), libMesh::SparseMatrix< T >::close(), libMesh::NumericVector< T >::dot(), libMesh::System::get_adjoint_rhs(), libMesh::System::get_qoi_values(), libMesh::System::get_sensitivity_solution(), libMesh::QoISet::has_index(), libMesh::make_range(), libMesh::ImplicitSystem::matrix, libMesh::System::n_qois(), libMesh::Real, libMesh::ExplicitSystem::rhs, libMesh::ImplicitSystem::sensitivity_solve(), libMesh::ParameterVector::size(), and libMesh::TOLERANCE.

Referenced by main().

◆ get_adjoint_rhs() [1/2]

NumericVector< Number > & libMesh::System::get_adjoint_rhs ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's adjoint rhs vectors, by default the one corresponding to the first qoi. This what the user's QoI derivative code should assemble when setting up an adjoint problem

Definition at line 1350 of file system.C.

1351{
1352 std::ostringstream adjoint_rhs_name;
1353 adjoint_rhs_name << "adjoint_rhs" << i;
1354
1355 return this->get_vector(adjoint_rhs_name.str());
1356}
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition system.C:971

References libMesh::System::get_vector().

Referenced by libMesh::ImplicitSystem::adjoint_solve(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().

◆ get_adjoint_rhs() [2/2]

const NumericVector< Number > & libMesh::System::get_adjoint_rhs ( unsigned int  i = 0) const
inherited
Returns
A reference to one of the system's adjoint rhs vectors, by default the one corresponding to the first qoi.

Definition at line 1360 of file system.C.

1361{
1362 std::ostringstream adjoint_rhs_name;
1363 adjoint_rhs_name << "adjoint_rhs" << i;
1364
1365 return this->get_vector(adjoint_rhs_name.str());
1366}

References libMesh::System::get_vector().

◆ get_adjoint_solution() [1/2]

NumericVector< Number > & libMesh::System::get_adjoint_solution ( unsigned int  i = 0)
inherited

◆ get_adjoint_solution() [2/2]

const NumericVector< Number > & libMesh::System::get_adjoint_solution ( unsigned int  i = 0) const
inherited
Returns
A reference to one of the system's adjoint solution vectors, by default the one corresponding to the first qoi.

Definition at line 1298 of file system.C.

1299{
1300 std::ostringstream adjoint_name;
1301 adjoint_name << "adjoint_solution" << i;
1302
1303 return this->get_vector(adjoint_name.str());
1304}

References libMesh::System::get_vector().

◆ get_all_variable_numbers()

void libMesh::System::get_all_variable_numbers ( std::vector< unsigned int > &  all_variable_numbers) const
inherited

Fills all_variable_numbers with all the variable numbers for the variables that have been added to this system.

Definition at line 1459 of file system.C.

1460{
1461 this->get_dof_map().get_all_variable_numbers(all_variable_numbers);
1462}
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...
Definition dof_map.C:3419

References libMesh::DofMap::get_all_variable_numbers(), and libMesh::System::get_dof_map().

Referenced by MeshFunctionTest::read_variable_info_from_output_data(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), and SystemsTest::testProjectCubeWithMeshFunction().

◆ get_constrain_in_solver()

virtual bool libMesh::DifferentiableSystem::get_constrain_in_solver ( )
inlinevirtualinherited

Definition at line 381 of file diff_system.h.

382 {
384 }
bool _constrain_in_solver
_constrain_in_solver defaults to true; if false then we apply constraints only via residual terms in ...

References libMesh::DifferentiableSystem::_constrain_in_solver.

◆ get_constraint_object()

System::Constraint & libMesh::System::get_constraint_object ( )
inherited

Return the user object for imposing constraints.

Definition at line 2079 of file system.C.

2080{
2081 libmesh_assert_msg(_constrain_system_object,"No constraint object available.");
2083}

◆ get_dof_map() [1/2]

DofMap & libMesh::System::get_dof_map ( )
inlineinherited
Returns
A writable reference to this system's _dof_map.

Definition at line 2456 of file system.h.

2457{
2458 return *_dof_map;
2459}

References libMesh::System::_dof_map.

◆ get_dof_map() [2/2]

const DofMap & libMesh::System::get_dof_map ( ) const
inlineinherited
Returns
A constant reference to this system's _dof_map.

Definition at line 2448 of file system.h.

2449{
2450 return *_dof_map;
2451}

References libMesh::System::_dof_map.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::DifferentiableSystem::add_dot_var_dirichlet_bcs(), libMesh::System::add_matrix(), libMesh::HPCoarsenTest::add_projection(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::System::add_variable(), libMesh::System::add_variable_array(), libMesh::System::add_variables(), libMesh::AdaptiveTimeSolver::adjoint_advance_timestep(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::NewmarkSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::EquationSystems::allgather(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::allocate_data_structures(), alternative_fe_assembly(), LinearElasticity::assemble(), assemble(), assemble(), assemble_1D(), AssembleOptimization::assemble_A_and_F(), libMesh::ClawSystem::assemble_advection_matrices(), assemble_and_solve(), libMesh::ClawSystem::assemble_avg_coupling_matrices(), assemble_biharmonic(), libMesh::ClawSystem::assemble_boundary_condition_matrices(), assemble_divgrad(), assemble_elasticity(), assemble_ellipticdg(), assemble_func(), assemble_graddiv(), assemble_helmholtz(), libMesh::ClawSystem::assemble_jump_coupling_matrix(), assemble_laplace(), assemble_mass(), libMesh::ClawSystem::assemble_mass_matrix(), assemble_matrices(), assemble_matrix_and_rhs(), assemble_poisson(), assemble_poisson(), assemble_SchroedingerEquation(), assemble_shell(), assemble_shell(), assemble_stokes(), assemble_temperature_jump(), assemble_wave(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_sf(), compute_jacobian(), compute_residual(), LinearElasticity::compute_stresses(), LargeDeformationElasticity::compute_stresses(), LinearElasticityWithContact::compute_stresses(), compute_stresses(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), MyConstraint::constrain(), GhostDofConstraint::constrain(), libMesh::VariationalSmootherConstraint::constrain_node_to_line(), libMesh::VariationalSmootherConstraint::constrain_node_to_plane(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::ImplicitSystem::create_static_condensation_system_matrix(), create_wrapped_function(), DMCreateDomainDecomposition_libMesh(), DMCreateFieldDecomposition_libMesh(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), fe_assembly(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::VariationalSmootherConstraint::fix_node(), form_functionA(), form_functionB(), form_matrixA(), libMesh::System::get_all_variable_numbers(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::System::has_variable(), libMesh::SystemSubsetBySubdomain::init(), CoupledSystem::init_data(), HeatSystem::init_data(), PoissonSystem::init_data(), NavierSystem::init_data(), ElasticitySystem::init_data(), SimpleRBConstruction::init_data(), ElasticityRBConstruction::init_data(), NonlinearDiffusionSystem::init_data(), libMesh::ClawSystem::init_data(), libMesh::SecondOrderUnsteadySolver::init_data(), libMesh::UnsteadySolver::init_data(), SigmaPhysics::init_data(), LaplaceSystem::init_dirichlet_bcs(), NonManifoldCouplingTestBase::init_es(), libMesh::System::init_matrices(), libMesh::EigenSystem::init_matrices(), libMesh::PetscDMWrapper::init_petscdm(), libMesh::CondensedEigenSystem::initialize_condensed_dofs(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), LargeDeformationElasticity::jacobian(), LaplaceYoung::jacobian(), libMesh::System::late_matrix_init(), libMesh::System::local_dof_indices(), AssembleOptimization::lower_and_upper_bounds(), main(), libMesh::DofMap::max_constraint_error(), LinearElasticityWithContact::move_mesh(), libMesh::DGFEMContext::neighbor_side_fe_reinit(), libMesh::UnsteadySolver::old_nonlinear_solution(), libMesh::SecondOrderUnsteadySolver::old_solution_accel(), libMesh::SecondOrderUnsteadySolver::old_solution_rate(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SmoothnessEstimator::EstimateSmoothness::operator()(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::RBSCMConstruction::perform_SCM_greedy(), periodic_bc_test_poisson(), libMesh::petsc_auto_fieldsplit(), libMesh::ErrorVector::plot_error(), libMesh::FEMContext::pre_fe_reinit(), libMesh::InterMeshProjection::project_system_vectors(), libMesh::System::re_update(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), MeshFunctionTest::read_variable_info_from_output_data(), libMesh::System::reinit(), libMesh::SecondOrderUnsteadySolver::reinit(), libMesh::UnsteadySolver::reinit(), libMesh::System::reinit_constraints(), libMesh::System::reinit_dirichlet_constraint_values(), libMesh::EquationSystems::reinit_solutions(), LargeDeformationElasticity::residual(), LaplaceYoung::residual(), LinearElasticityWithContact::residual_and_jacobian(), libMesh::UnsteadySolver::retrieve_timestep(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), libMesh::HPCoarsenTest::select_refinement(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::RBConstruction::set_context_solution_vec(), libMesh::PetscPreconditioner< T >::set_hypre_ads_data(), libMesh::PetscPreconditioner< T >::set_hypre_ams_data(), libMesh::PetscDMWrapper::set_point_range_in_section(), set_system_parameters(), FETestBase< order, family, elem_type, build_nx, CaseName >::setUp(), SlitMeshRefinedSystemTest::setUp(), side_time_derivative(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::EigenSystem::solve(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), SystemsTest::test100KVariables(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), MeshFunctionTest::test_bad_gradient_var_with_out_of_mesh_value(), MeshFunctionTest::test_bad_hessian_var_with_out_of_mesh_value(), FEOrientationTestBase< order, family >::test_conformity_across_sides(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), ProjectSolutionTest::test_partial_project_solution(), MeshFunctionTest::test_subdomain_id_sets(), SystemsTest::testBlockRestrictedVarNDofs(), DofMapTest::testConstraintLoopDetection(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), EquationSystemsTest::testDisableDefaultGhosting(), SystemsTest::testDofCouplingWithVarGroups(), DofMapTest::testDofOwner(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), DofMapTest::testGhostConstraintSendList(), MeshAssignTest::testMeshMoveAssign(), HeterogeneousNonlinearConstraintTest::testNonzeroDirichletValues(), PeriodicBCTest::testPeriodicBC(), PeriodicBCTest::testPeriodicSideHierarchic(), SystemsTest::testPostInitAddVectorTypeChange(), SystemsTest::testProjectCubeWithMeshFunction(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), SystemsTest::testProjectScalarCoarsening(), PeriodicBCTest::testRedistributeToGhosts(), InfFERadialTest::testRefinement(), EquationSystemsTest::testSelectivePRefine(), BoundaryInfoTest::testShellFaceConstraints(), DisjointNeighborTest::testTempJump(), DisjointNeighborTest::testTempJumpRefine(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::UnsteadySolver::update(), update_current_local_solution(), libMesh::System::variable_number(), NonManifoldGhostingFunctorTest::verify_send_list_entries_helper(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), libMesh::ImplicitSystem::weighted_sensitivity_solve(), libMesh::Nemesis_IO_Helper::write_nodal_solution(), libMesh::System::write_parallel_data(), libMesh::EnsightIO::write_scalar_ascii(), libMesh::System::write_SCALAR_dofs(), libMesh::EnsightIO::write_vector_ascii(), and libMesh::RBConstruction::zero_constrained_dofs_on_vector().

◆ get_equation_systems() [1/2]

EquationSystems & libMesh::System::get_equation_systems ( )
inlineinherited
Returns
A reference to this system's parent EquationSystems object.

Definition at line 784 of file system.h.

784{ return _equation_systems; }
EquationSystems & _equation_systems
Constant reference to the EquationSystems object used for the simulation.
Definition system.h:2257

References libMesh::System::_equation_systems.

◆ get_equation_systems() [2/2]

const EquationSystems & libMesh::System::get_equation_systems ( ) const
inlineinherited
Returns
A constant reference to this system's parent EquationSystems object.

Definition at line 779 of file system.h.

779{ return _equation_systems; }

References libMesh::System::_equation_systems.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::RBSCMConstruction::add_scaled_symm_Aq(), libMesh::NewmarkSystem::clear(), libMesh::FrequencySystem::clear_all(), compute_jacobian(), compute_residual(), LinearElasticityWithContact::compute_stresses(), element_time_derivative(), libMesh::RBConstruction::enrich_basis_from_rhs_terms(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::ImplicitSystem::get_linear_solve_parameters(), HeatSystem::init_data(), init_data(), libMesh::FrequencySystem::init_data(), LaplaceYoung::jacobian(), libMesh::RBSCMConstruction::load_matrix_B(), LinearElasticityWithContact::move_mesh(), libMesh::FrequencySystem::n_frequencies(), libMesh::RBSCMConstruction::perform_SCM_greedy(), libMesh::InterMeshProjection::project_system_vectors(), libMesh::StaticCondensationDofMap::reinit(), LaplaceYoung::residual(), LinearElasticityWithContact::residual_and_jacobian(), libMesh::FileHistoryData::retrieve_adjoint_solution(), libMesh::FileHistoryData::retrieve_primal_solution(), libMesh::FileHistoryData::rewrite_stored_solution(), save_initial_mesh(), libMesh::FrequencySystem::set_current_frequency(), libMesh::FrequencySystem::set_frequencies(), libMesh::FrequencySystem::set_frequencies_by_range(), libMesh::FrequencySystem::set_frequencies_by_steps(), libMesh::PetscPreconditioner< T >::set_hypre_ads_data(), libMesh::PetscPreconditioner< T >::set_hypre_ams_data(), libMesh::NewmarkSystem::set_newmark_parameters(), libMesh::NonlinearImplicitSystem::set_solver_parameters(), side_time_derivative(), libMesh::CondensedEigenSystem::solve(), libMesh::EigenSystem::solve(), libMesh::FrequencySystem::solve(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), libMesh::EigenSystem::solve_helper(), libMesh::FileHistoryData::store_adjoint_solution(), libMesh::FileHistoryData::store_initial_solution(), libMesh::FileHistoryData::store_primal_solution(), MeshFunctionTest::test_p_level(), MeshFunctionTest::test_subdomain_id_sets(), MeshAssignTest::testMeshMoveAssign(), libMesh::DirectSolutionTransfer::transfer(), libMesh::DTKSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::RBConstruction::truth_solve(), and libMesh::WrappedFunction< Output >::WrappedFunction().

◆ get_first_order_vars()

const std::set< unsigned int > & libMesh::DifferentiablePhysics::get_first_order_vars ( ) const
inlineinherited
Returns
The set of first order in time variable indices. May be empty.

Definition at line 506 of file diff_physics.h.

507 { return _first_order_vars; }
std::set< unsigned int > _first_order_vars
Variable indices for those variables that are first order in time.

References libMesh::DifferentiablePhysics::_first_order_vars.

Referenced by libMesh::DifferentiableSystem::have_first_order_scalar_vars().

◆ get_info() [1/2]

std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

48{
49#if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
50
51 std::ostringstream oss;
52
53 oss << '\n'
54 << " ---------------------------------------------------------------------------- \n"
55 << "| Reference count information |\n"
56 << " ---------------------------------------------------------------------------- \n";
57
58 for (const auto & [name, cd] : _counts)
59 oss << "| " << name << " reference count information:\n"
60 << "| Creations: " << cd.first << '\n'
61 << "| Destructions: " << cd.second << '\n';
62
63 oss << " ---------------------------------------------------------------------------- \n";
64
65 return oss.str();
66
67#else
68
69 return "";
70
71#endif
72}
static Counts _counts
Actually holds the data.
std::string name(const ElemQuality q)
This function returns a string containing some name for q.

References libMesh::ReferenceCounter::_counts.

Referenced by libMesh::ReferenceCounter::print_info().

◆ get_info() [2/2]

std::string libMesh::System::get_info ( ) const
inherited
Returns
A string containing information about the system.

Definition at line 1882 of file system.C.

1883{
1884 std::ostringstream oss;
1885
1886
1887 const std::string & sys_name = this->name();
1888
1889 oss << " System #" << this->number() << ", \"" << sys_name << "\"\n"
1890 << " Type \"" << this->system_type() << "\"\n"
1891 << " Variables=";
1892
1893 for (auto vg : make_range(this->n_variable_groups()))
1894 {
1895 const VariableGroup & vg_description (this->variable_group(vg));
1896
1897 if (vg_description.n_variables() > 1) oss << "{ ";
1898 for (auto vn : make_range(vg_description.n_variables()))
1899 oss << "\"" << vg_description.name(vn) << "\" ";
1900 if (vg_description.n_variables() > 1) oss << "} ";
1901 }
1902
1903 oss << '\n';
1904
1905 oss << " Finite Element Types=";
1906#ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
1907 for (auto vg : make_range(this->n_variable_groups()))
1908 oss << "\""
1909 << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
1910 << "\" ";
1911#else
1912 for (auto vg : make_range(this->n_variable_groups()))
1913 {
1914 oss << "\""
1915 << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
1916 << "\", \""
1917 << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().radial_family)
1918 << "\" ";
1919 }
1920
1921 oss << '\n' << " Infinite Element Mapping=";
1922 for (auto vg : make_range(this->n_variable_groups()))
1923 oss << "\""
1924 << Utility::enum_to_string<InfMapType>(this->get_dof_map().variable_group(vg).type().inf_map)
1925 << "\" ";
1926#endif
1927
1928 oss << '\n';
1929
1930 oss << " Approximation Orders=";
1931 for (auto vg : make_range(this->n_variable_groups()))
1932 {
1933#ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
1934 oss << "\""
1935 << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
1936 << "\" ";
1937#else
1938 oss << "\""
1939 << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
1940 << "\", \""
1941 << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().radial_order)
1942 << "\" ";
1943#endif
1944 }
1945
1946 oss << '\n';
1947
1948 if (this->is_initialized())
1949 {
1950 oss << " n_dofs()=" << this->n_dofs() << '\n';
1951 dof_id_type local_dofs = this->n_local_dofs();
1952 oss << " n_local_dofs()=" << local_dofs << '\n';
1953 this->comm().max(local_dofs);
1954 oss << " max(n_local_dofs())=" << local_dofs << '\n';
1955#ifdef LIBMESH_ENABLE_CONSTRAINTS
1956 if (this->n_constrained_dofs())
1957 {
1958 oss << " n_constrained_dofs()=" << this->n_constrained_dofs() << '\n';
1959 oss << " n_local_constrained_dofs()=" << this->n_local_constrained_dofs() << '\n';
1960 dof_id_type local_unconstrained_dofs = this->n_local_dofs() - this->n_local_constrained_dofs();
1961 this->comm().max(local_unconstrained_dofs);
1962 oss << " max(local unconstrained dofs)=" << local_unconstrained_dofs << '\n';
1963 }
1964#endif
1965 if (this->has_static_condensation())
1966 oss << " n uncondensed dofs="
1967 << this->get_dof_map().get_static_condensation().n_dofs() << '\n';
1968 }
1969 else
1970 oss << " (still uninitialized)\n";
1971
1972 oss << " " << "n_vectors()=" << this->n_vectors() << '\n';
1973 oss << " " << "n_matrices()=" << this->n_matrices() << '\n';
1974 // oss << " " << "n_additional_matrices()=" << this->n_additional_matrices() << '\n';
1975
1976 oss << this->get_dof_map().get_info();
1977
1978 return oss.str();
1979}
dof_id_type n_dofs() const
StaticCondensationDofMap & get_static_condensation()
Definition dof_map.h:2949
std::string get_info() const
Gets summary info about the sparsity bandwidth and constraints.
Definition dof_map.C:3015
const std::string & name() const
Definition system.h:2416
bool is_initialized() const
Definition system.h:2488
virtual std::string system_type() const
Definition system.h:522
dof_id_type n_constrained_dofs() const
Definition system.C:127
dof_id_type n_local_constrained_dofs() const
Definition system.C:142
unsigned int number() const
Definition system.h:2424
uint8_t dof_id_type
Definition id_types.h:67

References libMesh::make_range(), libMesh::VariableGroup::n_variables(), and libMesh::VariableGroup::name().

Referenced by SystemsTest::testUninitializedInfo().

◆ get_linear_solve_parameters()

std::pair< unsigned int, Real > libMesh::DifferentiableSystem::get_linear_solve_parameters ( ) const
overridevirtualinherited
Returns
An integer corresponding to the upper iteration count limit and a Real corresponding to the convergence tolerance to be used in linear adjoint and/or sensitivity solves

Reimplemented from libMesh::ImplicitSystem.

Definition at line 172 of file diff_system.C.

173{
175 libmesh_assert_equal_to (&(time_solver->system()), this);
176 return std::make_pair(this->time_solver->diff_solver()->max_linear_iterations,
177 this->time_solver->diff_solver()->relative_residual_tolerance);
178}

References libMesh::libmesh_assert(), and libMesh::DifferentiableSystem::time_solver.

◆ get_linear_solver()

LinearSolver< Number > * libMesh::DifferentiableSystem::get_linear_solver ( ) const
overridevirtualinherited
Returns
A pointer to a linear solver appropriate for use in adjoint and/or sensitivity solves

Reimplemented from libMesh::ImplicitSystem.

Definition at line 163 of file diff_system.C.

164{
166 libmesh_assert_equal_to (&(time_solver->system()), this);
167 return this->time_solver->linear_solver().get();
168}

References libMesh::libmesh_assert(), and libMesh::DifferentiableSystem::time_solver.

Referenced by adjust_linear_solvers(), and main().

◆ get_matrix() [1/2]

SparseMatrix< Number > & libMesh::System::get_matrix ( std::string_view  mat_name)
inherited
Returns
A writable reference to this system's matrix named mat_name.

Definition at line 1174 of file system.C.

1175{
1176 return *libmesh_map_find(_matrices, mat_name);
1177}

References libMesh::System::_matrices.

◆ get_matrix() [2/2]

const SparseMatrix< Number > & libMesh::System::get_matrix ( std::string_view  mat_name) const
inherited

◆ get_mesh() [1/2]

MeshBase & libMesh::System::get_mesh ( )
inlineinherited
Returns
A reference to this systems's _mesh.

Definition at line 2440 of file system.h.

2441{
2442 return _mesh;
2443}

References libMesh::System::_mesh.

◆ get_mesh() [2/2]

const MeshBase & libMesh::System::get_mesh ( ) const
inlineinherited
Returns
A constant reference to this systems's _mesh.

Definition at line 2432 of file system.h.

2433{
2434 return _mesh;
2435}

References libMesh::System::_mesh.

Referenced by libMesh::ExactSolution::_compute_error(), LinearElasticityWithContact::add_contact_edge_elements(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::System::add_matrix(), libMesh::HPCoarsenTest::add_projection(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::DofMap::add_variables(), libMesh::System::assemble(), AssembleOptimization::assemble_A_and_F(), libMesh::ClawSystem::assemble_advection_matrices(), libMesh::ClawSystem::assemble_avg_coupling_matrices(), libMesh::ClawSystem::assemble_boundary_condition_matrices(), libMesh::ClawSystem::assemble_jump_coupling_matrix(), libMesh::ClawSystem::assemble_mass_matrix(), libMesh::FEMSystem::assemble_qoi(), libMesh::System::assemble_qoi(), libMesh::System::assemble_qoi_derivative(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::FEMSystem::assembly(), libMesh::NonlinearImplicitSystem::assembly(), libMesh::VariationalSmootherSystem::assembly(), AssemblyF0::boundary_assembly(), AssemblyF1::boundary_assembly(), AssemblyF2::boundary_assembly(), AssemblyA0::boundary_assembly(), AssemblyA1::boundary_assembly(), AssemblyA2::boundary_assembly(), centroid_l2_error(), compute_jacobian(), compute_residual(), LinearElasticityWithContact::compute_stresses(), libMesh::VariationalSmootherConstraint::constrain(), GhostDofConstraint::constrain(), libMesh::VariationalSmootherConstraint::constrain_node_to_line(), libMesh::VariationalSmootherConstraint::constrain_node_to_plane(), libMesh::ImplicitSystem::create_static_condensation_system_matrix(), libMesh::RBEIMEvaluation::distribute_bfs(), DMCreateDomainDecomposition_libMesh(), DMCreateFieldDecomposition_libMesh(), DMlibMeshSetSystem_libMesh(), NavierSystem::element_constraint(), HeatSystem::element_time_derivative(), NavierSystem::element_time_derivative(), element_time_derivative(), libMesh::RBConstruction::enrich_basis_from_rhs_terms(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::SmoothnessEstimator::estimate_smoothness(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::VariationalSmootherConstraint::fix_node(), NavierSystem::forcing(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::GenericProjector(), LinearElasticityWithContact::get_least_and_max_gap_function(), AssemblyPointLoadX::get_nodal_rhs_values(), AssemblyPointLoadY::get_nodal_rhs_values(), AssemblyPointLoadZ::get_nodal_rhs_values(), libMesh::SystemSubsetBySubdomain::init(), libMesh::RBEIMConstruction::init_context(), NavierSystem::init_data(), init_data(), ElasticitySystem::init_data(), ElasticityRBConstruction::init_data(), libMesh::System::init_data(), libMesh::System::init_matrices(), libMesh::PetscDMWrapper::init_petscdm(), LinearElasticityWithContact::initialize_contact_load_paths(), libMesh::RBEIMConstruction::initialize_qp_data(), libMesh::System::local_dof_indices(), NavierSystem::mass_residual(), libMesh::DofMap::max_constraint_error(), libMesh::FEMSystem::mesh_position_get(), libMesh::FEMSystem::mesh_position_set(), LinearElasticityWithContact::move_mesh(), libMesh::RBEIMEvaluation::node_distribute_bfs(), Integrate::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SmoothnessEstimator::EstimateSmoothness::operator()(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices::operator()(), libMesh::petsc_auto_fieldsplit(), NavierSystem::postprocess(), libMesh::FEMSystem::postprocess(), libMesh::RBParametrizedFunction::preevaluate_parametrized_function_on_mesh(), libMesh::RBParametrizedFunction::preevaluate_parametrized_function_on_mesh_sides(), libMesh::System::read_header(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::System::read_parallel_data(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::System::reinit(), LinearElasticityWithContact::residual_and_jacobian(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), save_initial_mesh(), libMesh::HPSingularity::select_refinement(), libMesh::HPCoarsenTest::select_refinement(), libMesh::PetscPreconditioner< T >::set_hypre_ads_data(), libMesh::PetscPreconditioner< T >::set_hypre_ams_data(), libMesh::PetscPreconditioner< T >::set_petsc_aux_data(), libMesh::PetscDMWrapper::set_point_range_in_section(), NavierSystem::side_constraint(), libMesh::RBEIMEvaluation::side_distribute_bfs(), side_time_derivative(), libMesh::PetscDiffSolver::solve(), libMesh::ClawSystem::solve_conservation_law(), DofMapTest::testGhostConstraintSendList(), MeshAssignTest::testMeshMoveAssign(), libMesh::BoundaryVolumeSolutionTransfer::transfer(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::BoundaryVolumeSolutionTransfer::transfer_volume_boundary(), libMesh::RBConstruction::truth_solve(), libMesh::TransientRBConstruction::truth_solve(), libMesh::System::write_header(), libMesh::RBEvaluation::write_out_vectors(), libMesh::System::write_parallel_data(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), and libMesh::System::zero_variable().

◆ get_mesh_system() [1/2]

System * libMesh::DifferentiablePhysics::get_mesh_system ( )
inlineinherited
Returns
A reference to the system with variables corresponding to mesh nodal coordinates, or nullptr if the mesh is fixed.

Definition at line 619 of file diff_physics.h.

620{
621 return _mesh_sys;
622}
System * _mesh_sys
System from which to acquire moving mesh information.

References libMesh::DifferentiablePhysics::_mesh_sys.

◆ get_mesh_system() [2/2]

const System * libMesh::DifferentiablePhysics::get_mesh_system ( ) const
inlineinherited
Returns
A const reference to the system with variables corresponding to mesh nodal coordinates, or nullptr if the mesh is fixed. Useful for ALE calculations.

Definition at line 613 of file diff_physics.h.

614{
615 return _mesh_sys;
616}

References libMesh::DifferentiablePhysics::_mesh_sys.

Referenced by libMesh::FEMSystem::build_context().

◆ get_mesh_x_var()

unsigned int libMesh::DifferentiablePhysics::get_mesh_x_var ( ) const
inlineinherited
Returns
The variable number corresponding to the mesh x coordinate. Useful for ALE calculations.

Definition at line 625 of file diff_physics.h.

626{
627 return _mesh_x_var;
628}
unsigned int _mesh_x_var
Variables from which to acquire moving mesh information.

References libMesh::DifferentiablePhysics::_mesh_x_var.

Referenced by libMesh::FEMSystem::build_context().

◆ get_mesh_y_var()

unsigned int libMesh::DifferentiablePhysics::get_mesh_y_var ( ) const
inlineinherited
Returns
The variable number corresponding to the mesh y coordinate. Useful for ALE calculations.

Definition at line 631 of file diff_physics.h.

632{
633 return _mesh_y_var;
634}

References libMesh::DifferentiablePhysics::_mesh_y_var.

Referenced by libMesh::FEMSystem::build_context().

◆ get_mesh_z_var()

unsigned int libMesh::DifferentiablePhysics::get_mesh_z_var ( ) const
inlineinherited
Returns
The variable number corresponding to the mesh z coordinate. Useful for ALE calculations.

Definition at line 637 of file diff_physics.h.

638{
639 return _mesh_z_var;
640}

References libMesh::DifferentiablePhysics::_mesh_z_var.

Referenced by libMesh::FEMSystem::build_context().

◆ get_physics() [1/2]

DifferentiablePhysics * libMesh::DifferentiableSystem::get_physics ( )
inlineinherited
Returns
A reference to a DifferentiablePhysics object.
Note
If no external Physics object is attached, the default is this.

Definition at line 192 of file diff_system.h.

193 { if (this->_diff_physics.empty())
194 return this;
195 return this->_diff_physics.top().get(); }

References libMesh::DifferentiableSystem::_diff_physics.

◆ get_physics() [2/2]

const DifferentiablePhysics * libMesh::DifferentiableSystem::get_physics ( ) const
inlineinherited

◆ get_project_with_constraints()

bool libMesh::System::get_project_with_constraints ( )
inlineinherited

Setter and getter functions for project_with_constraints boolean.

Definition at line 1849 of file system.h.

1850 {
1852 }
bool project_with_constraints
Do we want to apply constraints while projecting vectors ?
Definition system.h:2369

References libMesh::System::project_with_constraints.

Referenced by libMesh::AdjointRefinementEstimator::estimate_error().

◆ get_qoi() [1/2]

DifferentiableQoI * libMesh::DifferentiableSystem::get_qoi ( )
inlineinherited
Returns
A reference to a DifferentiableQoI object.
Note
If no external QoI object is attached, the default is this.

Definition at line 231 of file diff_system.h.

232 { if (this->_diff_qoi.empty())
233 return this;
234 return this->_diff_qoi.top().get(); }

References libMesh::DifferentiableSystem::_diff_qoi.

◆ get_qoi() [2/2]

const DifferentiableQoI * libMesh::DifferentiableSystem::get_qoi ( ) const
inlineinherited
Returns
A const reference to a DifferentiableQoI object.
Note
If no external QoI object is attached, the default is this.

Definition at line 221 of file diff_system.h.

222 { if (this->_diff_qoi.empty())
223 return this;
224 return this->_diff_qoi.top().get(); }

References libMesh::DifferentiableSystem::_diff_qoi.

Referenced by libMesh::FEMSystem::assemble_qoi(), and libMesh::FEMSystem::assemble_qoi_derivative().

◆ get_qoi_error_estimate_value()

Number libMesh::System::get_qoi_error_estimate_value ( unsigned int  qoi_index) const
inherited

Definition at line 2266 of file system.C.

2267{
2268 libmesh_assert(qoi_index < _qoi_error_estimates.size());
2269 return _qoi_error_estimates[qoi_index];
2270}
std::vector< Number > _qoi_error_estimates
Vector to hold error estimates for qois, either from a steady state calculation, or from a single uns...
Definition system.h:2408

References libMesh::libmesh_assert().

Referenced by libMesh::TwostepTimeSolver::integrate_adjoint_refinement_error_estimate(), and main().

◆ get_qoi_value()

Number libMesh::System::get_qoi_value ( unsigned int  qoi_index) const
inherited

◆ get_qoi_values()

std::vector< Number > libMesh::System::get_qoi_values ( ) const
inherited

◆ get_second_order_dot_var()

unsigned int libMesh::DifferentiableSystem::get_second_order_dot_var ( unsigned int  var) const
inherited

For a given second order (in time) variable var, this method will return the index to the corresponding "dot" variable.

For FirstOrderUnsteadySolver classes, the "dot" variable would automatically be added and the returned index will correspond to that variable. For SecondOrderUnsteadySolver classes, this method will return var as there this is no "dot" variable per se, but having this function allows one to use the interface to treat both FirstOrderUnsteadySolver and SecondOrderUnsteadySolver simultaneously.

Definition at line 288 of file diff_system.C.

289{
290 // For SteadySolver or SecondOrderUnsteadySolvers, we just give back var
291 unsigned int dot_var = var;
292
293 if (!time_solver->is_steady())
294 {
295 const UnsteadySolver & unsteady_solver =
296 cast_ref<const UnsteadySolver &>(*(time_solver.get()));
297
298 if (unsteady_solver.time_order() == 1)
299 dot_var = this->_second_order_dot_vars.find(var)->second;
300 }
301
302 return dot_var;
303}

References libMesh::DifferentiablePhysics::_second_order_dot_vars, libMesh::UnsteadySolver::time_order(), and libMesh::DifferentiableSystem::time_solver.

Referenced by libMesh::FirstOrderUnsteadySolver::compute_second_order_eqns(), SecondOrderScalarSystemFirstOrderTimeSolverBase::damping_residual(), ElasticitySystem::element_time_derivative(), SecondOrderScalarSystemFirstOrderTimeSolverBase::element_time_derivative(), ElasticitySystem::mass_residual(), SecondOrderScalarSystemFirstOrderTimeSolverBase::mass_residual(), and ElasticitySystem::side_time_derivative().

◆ get_second_order_vars()

const std::set< unsigned int > & libMesh::DifferentiablePhysics::get_second_order_vars ( ) const
inlineinherited
Returns
The set of second order in time variable indices. May be empty.

Definition at line 519 of file diff_physics.h.

520 { return _second_order_vars; }
std::set< unsigned int > _second_order_vars
Variable indices for those variables that are second order in time.

References libMesh::DifferentiablePhysics::_second_order_vars.

Referenced by libMesh::DifferentiableSystem::add_second_order_dot_vars(), libMesh::DiffContext::DiffContext(), libMesh::Euler2Solver::element_residual(), libMesh::DifferentiableSystem::have_second_order_scalar_vars(), and libMesh::FEMContext::pre_fe_reinit().

◆ get_sensitivity_rhs() [1/2]

NumericVector< Number > & libMesh::System::get_sensitivity_rhs ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's sensitivity rhs vectors, by default the one corresponding to the first parameter. By default these vectors are built by the library, using finite differences, when assemble_residual_derivatives() is called.

When assembled, this vector should hold -(partial R / partial p_i)

Definition at line 1380 of file system.C.

1381{
1382 std::ostringstream sensitivity_rhs_name;
1383 sensitivity_rhs_name << "sensitivity_rhs" << i;
1384
1385 return this->get_vector(sensitivity_rhs_name.str());
1386}

References libMesh::System::get_vector().

Referenced by libMesh::ImplicitSystem::adjoint_qoi_parameter_sensitivity(), and libMesh::ImplicitSystem::sensitivity_solve().

◆ get_sensitivity_rhs() [2/2]

const NumericVector< Number > & libMesh::System::get_sensitivity_rhs ( unsigned int  i = 0) const
inherited
Returns
A reference to one of the system's sensitivity rhs vectors, by default the one corresponding to the first parameter.

Definition at line 1390 of file system.C.

1391{
1392 std::ostringstream sensitivity_rhs_name;
1393 sensitivity_rhs_name << "sensitivity_rhs" << i;
1394
1395 return this->get_vector(sensitivity_rhs_name.str());
1396}

References libMesh::System::get_vector().

◆ get_sensitivity_solution() [1/2]

NumericVector< Number > & libMesh::System::get_sensitivity_solution ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's solution sensitivity vectors, by default the one corresponding to the first parameter.

Definition at line 1235 of file system.C.

1236{
1237 std::ostringstream sensitivity_name;
1238 sensitivity_name << "sensitivity_solution" << i;
1239
1240 return this->get_vector(sensitivity_name.str());
1241}

References libMesh::System::get_vector().

Referenced by libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity(), libMesh::ImplicitSystem::qoi_parameter_hessian(), and libMesh::ImplicitSystem::sensitivity_solve().

◆ get_sensitivity_solution() [2/2]

const NumericVector< Number > & libMesh::System::get_sensitivity_solution ( unsigned int  i = 0) const
inherited
Returns
A reference to one of the system's solution sensitivity vectors, by default the one corresponding to the first parameter.

Definition at line 1245 of file system.C.

1246{
1247 std::ostringstream sensitivity_name;
1248 sensitivity_name << "sensitivity_solution" << i;
1249
1250 return this->get_vector(sensitivity_name.str());
1251}

References libMesh::System::get_vector().

◆ get_static_condensation()

StaticCondensation & libMesh::ImplicitSystem::get_static_condensation ( )
inlineinherited
Returns
The static condensation system matrix

Definition at line 362 of file implicit_system.h.

363{
365 return *_sc_system_matrix;
366}

References libMesh::ImplicitSystem::_sc_system_matrix, and libMesh::libmesh_assert().

Referenced by assemble_poisson(), and libMesh::ImplicitSystem::create_static_condensation_system_matrix().

◆ get_system_matrix() [1/2]

SparseMatrix< Number > & libMesh::ImplicitSystem::get_system_matrix ( )
inherited
Returns
A reference to the system's primary matrix.

Definition at line 1260 of file implicit_system.C.

1261{
1263 libmesh_assert_equal_to(&get_matrix("System Matrix"), matrix);
1264 return *matrix;
1265}
const SparseMatrix< Number > & get_matrix(std::string_view mat_name) const
Definition system.C:1167

References libMesh::System::get_matrix(), libMesh::libmesh_assert(), and libMesh::ImplicitSystem::matrix.

◆ get_system_matrix() [2/2]

const SparseMatrix< Number > & libMesh::ImplicitSystem::get_system_matrix ( ) const
inherited

◆ get_time_solver() [1/2]

TimeSolver & libMesh::DifferentiableSystem::get_time_solver ( )
inlineinherited

◆ get_time_solver() [2/2]

const TimeSolver & libMesh::DifferentiableSystem::get_time_solver ( ) const
inlineinherited

Non-const version of the above.

Definition at line 456 of file diff_system.h.

457{
459 libmesh_assert_equal_to (&(time_solver->system()), this);
460 return *time_solver;
461}

References libMesh::libmesh_assert(), and libMesh::DifferentiableSystem::time_solver.

◆ get_vector() [1/4]

NumericVector< Number > & libMesh::System::get_vector ( const unsigned int  vec_num)
inherited
Returns
A writable reference to this system's additional vector number vec_num (where the vectors are counted starting with 0).

Definition at line 998 of file system.C.

999{
1000 // If we don't have that many vectors, throw an error
1001 libmesh_assert_less(vec_num, _vectors.size());
1002
1003 // Otherwise return a reference to the vec_num'th vector
1004 auto it = vectors_begin();
1005 std::advance(it, vec_num);
1006 return *(it->second);
1007}
vectors_iterator vectors_begin()
Beginning of vectors container.
Definition system.h:2536

References libMesh::System::_vectors, and libMesh::System::vectors_begin().

◆ get_vector() [2/4]

const NumericVector< Number > & libMesh::System::get_vector ( const unsigned int  vec_num) const
inherited
Returns
A const reference to this system's additional vector number vec_num (where the vectors are counted starting with 0).

Definition at line 985 of file system.C.

986{
987 // If we don't have that many vectors, throw an error
988 libmesh_assert_less(vec_num, _vectors.size());
989
990 // Otherwise return a reference to the vec_num'th vector
991 auto it = vectors_begin();
992 std::advance(it, vec_num);
993 return *(it->second);
994}

References libMesh::System::_vectors, and libMesh::System::vectors_begin().

◆ get_vector() [3/4]

NumericVector< Number > & libMesh::System::get_vector ( std::string_view  vec_name)
inherited
Returns
A writable reference to this system's additional vector named vec_name. Access is only granted when the vector is already properly initialized.

Definition at line 978 of file system.C.

979{
980 return *(libmesh_map_find(_vectors, vec_name));
981}

References libMesh::System::_vectors.

◆ get_vector() [4/4]

const NumericVector< Number > & libMesh::System::get_vector ( std::string_view  vec_name) const
inherited
Returns
A const reference to this system's additional vector named vec_name. Access is only granted when the vector is already properly initialized.

Definition at line 971 of file system.C.

972{
973 return *(libmesh_map_find(_vectors, vec_name));
974}

References libMesh::System::_vectors.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), add_M_C_K_helmholtz(), libMesh::AdaptiveTimeSolver::adjoint_advance_timestep(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::NewmarkSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), apply_initial(), assemble(), libMesh::System::compare(), libMesh::NewmarkSolver::compute_initial_accel(), libMesh::UnsteadySolver::du(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::System::get_adjoint_rhs(), libMesh::System::get_adjoint_rhs(), libMesh::System::get_adjoint_solution(), libMesh::System::get_adjoint_solution(), libMesh::System::get_sensitivity_rhs(), libMesh::System::get_sensitivity_rhs(), libMesh::System::get_sensitivity_solution(), libMesh::System::get_sensitivity_solution(), libMesh::System::get_weighted_sensitivity_adjoint_solution(), libMesh::System::get_weighted_sensitivity_adjoint_solution(), libMesh::System::get_weighted_sensitivity_solution(), libMesh::System::get_weighted_sensitivity_solution(), libMesh::NewmarkSystem::initial_conditions(), AssembleOptimization::lower_and_upper_bounds(), main(), libMesh::NewmarkSolver::project_initial_accel(), libMesh::SecondOrderUnsteadySolver::project_initial_rate(), libMesh::InterMeshProjection::project_system_vectors(), libMesh::SecondOrderUnsteadySolver::reinit(), libMesh::UnsteadySolver::reinit(), libMesh::FileSolutionHistory::retrieve(), libMesh::UnsteadySolver::retrieve_timestep(), libMesh::MemoryHistoryData::retrieve_vectors(), libMesh::TwostepTimeSolver::solve(), libMesh::FrequencySystem::solve(), SystemsTest::testPetscOptionsPrefix(), libMesh::UnsteadySolver::update(), libMesh::NewmarkSystem::update_rhs(), and libMesh::NewmarkSystem::update_u_v_a().

◆ get_weighted_sensitivity_adjoint_solution() [1/2]

NumericVector< Number > & libMesh::System::get_weighted_sensitivity_adjoint_solution ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's weighted sensitivity adjoint solution vectors, by default the one corresponding to the first qoi.

Definition at line 1320 of file system.C.

1321{
1322 std::ostringstream adjoint_name;
1323 adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1324
1325 return this->get_vector(adjoint_name.str());
1326}

References libMesh::System::get_vector().

Referenced by libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().

◆ get_weighted_sensitivity_adjoint_solution() [2/2]

const NumericVector< Number > & libMesh::System::get_weighted_sensitivity_adjoint_solution ( unsigned int  i = 0) const
inherited
Returns
A reference to one of the system's weighted sensitivity adjoint solution vectors, by default the one corresponding to the first qoi.

Definition at line 1330 of file system.C.

1331{
1332 std::ostringstream adjoint_name;
1333 adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1334
1335 return this->get_vector(adjoint_name.str());
1336}

References libMesh::System::get_vector().

◆ get_weighted_sensitivity_solution() [1/2]

NumericVector< Number > & libMesh::System::get_weighted_sensitivity_solution ( )
inherited
Returns
A reference to the solution of the last weighted sensitivity solve

Definition at line 1262 of file system.C.

1263{
1264 return this->get_vector("weighted_sensitivity_solution");
1265}

References libMesh::System::get_vector().

Referenced by libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), and libMesh::ImplicitSystem::weighted_sensitivity_solve().

◆ get_weighted_sensitivity_solution() [2/2]

const NumericVector< Number > & libMesh::System::get_weighted_sensitivity_solution ( ) const
inherited
Returns
A reference to the solution of the last weighted sensitivity solve

Definition at line 1269 of file system.C.

1270{
1271 return this->get_vector("weighted_sensitivity_solution");
1272}

References libMesh::System::get_vector().

◆ has_constraint_object()

bool libMesh::System::has_constraint_object ( ) const
inherited
Returns
true if there is a user-defined constraint object attached to this object, false otherwise. Calling System:: get_constraint_object() when there is no user-defined constraint object attached leads to either undefined behavior (dereferencing a nullptr) or an assert (in dbg mode) so you should call this function first unless you are sure there is a user-defined constraint object attached.

Definition at line 2074 of file system.C.

2075{
2076 return _constrain_system_object != nullptr;
2077}

◆ has_static_condensation()

bool libMesh::System::has_static_condensation ( ) const
inherited

◆ has_variable()

bool libMesh::System::has_variable ( std::string_view  var) const
inherited
Returns
true if a variable named var exists in this System

Definition at line 1449 of file system.C.

1450{
1451 return this->get_dof_map().has_variable(var);
1452}
bool has_variable(std::string_view var) const
Definition dof_map.h:3076

References libMesh::System::get_dof_map(), and libMesh::DofMap::has_variable().

Referenced by libMesh::ExactSolution::compute_error(), libMesh::GMVIO::copy_nodal_solution(), and main().

◆ have_first_order_scalar_vars()

bool libMesh::DifferentiableSystem::have_first_order_scalar_vars ( ) const
inherited

Check for any first order vars that are also belong to FEFamily::SCALAR.

Definition at line 305 of file diff_system.C.

306{
307 bool have_first_order_scalar_vars = false;
308
309 if (this->have_first_order_vars())
310 for (const auto & var : this->get_first_order_vars())
311 if (this->variable(var).type().family == SCALAR)
313
315}
const std::set< unsigned int > & get_first_order_vars() const
bool have_first_order_scalar_vars() const
Check for any first order vars that are also belong to FEFamily::SCALAR.

References libMesh::FEType::family, libMesh::DifferentiablePhysics::get_first_order_vars(), libMesh::DifferentiableSystem::have_first_order_scalar_vars(), libMesh::DifferentiablePhysics::have_first_order_vars(), libMesh::SCALAR, libMesh::Variable::type(), and libMesh::System::variable().

Referenced by libMesh::DifferentiableSystem::have_first_order_scalar_vars().

◆ have_first_order_vars()

bool libMesh::DifferentiablePhysics::have_first_order_vars ( ) const
inlineinherited

◆ have_matrix()

bool libMesh::System::have_matrix ( std::string_view  mat_name) const
inlineinherited
Returns
true if this System has a matrix associated with the given name, false otherwise.

Definition at line 1945 of file system.h.

1945{ return _matrices.count(mat_name); }

References libMesh::System::_matrices.

Referenced by libMesh::EigenTimeSolver::init().

◆ have_second_order_scalar_vars()

bool libMesh::DifferentiableSystem::have_second_order_scalar_vars ( ) const
inherited

Check for any second order vars that are also belong to FEFamily::SCALAR.

Definition at line 317 of file diff_system.C.

318{
320
321 if (this->have_second_order_vars())
322 for (const auto & var : this->get_second_order_vars())
323 if (this->variable(var).type().family == SCALAR)
325
327}
bool have_second_order_scalar_vars() const
Check for any second order vars that are also belong to FEFamily::SCALAR.

References libMesh::FEType::family, libMesh::DifferentiablePhysics::get_second_order_vars(), libMesh::DifferentiableSystem::have_second_order_scalar_vars(), libMesh::DifferentiablePhysics::have_second_order_vars(), libMesh::SCALAR, libMesh::Variable::type(), and libMesh::System::variable().

Referenced by libMesh::DifferentiableSystem::have_second_order_scalar_vars(), libMesh::Euler2Solver::nonlocal_residual(), and libMesh::EulerSolver::nonlocal_residual().

◆ have_second_order_vars()

bool libMesh::DifferentiablePhysics::have_second_order_vars ( ) const
inlineinherited

◆ have_vector()

bool libMesh::System::have_vector ( std::string_view  vec_name) const
inlineinherited
Returns
true if this System has a vector associated with the given name, false otherwise.

Definition at line 2522 of file system.h.

2523{
2524 return (_vectors.count(vec_name));
2525}

References libMesh::System::_vectors.

◆ hide_output()

bool & libMesh::System::hide_output ( )
inlineinherited
Returns
A writable reference to a boolean that determines if this system can be written to file or not. If set to true, then EquationSystems::write will ignore this system.

Definition at line 1864 of file system.h.

1864{ return _hide_output; }
bool _hide_output
Are we allowed to write this system to file? If _hide_output is true, then EquationSystems::write wil...
Definition system.h:2364

References libMesh::System::_hide_output.

Referenced by libMesh::StaticCondensationDofMap::reinit(), libMesh::PetscPreconditioner< T >::set_hypre_ads_data(), and libMesh::PetscPreconditioner< T >::set_hypre_ams_data().

◆ identify_variable_groups() [1/2]

bool libMesh::System::identify_variable_groups ( ) const
inherited
Returns
true when VariableGroup structures should be automatically identified, false otherwise.

Definition at line 2739 of file system.C.

2740{
2741 return this->get_dof_map().identify_variable_groups();
2742}
bool identify_variable_groups() const
Definition dof_map.h:3041

◆ identify_variable_groups() [2/2]

void libMesh::System::identify_variable_groups ( const bool  ivg)
inherited

Toggle automatic VariableGroup identification.

Definition at line 2744 of file system.C.

2745{
2747}

◆ increment_constructor_count()

void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
inlineprotectednoexceptinherited

Increments the construction counter.

Should be called in the constructor of any derived class that will be reference counted.

Definition at line 183 of file reference_counter.h.

184{
185 libmesh_try
186 {
187 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
188 std::pair<unsigned int, unsigned int> & p = _counts[name];
189 p.first++;
190 }
191 libmesh_catch (...)
192 {
193 auto stream = libMesh::err.get();
194 stream->exceptions(stream->goodbit); // stream must not throw
195 libMesh::err << "Encountered unrecoverable error while calling "
196 << "ReferenceCounter::increment_constructor_count() "
197 << "for a(n) " << name << " object." << std::endl;
198 std::terminate();
199 }
200}
streamT * get()
Rather than implement every ostream/ios/ios_base function, we'll be lazy and make esoteric uses go th...
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition threads.C:30

References libMesh::err, libMesh::BasicOStreamProxy< charT, traits >::get(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< T >::ReferenceCountedObject(), libMesh::ReferenceCountedObject< T >::ReferenceCountedObject(), and libMesh::ReferenceCountedObject< T >::ReferenceCountedObject().

◆ increment_destructor_count()

void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
inlineprotectednoexceptinherited

Increments the destruction counter.

Should be called in the destructor of any derived class that will be reference counted.

Definition at line 207 of file reference_counter.h.

208{
209 libmesh_try
210 {
211 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
212 std::pair<unsigned int, unsigned int> & p = _counts[name];
213 p.second++;
214 }
215 libmesh_catch (...)
216 {
217 auto stream = libMesh::err.get();
218 stream->exceptions(stream->goodbit); // stream must not throw
219 libMesh::err << "Encountered unrecoverable error while calling "
220 << "ReferenceCounter::increment_destructor_count() "
221 << "for a(n) " << name << " object." << std::endl;
222 std::terminate();
223 }
224}

References libMesh::err, libMesh::BasicOStreamProxy< charT, traits >::get(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< T >::~ReferenceCountedObject().

◆ init()

void libMesh::System::init ( )
inherited

Initializes degrees of freedom on the current mesh.

Sets the

Definition at line 198 of file system.C.

199{
200 // Calling init() twice on the same system currently works evil
201 // magic, whether done directly or via EquationSystems::read()
203
204 this->reinit_mesh();
205}
virtual void reinit_mesh()
Reinitializes the system with a new mesh.
Definition system.C:296

References libMesh::System::is_initialized(), libMesh::libmesh_assert(), and libMesh::System::reinit_mesh().

Referenced by libMesh::StaticCondensationDofMap::reinit(), and NonlinearImplicitSystemOperatorMatrixTest::setUp().

◆ init_context()

void SolidSystem::init_context ( DiffContext &  context)
virtual

Reimplemented from libMesh::FEMSystem.

Definition at line 146 of file solid_system.C.

147{
148 FEMContext & c = cast_ref<FEMContext &>(context);
149
150 // Pre-request all the data needed
151 FEBase * elem_fe = nullptr;
152 c.get_element_fe(0, elem_fe);
153
154 elem_fe->get_JxW();
155 elem_fe->get_phi();
156 elem_fe->get_dphi();
157 elem_fe->get_xyz();
158
159 FEBase * side_fe = nullptr;
160 c.get_side_fe(0, side_fe);
161
162 side_fe->get_JxW();
163 side_fe->get_phi();
164 side_fe->get_xyz();
165}
virtual_for_inffe const std::vector< Point > & get_xyz() const
const std::vector< std::vector< OutputShape > > & get_phi() const
Definition fe_base.h:207
void get_side_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for edge/face (2D/3D) finite element object for variable var for the largest dimension in th...

References libMesh::FEGenericBase< OutputType >::get_dphi(), libMesh::FEMContext::get_element_fe(), libMesh::FEAbstract::get_JxW(), libMesh::FEGenericBase< OutputType >::get_phi(), libMesh::FEMContext::get_side_fe(), and libMesh::FEAbstract::get_xyz().

◆ init_data()

void SolidSystem::init_data ( )
virtual

Initializes the member data fields associated with the system, so that, e.g., assemble() may be used.

Reimplemented from libMesh::FEMSystem.

Definition at line 76 of file solid_system.C.

77{
78 const unsigned int dim = this->get_mesh().mesh_dimension();
79
80 // Get the default order of the used elements. Assumption:
81 // Just one type of elements in the mesh.
82 Order order = (*(this->get_mesh().elements_begin()))->default_order();
83
84 // Add the node positions as primary variables.
85 var[0] = this->add_variable("x", order);
86 var[1] = this->add_variable("y", order);
87 if (dim == 3)
88 var[2] = this->add_variable("z", order);
89 else
90 var[2] = var[1];
91
92 // Add variables for storing the initial mesh to an auxiliary system.
93 System & aux_sys = this->get_equation_systems().get_system("auxiliary");
94 undefo_var[0] = aux_sys.add_variable("undefo_x", order);
95 undefo_var[1] = aux_sys.add_variable("undefo_y", order);
96 undefo_var[2] = aux_sys.add_variable("undefo_z", order);
97
98 // Set the time stepping options
99 this->deltat = args("schedule/dt", 0.2);
100
101 // Do the parent's initialization after variables are defined
102 FEMSystem::init_data();
103
106 //this->time_evolving(var[0]);
107 //this->time_evolving(var[1]);
108 //if (dim == 3)
109 //this->time_evolving(var[2]);
110
111 // Tell the system which variables are containing the node positions
112 set_mesh_system(this);
113
114 this->set_mesh_x_var(var[0]);
115 this->set_mesh_y_var(var[1]);
116 if (dim == 3)
117 this->set_mesh_z_var(var[2]);
118
119 // Fill the variables with the position of the nodes
120 this->mesh_position_get();
121
122 System::reinit();
123
124 // Set some options for the DiffSolver
125 DiffSolver & solver = *(this->time_solver->diff_solver().get());
126 solver.quiet = args("solver/quiet", false);
127 solver.max_nonlinear_iterations = args("solver/nonlinear/max_nonlinear_iterations", 100);
128 solver.relative_step_tolerance = args("solver/nonlinear/relative_step_tolerance", 1.e-3);
129 solver.relative_residual_tolerance = args("solver/nonlinear/relative_residual_tolerance", 1.e-8);
130 solver.absolute_residual_tolerance = args("solver/nonlinear/absolute_residual_tolerance", 1.e-8);
131 solver.verbose = !args("solver/quiet", false);
132
133 ((NewtonSolver &) solver).require_residual_reduction = args("solver/nonlinear/require_reduction", false);
134
135 // And the linear solver options
136 solver.max_linear_iterations = args("max_linear_iterations", 50000);
137 solver.initial_linear_tolerance = args("initial_linear_tolerance", 1.e-3);
138}
This is a generic class that defines a solver to handle ImplicitSystem classes, including NonlinearIm...
Definition diff_solver.h:70
Real absolute_residual_tolerance
The DiffSolver should exit after the residual is reduced to either less than absolute_residual_tolera...
unsigned int max_linear_iterations
Each linear solver step should exit after max_linear_iterations is exceeded.
double initial_linear_tolerance
Any required linear solves will at first be done with this tolerance; the DiffSolver may tighten the ...
bool verbose
The DiffSolver may print a lot more to libMesh::out if verbose is set to true; default is false.
unsigned int max_nonlinear_iterations
The DiffSolver should exit in failure if max_nonlinear_iterations is exceeded and continue_after_max_...
bool quiet
The DiffSolver should not print anything to libMesh::out unless quiet is set to false; default is tru...
virtual void set_mesh_y_var(unsigned int var)
Tells the DifferentiablePhysics that variable var from the mesh system should be used to update the y...
virtual void set_mesh_x_var(unsigned int var)
Tells the DifferentiablePhysics that variable var from the mesh system should be used to update the x...
virtual void set_mesh_system(System *sys)
Tells the DifferentiablePhysics that system sys contains the isoparametric Lagrangian variables which...
virtual void set_mesh_z_var(unsigned int var)
Tells the DifferentiablePhysics that variable var from the mesh system should be used to update the z...
void mesh_position_get()
Tells the FEMSystem to set the degree of freedom coefficients which should correspond to mesh nodal c...
This class defines a solver which uses the default libMesh linear solver in a quasiNewton method to h...
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition system.h:100

References libMesh::DiffSolver::absolute_residual_tolerance, libMesh::System::add_variable(), args, libMesh::DifferentiableSystem::deltat, dim, libMesh::System::get_equation_systems(), libMesh::System::get_mesh(), libMesh::EquationSystems::get_system(), libMesh::DiffSolver::initial_linear_tolerance, libMesh::DiffSolver::max_linear_iterations, libMesh::DiffSolver::max_nonlinear_iterations, libMesh::MeshBase::mesh_dimension(), libMesh::FEMSystem::mesh_position_get(), libMesh::DiffSolver::quiet, libMesh::DiffSolver::relative_residual_tolerance, libMesh::DiffSolver::relative_step_tolerance, libMesh::DifferentiablePhysics::set_mesh_system(), libMesh::DifferentiablePhysics::set_mesh_x_var(), libMesh::DifferentiablePhysics::set_mesh_y_var(), libMesh::DifferentiablePhysics::set_mesh_z_var(), libMesh::DifferentiableSystem::time_solver, undefo_var, var, and libMesh::DiffSolver::verbose.

◆ init_matrices()

void libMesh::System::init_matrices ( )
protectedvirtualinherited

Initializes the matrices associated with this system.

Reimplemented in libMesh::EigenSystem.

Definition at line 318 of file system.C.

319{
320 parallel_object_only();
321
322 // No matrices to init
323 if (_matrices.empty())
324 {
325 // any future matrices to be added will need their own
326 // initialization
328
329 return;
330 }
331
332 // Check for quick return in case the first matrix
333 // (and by extension all the matrices) has already
334 // been initialized
335 if (_matrices.begin()->second->initialized())
336 {
338 return;
339 }
340
342
343 // Tell the matrices about the dof map, and vice versa
344 for (auto & pr : _matrices)
345 {
346 SparseMatrix<Number> & m = *(pr.second);
347 libmesh_assert (!m.initialized());
348
349 // We want to allow repeated init() on systems, but we don't
350 // want to attach the same matrix to the DofMap twice
351 if (!this->get_dof_map().is_attached(m))
352 this->get_dof_map().attach_matrix(m);
353
354 // If the user has already explicitly requested that this matrix use a hash table, then we
355 // always honor that
356 const bool use_hash =
357 pr.second->use_hash_table() ||
358 (this->_prefer_hash_table_matrix_assembly && pr.second->supports_hash_table());
359 pr.second->use_hash_table(use_hash);
360 // Make this call after we've determined whether the matrix is using a hash table
361 if (pr.second->require_sparsity_pattern())
362 this->_require_sparsity_pattern = true;
363 }
364
365 // Compute the sparsity pattern for the current
366 // mesh and DOF distribution. This also updates
367 // additional matrices, \p DofMap now knows them
369 this->get_dof_map().compute_sparsity(this->get_mesh());
370
371 // Initialize matrices and set to zero
372 for (auto & [name, mat] : _matrices)
373 {
374 mat->init(_matrix_types[name]);
375 mat->zero();
376 }
377}
void compute_sparsity(const MeshBase &)
Computes the sparsity pattern for the matrices corresponding to proc_id and sends that data to Linear...
Definition dof_map.C:1990
void attach_matrix(SparseMatrix< Number > &matrix)
Additional matrices may be attached to this DofMap.
Definition dof_map.C:250
bool _prefer_hash_table_matrix_assembly
Whether to use hash table matrix assembly if the matrix sub-classes support it.
Definition system.h:2374
bool _require_sparsity_pattern
Whether any of our matrices require an initial sparsity pattern computation in order to determine pre...
Definition system.h:2379

References libMesh::System::_matrices, libMesh::System::_matrices_initialized, libMesh::System::_matrix_types, libMesh::System::_prefer_hash_table_matrix_assembly, libMesh::System::_require_sparsity_pattern, libMesh::DofMap::attach_matrix(), libMesh::DofMap::compute_sparsity(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::SparseMatrix< T >::initialized(), libMesh::libmesh_assert(), and libMesh::System::name().

Referenced by libMesh::System::init_data(), and libMesh::EigenSystem::init_matrices().

◆ init_physics()

void libMesh::DifferentiablePhysics::init_physics ( const System &  sys)
virtualinherited

Initialize any data structures associated with the physics.

Definition at line 36 of file diff_physics.C.

37{
38 // give us flags for every variable that might be time evolving
39 _time_evolving.resize(sys.n_vars(), false);
40}

References libMesh::DifferentiablePhysics::_time_evolving, and libMesh::System::n_vars().

Referenced by libMesh::DifferentiableSystem::init_data().

◆ init_qoi_count()

virtual void libMesh::DifferentiableQoI::init_qoi_count ( System &  )
inlinevirtualinherited

Initialize system qoi.

Often this will just call sys.init_qois(some_desired_number_of_qois)

Reimplemented in LaplaceQoI, and CoupledSystemQoI.

Definition at line 71 of file diff_qoi.h.

71{}

◆ init_qois()

void libMesh::System::init_qois ( unsigned int  n_qois)
inherited

Accessors for qoi and qoi_error_estimates vectors.

Definition at line 2224 of file system.C.

2225{
2226 _qoi.resize(n_qois);
2228}

Referenced by CoupledSystem::CoupledSystem(), HeatSystem::HeatSystem(), LaplaceQoI::init_qoi_count(), CoupledSystemQoI::init_qoi_count(), LaplaceSystem::LaplaceSystem(), main(), and PoissonSystem::PoissonSystem().

◆ is_adjoint_already_solved()

bool libMesh::System::is_adjoint_already_solved ( ) const
inlineinherited

Accessor for the adjoint_already_solved boolean.

Definition at line 423 of file system.h.

424 { return adjoint_already_solved;}
bool adjoint_already_solved
Has the adjoint problem already been solved? If the user sets adjoint_already_solved to true,...
Definition system.h:2358

References libMesh::System::adjoint_already_solved.

Referenced by libMesh::ImplicitSystem::adjoint_qoi_parameter_sensitivity(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ImplicitSystem::qoi_parameter_hessian(), and libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product().

◆ is_first_order_var()

bool libMesh::DifferentiablePhysics::is_first_order_var ( unsigned int  var) const
inlineinherited

Definition at line 509 of file diff_physics.h.

510 { return _first_order_vars.find(var) != _first_order_vars.end(); }

References libMesh::DifferentiablePhysics::_first_order_vars.

◆ is_initialized()

bool libMesh::System::is_initialized ( ) const
inlineinherited
Returns
true iff this system has been initialized.

Definition at line 2488 of file system.h.

2489{
2490 return _is_initialized;
2491}

References libMesh::System::_is_initialized.

Referenced by libMesh::DofMap::add_variable(), libMesh::DofMap::add_variables(), libMesh::System::init(), and libMesh::StaticCondensationDofMap::reinit().

◆ is_second_order_var()

bool libMesh::DifferentiablePhysics::is_second_order_var ( unsigned int  var) const
inlineinherited

◆ is_time_evolving()

bool libMesh::DifferentiablePhysics::is_time_evolving ( unsigned int  var) const
inlineinherited
Returns
true iff variable var is evolving with respect to time. In general, the user's init() function should have set time_evolving() for any variables which behave like du/dt = F(u), and should not call time_evolving() for any variables which behave like 0 = G(u).

Definition at line 260 of file diff_physics.h.

261 {
262 libmesh_assert_less(var,_time_evolving.size());
263 libmesh_assert( _time_evolving[var] == 0 ||
264 _time_evolving[var] == 1 ||
265 _time_evolving[var] == 2 );
266 return _time_evolving[var];
267 }

References libMesh::DifferentiablePhysics::_time_evolving, and libMesh::libmesh_assert().

Referenced by libMesh::FEMPhysics::eulerian_residual(), libMesh::FEMSystem::init_context(), libMesh::FEMPhysics::mass_residual(), and libMesh::DifferentiablePhysics::nonlocal_mass_residual().

◆ late_matrix_init()

void libMesh::System::late_matrix_init ( SparseMatrix< Number > &  mat,
ParallelType  type 
)
privateinherited

Helper function to keep DofMap forward declarable in system.h.

Definition at line 1105 of file system.C.

1107{
1109 {
1110 this->get_dof_map().attach_matrix(mat);
1111 mat.init(type);
1112 }
1113}
virtual void init(const numeric_index_type m, const numeric_index_type n, const numeric_index_type m_l, const numeric_index_type n_l, const numeric_index_type nnz=30, const numeric_index_type noz=10, const numeric_index_type blocksize=1)=0
Initialize SparseMatrix with the specified sizes.

References libMesh::System::_matrices_initialized, libMesh::DofMap::attach_matrix(), libMesh::System::get_dof_map(), and libMesh::SparseMatrix< T >::init().

Referenced by libMesh::System::add_matrix(), libMesh::System::add_matrix(), and libMesh::System::add_matrix().

◆ local_dof_indices()

void libMesh::System::local_dof_indices ( const unsigned int  var,
std::set< dof_id_type > &  var_indices 
) const
inherited

Fills the std::set with the degrees of freedom on the local processor corresponding the the variable number passed in.

Definition at line 1465 of file system.C.

1467{
1468 // Make sure the set is clear
1469 var_indices.clear();
1470
1471 std::vector<dof_id_type> dof_indices;
1472
1473 const dof_id_type
1474 first_local = this->get_dof_map().first_dof(),
1475 end_local = this->get_dof_map().end_dof();
1476
1477 // Begin the loop over the elements
1478 for (const auto & elem : this->get_mesh().active_local_element_ptr_range())
1479 {
1480 this->get_dof_map().dof_indices (elem, dof_indices, var);
1481
1482 for (dof_id_type dof : dof_indices)
1483 //If the dof is owned by the local processor
1484 if (first_local <= dof && dof < end_local)
1485 var_indices.insert(dof);
1486 }
1487
1488 // we may have missed assigning DOFs to nodes that we own
1489 // but to which we have no connected elements matching our
1490 // variable restriction criterion. this will happen, for example,
1491 // if variable V is restricted to subdomain S. We may not own
1492 // any elements which live in S, but we may own nodes which are
1493 // *connected* to elements which do.
1494 for (const auto & node : this->get_mesh().local_node_ptr_range())
1495 {
1496 libmesh_assert(node);
1497 this->get_dof_map().dof_indices (node, dof_indices, var);
1498 for (auto dof : dof_indices)
1499 if (first_local <= dof && dof < end_local)
1500 var_indices.insert(dof);
1501 }
1502}
dof_id_type first_dof(const processor_id_type proc) const
dof_id_type end_dof(const processor_id_type proc) const

References libMesh::DofMap::dof_indices(), libMesh::DofMapBase::end_dof(), libMesh::DofMapBase::first_dof(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), and libMesh::libmesh_assert().

Referenced by SystemsTest::testBlockRestrictedVarNDofs(), and libMesh::DirectSolutionTransfer::transfer().

◆ mass_residual() [1/2]

virtual bool libMesh::DifferentiablePhysics::mass_residual ( bool  request_jacobian,
DiffContext &   
)
inlinevirtualinherited

Subtracts a mass vector contribution on elem from elem_residual.

For first-order-in-time problems, this is the \( M(u,\dot{u})\dot{u} \) term. For second-order-in-time problems, this is the \( M(u,\ddot{u})\ddot{u} \) term. This method is only called for UnsteadySolver-based TimeSolvers.

If this method receives request_jacobian = true, then it should compute elem_jacobian and return true if possible. If elem_jacobian has not been computed then the method should return false.

Many first-order-in-time problems can use the reimplementation in FEMPhysics::mass_residual which subtracts (du/dt,v) for each transient variable u; users with more complicated transient problems or second-order-in-time problems will need to reimplement this themselves.

Reimplemented in libMesh::FEMPhysics, NavierSystem, ElasticitySystem, ElasticitySystem, FirstOrderScalarSystemBase, SecondOrderScalarSystemSecondOrderTimeSolverBase, and SecondOrderScalarSystemFirstOrderTimeSolverBase.

Definition at line 302 of file diff_physics.h.

304 {
305 return request_jacobian;
306 }

Referenced by libMesh::EigenTimeSolver::element_residual(), libMesh::Euler2Solver::element_residual(), libMesh::EulerSolver::element_residual(), and libMesh::NewmarkSolver::element_residual().

◆ mass_residual() [2/2]

bool libMesh::FEMPhysics::mass_residual ( bool  request_jacobian,
DiffContext &  c 
)
overridevirtualinherited

Subtracts a mass vector contribution on elem from elem_residual.

If this method receives request_jacobian = true, then it should compute elem_jacobian and return true if possible. If elem_jacobian has not been computed then the method should return false.

Many problems can use the reimplementation in FEMPhysics::mass_residual which subtracts (du/dt,v) for each transient variable u; users with more complicated transient problems will need to reimplement this themselves.

Reimplemented from libMesh::DifferentiablePhysics.

Reimplemented in NavierSystem, ElasticitySystem, ElasticitySystem, FirstOrderScalarSystemBase, SecondOrderScalarSystemSecondOrderTimeSolverBase, and SecondOrderScalarSystemFirstOrderTimeSolverBase.

Definition at line 200 of file fem_physics.C.

202{
203 FEMContext & context = cast_ref<FEMContext &>(c);
204
205 unsigned int n_qpoints = context.get_element_qrule().n_points();
206
207 for (auto var : make_range(context.n_vars()))
208 {
209 if (!this->is_time_evolving(var))
210 continue;
211
212 FEBase * elem_fe = nullptr;
213 context.get_element_fe( var, elem_fe );
214
215 const std::vector<Real> & JxW = elem_fe->get_JxW();
216
217 const std::vector<std::vector<Real>> & phi = elem_fe->get_phi();
218
219 const unsigned int n_dofs = cast_int<unsigned int>
220 (context.get_dof_indices(var).size());
221
222 DenseSubVector<Number> & Fu = context.get_elem_residual(var);
223 DenseSubMatrix<Number> & Kuu = context.get_elem_jacobian( var, var );
224
225 for (unsigned int qp = 0; qp != n_qpoints; ++qp)
226 {
227 Number uprime;
228 context.interior_rate(var, qp, uprime);
229 const Number JxWxU = JxW[qp] * uprime;
230 for (unsigned int i = 0; i != n_dofs; ++i)
231 {
232 Fu(i) -= JxWxU * phi[i][qp];
233 if (request_jacobian && context.elem_solution_rate_derivative)
234 {
235 const Number JxWxPhiIxDeriv = JxW[qp] * phi[i][qp] *
236 context.elem_solution_rate_derivative;
237 Kuu(i,i) -= JxWxPhiIxDeriv * phi[i][qp];
238 for (unsigned int j = i+1; j < n_dofs; ++j)
239 {
240 const Number Kij = JxWxPhiIxDeriv * phi[j][qp];
241 Kuu(i,j) -= Kij;
242 Kuu(j,i) -= Kij;
243 }
244 }
245 }
246 }
247 }
248
249 return request_jacobian;
250}
unsigned int n_vars
bool is_time_evolving(unsigned int var) const

References libMesh::DiffContext::elem_solution_rate_derivative, libMesh::DiffContext::get_dof_indices(), libMesh::DiffContext::get_elem_jacobian(), libMesh::DiffContext::get_elem_residual(), libMesh::FEMContext::get_element_fe(), libMesh::FEMContext::get_element_qrule(), libMesh::FEAbstract::get_JxW(), libMesh::FEGenericBase< OutputType >::get_phi(), libMesh::FEMContext::interior_rate(), libMesh::DifferentiablePhysics::is_time_evolving(), libMesh::make_range(), libMesh::QBase::n_points(), and libMesh::DiffContext::n_vars().

◆ matrices_begin() [1/2]

System::matrices_iterator libMesh::System::matrices_begin ( )
inlineinherited

Beginning of matrices container.

Definition at line 2560 of file system.h.

2561{
2562 return _matrices.begin();
2563}

References libMesh::System::_matrices.

◆ matrices_begin() [2/2]

System::const_matrices_iterator libMesh::System::matrices_begin ( ) const
inlineinherited

Beginning of matrices container.

Definition at line 2566 of file system.h.

2567{
2568 return _matrices.begin();
2569}

References libMesh::System::_matrices.

◆ matrices_end() [1/2]

System::matrices_iterator libMesh::System::matrices_end ( )
inlineinherited

End of matrices container.

Definition at line 2572 of file system.h.

2573{
2574 return _matrices.end();
2575}

References libMesh::System::_matrices.

◆ matrices_end() [2/2]

System::const_matrices_iterator libMesh::System::matrices_end ( ) const
inlineinherited

End of matrices container.

Definition at line 2578 of file system.h.

2579{
2580 return _matrices.end();
2581}

References libMesh::System::_matrices.

◆ mesh_position_get()

void FEMSystem::mesh_position_get ( )
inherited

Tells the FEMSystem to set the degree of freedom coefficients which should correspond to mesh nodal coordinates.

Definition at line 1430 of file fem_system.C.

1431{
1432 // This function makes no sense unless we've already picked out some
1433 // variable(s) to reflect mesh position coordinates
1434 libmesh_error_msg_if(!_mesh_sys, "_mesh_sys was nullptr!");
1435
1436 // We currently assume mesh variables are in our own system
1437 if (_mesh_sys != this)
1438 libmesh_not_implemented();
1439
1440 // Loop over every active mesh element on this processor
1441 const MeshBase & mesh = this->get_mesh();
1442
1443 std::unique_ptr<DiffContext> con = this->build_context();
1444 FEMContext & _femcontext = cast_ref<FEMContext &>(*con);
1445 this->init_context(_femcontext);
1446
1447 // Get the solution's mesh variables from every element
1448 for (const auto & elem : mesh.active_local_element_ptr_range())
1449 {
1450 _femcontext.pre_fe_reinit(*this, elem);
1451
1452 _femcontext.elem_position_get();
1453
1455 this->solution->insert(_femcontext.get_elem_solution(_mesh_x_var),
1456 _femcontext.get_dof_indices(_mesh_x_var) );
1458 this->solution->insert(_femcontext.get_elem_solution(_mesh_y_var),
1459 _femcontext.get_dof_indices(_mesh_y_var));
1461 this->solution->insert(_femcontext.get_elem_solution(_mesh_z_var),
1462 _femcontext.get_dof_indices(_mesh_z_var));
1463 }
1464
1465 this->solution->close();
1466
1467 // And make sure the current_local_solution is up to date too
1468 this->System::update();
1469}
const std::vector< dof_id_type > & get_dof_indices() const
Accessor for element dof indices.
const DenseVector< Number > & get_elem_solution() const
Accessor for element solution.
void elem_position_get()
Uses the geometry of elem to set the coordinate data specified by mesh_*_position configuration.
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
Definition libmesh.h:303

References libMesh::DifferentiablePhysics::_mesh_sys, libMesh::DifferentiablePhysics::_mesh_x_var, libMesh::DifferentiablePhysics::_mesh_y_var, libMesh::DifferentiablePhysics::_mesh_z_var, libMesh::FEMSystem::build_context(), libMesh::FEMContext::elem_position_get(), libMesh::DiffContext::get_dof_indices(), libMesh::DiffContext::get_elem_solution(), libMesh::System::get_mesh(), libMesh::FEMSystem::init_context(), libMesh::invalid_uint, mesh, libMesh::FEMContext::pre_fe_reinit(), libMesh::System::solution, and libMesh::System::update().

Referenced by init_data().

◆ mesh_position_set()

void FEMSystem::mesh_position_set ( )
inherited

Tells the FEMSystem to set the mesh nodal coordinates which should correspond to degree of freedom coefficients.

Definition at line 1087 of file fem_system.C.

1088{
1089 // If we don't need to move the mesh, we're done
1090 if (_mesh_sys != this)
1091 return;
1092
1093 MeshBase & mesh = this->get_mesh();
1094
1095 std::unique_ptr<DiffContext> con = this->build_context();
1096 FEMContext & _femcontext = cast_ref<FEMContext &>(*con);
1097 this->init_context(_femcontext);
1098
1099 // Move every mesh element we can
1100 for (const auto & elem : mesh.active_local_element_ptr_range())
1101 {
1102 // We need the algebraic data
1103 _femcontext.pre_fe_reinit(*this, elem);
1104 // And when asserts are on, we also need the FE so
1105 // we can assert that the mesh data is of the right type.
1106#ifndef NDEBUG
1107 _femcontext.elem_fe_reinit();
1108#endif
1109
1110 // This code won't handle moving subactive elements
1111 libmesh_assert(!_femcontext.get_elem().has_children());
1112
1113 _femcontext.elem_position_set(1.);
1114 }
1115
1116 // We've now got positions set on all local nodes (and some
1117 // semilocal nodes); let's request positions for non-local nodes
1118 // from their processors.
1119
1120 SyncNodalPositions sync_object(mesh);
1122 (this->comm(), mesh.nodes_begin(), mesh.nodes_end(), sync_object);
1123}
bool has_children() const
Definition elem.h:3117
void elem_position_set(Real theta)
Uses the coordinate data specified by mesh_*_position configuration to set the geometry of elem to th...
virtual void elem_fe_reinit(const std::vector< Point > *const pts=nullptr)
Reinitializes interior FE objects on the current geometric element.
void sync_dofobject_data_by_id(const Communicator &comm, const Iterator &range_begin, const Iterator &range_end, SyncFunctor &sync)
Request data about a range of ghost dofobjects uniquely identified by their id.

References libMesh::DifferentiablePhysics::_mesh_sys, libMesh::FEMSystem::build_context(), libMesh::ParallelObject::comm(), libMesh::FEMContext::elem_fe_reinit(), libMesh::FEMContext::elem_position_set(), libMesh::FEMContext::get_elem(), libMesh::System::get_mesh(), libMesh::Elem::has_children(), libMesh::FEMSystem::init_context(), libMesh::libmesh_assert(), mesh, libMesh::FEMContext::pre_fe_reinit(), and libMesh::Parallel::sync_dofobject_data_by_id().

Referenced by libMesh::FEMSystem::solve(), and update().

◆ n_active_dofs()

dof_id_type libMesh::System::n_active_dofs ( ) const
inlineinherited
Returns
The number of active degrees of freedom for this System.

Definition at line 2514 of file system.h.

2515{
2516 return this->n_dofs() - this->n_constrained_dofs();
2517}

References libMesh::System::n_constrained_dofs(), and libMesh::System::n_dofs().

◆ n_components()

unsigned int libMesh::System::n_components ( ) const
inherited
Returns
The total number of scalar components in the system's variables. This will equal n_vars() in the case of all scalar-valued variables.

Definition at line 2749 of file system.C.

2750{
2751 return this->get_dof_map().n_components(this->get_mesh());
2752}
unsigned int n_components(const MeshBase &mesh) const
Definition dof_map.h:3053

Referenced by ElasticityRBConstruction::init_data().

◆ n_constrained_dofs()

dof_id_type libMesh::System::n_constrained_dofs ( ) const
inherited
Returns
The total number of constrained degrees of freedom in the system.

Definition at line 127 of file system.C.

128{
129#ifdef LIBMESH_ENABLE_CONSTRAINTS
130
131 return _dof_map->n_constrained_dofs();
132
133#else
134
135 return 0;
136
137#endif
138}

References libMesh::System::_dof_map.

Referenced by form_functionA(), form_functionB(), form_matrixA(), libMesh::System::n_active_dofs(), libMesh::EigenSystem::solve(), and BoundaryInfoTest::testShellFaceConstraints().

◆ n_dofs()

dof_id_type libMesh::System::n_dofs ( ) const
inherited
Returns
The number of degrees of freedom in the system

Definition at line 120 of file system.C.

121{
122 return _dof_map->n_dofs();
123}

References libMesh::System::_dof_map.

Referenced by libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::System::add_vector(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::ClawSystem::assemble_avg_coupling_matrices(), libMesh::ClawSystem::assemble_boundary_condition_matrices(), libMesh::AdvectionSystem::assemble_claw_rhs(), libMesh::ClawSystem::assemble_jump_coupling_matrix(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), NonlinearDiffusionSystem::element_time_derivative(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::System::init_data(), libMesh::AdvectionSystem::init_data(), libMesh::SecondOrderUnsteadySolver::init_data(), libMesh::UnsteadySolver::init_data(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), main(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::System::n_active_dofs(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::FEMSystem::numerical_jacobian(), libMesh::RBSCMConstruction::perform_SCM_greedy(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), MeshFunctionTest::read_variable_info_from_output_data(), libMesh::SecondOrderUnsteadySolver::reinit(), libMesh::UnsteadySolver::reinit(), libMesh::System::restrict_vectors(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), libMesh::TransientRBConstruction::set_error_temporal_data(), libMesh::PetscPreconditioner< T >::set_hypre_ads_data(), libMesh::PetscPreconditioner< T >::set_hypre_ams_data(), libMesh::ClawSystem::solve_conservation_law(), SystemsTest::test100KVariables(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), SystemsTest::testPostInitAddVector(), SystemsTest::testPostInitAddVectorTypeChange(), SystemsTest::testProjectCubeWithMeshFunction(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), SystemsTest::testProjectScalarCoarsening(), libMesh::RBConstruction::train_reduced_basis_with_POD(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), and libMesh::RBConstruction::update_residual_terms().

◆ n_local_constrained_dofs()

dof_id_type libMesh::System::n_local_constrained_dofs ( ) const
inherited
Returns
The number of constrained degrees of freedom on this processor.

Definition at line 142 of file system.C.

143{
144#ifdef LIBMESH_ENABLE_CONSTRAINTS
145
146 return _dof_map->n_local_constrained_dofs();
147
148#else
149
150 return 0;
151
152#endif
153}

References libMesh::System::_dof_map.

◆ n_local_dofs()

dof_id_type libMesh::System::n_local_dofs ( ) const
inherited
Returns
The number of degrees of freedom local to this processor

Definition at line 157 of file system.C.

158{
159 return _dof_map->n_local_dofs();
160}

References libMesh::System::_dof_map.

Referenced by libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::System::add_vector(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::AdvectionSystem::assemble_claw_rhs(), libMesh::PetscDMWrapper::build_section(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::System::init_data(), libMesh::AdvectionSystem::init_data(), libMesh::SecondOrderUnsteadySolver::init_data(), libMesh::UnsteadySolver::init_data(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), main(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::SecondOrderUnsteadySolver::reinit(), libMesh::UnsteadySolver::reinit(), libMesh::System::restrict_vectors(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), libMesh::TransientRBConstruction::set_error_temporal_data(), libMesh::PetscPreconditioner< T >::set_hypre_ads_data(), libMesh::PetscPreconditioner< T >::set_hypre_ams_data(), libMesh::ClawSystem::solve_conservation_law(), MeshFunctionTest::test_p_level(), libMesh::RBConstruction::train_reduced_basis_with_POD(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), and libMesh::RBConstruction::update_residual_terms().

◆ n_matrices()

unsigned int libMesh::System::n_matrices ( ) const
inlineinherited
Returns
The number of matrices handled by this system. This is the size of the _matrices map

Definition at line 2669 of file system.h.

2670{
2671 return cast_int<unsigned int>(_matrices.size());
2672}

References libMesh::System::_matrices.

Referenced by libMesh::ImplicitSystem::add_matrices().

◆ n_objects()

static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited

Prints the number of outstanding (created, but not yet destroyed) objects.

Definition at line 85 of file reference_counter.h.

86 { return _n_objects; }
static Threads::atomic< unsigned int > _n_objects
The number of objects.

References libMesh::ReferenceCounter::_n_objects.

Referenced by libMesh::LibMeshInit::~LibMeshInit().

◆ n_processors()

processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
Returns
The number of processors in the group.

Definition at line 103 of file parallel_object.h.

104 {
105 processor_id_type returnval =
106 cast_int<processor_id_type>(_communicator.size());
107 libmesh_assert(returnval); // We never have an empty comm
108 return returnval;
109 }
processor_id_type size() const
uint8_t processor_id_type
Definition id_types.h:104

References libMesh::ParallelObject::_communicator, libMesh::libmesh_assert(), and libMesh::Parallel::Communicator::size().

Referenced by libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::DofMap::add_constraints_to_send_list(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::System::add_vector(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), ExodusC0PolyhedronTest::assert_distributed_if_parallel(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::Partitioner::assign_partitioning(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::Partitioner::build_graph(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::DistributedMesh::clear_elems(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::UnstructuredMesh::copy_nodes_and_elements(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_scalar_dofs(), libMesh::EnsightIO::EnsightIO(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::MeshBase::get_info(), libMesh::StaticCondensation::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_petscdm(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), libMesh::NumericVector< T >::is_effectively_ghosted(), libMesh::NumericVector< T >::is_effectively_serial(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::DofMap::local_variable_indices(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::DofMap::n_dofs_per_processor(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::DofMap::prepare_send_list(), libMesh::MeshBase::print_constraint_rows(), libMesh::DofMap::print_dof_constraints(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::NameBasedIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::XdrIO::read_header(), libMesh::CheckpointIO::read_nodes(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::Partitioner::repartition(), OverlappingFunctorTest::run_partitioner_test(), libMesh::DofMap::scatter_constraints(), libMesh::DistributedMesh::set_next_ids(), libMesh::DistributedMesh::set_next_unique_id(), libMesh::DistributedMesh::set_next_unique_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), WriteVecAndScalar::setupTests(), libMesh::RBEIMEvaluation::side_gather_bfs(), ExodusC0PolyhedronTest::test_write_and_read_mixed_hex_tet_block_names_impl(), CheckpointIOTest::testDisjointNeighborPairsCheckpoint(), SystemsTest::testPetscOptionsPrefix(), DistributedMeshTest::testRemoteElemError(), CheckpointIOTest::testSplitter(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

◆ n_qois()

unsigned int libMesh::System::n_qois ( ) const
inlineinherited

Number of currently active quantities of interest.

Definition at line 2593 of file system.h.

2594{
2595 libmesh_assert_equal_to(this->_qoi.size(), this->_qoi_error_estimates.size());
2596
2597 return cast_int<unsigned int>(this->_qoi.size());
2598}

References libMesh::System::_qoi.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::AdaptiveTimeSolver::adjoint_advance_timestep(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::ImplicitSystem::adjoint_qoi_parameter_sensitivity(), libMesh::TwostepTimeSolver::adjoint_solve(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::SensitivityData::allocate_data(), libMesh::SensitivityData::allocate_hessian_data(), libMesh::FEMSystem::assemble_qoi(), libMesh::ExplicitSystem::assemble_qoi(), libMesh::ExplicitSystem::assemble_qoi_derivative(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::DiffContext::DiffContext(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::FileSolutionHistory::FileSolutionHistory(), libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity(), libMesh::TimeSolver::init_adjoints(), libMesh::UnsteadySolver::init_adjoints(), libMesh::Euler2Solver::integrate_adjoint_refinement_error_estimate(), libMesh::EulerSolver::integrate_adjoint_refinement_error_estimate(), libMesh::SteadySolver::integrate_adjoint_refinement_error_estimate(), libMesh::TwostepTimeSolver::integrate_adjoint_refinement_error_estimate(), libMesh::Euler2Solver::integrate_qoi_timestep(), libMesh::EulerSolver::integrate_qoi_timestep(), libMesh::TwostepTimeSolver::integrate_qoi_timestep(), main(), libMesh::FEMContext::pre_fe_reinit(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), libMesh::FileSolutionHistory::retrieve(), libMesh::QoISet::size(), libMesh::UnsteadySolver::UnsteadySolver(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().

◆ n_variable_groups()

unsigned int libMesh::System::n_variable_groups ( ) const
inherited
Returns
The number of VariableGroup variable groups in the system

Definition at line 2754 of file system.C.

2755{
2756 return this->get_dof_map().n_variable_groups();
2757}
unsigned int n_variable_groups() const
Definition dof_map.h:740

Referenced by libMesh::FEMSystem::assembly().

◆ n_vars()

unsigned int libMesh::System::n_vars ( ) const
inherited
Returns
The number of variables in the system

Definition at line 2729 of file system.C.

2730{
2731 return this->get_dof_map().n_vars();
2732}
unsigned int n_vars() const
Definition dof_map.h:3027

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::PetscDMWrapper::add_dofs_helper(), libMesh::DiffContext::add_localized_vector(), libMesh::TwostepTimeSolver::adjoint_solve(), libMesh::FEMContext::attach_quadrature_rules(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_section(), LinearElasticity::compute_stresses(), LargeDeformationElasticity::compute_stresses(), LinearElasticityWithContact::compute_stresses(), compute_stresses(), libMesh::DGFEMContext::DGFEMContext(), libMesh::DiffContext::DiffContext(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::ErrorEstimator::estimate_errors(), libMesh::ExactSolution::ExactSolution(), libMesh::FEMContext::find_hardest_fe_type(), libMesh::EquationSystems::find_variable_numbers_by_predicate(), libMesh::RBEIMConstruction::init_context(), libMesh::FEMContext::init_internal_data(), libMesh::PetscDMWrapper::init_petscdm(), libMesh::DifferentiablePhysics::init_physics(), AssemblyA0::interior_assembly(), AssemblyA1::interior_assembly(), AssemblyA2::interior_assembly(), InnerProductAssembly::interior_assembly(), main(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SmoothnessEstimator::EstimateSmoothness::operator()(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), output_norms(), libMesh::petsc_auto_fieldsplit(), libMesh::FEMContext::pre_fe_reinit(), libMesh::InterMeshProjection::project_system_vectors(), libMesh::System::re_update(), libMesh::System::read_parallel_data(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::System::reinit_mesh(), libMesh::HPCoarsenTest::select_refinement(), libMesh::PetscPreconditioner< T >::set_petsc_aux_data(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::SystemSubsetBySubdomain::set_var_nums(), OverlappingTestBase::setup_coupling_matrix(), SystemsTest::testDofCouplingWithVarGroups(), SlitMeshRefinedSystemTest::testRestart(), SlitMeshRefinedSystemTest::testSystem(), libMesh::System::write_header(), libMesh::System::write_parallel_data(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), and libMesh::System::zero_variable().

◆ n_vectors()

unsigned int libMesh::System::n_vectors ( ) const
inlineinherited
Returns
The number of vectors (in addition to the solution) handled by this system This is the size of the _vectors map

Definition at line 2530 of file system.h.

2531{
2532 return cast_int<unsigned int>(_vectors.size());
2533}

References libMesh::System::_vectors.

Referenced by libMesh::ExplicitSystem::add_system_rhs(), libMesh::System::compare(), main(), libMesh::InterMeshProjection::project_system_vectors(), and libMesh::System::write_header().

◆ name()

const std::string & libMesh::System::name ( ) const
inlineinherited

◆ nonlocal_constraint()

virtual bool libMesh::DifferentiablePhysics::nonlocal_constraint ( bool  request_jacobian,
DiffContext &   
)
inlinevirtualinherited

Adds any nonlocal constraint contributions (e.g.

some components of constraints in scalar variable equations) to elem_residual

If this method receives request_jacobian = true, then it should also modify elem_jacobian and return true if possible. If the Jacobian changes have not been computed then the method should return false.

Users may need to reimplement this for PDEs on systems to which SCALAR variables with non-transient equations have been added.

Definition at line 233 of file diff_physics.h.

235 {
236 return request_jacobian;
237 }

Referenced by libMesh::EigenTimeSolver::nonlocal_residual(), libMesh::Euler2Solver::nonlocal_residual(), libMesh::EulerSolver::nonlocal_residual(), libMesh::NewmarkSolver::nonlocal_residual(), and libMesh::SteadySolver::nonlocal_residual().

◆ nonlocal_damping_residual()

virtual bool libMesh::DifferentiablePhysics::nonlocal_damping_residual ( bool  request_jacobian,
DiffContext &   
)
inlinevirtualinherited

Subtracts any nonlocal damping vector contributions (e.g.

any first time derivative coefficients in scalar variable equations) from elem_residual

If this method receives request_jacobian = true, then it should also modify elem_jacobian and return true if possible. If the Jacobian changes have not been computed then the method should return false.

Definition at line 394 of file diff_physics.h.

396 {
397 return request_jacobian;
398 }

Referenced by libMesh::Euler2Solver::nonlocal_residual(), libMesh::EulerSolver::nonlocal_residual(), and libMesh::NewmarkSolver::nonlocal_residual().

◆ nonlocal_mass_residual()

bool libMesh::DifferentiablePhysics::nonlocal_mass_residual ( bool  request_jacobian,
DiffContext &  c 
)
virtualinherited

Subtracts any nonlocal mass vector contributions (e.g.

any time derivative coefficients in scalar variable equations) from elem_residual

If this method receives request_jacobian = true, then it should also modify elem_jacobian and return true if possible. If the Jacobian changes have not been computed then the method should return false.

Many problems can use the reimplementation in FEMPhysics::mass_residual which subtracts (du/dt,v) for each transient scalar variable u; users with more complicated transient scalar variable equations will need to reimplement this themselves.

Definition at line 58 of file diff_physics.C.

60{
61 FEMContext & context = cast_ref<FEMContext &>(c);
62
63 for (auto var : make_range(context.n_vars()))
64 {
65 if (!this->is_time_evolving(var))
66 continue;
67
68 if (c.get_system().variable(var).type().family != SCALAR)
69 continue;
70
71 const std::vector<dof_id_type> & dof_indices =
72 context.get_dof_indices(var);
73
74 const unsigned int n_dofs = cast_int<unsigned int>
75 (dof_indices.size());
76
77 DenseSubVector<Number> & Fs = context.get_elem_residual(var);
78 DenseSubMatrix<Number> & Kss = context.get_elem_jacobian( var, var );
79
81 context.get_elem_solution(var);
82
83 for (unsigned int i=0; i != n_dofs; ++i)
84 {
85 Fs(i) -= Us(i);
86
87 if (request_jacobian)
88 Kss(i,i) -= context.elem_solution_rate_derivative;
89 }
90 }
91
92 return request_jacobian;
93}
Defines a dense subvector for use in finite element computations.

References libMesh::DiffContext::elem_solution_rate_derivative, libMesh::FEType::family, libMesh::DiffContext::get_dof_indices(), libMesh::DiffContext::get_elem_jacobian(), libMesh::DiffContext::get_elem_residual(), libMesh::DiffContext::get_elem_solution(), libMesh::DiffContext::get_system(), libMesh::DifferentiablePhysics::is_time_evolving(), libMesh::make_range(), libMesh::DiffContext::n_vars(), libMesh::SCALAR, libMesh::Variable::type(), and libMesh::System::variable().

Referenced by libMesh::EigenTimeSolver::nonlocal_residual(), libMesh::Euler2Solver::nonlocal_residual(), libMesh::EulerSolver::nonlocal_residual(), and libMesh::NewmarkSolver::nonlocal_residual().

◆ nonlocal_time_derivative()

virtual bool libMesh::DifferentiablePhysics::nonlocal_time_derivative ( bool  request_jacobian,
DiffContext &   
)
inlinevirtualinherited

Adds any nonlocal time derivative contributions (e.g.

some components of time derivatives in scalar variable equations) to elem_residual

If this method receives request_jacobian = true, then it should also modify elem_jacobian and return true if possible. If the Jacobian changes have not been computed then the method should return false.

Users may need to reimplement this for PDEs on systems to which SCALAR variables have been added.

Definition at line 214 of file diff_physics.h.

216 {
217 return request_jacobian;
218 }

Referenced by libMesh::EigenTimeSolver::nonlocal_residual(), libMesh::Euler2Solver::nonlocal_residual(), libMesh::EulerSolver::nonlocal_residual(), libMesh::NewmarkSolver::nonlocal_residual(), and libMesh::SteadySolver::nonlocal_residual().

◆ number()

unsigned int libMesh::System::number ( ) const
inlineinherited
Returns
The system number.

Definition at line 2424 of file system.h.

2425{
2426 return _sys_number;
2427}
const unsigned int _sys_number
The number associated with this system.
Definition system.h:2273

References libMesh::System::_sys_number.

Referenced by libMesh::PetscDMWrapper::add_dofs_helper(), assemble_advection_diffusion(), assemble_matrix_and_rhs(), assemble_shell(), libMesh::EquationSystems::build_parallel_solution_vector(), centroid_l2_error(), GhostDofConstraint::constrain(), libMesh::VariationalSmootherConstraint::constrain_node_to_line(), libMesh::VariationalSmootherConstraint::constrain_node_to_plane(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::Nemesis_IO::copy_nodal_solution(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::EquationSystems::find_variable_numbers_by_predicate(), libMesh::VariationalSmootherConstraint::fix_node(), AssemblyPointLoadX::get_nodal_rhs_values(), AssemblyPointLoadY::get_nodal_rhs_values(), AssemblyPointLoadZ::get_nodal_rhs_values(), main(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SortAndCopy::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectInteriors::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectEdges::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectSides::operator()(), libMesh::System::read_parallel_data(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::StaticCondensationDofMap::reinit(), LinearElasticityWithContact::residual_and_jacobian(), save_initial_mesh(), libMesh::HPCoarsenTest::select_refinement(), libMesh::PetscPreconditioner< T >::set_hypre_ads_data(), libMesh::PetscPreconditioner< T >::set_hypre_ams_data(), libMesh::PetscDMWrapper::set_point_range_in_section(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), DofMapTest::testGhostConstraintSendList(), HeterogeneousNonlinearConstraintTest::testNonzeroDirichletValues(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::BoundaryVolumeSolutionTransfer::transfer_volume_boundary(), libMesh::DTKAdapter::update_variable_values(), libMesh::System::write_parallel_data(), libMesh::System::write_serialized_blocked_dof_objects(), and libMesh::System::zero_variable().

◆ numerical_elem_jacobian()

void FEMSystem::numerical_elem_jacobian ( FEMContext &  context) const
inherited

Uses the results of multiple element_residual() calls to numerically differentiate the corresponding jacobian on an element.

Definition at line 1329 of file fem_system.C.

1330{
1331 LOG_SCOPE("numerical_elem_jacobian()", "FEMSystem");
1333}
void numerical_jacobian(TimeSolverResPtr res, FEMContext &context) const
Uses the results of multiple res calls to numerically differentiate the corresponding jacobian.
virtual bool element_residual(bool request_jacobian, DiffContext &)=0
This method uses the DifferentiablePhysics element_time_derivative(), element_constraint(),...

References libMesh::TimeSolver::element_residual(), and libMesh::FEMSystem::numerical_jacobian().

◆ numerical_jacobian()

void FEMSystem::numerical_jacobian ( TimeSolverResPtr  res,
FEMContext &  context 
) const
inherited

Uses the results of multiple res calls to numerically differentiate the corresponding jacobian.

Definition at line 1217 of file fem_system.C.

1219{
1220 // Logging is done by numerical_elem_jacobian
1221 // or numerical_side_jacobian
1222
1223 DenseVector<Number> original_residual(context.get_elem_residual());
1224 DenseVector<Number> backwards_residual(context.get_elem_residual());
1225 DenseMatrix<Number> numeric_jacobian(context.get_elem_jacobian());
1226#ifdef DEBUG
1227 DenseMatrix<Number> old_jacobian(context.get_elem_jacobian());
1228#endif
1229
1230 Real numerical_point_h = 0.;
1231 if (_mesh_sys == this)
1232 numerical_point_h = numerical_jacobian_h * context.get_elem().hmin();
1233
1234 const unsigned int n_dofs =
1235 cast_int<unsigned int>(context.get_dof_indices().size());
1236
1237 for (auto v : make_range(context.n_vars()))
1238 {
1239 const Real my_h = this->numerical_jacobian_h_for_var(v);
1240
1241 unsigned int j_offset = libMesh::invalid_uint;
1242
1243 if (!context.get_dof_indices(v).empty())
1244 {
1245 for (auto i : make_range(n_dofs))
1246 if (context.get_dof_indices()[i] ==
1247 context.get_dof_indices(v)[0])
1248 j_offset = i;
1249
1250 libmesh_assert_not_equal_to(j_offset, libMesh::invalid_uint);
1251 }
1252
1253 for (auto j : make_range(context.get_dof_indices(v).size()))
1254 {
1255 const unsigned int total_j = j + j_offset;
1256
1257 // Take the "minus" side of a central differenced first derivative
1258 Number original_solution = context.get_elem_solution(v)(j);
1259 context.get_elem_solution(v)(j) -= my_h;
1260
1261 // Make sure to catch any moving mesh terms
1262 Real * coord = nullptr;
1263 if (_mesh_sys == this)
1264 {
1265 if (_mesh_x_var == v)
1266 coord = &(context.get_elem().point(j)(0));
1267 else if (_mesh_y_var == v)
1268 coord = &(context.get_elem().point(j)(1));
1269 else if (_mesh_z_var == v)
1270 coord = &(context.get_elem().point(j)(2));
1271 }
1272 if (coord)
1273 {
1274 // We have enough information to scale the perturbations
1275 // here appropriately
1276 context.get_elem_solution(v)(j) = original_solution - numerical_point_h;
1277 *coord = libmesh_real(context.get_elem_solution(v)(j));
1278 }
1279
1280 context.get_elem_residual().zero();
1281 ((*time_solver).*(res))(false, context);
1282#ifdef DEBUG
1283 libmesh_assert_equal_to (old_jacobian, context.get_elem_jacobian());
1284#endif
1285 backwards_residual = context.get_elem_residual();
1286
1287 // Take the "plus" side of a central differenced first derivative
1288 context.get_elem_solution(v)(j) = original_solution + my_h;
1289 if (coord)
1290 {
1291 context.get_elem_solution()(j) = original_solution + numerical_point_h;
1292 *coord = libmesh_real(context.get_elem_solution(v)(j));
1293 }
1294 context.get_elem_residual().zero();
1295 ((*time_solver).*(res))(false, context);
1296#ifdef DEBUG
1297 libmesh_assert_equal_to (old_jacobian, context.get_elem_jacobian());
1298#endif
1299
1300 context.get_elem_solution(v)(j) = original_solution;
1301 if (coord)
1302 {
1303 *coord = libmesh_real(context.get_elem_solution(v)(j));
1304 for (auto i : make_range(n_dofs))
1305 {
1306 numeric_jacobian(i,total_j) =
1307 (context.get_elem_residual()(i) - backwards_residual(i)) /
1308 2. / numerical_point_h;
1309 }
1310 }
1311 else
1312 {
1313 for (auto i : make_range(n_dofs))
1314 {
1315 numeric_jacobian(i,total_j) =
1316 (context.get_elem_residual()(i) - backwards_residual(i)) /
1317 2. / my_h;
1318 }
1319 }
1320 }
1321 }
1322
1323 context.get_elem_residual() = original_residual;
1324 context.get_elem_jacobian() = numeric_jacobian;
1325}
virtual void zero() override final
Set every element in the vector to 0.
const Point & point(const unsigned int i) const
Definition elem.h:2583
virtual Real hmin() const
Definition elem.C:623
Real numerical_jacobian_h
If calculating numeric jacobians is required, the FEMSystem will perturb each solution vector entry b...
Definition fem_system.h:187
Real numerical_jacobian_h_for_var(unsigned int var_num) const
If numerical_jacobian_h_for_var(var_num) is changed from its default value (numerical_jacobian_h),...
Definition fem_system.h:265
LIBMESH_DEVICE_INLINE T libmesh_real(T a)

References libMesh::DifferentiablePhysics::_mesh_sys, libMesh::DifferentiablePhysics::_mesh_x_var, libMesh::DifferentiablePhysics::_mesh_y_var, libMesh::DifferentiablePhysics::_mesh_z_var, libMesh::DiffContext::get_dof_indices(), libMesh::FEMContext::get_elem(), libMesh::DiffContext::get_elem_jacobian(), libMesh::DiffContext::get_elem_residual(), libMesh::DiffContext::get_elem_solution(), libMesh::Elem::hmin(), libMesh::invalid_uint, libMesh::libmesh_real(), libMesh::make_range(), libMesh::System::n_dofs(), libMesh::DiffContext::n_vars(), libMesh::FEMSystem::numerical_jacobian_h, libMesh::FEMSystem::numerical_jacobian_h_for_var(), libMesh::Elem::point(), libMesh::Real, and libMesh::DenseVector< T >::zero().

Referenced by libMesh::FEMSystem::numerical_elem_jacobian(), libMesh::FEMSystem::numerical_nonlocal_jacobian(), and libMesh::FEMSystem::numerical_side_jacobian().

◆ numerical_jacobian_h_for_var()

Real FEMSystem::numerical_jacobian_h_for_var ( unsigned int  var_num) const
inlineinherited

If numerical_jacobian_h_for_var(var_num) is changed from its default value (numerical_jacobian_h), the FEMSystem will perturb solution vector entries for variable var_num by that amount when calculating finite differences with respect to that variable.

This is useful in multiphysics problems which have not been normalized.

Definition at line 265 of file fem_system.h.

266{
267 if ((var_num >= _numerical_jacobian_h_for_var.size()) ||
268 _numerical_jacobian_h_for_var[var_num] == Real(0))
270
271 return _numerical_jacobian_h_for_var[var_num];
272}
std::vector< Real > _numerical_jacobian_h_for_var
Definition fem_system.h:258

References libMesh::FEMSystem::_numerical_jacobian_h_for_var, libMesh::FEMSystem::numerical_jacobian_h, and libMesh::Real.

Referenced by libMesh::FEMSystem::numerical_jacobian().

◆ numerical_nonlocal_jacobian()

void FEMSystem::numerical_nonlocal_jacobian ( FEMContext &  context) const
inherited

Uses the results of multiple side_residual() calls to numerically differentiate the corresponding jacobian on nonlocal DoFs.

Definition at line 1345 of file fem_system.C.

1346{
1347 LOG_SCOPE("numerical_nonlocal_jacobian()", "FEMSystem");
1349}
virtual bool nonlocal_residual(bool request_jacobian, DiffContext &)=0
This method uses the DifferentiablePhysics nonlocal_time_derivative(), nonlocal_constraint(),...

References libMesh::TimeSolver::nonlocal_residual(), and libMesh::FEMSystem::numerical_jacobian().

Referenced by libMesh::FEMSystem::assembly().

◆ numerical_side_jacobian()

void FEMSystem::numerical_side_jacobian ( FEMContext &  context) const
inherited

Uses the results of multiple side_residual() calls to numerically differentiate the corresponding jacobian on an element's side.

Definition at line 1337 of file fem_system.C.

1338{
1339 LOG_SCOPE("numerical_side_jacobian()", "FEMSystem");
1341}
virtual bool side_residual(bool request_jacobian, DiffContext &)=0
This method uses the DifferentiablePhysics side_time_derivative(), side_constraint(),...

References libMesh::FEMSystem::numerical_jacobian(), and libMesh::TimeSolver::side_residual().

◆ options_prefix()

const std::string & libMesh::System::options_prefix ( ) const
inlineinherited
Returns
The options prefix of this system's vectors and matrices. See set_options_prefix().

Definition at line 2006 of file system.h.

2006{ return _options_prefix; }

References libMesh::System::_options_prefix.

Referenced by libMesh::System::set_options_prefix().

◆ parallel_op()

void libMesh::DifferentiableQoI::parallel_op ( const Parallel::Communicator &  communicator,
std::vector< Number > &  sys_qoi,
std::vector< Number > &  local_qoi,
const QoISet &  qoi_indices 
)
virtualinherited

Method to populate system qoi data structure with process-local qoi.

By default, simply sums process qois into system qoi.

Definition at line 41 of file diff_qoi.C.

45{
46 // Sum everything into local_qoi
47 communicator.sum(local_qoi);
48
49 // Now put into system qoi
50 sys_qoi = local_qoi;
51}
DIE A HORRIBLE DEATH HERE typedef MPI_Comm communicator

Referenced by libMesh::FEMSystem::assemble_qoi().

◆ point_gradient() [1/4]

Gradient libMesh::System::point_gradient ( unsigned int  var,
const Point &  p,
const bool  insist_on_success = true,
const NumericVector< Number > *  sol = nullptr 
) const
inherited
Returns
The gradient of the solution variable var at the physical point p in the mesh, similarly to point_value.

Definition at line 2403 of file system.C.

2407{
2408 // This function must be called on every processor; there's no
2409 // telling where in the partition p falls.
2410 parallel_object_only();
2411
2412 // And every processor had better agree about which point we're
2413 // looking for
2414#ifndef NDEBUG
2415 libmesh_assert(this->comm().verify(p(0)));
2416#if LIBMESH_DIM > 1
2417 libmesh_assert(this->comm().verify(p(1)));
2418#endif
2419#if LIBMESH_DIM > 2
2420 libmesh_assert(this->comm().verify(p(2)));
2421#endif
2422#endif // NDEBUG
2423
2424 // Get a reference to the mesh object associated with the system object that calls this function
2425 const MeshBase & mesh = this->get_mesh();
2426
2427 // Use an existing PointLocator or create a new one
2428 std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2429 PointLocatorBase & locator = *locator_ptr;
2430
2431 if (!insist_on_success || !mesh.is_serial())
2432 locator.enable_out_of_mesh_mode();
2433
2434 // Get a pointer to an element that contains p and allows us to
2435 // evaluate var
2436 const std::set<subdomain_id_type> & raw_subdomains =
2437 this->variable(var).active_subdomains();
2438 const std::set<subdomain_id_type> * implicit_subdomains =
2439 raw_subdomains.empty() ? nullptr : &raw_subdomains;
2440 const Elem * e = locator(p, implicit_subdomains);
2441
2442 Gradient grad_u;
2443
2444 if (e && this->get_dof_map().is_evaluable(*e, var))
2445 grad_u = point_gradient(var, p, *e, sol);
2446
2447 // If I have an element containing p, then let's let everyone know
2448 processor_id_type lowest_owner =
2449 (e && (e->processor_id() == this->processor_id())) ?
2450 this->processor_id() : this->n_processors();
2451 this->comm().min(lowest_owner);
2452
2453 // Everybody should get their value from a processor that was able
2454 // to compute it.
2455 // If nobody admits owning the point, we may have a problem.
2456 if (lowest_owner != this->n_processors())
2457 this->comm().broadcast(grad_u, lowest_owner);
2458 else
2459 libmesh_assert(!insist_on_success);
2460
2461 return grad_u;
2462}
void min(const T &r, T &o, Request &req) const
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
Gradient point_gradient(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition system.C:2403
const std::set< subdomain_id_type > & active_subdomains() const
Definition variable.h:181
NumberVectorValue Gradient

References libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::libmesh_assert(), mesh, and libMesh::DofObject::processor_id().

Referenced by line_print().

◆ point_gradient() [2/4]

Gradient libMesh::System::point_gradient ( unsigned int  var,
const Point &  p,
const Elem &  e,
const NumericVector< Number > *  sol = nullptr 
) const
inherited
Returns
The gradient of the solution variable var at the physical point p in local Elem e in the mesh, similarly to point_value.

Definition at line 2465 of file system.C.

2469{
2470 // Ensuring that the given point is really in the element is an
2471 // expensive assert, but as long as debugging is turned on we might
2472 // as well try to catch a particularly nasty potential error
2473 libmesh_assert (e.contains_point(p));
2474
2475 if (!sol)
2476 sol = this->current_local_solution.get();
2477
2478 // Get the dof map to get the proper indices for our computation
2479 const DofMap & dof_map = this->get_dof_map();
2480
2481 // write the element dimension into a separate variable.
2482 const unsigned int dim = e.dim();
2483
2484 // Make sure we can evaluate on this element.
2485 libmesh_assert (dof_map.is_evaluable(e, var));
2486
2487 // Need dof_indices for phi[i][j]
2488 std::vector<dof_id_type> dof_indices;
2489
2490 // Fill in the dof_indices for our element
2491 dof_map.dof_indices (&e, dof_indices, var);
2492
2493 // Get the no of dofs associated with this point
2494 const unsigned int num_dofs = cast_int<unsigned int>
2495 (dof_indices.size());
2496
2497 FEType fe_type = dof_map.variable_type(var);
2498
2499 // Map the physical co-ordinates to the master co-ordinates
2500 Point coor = FEMap::inverse_map(dim, &e, p);
2501
2502 // get the shape function value via the FEInterface to also handle the case
2503 // of infinite elements correctly, the shape function is not fe->phi().
2504 FEComputeData fe_data(this->get_equation_systems(), coor);
2505 fe_data.enable_derivative();
2506 FEInterface::compute_data(dim, fe_type, &e, fe_data);
2507
2508 // Get ready to accumulate a gradient
2509 Gradient grad_u;
2510
2511 for (unsigned int l=0; l<num_dofs; l++)
2512 {
2513 // Chartesian coordinates have always LIBMESH_DIM entries,
2514 // local coordinates have as many coordinates as the element has.
2515 for (std::size_t v=0; v<dim; v++)
2516 for (std::size_t xyz=0; xyz<LIBMESH_DIM; xyz++)
2517 {
2518 // FIXME: this needs better syntax: It is matrix-vector multiplication.
2519 grad_u(xyz) += fe_data.local_transform[v][xyz]
2520 * fe_data.dshape[l](v)
2521 * (*sol)(dof_indices[l]);
2522 }
2523 }
2524
2525 return grad_u;
2526}
static void compute_data(const unsigned int dim, const FEType &fe_t, const Elem *elem, FEComputeData &data)
Lets the appropriate child of FEBase compute the requested data for the input specified in data,...
static Point inverse_map(const unsigned int dim, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true, const bool extra_checks=true)
Definition fe_map.C:1512
virtual void get(const std::vector< numeric_index_type > &index, T *values) const
Access multiple components at once.

References libMesh::Elem::contains_point(), dim, libMesh::Elem::dim(), libMesh::DofMap::dof_indices(), libMesh::FEComputeData::dshape, libMesh::FEComputeData::enable_derivative(), libMesh::NumericVector< T >::get(), libMesh::DofMap::is_evaluable(), libMesh::libmesh_assert(), libMesh::FEComputeData::local_transform, and libMesh::DofMap::variable_type().

◆ point_gradient() [3/4]

Gradient libMesh::System::point_gradient ( unsigned int  var,
const Point &  p,
const Elem *  e 
) const
inherited

Calls the version of point_gradient() which takes a reference.

This function exists only to prevent people from calling the version of point_gradient() that has a boolean third argument, which would result in unnecessary PointLocator calls.

Definition at line 2530 of file system.C.

2531{
2532 libmesh_assert(e);
2533 return this->point_gradient(var, p, *e);
2534}

References libMesh::libmesh_assert().

◆ point_gradient() [4/4]

Gradient libMesh::System::point_gradient ( unsigned int  var,
const Point &  p,
const NumericVector< Number > *  sol 
) const
inherited

Calls the parallel version of point_gradient().

This function exists only to prevent people from accidentally calling the version of point_gradient() that has a boolean third argument, which would result in incorrect output.

Definition at line 2538 of file system.C.

2539{
2540 return this->point_gradient(var, p, true, sol);
2541}

◆ point_hessian() [1/4]

Tensor libMesh::System::point_hessian ( unsigned int  var,
const Point &  p,
const bool  insist_on_success = true,
const NumericVector< Number > *  sol = nullptr 
) const
inherited
Returns
The second derivative tensor of the solution variable var at the physical point p in the mesh, similarly to point_value.

Definition at line 2547 of file system.C.

2551{
2552 // This function must be called on every processor; there's no
2553 // telling where in the partition p falls.
2554 parallel_object_only();
2555
2556 // And every processor had better agree about which point we're
2557 // looking for
2558#ifndef NDEBUG
2559 libmesh_assert(this->comm().verify(p(0)));
2560#if LIBMESH_DIM > 1
2561 libmesh_assert(this->comm().verify(p(1)));
2562#endif
2563#if LIBMESH_DIM > 2
2564 libmesh_assert(this->comm().verify(p(2)));
2565#endif
2566#endif // NDEBUG
2567
2568 // Get a reference to the mesh object associated with the system object that calls this function
2569 const MeshBase & mesh = this->get_mesh();
2570
2571 // Use an existing PointLocator or create a new one
2572 std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2573 PointLocatorBase & locator = *locator_ptr;
2574
2575 if (!insist_on_success || !mesh.is_serial())
2576 locator.enable_out_of_mesh_mode();
2577
2578 // Get a pointer to an element that contains p and allows us to
2579 // evaluate var
2580 const std::set<subdomain_id_type> & raw_subdomains =
2581 this->variable(var).active_subdomains();
2582 const std::set<subdomain_id_type> * implicit_subdomains =
2583 raw_subdomains.empty() ? nullptr : &raw_subdomains;
2584 const Elem * e = locator(p, implicit_subdomains);
2585
2586 Tensor hess_u;
2587
2588 if (e && this->get_dof_map().is_evaluable(*e, var))
2589 hess_u = point_hessian(var, p, *e, sol);
2590
2591 // If I have an element containing p, then let's let everyone know
2592 processor_id_type lowest_owner =
2593 (e && (e->processor_id() == this->processor_id())) ?
2594 this->processor_id() : this->n_processors();
2595 this->comm().min(lowest_owner);
2596
2597 // Everybody should get their value from a processor that was able
2598 // to compute it.
2599 // If nobody admits owning the point, we may have a problem.
2600 if (lowest_owner != this->n_processors())
2601 this->comm().broadcast(hess_u, lowest_owner);
2602 else
2603 libmesh_assert(!insist_on_success);
2604
2605 return hess_u;
2606}
Tensor point_hessian(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition system.C:2547
NumberTensorValue Tensor

References libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::libmesh_assert(), mesh, and libMesh::DofObject::processor_id().

◆ point_hessian() [2/4]

Tensor libMesh::System::point_hessian ( unsigned int  var,
const Point &  p,
const Elem &  e,
const NumericVector< Number > *  sol = nullptr 
) const
inherited
Returns
The second derivative tensor of the solution variable var at the physical point p in local Elem e in the mesh, similarly to point_value.

Definition at line 2608 of file system.C.

2612{
2613 // Ensuring that the given point is really in the element is an
2614 // expensive assert, but as long as debugging is turned on we might
2615 // as well try to catch a particularly nasty potential error
2616 libmesh_assert (e.contains_point(p));
2617
2618 if (!sol)
2619 sol = this->current_local_solution.get();
2620
2621 if (e.infinite())
2622 libmesh_not_implemented();
2623
2624 // Get the dof map to get the proper indices for our computation
2625 const DofMap & dof_map = this->get_dof_map();
2626
2627 // Make sure we can evaluate on this element.
2628 libmesh_assert (dof_map.is_evaluable(e, var));
2629
2630 // Need dof_indices for phi[i][j]
2631 std::vector<dof_id_type> dof_indices;
2632
2633 // Fill in the dof_indices for our element
2634 dof_map.dof_indices (&e, dof_indices, var);
2635
2636 // Get the no of dofs associated with this point
2637 const unsigned int num_dofs = cast_int<unsigned int>
2638 (dof_indices.size());
2639
2640 FEType fe_type = dof_map.variable_type(var);
2641
2642 // Build a FE again so we can calculate u(p)
2643 std::unique_ptr<FEBase> fe (FEBase::build(e.dim(), fe_type));
2644
2645 // Map the physical co-ordinates to the master co-ordinates
2646 // Build a vector of point co-ordinates to send to reinit
2647 std::vector<Point> coor(1, FEMap::inverse_map(e.dim(), &e, p));
2648
2649 // Get the values of the shape function derivatives
2650 const std::vector<std::vector<RealTensor>> & d2phi = fe->get_d2phi();
2651
2652 // Reinitialize the element and compute the shape function values at coor
2653 fe->reinit (&e, &coor);
2654
2655 // Get ready to accumulate a hessian
2656 Tensor hess_u;
2657
2658 for (unsigned int l=0; l<num_dofs; l++)
2659 {
2660 hess_u.add_scaled (d2phi[l][0], (*sol)(dof_indices[l]));
2661 }
2662
2663 return hess_u;
2664}
LIBMESH_DEVICE_INLINE void add_scaled(const TypeTensor< T2 > &, const T &)
Add a scaled tensor to this tensor without creating a temporary.

References libMesh::TypeTensor< T >::add_scaled(), libMesh::Elem::contains_point(), libMesh::Elem::dim(), libMesh::DofMap::dof_indices(), libMesh::NumericVector< T >::get(), libMesh::Elem::infinite(), libMesh::DofMap::is_evaluable(), libMesh::libmesh_assert(), and libMesh::DofMap::variable_type().

◆ point_hessian() [3/4]

Tensor libMesh::System::point_hessian ( unsigned int  var,
const Point &  p,
const Elem *  e 
) const
inherited

Calls the version of point_hessian() which takes a reference.

This function exists only to prevent people from calling the version of point_hessian() that has a boolean third argument, which would result in unnecessary PointLocator calls.

Definition at line 2668 of file system.C.

2669{
2670 libmesh_assert(e);
2671 return this->point_hessian(var, p, *e);
2672}

References libMesh::libmesh_assert().

◆ point_hessian() [4/4]

Tensor libMesh::System::point_hessian ( unsigned int  var,
const Point &  p,
const NumericVector< Number > *  sol 
) const
inherited

Calls the parallel version of point_hessian().

This function exists only to prevent people from accidentally calling the version of point_hessian() that has a boolean third argument, which would result in incorrect output.

Definition at line 2676 of file system.C.

2677{
2678 return this->point_hessian(var, p, true, sol);
2679}

◆ point_value() [1/4]

Number libMesh::System::point_value ( unsigned int  var,
const Point &  p,
const bool  insist_on_success = true,
const NumericVector< Number > *  sol = nullptr 
) const
inherited
Returns
The value of the solution variable var at the physical point p in the mesh, without knowing a priori which element contains p, using the degree of freedom coefficients in sol (or in current_local_solution if sol is left null).
Note
This function uses MeshBase::sub_point_locator(); users may or may not want to call MeshBase::clear_point_locator() afterward. Also, point_locator() is expensive (N log N for initial construction, log N for evaluations). Avoid using this function in any context where you are already looping over elements.

Because the element containing p may lie on any processor, this function is parallel-only.

By default this method expects the point to reside inside the domain and will abort if no element can be found which contains p. The optional parameter insist_on_success can be set to false to allow the method to return 0 when the point is not located.

Definition at line 2274 of file system.C.

2278{
2279 // This function must be called on every processor; there's no
2280 // telling where in the partition p falls.
2281 parallel_object_only();
2282
2283 // And every processor had better agree about which point we're
2284 // looking for
2285#ifndef NDEBUG
2286 libmesh_assert(this->comm().verify(p(0)));
2287#if LIBMESH_DIM > 1
2288 libmesh_assert(this->comm().verify(p(1)));
2289#endif
2290#if LIBMESH_DIM > 2
2291 libmesh_assert(this->comm().verify(p(2)));
2292#endif
2293#endif // NDEBUG
2294
2295 // Get a reference to the mesh object associated with the system object that calls this function
2296 const MeshBase & mesh = this->get_mesh();
2297
2298 // Use an existing PointLocator or create a new one
2299 std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2300 PointLocatorBase & locator = *locator_ptr;
2301
2302 if (!insist_on_success || !mesh.is_serial())
2303 locator.enable_out_of_mesh_mode();
2304
2305 // Get a pointer to an element that contains p and allows us to
2306 // evaluate var
2307 const std::set<subdomain_id_type> & raw_subdomains =
2308 this->variable(var).active_subdomains();
2309 const std::set<subdomain_id_type> * implicit_subdomains =
2310 raw_subdomains.empty() ? nullptr : &raw_subdomains;
2311 const Elem * e = locator(p, implicit_subdomains);
2312
2313 Number u = 0;
2314
2315 if (e && this->get_dof_map().is_evaluable(*e, var))
2316 u = point_value(var, p, *e, sol);
2317
2318 // If I have an element containing p, then let's let everyone know
2319 processor_id_type lowest_owner =
2320 (e && (e->processor_id() == this->processor_id())) ?
2321 this->processor_id() : this->n_processors();
2322 this->comm().min(lowest_owner);
2323
2324 // Everybody should get their value from a processor that was able
2325 // to compute it.
2326 // If nobody admits owning the point, we have a problem.
2327 if (lowest_owner != this->n_processors())
2328 this->comm().broadcast(u, lowest_owner);
2329 else
2330 libmesh_assert(!insist_on_success);
2331
2332 return u;
2333}
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition system.C:2274

References libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::libmesh_assert(), mesh, and libMesh::DofObject::processor_id().

Referenced by line_print(), main(), NavierSystem::postprocess(), FEAMRConstraintTest< elem_type, order, family >::testConstrainedSpaceHoldsPolynomials(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testCopyNodalSolutionImpl(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testExodusCopyHighOrderElementSolution(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), PeriodicBCTest::testPeriodicBC(), PeriodicBCTest::testPeriodicSideHierarchic(), SystemsTest::testProjectCubeWithMeshFunction(), EquationSystemsTest::testRepartitionThenReinit(), DisjointNeighborTest::testTempJump(), and DisjointNeighborTest::testTempJumpRefine().

◆ point_value() [2/4]

Number libMesh::System::point_value ( unsigned int  var,
const Point &  p,
const Elem &  e,
const NumericVector< Number > *  sol = nullptr 
) const
inherited
Returns
The value of the solution variable var at the physical point p contained in local Elem e, using the degree of freedom coefficients in sol (or in current_local_solution if sol is left null).

This version of point_value can be run in serial, but assumes e is in the local mesh partition or is algebraically ghosted.

Definition at line 2335 of file system.C.

2339{
2340 // Ensuring that the given point is really in the element is an
2341 // expensive assert, but as long as debugging is turned on we might
2342 // as well try to catch a particularly nasty potential error
2343 libmesh_assert (e.contains_point(p));
2344
2345 if (!sol)
2346 sol = this->current_local_solution.get();
2347
2348 // Get the dof map to get the proper indices for our computation
2349 const DofMap & dof_map = this->get_dof_map();
2350
2351 // Make sure we can evaluate on this element.
2352 libmesh_assert (dof_map.is_evaluable(e, var));
2353
2354 // Need dof_indices for phi[i][j]
2355 std::vector<dof_id_type> dof_indices;
2356
2357 // Fill in the dof_indices for our element
2358 dof_map.dof_indices (&e, dof_indices, var);
2359
2360 // Get the no of dofs associated with this point
2361 const unsigned int num_dofs = cast_int<unsigned int>
2362 (dof_indices.size());
2363
2364 FEType fe_type = dof_map.variable_type(var);
2365
2366 // Map the physical co-ordinates to the master co-ordinates
2367 Point coor = FEMap::inverse_map(e.dim(), &e, p);
2368
2369 // get the shape function value via the FEInterface to also handle the case
2370 // of infinite elements correctly, the shape function is not fe->phi().
2371 FEComputeData fe_data(this->get_equation_systems(), coor);
2372 FEInterface::compute_data(e.dim(), fe_type, &e, fe_data);
2373
2374 // Get ready to accumulate a value
2375 Number u = 0;
2376
2377 for (unsigned int l=0; l<num_dofs; l++)
2378 {
2379 u += fe_data.shape[l] * (*sol)(dof_indices[l]);
2380 }
2381
2382 return u;
2383}

References libMesh::Elem::contains_point(), libMesh::Elem::dim(), libMesh::DofMap::dof_indices(), libMesh::NumericVector< T >::get(), libMesh::DofMap::is_evaluable(), libMesh::libmesh_assert(), libMesh::FEComputeData::shape, and libMesh::DofMap::variable_type().

◆ point_value() [3/4]

Number libMesh::System::point_value ( unsigned int  var,
const Point &  p,
const Elem *  e 
) const
inherited

Calls the version of point_value() which takes a reference.

This function exists only to prevent people from calling the version of point_value() that has a boolean third argument, which would result in unnecessary PointLocator calls.

Definition at line 2387 of file system.C.

2388{
2389 libmesh_assert(e);
2390 return this->point_value(var, p, *e);
2391}

References libMesh::libmesh_assert().

◆ point_value() [4/4]

Number libMesh::System::point_value ( unsigned int  var,
const Point &  p,
const NumericVector< Number > *  sol 
) const
inherited

Calls the parallel version of point_value().

This function exists only to prevent people from accidentally calling the version of point_value() that has a boolean third argument, which would result in incorrect output.

Definition at line 2395 of file system.C.

2396{
2397 return this->point_value(var, p, true, sol);
2398}

◆ pop_physics()

void libMesh::DifferentiableSystem::pop_physics ( )
inherited

Pop a physics object off of our stack.

Definition at line 343 of file diff_system.C.

344{
345 libmesh_assert(!this->_diff_physics.empty());
346
347 this->_diff_physics.pop();
348
349 // If the physics has been changed, we will reassemble
350 // the matrix from scratch before doing an adjoint solve
351 // rather than just transposing
352 this->disable_cache();
353}
virtual void disable_cache() override
Avoids use of any cached data that might affect any solve result.

References libMesh::DifferentiableSystem::_diff_physics, libMesh::ImplicitSystem::disable_cache(), and libMesh::libmesh_assert().

Referenced by main().

◆ postprocess()

void FEMSystem::postprocess ( void  )
overridevirtualinherited

Runs a postprocessing loop over all elements, and if postprocess_sides is true over all sides.

Reimplemented from libMesh::DifferentiableSystem.

Reimplemented in LaplaceSystem, CoupledSystem, LaplaceSystem, NavierSystem, and PoissonSystem.

Definition at line 1127 of file fem_system.C.

1128{
1129 LOG_SCOPE("postprocess()", "FEMSystem");
1130
1131 const MeshBase & mesh = this->get_mesh();
1132
1133 this->update();
1134
1135 // Get the time solver object associated with the system, and tell it that
1136 // we are not solving the adjoint problem
1137 this->get_time_solver().set_is_adjoint(false);
1138
1139 // Loop over every active mesh element on this processor
1141 PostprocessContributions(*this));
1142}

References libMesh::MeshBase::active_local_element_stored_range(), libMesh::System::get_mesh(), libMesh::DifferentiableSystem::get_time_solver(), mesh, libMesh::Threads::parallel_for(), libMesh::TimeSolver::set_is_adjoint(), and libMesh::System::update().

Referenced by main().

◆ prefer_hash_table_matrix_assembly()

void libMesh::System::prefer_hash_table_matrix_assembly ( bool  preference)
inlineinherited

Sets whether to use hash table matrix assembly if the matrix sub-classes support it.

Definition at line 2698 of file system.h.

2699{
2700 libmesh_error_msg_if(
2702 "System::prefer_hash_table_matrix_assembly() should be called before matrices are initialized");
2704}

References libMesh::System::_matrices_initialized, and libMesh::System::_prefer_hash_table_matrix_assembly.

Referenced by main().

◆ prefix()

std::string libMesh::System::prefix ( ) const
inlineinherited
Returns
A prefix that may be applied to solver options. Note that this prefix is only used if prefix_with_name()

Definition at line 1992 of file system.h.

1992{ return this->name() + "_"; }

References libMesh::System::name().

Referenced by libMesh::ContinuationSystem::ContinuationSystem(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::LinearImplicitSystem::solve(), and libMesh::NonlinearImplicitSystem::solve().

◆ prefix_with_name() [1/2]

bool libMesh::System::prefix_with_name ( ) const
inlineinherited
Returns
Whether we are name prefixing

Definition at line 1986 of file system.h.

1986{ return _prefix_with_name; }
bool _prefix_with_name
Whether we are name prefixing solver options.
Definition system.h:2384

References libMesh::System::_prefix_with_name.

Referenced by libMesh::ContinuationSystem::ContinuationSystem(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::LinearImplicitSystem::solve(), libMesh::NonlinearImplicitSystem::solve(), and libMesh::System::System().

◆ prefix_with_name() [2/2]

void libMesh::System::prefix_with_name ( bool  value)
inlineinherited

Instructs this system to prefix solve options with its name for solvers that leverage prefixes.

Definition at line 1981 of file system.h.

static const bool value
Definition xdr_io.C:55

References libMesh::System::_prefix_with_name, and value.

◆ print_info()

void libMesh::ReferenceCounter::print_info ( std::ostream &  out_stream = libMesh::out)
staticinherited

Prints the reference information, by default to libMesh::out.

Definition at line 81 of file reference_counter.C.

82{
84 out_stream << ReferenceCounter::get_info();
85}
static std::string get_info()
Gets a string containing the reference information.

References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().

Referenced by libMesh::LibMeshInit::~LibMeshInit().

◆ processor_id()

processor_id_type libMesh::ParallelObject::processor_id ( ) const
inlineinherited
Returns
The rank of this processor in the group.

Definition at line 114 of file parallel_object.h.

115 { return cast_int<processor_id_type>(_communicator.rank()); }
processor_id_type rank() const

References libMesh::ParallelObject::_communicator, and libMesh::Parallel::Communicator::rank().

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DistributedMesh::add_node(), libMesh::MeshTools::Modification::all_tri(), libMesh::FEMSystem::assembly(), libMesh::MeshBase::assert_equal_to(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::Partitioner::assign_partitioning(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::Partitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::MeshFunction::check_found_elem(), libMesh::DistributedMesh::clear(), libMesh::DistributedMesh::clear_elems(), libMesh::ExodusII_IO_Helper::close(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::compute_communication_map_parameters(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_node_communication_maps(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshBase::count_constraint_rows(), libMesh::ExodusII_IO_Helper::create(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DofMap::distribute_scalar_dofs(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DofMapBase::end_dof(), libMesh::DofMapBase::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMapBase::first_dof(), libMesh::DofMapBase::first_old_dof(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::DofMap::get_info(), libMesh::MeshBase::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::RBEIMEvaluation::get_interior_basis_functions_as_vecs(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::DofMap::get_local_constraints(), libMesh::MeshBase::get_local_constraints(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::SystemSubsetBySubdomain::init(), HeatSystem::init_data(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::DistributedMesh::insert_elem(), libMesh::MeshTools::Modification::interpolate_surface(), libMesh::SparsityPattern::Build::join(), libMesh::RBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), libMesh::TransientRBEvaluation::legacy_write_offline_data_to_files(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DofMap::local_variable_indices(), main(), AugmentSparsityOnInterface::mesh_reinit(), libMesh::TriangulatorInterface::MeshedHole::MeshedHole(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::MeshTools::n_connected_components(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMapBase::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::DistributedMesh::own_node(), libMesh::BoundaryInfo::parallel_sync_node_ids(), libMesh::BoundaryInfo::parallel_sync_side_ids(), libMesh::MeshBase::print_constraint_rows(), libMesh::DofMap::print_dof_constraints(), libMesh::DofMap::process_mesh_constraint_rows(), libMesh::Nemesis_IO_Helper::put_cmap_params(), libMesh::Nemesis_IO_Helper::put_elem_cmap(), libMesh::Nemesis_IO_Helper::put_elem_map(), libMesh::Nemesis_IO_Helper::put_loadbal_param(), libMesh::Nemesis_IO_Helper::put_node_cmap(), libMesh::Nemesis_IO_Helper::put_node_map(), libMesh::XdrIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::NameBasedIO::read(), libMesh::EquationSystems::read(), libMesh::EquationSystems::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), libMesh::CheckpointIO::read_header(), libMesh::ExodusII_IO::read_header(), libMesh::System::read_header(), libMesh::XdrIO::read_header(), libMesh::DynaIO::read_mesh(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::System::read_serialized_data(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::Nemesis_IO_Helper::read_var_names_impl(), libMesh::SimplexRefiner::refine_via_edges(), libMesh::SimplexRefiner::refine_via_edges(), libMesh::StaticCondensationDofMap::reinit(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::DistributedMesh::renumber_nodes_and_elements(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::DistributedMesh::set_next_ids(), libMesh::DistributedMesh::set_next_unique_id(), libMesh::DistributedMesh::set_next_unique_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::RBEIMEvaluation::side_gather_bfs(), MeshFunctionTest::test_bad_gradient_var_with_out_of_mesh_value(), MeshFunctionTest::test_bad_hessian_var_with_out_of_mesh_value(), ExodusTest< elem_type >::test_read_gold(), ExodusTest< elem_type >::test_write(), ExodusC0PolyhedronTest::test_write_and_read_hexagonal_prism(), ExodusC0PolyhedronTest::test_write_and_read_mixed_hex_tet_block_names_impl(), ExodusC0PolygonTest::test_write_and_read_pentagon(), MeshInputTest::testAbaqusRead(), MeshInputTest::testBadGmsh(), BoundaryInfoTest::testBoundaryIDs(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testCopyNodalSolutionImpl(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testDynaFileMappings(), MeshInputTest::testDynaNoSplines(), MeshInputTest::testDynaReadElem(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusCopyHighOrderElementSolution(), MeshInputTest::testExodusFileMappings(), MeshInputTest::testExodusIGASidesets(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), DofMapTest::testGhostConstraintSendList(), MeshInputTest::testGmshBCIDOverlap(), MeshInputTest::testGoodGmsh(), MeshInputTest::testGoodSTL(), MeshInputTest::testGoodSTLBinary(), BoundaryInfoTest::testInternalBoundary(), MeshInputTest::testLowOrderEdgeBlocks(), BoundaryMeshSubdomainTest::testPerBoundarySubdomain(), SystemsTest::testProjectMatrix3D(), BoundaryInfoTest::testShellFaceConstraints(), MeshInputTest::testSingleElementImpl(), BoundaryMeshSubdomainTest::testSingleSubdomain(), WriteVecAndScalar::testSolution(), CheckpointIOTest::testSplitter(), MeshInputTest::testSTLGzipped(), MeshInputTest::testTetgenIO(), MeshInputTest::testUCDWriteNodalData(), MeshSmootherTest::testVariationalSmoother(), libMesh::MeshTools::total_weight(), libMesh::NetGenMeshInterface::triangulate(), libMesh::Parallel::Packing< Elem * >::unpack(), libMesh::Parallel::Packing< Node * >::unpack(), libMesh::DTKAdapter::update_variable_values(), libMesh::MeshTools::volume(), libMesh::STLIO::write(), libMesh::XdrIO::write(), libMesh::NameBasedIO::write(), libMesh::CheckpointIO::write(), libMesh::EquationSystems::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO::write_element_data_from_discontinuous_nodal_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_element_values_element_major(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO_Helper::write_elemset_data(), libMesh::ExodusII_IO_Helper::write_elemsets(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::System::write_header(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), libMesh::UCDIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_common(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::ExodusII_IO_Helper::write_nodeset_data(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::RBEIMEvaluation::write_out_interior_basis_functions(), libMesh::RBEIMEvaluation::write_out_node_basis_functions(), libMesh::RBEIMEvaluation::write_out_side_basis_functions(), write_output_solvedata(), libMesh::System::write_parallel_data(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::System::write_serialized_data(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), libMesh::ExodusII_IO_Helper::write_sideset_data(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), libMesh::ExodusII_IO_Helper::write_timestep(), and libMesh::ExodusII_IO::write_timestep_discontinuous().

◆ project_solution() [1/3]

void libMesh::System::project_solution ( FEMFunctionBase< Number > *  f,
FEMFunctionBase< Gradient > *  g = nullptr,
std::optional< ConstElemRange >  active_local_range = std::nullopt,
std::optional< std::vector< unsigned int > >  variable_numbers = std::nullopt 
) const
inherited

Projects arbitrary functions onto the current solution.

This method projects an arbitrary function onto the solution via L2 projections and nodal interpolations on each element.

The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives. elem_range active_local_range, if provided, indicates the range of elements over which to perform the projection. variable_numbers variable_numbers, if provided, indicates the variable numbers onto which to project.

Definition at line 1073 of file system_projection.C.

1077{
1078 this->project_vector(*solution, f, g, /*is_adjoint=*/-1, active_local_range, variable_numbers);
1079
1080 solution->localize(*current_local_solution, _dof_map->get_send_list());
1081}
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.

◆ project_solution() [2/3]

void libMesh::System::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
inherited

Projects arbitrary functions onto the current solution.

This method projects an arbitrary function onto the solution via L2 projections and nodal interpolations on each element.

The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives. elem_range active_local_range, if provided, indicates the range of elements over which to perform the projection. variable_numbers variable_numbers, if provided, indicates the variable numbers onto which to project.

Definition at line 1058 of file system_projection.C.

1062{
1063 this->project_vector(*solution, f, g, /*is_adjoint=*/-1, active_local_range, variable_numbers);
1064
1065 solution->localize(*current_local_solution, _dof_map->get_send_list());
1066}

Referenced by init_sys(), initialize(), main(), set_initial_condition(), FETestBase< order, family, elem_type, build_nx, CaseName >::setUp(), SlitMeshRefinedSystemTest::setUp(), MeshFunctionTest::test_bad_gradient_var_with_out_of_mesh_value(), MeshFunctionTest::test_bad_hessian_var_with_out_of_mesh_value(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), ProjectSolutionTest::test_partial_project_solution(), MeshFunctionTest::test_subdomain_id_sets(), FEAMRConstraintTest< elem_type, order, family >::testConstrainedSpaceHoldsPolynomials(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyNodalSolutionImpl(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testExodusCopyHighOrderElementSolution(), PeriodicBCTest::testPeriodicSideHierarchic(), SystemsTest::testProjectCubeWithMeshFunction(), MeshInputTest::testProjectionRegression(), EquationSystemsTest::testRepartitionThenReinit(), and libMesh::MeshfreeSolutionTransfer::transfer().

◆ project_solution() [3/3]

void libMesh::System::project_solution ( ValueFunctionPointer  fptr,
GradientFunctionPointer  gptr,
const Parameters &  parameters,
std::optional< ConstElemRange >  active_local_range = std::nullopt,
std::optional< std::vector< unsigned int > >  variable_numbers = std::nullopt 
) const
inherited

This method projects an arbitrary function onto the solution via L2 projections and nodal interpolations on each element.

Definition at line 1042 of file system_projection.C.

1047{
1048 WrappedFunction<Number> f(*this, fptr, &function_parameters);
1049 WrappedFunction<Gradient> g(*this, gptr, &function_parameters);
1050 this->project_solution(&f, &g, active_local_range, variable_numbers);
1051}
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.

References fptr(), and gptr().

◆ project_solution_on_reinit()

bool & libMesh::System::project_solution_on_reinit ( void  )
inlineinherited

Tells the System whether or not to project the solution vector onto new grids when the system is reinitialized.

The solution will be projected unless project_solution_on_reinit() = false is called.

Definition at line 896 of file system.h.

897 { return _solution_projection; }
bool _solution_projection
Holds true if the solution vector should be projected onto a changed grid, false if it should be zero...
Definition system.h:2320

References libMesh::System::_solution_projection.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), and libMesh::MemoryHistoryData::store_vectors().

◆ project_vector() [1/5]

void libMesh::System::project_vector ( const NumericVector< Number > &  old_v,
NumericVector< Number > &  new_v,
int  is_adjoint = -1,
std::optional< ConstElemRange >  active_local_range = std::nullopt,
std::optional< std::vector< unsigned int > >  variable_numbers = std::nullopt 
) const
protectedinherited

Projects the vector defined on the old mesh onto the new mesh.

This method projects the vector via L2 projections or nodal interpolations on each element.

The original vector is unchanged and the new vector is passed through the second argument.

Constrain the new vector using the requested adjoint rather than primal constraints if is_adjoint is non-negative.

This method projects a solution from an old mesh to a current, refined mesh. The input vector old_v gives the solution on the old mesh, while the new_v gives the solution (to be computed) on the new mesh.

Definition at line 268 of file system_projection.C.

273{
274 LOG_SCOPE ("project_vector(old,new)", "System");
275
282 new_v.clear();
283
284#ifdef LIBMESH_ENABLE_AMR
285
286 // Resize the new vector and get a serial version.
287 NumericVector<Number> * new_vector_ptr = nullptr;
288 std::unique_ptr<NumericVector<Number>> new_vector_built;
289 NumericVector<Number> * local_old_vector;
290 std::unique_ptr<NumericVector<Number>> local_old_vector_built;
291 const NumericVector<Number> * old_vector_ptr = nullptr;
292
293 const ConstElemRange & range =
294 active_local_range ?
295 active_local_range.value() :
297
298 // If the old vector was uniprocessor, make the new
299 // vector uniprocessor
300 if (old_v.type() == SERIAL)
301 {
302 new_v.init (this->n_dofs(), false, SERIAL);
303 new_vector_ptr = &new_v;
304 old_vector_ptr = &old_v;
305 }
306
307 // Otherwise it is a parallel, distributed vector, which
308 // we need to localize.
309 else if (old_v.type() == PARALLEL)
310 {
311 // Build a send list for efficient localization
312 BuildProjectionList projection_list(*this);
313 Threads::parallel_reduce (range, projection_list);
314
315 // Create a sorted, unique send_list
316 projection_list.unique();
317
318 new_v.init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
319 new_vector_built = NumericVector<Number>::build(this->comm());
320 local_old_vector_built = NumericVector<Number>::build(this->comm());
321 new_vector_ptr = new_vector_built.get();
322 local_old_vector = local_old_vector_built.get();
323 new_vector_ptr->init(this->n_dofs(), this->n_local_dofs(),
324 this->get_dof_map().get_send_list(), false,
325 GHOSTED);
326 local_old_vector->init(old_v.size(), old_v.local_size(),
327 projection_list.send_list, false, GHOSTED);
328 old_v.localize(*local_old_vector, projection_list.send_list);
329 local_old_vector->close();
330 old_vector_ptr = local_old_vector;
331 }
332 else if (old_v.type() == GHOSTED)
333 {
334 // Build a send list for efficient localization
335 BuildProjectionList projection_list(*this);
336 Threads::parallel_reduce (range, projection_list);
337
338 // Create a sorted, unique send_list
339 projection_list.unique();
340
341 new_v.init (this->n_dofs(), this->n_local_dofs(),
342 this->get_dof_map().get_send_list(), false, GHOSTED);
343
344 local_old_vector_built = NumericVector<Number>::build(this->comm());
345 new_vector_ptr = &new_v;
346 local_old_vector = local_old_vector_built.get();
347 local_old_vector->init(old_v.size(), old_v.local_size(),
348 projection_list.send_list, false, GHOSTED);
349 old_v.localize(*local_old_vector, projection_list.send_list);
350 local_old_vector->close();
351 old_vector_ptr = local_old_vector;
352 }
353 else // unknown old_v.type()
354 libmesh_error_msg("ERROR: Unknown old_v.type() == " << old_v.type());
355
356 // Note that the above will have zeroed the new_vector.
357 // Just to be sure, assert that new_vector_ptr and old_vector_ptr
358 // were successfully set before trying to deref them.
359 libmesh_assert(new_vector_ptr);
360 libmesh_assert(old_vector_ptr);
361
362 NumericVector<Number> & new_vector = *new_vector_ptr;
363 const NumericVector<Number> & old_vector = *old_vector_ptr;
364
365 const unsigned int n_variables = this->n_vars();
366
367 if (n_variables)
368 {
369 std::vector<unsigned int> vars;
370 if (variable_numbers)
371 {
372 vars = *variable_numbers;
373 for (auto v : vars)
374 if (v >= n_variables)
375 libmesh_error_msg("ERROR: variable number " << v <<
376 " out of range for system with " <<
377 n_variables << " variables.");
378 }
379 else
380 {
381 vars.resize(n_variables);
382 std::iota(vars.begin(), vars.end(), 0);
383 }
384
385 std::vector<unsigned int> regular_vars, vector_vars, scalar_vars;
386 for (auto var : vars)
387 {
388 if (this->variable(var).type().family == SCALAR)
389 scalar_vars.push_back(var);
390 else if (FEInterface::field_type(this->variable_type(var)) == TYPE_SCALAR)
391 regular_vars.push_back(var);
392 else
393 vector_vars.push_back(var);
394 }
395
396 VectorSetAction<Number> setter(new_vector);
397
398 if (!regular_vars.empty())
399 {
400 // Use a typedef to make the calling sequence for parallel_for() a bit more readable
401 typedef
402 GenericProjector<OldSolutionValue<Number, &FEMContext::point_value>,
403 OldSolutionValue<Gradient, &FEMContext::point_gradient>,
404 Number, VectorSetAction<Number>> FEMProjector;
405
406 OldSolutionValue<Number, &FEMContext::point_value>
407 f(*this, old_vector, &regular_vars);
408 OldSolutionValue<Gradient, &FEMContext::point_gradient>
409 g(*this, old_vector, &regular_vars);
410
411 FEMProjector projector(*this, f, &g, setter, regular_vars);
412 projector.project(range);
413 }
414
415 if (!vector_vars.empty())
416 {
417 typedef
418 GenericProjector<OldSolutionValue<Gradient, &FEMContext::point_value>,
419 OldSolutionValue<Tensor, &FEMContext::point_gradient>,
420 Gradient, VectorSetAction<Number>> FEMVectorProjector;
421
422 OldSolutionValue<Gradient, &FEMContext::point_value> f_vector(*this, old_vector, &vector_vars);
423 OldSolutionValue<Tensor, &FEMContext::point_gradient> g_vector(*this, old_vector, &vector_vars);
424
425 FEMVectorProjector vector_projector(*this, f_vector, &g_vector, setter, vector_vars);
426 vector_projector.project(range);
427 }
428
429 // Copy the SCALAR dofs from old_vector to new_vector
430 // Note: We assume that all SCALAR dofs are on the
431 // processor with highest ID
432 if (this->processor_id() == (this->n_processors()-1))
433 {
434 const DofMap & dof_map = this->get_dof_map();
435 for (auto var : scalar_vars)
436 {
437 // We can just map SCALAR dofs directly across
438 std::vector<dof_id_type> new_SCALAR_indices, old_SCALAR_indices;
439 dof_map.SCALAR_dof_indices (new_SCALAR_indices, var, false);
440 dof_map.SCALAR_dof_indices (old_SCALAR_indices, var, true);
441 for (auto i : index_range(new_SCALAR_indices))
442 new_vector.set(new_SCALAR_indices[i], old_vector(old_SCALAR_indices[i]));
443 }
444 }
445 }
446
447 new_vector.close();
448
449 // If the old vector was serial, we probably need to send our values
450 // to other processors
451 //
452 // FIXME: I'm not sure how to make a NumericVector do that without
453 // creating a temporary parallel vector to use localize! - RHS
454 if (old_v.type() == SERIAL)
455 {
456 std::unique_ptr<NumericVector<Number>> dist_v = NumericVector<Number>::build(this->comm());
457 dist_v->init(this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
458 dist_v->close();
459
460 for (auto i : make_range(dist_v->size()))
461 if (new_vector(i) != 0.0)
462 dist_v->set(i, new_vector(i));
463
464 dist_v->close();
465
466 dist_v->localize (new_v, this->get_dof_map().get_send_list());
467 new_v.close();
468 }
469 // If the old vector was parallel, we need to update it
470 // and free the localized copies
471 else if (old_v.type() == PARALLEL)
472 {
473 // We may have to set dof values that this processor doesn't
474 // own in certain special cases, like LAGRANGE FIRST or
475 // HERMITE THIRD elements on second-order meshes?
476 new_v = new_vector;
477 new_v.close();
478 }
479
480
481 // Apply constraints only if we we are asked to
483 {
484 if (is_adjoint == -1)
485 {
486 this->get_dof_map().enforce_constraints_exactly(*this, &new_v);
487 }
488 else if (is_adjoint >= 0)
489 {
491 is_adjoint);
492 }
493 }
494#else
495
496 // AMR is disabled: simply copy the vector
497 new_v = old_v;
498
499 libmesh_ignore(is_adjoint, active_local_range, variable_numbers);
500
501#endif // #ifdef LIBMESH_ENABLE_AMR
502}
virtual void clear()
Restores the NumericVector<T> to a pristine state.
ParallelType type() const
virtual void init(const numeric_index_type n, const numeric_index_type n_local, const bool fast=false, const ParallelType ptype=AUTOMATIC)=0
Change the dimension of the vector to n.
const FEType & variable_type(const unsigned int i) const
Definition system.C:2776
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition int_range.h:153

References libMesh::NumericVector< T >::clear(), libMesh::NumericVector< T >::close(), libMesh::NumericVector< T >::get(), libMesh::GHOSTED, libMesh::index_range(), libMesh::NumericVector< T >::init(), libMesh::libmesh_assert(), libMesh::libmesh_ignore(), libMesh::NumericVector< T >::local_size(), libMesh::NumericVector< T >::localize(), libMesh::make_range(), n_vars, libMesh::PARALLEL, libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::BuildProjectionList::send_list, libMesh::SERIAL, libMesh::NumericVector< T >::set(), libMesh::NumericVector< T >::size(), libMesh::NumericVector< T >::type(), libMesh::TYPE_SCALAR, and libMesh::BuildProjectionList::unique().

◆ project_vector() [2/5]

void libMesh::System::project_vector ( NumericVector< Number > &  vector,
int  is_adjoint = -1,
std::optional< ConstElemRange >  active_local_range = std::nullopt,
std::optional< std::vector< unsigned int > >  variable_numbers = std::nullopt 
) const
protectedinherited

Projects the vector defined on the old mesh onto the new mesh.

Constrain the new vector using the requested adjoint rather than primal constraints if is_adjoint is non-negative.

Definition at line 248 of file system_projection.C.

252{
253 // Create a copy of the vector, which currently
254 // contains the old data.
255 std::unique_ptr<NumericVector<Number>>
256 old_vector (vector.clone());
257
258 // Project the old vector to the new vector
259 this->project_vector (*old_vector, vector, is_adjoint, active_local_range, variable_numbers);
260}
virtual std::unique_ptr< NumericVector< T > > clone() const =0

References libMesh::NumericVector< T >::clone().

◆ project_vector() [3/5]

void libMesh::System::project_vector ( NumericVector< Number > &  new_vector,
FEMFunctionBase< Number > *  f,
FEMFunctionBase< 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
inherited

Projects arbitrary functions onto a vector of degree of freedom values for the current system.

This method projects an arbitrary function via L2 projections and nodal interpolations on each element.

The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives. elem_range active_local_range, if provided, indicates the range of elements over which to perform the projection. variable_numbers variable_numbers, if provided, indicates the variable numbers onto which to project.

Constrain the new vector using the requested adjoint rather than primal constraints if is_adjoint is non-negative.

Definition at line 1133 of file system_projection.C.

1139{
1140 LOG_SCOPE ("project_fem_vector()", "System");
1141
1142 libmesh_assert (f);
1143
1144 const ConstElemRange & range =
1145 active_local_range ?
1146 active_local_range.value() :
1148
1149 VectorSetAction<Number> setter(new_vector);
1150
1151 const unsigned int n_variables = this->n_vars();
1152
1153 std::vector<unsigned int> vars;
1154 if (variable_numbers)
1155 {
1156 vars = *variable_numbers;
1157 for (auto v : vars)
1158 if (v >= n_variables)
1159 libmesh_error_msg("ERROR: variable number " << v <<
1160 " out of range for system with " <<
1161 n_variables << " variables.");
1162 }
1163 else
1164 {
1165 vars.resize(n_variables);
1166 std::iota(vars.begin(), vars.end(), 0);
1167 }
1168
1169
1170 // Use a typedef to make the calling sequence for parallel_for() a bit more readable
1171 typedef
1172 GenericProjector<FEMFunctionWrapper<Number>, FEMFunctionWrapper<Gradient>,
1173 Number, VectorSetAction<Number>> FEMProjector;
1174
1175 FEMFunctionWrapper<Number> fw(*f);
1176
1177 if (g)
1178 {
1179 FEMFunctionWrapper<Gradient> gw(*g);
1180
1181 FEMProjector projector(*this, fw, &gw, setter, vars);
1182 projector.project(range);
1183 }
1184 else
1185 {
1186 FEMProjector projector(*this, fw, nullptr, setter, vars);
1187 projector.project(range);
1188 }
1189
1190 // Also, load values into the SCALAR dofs
1191 // Note: We assume that all SCALAR dofs are on the
1192 // processor with highest ID
1193 if (this->processor_id() == (this->n_processors()-1))
1194 {
1195 // FIXME: Do we want to first check for SCALAR vars before building this? [PB]
1196 FEMContext context( *this );
1197
1198 const DofMap & dof_map = this->get_dof_map();
1199 for (auto var : vars)
1200 if (this->variable(var).type().family == SCALAR)
1201 {
1202 // FIXME: We reinit with an arbitrary element in case the user
1203 // doesn't override FEMFunctionBase::component. Is there
1204 // any use case we're missing? [PB]
1205 context.pre_fe_reinit(*this, *(this->get_mesh().active_local_elements_begin()));
1206
1207 std::vector<dof_id_type> SCALAR_indices;
1208 dof_map.SCALAR_dof_indices (SCALAR_indices, var);
1209 const unsigned int n_SCALAR_dofs =
1210 cast_int<unsigned int>(SCALAR_indices.size());
1211
1212 for (unsigned int i=0; i<n_SCALAR_dofs; i++)
1213 {
1214 const dof_id_type global_index = SCALAR_indices[i];
1215 const unsigned int component_index =
1216 this->variable_scalar_number(var,i);
1217
1218 new_vector.set(global_index, f->component(context, component_index, Point(), this->time));
1219 }
1220 }
1221 }
1222
1223 new_vector.close();
1224
1225 // Look for spline bases, in which case we need to backtrack
1226 // to calculate the spline DoF values.
1227 std::vector<const Variable *> rational_vars;
1228 for (auto varnum : vars)
1229 {
1230 const Variable & var = this->get_dof_map().variable(varnum);
1231 if (var.type().family == RATIONAL_BERNSTEIN)
1232 rational_vars.push_back(&var);
1233 }
1234
1235 // Okay, but are we really using any *spline* bases, or just
1236 // unconstrained rational bases?
1237 bool using_spline_bases = false;
1238 if (!rational_vars.empty())
1239 {
1240 // Look for a spline node: a NodeElem with a rational variable
1241 // on it.
1242 for (auto & elem : range)
1243 if (elem->type() == NODEELEM)
1244 for (auto rational_var : rational_vars)
1245 if (rational_var->active_on_subdomain(elem->subdomain_id()))
1246 {
1247 using_spline_bases = true;
1248 goto checked_on_splines;
1249 }
1250 }
1251
1252checked_on_splines:
1253
1254 // Not every processor may have a NodeElem, especially while
1255 // we're not partitioning them efficiently yet.
1256 this->comm().max(using_spline_bases);
1257
1258 if (using_spline_bases)
1259 this->solve_for_unconstrained_dofs(new_vector, is_adjoint);
1260
1261#ifdef LIBMESH_ENABLE_CONSTRAINTS
1262 if (is_adjoint == -1)
1263 this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
1264 else if (is_adjoint >= 0)
1266 is_adjoint);
1267#else
1268 libmesh_ignore(is_adjoint);
1269#endif
1270}
const Variable & variable(const unsigned int c) const override
Definition dof_map.h:2442
virtual Output component(const FEMContext &, unsigned int i, const Point &p, Real time=0.)
virtual void set(const numeric_index_type i, const T value)=0
Sets v(i) = value.
void solve_for_unconstrained_dofs(NumericVector< Number > &, int is_adjoint=-1) const
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
Definition system.h:1689
unsigned int variable_scalar_number(std::string_view var, unsigned int component) const
Definition system.h:2505
@ RATIONAL_BERNSTEIN

References libMesh::NumericVector< T >::close(), libMesh::FEMFunctionBase< Output >::component(), libMesh::FEType::family, libMesh::libmesh_assert(), libMesh::libmesh_ignore(), n_vars, libMesh::NODEELEM, libMesh::FEMContext::pre_fe_reinit(), libMesh::RATIONAL_BERNSTEIN, libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::NumericVector< T >::set(), and libMesh::Variable::type().

◆ project_vector() [4/5]

void libMesh::System::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
inherited

Projects arbitrary functions onto a vector of degree of freedom values for the current system.

This method projects an arbitrary function via L2 projections and nodal interpolations on each element.

The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives. elem_range active_local_range, if provided, indicates the range of elements over which to perform the projection. variable_numbers variable_numbers, if provided, indicates the variable numbers onto which to project.

Constrain the new vector using the requested adjoint rather than primal constraints if is_adjoint is non-negative.

Definition at line 1105 of file system_projection.C.

1111{
1112 LOG_SCOPE ("project_vector(FunctionBase)", "System");
1113
1114 libmesh_assert(f);
1115
1116 WrappedFunctor<Number> f_fem(*f);
1117
1118 if (g)
1119 {
1120 WrappedFunctor<Gradient> g_fem(*g);
1121
1122 this->project_vector(new_vector, &f_fem, &g_fem, is_adjoint, active_local_range, variable_numbers);
1123 }
1124 else
1125 this->project_vector(new_vector, &f_fem, nullptr, is_adjoint, active_local_range, variable_numbers);
1126}

References libMesh::libmesh_assert().

Referenced by main(), libMesh::NewmarkSolver::project_initial_accel(), libMesh::SecondOrderUnsteadySolver::project_initial_rate(), libMesh::InterMeshProjection::project_system_vectors(), and libMesh::System::restrict_vectors().

◆ project_vector() [5/5]

void libMesh::System::project_vector ( ValueFunctionPointer  fptr,
GradientFunctionPointer  gptr,
const Parameters &  parameters,
NumericVector< Number > &  new_vector,
int  is_adjoint = -1,
std::optional< ConstElemRange >  active_local_range = std::nullopt,
std::optional< std::vector< unsigned int > >  variable_numbers = std::nullopt 
) const
inherited

Projects arbitrary functions onto a vector of degree of freedom values for the current system.

This method projects an arbitrary function via L2 projections and nodal interpolations on each element.

The function value fptr and its gradient gptr are represented by function pointers. A gradient gptr is only required/used for projecting onto finite element spaces with continuous derivatives. elem_range active_local_range, if provided, indicates the range of elements over which to perform the projection. variable_numbers variable_numbers, if provided, indicates the variable numbers onto which to project.

Constrain the new vector using the requested adjoint rather than primal constraints if is_adjoint is non-negative.

Definition at line 1088 of file system_projection.C.

1095{
1096 WrappedFunction<Number> f(*this, fptr, &function_parameters);
1097 WrappedFunction<Gradient> g(*this, gptr, &function_parameters);
1098 this->project_vector(new_vector, &f, &g, is_adjoint, active_local_range, variable_numbers);
1099}

References fptr(), and gptr().

◆ projection_matrix()

void libMesh::System::projection_matrix ( SparseMatrix< Number > &  proj_mat) const
inherited

This method creates a projection matrix which corresponds to the operation of project_vector between old and new solution spaces.

Heterogeneous Dirichlet boundary conditions are not taken into account here; if this matrix is used for prolongation (mesh refinement) on a side with a heterogeneous BC, the newly created degrees of freedom on that side will still match the coarse grid approximation of the BC, not the fine grid approximation.

Definition at line 980 of file system_projection.C.

981{
982 LOG_SCOPE ("projection_matrix()", "System");
983
984 const unsigned int n_variables = this->n_vars();
985
986 if (n_variables)
987 {
988 std::vector<unsigned int> vars(n_variables);
989 std::iota(vars.begin(), vars.end(), 0);
990
991 // Use a typedef to make the calling sequence for parallel_for() a bit more readable
992 typedef OldSolutionCoefs<Real, &FEMContext::point_value> OldSolutionValueCoefs;
993 typedef OldSolutionCoefs<RealGradient, &FEMContext::point_gradient> OldSolutionGradientCoefs;
994
995 typedef
996 GenericProjector<OldSolutionValueCoefs,
997 OldSolutionGradientCoefs,
998 DynamicSparseNumberArray<Real,dof_id_type>,
999 MatrixFillAction<Real, Number> > ProjMatFiller;
1000
1001 OldSolutionValueCoefs f(*this, &vars);
1002 OldSolutionGradientCoefs g(*this, &vars);
1003 MatrixFillAction<Real, Number> setter(proj_mat);
1004
1005 ProjMatFiller mat_filler(*this, f, &g, setter, vars);
1006 mat_filler.project(this->get_mesh().active_local_element_stored_range());
1007
1008 // Set the SCALAR dof transfer entries too.
1009 // Note: We assume that all SCALAR dofs are on the
1010 // processor with highest ID
1011 if (this->processor_id() == (this->n_processors()-1))
1012 {
1013 const DofMap & dof_map = this->get_dof_map();
1014 for (auto var : make_range(this->n_vars()))
1015 if (this->variable(var).type().family == SCALAR)
1016 {
1017 // We can just map SCALAR dofs directly across
1018 std::vector<dof_id_type> new_SCALAR_indices, old_SCALAR_indices;
1019 dof_map.SCALAR_dof_indices (new_SCALAR_indices, var, false);
1020 dof_map.SCALAR_dof_indices (old_SCALAR_indices, var, true);
1021 const unsigned int new_n_dofs =
1022 cast_int<unsigned int>(new_SCALAR_indices.size());
1023
1024 for (unsigned int i=0; i<new_n_dofs; i++)
1025 {
1026 proj_mat.set( new_SCALAR_indices[i],
1027 old_SCALAR_indices[i], 1);
1028 }
1029 }
1030 }
1031 }
1032}
virtual void set(const numeric_index_type i, const numeric_index_type j, const T value)=0
Set the element (i,j) to value.

References libMesh::make_range(), n_vars, libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), and libMesh::SparseMatrix< T >::set().

Referenced by libMesh::PetscDMWrapper::init_petscdm(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), and SystemsTest::testProjectMatrix3D().

◆ prolong_vectors()

void libMesh::System::prolong_vectors ( )
virtualinherited

Prolong vectors after the mesh has refined.

Definition at line 439 of file system.C.

440{
441#ifdef LIBMESH_ENABLE_AMR
442 // Currently project_vector handles both restriction and prolongation
443 this->restrict_vectors();
444#endif
445}
virtual void restrict_vectors()
Restrict vectors after the mesh has coarsened.
Definition system.C:381

References libMesh::System::restrict_vectors().

Referenced by libMesh::EquationSystems::reinit_solutions().

◆ push_physics()

void libMesh::DifferentiableSystem::push_physics ( DifferentiablePhysics &  new_physics)
inherited

Push a clone of a new physics object onto our stack, overriding the current physics until the new physics is popped off again (or until something else is pushed on top of it).

Definition at line 331 of file diff_system.C.

332{
333 this->_diff_physics.push(new_physics.clone_physics());
334
335 // If the physics has been changed, we will reassemble
336 // the matrix from scratch before doing an adjoint solve
337 // rather than just transposing
338 this->disable_cache();
339}

References libMesh::DifferentiableSystem::_diff_physics, libMesh::DifferentiablePhysics::clone_physics(), and libMesh::ImplicitSystem::disable_cache().

Referenced by main().

◆ qoi_parameter_hessian()

void libMesh::ImplicitSystem::qoi_parameter_hessian ( const QoISet &  qoi_indices,
const ParameterVector &  parameters,
SensitivityData &  hessian 
)
overridevirtualinherited

For each of the system's quantities of interest q in qoi[qoi_indices], and for a vector of parameters p, the parameter sensitivity Hessian H_ij is defined as H_ij = (d^2 q)/(d p_i d p_j) This Hessian is the output of this method, where for each q_i, H_jk is stored in hessian.second_derivative(i,j,k).

Note that in some cases only current_local_solution is used during assembly, and, therefore, if solution has been altered without update() being called, then the user must call update() before calling this function.

Reimplemented from libMesh::System.

Definition at line 922 of file implicit_system.C.

925{
926 // We currently get partial derivatives via finite differencing
927 const Real delta_p = TOLERANCE;
928
929 ParameterVector & parameters_vec =
930 const_cast<ParameterVector &>(parameters_in);
931
932 // We'll use one temporary vector for matrix-vector-vector products
933 std::unique_ptr<NumericVector<Number>> tempvec = this->solution->zero_clone();
934
935 // And another temporary vector to hold a copy of the true solution
936 // so we can safely perturb this->solution.
937 std::unique_ptr<NumericVector<Number>> oldsolution = this->solution->clone();
938
939 const unsigned int Np = cast_int<unsigned int>
940 (parameters_vec.size());
941 const unsigned int Nq = this->n_qois();
942
943 // For each quantity of interest q, the parameter sensitivity
944 // Hessian is defined as q''_{kl} = {d^2 q}/{d p_k d p_l}.
945 //
946 // We calculate it from values and partial derivatives of the
947 // quantity of interest function Q, solution u, adjoint solution z,
948 // and residual R, as:
949 //
950 // q''_{kl} =
951 // Q''_{kl} + Q''_{uk}(u)*u'_l + Q''_{ul}(u) * u'_k +
952 // Q''_{uu}(u)*u'_k*u'_l -
953 // R''_{kl}(u,z) -
954 // R''_{uk}(u,z)*u'_l - R''_{ul}(u,z)*u'_k -
955 // R''_{uu}(u,z)*u'_k*u'_l
956 //
957 // See the adjoints model document for more details.
958
959 // We first do an adjoint solve to get z for each quantity of
960 // interest
961 // if we haven't already or dont have an initial condition for the adjoint
962 if (!this->is_adjoint_already_solved())
963 {
964 this->adjoint_solve(qoi_indices);
965 }
966
967 // And a sensitivity solve to get u_k for each parameter
968 this->sensitivity_solve(parameters_vec);
969
970 // Get ready to fill in second derivatives:
971 sensitivities.allocate_hessian_data(qoi_indices, *this, parameters_vec);
972
973 for (unsigned int k=0; k != Np; ++k)
974 {
975 Number old_parameterk = *parameters_vec[k];
976
977 // The Hessian is symmetric, so we just calculate the lower
978 // triangle and the diagonal, and we get the upper triangle from
979 // the transpose of the lower
980
981 for (unsigned int l=0; l != k+1; ++l)
982 {
983 // The second partial derivatives with respect to parameters_vec
984 // are all calculated via a central finite difference
985 // stencil:
986 // F''_{kl} ~= (F(p+dp*e_k+dp*e_l) - F(p+dp*e_k-dp*e_l) -
987 // F(p-dp*e_k+dp*e_l) + F(p-dp*e_k-dp*e_l))/(4*dp^2)
988 // We will add Q''_{kl}(u) and subtract R''_{kl}(u,z) at the
989 // same time.
990 //
991 // We have to be careful with the perturbations to handle
992 // the k=l case
993
994 Number old_parameterl = *parameters_vec[l];
995
996 *parameters_vec[k] += delta_p;
997 *parameters_vec[l] += delta_p;
998 this->assemble_qoi(qoi_indices);
999 this->assembly(true, false, true);
1000 this->rhs->close();
1001 std::vector<Number> partial2q_term = this->get_qoi_values();
1002 std::vector<Number> partial2R_term(this->n_qois());
1003 for (unsigned int i=0; i != Nq; ++i)
1004 if (qoi_indices.has_index(i))
1005 partial2R_term[i] = this->rhs->dot(this->get_adjoint_solution(i));
1006
1007 *parameters_vec[l] -= 2.*delta_p;
1008 this->assemble_qoi(qoi_indices);
1009 this->assembly(true, false, true);
1010 this->rhs->close();
1011 for (unsigned int i=0; i != Nq; ++i)
1012 if (qoi_indices.has_index(i))
1013 {
1014 partial2q_term[i] -= this->get_qoi_value(i);
1015 partial2R_term[i] -= this->rhs->dot(this->get_adjoint_solution(i));
1016 }
1017
1018 *parameters_vec[k] -= 2.*delta_p;
1019 this->assemble_qoi(qoi_indices);
1020 this->assembly(true, false, true);
1021 this->rhs->close();
1022 for (unsigned int i=0; i != Nq; ++i)
1023 if (qoi_indices.has_index(i))
1024 {
1025 partial2q_term[i] += this->get_qoi_value(i);
1026 partial2R_term[i] += this->rhs->dot(this->get_adjoint_solution(i));
1027 }
1028
1029 *parameters_vec[l] += 2.*delta_p;
1030 this->assemble_qoi(qoi_indices);
1031 this->assembly(true, false, true);
1032 this->rhs->close();
1033 for (unsigned int i=0; i != Nq; ++i)
1034 if (qoi_indices.has_index(i))
1035 {
1036 partial2q_term[i] -= this->get_qoi_value(i);
1037 partial2R_term[i] -= this->rhs->dot(this->get_adjoint_solution(i));
1038 partial2q_term[i] /= (4. * delta_p * delta_p);
1039 partial2R_term[i] /= (4. * delta_p * delta_p);
1040 }
1041
1042 for (unsigned int i=0; i != Nq; ++i)
1043 if (qoi_indices.has_index(i))
1044 {
1045 Number current_terms = partial2q_term[i] - partial2R_term[i];
1046 sensitivities.second_derivative(i,k,l) += current_terms;
1047 if (k != l)
1048 sensitivities.second_derivative(i,l,k) += current_terms;
1049 }
1050
1051 // Don't leave the parameters_vec perturbed
1052 *parameters_vec[l] = old_parameterl;
1053 *parameters_vec[k] = old_parameterk;
1054 }
1055
1056 // We get (partial q / partial u) and
1057 // (partial R / partial u) from the user, but centrally
1058 // difference to get q_uk and R_uk terms:
1059 // (partial^2 q / partial u partial k)
1060 // q_uk*u'_l = (q_u(p+dp*e_k)*u'_l - q_u(p-dp*e_k)*u'_l)/(2*dp)
1061 // R_uk*z*u'_l = (R_u(p+dp*e_k)*z*u'_l - R_u(p-dp*e_k)*z*u'_l)/(2*dp)
1062 //
1063 // To avoid creating Nq temporary vectors, we add these
1064 // subterms to the sensitivities output one by one.
1065 //
1066 // FIXME: this is probably a bad order of operations for
1067 // controlling floating point error.
1068
1069 *parameters_vec[k] = old_parameterk + delta_p;
1070 this->assembly(false, true);
1071 this->matrix->close();
1072 this->assemble_qoi_derivative(qoi_indices,
1073 /* include_liftfunc = */ true,
1074 /* apply_constraints = */ false);
1075
1076 for (unsigned int l=0; l != Np; ++l)
1077 {
1078 this->matrix->vector_mult(*tempvec, this->get_sensitivity_solution(l));
1079 for (unsigned int i=0; i != Nq; ++i)
1080 if (qoi_indices.has_index(i))
1081 {
1082 this->get_adjoint_rhs(i).close();
1083 Number current_terms =
1084 (this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(l)) -
1085 tempvec->dot(this->get_adjoint_solution(i))) / (2.*delta_p);
1086 sensitivities.second_derivative(i,k,l) += current_terms;
1087
1088 // We use the _uk terms twice; symmetry lets us reuse
1089 // these calculations for the _ul terms.
1090
1091 sensitivities.second_derivative(i,l,k) += current_terms;
1092 }
1093 }
1094
1095 *parameters_vec[k] = old_parameterk - delta_p;
1096 this->assembly(false, true);
1097 this->matrix->close();
1098 this->assemble_qoi_derivative(qoi_indices,
1099 /* include_liftfunc = */ true,
1100 /* apply_constraints = */ false);
1101
1102 for (unsigned int l=0; l != Np; ++l)
1103 {
1104 this->matrix->vector_mult(*tempvec, this->get_sensitivity_solution(l));
1105 for (unsigned int i=0; i != Nq; ++i)
1106 if (qoi_indices.has_index(i))
1107 {
1108 this->get_adjoint_rhs(i).close();
1109 Number current_terms =
1110 (-this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(l)) +
1111 tempvec->dot(this->get_adjoint_solution(i))) / (2.*delta_p);
1112 sensitivities.second_derivative(i,k,l) += current_terms;
1113
1114 // We use the _uk terms twice; symmetry lets us reuse
1115 // these calculations for the _ul terms.
1116
1117 sensitivities.second_derivative(i,l,k) += current_terms;
1118 }
1119 }
1120
1121 // Don't leave the parameter perturbed
1122 *parameters_vec[k] = old_parameterk;
1123
1124 // Our last remaining terms are -R_uu(u,z)*u_k*u_l and
1125 // Q_uu(u)*u_k*u_l
1126 //
1127 // We take directional central finite differences of R_u and Q_u
1128 // to approximate these terms, e.g.:
1129 //
1130 // Q_uu(u)*u_k ~= (Q_u(u+dp*u_k) - Q_u(u-dp*u_k))/(2*dp)
1131
1132 *this->solution = this->get_sensitivity_solution(k);
1133 *this->solution *= delta_p;
1134 *this->solution += *oldsolution;
1135
1136 // We've modified solution, so we need to update before calling
1137 // assembly since assembly may only use current_local_solution
1138 this->update();
1139 this->assembly(false, true);
1140 this->matrix->close();
1141 this->assemble_qoi_derivative(qoi_indices,
1142 /* include_liftfunc = */ true,
1143 /* apply_constraints = */ false);
1144
1145 // The Hessian is symmetric, so we just calculate the lower
1146 // triangle and the diagonal, and we get the upper triangle from
1147 // the transpose of the lower
1148 //
1149 // Note that, because we took the directional finite difference
1150 // with respect to k and not l, we've added an O(delta_p^2)
1151 // error to any permutational symmetry in the Hessian...
1152 for (unsigned int l=0; l != k+1; ++l)
1153 {
1154 this->matrix->vector_mult(*tempvec, this->get_sensitivity_solution(l));
1155 for (unsigned int i=0; i != Nq; ++i)
1156 if (qoi_indices.has_index(i))
1157 {
1158 this->get_adjoint_rhs(i).close();
1159 Number current_terms =
1160 (this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(l)) -
1161 tempvec->dot(this->get_adjoint_solution(i))) / (2.*delta_p);
1162 sensitivities.second_derivative(i,k,l) += current_terms;
1163 if (k != l)
1164 sensitivities.second_derivative(i,l,k) += current_terms;
1165 }
1166 }
1167
1168 *this->solution = this->get_sensitivity_solution(k);
1169 *this->solution *= -delta_p;
1170 *this->solution += *oldsolution;
1171
1172 // We've modified solution, so we need to update before calling
1173 // assembly since assembly may only use current_local_solution
1174 this->update();
1175 this->assembly(false, true);
1176 this->matrix->close();
1177 this->assemble_qoi_derivative(qoi_indices,
1178 /* include_liftfunc = */ true,
1179 /* apply_constraints = */ false);
1180
1181 for (unsigned int l=0; l != k+1; ++l)
1182 {
1183 this->matrix->vector_mult(*tempvec, this->get_sensitivity_solution(l));
1184 for (unsigned int i=0; i != Nq; ++i)
1185 if (qoi_indices.has_index(i))
1186 {
1187 this->get_adjoint_rhs(i).close();
1188 Number current_terms =
1189 (-this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(l)) +
1190 tempvec->dot(this->get_adjoint_solution(i))) / (2.*delta_p);
1191 sensitivities.second_derivative(i,k,l) += current_terms;
1192 if (k != l)
1193 sensitivities.second_derivative(i,l,k) += current_terms;
1194 }
1195 }
1196
1197 // Don't leave the solution perturbed
1198 *this->solution = *oldsolution;
1199 }
1200
1201 // All parameters_vec have been reset.
1202 // Don't leave the qoi or system changed - principle of least
1203 // surprise.
1204 // We've modified solution, so we need to update before calling
1205 // assembly since assembly may only use current_local_solution
1206 this->update();
1207 this->assembly(true, true);
1208 this->rhs->close();
1209 this->matrix->close();
1210 this->assemble_qoi(qoi_indices);
1211}
void vector_mult(NumericVector< T > &dest, const NumericVector< T > &arg) const
Multiplies the matrix by the NumericVector arg and stores the result in NumericVector dest.
Number get_qoi_value(unsigned int qoi_index) const
Definition system.C:2239
NumericVector< Number > & get_adjoint_solution(unsigned int i=0)
Definition system.C:1288

References libMesh::ImplicitSystem::adjoint_solve(), libMesh::SensitivityData::allocate_hessian_data(), libMesh::ExplicitSystem::assemble_qoi(), libMesh::ExplicitSystem::assemble_qoi_derivative(), libMesh::ImplicitSystem::assembly(), libMesh::NumericVector< T >::close(), libMesh::SparseMatrix< T >::close(), libMesh::NumericVector< T >::dot(), libMesh::System::get_adjoint_rhs(), libMesh::System::get_adjoint_solution(), libMesh::System::get_qoi_value(), libMesh::System::get_qoi_values(), libMesh::System::get_sensitivity_solution(), libMesh::QoISet::has_index(), libMesh::System::is_adjoint_already_solved(), libMesh::ImplicitSystem::matrix, libMesh::System::n_qois(), libMesh::Real, libMesh::ExplicitSystem::rhs, libMesh::SensitivityData::second_derivative(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::ParameterVector::size(), libMesh::System::solution, libMesh::TOLERANCE, libMesh::System::update(), and libMesh::SparseMatrix< T >::vector_mult().

◆ qoi_parameter_hessian_vector_product()

void libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product ( const QoISet &  qoi_indices,
const ParameterVector &  parameters,
const ParameterVector &  vector,
SensitivityData &  product 
)
overridevirtualinherited

For each of the system's quantities of interest q in qoi[qoi_indices], and for a vector of parameters p, the parameter sensitivity Hessian H_ij is defined as H_ij = (d^2 q)/(d p_i d p_j) The Hessian-vector product, for a vector v_k in parameter space, is S_j = H_jk v_k This product is the output of this method, where for each q_i, S_j is stored in sensitivities[i][j].

Reimplemented from libMesh::System.

Definition at line 717 of file implicit_system.C.

721{
722 // We currently get partial derivatives via finite differencing
723 const Real delta_p = TOLERANCE;
724
725 ParameterVector & parameters_vec =
726 const_cast<ParameterVector &>(parameters_in);
727
728 // We'll use a single temporary vector for matrix-vector-vector products
729 std::unique_ptr<NumericVector<Number>> tempvec = this->solution->zero_clone();
730
731 const unsigned int Np = cast_int<unsigned int>
732 (parameters_vec.size());
733 const unsigned int Nq = this->n_qois();
734
735 // For each quantity of interest q, the parameter sensitivity
736 // Hessian is defined as q''_{kl} = {d^2 q}/{d p_k d p_l}.
737 // Given a vector of parameter perturbation weights w_l, this
738 // function evaluates the hessian-vector product sum_l(q''_{kl}*w_l)
739 //
740 // We calculate it from values and partial derivatives of the
741 // quantity of interest function Q, solution u, adjoint solution z,
742 // parameter sensitivity adjoint solutions z^l, and residual R, as:
743 //
744 // sum_l(q''_{kl}*w_l) =
745 // sum_l(w_l * Q''_{kl}) + Q''_{uk}(u)*(sum_l(w_l u'_l)) -
746 // R'_k(u, sum_l(w_l*z^l)) - R'_{uk}(u,z)*(sum_l(w_l u'_l) -
747 // sum_l(w_l*R''_{kl}(u,z))
748 //
749 // See the adjoints model document for more details.
750
751 // We first do an adjoint solve to get z for each quantity of
752 // interest
753 // if we haven't already or dont have an initial condition for the adjoint
754 if (!this->is_adjoint_already_solved())
755 {
756 this->adjoint_solve(qoi_indices);
757 }
758
759 // Get ready to fill in sensitivities:
760 sensitivities.allocate_data(qoi_indices, *this, parameters_vec);
761
762 // We can't solve for all the solution sensitivities u'_l or for all
763 // of the parameter sensitivity adjoint solutions z^l without
764 // requiring O(Nq*Np) linear solves. So we'll solve directly for their
765 // weighted sum - this is just O(Nq) solves.
766
767 // First solve for sum_l(w_l u'_l).
768 this->weighted_sensitivity_solve(parameters_vec, vector);
769
770 // Then solve for sum_l(w_l z^l).
771 this->weighted_sensitivity_adjoint_solve(parameters_vec, vector, qoi_indices);
772
773 for (unsigned int k=0; k != Np; ++k)
774 {
775 // We approximate sum_l(w_l * Q''_{kl}) with a central
776 // differencing perturbation:
777 // sum_l(w_l * Q''_{kl}) ~=
778 // (Q(p + dp*w_l*e_l + dp*e_k) - Q(p - dp*w_l*e_l + dp*e_k) -
779 // Q(p + dp*w_l*e_l - dp*e_k) + Q(p - dp*w_l*e_l - dp*e_k))/(4*dp^2)
780
781 // The sum(w_l*R''_kl) term requires the same sort of perturbation,
782 // and so we subtract it in at the same time:
783 // sum_l(w_l * R''_{kl}) ~=
784 // (R(p + dp*w_l*e_l + dp*e_k) - R(p - dp*w_l*e_l + dp*e_k) -
785 // R(p + dp*w_l*e_l - dp*e_k) + R(p - dp*w_l*e_l - dp*e_k))/(4*dp^2)
786
787 ParameterVector oldparameters, parameterperturbation;
788 parameters_vec.deep_copy(oldparameters);
789 vector.deep_copy(parameterperturbation);
790 parameterperturbation *= delta_p;
791 parameters_vec += parameterperturbation;
792
793 Number old_parameter = *parameters_vec[k];
794
795 *parameters_vec[k] = old_parameter + delta_p;
796 this->assemble_qoi(qoi_indices);
797 this->assembly(true, false, true);
798 this->rhs->close();
799 std::vector<Number> partial2q_term = this->get_qoi_values();
800 std::vector<Number> partial2R_term(this->n_qois());
801 for (unsigned int i=0; i != Nq; ++i)
802 if (qoi_indices.has_index(i))
803 partial2R_term[i] = this->rhs->dot(this->get_adjoint_solution(i));
804
805 *parameters_vec[k] = old_parameter - delta_p;
806 this->assemble_qoi(qoi_indices);
807 this->assembly(true, false, true);
808 this->rhs->close();
809 for (unsigned int i=0; i != Nq; ++i)
810 if (qoi_indices.has_index(i))
811 {
812 partial2q_term[i] -= this->get_qoi_value(i);
813 partial2R_term[i] -= this->rhs->dot(this->get_adjoint_solution(i));
814 }
815
816 oldparameters.value_copy(parameters_vec);
817 parameterperturbation *= -1.0;
818 parameters_vec += parameterperturbation;
819
820 // Re-center old_parameter, which may be affected by vector
821 old_parameter = *parameters_vec[k];
822
823 *parameters_vec[k] = old_parameter + delta_p;
824 this->assemble_qoi(qoi_indices);
825 this->assembly(true, false, true);
826 this->rhs->close();
827 for (unsigned int i=0; i != Nq; ++i)
828 if (qoi_indices.has_index(i))
829 {
830 partial2q_term[i] -= this->get_qoi_value(i);
831 partial2R_term[i] -= this->rhs->dot(this->get_adjoint_solution(i));
832 }
833
834 *parameters_vec[k] = old_parameter - delta_p;
835 this->assemble_qoi(qoi_indices);
836 this->assembly(true, false, true);
837 this->rhs->close();
838 for (unsigned int i=0; i != Nq; ++i)
839 if (qoi_indices.has_index(i))
840 {
841 partial2q_term[i] += this->get_qoi_value(i);
842 partial2R_term[i] += this->rhs->dot(this->get_adjoint_solution(i));
843 }
844
845 for (unsigned int i=0; i != Nq; ++i)
846 if (qoi_indices.has_index(i))
847 {
848 partial2q_term[i] /= (4. * delta_p * delta_p);
849 partial2R_term[i] /= (4. * delta_p * delta_p);
850 }
851
852 for (unsigned int i=0; i != Nq; ++i)
853 if (qoi_indices.has_index(i))
854 sensitivities[i][k] = partial2q_term[i] - partial2R_term[i];
855
856 // We get (partial q / partial u), R, and
857 // (partial R / partial u) from the user, but centrally
858 // difference to get q_uk, R_k, and R_uk terms:
859 // (partial R / partial k)
860 // R_k*sum(w_l*z^l) = (R(p+dp*e_k)*sum(w_l*z^l) - R(p-dp*e_k)*sum(w_l*z^l))/(2*dp)
861 // (partial^2 q / partial u partial k)
862 // q_uk = (q_u(p+dp*e_k) - q_u(p-dp*e_k))/(2*dp)
863 // (partial^2 R / partial u partial k)
864 // R_uk*z*sum(w_l*u'_l) = (R_u(p+dp*e_k)*z*sum(w_l*u'_l) - R_u(p-dp*e_k)*z*sum(w_l*u'_l))/(2*dp)
865
866 // To avoid creating Nq temporary vectors for q_uk or R_uk, we add
867 // subterms to the sensitivities output one by one.
868 //
869 // FIXME: this is probably a bad order of operations for
870 // controlling floating point error.
871
872 *parameters_vec[k] = old_parameter + delta_p;
873 this->assembly(true, true);
874 this->rhs->close();
875 this->matrix->close();
876 this->assemble_qoi_derivative(qoi_indices,
877 /* include_liftfunc = */ true,
878 /* apply_constraints = */ false);
879
880 this->matrix->vector_mult(*tempvec, this->get_weighted_sensitivity_solution());
881
882 for (unsigned int i=0; i != Nq; ++i)
883 if (qoi_indices.has_index(i))
884 {
885 this->get_adjoint_rhs(i).close();
886 sensitivities[i][k] += (this->get_adjoint_rhs(i).dot(this->get_weighted_sensitivity_solution()) -
888 this->get_adjoint_solution(i).dot(*tempvec)) / (2.*delta_p);
889 }
890
891 *parameters_vec[k] = old_parameter - delta_p;
892 this->assembly(true, true);
893 this->rhs->close();
894 this->matrix->close();
895 this->assemble_qoi_derivative(qoi_indices,
896 /* include_liftfunc = */ true,
897 /* apply_constraints = */ false);
898
899 this->matrix->vector_mult(*tempvec, this->get_weighted_sensitivity_solution());
900
901 for (unsigned int i=0; i != Nq; ++i)
902 if (qoi_indices.has_index(i))
903 {
904 this->get_adjoint_rhs(i).close();
905 sensitivities[i][k] += (-this->get_adjoint_rhs(i).dot(this->get_weighted_sensitivity_solution()) +
907 this->get_adjoint_solution(i).dot(*tempvec)) / (2.*delta_p);
908 }
909 }
910
911 // All parameters have been reset.
912 // Don't leave the qoi or system changed - principle of least
913 // surprise.
914 this->assembly(true, true);
915 this->rhs->close();
916 this->matrix->close();
917 this->assemble_qoi(qoi_indices);
918}
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 > 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)),...
NumericVector< Number > & get_weighted_sensitivity_adjoint_solution(unsigned int i=0)
Definition system.C:1320
NumericVector< Number > & get_weighted_sensitivity_solution()
Definition system.C:1262

References libMesh::ImplicitSystem::adjoint_solve(), libMesh::SensitivityData::allocate_data(), libMesh::ExplicitSystem::assemble_qoi(), libMesh::ExplicitSystem::assemble_qoi_derivative(), libMesh::ImplicitSystem::assembly(), libMesh::NumericVector< T >::close(), libMesh::SparseMatrix< T >::close(), libMesh::ParameterVector::deep_copy(), libMesh::NumericVector< T >::dot(), libMesh::System::get_adjoint_rhs(), libMesh::System::get_adjoint_solution(), libMesh::System::get_qoi_value(), libMesh::System::get_qoi_values(), libMesh::System::get_weighted_sensitivity_adjoint_solution(), libMesh::System::get_weighted_sensitivity_solution(), libMesh::QoISet::has_index(), libMesh::System::is_adjoint_already_solved(), libMesh::ImplicitSystem::matrix, libMesh::System::n_qois(), libMesh::Real, libMesh::ExplicitSystem::rhs, libMesh::ParameterVector::size(), libMesh::System::solution, libMesh::TOLERANCE, libMesh::ParameterVector::value_copy(), libMesh::SparseMatrix< T >::vector_mult(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), and libMesh::ImplicitSystem::weighted_sensitivity_solve().

◆ qoi_parameter_sensitivity()

void libMesh::System::qoi_parameter_sensitivity ( const QoISet &  qoi_indices,
const ParameterVector &  parameters,
SensitivityData &  sensitivities 
)
virtualinherited

Solves for the derivative of each of the system's quantities of interest q in qoi[qoi_indices] with respect to each parameter in parameters, placing the result for qoi i and parameter j into sensitivities[i][j].

Note
parameters is a const vector, not a vector-of-const; parameter values in this vector need to be mutable for finite differencing to work.

Automatically chooses the forward method for problems with more quantities of interest than parameters, or the adjoint method otherwise.

This method is only usable in derived classes which override an implementation.

Definition at line 628 of file system.C.

631{
632 // Forward sensitivities are more efficient for Nq > Np
633 if (qoi_indices.size(*this) > parameters_vec.size())
634 forward_qoi_parameter_sensitivity(qoi_indices, parameters_vec, sensitivities);
635 // Adjoint sensitivities are more efficient for Np > Nq,
636 // and an adjoint may be more reusable than a forward
637 // solution sensitivity in the Np == Nq case.
638 else
639 adjoint_qoi_parameter_sensitivity(qoi_indices, parameters_vec, sensitivities);
640}
virtual void adjoint_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Solves for parameter sensitivities using the adjoint method.
Definition system.h:2633
virtual void forward_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Solves for parameter sensitivities using the forward method.
Definition system.h:2642

References libMesh::System::adjoint_qoi_parameter_sensitivity(), libMesh::System::forward_qoi_parameter_sensitivity(), libMesh::ParameterVector::size(), and libMesh::QoISet::size().

◆ re_update()

void libMesh::System::re_update ( )
virtualinherited

Re-update the local values when the mesh has changed.

This method takes the data updated by update() and makes it up-to-date on the current mesh.

Reimplemented in libMesh::TransientSystem< RBConstruction >.

Definition at line 544 of file system.C.

545{
546 parallel_object_only();
547
548 // If this system is empty... don't do anything!
549 if (!this->n_vars())
550 return;
551
552 const std::vector<dof_id_type> & send_list = this->get_dof_map().get_send_list ();
553
554 // Check sizes
555 libmesh_assert_equal_to (current_local_solution->size(), solution->size());
556 // Not true with ghosted vectors
557 // libmesh_assert_equal_to (current_local_solution->local_size(), solution->size());
558 // libmesh_assert (!send_list.empty());
559 libmesh_assert_less_equal (send_list.size(), solution->size());
560
561 // Create current_local_solution from solution. This will
562 // put a local copy of solution into current_local_solution.
563 solution->localize (*current_local_solution, send_list);
564}
const std::vector< dof_id_type > & get_send_list() const
Definition dof_map.h:540

References libMesh::System::current_local_solution, libMesh::System::get_dof_map(), libMesh::DofMap::get_send_list(), libMesh::System::n_vars(), and libMesh::System::solution.

◆ read_header()

void libMesh::System::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 
)
inherited

Reads the basic data header for this System.

Definition at line 97 of file system_io.C.

102{
103 // This method implements the input of a
104 // System object, embedded in the output of
105 // an EquationSystems<T_sys>. This warrants some
106 // documentation. The output file essentially
107 // consists of 5 sections:
108 //
109 // for this system
110 //
111 // 5.) The number of variables in the system (unsigned int)
112 //
113 // for each variable in the system
114 //
115 // 6.) The name of the variable (string)
116 //
117 // 6.1.) Variable subdomains
118 //
119 // 7.) Combined in an FEType:
120 // - The approximation order(s) of the variable
121 // (Order Enum, cast to int/s)
122 // - The finite element family/ies of the variable
123 // (FEFamily Enum, cast to int/s)
124 //
125 // end variable loop
126 //
127 // 8.) The number of additional vectors (unsigned int),
128 //
129 // for each additional vector in the system object
130 //
131 // 9.) the name of the additional vector (string)
132 //
133 // end system
134 libmesh_assert (io.reading());
135
136 // Possibly clear data structures and start from scratch.
137 if (read_header_in)
138 this->clear ();
139
140 // Figure out if we need to read infinite element information.
141 // This will be true if the version string contains " with infinite elements"
142 const bool read_ifem_info =
143 Utility::contains(version, " with infinite elements") ||
144 libMesh::on_command_line ("--read-ifem-systems");
145
146
147 {
148 // 5.)
149 // Read the number of variables in the system
150 unsigned int nv=0;
151 if (this->processor_id() == 0)
152 io.data (nv);
153 this->comm().broadcast(nv);
154
155 _written_var_indices.clear();
156 _written_var_indices.resize(nv, 0);
157
158 for (unsigned int var=0; var<nv; var++)
159 {
160 // 6.)
161 // Read the name of the var-th variable
162 std::string var_name;
163 if (this->processor_id() == 0)
164 io.data (var_name);
165 this->comm().broadcast(var_name);
166
167 // 6.1.)
168 std::set<subdomain_id_type> domains;
169 if (io.version() >= LIBMESH_VERSION_ID(0,7,2))
170 {
171 std::vector<subdomain_id_type> domain_array;
172 if (this->processor_id() == 0)
173 io.data (domain_array);
174 for (const auto & id : domain_array)
175 domains.insert(id);
176 }
177 this->comm().broadcast(domains);
178
179 // 7.)
180 // Read the approximation order(s) of the var-th variable
181 int order=0;
182 if (this->processor_id() == 0)
183 io.data (order);
184 this->comm().broadcast(order);
185
186
187 // do the same for infinite element radial_order
188 int rad_order=0;
189 if (read_ifem_info)
190 {
191 if (this->processor_id() == 0)
192 io.data(rad_order);
193 this->comm().broadcast(rad_order);
194 }
195
196 // Read the finite element type of the var-th variable
197 int fam=0;
198 if (this->processor_id() == 0)
199 io.data (fam);
200 this->comm().broadcast(fam);
201 FEType type;
202 type.order = static_cast<Order>(order);
203 type.family = static_cast<FEFamily>(fam);
204
205 // Check for incompatibilities. The shape function indexing was
206 // changed for the monomial and xyz finite element families to
207 // simplify extension to arbitrary p. The consequence is that
208 // old restart files will not be read correctly. This is expected
209 // to be an unlikely occurrence, but catch it anyway.
210 if (read_legacy_format)
211 if ((type.family == MONOMIAL || type.family == XYZ) &&
212 ((type.order.get_order() > 2 && this->get_mesh().mesh_dimension() == 2) ||
213 (type.order.get_order() > 1 && this->get_mesh().mesh_dimension() == 3)))
214 {
215 libmesh_here();
216 libMesh::out << "*****************************************************************\n"
217 << "* WARNING: reading a potentially incompatible restart file!!! *\n"
218 << "* contact [email protected] for more details *\n"
219 << "*****************************************************************"
220 << std::endl;
221 }
222
223 // Read additional information for infinite elements
224 int radial_fam=0;
225 int i_map=0;
226 if (read_ifem_info)
227 {
228 if (this->processor_id() == 0)
229 io.data (radial_fam);
230 this->comm().broadcast(radial_fam);
231 if (this->processor_id() == 0)
232 io.data (i_map);
233 this->comm().broadcast(i_map);
234 }
235
236#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
237
238 type.radial_order = static_cast<Order>(rad_order);
239 type.radial_family = static_cast<FEFamily>(radial_fam);
240 type.inf_map = static_cast<InfMapType>(i_map);
241
242#endif
243
244 if (read_header_in)
245 {
246 if (domains.empty())
247 _written_var_indices[var] = this->add_variable (var_name, type);
248 else
249 _written_var_indices[var] = this->add_variable (var_name, type, &domains);
250 }
251 else
252 _written_var_indices[var] = this->variable_number(var_name);
253 }
254 }
255
256 // 8.)
257 // Read the number of additional vectors.
258 unsigned int nvecs=0;
259 if (this->processor_id() == 0)
260 io.data (nvecs);
261 this->comm().broadcast(nvecs);
262
263 // If nvecs > 0, this means that write_additional_data
264 // was true when this file was written. We will need to
265 // make use of this fact later.
266 this->_additional_data_written = nvecs;
267
268 for (unsigned int vec=0; vec<nvecs; vec++)
269 {
270 // 9.)
271 // Read the name of the vec-th additional vector
272 std::string vec_name;
273 if (this->processor_id() == 0)
274 io.data (vec_name);
275 this->comm().broadcast(vec_name);
276 if (io.version() >= LIBMESH_VERSION_ID(1,7,0))
277 {
278 int vec_projection = 0;
279 if (this->processor_id() == 0)
280 io.data (vec_projection);
281 this->comm().broadcast(vec_projection);
282 int vec_type;
283 if (this->processor_id() == 0)
284 io.data (vec_type);
285 this->comm().broadcast(vec_type);
286
287 if (read_additional_data)
288 this->add_vector(vec_name, bool(vec_projection), ParallelType(vec_type));
289 }
290 else if (read_additional_data)
291 // Systems now can handle adding post-initialization vectors
292 // libmesh_assert(this->_can_add_vectors);
293 // Some systems may have added their own vectors already
294 // libmesh_assert_equal_to (this->_vectors.count(vec_name), 0);
295 this->add_vector(vec_name);
296 }
297}
std::vector< unsigned int > _written_var_indices
This vector is used only when reading in a system from file.
Definition system.h:2351
virtual void clear()
Clear all the data structures associated with the system.
Definition system.C:175
unsigned int variable_number(std::string_view var) const
Definition system.C:1454
unsigned int _additional_data_written
This flag is used only when reading in a system from file.
Definition system.h:2339
bool contains(std::string_view superstring, std::string_view substring)
Look for a substring within a string.
Definition utility.C:205
ParallelType
Defines an enum for parallel data structure types.
bool on_command_line(std::string arg)
Definition libmesh.C:934

References libMesh::System::_additional_data_written, libMesh::System::_written_var_indices, libMesh::System::add_variable(), libMesh::System::add_vector(), libMesh::Parallel::Communicator::broadcast(), libMesh::System::clear(), libMesh::ParallelObject::comm(), libMesh::Utility::contains(), libMesh::Xdr::data(), libMesh::FEType::family, libMesh::System::get_mesh(), libMesh::OrderWrapper::get_order(), libMesh::FEType::inf_map, libMesh::libmesh_assert(), libMesh::MeshBase::mesh_dimension(), libMesh::MONOMIAL, libMesh::on_command_line(), libMesh::FEType::order, libMesh::out, libMesh::ParallelObject::processor_id(), libMesh::FEType::radial_family, libMesh::FEType::radial_order, libMesh::Xdr::reading(), libMesh::System::variable_number(), libMesh::Xdr::version(), and libMesh::XYZ.

Referenced by libMesh::EquationSystems::read(), and libMesh::RBEvaluation::read_in_vectors_from_multiple_files().

◆ read_parallel_data() [1/2]

template<typename InValType >
void libMesh::System::read_parallel_data ( Xdr &  io,
const bool  read_additional_data 
)
inherited

Reads additional data, namely vectors, for this System.

This method may safely be called on a distributed-memory mesh. This method will read an individual file for each processor in the simulation where the local solution components for that processor are stored.

This method implements the output of the vectors contained in this System object, embedded in the output of an EquationSystems<T_sys>.

9.) The global solution vector, re-ordered to be node-major (More on this later.)

for each additional vector in the object

10.) The global additional vector, re-ordered to be node-major (More on this later.)

Note that the actual IO is handled through the Xdr class (to be renamed later?) which provides a uniform interface to both the XDR (eXternal Data Representation) interface and standard ASCII output. Thus this one section of code will read XDR or ASCII files with no changes.

Definition at line 302 of file system_io.C.

304{
324 // PerfLog pl("IO Performance",false);
325 // pl.push("read_parallel_data");
326 [[maybe_unused]] dof_id_type total_read_size = 0;
327
328 libmesh_assert (io.reading());
329 libmesh_assert (io.is_open());
330
331 // build the ordered nodes and element maps.
332 // when writing/reading parallel files we need to iterate
333 // over our nodes/elements in order of increasing global id().
334 // however, this is not guaranteed to be ordering we obtain
335 // by using the node_iterators/element_iterators directly.
336 // so build a set, sorted by id(), that provides the ordering.
337 // further, for memory economy build the set but then transfer
338 // its contents to vectors, which will be sorted.
339 std::vector<const DofObject *> ordered_nodes, ordered_elements;
340 {
341 std::set<const DofObject *, CompareDofObjectsByID>
342 ordered_nodes_set (this->get_mesh().local_nodes_begin(),
343 this->get_mesh().local_nodes_end());
344
345 ordered_nodes.insert(ordered_nodes.end(),
346 ordered_nodes_set.begin(),
347 ordered_nodes_set.end());
348 }
349 {
350 std::set<const DofObject *, CompareDofObjectsByID>
351 ordered_elements_set (this->get_mesh().local_elements_begin(),
352 this->get_mesh().local_elements_end());
353
354 ordered_elements.insert(ordered_elements.end(),
355 ordered_elements_set.begin(),
356 ordered_elements_set.end());
357 }
358
359 // std::vector<Number> io_buffer;
360 std::vector<InValType> io_buffer;
361
362 // 9.)
363 //
364 // Actually read the solution components
365 // for the ith system to disk
366 io.data(io_buffer);
367
368 total_read_size += cast_int<dof_id_type>(io_buffer.size());
369
370 const unsigned int sys_num = this->number();
371 const unsigned int nv = cast_int<unsigned int>
372 (this->_written_var_indices.size());
373 libmesh_assert_less_equal (nv, this->n_vars());
374
375 dof_id_type cnt=0;
376
377 // Loop over each non-SCALAR variable and each node, and read out the value.
378 for (unsigned int data_var=0; data_var<nv; data_var++)
379 {
380 const unsigned int var = _written_var_indices[data_var];
381 if (this->variable(var).type().family != SCALAR)
382 {
383 // First read the node DOF values
384 for (const auto & node : ordered_nodes)
385 for (auto comp : make_range(node->n_comp(sys_num,var)))
386 {
387 libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
389 libmesh_assert_less (cnt, io_buffer.size());
390 this->solution->set(node->dof_number(sys_num, var, comp), io_buffer[cnt++]);
391 }
392
393 // Then read the element DOF values
394 for (const auto & elem : ordered_elements)
395 for (auto comp : make_range(elem->n_comp(sys_num,var)))
396 {
397 libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
399 libmesh_assert_less (cnt, io_buffer.size());
400 this->solution->set(elem->dof_number(sys_num, var, comp), io_buffer[cnt++]);
401 }
402 }
403 }
404
405 // Finally, read the SCALAR variables on the last processor
406 for (unsigned int data_var=0; data_var<nv; data_var++)
407 {
408 const unsigned int var = _written_var_indices[data_var];
409 if (this->variable(var).type().family == SCALAR)
410 {
411 if (this->processor_id() == (this->n_processors()-1))
412 {
413 const DofMap & dof_map = this->get_dof_map();
414 std::vector<dof_id_type> SCALAR_dofs;
415 dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
416
417 for (auto dof : SCALAR_dofs)
418 this->solution->set(dof, io_buffer[cnt++]);
419 }
420 }
421 }
422
423 // And we're done setting solution entries
424 this->solution->close();
425
426 // For each additional vector, simply go through the list.
427 // ONLY attempt to do this IF additional data was actually
428 // written to the file for this system (controlled by the
429 // _additional_data_written flag).
430 if (this->_additional_data_written)
431 {
432 const std::size_t nvecs = this->_vectors.size();
433
434 // If the number of additional vectors written is non-zero, and
435 // the number of additional vectors we have is non-zero, and
436 // they don't match, then something is wrong and we can't be
437 // sure we're reading data into the correct places.
438 if (read_additional_data && nvecs &&
439 nvecs != this->_additional_data_written)
440 libmesh_error_msg
441 ("Additional vectors in file do not match system");
442
443 auto pos = _vectors.begin();
444
445 for (std::size_t i = 0; i != this->_additional_data_written; ++i)
446 {
447 cnt=0;
448 io_buffer.clear();
449
450 // 10.)
451 //
452 // Actually read the additional vector components
453 // for the ith system from disk
454 io.data(io_buffer);
455
456 total_read_size += cast_int<dof_id_type>(io_buffer.size());
457
458 // If read_additional_data==true and we have additional vectors,
459 // then we will keep this vector data; otherwise we are going to
460 // throw it away.
461 if (read_additional_data && nvecs)
462 {
463 // Loop over each non-SCALAR variable and each node, and read out the value.
464 for (unsigned int data_var=0; data_var<nv; data_var++)
465 {
466 const unsigned int var = _written_var_indices[data_var];
467 if (this->variable(var).type().family != SCALAR)
468 {
469 // First read the node DOF values
470 for (const auto & node : ordered_nodes)
471 for (auto comp : make_range(node->n_comp(sys_num,var)))
472 {
473 libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
475 libmesh_assert_less (cnt, io_buffer.size());
476 pos->second->set(node->dof_number(sys_num, var, comp), io_buffer[cnt++]);
477 }
478
479 // Then read the element DOF values
480 for (const auto & elem : ordered_elements)
481 for (auto comp : make_range(elem->n_comp(sys_num,var)))
482 {
483 libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
485 libmesh_assert_less (cnt, io_buffer.size());
486 pos->second->set(elem->dof_number(sys_num, var, comp), io_buffer[cnt++]);
487 }
488 }
489 }
490
491 // Finally, read the SCALAR variables on the last processor
492 for (unsigned int data_var=0; data_var<nv; data_var++)
493 {
494 const unsigned int var = _written_var_indices[data_var];
495 if (this->variable(var).type().family == SCALAR)
496 {
497 if (this->processor_id() == (this->n_processors()-1))
498 {
499 const DofMap & dof_map = this->get_dof_map();
500 std::vector<dof_id_type> SCALAR_dofs;
501 dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
502
503 for (auto dof : SCALAR_dofs)
504 pos->second->set(dof, io_buffer[cnt++]);
505 }
506 }
507 }
508
509 // And we're done setting entries for this variable
510 pos->second->close();
511 }
512
513 // If we've got vectors then we need to be iterating through
514 // those too
515 if (pos != this->_vectors.end())
516 ++pos;
517 }
518 }
519
520 // const Real
521 // dt = pl.get_elapsed_time(),
522 // rate = total_read_size*sizeof(Number)/dt;
523
524 // libMesh::err << "Read " << total_read_size << " \"Number\" values\n"
525 // << " Elapsed time = " << dt << '\n'
526 // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
527
528 // pl.pop("read_parallel_data");
529}
static constexpr dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition dof_object.h:473

References libMesh::System::_additional_data_written, libMesh::System::_vectors, libMesh::System::_written_var_indices, libMesh::Xdr::data(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::DofObject::invalid_id, libMesh::Xdr::is_open(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMesh::System::number(), libMesh::ParallelObject::processor_id(), libMesh::Xdr::reading(), libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::System::solution, and libMesh::System::variable().

◆ read_parallel_data() [2/2]

template LIBMESH_EXPORT void libMesh::System::read_parallel_data< Real > ( Xdr &  io,
const bool  read_additional_data 
)
inlineinherited

Non-templated version for backward compatibility.

Reads additional data, namely vectors, for this System. This method may safely be called on a distributed-memory mesh. This method will read an individual file for each processor in the simulation where the local solution components for that processor are stored.

Definition at line 1424 of file system.h.

1426 { read_parallel_data<Number>(io, read_additional_data); }

◆ read_SCALAR_dofs()

unsigned int libMesh::System::read_SCALAR_dofs ( const unsigned int  var,
Xdr &  io,
NumericVector< Number > *  vec 
) const
privateinherited

Reads the SCALAR dofs from the stream io and assigns the values to the appropriate entries of vec.

Returns
The number of dofs read.

Reads data and discards it if vec is a null pointer.

Definition at line 939 of file system_io.C.

942{
943 unsigned int n_assigned_vals = 0; // the number of values assigned, this will be returned.
944
945 // Processor 0 will read the block from the buffer stream and send it to the last processor
946 const unsigned int n_SCALAR_dofs = this->variable(var).type().order.get_order();
947 std::vector<Number> input_buffer(n_SCALAR_dofs);
948 if (this->processor_id() == 0)
949 io.data_stream(input_buffer.data(), n_SCALAR_dofs);
950
951#ifdef LIBMESH_HAVE_MPI
952 if (this->n_processors() > 1)
953 {
954 const Parallel::MessageTag val_tag = this->comm().get_unique_tag();
955
956 // Post the receive on the last processor
957 if (this->processor_id() == (this->n_processors()-1))
958 this->comm().receive(0, input_buffer, val_tag);
959
960 // Send the data to processor 0
961 if (this->processor_id() == 0)
962 this->comm().send(this->n_processors()-1, input_buffer, val_tag);
963 }
964#endif
965
966 // Finally, set the SCALAR values
967 if (this->processor_id() == (this->n_processors()-1))
968 {
969 const DofMap & dof_map = this->get_dof_map();
970 std::vector<dof_id_type> SCALAR_dofs;
971 dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
972
973 for (auto i : index_range(SCALAR_dofs))
974 {
975 if (vec)
976 vec->set (SCALAR_dofs[i], input_buffer[i]);
977 ++n_assigned_vals;
978 }
979 }
980
981 return n_assigned_vals;
982}
MessageTag get_unique_tag(int tagvalue=MessageTag::invalid_tag) const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
OrderWrapper order
The approximation order of the element (at 0 p-refinement level).
Definition fe_type.h:203
int get_order() const
Explicitly request the order as an int.
Definition fe_type.h:80
const FEType & type() const
Definition variable.h:144

References libMesh::ParallelObject::comm(), libMesh::Xdr::data_stream(), libMesh::System::get_dof_map(), libMesh::OrderWrapper::get_order(), libMesh::Parallel::Communicator::get_unique_tag(), libMesh::index_range(), libMesh::ParallelObject::n_processors(), libMesh::FEType::order, libMesh::ParallelObject::processor_id(), libMesh::Parallel::Communicator::receive(), libMesh::DofMap::SCALAR_dof_indices(), libMesh::Parallel::Communicator::send(), libMesh::NumericVector< T >::set(), libMesh::Variable::type(), and libMesh::System::variable().

Referenced by libMesh::System::read_serialized_vector(), and libMesh::System::read_serialized_vectors().

◆ read_serialized_blocked_dof_objects()

template<typename iterator_type , typename InValType >
std::size_t libMesh::System::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
privateinherited

Reads an input vector from the stream io and assigns the values to a set of DofObjects.

This method uses blocked input and is safe to call on a distributed memory-mesh. Unless otherwise specified, all variables are read.

If an entry in vecs is a null pointer, the corresponding data is read (incrementing the file read location) but discarded.

Definition at line 618 of file system_io.C.

625{
626 //-------------------------------------------------------
627 // General order: (IO format 0.7.4 & greater)
628 //
629 // for (objects ...)
630 // for (vecs ....)
631 // for (vars ....)
632 // for (comps ...)
633 //
634 // where objects are nodes or elements, sorted to be
635 // partition independent,
636 // vecs are one or more *identically distributed* solution
637 // coefficient vectors, vars are one or more variables
638 // to write, and comps are all the components for said
639 // vars on the object.
640
641 // variables to read. Unless specified otherwise, defaults to _written_var_indices.
642 std::vector<unsigned int> vars_to_read (_written_var_indices);
643
644 if (var_to_read != libMesh::invalid_uint)
645 vars_to_read.assign({var_to_read});
646
647 const unsigned int
648 sys_num = this->number(),
649 num_vecs = cast_int<unsigned int>(vecs.size());
650 const dof_id_type
651 io_blksize = cast_int<dof_id_type>(std::min(max_io_blksize, static_cast<std::size_t>(n_objs))),
652 num_blks = cast_int<unsigned int>(std::ceil(static_cast<double>(n_objs)/
653 static_cast<double>(io_blksize)));
654
655 libmesh_assert_less_equal (_written_var_indices.size(), this->n_vars());
656
657 std::size_t n_read_values=0;
658
659 std::vector<std::vector<dof_id_type>> xfer_ids(num_blks); // The global IDs and # of components for the local objects in all blocks
660 std::vector<std::vector<Number>> recv_vals(num_blks); // The raw values for the local objects in all blocks
661 std::vector<Parallel::Request>
662 id_requests(num_blks), val_requests(num_blks);
663 std::vector<Parallel::MessageTag>
664 id_tags(num_blks), val_tags(num_blks);
665
666 // ------------------------------------------------------
667 // First pass - count the number of objects in each block
668 // traverse all the objects and figure out which block they
669 // will ultimately live in.
670 std::vector<std::size_t>
671 xfer_ids_size (num_blks,0),
672 recv_vals_size (num_blks,0);
673
674
675 for (iterator_type it=begin; it!=end; ++it)
676 {
677 const dof_id_type
678 id = (*it)->id(),
679 block = id/io_blksize;
680
681 libmesh_assert_less (block, num_blks);
682
683 xfer_ids_size[block] += 2; // for each object, we send its id, as well as the total number of components for all variables
684
685 dof_id_type n_comp_tot=0;
686 for (const auto & var : vars_to_read)
687 n_comp_tot += (*it)->n_comp(sys_num, var); // for each variable, we will receive the nonzero components
688
689 recv_vals_size[block] += n_comp_tot*num_vecs;
690 }
691
692 // knowing the recv_vals_size[block] for each processor allows
693 // us to sum them and find the global size for each block.
694 std::vector<std::size_t> tot_vals_size(recv_vals_size);
695 this->comm().sum (tot_vals_size);
696
697
698 //------------------------------------------
699 // Collect the ids & number of values needed
700 // for all local objects, binning them into
701 // 'blocks' that will be sent to processor 0
702 for (dof_id_type blk=0; blk<num_blks; blk++)
703 {
704 // Each processor should build up its transfer buffers for its
705 // local objects in [first_object,last_object).
706 const dof_id_type
707 first_object = blk*io_blksize,
708 last_object = std::min(cast_int<dof_id_type>((blk+1)*io_blksize), n_objs);
709
710 // convenience
711 std::vector<dof_id_type> & ids (xfer_ids[blk]);
712 std::vector<Number> & vals (recv_vals[blk]);
713
714 // we now know the number of values we will store for each block,
715 // so we can do efficient preallocation
716 ids.clear(); ids.reserve (xfer_ids_size[blk]);
717 vals.resize(recv_vals_size[blk]);
718
719#ifdef DEBUG
720 std::unordered_set<dof_id_type> seen_ids;
721#endif
722
723 if (recv_vals_size[blk] != 0) // only if there are nonzero values to receive
724 for (iterator_type it=begin; it!=end; ++it)
725 {
726 dof_id_type id = (*it)->id();
727#ifdef DEBUG
728 // Any renumbering tricks should not have given us any
729 // duplicate ids.
730 libmesh_assert(!seen_ids.count(id));
731 seen_ids.insert(id);
732#endif
733
734 if ((id >= first_object) && // object in [first_object,last_object)
735 (id < last_object))
736 {
737 ids.push_back(id);
738
739 unsigned int n_comp_tot=0;
740
741 for (const auto & var : vars_to_read)
742 n_comp_tot += (*it)->n_comp(sys_num, var);
743
744 ids.push_back (n_comp_tot*num_vecs);
745 }
746 }
747
748#ifdef LIBMESH_HAVE_MPI
749 id_tags[blk] = this->comm().get_unique_tag(100*num_blks + blk);
750 val_tags[blk] = this->comm().get_unique_tag(200*num_blks + blk);
751
752 // nonblocking send the data for this block
753 this->comm().send (0, ids, id_requests[blk], id_tags[blk]);
754
755 // Go ahead and post the receive too
756 this->comm().receive (0, vals, val_requests[blk], val_tags[blk]);
757#endif
758 }
759
760 //---------------------------------------------------
761 // Here processor 0 will read and distribute the data.
762 // We have to do this block-wise to ensure that we
763 // do not exhaust memory on processor 0.
764
765 // give these variables scope outside the block to avoid reallocation
766 std::vector<std::vector<dof_id_type>> recv_ids (this->n_processors());
767 std::vector<std::vector<Number>> send_vals (this->n_processors());
768 std::vector<Parallel::Request> reply_requests (this->n_processors());
769 std::vector<unsigned int> obj_val_offsets; // map to traverse entry-wise rather than processor-wise
770 std::vector<Number> input_vals; // The input buffer for the current block
771 std::vector<InValType> input_vals_tmp; // The input buffer for the current block
772
773 for (dof_id_type blk=0; blk<num_blks; blk++)
774 {
775 // Each processor should build up its transfer buffers for its
776 // local objects in [first_object,last_object).
777 const dof_id_type
778 first_object = blk*io_blksize,
779 last_object = std::min(cast_int<dof_id_type>((blk+1)*io_blksize), n_objs),
780 n_objects_blk = last_object - first_object;
781
782 // Processor 0 has a special job. It needs to gather the requested indices
783 // in [first_object,last_object) from all processors, read the data from
784 // disk, and reply
785 if (this->processor_id() == 0)
786 {
787 // we know the input buffer size for this block and can begin reading it now
788 input_vals.resize(tot_vals_size[blk]);
789 input_vals_tmp.resize(tot_vals_size[blk]);
790
791 // a ThreadedIO object to perform asynchronous file IO
792 ThreadedIO<InValType> threaded_io(io, input_vals_tmp);
793 Threads::Thread async_io(threaded_io);
794
795 // offset array. this will define where each object's values
796 // map into the actual input_vals buffer. this must get
797 // 0-initialized because 0-component objects are not actually sent
798 obj_val_offsets.resize (n_objects_blk); std::fill (obj_val_offsets.begin(), obj_val_offsets.end(), 0);
799 recv_vals_size.resize(this->n_processors()); // reuse this to count how many values are going to each processor
800
801#ifndef NDEBUG
802 std::size_t n_vals_blk = 0;
803#endif
804
805 // loop over all processors and process their index request
806 for (processor_id_type comm_step=0, tnp=this->n_processors(); comm_step != tnp; ++comm_step)
807 {
808#ifdef LIBMESH_HAVE_MPI
809 // blocking receive indices for this block, imposing no particular order on processor
810 Parallel::Status id_status (this->comm().probe (Parallel::any_source, id_tags[blk]));
811 std::vector<dof_id_type> & ids (recv_ids[id_status.source()]);
812 std::size_t & n_vals_proc (recv_vals_size[id_status.source()]);
813 this->comm().receive (id_status.source(), ids, id_tags[blk]);
814#else
815 // straight copy without MPI
816 std::vector<dof_id_type> & ids (recv_ids[0]);
817 std::size_t & n_vals_proc (recv_vals_size[0]);
818 ids = xfer_ids[blk];
819#endif
820
821 n_vals_proc = 0;
822
823 // note its possible we didn't receive values for objects in
824 // this block if they have no components allocated.
825 for (std::size_t idx=0, sz=ids.size(); idx<sz; idx+=2)
826 {
827 const dof_id_type
828 local_idx = ids[idx+0]-first_object,
829 n_vals_tot_allvecs = ids[idx+1];
830
831 libmesh_assert_less (local_idx, n_objects_blk);
832
833 obj_val_offsets[local_idx] = n_vals_tot_allvecs;
834 n_vals_proc += n_vals_tot_allvecs;
835 }
836
837#ifndef NDEBUG
838 n_vals_blk += n_vals_proc;
839#endif
840 }
841
842 // We need the offsets into the input_vals vector for each object.
843 // fortunately, this is simply the partial sum of the total number
844 // of components for each object
845 std::partial_sum(obj_val_offsets.begin(), obj_val_offsets.end(),
846 obj_val_offsets.begin());
847
848 libmesh_assert_equal_to (n_vals_blk, obj_val_offsets.back());
849 libmesh_assert_equal_to (n_vals_blk, tot_vals_size[blk]);
850
851 // Wait for read completion
852 async_io.join();
853 // now copy the values back to the main vector for transfer
854 for (auto i_val : index_range(input_vals))
855 input_vals[i_val] = input_vals_tmp[i_val];
856
857 n_read_values += input_vals.size();
858
859 // pack data replies for each processor
860 for (auto proc : make_range(this->n_processors()))
861 {
862 const std::vector<dof_id_type> & ids (recv_ids[proc]);
863 std::vector<Number> & vals (send_vals[proc]);
864 const std::size_t & n_vals_proc (recv_vals_size[proc]);
865
866 vals.clear(); vals.reserve(n_vals_proc);
867
868 for (std::size_t idx=0, sz=ids.size(); idx<sz; idx+=2)
869 {
870 const dof_id_type
871 local_idx = ids[idx+0]-first_object,
872 n_vals_tot_allvecs = ids[idx+1];
873
874 std::vector<Number>::const_iterator in_vals(input_vals.begin());
875 if (local_idx != 0)
876 std::advance (in_vals, obj_val_offsets[local_idx-1]);
877
878 for (unsigned int val=0; val<n_vals_tot_allvecs; val++, ++in_vals)
879 {
880 libmesh_assert (in_vals != input_vals.end());
881 //libMesh::out << "*in_vals=" << *in_vals << '\n';
882 vals.push_back(*in_vals);
883 }
884 }
885
886#ifdef LIBMESH_HAVE_MPI
887 // send the relevant values to this processor
888 this->comm().send (proc, vals, reply_requests[proc], val_tags[blk]);
889#else
890 recv_vals[blk] = vals;
891#endif
892 }
893 } // end processor 0 read/reply
894
895 // all processors complete the (already posted) read for this block
896 {
897 Parallel::wait (val_requests[blk]);
898
899 const std::vector<Number> & vals (recv_vals[blk]);
900 std::vector<Number>::const_iterator val_it(vals.begin());
901
902 if (!recv_vals[blk].empty()) // nonzero values to receive
903 for (iterator_type it=begin; it!=end; ++it)
904 if (((*it)->id() >= first_object) && // object in [first_object,last_object)
905 ((*it)->id() < last_object))
906 // unpack & set the values
907 for (auto & vec : vecs)
908 for (const auto & var : vars_to_read)
909 {
910 const unsigned int n_comp = (*it)->n_comp(sys_num, var);
911
912 for (unsigned int comp=0; comp<n_comp; comp++, ++val_it)
913 {
914 const dof_id_type dof_index = (*it)->dof_number (sys_num, var, comp);
915 libmesh_assert (val_it != vals.end());
916 if (vec)
917 {
918 libmesh_assert_greater_equal (dof_index, vec->first_local_index());
919 libmesh_assert_less (dof_index, vec->last_local_index());
920 //libMesh::out << "dof_index, *val_it = \t" << dof_index << ", " << *val_it << '\n';
921 vec->set (dof_index, *val_it);
922 }
923 }
924 }
925 }
926
927 // processor 0 needs to make sure all replies have been handed off
928 if (this->processor_id () == 0)
929 Parallel::wait(reply_requests);
930 }
931
932 Parallel::wait(id_requests);
933
934 return n_read_values;
935}
Status wait(Request &r)
const unsigned int any_source
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
A useful inline function which replaces the macros used previously.
NonConcurrentThread Thread
Use the non-concurrent placeholder.

References libMesh::System::_written_var_indices, TIMPI::any_source, libMesh::ParallelObject::comm(), libMesh::Parallel::Communicator::get_unique_tag(), libMesh::index_range(), libMesh::invalid_uint, libMesh::Threads::NonConcurrentThread::join(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::ParallelObject::n_processors(), libMesh::System::number(), libMesh::ParallelObject::processor_id(), libMesh::Parallel::Communicator::receive(), libMesh::Parallel::Communicator::send(), TIMPI::Status::source(), libMesh::Parallel::Communicator::sum(), and TIMPI::wait().

Referenced by libMesh::System::read_serialized_vector(), and libMesh::System::read_serialized_vectors().

◆ read_serialized_data() [1/2]

template<typename InValType >
void libMesh::System::read_serialized_data ( Xdr &  io,
const bool  read_additional_data = true 
)
inherited

Reads additional data, namely vectors, for this System.

This method may safely be called on a distributed-memory mesh.

Definition at line 533 of file system_io.C.

535{
536 // This method implements the input of the vectors
537 // contained in this System object, embedded in the
538 // output of an EquationSystems<T_sys>.
539 //
540 // 10.) The global solution vector, re-ordered to be node-major
541 // (More on this later.)
542 //
543 // for each additional vector in the object
544 //
545 // 11.) The global additional vector, re-ordered to be
546 // node-major (More on this later.)
547 parallel_object_only();
548 std::string comment;
549
550 // PerfLog pl("IO Performance",false);
551 // pl.push("read_serialized_data");
552 // std::size_t total_read_size = 0;
553
554 // 10.)
555 // Read the global solution vector
556 {
557 // total_read_size +=
558 this->read_serialized_vector<InValType>(io, this->solution.get());
559
560 // get the comment
561 if (this->processor_id() == 0)
562 io.comment (comment);
563 }
564
565 // 11.)
566 // Only read additional vectors if data is available, and only use
567 // that data to fill our vectors if the user requested it.
568 if (this->_additional_data_written)
569 {
570 const std::size_t nvecs = this->_vectors.size();
571
572 // If the number of additional vectors written is non-zero, and
573 // the number of additional vectors we have is non-zero, and
574 // they don't match, then we can't read additional vectors
575 // and be sure we're reading data into the correct places.
576 if (read_additional_data && nvecs &&
577 nvecs != this->_additional_data_written)
578 libmesh_error_msg
579 ("Additional vectors in file do not match system");
580
581 auto pos = _vectors.begin();
582
583 for (std::size_t i = 0; i != this->_additional_data_written; ++i)
584 {
585 // Read data, but only put it into a vector if we've been
586 // asked to and if we have a corresponding vector to read.
587
588 // total_read_size +=
589 this->read_serialized_vector<InValType>
590 (io, (read_additional_data && nvecs) ? pos->second.get() : nullptr);
591
592 // get the comment
593 if (this->processor_id() == 0)
594 io.comment (comment);
595
596
597 // If we've got vectors then we need to be iterating through
598 // those too
599 if (pos != this->_vectors.end())
600 ++pos;
601 }
602 }
603
604 // const Real
605 // dt = pl.get_elapsed_time(),
606 // rate = total_read_size*sizeof(Number)/dt;
607
608 // libMesh::out << "Read " << total_read_size << " \"Number\" values\n"
609 // << " Elapsed time = " << dt << '\n'
610 // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
611
612 // pl.pop("read_serialized_data");
613}

References libMesh::System::_additional_data_written, libMesh::System::_vectors, libMesh::Xdr::comment(), libMesh::ParallelObject::processor_id(), and libMesh::System::solution.

Referenced by libMesh::TransientRBConstruction::initialize_truth(), libMesh::RBConstruction::read_riesz_representors_from_files(), and libMesh::TransientRBConstruction::read_riesz_representors_from_files().

◆ read_serialized_data() [2/2]

template LIBMESH_EXPORT void libMesh::System::read_serialized_data< Real > ( Xdr &  io,
const bool  read_additional_data = true 
)
inlineinherited

Non-templated version for backward compatibility.

Reads additional data, namely vectors, for this System. This method may safely be called on a distributed-memory mesh.

Definition at line 1382 of file system.h.

1384 { read_serialized_data<Number>(io, read_additional_data); }

◆ read_serialized_vector() [1/2]

numeric_index_type libMesh::System::read_serialized_vector ( Xdr &  io,
NumericVector< Number > &  vec 
)
inlineprivateinherited

Non-templated version for backward compatibility.

Reads a vector for this System. This method may safely be called on a distributed-memory mesh.

Returns
The length of the vector read.

Definition at line 2152 of file system.h.

2154 { return read_serialized_vector<Number>(io, &vec); }

◆ read_serialized_vector() [2/2]

template<typename InValType >
template LIBMESH_EXPORT numeric_index_type libMesh::System::read_serialized_vector< Real > ( Xdr &  io,
NumericVector< Number > *  vec 
)
privateinherited

Reads a vector for this System.

This method may safely be called on a distributed-memory mesh.

Returns
The length of the vector read.

Reads data and discards it if vec is a null pointer.

Definition at line 986 of file system_io.C.

988{
989 parallel_object_only();
990
991#ifndef NDEBUG
992 // In parallel we better be reading a parallel vector -- if not
993 // we will not set all of its components below!!
994 if (this->n_processors() > 1 && vec)
995 {
996 libmesh_assert (vec->type() == PARALLEL ||
997 vec->type() == GHOSTED);
998 }
999#endif
1000
1001 libmesh_assert (io.reading());
1002
1003 // vector length
1004 unsigned int vector_length=0; // FIXME? size_t would break binary compatibility...
1005#ifndef NDEBUG
1006 std::size_t n_assigned_vals=0;
1007#endif
1008
1009 // Get the buffer size
1010 if (this->processor_id() == 0)
1011 io.data(vector_length, "# vector length");
1012 this->comm().broadcast(vector_length);
1013
1014 const unsigned int nv = cast_int<unsigned int>
1015 (this->_written_var_indices.size());
1016 const dof_id_type
1017 n_nodes = this->get_mesh().n_nodes(),
1018 n_elem = this->get_mesh().n_elem();
1019
1020 libmesh_assert_less_equal (nv, this->n_vars());
1021
1022 // for newer versions, read variables node/elem major
1023 if (io.version() >= LIBMESH_VERSION_ID(0,7,4))
1024 {
1025 //---------------------------------
1026 // Collect the values for all nodes
1027#ifndef NDEBUG
1028 n_assigned_vals +=
1029#endif
1031 this->get_mesh().local_nodes_begin(),
1032 this->get_mesh().local_nodes_end(),
1033 InValType(),
1034 io,
1035 std::vector<NumericVector<Number> *> (1,vec));
1036
1037
1038 //------------------------------------
1039 // Collect the values for all elements
1040#ifndef NDEBUG
1041 n_assigned_vals +=
1042#endif
1044 this->get_mesh().local_elements_begin(),
1045 this->get_mesh().local_elements_end(),
1046 InValType(),
1047 io,
1048 std::vector<NumericVector<Number> *> (1,vec));
1049 }
1050
1051 // for older versions, read variables var-major
1052 else
1053 {
1054 // Loop over each variable in the system, and then each node/element in the mesh.
1055 for (unsigned int data_var=0; data_var<nv; data_var++)
1056 {
1057 const unsigned int var = _written_var_indices[data_var];
1058 if (this->variable(var).type().family != SCALAR)
1059 {
1060 //---------------------------------
1061 // Collect the values for all nodes
1062#ifndef NDEBUG
1063 n_assigned_vals +=
1064#endif
1066 this->get_mesh().local_nodes_begin(),
1067 this->get_mesh().local_nodes_end(),
1068 InValType(),
1069 io,
1070 std::vector<NumericVector<Number> *> (1,vec),
1071 var);
1072
1073
1074 //------------------------------------
1075 // Collect the values for all elements
1076#ifndef NDEBUG
1077 n_assigned_vals +=
1078#endif
1080 this->get_mesh().local_elements_begin(),
1081 this->get_mesh().local_elements_end(),
1082 InValType(),
1083 io,
1084 std::vector<NumericVector<Number> *> (1,vec),
1085 var);
1086 } // end variable loop
1087 }
1088 }
1089
1090 //-------------------------------------------
1091 // Finally loop over all the SCALAR variables
1092 for (unsigned int data_var=0; data_var<nv; data_var++)
1093 {
1094 const unsigned int var = _written_var_indices[data_var];
1095 if (this->variable(var).type().family == SCALAR)
1096 {
1097#ifndef NDEBUG
1098 n_assigned_vals +=
1099#endif
1100 this->read_SCALAR_dofs (var, io, vec);
1101 }
1102 }
1103
1104 if (vec)
1105 vec->close();
1106
1107#ifndef NDEBUG
1108 this->comm().sum (n_assigned_vals);
1109 libmesh_assert_equal_to (n_assigned_vals, vector_length);
1110#endif
1111
1112 return vector_length;
1113}
virtual dof_id_type n_elem() const =0
virtual dof_id_type n_nodes() const =0
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.
Definition system_io.C:618
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.
Definition system_io.C:939
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Count up the number of elements of a specific type (as defined by an iterator range).
const dof_id_type n_nodes
Definition tecplot_io.C:67

References libMesh::System::_written_var_indices, libMesh::Parallel::Communicator::broadcast(), libMesh::NumericVector< T >::close(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::System::get_mesh(), libMesh::GHOSTED, libMesh::libmesh_assert(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), n_nodes, libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMesh::PARALLEL, libMesh::ParallelObject::processor_id(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::Xdr::reading(), libMesh::SCALAR, libMesh::Parallel::Communicator::sum(), libMesh::NumericVector< T >::type(), libMesh::System::variable(), and libMesh::Xdr::version().

◆ read_serialized_vectors() [1/2]

template<typename InValType >
std::size_t libMesh::System::read_serialized_vectors ( Xdr &  io,
const std::vector< NumericVector< Number > * > &  vectors 
) const
inherited

Read a number of identically distributed vectors.

This method allows for optimization for the multiple vector case by only communicating the metadata once.

Definition at line 2015 of file system_io.C.

2017{
2018 parallel_object_only();
2019
2020 // Error checking
2021 // #ifndef NDEBUG
2022 // // In parallel we better be reading a parallel vector -- if not
2023 // // we will not set all of its components below!!
2024 // if (this->n_processors() > 1)
2025 // {
2026 // libmesh_assert (vec.type() == PARALLEL ||
2027 // vec.type() == GHOSTED);
2028 // }
2029 // #endif
2030
2031 libmesh_assert (io.reading());
2032
2033 if (this->processor_id() == 0)
2034 {
2035 // sizes
2036 unsigned int num_vecs=0;
2037 dof_id_type vector_length=0;
2038
2039 // Get the number of vectors
2040 io.data(num_vecs);
2041 // Get the buffer size
2042 io.data(vector_length);
2043
2044 libmesh_error_msg_if
2045 (num_vecs != vectors.size(),
2046 "Xdr file header declares " << num_vecs << " vectors, but we were asked to read " << vectors.size());
2047
2048 if (num_vecs != 0)
2049 {
2050 libmesh_error_msg_if (vectors[0] == nullptr, "vectors[0] should not be null");
2051 libmesh_error_msg_if (vectors[0]->size() != vector_length, "Inconsistent vector sizes");
2052 }
2053 }
2054
2055 // no need to actually communicate these.
2056 // this->comm().broadcast(num_vecs);
2057 // this->comm().broadcast(vector_length);
2058
2059 // Cache these - they are not free!
2060 const dof_id_type
2061 n_nodes = this->get_mesh().n_nodes(),
2062 n_elem = this->get_mesh().n_elem();
2063
2064 std::size_t read_length = 0;
2065
2066 //---------------------------------
2067 // Collect the values for all nodes
2068 read_length +=
2070 this->get_mesh().local_nodes_begin(),
2071 this->get_mesh().local_nodes_end(),
2072 InValType(),
2073 io,
2074 vectors);
2075
2076 //------------------------------------
2077 // Collect the values for all elements
2078 read_length +=
2080 this->get_mesh().local_elements_begin(),
2081 this->get_mesh().local_elements_end(),
2082 InValType(),
2083 io,
2084 vectors);
2085
2086 //-------------------------------------------
2087 // Finally loop over all the SCALAR variables
2088 for (NumericVector<Number> * vec : vectors)
2089 for (auto var : make_range(this->n_vars()))
2090 if (this->variable(var).type().family == SCALAR)
2091 {
2092 libmesh_assert_not_equal_to (vec, 0);
2093
2094 read_length +=
2095 this->read_SCALAR_dofs (var, io, vec);
2096 }
2097
2098 //---------------------------------------
2099 // last step - must close all the vectors
2100 for (NumericVector<Number> * vec : vectors)
2101 {
2102 libmesh_assert_not_equal_to (vec, 0);
2103 vec->close();
2104 }
2105
2106 return read_length;
2107}

References libMesh::Xdr::data(), libMesh::FEType::family, libMesh::System::get_mesh(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), n_nodes, libMesh::System::n_vars(), libMesh::ParallelObject::processor_id(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::Xdr::reading(), libMesh::SCALAR, libMesh::Variable::type(), and libMesh::System::variable().

Referenced by libMesh::RBEvaluation::read_in_vectors_from_multiple_files().

◆ read_serialized_vectors() [2/2]

template LIBMESH_EXPORT std::size_t libMesh::System::read_serialized_vectors< Real > ( Xdr &  io,
const std::vector< NumericVector< Number > * > &  vectors 
) const
inlineinherited

Non-templated version for backward compatibility.

Read a number of identically distributed vectors. This method allows for optimization for the multiple vector case by only communicating the metadata once.

Definition at line 1402 of file system.h.

1404 { return read_serialized_vectors<Number>(io, vectors); }

◆ reinit()

void libMesh::DifferentiableSystem::reinit ( )
overridevirtualinherited

Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be used.

Reimplemented from libMesh::System.

Definition at line 82 of file diff_system.C.

83{
85
87 libmesh_assert_equal_to (&(time_solver->system()), this);
88
89 time_solver->reinit();
90}
virtual void reinit()
Reinitializes degrees of freedom and other required data on the current mesh.
Definition system.C:449

References libMesh::libmesh_assert(), libMesh::System::reinit(), and libMesh::DifferentiableSystem::time_solver.

◆ reinit_constraints()

void libMesh::System::reinit_constraints ( )
virtualinherited

Reinitializes the constraints for this system.

Also prepares the send_list, whether or not constraints have changed.

Definition at line 490 of file system.C.

491{
492 parallel_object_only();
493
494#ifdef LIBMESH_ENABLE_CONSTRAINTS
498 if (libMesh::on_command_line ("--print-constraints"))
500#endif
502}
void prepare_send_list()
Takes the _send_list vector (which may have duplicate entries) and sorts it.
Definition dof_map.C:1865
void print_dof_constraints(std::ostream &os=libMesh::out, bool print_nonlocal=false) const
Prints (from processor 0) all DoF and Node constraints.
void create_dof_constraints(const MeshBase &, Real time=0)
Rebuilds the raw degree of freedom and DofObject constraints, based on attached DirichletBoundary obj...
void process_constraints(MeshBase &)
Postprocesses any constrained degrees of freedom to be constrained only in terms of unconstrained dof...
virtual void user_constrain()
Calls user's attached constraint function, or is overridden by the user in derived classes.
Definition system.C:2178

References libMesh::System::_mesh, libMesh::DofMap::create_dof_constraints(), libMesh::System::get_dof_map(), libMesh::on_command_line(), libMesh::out, libMesh::DofMap::prepare_send_list(), libMesh::DofMap::print_dof_constraints(), libMesh::DofMap::process_constraints(), libMesh::System::time, and libMesh::System::user_constrain().

Referenced by libMesh::EquationSystems::allgather(), libMesh::System::init_data(), libMesh::PetscDMWrapper::init_petscdm(), and libMesh::EquationSystems::reinit_solutions().

◆ reinit_dirichlet_constraint_values()

void libMesh::System::reinit_dirichlet_constraint_values ( )
inherited

Recomputes the DirichletBoundary constraint values of this system at the current time.

If only time changed since the last call to this method or to reinit_constraints(), the result is the same as that of reinit_constraints(). This method reuses the constraints that do not depend on time. See DofMap::reinit_dirichlet_constraint_values().

This method also prepares the send_list.

Definition at line 506 of file system.C.

507{
508 parallel_object_only();
509
510#ifdef LIBMESH_ENABLE_CONSTRAINTS
514 if (libMesh::on_command_line ("--print-constraints"))
516#endif
518}
void reinit_dirichlet_constraint_values(const MeshBase &mesh, Real time)
Recomputes the DirichletBoundary constraint values at a new time.

References libMesh::System::_mesh, libMesh::System::get_dof_map(), libMesh::on_command_line(), libMesh::out, libMesh::DofMap::prepare_send_list(), libMesh::DofMap::print_dof_constraints(), libMesh::DofMap::process_constraints(), libMesh::DofMap::reinit_dirichlet_constraint_values(), libMesh::System::time, and libMesh::System::user_constrain().

◆ reinit_mesh()

void libMesh::System::reinit_mesh ( )
virtualinherited

Reinitializes the system with a new mesh.

Definition at line 296 of file system.C.

297{
298 parallel_object_only();
299
300 // First initialize any required data:
301 // either only the basic System data
304 // or all the derived class' data too
305 else
306 this->init_data();
307
308 // If no variables have been added to this system
309 // don't do anything
310 if (!this->n_vars())
311 return;
312
313 // Then call the user-provided initialization function
314 this->user_initialization();
315
316}
virtual void user_initialization()
Calls user's attached initialization function, or is overridden by the user in derived classes.
Definition system.C:2150
bool _basic_system_only
Holds true if the components of more advanced system types (e.g.
Definition system.h:2326
virtual void init_data()
Initializes the data for the system.
Definition system.C:209

References libMesh::System::_basic_system_only, libMesh::System::init_data(), libMesh::System::n_vars(), and libMesh::System::user_initialization().

Referenced by libMesh::System::init(), libMesh::PetscPreconditioner< T >::set_hypre_ads_data(), and libMesh::PetscPreconditioner< T >::set_hypre_ams_data().

◆ remove_matrix()

void libMesh::System::remove_matrix ( std::string_view  mat_name)
inherited

Removes the additional matrix mat_name from this system.

Definition at line 1132 of file system.C.

1133{
1134 parallel_object_only(); // Not strictly needed, but the only safe way to keep in sync
1135
1136 if (const auto pos = _matrices.find(mat_name);
1137 pos != _matrices.end())
1138 _matrices.erase(pos); // erase()'d entries are destroyed
1139}

References libMesh::System::_matrices.

◆ remove_vector()

void libMesh::System::remove_vector ( std::string_view  vec_name)
inherited

Removes the additional vector vec_name from this system.

Definition at line 901 of file system.C.

902{
903 parallel_object_only(); // Not strictly needed, but the only safe way to keep in sync
904
905 if (const auto pos = _vectors.find(vec_name);
906 pos != _vectors.end())
907 {
908 _vectors.erase(pos);
909 auto proj_it = _vector_projections.find(vec_name);
910 libmesh_assert(proj_it != _vector_projections.end());
911 _vector_projections.erase(proj_it);
912
913 auto adj_it = _vector_is_adjoint.find(vec_name);
914 libmesh_assert(adj_it != _vector_is_adjoint.end());
915 _vector_is_adjoint.erase(adj_it);
916 }
917}

References libMesh::System::_vector_is_adjoint, libMesh::System::_vector_projections, libMesh::System::_vectors, and libMesh::libmesh_assert().

Referenced by libMesh::AdjointRefinementEstimator::estimate_error(), and libMesh::UnsteadySolver::integrate_adjoint_sensitivity().

◆ request_matrix() [1/2]

SparseMatrix< Number > * libMesh::System::request_matrix ( std::string_view  mat_name)
inherited
Returns
A writable pointer to this system's additional matrix named mat_name, or nullptr if no matrix by that name exists.

Definition at line 1155 of file system.C.

1156{
1157 if (auto pos = _matrices.find(mat_name);
1158 pos != _matrices.end())
1159 return pos->second.get();
1160
1161 // Otherwise, mat_name does not exist
1162 return nullptr;
1163}

References libMesh::System::_matrices.

◆ request_matrix() [2/2]

const SparseMatrix< Number > * libMesh::System::request_matrix ( std::string_view  mat_name) const
inherited
Returns
A const pointer to this system's additional matrix named mat_name, or nullptr if no matrix by that name exists.

Definition at line 1143 of file system.C.

1144{
1145 if (const auto pos = _matrices.find(mat_name);
1146 pos != _matrices.end())
1147 return pos->second.get();
1148
1149 // Otherwise, mat_name does not exist
1150 return nullptr;
1151}

References libMesh::System::_matrices.

Referenced by libMesh::EigenSystem::has_matrix_A(), libMesh::EigenSystem::has_matrix_B(), libMesh::EigenSystem::has_precond_matrix(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::NewtonSolver::solve(), and libMesh::LinearImplicitSystem::solve().

◆ request_vector() [1/4]

NumericVector< Number > * libMesh::System::request_vector ( const unsigned int  vec_num)
inherited
Returns
A writable pointer to this system's additional vector number vec_num (where the vectors are counted starting with 0), or nullptr if the system has no such vector.

Definition at line 957 of file system.C.

958{
959 // If we don't have that many vectors, return nullptr
960 if (vec_num >= _vectors.size())
961 return nullptr;
962
963 // Otherwise return a pointer to the vec_num'th vector
964 auto it = vectors_begin();
965 std::advance(it, vec_num);
966 return it->second.get();
967}

References libMesh::System::_vectors, and libMesh::System::vectors_begin().

◆ request_vector() [2/4]

const NumericVector< Number > * libMesh::System::request_vector ( const unsigned int  vec_num) const
inherited
Returns
A const pointer to this system's additional vector number vec_num (where the vectors are counted starting with 0), or nullptr if the system has no such vector.

Definition at line 943 of file system.C.

944{
945 // If we don't have that many vectors, return nullptr
946 if (vec_num >= _vectors.size())
947 return nullptr;
948
949 // Otherwise return a pointer to the vec_num'th vector
950 auto it = vectors_begin();
951 std::advance(it, vec_num);
952 return it->second.get();
953}

References libMesh::System::_vectors, and libMesh::System::vectors_begin().

◆ request_vector() [3/4]

NumericVector< Number > * libMesh::System::request_vector ( std::string_view  vec_name)
inherited
Returns
A pointer to the vector if this System has a vector associated with the given name, nullptr otherwise.

Definition at line 931 of file system.C.

932{
933 if (auto pos = _vectors.find(vec_name);
934 pos != _vectors.end())
935 return pos->second.get();
936
937 // Otherwise, vec_name was not found
938 return nullptr;
939}

References libMesh::System::_vectors, and libMesh::NumericVector< T >::get().

◆ request_vector() [4/4]

const NumericVector< Number > * libMesh::System::request_vector ( std::string_view  vec_name) const
inherited
Returns
A const pointer to the vector if this System has a vector associated with the given name, nullptr otherwise.

Definition at line 919 of file system.C.

920{
921 if (const auto pos = _vectors.find(vec_name);
922 pos != _vectors.end())
923 return pos->second.get();
924
925 // Otherwise, vec_name was not found
926 return nullptr;
927}

References libMesh::System::_vectors, and libMesh::NumericVector< T >::get().

Referenced by libMesh::UniformRefinementEstimator::_estimate_error().

◆ restrict_solve_to()

void libMesh::System::restrict_solve_to ( const SystemSubset *  subset,
const SubsetSolveMode  subset_solve_mode = SUBSET_ZERO 
)
virtualinherited

After calling this method, any solve will be restricted to the given subdomain.

To disable this mode, call this method with subset being a nullptr.

Reimplemented in libMesh::LinearImplicitSystem.

Definition at line 568 of file system.C.

570{
571 if (subset != nullptr)
572 libmesh_not_implemented();
573}

◆ restrict_vectors()

void libMesh::System::restrict_vectors ( )
virtualinherited

Restrict vectors after the mesh has coarsened.

Definition at line 381 of file system.C.

382{
383 parallel_object_only();
384
385#ifdef LIBMESH_ENABLE_AMR
386 // Restrict the _vectors on the coarsened cells
387 for (auto & [vec_name, vec] : _vectors)
388 {
389 NumericVector<Number> * v = vec.get();
390
391 if (_vector_projections[vec_name])
392 {
393 this->project_vector (*v, this->vector_is_adjoint(vec_name));
394 }
395 else
396 {
397 const ParallelType type = vec->type();
398
399 if (type == GHOSTED)
400 {
401#ifdef LIBMESH_ENABLE_GHOSTED
402 vec->init (this->n_dofs(), this->n_local_dofs(),
403 _dof_map->get_send_list(), /*fast=*/false,
404 GHOSTED);
405#else
406 libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
407#endif
408 }
409 else
410 vec->init (this->n_dofs(), this->n_local_dofs(), false, type);
411 }
412 }
413
414 const std::vector<dof_id_type> & send_list = _dof_map->get_send_list ();
415
416 // Restrict the solution on the coarsened cells
418 this->project_vector (*solution);
419 // Or at least make sure the solution vector is the correct size
420 else
421 solution->init (this->n_dofs(), this->n_local_dofs(), true, PARALLEL);
422
423#ifdef LIBMESH_ENABLE_GHOSTED
424 current_local_solution->init(this->n_dofs(),
425 this->n_local_dofs(), send_list,
426 false, GHOSTED);
427#else
428 current_local_solution->init(this->n_dofs());
429#endif
430
432 solution->localize (*current_local_solution, send_list);
433
434#endif // LIBMESH_ENABLE_AMR
435}
int vector_is_adjoint(std::string_view vec_name) const
Definition system.C:1216

References libMesh::System::_dof_map, libMesh::System::_solution_projection, libMesh::System::_vector_projections, libMesh::System::_vectors, libMesh::System::current_local_solution, libMesh::NumericVector< T >::get(), libMesh::GHOSTED, libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::PARALLEL, libMesh::System::project_vector(), libMesh::System::solution, and libMesh::System::vector_is_adjoint().

Referenced by libMesh::System::prolong_vectors(), and libMesh::EquationSystems::reinit_solutions().

◆ save_initial_mesh()

void SolidSystem::save_initial_mesh ( )

Definition at line 58 of file solid_system.C.

59{
60 System & aux_sys = this->get_equation_systems().get_system("auxiliary");
61
62 const unsigned int dim = this->get_mesh().mesh_dimension();
63
64 // Loop over all nodes and copy the location from the current system to
65 // the auxiliary system.
66 for (const auto & node : this->get_mesh().local_node_ptr_range())
67 for (unsigned int d = 0; d < dim; ++d)
68 {
69 unsigned int source_dof = node->dof_number(this->number(), var[d], 0);
70 unsigned int dest_dof = node->dof_number(aux_sys.number(), undefo_var[d], 0);
71 Number value = this->current_local_solution->el(source_dof);
72 aux_sys.current_local_solution->set(dest_dof, value);
73 }
74}
void ErrorVector unsigned int

References libMesh::System::current_local_solution, dim, libMesh::System::get_equation_systems(), libMesh::System::get_mesh(), libMesh::EquationSystems::get_system(), libMesh::MeshBase::mesh_dimension(), libMesh::System::number(), undefo_var, value, and var.

Referenced by setup().

◆ sensitivity_solve()

std::pair< unsigned int, Real > libMesh::ImplicitSystem::sensitivity_solve ( const ParameterVector &  parameters)
overridevirtualinherited

Assembles & solves the linear system(s) (dR/du)*u_p = -dR/dp, for those parameters contained within parameters.

Returns
A pair with the total number of linear iterations performed and the (sum of the) final residual norms

Reimplemented from libMesh::System.

Definition at line 140 of file implicit_system.C.

141{
142 // Log how long the linear solve takes.
143 LOG_SCOPE("sensitivity_solve()", "ImplicitSystem");
144
145 // The forward system should now already be solved.
146 // Now assemble the corresponding sensitivity system.
147
148 if (this->assemble_before_solve)
149 {
150 // Build the Jacobian
151 this->assembly(false, true);
152 this->matrix->close();
153
154 // Reset and build the RHS from the residual derivatives
155 this->assemble_residual_derivatives(parameters_vec);
156 }
157
158 // The sensitivity problem is linear
159 LinearSolver<Number> * solver = this->get_linear_solver();
160
161 // Our iteration counts and residuals will be sums of the individual
162 // results
163 std::pair<unsigned int, Real> solver_params =
165 std::pair<unsigned int, Real> totalrval = std::make_pair(0,0.0);
166
167 // Solve the linear system.
168 SparseMatrix<Number> * pc = this->request_matrix("Preconditioner");
169 for (auto p : make_range(parameters_vec.size()))
170 {
171 std::pair<unsigned int, Real> rval =
172 solver->solve (*matrix, pc,
174 this->get_sensitivity_rhs(p),
175 double(solver_params.second),
176 solver_params.first);
177
178 totalrval.first += rval.first;
179 totalrval.second += rval.second;
180 }
181
182 // The linear solver may not have fit our constraints exactly
183#ifdef LIBMESH_ENABLE_CONSTRAINTS
184 for (auto p : make_range(parameters_vec.size()))
185 this->get_dof_map().enforce_constraints_exactly
186 (*this, &this->get_sensitivity_solution(p),
187 /* homogeneous = */ true);
188#endif
189
190 return totalrval;
191}
virtual std::pair< unsigned int, Real > get_linear_solve_parameters() const
NumericVector< Number > & add_sensitivity_solution(unsigned int i=0)
Definition system.C:1225
const SparseMatrix< Number > * request_matrix(std::string_view mat_name) const
Definition system.C:1143
template class LIBMESH_EXPORT LinearSolver< Number >

References libMesh::System::add_sensitivity_solution(), libMesh::System::assemble_before_solve, libMesh::ImplicitSystem::assemble_residual_derivatives(), libMesh::ImplicitSystem::assembly(), libMesh::SparseMatrix< T >::close(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::System::get_dof_map(), libMesh::ImplicitSystem::get_linear_solve_parameters(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::System::get_sensitivity_rhs(), libMesh::System::get_sensitivity_solution(), libMesh::make_range(), libMesh::ImplicitSystem::matrix, libMesh::System::request_matrix(), libMesh::ParameterVector::size(), and libMesh::LinearSolver< T >::solve().

Referenced by libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity(), and libMesh::ImplicitSystem::qoi_parameter_hessian().

◆ set_adjoint_already_solved()

void libMesh::System::set_adjoint_already_solved ( bool  setting)
inlineinherited

Setter for the adjoint_already_solved boolean.

Definition at line 429 of file system.h.

430 { adjoint_already_solved = setting;}

References libMesh::System::adjoint_already_solved.

Referenced by main().

◆ set_basic_system_only()

void libMesh::System::set_basic_system_only ( )
inlineinherited

Sets the system to be "basic only": i.e.

advanced system components such as ImplicitSystem matrices may not be initialized. This is useful for efficiency in certain utility programs that never use System::solve(). This method must be called after the System or derived class is created but before it is initialized; e.g. from within EquationSystems::read()

Definition at line 2496 of file system.h.

2497{
2498 _basic_system_only = true;
2499}

References libMesh::System::_basic_system_only.

Referenced by libMesh::EquationSystems::read().

◆ set_constrain_in_solver()

void libMesh::DifferentiableSystem::set_constrain_in_solver ( bool  enable)
virtualinherited

set_constrain_in_solver to false to apply constraints only via residual terms in the systems to be solved.

Definition at line 356 of file diff_system.C.

357{
358 _constrain_in_solver = enable;
359 this->time_solver->diff_solver()->set_exact_constraint_enforcement(enable);
360}

References libMesh::DifferentiableSystem::_constrain_in_solver, and libMesh::DifferentiableSystem::time_solver.

Referenced by main(), set_system_parameters(), set_system_parameters(), and set_system_parameters().

◆ set_mesh_system()

void libMesh::DifferentiablePhysics::set_mesh_system ( System *  sys)
inlinevirtualinherited

Tells the DifferentiablePhysics that system sys contains the isoparametric Lagrangian variables which correspond to the coordinates of mesh nodes, in problems where the mesh itself is expected to move in time.

The system with mesh coordinate data (which may be this system itself, for fully coupled moving mesh problems) is currently assumed to have new (end of time step) mesh coordinates stored in solution, old (beginning of time step) mesh coordinates stored in _old_nonlinear_solution, and constant velocity motion during each time step.

Activating this function ensures that local (but not neighbor!) element geometry is correctly repositioned when evaluating element residuals.

Currently sys must be *this for a tightly coupled moving mesh problem or nullptr to stop mesh movement; loosely coupled moving mesh problems are not implemented.

This code is experimental. "Trust but verify, and not in that order"

Definition at line 569 of file diff_physics.h.

570{
571 // For now we assume that we're doing fully coupled mesh motion
572 // if (sys && sys != this)
573 // libmesh_not_implemented();
574
575 // For the foreseeable future we'll assume that we keep these
576 // Systems in the same EquationSystems
577 // libmesh_assert_equal_to (&this->get_equation_systems(),
578 // &sys->get_equation_systems());
579
580 // And for the immediate future this code may not even work
581 libmesh_experimental();
582
583 _mesh_sys = sys;
584}

References libMesh::DifferentiablePhysics::_mesh_sys.

Referenced by init_data().

◆ set_mesh_x_var()

void libMesh::DifferentiablePhysics::set_mesh_x_var ( unsigned int  var)
inlinevirtualinherited

Tells the DifferentiablePhysics that variable var from the mesh system should be used to update the x coordinate of mesh nodes, in problems where the mesh itself is expected to move in time.

The system with mesh coordinate data (which may be this system itself, for fully coupled moving mesh problems) is currently assumed to have new (end of time step) mesh coordinates stored in solution, old (beginning of time step) mesh coordinates stored in _old_nonlinear_solution, and constant velocity motion during each time step.

Activating this function ensures that local (but not neighbor!) element geometry is correctly repositioned when evaluating element residuals.

Definition at line 589 of file diff_physics.h.

590{
591 _mesh_x_var = var;
592}

References libMesh::DifferentiablePhysics::_mesh_x_var.

Referenced by init_data().

◆ set_mesh_y_var()

void libMesh::DifferentiablePhysics::set_mesh_y_var ( unsigned int  var)
inlinevirtualinherited

Tells the DifferentiablePhysics that variable var from the mesh system should be used to update the y coordinate of mesh nodes.

Definition at line 597 of file diff_physics.h.

598{
599 _mesh_y_var = var;
600}

References libMesh::DifferentiablePhysics::_mesh_y_var.

Referenced by init_data().

◆ set_mesh_z_var()

void libMesh::DifferentiablePhysics::set_mesh_z_var ( unsigned int  var)
inlinevirtualinherited

Tells the DifferentiablePhysics that variable var from the mesh system should be used to update the z coordinate of mesh nodes.

Definition at line 605 of file diff_physics.h.

606{
607 _mesh_z_var = var;
608}

References libMesh::DifferentiablePhysics::_mesh_z_var.

Referenced by init_data().

◆ set_numerical_jacobian_h_for_var()

void FEMSystem::set_numerical_jacobian_h_for_var ( unsigned int  var_num,
Real  new_h 
)
inlineinherited

Definition at line 275 of file fem_system.h.

277{
278 if (_numerical_jacobian_h_for_var.size() <= var_num)
279 _numerical_jacobian_h_for_var.resize(var_num+1,Real(0));
280
281 libmesh_assert_greater(new_h, Real(0));
282
283 _numerical_jacobian_h_for_var[var_num] = new_h;
284}

References libMesh::FEMSystem::_numerical_jacobian_h_for_var, and libMesh::Real.

◆ set_options_prefix()

void libMesh::System::set_options_prefix ( std::string  options_prefix)
inherited

Sets the solver-package options prefix of every vector and matrix this system owns, including ones added later.

Each object reads options with this prefix the next time it is initialized, so the prefix persists through reinitialization, e.g. after adaptivity.

Definition at line 1117 of file system.C.

1118{
1119 _options_prefix = std::move(options_prefix);
1120
1121 solution->set_options_prefix(_options_prefix);
1122 current_local_solution->set_options_prefix(_options_prefix);
1123 for (auto & pr : _vectors)
1125 for (auto & pr : _matrices)
1127}
const std::string & options_prefix() const
Definition system.h:2006
void set_options_prefix(std::string options_prefix)
Sets the solver-package options prefix of every vector and matrix this system owns,...
Definition system.C:1117

References libMesh::System::_matrices, libMesh::System::_options_prefix, libMesh::System::_vectors, libMesh::System::current_local_solution, libMesh::System::options_prefix(), and libMesh::System::solution.

Referenced by SystemsTest::testPetscOptionsPrefix().

◆ set_project_with_constraints()

void libMesh::System::set_project_with_constraints ( bool  _project_with_constraints)
inlineinherited

Definition at line 1854 of file system.h.

1855 {
1856 project_with_constraints = _project_with_constraints;
1857 }

References libMesh::System::project_with_constraints.

Referenced by libMesh::AdjointRefinementEstimator::estimate_error().

◆ set_qoi() [1/2]

void libMesh::System::set_qoi ( std::vector< Number >  new_qoi)
inherited

Definition at line 2252 of file system.C.

2253{
2254 libmesh_assert_equal_to(this->_qoi.size(), new_qoi.size());
2255 this->_qoi = std::move(new_qoi);
2256}

◆ set_qoi() [2/2]

void libMesh::System::set_qoi ( unsigned int  qoi_index,
Number  qoi_value 
)
inherited

◆ set_qoi_error_estimate()

void libMesh::System::set_qoi_error_estimate ( unsigned int  qoi_index,
Number  qoi_error_estimate 
)
inherited

◆ set_time_solver()

void libMesh::DifferentiableSystem::set_time_solver ( std::unique_ptr< TimeSolver >  _time_solver)
inlineinherited

Sets the time_solver FIXME: This code is a little dangerous as it transfers ownership from the TimeSolver creator to this class.

The user must no longer access his original TimeSolver object after calling this function.

Definition at line 253 of file diff_system.h.

254 {
255 time_solver.reset(_time_solver.release());
256 }

References libMesh::DifferentiableSystem::time_solver.

◆ set_vector_as_adjoint()

void libMesh::System::set_vector_as_adjoint ( const std::string &  vec_name,
int  qoi_num 
)
inherited

Allows one to set the QoI index controlling whether the vector identified by vec_name represents a solution from the adjoint (qoi_num >= 0) or primal (qoi_num == -1) space.

This becomes significant if those spaces have differing heterogeneous Dirichlet constraints.

qoi_num == -2 can be used to indicate a vector which should not be affected by constraints during projection operations.

Definition at line 1203 of file system.C.

1205{
1206 parallel_object_only(); // Not strictly needed, but the only safe way to keep in sync
1207
1208 // We reserve -1 for vectors which get primal constraints, -2 for
1209 // vectors which get no constraints
1210 libmesh_assert_greater_equal(qoi_num, -2);
1211 _vector_is_adjoint[vec_name] = qoi_num;
1212}

References libMesh::System::_vector_is_adjoint.

Referenced by libMesh::System::add_adjoint_solution(), and libMesh::System::add_weighted_sensitivity_adjoint_solution().

◆ set_vector_preservation()

void libMesh::System::set_vector_preservation ( const std::string &  vec_name,
bool  preserve 
)
inherited

Allows one to set the boolean controlling whether the vector identified by vec_name should be "preserved": projected to new meshes, saved, etc.

Definition at line 1181 of file system.C.

1183{
1184 parallel_object_only(); // Not strictly needed, but the only safe way to keep in sync
1185
1186 _vector_projections[vec_name] = preserve;
1187}

References libMesh::System::_vector_projections.

Referenced by libMesh::AdjointRefinementEstimator::estimate_error(), and main().

◆ setup_static_condensation_preconditioner()

template<typename T >
template void libMesh::ImplicitSystem::setup_static_condensation_preconditioner ( T &  solver)
protectedinherited

◆ side_constraint()

virtual bool libMesh::DifferentiablePhysics::side_constraint ( bool  request_jacobian,
DiffContext &   
)
inlinevirtualinherited

Adds the constraint contribution on side of elem to elem_residual.

If this method receives request_jacobian = true, then it should compute elem_jacobian and return true if possible. If elem_jacobian has not been computed then the method should return false.

Users may need to reimplement this for their particular PDE depending on the boundary conditions.

To implement a weak form of the constraint 0 = G(u), the user should examine u = elem_solution and add (G(u), phi_i) boundary integral contributions to elem_residual in side_constraint().

Reimplemented in LaplaceSystem, LaplaceSystem, LaplaceSystem, and NavierSystem.

Definition at line 195 of file diff_physics.h.

197 {
198 return request_jacobian;
199 }

Referenced by libMesh::EigenTimeSolver::side_residual(), libMesh::Euler2Solver::side_residual(), libMesh::EulerSolver::side_residual(), libMesh::NewmarkSolver::side_residual(), and libMesh::SteadySolver::side_residual().

◆ side_damping_residual()

virtual bool libMesh::DifferentiablePhysics::side_damping_residual ( bool  request_jacobian,
DiffContext &   
)
inlinevirtualinherited

Subtracts a damping vector contribution on side of elem from elem_residual.

If this method receives request_jacobian = true, then it should compute elem_jacobian and return true if possible. If elem_jacobian has not been computed then the method should return false.

For most problems, the default implementation of "do nothing" is correct; users with boundary conditions including first time derivatives may need to reimplement this themselves.

Definition at line 378 of file diff_physics.h.

380 {
381 return request_jacobian;
382 }

Referenced by libMesh::Euler2Solver::side_residual(), libMesh::EulerSolver::side_residual(), and libMesh::NewmarkSolver::side_residual().

◆ side_mass_residual()

virtual bool libMesh::DifferentiablePhysics::side_mass_residual ( bool  request_jacobian,
DiffContext &   
)
inlinevirtualinherited

Subtracts a mass vector contribution on side of elem from elem_residual.

If this method receives request_jacobian = true, then it should compute elem_jacobian and return true if possible. If elem_jacobian has not been computed then the method should return false.

For most problems, the default implementation of "do nothing" is correct; users with boundary conditions including time derivatives may need to reimplement this themselves.

Definition at line 320 of file diff_physics.h.

322 {
323 return request_jacobian;
324 }

Referenced by libMesh::EigenTimeSolver::side_residual(), libMesh::Euler2Solver::side_residual(), libMesh::EulerSolver::side_residual(), and libMesh::NewmarkSolver::side_residual().

◆ side_postprocess()

virtual void libMesh::DifferentiableSystem::side_postprocess ( DiffContext &  )
inlinevirtualinherited

Does any work that needs to be done on side of elem in a postprocessing loop.

Reimplemented in LaplaceSystem, and LaplaceSystem.

Definition at line 299 of file diff_system.h.

299{}

◆ side_qoi()

virtual void libMesh::DifferentiableQoI::side_qoi ( DiffContext &  ,
const QoISet &   
)
inlinevirtualinherited

Does any work that needs to be done on side of elem in a quantity of interest assembly loop, outputting to elem_qoi.

Only qois included in the supplied QoISet need to be assembled.

Reimplemented in CoupledSystemQoI.

Definition at line 133 of file diff_qoi.h.

135 {}

◆ side_qoi_derivative()

virtual void libMesh::DifferentiableQoI::side_qoi_derivative ( DiffContext &  ,
const QoISet &   
)
inlinevirtualinherited

Does any work that needs to be done on side of elem in a quantity of interest derivative assembly loop, outputting to elem_qoi_derivative.

Only qois included in the supplied QoISet need their derivatives assembled.

Reimplemented in LaplaceSystem, CoupledSystemQoI, and LaplaceSystem.

Definition at line 145 of file diff_qoi.h.

147 {}

◆ side_time_derivative()

bool SolidSystem::side_time_derivative ( bool  request_jacobian,
DiffContext &   
)
virtual

Adds the time derivative contribution on side of elem to elem_residual.

If this method receives request_jacobian = true, then it should compute elem_jacobian and return true if possible. If elem_jacobian has not been computed then the method should return false.

Users may need to reimplement this for their particular PDE depending on the boundary conditions.

To implement a weak form of the source term du/dt = F(u) on sides, such as might arise in a flux boundary condition, the user should examine u = elem_solution and add (F(u), phi_i) boundary integral contributions to elem_residual in side_constraint().

Reimplemented from libMesh::DifferentiablePhysics.

Definition at line 274 of file solid_system.C.

276{
277 FEMContext & c = cast_ref<FEMContext &>(context);
278
279 // Apply displacement boundary conditions with penalty method
280
281 // Get the current load step
282 Real ratio = this->get_equation_systems().parameters.get<Real>("progress") + 0.001;
283
284 // The BC are stored in the simulation parameters as array containing sequences of
285 // four numbers: Id of the side for the displacements and three values describing the
286 // displacement. E.g.: bc/displacement = '5 nan nan -1.0'. This will move all nodes of
287 // side 5 about 1.0 units down the z-axis while leaving all other directions unrestricted
288
289 // Get number of BCs to enforce
290 boundary_id_type num_bc =
291 cast_int<boundary_id_type>(args.vector_variable_size("bc/displacement"));
292
293 libmesh_error_msg_if(num_bc % 4 != 0,
294 "ERROR, Odd number of values in displacement boundary condition.");
295
296 num_bc /= 4;
297
298 // Loop over all BCs
299 for (boundary_id_type nbc = 0; nbc < num_bc; nbc++)
300 {
301 // Get IDs of the side for this BC
302 boundary_id_type positive_boundary_id =
303 cast_int<boundary_id_type>(args("bc/displacement", 1, nbc * 4));
304
305 // The current side may not be on the boundary to be restricted
306 if (!this->get_mesh().get_boundary_info().has_boundary_id
307 (&c.get_elem(),c.get_side(),positive_boundary_id))
308 continue;
309
310 // Read values from configuration file
311 Point diff_value;
312 for (unsigned int d = 0; d < c.get_dim(); ++d)
313 diff_value(d) = args("bc/displacement", NAN, nbc * 4 + 1 + d);
314
315 // Scale according to current load step
316 diff_value *= ratio;
317
318 Real penalty_number = args("bc/displacement_penalty", 1e7);
319
320 FEBase * fe = nullptr;
321 c.get_side_fe(0, fe);
322
323 const std::vector<std::vector<Real>> & phi = fe->get_phi();
324 const std::vector<Real> & JxW = fe->get_JxW();
325 const std::vector<Point> & coords = fe->get_xyz();
326
327 const unsigned int n_x_dofs = c.n_dof_indices(this->var[0]);
328
329 // get mappings for dofs for auxiliary system for original mesh positions
330 const System & auxsys = this->get_equation_systems().get_system("auxiliary");
331 const DofMap & auxmap = auxsys.get_dof_map();
332 std::vector<dof_id_type> undefo_dofs[3];
333 for (unsigned int d = 0; d < c.get_dim(); ++d)
334 auxmap.dof_indices(&c.get_elem(), undefo_dofs[d], undefo_var[d]);
335
336 for (unsigned int qp = 0; qp < c.get_side_qrule().n_points(); ++qp)
337 {
338 // calculate coordinates of qp on undeformed mesh
339 Point orig_point;
340 for (unsigned int i = 0; i < n_x_dofs; ++i)
341 {
342 for (unsigned int d = 0; d < c.get_dim(); ++d)
343 {
344 Number orig_val = auxsys.current_solution(undefo_dofs[d][i]);
345
346#if LIBMESH_USE_COMPLEX_NUMBERS
347 orig_point(d) += phi[i][qp] * orig_val.real();
348#else
349 orig_point(d) += phi[i][qp] * orig_val;
350#endif
351 }
352 }
353
354 // Calculate displacement to be enforced.
355 Point diff = coords[qp] - orig_point - diff_value;
356
357 // Assemble
358 for (unsigned int i = 0; i < n_x_dofs; ++i)
359 {
360 for (unsigned int d1 = 0; d1 < c.get_dim(); ++d1)
361 {
362 if (libmesh_isnan(diff(d1)))
363 continue;
364 Real val = JxW[qp] * phi[i][qp] * diff(d1) * penalty_number;
365 (c.get_elem_residual(var[d1]))(i) += val;
366 }
367 if (request_jacobian)
368 {
369 for (unsigned int j = 0; j < n_x_dofs; ++j)
370 {
371 for (unsigned int d1 = 0; d1 < c.get_dim(); ++d1)
372 {
373 if (libmesh_isnan(diff(d1)))
374 continue;
375 Real val = JxW[qp] * phi[i][qp] * phi[j][qp] * penalty_number;
376 (c.get_elem_jacobian(var[d1],var[d1]))(i, j) += val;
377 }
378 }
379 }
380 }
381 }
382 }
383
384 return request_jacobian;
385}
This class handles the numbering of degrees of freedom on a mesh.
Definition dof_map.h:181
Parameters parameters
Data structure holding arbitrary parameters.
unsigned char get_dim() const
Accessor for cached mesh dimension.
unsigned char get_side() const
Accessor for current side of Elem object.
const QBase & get_side_qrule() const
Accessor for element side quadrature rule for the dimension of the current _elem.
const T & get(std::string_view) const
Definition parameters.h:451
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:41
Number current_solution(const dof_id_type global_dof_number) const
Definition system.C:164
int8_t boundary_id_type
Definition id_types.h:51
LIBMESH_DEVICE_INLINE bool libmesh_isnan(T x)

References args, libMesh::System::current_solution(), libMesh::DofMap::dof_indices(), libMesh::Parameters::get(), libMesh::FEMContext::get_dim(), libMesh::System::get_dof_map(), libMesh::FEMContext::get_elem(), libMesh::DiffContext::get_elem_jacobian(), libMesh::DiffContext::get_elem_residual(), libMesh::System::get_equation_systems(), libMesh::FEAbstract::get_JxW(), libMesh::System::get_mesh(), libMesh::FEGenericBase< OutputType >::get_phi(), libMesh::FEMContext::get_side(), libMesh::FEMContext::get_side_fe(), libMesh::FEMContext::get_side_qrule(), libMesh::EquationSystems::get_system(), libMesh::FEAbstract::get_xyz(), libMesh::libmesh_isnan(), libMesh::DiffContext::n_dof_indices(), libMesh::EquationSystems::parameters, libMesh::Real, undefo_var, and var.

◆ solve()

void FEMSystem::solve ( )
overridevirtualinherited

Invokes the solver associated with the system.

For steady state solvers, this will find a root x where F(x) = 0. For transient solvers, this will integrate dx/dt = F(x).

For moving mesh systems, this also translates the mesh to the solution position.

Reimplemented from libMesh::DifferentiableSystem.

Reimplemented in libMesh::ContinuationSystem, and libMesh::VariationalSmootherSystem.

Definition at line 1076 of file fem_system.C.

1077{
1078 // We are solving the primal problem
1079 Parent::solve();
1080
1081 // On a moving mesh we want the mesh to reflect the new solution
1082 this->mesh_position_set();
1083}
virtual void solve() override
Invokes the solver associated with the system.
void mesh_position_set()
Tells the FEMSystem to set the mesh nodal coordinates which should correspond to degree of freedom co...

References libMesh::FEMSystem::mesh_position_set(), and libMesh::DifferentiableSystem::solve().

Referenced by main().

◆ solve_for_unconstrained_dofs()

void libMesh::System::solve_for_unconstrained_dofs ( NumericVector< Number > &  vec,
int  is_adjoint = -1 
) const
inherited

Definition at line 2092 of file system_projection.C.

2094{
2095 // We generally don't need this function if we don't have
2096 // non-assembly elements, but let's make sure it's robust to
2097 // pre-INVALID_MAP definitions of those, and let's make sure
2098 // *that's* robust to meshes with non-spline NodeElem too.
2099 //
2100 // Once everything's INVALID_MAP compliant we can remove this.
2101 if (!this->get_mesh().n_constraint_rows())
2102 {
2103 libmesh_warning("Called solve_for_unconstrained_dofs on a mesh with no constraint_rows?");
2104 return;
2105 }
2106
2107 const DofMap & dof_map = this->get_dof_map();
2108
2109 std::unique_ptr<SparseMatrix<Number>> mat =
2111
2112 std::unique_ptr<SparsityPattern::Build> sp;
2113
2114 if (dof_map.computed_sparsity_already())
2115 dof_map.update_sparsity_pattern(*mat);
2116 else
2117 {
2118 mat->attach_dof_map(dof_map);
2119 sp = dof_map.build_sparsity(this->get_mesh());
2120 mat->attach_sparsity_pattern(*sp);
2121 }
2122
2123 mat->init();
2124
2125 libmesh_assert_equal_to(vec.size(), dof_map.n_dofs());
2126 libmesh_assert_equal_to(vec.local_size(), dof_map.n_local_dofs());
2127
2128 std::unique_ptr<NumericVector<Number>> rhs =
2130
2131 rhs->init(dof_map.n_dofs(), dof_map.n_local_dofs(), false,
2132 PARALLEL);
2133
2134 // Here we start with the unconstrained (and indeterminate) linear
2135 // system, K*u = f, where K is the identity matrix for
2136 // DoFs which have been evaluated and 0 elsewhere, and f is the
2137 // current solution values for evaluated DoFs and 0 elsewhere.
2138 // We then apply the usual heterogeneous constraint matrix C and
2139 // offset h, where u = C*x + h,
2140 // to get C^T*K*C*x = C^T*f - C^T*K*h
2141 // - a constrained and no-longer-singular system that finds the
2142 // closest approximation for the unconstrained degrees of freedom.
2143 //
2144 // Here, though "closest" is in an algebraic sense; we're
2145 // effectively using a pseudoinverse that optimizes in a
2146 // discretization-dependent norm. That only seems to give ~0.1%
2147 // excess error even in coarse unit test cases, but at some point it
2148 // might be reasonable to weight K and f properly.
2149 //
2150 // We used to do this by distinguishing "constrained" from
2151 // "unconstrained" DoFs rather than "evaluated" vs "unevaluated",
2152 // but that was failing for any IGA meshes where we didn't bother to
2153 // duplicate spline nodes that were exactly equal to assembly
2154 // element vertices.
2155
2156 // Keep track of which DoFs we've added. We have a contiguous DoF
2157 // range [a,b) so we'll store a vector with indices [0,b-a) for
2158 // efficiency
2159 std::size_t n_local_dofs = dof_map.n_local_dofs();
2160 std::vector<bool> have_added(n_local_dofs, false);
2161 std::set<dof_id_type> have_added_ghost;
2162 std::size_t first_dof = dof_map.first_dof();
2163
2164 std::vector<dof_id_type> di;
2165
2166 for (const auto & elem : this->get_mesh().active_local_element_ptr_range())
2167 {
2168 // INVALID_MAP for the upcoming spline node change, plus
2169 // NODEELEM for meshes pre-change. If we have non-spline-node
2170 // NODEELEM we should have returned early already.
2171 if (elem->mapping_type() == INVALID_MAP ||
2172 (elem->type() == NODEELEM))
2173 continue;
2174
2175 dof_map.dof_indices(elem, di);
2176
2177 for (auto d : di)
2178 {
2179 if (d < first_dof)
2180 continue;
2181 const std::size_t i = d - first_dof;
2182 if (i >= n_local_dofs ||
2183 have_added[i])
2184 continue;
2185
2186 DenseMatrix<Number> K(1,1);
2187 DenseVector<Number> F(1);
2188 std::vector<dof_id_type> dof_indices(1, d);
2189 K(0,0) = 1;
2190 F(0) = (*this->solution)(d);
2191 dof_map.heterogenously_constrain_element_matrix_and_vector
2192 (K, F, dof_indices, false, is_adjoint);
2193 mat->add_matrix(K, dof_indices);
2194 rhs->add_vector(F, dof_indices);
2195
2196 // Keep track of both constrained and constraining additions
2197 // to mat, so we can fix any "leftovers" later. Otherwise if
2198 // someone puts a non-constraining DoF on a spline node we
2199 // end up with a singular system.
2200 for (auto d2 : dof_indices)
2201 {
2202 if (d2 < first_dof)
2203 {
2204 have_added_ghost.insert(d2);
2205 continue;
2206 }
2207 const std::size_t i2 = d2 - first_dof;
2208 if (i2 >= n_local_dofs)
2209 {
2210 have_added_ghost.insert(d2);
2211 continue;
2212 }
2213
2214 have_added[i2] = true;
2215 }
2216 }
2217 }
2218
2219 std::unordered_map<processor_id_type, std::vector<dof_id_type>> adds_to_push;
2221 dof_id_type end_p_dof = dof_map.end_dof(0);
2222 for (auto d : have_added_ghost)
2223 {
2224 while (d >= end_p_dof)
2225 {
2226 ++p;
2227 end_p_dof = dof_map.end_dof(p);
2228 }
2229 adds_to_push[p].push_back(d);
2230 }
2231
2232 auto act_on_adds = [&have_added, first_dof]
2233 (processor_id_type, const std::vector<dof_id_type> & dofs)
2234 {
2235 for (auto d : dofs)
2236 have_added[d-first_dof] = true;
2237 };
2238
2240 (this->comm(), adds_to_push, act_on_adds);
2241
2242 // Pin any unconstraining DoFs that lived on spline nodes
2243 for (auto i : index_range(have_added))
2244 {
2245 if (have_added[i])
2246 continue;
2247
2248 const std::size_t d = i + first_dof;
2249 mat->add(d, d, 1);
2250 rhs->add(d, (*this->solution)(d));
2251 }
2252
2253 std::unique_ptr<LinearSolver<Number>> linear_solver =
2255
2256 linear_solver->solve(*mat, vec, *rhs,
2257 double(this->get_equation_systems().parameters.get<Real>("linear solver tolerance")),
2258 this->get_equation_systems().parameters.get<unsigned int>("linear solver maximum iterations"));
2259
2260 LinearConvergenceReason conv_flag = linear_solver->get_converged_reason();
2261 libmesh_error_msg_if(conv_flag < 0, "Projection to unconstrained DoF space failed: " << Utility::enum_to_string(conv_flag) << std::endl);
2262}
static std::unique_ptr< LinearSolver< T > > build(const libMesh::Parallel::Communicator &comm_in, const SolverPackage solver_package=libMesh::default_solver_package())
Builds a LinearSolver using the linear solver package specified by solver_package.
void push_parallel_vector_data(const Communicator &comm, MapToVectors &&data, const ActionFunctor &act_on_data)
LinearConvergenceReason
Linear solver convergence flags (taken from the PETSc flags).

References libMesh::DofMap::build_sparsity(), libMesh::DofMap::computed_sparsity_already(), libMesh::DofMap::dof_indices(), libMesh::DofMapBase::end_dof(), libMesh::DofMapBase::first_dof(), libMesh::NumericVector< T >::get(), libMesh::DofMap::heterogenously_constrain_element_matrix_and_vector(), libMesh::index_range(), libMesh::INVALID_MAP, libMesh::NumericVector< T >::local_size(), libMesh::DofMap::n_dofs(), libMesh::DofMap::n_local_dofs(), libMesh::NODEELEM, libMesh::PARALLEL, libMesh::Real, libMesh::NumericVector< T >::size(), and libMesh::DofMap::update_sparsity_pattern().

◆ system()

sys_type & libMesh::ImplicitSystem::system ( )
inlineinherited
Returns
A reference to *this.

Definition at line 87 of file implicit_system.h.

87{ return *this; }

◆ system_type()

virtual std::string SolidSystem::system_type ( ) const
inlinevirtual
Returns
"Implicit". Helps in identifying the system type in an equation system file.

Reimplemented from libMesh::ImplicitSystem.

Definition at line 61 of file solid_system.h.

62 {
63 return "Solid";
64 }

◆ thread_join()

void libMesh::DifferentiableQoI::thread_join ( std::vector< Number > &  qoi,
const std::vector< Number > &  other_qoi,
const QoISet &  qoi_indices 
)
virtualinherited

Method to combine thread-local qois.

By default, simply sums thread qois.

Definition at line 33 of file diff_qoi.C.

36{
37 for (auto i : index_range(qoi))
38 qoi[i] += other_qoi[i];
39}

References libMesh::index_range().

◆ time_evolving()

void libMesh::DifferentiablePhysics::time_evolving ( unsigned int  var,
unsigned int  order 
)
virtualinherited

Tells the DiffSystem that variable var is evolving with respect to time.

In general, the user's init() function should call time_evolving() with order 1 for any variables which behave like du/dt = F(u), with order 2 for any variables that behave like d^2u/dt^2 = F(u), and should not call time_evolving() for any variables which behave like 0 = G(u).

Most derived systems will not have to reimplement this function; however any system which reimplements mass_residual() may have to reimplement time_evolving() to prepare data structures.

Definition at line 42 of file diff_physics.C.

44{
45 libmesh_error_msg_if(order != 1 && order != 2, "Input order must be 1 or 2!");
46
47 if (_time_evolving.size() <= var)
48 _time_evolving.resize(var+1, 0);
49
50 _time_evolving[var] = order;
51
52 if (order == 1)
53 _first_order_vars.insert(var);
54 else
55 _second_order_vars.insert(var);
56}

References libMesh::DifferentiablePhysics::_first_order_vars, libMesh::DifferentiablePhysics::_second_order_vars, and libMesh::DifferentiablePhysics::_time_evolving.

Referenced by libMesh::DifferentiableSystem::add_second_order_dot_vars(), LaplaceSystem::init_data(), CoupledSystem::init_data(), HeatSystem::init_data(), PoissonSystem::init_data(), NavierSystem::init_data(), ElasticitySystem::init_data(), CurlCurlSystem::init_data(), FirstOrderScalarSystemBase::init_data(), SecondOrderScalarSystemSecondOrderTimeSolverBase::init_data(), and SigmaPhysics::init_data().

◆ update()

void SolidSystem::update ( )
virtual

Update the local values to reflect the solution on neighboring processors.

Reimplemented from libMesh::System.

Definition at line 140 of file solid_system.C.

141{
142 System::update();
143 this->mesh_position_set();
144}

References libMesh::FEMSystem::mesh_position_set().

◆ update_global_solution() [1/2]

void libMesh::System::update_global_solution ( std::vector< Number > &  global_soln) const
inherited

Fill the input vector global_soln so that it contains the global solution on all processors.

Requires communication with all other processors.

Definition at line 771 of file system.C.

772{
773 parallel_object_only();
774
775 global_soln.resize (solution->size());
776
777 solution->localize (global_soln);
778}

References libMesh::System::solution.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::ExactErrorEstimator::estimate_error(), main(), and libMesh::InterMeshProjection::project_system_vectors().

◆ update_global_solution() [2/2]

void libMesh::System::update_global_solution ( std::vector< Number > &  global_soln,
const processor_id_type  dest_proc 
) const
inherited

Fill the input vector global_soln so that it contains the global solution on processor dest_proc.

Requires communication with all other processors.

Definition at line 782 of file system.C.

784{
785 parallel_object_only();
786
787 global_soln.resize (solution->size());
788
789 solution->localize_to_one (global_soln, dest_proc);
790}

References libMesh::System::solution.

◆ user_assembly()

void libMesh::System::user_assembly ( )
virtualinherited

Calls user's attached assembly function, or is overridden by the user in derived classes.

Definition at line 2164 of file system.C.

2165{
2166 // Call the user-provided assembly function,
2167 // if it was provided
2168 if (_assemble_system_function != nullptr)
2170
2171 // ...or the user-provided assembly object.
2172 else if (_assemble_system_object != nullptr)
2174}
virtual void assemble()=0
Assembly function.

Referenced by libMesh::System::assemble().

◆ user_constrain()

void libMesh::System::user_constrain ( )
virtualinherited

Calls user's attached constraint function, or is overridden by the user in derived classes.

Definition at line 2178 of file system.C.

2179{
2180 // Call the user-provided constraint function,
2181 // if it was provided
2182 if (_constrain_system_function!= nullptr)
2184
2185 // ...or the user-provided constraint object.
2186 else if (_constrain_system_object != nullptr)
2188}
virtual void constrain()=0
Constraint function.

Referenced by libMesh::System::reinit_constraints(), and libMesh::System::reinit_dirichlet_constraint_values().

◆ user_initialization()

void libMesh::System::user_initialization ( )
virtualinherited

Calls user's attached initialization function, or is overridden by the user in derived classes.

Definition at line 2150 of file system.C.

2151{
2152 // Call the user-provided initialization function,
2153 // if it was provided
2154 if (_init_system_function != nullptr)
2156
2157 // ...or the user-provided initialization object.
2158 else if (_init_system_object != nullptr)
2160}
virtual void initialize()=0
Initialization function.

Referenced by libMesh::NewmarkSystem::initial_conditions(), and libMesh::System::reinit_mesh().

◆ user_QOI()

void libMesh::System::user_QOI ( const QoISet &  qoi_indices)
virtualinherited

Calls user's attached quantity of interest function, or is overridden by the user in derived classes.

Definition at line 2192 of file system.C.

2193{
2194 // Call the user-provided quantity of interest function,
2195 // if it was provided
2196 if (_qoi_evaluate_function != nullptr)
2197 this->_qoi_evaluate_function(_equation_systems, this->name(), qoi_indices);
2198
2199 // ...or the user-provided QOI function object.
2200 else if (_qoi_evaluate_object != nullptr)
2201 this->_qoi_evaluate_object->qoi(qoi_indices);
2202}
virtual void qoi(const QoISet &qoi_indices)=0
Quantity of interest function.

Referenced by libMesh::System::assemble_qoi().

◆ user_QOI_derivative()

void libMesh::System::user_QOI_derivative ( const QoISet &  qoi_indices = QoISet(),
bool  include_liftfunc = true,
bool  apply_constraints = true 
)
virtualinherited

Calls user's attached quantity of interest derivative function, or is overridden by the user in derived classes.

Definition at line 2206 of file system.C.

2209{
2210 // Call the user-provided quantity of interest derivative,
2211 // if it was provided
2212 if (_qoi_evaluate_derivative_function != nullptr)
2214 (_equation_systems, this->name(), qoi_indices, include_liftfunc,
2215 apply_constraints);
2216
2217 // ...or the user-provided QOI derivative function object.
2218 else if (_qoi_evaluate_derivative_object != nullptr)
2220 (qoi_indices, include_liftfunc, apply_constraints);
2221}
virtual void qoi_derivative(const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)=0
Quantity of interest derivative function.

Referenced by libMesh::System::assemble_qoi_derivative().

◆ variable()

const Variable & libMesh::System::variable ( unsigned int  var) const
inherited

Return a constant reference to Variable var.

Definition at line 2759 of file system.C.

2760{
2761 return this->get_dof_map().variable(i);
2762}

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DifferentiableSystem::add_second_order_dot_vars(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::FirstOrderUnsteadySolver::compute_second_order_eqns(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::DifferentiableSystem::have_first_order_scalar_vars(), libMesh::DifferentiableSystem::have_second_order_scalar_vars(), main(), main(), libMesh::DifferentiablePhysics::nonlocal_mass_residual(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SortAndCopy::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectInteriors::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectEdges::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectSides::operator()(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::PetscPreconditioner< T >::set_petsc_aux_data(), libMesh::PetscDMWrapper::set_point_range_in_section(), SystemsTest::testFirstScalarNumber(), libMesh::System::write_header(), libMesh::Nemesis_IO_Helper::write_nodal_solution(), libMesh::System::write_parallel_data(), libMesh::System::write_serialized_vector(), and libMesh::System::write_serialized_vectors().

◆ variable_group()

const VariableGroup & libMesh::System::variable_group ( unsigned int  vg) const
inherited

Return a constant reference to VariableGroup vg.

Definition at line 2764 of file system.C.

2765{
2766 return this->get_dof_map().variable_group(vg);
2767}
const VariableGroup & variable_group(const unsigned int c) const
Definition dof_map.h:2432

Referenced by libMesh::FEMSystem::assembly().

◆ variable_name()

const std::string & libMesh::System::variable_name ( const unsigned int  i) const
inherited

◆ variable_number()

unsigned int libMesh::System::variable_number ( std::string_view  var) const
inherited
Returns
The variable number associated with the user-specified variable named var.

Definition at line 1454 of file system.C.

1455{
1456 return this->get_dof_map().variable_number(var);
1457}
unsigned int variable_number(std::string_view var) const
Definition dof_map.h:3081

References libMesh::System::get_dof_map(), and libMesh::DofMap::variable_number().

Referenced by libMesh::ExactSolution::_compute_error(), alternative_fe_assembly(), LinearElasticity::assemble(), AssembleOptimization::assemble_A_and_F(), assemble_divgrad(), assemble_elasticity(), assemble_graddiv(), assemble_matrix_and_rhs(), assemble_shell(), assemble_stokes(), compute_enriched_soln(), LinearElasticity::compute_stresses(), LargeDeformationElasticity::compute_stresses(), LinearElasticityWithContact::compute_stresses(), compute_stresses(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_elemental_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::Nemesis_IO::copy_nodal_solution(), libMesh::ExactErrorEstimator::estimate_error(), fe_assembly(), libMesh::ExactErrorEstimator::find_squared_element_error(), AssemblyPointLoadX::get_nodal_rhs_values(), AssemblyPointLoadY::get_nodal_rhs_values(), AssemblyPointLoadZ::get_nodal_rhs_values(), CoupledSystemQoI::init_context(), LargeDeformationElasticity::jacobian(), libMesh::HDGProblem::jacobian(), line_print(), main(), LinearElasticityWithContact::move_mesh(), OverlappingCouplingFunctor::operator()(), libMesh::System::read_header(), LargeDeformationElasticity::residual(), libMesh::HDGProblem::residual(), LinearElasticityWithContact::residual_and_jacobian(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), OverlappingTestBase::setup_coupling_matrix(), libMesh::DTKAdapter::update_variable_values(), libMesh::System::variable_scalar_number(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().

◆ variable_scalar_number() [1/2]

unsigned int libMesh::System::variable_scalar_number ( std::string_view  var,
unsigned int  component 
) const
inlineinherited
Returns
An index, starting from 0 for the first component of the first variable, and incrementing for each component of each (potentially vector-valued) variable in the system in order. For systems with only scalar-valued variables, this will be the same as variable_number(var)

Irony: currently our only non-scalar-valued variable type is SCALAR.

Definition at line 2505 of file system.h.

2507{
2508 return variable_scalar_number(this->variable_number(var), component);
2509}

References libMesh::System::variable_number(), and libMesh::System::variable_scalar_number().

Referenced by libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectInteriors::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectEdges::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectSides::operator()(), and libMesh::System::variable_scalar_number().

◆ variable_scalar_number() [2/2]

unsigned int libMesh::System::variable_scalar_number ( unsigned int  var_num,
unsigned int  component 
) const
inherited
Returns
An index, starting from 0 for the first component of the first variable, and incrementing for each component of each (potentially vector-valued) variable in the system in order. For systems with only scalar-valued variables, this will be the same as var_num

Irony: currently our only non-scalar-valued variable type is SCALAR.

Definition at line 2770 of file system.C.

2772{
2773 return this->get_dof_map().variable_scalar_number(var_num, component);
2774}
unsigned int variable_scalar_number(unsigned int var_num, unsigned int component) const
Definition dof_map.h:3064

◆ variable_type() [1/2]

const FEType & libMesh::System::variable_type ( const unsigned int  i) const
inherited
Returns
The finite element type variable number i.

Definition at line 2776 of file system.C.

2777{
2778 return this->get_dof_map().variable_type(i);
2779}

Referenced by libMesh::ExactSolution::_compute_error(), alternative_fe_assembly(), assemble(), libMesh::ClawSystem::assemble_advection_matrices(), libMesh::ClawSystem::assemble_avg_coupling_matrices(), libMesh::ClawSystem::assemble_boundary_condition_matrices(), assemble_ellipticdg(), libMesh::ClawSystem::assemble_jump_coupling_matrix(), libMesh::ClawSystem::assemble_mass_matrix(), assemble_shell(), assemble_shell(), assemble_stokes(), libMesh::FEMContext::attach_quadrature_rules(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::ExactSolution::compute_error(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_elemental_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::DGFEMContext::DGFEMContext(), libMesh::JumpErrorEstimator::estimate_error(), fe_assembly(), libMesh::FEMContext::find_hardest_fe_type(), libMesh::EquationSystems::find_variable_numbers_by_predicate(), form_functionA(), form_functionB(), form_matrixA(), libMesh::FEMSystem::init_context(), libMesh::FEMContext::init_internal_data(), OverlappingCouplingFunctor::operator()(), RationalMapTest< elem_type >::setUp(), FETestBase< order, family, elem_type, build_nx, CaseName >::setUp(), EquationSystemsTest::testBadVarNames(), FETest< order, family, elem_type, CaseName >::testCustomReinit(), FETest< order, family, elem_type, CaseName >::testFEInterface(), FETest< order, family, elem_type, CaseName >::testNodalSoln(), FETest< order, family, elem_type, CaseName >::testVectorNodalSoln(), libMesh::Nemesis_IO_Helper::write_element_values(), libMesh::System::write_header(), libMesh::Nemesis_IO_Helper::write_nodal_solution(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().

◆ variable_type() [2/2]

const FEType & libMesh::System::variable_type ( std::string_view  var) const
inherited
Returns
The finite element type for variable var.

Definition at line 2781 of file system.C.

2782{
2783 return this->get_dof_map().variable_type(var);
2784}

◆ vector_is_adjoint()

int libMesh::System::vector_is_adjoint ( std::string_view  vec_name) const
inherited
Returns
The integer describing whether the vector identified by vec_name represents a solution from an adjoint (non-negative) or the primal (-1) space.

Definition at line 1216 of file system.C.

1217{
1218 const auto it = _vector_is_adjoint.find(vec_name);
1220 return it->second;
1221}

References libMesh::System::_vector_is_adjoint, and libMesh::libmesh_assert().

Referenced by libMesh::InterMeshProjection::project_system_vectors(), and libMesh::System::restrict_vectors().

◆ vector_name() [1/2]

const std::string & libMesh::System::vector_name ( const NumericVector< Number > &  vec_reference) const
inherited
Returns
The name of a system vector, given a reference to that vector

Definition at line 1022 of file system.C.

1023{
1024 // Linear search for a vector whose pointer matches vec_reference
1025 auto it = std::find_if(vectors_begin(), vectors_end(),
1026 [&vec_reference](const decltype(_vectors)::value_type & pr)
1027 { return &vec_reference == pr.second.get(); });
1028
1029 // Before returning, make sure we didn't loop till the end and not find any match
1030 libmesh_assert (it != vectors_end());
1031
1032 // Return the string associated with the current vector
1033 return it->first;
1034}
vectors_iterator vectors_end()
End of vectors container.
Definition system.h:2548

References libMesh::System::_vectors, libMesh::NumericVector< T >::get(), libMesh::libmesh_assert(), libMesh::System::vectors_begin(), and libMesh::System::vectors_end().

◆ vector_name() [2/2]

const std::string & libMesh::System::vector_name ( const unsigned int  vec_num) const
inherited
Returns
The name of this system's additional vector number vec_num (where the vectors are counted starting with 0).

Definition at line 1011 of file system.C.

1012{
1013 // If we don't have that many vectors, throw an error
1014 libmesh_assert_less(vec_num, _vectors.size());
1015
1016 // Otherwise return a reference to the vec_num'th vector name
1017 auto it = vectors_begin();
1018 std::advance(it, vec_num);
1019 return it->first;
1020}

References libMesh::System::_vectors, and libMesh::System::vectors_begin().

Referenced by libMesh::AdjointRefinementEstimator::estimate_error(), and main().

◆ vector_preservation()

bool libMesh::System::vector_preservation ( std::string_view  vec_name) const
inherited
Returns
The boolean describing whether the vector identified by vec_name should be "preserved": projected to new meshes, saved, etc.

Definition at line 1191 of file system.C.

1192{
1193 if (auto it = _vector_projections.find(vec_name);
1194 it != _vector_projections.end())
1195 return it->second;
1196
1197 // vec_name was not in the map, return false
1198 return false;
1199}

References libMesh::System::_vector_projections.

Referenced by libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::MemoryHistoryData::store_vectors(), SystemsTest::testAddVectorProjChange(), SystemsTest::testAddVectorTypeChange(), and SystemsTest::testPostInitAddVectorTypeChange().

◆ vectors_begin() [1/2]

System::vectors_iterator libMesh::System::vectors_begin ( )
inlineinherited

◆ vectors_begin() [2/2]

System::const_vectors_iterator libMesh::System::vectors_begin ( ) const
inlineinherited

Beginning of vectors container.

Definition at line 2542 of file system.h.

2543{
2544 return _vectors.begin();
2545}

References libMesh::System::_vectors.

◆ vectors_end() [1/2]

System::vectors_iterator libMesh::System::vectors_end ( )
inlineinherited

◆ vectors_end() [2/2]

System::const_vectors_iterator libMesh::System::vectors_end ( ) const
inlineinherited

End of vectors container.

Definition at line 2554 of file system.h.

2555{
2556 return _vectors.end();
2557}

References libMesh::System::_vectors.

◆ weighted_sensitivity_adjoint_solve()

std::pair< unsigned int, Real > libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve ( const ParameterVector &  parameters,
const ParameterVector &  weights,
const QoISet &  qoi_indices = QoISet() 
)
overridevirtualinherited

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.

Assumes that adjoint_solve has already calculated z for each qoi in qoi_indices.

Returns
A pair with the total number of linear iterations performed and the (sum of the) final residual norms

Reimplemented from libMesh::System.

Definition at line 247 of file implicit_system.C.

250{
251 // Log how long the linear solve takes.
252 LOG_SCOPE("weighted_sensitivity_adjoint_solve()", "ImplicitSystem");
253
254 // We currently get partial derivatives via central differencing
255 const Real delta_p = TOLERANCE;
256
257 ParameterVector & parameters_vec =
258 const_cast<ParameterVector &>(parameters_in);
259
260 // The forward system should now already be solved.
261 // The adjoint system should now already be solved.
262 // Now we're assembling a weighted sum of adjoint-adjoint systems:
263 //
264 // dR/du (u, sum_l(w_l*z^l)) = sum_l(w_l*(Q''_ul - R''_ul (u, z)))
265
266 // FIXME: The derivation here does not yet take adjoint boundary
267 // conditions into account.
268#ifdef LIBMESH_ENABLE_DIRICHLET
269 for (auto i : make_range(this->n_qois()))
270 if (qoi_indices.has_index(i))
271 libmesh_assert(!this->get_dof_map().has_adjoint_dirichlet_boundaries(i));
272#endif
273
274 // We'll assemble the rhs first, because the R'' term will require
275 // perturbing the jacobian
276
277 // We'll use temporary rhs vectors, because we haven't (yet) found
278 // any good reasons why users might want to save these:
279
280 std::vector<std::unique_ptr<NumericVector<Number>>> temprhs(this->n_qois());
281 for (auto i : make_range(this->n_qois()))
282 if (qoi_indices.has_index(i))
283 temprhs[i] = this->rhs->zero_clone();
284
285 // We approximate the _l partial derivatives via a central
286 // differencing perturbation in the w_l direction:
287 //
288 // sum_l(w_l*v_l) ~= (v(p + dp*w_l*e_l) - v(p - dp*w_l*e_l))/(2*dp)
289
290 // PETSc doesn't implement SGEMX, so neither does NumericVector,
291 // so we want to avoid calculating f -= R'*z. We'll thus evaluate
292 // the above equation by first adding -v(p+dp...), then multiplying
293 // the intermediate result vectors by -1, then adding -v(p-dp...),
294 // then finally dividing by 2*dp.
295
296 ParameterVector oldparameters, parameterperturbation;
297 parameters_vec.deep_copy(oldparameters);
298 weights.deep_copy(parameterperturbation);
299 parameterperturbation *= delta_p;
300 parameters_vec += parameterperturbation;
301
302 this->assembly(false, true);
303 this->matrix->close();
304
305 // Take the discrete adjoint, so that we can calculate R_u(u,z) with
306 // a matrix-vector product of R_u and z.
308
309 this->assemble_qoi_derivative(qoi_indices,
310 /* include_liftfunc = */ false,
311 /* apply_constraints = */ true);
312 for (auto i : make_range(this->n_qois()))
313 if (qoi_indices.has_index(i))
314 {
315 this->get_adjoint_rhs(i).close();
316 *(temprhs[i]) -= this->get_adjoint_rhs(i);
317 this->matrix->vector_mult_add(*(temprhs[i]), this->get_adjoint_solution(i));
318 *(temprhs[i]) *= -1.0;
319 }
320
321 oldparameters.value_copy(parameters_vec);
322 parameterperturbation *= -1.0;
323 parameters_vec += parameterperturbation;
324
325 this->assembly(false, true);
326 this->matrix->close();
328
329 this->assemble_qoi_derivative(qoi_indices,
330 /* include_liftfunc = */ false,
331 /* apply_constraints = */ true);
332 for (auto i : make_range(this->n_qois()))
333 if (qoi_indices.has_index(i))
334 {
335 this->get_adjoint_rhs(i).close();
336 *(temprhs[i]) -= this->get_adjoint_rhs(i);
337 this->matrix->vector_mult_add(*(temprhs[i]), this->get_adjoint_solution(i));
338 *(temprhs[i]) /= (2.0*delta_p);
339 }
340
341 // Finally, assemble the jacobian at the non-perturbed parameter
342 // values. Ignore assemble_before_solve; if we had a good
343 // non-perturbed matrix before we've already overwritten it.
344 oldparameters.value_copy(parameters_vec);
345
346 // if (this->assemble_before_solve)
347 {
348 // Build the Jacobian
349 this->assembly(false, true);
350 this->matrix->close();
351
352 // Take the discrete adjoint
354 }
355
356 // The weighted adjoint-adjoint problem is linear
357 LinearSolver<Number> * solver = this->get_linear_solver();
358
359 // Our iteration counts and residuals will be sums of the individual
360 // results
361 std::pair<unsigned int, Real> solver_params =
363 std::pair<unsigned int, Real> totalrval = std::make_pair(0,0.0);
364
365 for (auto i : make_range(this->n_qois()))
366 if (qoi_indices.has_index(i))
367 {
368 const std::pair<unsigned int, Real> rval =
369 solver->solve (*matrix, this->add_weighted_sensitivity_adjoint_solution(i),
370 *(temprhs[i]),
371 double(solver_params.second),
372 solver_params.first);
373
374 totalrval.first += rval.first;
375 totalrval.second += rval.second;
376 }
377
378 // The linear solver may not have fit our constraints exactly
379#ifdef LIBMESH_ENABLE_CONSTRAINTS
380 for (auto i : make_range(this->n_qois()))
381 if (qoi_indices.has_index(i))
382 this->get_dof_map().enforce_constraints_exactly
384 /* homogeneous = */ true);
385#endif
386
387 return totalrval;
388}
void vector_mult_add(NumericVector< T > &dest, const NumericVector< T > &arg) const
Multiplies the matrix by the NumericVector arg and adds the result to the NumericVector dest.
virtual void get_transpose(SparseMatrix< T > &dest) const =0
Copies the transpose of the matrix into dest, which may be *this.
NumericVector< Number > & add_weighted_sensitivity_adjoint_solution(unsigned int i=0)
Definition system.C:1308

References libMesh::System::add_weighted_sensitivity_adjoint_solution(), libMesh::ExplicitSystem::assemble_qoi_derivative(), libMesh::ImplicitSystem::assembly(), libMesh::NumericVector< T >::close(), libMesh::SparseMatrix< T >::close(), libMesh::ParameterVector::deep_copy(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::System::get_adjoint_rhs(), libMesh::System::get_adjoint_solution(), libMesh::System::get_dof_map(), libMesh::ImplicitSystem::get_linear_solve_parameters(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::SparseMatrix< T >::get_transpose(), libMesh::System::get_weighted_sensitivity_adjoint_solution(), libMesh::DofMap::has_adjoint_dirichlet_boundaries(), libMesh::QoISet::has_index(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::ImplicitSystem::matrix, libMesh::System::n_qois(), libMesh::Real, libMesh::ExplicitSystem::rhs, libMesh::LinearSolver< T >::solve(), libMesh::TOLERANCE, libMesh::ParameterVector::value_copy(), libMesh::SparseMatrix< T >::vector_mult_add(), and libMesh::NumericVector< T >::zero_clone().

Referenced by libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product().

◆ weighted_sensitivity_solve()

std::pair< unsigned int, Real > libMesh::ImplicitSystem::weighted_sensitivity_solve ( const ParameterVector &  parameters,
const ParameterVector &  weights 
)
overridevirtualinherited

Assembles & solves the linear system(s) (dR/du)*u_w = sum(w_p*-dR/dp), for those parameters p contained within parameters weighted by the values w_p found within weights.

Returns
A pair with the total number of linear iterations performed and the (sum of the) final residual norms

Reimplemented from libMesh::System.

Definition at line 393 of file implicit_system.C.

395{
396 // Log how long the linear solve takes.
397 LOG_SCOPE("weighted_sensitivity_solve()", "ImplicitSystem");
398
399 // We currently get partial derivatives via central differencing
400 const Real delta_p = TOLERANCE;
401
402 ParameterVector & parameters_vec =
403 const_cast<ParameterVector &>(parameters_in);
404
405 // The forward system should now already be solved.
406
407 // Now we're assembling a weighted sum of sensitivity systems:
408 //
409 // dR/du (u, v)(sum(w_l*u'_l)) = -sum_l(w_l*R'_l (u, v)) forall v
410
411 // We'll assemble the rhs first, because the R' term will require
412 // perturbing the system, and some applications may not be able to
413 // assemble a perturbed residual without simultaneously constructing
414 // a perturbed jacobian.
415
416 // We approximate the _l partial derivatives via a central
417 // differencing perturbation in the w_l direction:
418 //
419 // sum_l(w_l*v_l) ~= (v(p + dp*w_l*e_l) - v(p - dp*w_l*e_l))/(2*dp)
420
421 ParameterVector oldparameters, parameterperturbation;
422 parameters_vec.deep_copy(oldparameters);
423 weights.deep_copy(parameterperturbation);
424 parameterperturbation *= delta_p;
425 parameters_vec += parameterperturbation;
426
427 this->assembly(true, false, true);
428 this->rhs->close();
429
430 std::unique_ptr<NumericVector<Number>> temprhs = this->rhs->clone();
431
432 oldparameters.value_copy(parameters_vec);
433 parameterperturbation *= -1.0;
434 parameters_vec += parameterperturbation;
435
436 this->assembly(true, false, true);
437 this->rhs->close();
438
439 *temprhs -= *(this->rhs);
440 *temprhs /= (2.0*delta_p);
441
442 // Finally, assemble the jacobian at the non-perturbed parameter
443 // values
444 oldparameters.value_copy(parameters_vec);
445
446 // Build the Jacobian
447 this->assembly(false, true);
448 this->matrix->close();
449
450 // The weighted sensitivity problem is linear
451 LinearSolver<Number> * solver = this->get_linear_solver();
452
453 std::pair<unsigned int, Real> solver_params =
455
456 const std::pair<unsigned int, Real> rval =
457 solver->solve (*matrix, this->add_weighted_sensitivity_solution(),
458 *temprhs,
459 double(solver_params.second),
460 solver_params.first);
461
462 // The linear solver may not have fit our constraints exactly
463#ifdef LIBMESH_ENABLE_CONSTRAINTS
465 (*this, &this->get_weighted_sensitivity_solution(),
466 /* homogeneous = */ true);
467#endif
468
469 return rval;
470}
NumericVector< Number > & add_weighted_sensitivity_solution()
Definition system.C:1255

References libMesh::System::add_weighted_sensitivity_solution(), libMesh::ImplicitSystem::assembly(), libMesh::NumericVector< T >::clone(), libMesh::NumericVector< T >::close(), libMesh::SparseMatrix< T >::close(), libMesh::ParameterVector::deep_copy(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::System::get_dof_map(), libMesh::ImplicitSystem::get_linear_solve_parameters(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::System::get_weighted_sensitivity_solution(), libMesh::ImplicitSystem::matrix, libMesh::Real, libMesh::ExplicitSystem::rhs, libMesh::LinearSolver< T >::solve(), libMesh::TOLERANCE, and libMesh::ParameterVector::value_copy().

Referenced by libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product().

◆ write_header()

void libMesh::System::write_header ( Xdr &  io,
std::string_view  version,
const bool  write_additional_data 
) const
inherited

Writes the basic data header for this System.

This method implements the output of a System object, embedded in the output of an EquationSystems<T_sys>. This warrants some documentation. The output of this part consists of 5 sections:

for this system

5.) The number of variables in the system (unsigned int)

for each variable in the system

6.) The name of the variable (string)

6.1.) subdomain where the variable lives

7.) Combined in an FEType:

  • The approximation order(s) of the variable (Order Enum, cast to int/s)
  • The finite element family/ies of the variable (FEFamily Enum, cast to int/s)

end variable loop

8.) The number of additional vectors (unsigned int),

for each additional vector in the system object

9.) the name of the additional vector (string)

end system

Definition at line 1117 of file system_io.C.

1120{
1154 libmesh_assert (io.writing());
1155
1156
1157 // Only write the header information
1158 // if we are processor 0.
1159 if (this->get_mesh().processor_id() != 0)
1160 return;
1161
1162 std::string comment;
1163
1164 // 5.)
1165 // Write the number of variables in the system
1166
1167 {
1168 // set up the comment
1169 comment = "# No. of Variables in System \"";
1170 comment += this->name();
1171 comment += "\"";
1172
1173 unsigned int nv = this->n_vars();
1174 io.data (nv, comment);
1175 }
1176
1177
1178 for (auto var : make_range(this->n_vars()))
1179 {
1180 // 6.)
1181 // Write the name of the var-th variable
1182 {
1183 // set up the comment
1184 comment = "# Name, Variable No. ";
1185 comment += std::to_string(var);
1186 comment += ", System \"";
1187 comment += this->name();
1188 comment += "\"";
1189
1190 std::string var_name = this->variable_name(var);
1191 io.data (var_name, comment);
1192 }
1193
1194 // 6.1.) Variable subdomains
1195 {
1196 // set up the comment
1197 comment = "# Subdomains, Variable \"";
1198 comment += this->variable_name(var);
1199 comment += "\", System \"";
1200 comment += this->name();
1201 comment += "\"";
1202
1203 const std::set<subdomain_id_type> & domains = this->variable(var).active_subdomains();
1204 std::vector<subdomain_id_type> domain_array;
1205 domain_array.assign(domains.begin(), domains.end());
1206 io.data (domain_array, comment);
1207 }
1208
1209 // 7.)
1210 // Write the approximation order of the var-th variable
1211 // in this system
1212 {
1213 // set up the comment
1214 comment = "# Approximation Order, Variable \"";
1215 comment += this->variable_name(var);
1216 comment += "\", System \"";
1217 comment += this->name();
1218 comment += "\"";
1219
1220 int order = static_cast<int>(this->variable_type(var).order);
1221 io.data (order, comment);
1222 }
1223
1224
1225#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1226
1227 // do the same for radial_order
1228 {
1229 comment = "# Radial Approximation Order, Variable \"";
1230 comment += this->variable_name(var);
1231 comment += "\", System \"";
1232 comment += this->name();
1233 comment += "\"";
1234
1235 int rad_order = static_cast<int>(this->variable_type(var).radial_order);
1236 io.data (rad_order, comment);
1237 }
1238
1239#endif
1240
1241 // Write the Finite Element type of the var-th variable
1242 // in this System
1243 {
1244 // set up the comment
1245 comment = "# FE Family, Variable \"";
1246 comment += this->variable_name(var);
1247 comment += "\", System \"";
1248 comment += this->name();
1249 comment += "\"";
1250
1251 const FEType & type = this->variable_type(var);
1252 int fam = static_cast<int>(type.family);
1253 io.data (fam, comment);
1254
1255#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1256
1257 comment = "# Radial FE Family, Variable \"";
1258 comment += this->variable_name(var);
1259 comment += "\", System \"";
1260 comment += this->name();
1261 comment += "\"";
1262
1263 int radial_fam = static_cast<int>(type.radial_family);
1264 io.data (radial_fam, comment);
1265
1266 comment = "# Infinite Mapping Type, Variable \"";
1267 comment += this->variable_name(var);
1268 comment += "\", System \"";
1269 comment += this->name();
1270 comment += "\"";
1271
1272 int i_map = static_cast<int>(type.inf_map);
1273 io.data (i_map, comment);
1274#endif
1275 }
1276 } // end of the variable loop
1277
1278 // 8.)
1279 // Write the number of additional vectors in the System.
1280 // If write_additional_data==false, then write zero for
1281 // the number of additional vectors.
1282 {
1283 {
1284 // set up the comment
1285 comment = "# No. of Additional Vectors, System \"";
1286 comment += this->name();
1287 comment += "\"";
1288
1289 unsigned int nvecs = write_additional_data ? this->n_vectors () : 0;
1290 io.data (nvecs, comment);
1291 }
1292
1293 if (write_additional_data)
1294 {
1295 unsigned int cnt=0;
1296 for (const auto & [vec_name, vec] : _vectors)
1297 {
1298 // 9.)
1299 // write the name of the cnt-th additional vector
1300 const std::string dth_vector = std::to_string(cnt++)+"th vector";
1301 comment = "# Name of " + dth_vector;
1302 std::string nonconst_vec_name = vec_name; // Stupid XDR API
1303
1304 io.data (nonconst_vec_name, comment);
1305 int vec_projection = _vector_projections.at(vec_name);
1306 comment = "# Whether to do projections for " + dth_vector;
1307 io.data (vec_projection, comment);
1308 int vec_type = vec->type();
1309 comment = "# Parallel type of " + dth_vector;
1310 io.data (vec_type, comment);
1311 }
1312 }
1313 }
1314}
OrderWrapper radial_order
The approximation order in radial direction of the infinite element.
Definition fe_type.h:263
const std::string & variable_name(const unsigned int i) const
Definition system.C:2734

References libMesh::System::_vector_projections, libMesh::System::_vectors, libMesh::Variable::active_subdomains(), libMesh::Xdr::data(), libMesh::FEType::family, libMesh::System::get_mesh(), libMesh::FEType::inf_map, libMesh::libmesh_assert(), libMesh::make_range(), libMesh::System::n_vars(), libMesh::System::n_vectors(), libMesh::System::name(), libMesh::FEType::order, libMesh::ParallelObject::processor_id(), libMesh::FEType::radial_family, libMesh::FEType::radial_order, libMesh::System::variable(), libMesh::System::variable_name(), libMesh::System::variable_type(), and libMesh::Xdr::writing().

Referenced by libMesh::RBEvaluation::write_out_vectors().

◆ write_parallel_data()

void libMesh::System::write_parallel_data ( Xdr &  io,
const bool  write_additional_data 
) const
inherited

Writes additional data, namely vectors, for this System.

This method may safely be called on a distributed-memory mesh. This method will create an individual file for each processor in the simulation where the local solution components for that processor will be stored.

This method implements the output of the vectors contained in this System object, embedded in the output of an EquationSystems<T_sys>.

9.) The global solution vector, re-ordered to be node-major (More on this later.)

for each additional vector in the object

10.) The global additional vector, re-ordered to be node-major (More on this later.)

Note that the actual IO is handled through the Xdr class (to be renamed later?) which provides a uniform interface to both the XDR (eXternal Data Representation) interface and standard ASCII output. Thus this one section of code will read XDR or ASCII files with no changes.

Definition at line 1318 of file system_io.C.

1320{
1340 // PerfLog pl("IO Performance",false);
1341 // pl.push("write_parallel_data");
1342 // std::size_t total_written_size = 0;
1343
1344 std::string comment;
1345
1346 libmesh_assert (io.writing());
1347
1348 std::vector<Number> io_buffer; io_buffer.reserve(this->solution->local_size());
1349
1350 // build the ordered nodes and element maps.
1351 // when writing/reading parallel files we need to iterate
1352 // over our nodes/elements in order of increasing global id().
1353 // however, this is not guaranteed to be ordering we obtain
1354 // by using the node_iterators/element_iterators directly.
1355 // so build a set, sorted by id(), that provides the ordering.
1356 // further, for memory economy build the set but then transfer
1357 // its contents to vectors, which will be sorted.
1358 std::vector<const DofObject *> ordered_nodes, ordered_elements;
1359 {
1360 std::set<const DofObject *, CompareDofObjectsByID>
1361 ordered_nodes_set (this->get_mesh().local_nodes_begin(),
1362 this->get_mesh().local_nodes_end());
1363
1364 ordered_nodes.insert(ordered_nodes.end(),
1365 ordered_nodes_set.begin(),
1366 ordered_nodes_set.end());
1367 }
1368 {
1369 std::set<const DofObject *, CompareDofObjectsByID>
1370 ordered_elements_set (this->get_mesh().local_elements_begin(),
1371 this->get_mesh().local_elements_end());
1372
1373 ordered_elements.insert(ordered_elements.end(),
1374 ordered_elements_set.begin(),
1375 ordered_elements_set.end());
1376 }
1377
1378 const unsigned int sys_num = this->number();
1379 const unsigned int nv = this->n_vars();
1380
1381 // Loop over each non-SCALAR variable and each node, and write out the value.
1382 for (unsigned int var=0; var<nv; var++)
1383 if (this->variable(var).type().family != SCALAR)
1384 {
1385 // First write the node DOF values
1386 for (const auto & node : ordered_nodes)
1387 for (auto comp : make_range(node->n_comp(sys_num,var)))
1388 {
1389 libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
1391
1392 io_buffer.push_back((*this->solution)(node->dof_number(sys_num, var, comp)));
1393 }
1394
1395 // Then write the element DOF values
1396 for (const auto & elem : ordered_elements)
1397 for (auto comp : make_range(elem->n_comp(sys_num,var)))
1398 {
1399 libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
1401
1402 io_buffer.push_back((*this->solution)(elem->dof_number(sys_num, var, comp)));
1403 }
1404 }
1405
1406 // Finally, write the SCALAR data on the last processor
1407 for (auto var : make_range(this->n_vars()))
1408 if (this->variable(var).type().family == SCALAR)
1409 {
1410 if (this->processor_id() == (this->n_processors()-1))
1411 {
1412 const DofMap & dof_map = this->get_dof_map();
1413 std::vector<dof_id_type> SCALAR_dofs;
1414 dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
1415
1416 for (auto dof : SCALAR_dofs)
1417 io_buffer.push_back((*this->solution)(dof));
1418 }
1419 }
1420
1421 // 9.)
1422 //
1423 // Actually write the reordered solution vector
1424 // for the ith system to disk
1425
1426 // set up the comment
1427 {
1428 comment = "# System \"";
1429 comment += this->name();
1430 comment += "\" Solution Vector";
1431 }
1432
1433 io.data (io_buffer, comment);
1434
1435 // total_written_size += io_buffer.size();
1436
1437 // Only write additional vectors if wanted
1438 if (write_additional_data)
1439 {
1440 for (auto & [vec_name, vec] : _vectors)
1441 {
1442 io_buffer.clear();
1443 io_buffer.reserve(vec->local_size());
1444
1445 // Loop over each non-SCALAR variable and each node, and write out the value.
1446 for (unsigned int var=0; var<nv; var++)
1447 if (this->variable(var).type().family != SCALAR)
1448 {
1449 // First write the node DOF values
1450 for (const auto & node : ordered_nodes)
1451 for (auto comp : make_range(node->n_comp(sys_num,var)))
1452 {
1453 libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
1455
1456 io_buffer.push_back((*vec)(node->dof_number(sys_num, var, comp)));
1457 }
1458
1459 // Then write the element DOF values
1460 for (const auto & elem : ordered_elements)
1461 for (auto comp : make_range(elem->n_comp(sys_num,var)))
1462 {
1463 libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
1465
1466 io_buffer.push_back((*vec)(elem->dof_number(sys_num, var, comp)));
1467 }
1468 }
1469
1470 // Finally, write the SCALAR data on the last processor
1471 for (auto var : make_range(this->n_vars()))
1472 if (this->variable(var).type().family == SCALAR)
1473 {
1474 if (this->processor_id() == (this->n_processors()-1))
1475 {
1476 const DofMap & dof_map = this->get_dof_map();
1477 std::vector<dof_id_type> SCALAR_dofs;
1478 dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
1479
1480 for (auto dof : SCALAR_dofs)
1481 io_buffer.push_back((*vec)(dof));
1482 }
1483 }
1484
1485 // 10.)
1486 //
1487 // Actually write the reordered additional vector
1488 // for this system to disk
1489
1490 // set up the comment
1491 {
1492 comment = "# System \"";
1493 comment += this->name();
1494 comment += "\" Additional Vector \"";
1495 comment += vec_name;
1496 comment += "\"";
1497 }
1498
1499 io.data (io_buffer, comment);
1500
1501 // total_written_size += io_buffer.size();
1502 }
1503 }
1504
1505 // const Real
1506 // dt = pl.get_elapsed_time(),
1507 // rate = total_written_size*sizeof(Number)/dt;
1508
1509 // libMesh::err << "Write " << total_written_size << " \"Number\" values\n"
1510 // << " Elapsed time = " << dt << '\n'
1511 // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
1512
1513 // pl.pop("write_parallel_data");
1514}

References libMesh::System::_vectors, libMesh::Xdr::data(), libMesh::FEType::family, libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::DofObject::invalid_id, libMesh::libmesh_assert(), libMesh::make_range(), libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMesh::System::name(), libMesh::System::number(), libMesh::ParallelObject::processor_id(), libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::System::solution, libMesh::Variable::type(), libMesh::System::variable(), and libMesh::Xdr::writing().

◆ write_SCALAR_dofs()

unsigned int libMesh::System::write_SCALAR_dofs ( const NumericVector< Number > &  vec,
const unsigned int  var,
Xdr &  io 
) const
privateinherited

Writes the SCALAR dofs associated with var to the stream io.

Returns
The number of values written.

Definition at line 1912 of file system_io.C.

1915{
1916 unsigned int written_length=0;
1917 std::vector<Number> vals; // The raw values for the local objects in the current block
1918 // Collect the SCALARs for the current variable
1919 if (this->processor_id() == (this->n_processors()-1))
1920 {
1921 const DofMap & dof_map = this->get_dof_map();
1922 std::vector<dof_id_type> SCALAR_dofs;
1923 dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
1924 const unsigned int n_scalar_dofs = cast_int<unsigned int>
1925 (SCALAR_dofs.size());
1926
1927 for (unsigned int i=0; i<n_scalar_dofs; i++)
1928 {
1929 vals.push_back( vec(SCALAR_dofs[i]) );
1930 }
1931 }
1932
1933#ifdef LIBMESH_HAVE_MPI
1934 if (this->n_processors() > 1)
1935 {
1936 const Parallel::MessageTag val_tag =
1937 this->comm().get_unique_tag(1);
1938
1939 // Post the receive on processor 0
1940 if (this->processor_id() == 0)
1941 {
1942 this->comm().receive(this->n_processors()-1, vals, val_tag);
1943 }
1944
1945 // Send the data to processor 0
1946 if (this->processor_id() == (this->n_processors()-1))
1947 {
1948 this->comm().send(0, vals, val_tag);
1949 }
1950 }
1951#endif
1952
1953 // -------------------------------------------------------
1954 // Write the output on processor 0.
1955 if (this->processor_id() == 0)
1956 {
1957 const unsigned int vals_size =
1958 cast_int<unsigned int>(vals.size());
1959 io.data_stream (vals.data(), vals_size);
1960 written_length += vals_size;
1961 }
1962
1963 return written_length;
1964}

References libMesh::ParallelObject::comm(), libMesh::Xdr::data_stream(), libMesh::System::get_dof_map(), libMesh::Parallel::Communicator::get_unique_tag(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::Parallel::Communicator::receive(), libMesh::DofMap::SCALAR_dof_indices(), and libMesh::Parallel::Communicator::send().

Referenced by libMesh::System::write_serialized_vector(), and libMesh::System::write_serialized_vectors().

◆ write_serialized_blocked_dof_objects()

template<typename iterator_type >
std::size_t libMesh::System::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
privateinherited

Writes an output vector to the stream io for a set of DofObjects.

This method uses blocked output and is safe to call on a distributed memory-mesh.

Returns
The number of values written

Definition at line 1626 of file system_io.C.

1632{
1633 parallel_object_only();
1634
1635 //-------------------------------------------------------
1636 // General order: (IO format 0.7.4 & greater)
1637 //
1638 // for (objects ...)
1639 // for (vecs ....)
1640 // for (vars ....)
1641 // for (comps ...)
1642 //
1643 // where objects are nodes or elements, sorted to be
1644 // partition independent,
1645 // vecs are one or more *identically distributed* solution
1646 // coefficient vectors, vars are one or more variables
1647 // to write, and comps are all the components for said
1648 // vars on the object.
1649
1650 // We will write all variables unless requested otherwise.
1651 std::vector<unsigned int> vars_to_write(1, var_to_write);
1652
1653 if (var_to_write == libMesh::invalid_uint)
1654 {
1655 vars_to_write.clear(); vars_to_write.reserve(this->n_vars());
1656 for (auto var : make_range(this->n_vars()))
1657 vars_to_write.push_back(var);
1658 }
1659
1660 const dof_id_type io_blksize = cast_int<dof_id_type>
1661 (std::min(max_io_blksize, static_cast<std::size_t>(n_objs)));
1662
1663 const unsigned int
1664 sys_num = this->number(),
1665 num_vecs = cast_int<unsigned int>(vecs.size()),
1666 num_blks = cast_int<unsigned int>(std::ceil(static_cast<double>(n_objs)/
1667 static_cast<double>(io_blksize)));
1668
1669 // libMesh::out << "io_blksize = " << io_blksize
1670 // << ", num_objects = " << n_objs
1671 // << ", num_blks = " << num_blks
1672 // << std::endl;
1673
1674 std::size_t written_length=0; // The numer of values written. This will be returned
1675 std::vector<std::vector<dof_id_type>> xfer_ids(num_blks); // The global IDs and # of components for the local objects in all blocks
1676 std::vector<std::vector<Number>> send_vals(num_blks); // The raw values for the local objects in all blocks
1677 std::vector<Parallel::Request>
1678 id_requests(num_blks), val_requests(num_blks); // send request handle for each block
1679 std::vector<Parallel::MessageTag>
1680 id_tags(num_blks), val_tags(num_blks); // tag number for each block
1681
1682 // ------------------------------------------------------
1683 // First pass - count the number of objects in each block
1684 // traverse all the objects and figure out which block they
1685 // will ultimately live in.
1686 std::vector<unsigned int>
1687 xfer_ids_size (num_blks,0),
1688 send_vals_size (num_blks,0);
1689
1690 for (iterator_type it=begin; it!=end; ++it)
1691 {
1692 const dof_id_type
1693 id = (*it)->id(),
1694 block = id/io_blksize;
1695
1696 libmesh_assert_less (block, num_blks);
1697
1698 xfer_ids_size[block] += 2; // for each object, we store its id, as well as the total number of components for all variables
1699
1700 unsigned int n_comp_tot=0;
1701
1702 for (const auto & var : vars_to_write)
1703 n_comp_tot += (*it)->n_comp(sys_num, var); // for each variable, we will store the nonzero components
1704
1705 send_vals_size[block] += n_comp_tot*num_vecs;
1706 }
1707
1708 //-----------------------------------------
1709 // Collect the values for all local objects,
1710 // binning them into 'blocks' that will be
1711 // sent to processor 0
1712 for (unsigned int blk=0; blk<num_blks; blk++)
1713 {
1714 // libMesh::out << "Writing object block " << blk << std::endl;
1715
1716 // Each processor should build up its transfer buffers for its
1717 // local objects in [first_object,last_object).
1718 const dof_id_type
1719 first_object = blk*io_blksize,
1720 last_object = std::min(cast_int<dof_id_type>((blk+1)*io_blksize), n_objs);
1721
1722 // convenience
1723 std::vector<dof_id_type> & ids (xfer_ids[blk]);
1724 std::vector<Number> & vals (send_vals[blk]);
1725
1726 // we now know the number of values we will store for each block,
1727 // so we can do efficient preallocation
1728 ids.clear(); ids.reserve (xfer_ids_size[blk]);
1729 vals.clear(); vals.reserve (send_vals_size[blk]);
1730
1731 if (send_vals_size[blk] != 0) // only send if we have nonzero components to write
1732 for (iterator_type it=begin; it!=end; ++it)
1733 if (((*it)->id() >= first_object) && // object in [first_object,last_object)
1734 ((*it)->id() < last_object))
1735 {
1736 ids.push_back((*it)->id());
1737
1738 // count the total number of nonzeros transferred for this object
1739 {
1740 unsigned int n_comp_tot=0;
1741
1742 for (const auto & var : vars_to_write)
1743 n_comp_tot += (*it)->n_comp(sys_num, var);
1744
1745 ids.push_back (n_comp_tot*num_vecs); // even if 0 - processor 0 has no way of knowing otherwise...
1746 }
1747
1748 // pack the values to send
1749 for (const auto & vec : vecs)
1750 for (const auto & var : vars_to_write)
1751 {
1752 const unsigned int n_comp = (*it)->n_comp(sys_num, var);
1753
1754 for (unsigned int comp=0; comp<n_comp; comp++)
1755 {
1756 libmesh_assert_greater_equal ((*it)->dof_number(sys_num, var, comp), vec->first_local_index());
1757 libmesh_assert_less ((*it)->dof_number(sys_num, var, comp), vec->last_local_index());
1758 vals.push_back((*vec)((*it)->dof_number(sys_num, var, comp)));
1759 }
1760 }
1761 }
1762
1763#ifdef LIBMESH_HAVE_MPI
1764 id_tags[blk] = this->comm().get_unique_tag(100*num_blks + blk);
1765 val_tags[blk] = this->comm().get_unique_tag(200*num_blks + blk);
1766
1767 // nonblocking send the data for this block
1768 this->comm().send (0, ids, id_requests[blk], id_tags[blk]);
1769 this->comm().send (0, vals, val_requests[blk], val_tags[blk]);
1770#endif
1771 }
1772
1773
1774 if (this->processor_id() == 0)
1775 {
1776 std::vector<std::vector<dof_id_type>> recv_ids (this->n_processors());
1777 std::vector<std::vector<Number>> recv_vals (this->n_processors());
1778 std::vector<unsigned int> obj_val_offsets; // map to traverse entry-wise rather than processor-wise
1779 std::vector<Number> output_vals; // The output buffer for the current block
1780
1781 // a ThreadedIO object to perform asynchronous file IO
1782 ThreadedIO<Number> threaded_io(io, output_vals);
1783 std::unique_ptr<Threads::Thread> async_io;
1784
1785 for (unsigned int blk=0; blk<num_blks; blk++)
1786 {
1787 // Each processor should build up its transfer buffers for its
1788 // local objects in [first_object,last_object).
1789 const dof_id_type
1790 first_object = cast_int<dof_id_type>(blk*io_blksize),
1791 last_object = std::min(cast_int<dof_id_type>((blk+1)*io_blksize), n_objs),
1792 n_objects_blk = last_object - first_object;
1793
1794 // offset array. this will define where each object's values
1795 // map into the actual output_vals buffer. this must get
1796 // 0-initialized because 0-component objects are not actually sent
1797 obj_val_offsets.resize (n_objects_blk); std::fill (obj_val_offsets.begin(), obj_val_offsets.end(), 0);
1798
1799 std::size_t n_val_recvd_blk=0;
1800
1801 // receive this block of data from all processors.
1802 for (processor_id_type comm_step=0, tnp=this->n_processors(); comm_step != tnp; ++comm_step)
1803 {
1804#ifdef LIBMESH_HAVE_MPI
1805 // blocking receive indices for this block, imposing no particular order on processor
1806 Parallel::Status id_status (this->comm().probe (Parallel::any_source, id_tags[blk]));
1807 std::vector<dof_id_type> & ids (recv_ids[id_status.source()]);
1808 this->comm().receive (id_status.source(), ids, id_tags[blk]);
1809#else
1810 std::vector<dof_id_type> & ids (recv_ids[0]);
1811 ids = xfer_ids[blk];
1812#endif
1813
1814 // note its possible we didn't receive values for objects in
1815 // this block if they have no components allocated.
1816 for (std::size_t idx=0, sz=ids.size(); idx<sz; idx+=2)
1817 {
1818 const dof_id_type
1819 local_idx = ids[idx+0]-first_object,
1820 n_vals_tot_allvecs = ids[idx+1];
1821
1822 libmesh_assert_less (local_idx, n_objects_blk);
1823 libmesh_assert_less (local_idx, obj_val_offsets.size());
1824
1825 obj_val_offsets[local_idx] = n_vals_tot_allvecs;
1826 }
1827
1828#ifdef LIBMESH_HAVE_MPI
1829 // blocking receive values for this block, imposing no particular order on processor
1830 Parallel::Status val_status (this->comm().probe (Parallel::any_source, val_tags[blk]));
1831 std::vector<Number> & vals (recv_vals[val_status.source()]);
1832 this->comm().receive (val_status.source(), vals, val_tags[blk]);
1833#else
1834 // straight copy without MPI
1835 std::vector<Number> & vals (recv_vals[0]);
1836 vals = send_vals[blk];
1837#endif
1838
1839 n_val_recvd_blk += vals.size();
1840 }
1841
1842 // We need the offsets into the output_vals vector for each object.
1843 // fortunately, this is simply the partial sum of the total number
1844 // of components for each object
1845 std::partial_sum(obj_val_offsets.begin(), obj_val_offsets.end(),
1846 obj_val_offsets.begin());
1847
1848 // wait on any previous asynchronous IO - this *must* complete before
1849 // we start messing with the output_vals buffer!
1850 if (async_io.get()) async_io->join();
1851
1852 // this is the actual output buffer that will be written to disk.
1853 // at ths point we finally know wha size it will be.
1854 output_vals.resize(n_val_recvd_blk);
1855
1856 // pack data from all processors into output values
1857 for (auto proc : make_range(this->n_processors()))
1858 {
1859 const std::vector<dof_id_type> & ids (recv_ids [proc]);
1860 const std::vector<Number> & vals(recv_vals[proc]);
1861 std::vector<Number>::const_iterator proc_vals(vals.begin());
1862
1863 for (std::size_t idx=0, sz=ids.size(); idx<sz; idx+=2)
1864 {
1865 const dof_id_type
1866 local_idx = ids[idx+0]-first_object,
1867 n_vals_tot_allvecs = ids[idx+1];
1868
1869 // put this object's data into the proper location
1870 // in the output buffer
1871 std::vector<Number>::iterator out_vals(output_vals.begin());
1872 if (local_idx != 0)
1873 std::advance (out_vals, obj_val_offsets[local_idx-1]);
1874
1875 for (unsigned int val=0; val<n_vals_tot_allvecs; val++, ++out_vals, ++proc_vals)
1876 {
1877 libmesh_assert (out_vals != output_vals.end());
1878 libmesh_assert (proc_vals != vals.end());
1879 *out_vals = *proc_vals;
1880 }
1881 }
1882 }
1883
1884 // output_vals buffer is now filled for this block.
1885 // write it to disk
1886 async_io = std::make_unique<Threads::Thread>(threaded_io);
1887 written_length += output_vals.size();
1888 }
1889
1890 // wait on any previous asynchronous IO - this *must* complete before
1891 // our stuff goes out of scope
1892 async_io->join();
1893 }
1894
1895 Parallel::wait(id_requests);
1896 Parallel::wait(val_requests);
1897
1898 // we need some synchronization here. Because this method
1899 // can be called for a range of nodes, then a range of elements,
1900 // we need some mechanism to prevent processors from racing past
1901 // to the next range and overtaking ongoing communication. one
1902 // approach would be to figure out unique tags for each range,
1903 // but for now we just impose a barrier here. And might as
1904 // well have it do some useful work.
1905 this->comm().broadcast(written_length);
1906
1907 return written_length;
1908}

References TIMPI::any_source, libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::Parallel::Communicator::get_unique_tag(), libMesh::invalid_uint, libMesh::libmesh_assert(), libMesh::make_range(), libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMesh::System::number(), libMesh::ParallelObject::processor_id(), libMesh::Parallel::Communicator::receive(), libMesh::Parallel::Communicator::send(), TIMPI::Status::source(), and TIMPI::wait().

Referenced by libMesh::System::write_serialized_vector(), and libMesh::System::write_serialized_vectors().

◆ write_serialized_data()

void libMesh::System::write_serialized_data ( Xdr &  io,
const bool  write_additional_data = true 
) const
inherited

Writes additional data, namely vectors, for this System.

This method may safely be called on a distributed-memory mesh.

This method implements the output of the vectors contained in this System object, embedded in the output of an EquationSystems<T_sys>.

9.) The global solution vector, re-ordered to be node-major (More on this later.)

for each additional vector in the object

10.) The global additional vector, re-ordered to be node-major (More on this later.)

Definition at line 1518 of file system_io.C.

1520{
1534 parallel_object_only();
1535 std::string comment;
1536
1537 // PerfLog pl("IO Performance",false);
1538 // pl.push("write_serialized_data");
1539 // std::size_t total_written_size = 0;
1540
1541 // total_written_size +=
1542 this->write_serialized_vector(io, *this->solution);
1543
1544 // set up the comment
1545 if (this->processor_id() == 0)
1546 {
1547 comment = "# System \"";
1548 comment += this->name();
1549 comment += "\" Solution Vector";
1550
1551 io.comment (comment);
1552 }
1553
1554 // Only write additional vectors if wanted
1555 if (write_additional_data)
1556 {
1557 for (auto & pair : this->_vectors)
1558 {
1559 // total_written_size +=
1560 this->write_serialized_vector(io, *pair.second);
1561
1562 // set up the comment
1563 if (this->processor_id() == 0)
1564 {
1565 comment = "# System \"";
1566 comment += this->name();
1567 comment += "\" Additional Vector \"";
1568 comment += pair.first;
1569 comment += "\"";
1570 io.comment (comment);
1571 }
1572 }
1573 }
1574
1575 // const Real
1576 // dt = pl.get_elapsed_time(),
1577 // rate = total_written_size*sizeof(Number)/dt;
1578
1579 // libMesh::out << "Write " << total_written_size << " \"Number\" values\n"
1580 // << " Elapsed time = " << dt << '\n'
1581 // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
1582
1583 // pl.pop("write_serialized_data");
1584
1585
1586
1587
1588 // // test the new method
1589 // {
1590 // std::vector<std::string> names;
1591 // std::vector<NumericVector<Number> *> vectors_to_write;
1592
1593 // names.push_back("Solution Vector");
1594 // vectors_to_write.push_back(this->solution.get());
1595
1596 // // Only write additional vectors if wanted
1597 // if (write_additional_data)
1598 // {
1599 // std::map<std::string, NumericVector<Number> *>::const_iterator
1600 // pos = _vectors.begin();
1601
1602 // for (; pos != this->_vectors.end(); ++pos)
1603 // {
1604 // names.push_back("Additional Vector " + pos->first);
1605 // vectors_to_write.push_back(pos->second);
1606 // }
1607 // }
1608
1609 // total_written_size =
1610 // this->write_serialized_vectors (io, names, vectors_to_write);
1611
1612 // const Real
1613 // dt2 = pl.get_elapsed_time(),
1614 // rate2 = total_written_size*sizeof(Number)/(dt2-dt);
1615
1616 // libMesh::out << "Write (new) " << total_written_size << " \"Number\" values\n"
1617 // << " Elapsed time = " << (dt2-dt) << '\n'
1618 // << " Rate = " << rate2/1.e6 << "(MB/sec)\n\n";
1619
1620 // }
1621}
dof_id_type write_serialized_vector(Xdr &io, const NumericVector< Number > &vec) const
Writes a vector for this System.
Definition system_io.C:1968

References libMesh::System::_vectors, libMesh::Xdr::comment(), libMesh::System::name(), libMesh::ParallelObject::processor_id(), libMesh::System::solution, and libMesh::System::write_serialized_vector().

Referenced by libMesh::RBConstruction::write_riesz_representors_to_files(), and libMesh::TransientRBConstruction::write_riesz_representors_to_files().

◆ write_serialized_vector()

dof_id_type libMesh::System::write_serialized_vector ( Xdr &  io,
const NumericVector< Number > &  vec 
) const
privateinherited

Writes a vector for this System.

This method may safely be called on a distributed-memory mesh.

Returns
The number of values written.

Definition at line 1968 of file system_io.C.

1970{
1971 parallel_object_only();
1972
1973 libmesh_assert (io.writing());
1974
1975 dof_id_type vec_length = vec.size();
1976 if (this->processor_id() == 0) io.data (vec_length, "# vector length");
1977
1978 dof_id_type written_length = 0;
1979
1980 //---------------------------------
1981 // Collect the values for all nodes
1982 written_length += cast_int<dof_id_type>
1983 (this->write_serialized_blocked_dof_objects (std::vector<const NumericVector<Number> *>(1,&vec),
1984 this->get_mesh().n_nodes(),
1985 this->get_mesh().local_nodes_begin(),
1986 this->get_mesh().local_nodes_end(),
1987 io));
1988
1989 //------------------------------------
1990 // Collect the values for all elements
1991 written_length += cast_int<dof_id_type>
1992 (this->write_serialized_blocked_dof_objects (std::vector<const NumericVector<Number> *>(1,&vec),
1993 this->get_mesh().n_elem(),
1994 this->get_mesh().local_elements_begin(),
1995 this->get_mesh().local_elements_end(),
1996 io));
1997
1998 //-------------------------------------------
1999 // Finally loop over all the SCALAR variables
2000 for (auto var : make_range(this->n_vars()))
2001 if (this->variable(var).type().family == SCALAR)
2002 {
2003 written_length +=
2004 this->write_SCALAR_dofs (vec, var, io);
2005 }
2006
2007 if (this->processor_id() == 0)
2008 libmesh_assert_equal_to (written_length, vec_length);
2009
2010 return written_length;
2011}
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.
Definition system_io.C:1626
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.
Definition system_io.C:1912

References libMesh::Xdr::data(), libMesh::FEType::family, libMesh::System::get_mesh(), libMesh::libmesh_assert(), libMesh::make_range(), n_nodes, libMesh::System::n_vars(), libMesh::ParallelObject::processor_id(), libMesh::SCALAR, libMesh::NumericVector< T >::size(), libMesh::Variable::type(), libMesh::System::variable(), libMesh::System::write_SCALAR_dofs(), libMesh::System::write_serialized_blocked_dof_objects(), and libMesh::Xdr::writing().

Referenced by libMesh::System::write_serialized_data().

◆ write_serialized_vectors()

std::size_t libMesh::System::write_serialized_vectors ( Xdr &  io,
const std::vector< const NumericVector< Number > * > &  vectors 
) const
inherited

Serialize & write a number of identically distributed vectors.

This method allows for optimization for the multiple vector case by only communicating the metadata once.

Definition at line 2111 of file system_io.C.

2113{
2114 parallel_object_only();
2115
2116 libmesh_assert (io.writing());
2117
2118 // Cache these - they are not free!
2119 const dof_id_type
2120 n_nodes = this->get_mesh().n_nodes(),
2121 n_elem = this->get_mesh().n_elem();
2122
2123 std::size_t written_length = 0;
2124
2125 if (this->processor_id() == 0)
2126 {
2127 unsigned int
2128 n_vec = cast_int<unsigned int>(vectors.size());
2130 vec_size = vectors.empty() ? 0 : vectors[0]->size();
2131 // Set the number of vectors
2132 io.data(n_vec, "# number of vectors");
2133 // Set the buffer size
2134 io.data(vec_size, "# vector length");
2135 }
2136
2137 //---------------------------------
2138 // Collect the values for all nodes
2139 written_length +=
2141 n_nodes,
2142 this->get_mesh().local_nodes_begin(),
2143 this->get_mesh().local_nodes_end(),
2144 io);
2145
2146 //------------------------------------
2147 // Collect the values for all elements
2148 written_length +=
2150 n_elem,
2151 this->get_mesh().local_elements_begin(),
2152 this->get_mesh().local_elements_end(),
2153 io);
2154
2155 //-------------------------------------------
2156 // Finally loop over all the SCALAR variables
2157 for (const NumericVector<Number> * vec : vectors)
2158 for (auto var : make_range(this->n_vars()))
2159 if (this->variable(var).type().family == SCALAR)
2160 {
2161 libmesh_assert_not_equal_to (vec, 0);
2162
2163 written_length +=
2164 this->write_SCALAR_dofs (*vec, var, io);
2165 }
2166
2167 return written_length;
2168}

References libMesh::Xdr::data(), libMesh::FEType::family, libMesh::System::get_mesh(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), n_nodes, libMesh::System::n_vars(), libMesh::ParallelObject::processor_id(), libMesh::SCALAR, libMesh::Variable::type(), libMesh::System::variable(), libMesh::System::write_SCALAR_dofs(), libMesh::System::write_serialized_blocked_dof_objects(), and libMesh::Xdr::writing().

Referenced by libMesh::RBEvaluation::write_out_vectors().

◆ zero_variable()

void libMesh::System::zero_variable ( NumericVector< Number > &  v,
unsigned int  var_num 
) const
inherited

Zeroes all dofs in v that correspond to variable number var_num.

Definition at line 1506 of file system.C.

1508{
1509 /* Make sure the call makes sense. */
1510 libmesh_assert_less (var_num, this->n_vars());
1511
1512 /* Get a reference to the mesh. */
1513 const MeshBase & mesh = this->get_mesh();
1514
1515 /* Check which system we are. */
1516 const unsigned int sys_num = this->number();
1517
1518 // Loop over nodes.
1520 (mesh.node_stored_range(),
1521 [sys_num, var_num, &v](const Node * node)
1522 {
1523 unsigned int n_comp = node->n_comp(sys_num,var_num);
1524 for (unsigned int i=0; i<n_comp; i++)
1525 {
1526 const dof_id_type index = node->dof_number(sys_num,var_num,i);
1527 v.set(index,0.0);
1528 }
1529 });
1530
1531 // Loop over elements.
1533 (mesh.active_local_element_stored_range(),
1534 [sys_num, var_num, &v](const Elem * elem)
1535 {
1536 unsigned int n_comp = elem->n_comp(sys_num,var_num);
1537 for (unsigned int i=0; i<n_comp; i++)
1538 {
1539 const dof_id_type index = elem->dof_number(sys_num,var_num,i);
1540 v.set(index,0.0);
1541 }
1542 });
1543}
void parallel_for_each(Range &&range, Body &&body, unsigned int n_threads=libMesh::n_threads())
A nicer syntax for parallel_for calls in cases where no setup or teardown is needed outside the subra...
Definition threads.h:308

References libMesh::System::get_mesh(), mesh, libMesh::System::n_vars(), libMesh::MeshBase::node_stored_range(), libMesh::System::number(), and libMesh::Threads::parallel_for_each().

Member Data Documentation

◆ _active

bool libMesh::System::_active
privateinherited

Flag stating if the system is active or not.

Definition at line 2278 of file system.h.

Referenced by libMesh::System::activate(), libMesh::System::active(), and libMesh::System::deactivate().

◆ _additional_data_written

unsigned int libMesh::System::_additional_data_written
privateinherited

This flag is used only when reading in a system from file.

Based on the system header, it keeps track of how many additional vectors were actually written for this file.

Definition at line 2339 of file system.h.

Referenced by libMesh::System::read_header(), libMesh::System::read_parallel_data(), and libMesh::System::read_serialized_data().

◆ _assemble_system_function

void(* libMesh::System::_assemble_system_function) (EquationSystems &es, const std::string &name)
privateinherited

Function that assembles the system.

Definition at line 2202 of file system.h.

◆ _assemble_system_object

Assembly* libMesh::System::_assemble_system_object
privateinherited

Object that assembles the system.

Definition at line 2208 of file system.h.

◆ _basic_system_only

bool libMesh::System::_basic_system_only
privateinherited

Holds true if the components of more advanced system types (e.g.

system matrices) should not be initialized.

Definition at line 2326 of file system.h.

Referenced by libMesh::System::init_data(), libMesh::System::reinit(), libMesh::System::reinit_mesh(), and libMesh::System::set_basic_system_only().

◆ _communicator

const Parallel::Communicator& libMesh::ParallelObject::_communicator
protectedinherited

◆ _constrain_in_solver

bool libMesh::DifferentiableSystem::_constrain_in_solver
protectedinherited

_constrain_in_solver defaults to true; if false then we apply constraints only via residual terms in the systems to be solved.

Definition at line 424 of file diff_system.h.

Referenced by libMesh::DifferentiableSystem::get_constrain_in_solver(), and libMesh::DifferentiableSystem::set_constrain_in_solver().

◆ _constrain_system_function

void(* libMesh::System::_constrain_system_function) (EquationSystems &es, const std::string &name)
privateinherited

Function to impose constraints.

Definition at line 2213 of file system.h.

◆ _constrain_system_object

Constraint* libMesh::System::_constrain_system_object
privateinherited

Object that constrains the system.

Definition at line 2219 of file system.h.

◆ _counts

ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited

Actually holds the data.

Definition at line 124 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::get_info().

◆ _diff_physics

std::stack<std::unique_ptr<DifferentiablePhysics>, std::vector<std::unique_ptr<DifferentiablePhysics> > > libMesh::DifferentiableSystem::_diff_physics
privateinherited

Stack of pointers to objects to use for physics assembly evaluations.

Physics assembly defaults to this for backwards compatibility if the stack is empty; for the most flexibility users should create separate physics objects.

Definition at line 434 of file diff_system.h.

Referenced by libMesh::DifferentiableSystem::attach_physics(), libMesh::DifferentiableSystem::clear(), libMesh::DifferentiableSystem::get_physics(), libMesh::DifferentiableSystem::get_physics(), libMesh::DifferentiableSystem::init_data(), libMesh::DifferentiableSystem::pop_physics(), and libMesh::DifferentiableSystem::push_physics().

◆ _diff_qoi

std::stack<std::unique_ptr<DifferentiableQoI>, std::vector<std::unique_ptr<DifferentiableQoI> > > libMesh::DifferentiableSystem::_diff_qoi
privateinherited

Pointer to object to use for quantity of interest assembly evaluations.

Defaults to this for backwards compatibility; in the future users should create separate physics objects.

Definition at line 442 of file diff_system.h.

Referenced by libMesh::DifferentiableSystem::attach_qoi(), libMesh::DifferentiableSystem::clear(), libMesh::DifferentiableSystem::get_qoi(), and libMesh::DifferentiableSystem::get_qoi().

◆ _dof_map

std::unique_ptr<DofMap> libMesh::System::_dof_map
privateinherited

◆ _enable_print_counter

bool libMesh::ReferenceCounter::_enable_print_counter = true
staticprotectedinherited

Flag to control whether reference count information is printed when print_info is called.

Definition at line 143 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().

◆ _equation_systems

EquationSystems& libMesh::System::_equation_systems
privateinherited

Constant reference to the EquationSystems object used for the simulation.

Definition at line 2257 of file system.h.

Referenced by libMesh::System::get_equation_systems(), and libMesh::System::get_equation_systems().

◆ _first_order_vars

std::set<unsigned int> libMesh::DifferentiablePhysics::_first_order_vars
protectedinherited

◆ _hide_output

bool libMesh::System::_hide_output
privateinherited

Are we allowed to write this system to file? If _hide_output is true, then EquationSystems::write will ignore this system.

Definition at line 2364 of file system.h.

Referenced by libMesh::System::hide_output().

◆ _init_system_function

void(* libMesh::System::_init_system_function) (EquationSystems &es, const std::string &name)
privateinherited

Function that initializes the system.

Definition at line 2191 of file system.h.

◆ _init_system_object

Initialization* libMesh::System::_init_system_object
privateinherited

Object that initializes the system.

Definition at line 2197 of file system.h.

◆ _is_initialized

bool libMesh::System::_is_initialized
privateinherited

true when additional vectors and variables do not require immediate initialization, false otherwise.

Definition at line 2332 of file system.h.

Referenced by libMesh::System::add_vector(), libMesh::System::clear(), libMesh::System::compare(), libMesh::System::init_data(), and libMesh::System::is_initialized().

◆ _matrices

std::map<std::string, std::unique_ptr<SparseMatrix<Number> >, std::less<> > libMesh::System::_matrices
privateinherited

◆ _matrices_initialized

bool libMesh::System::_matrices_initialized
privateinherited

false when additional matrices being added require initialization, true otherwise.

Definition at line 2313 of file system.h.

Referenced by libMesh::System::can_add_matrices(), libMesh::System::clear(), libMesh::System::init_matrices(), libMesh::System::late_matrix_init(), and libMesh::System::prefer_hash_table_matrix_assembly().

◆ _matrix_types

std::map<std::string, ParallelType, std::less<> > libMesh::System::_matrix_types
privateinherited

Holds the types of the matrices.

Definition at line 2308 of file system.h.

Referenced by libMesh::System::add_matrix(), libMesh::System::add_matrix(), libMesh::System::add_matrix(), and libMesh::System::init_matrices().

◆ _mesh

MeshBase& libMesh::System::_mesh
privateinherited

Constant reference to the mesh data structure used for the simulation.

Definition at line 2263 of file system.h.

Referenced by libMesh::System::get_mesh(), libMesh::System::get_mesh(), libMesh::System::reinit_constraints(), and libMesh::System::reinit_dirichlet_constraint_values().

◆ _mesh_sys

System* libMesh::DifferentiablePhysics::_mesh_sys
protectedinherited

◆ _mesh_x_var

unsigned int libMesh::DifferentiablePhysics::_mesh_x_var
protectedinherited

◆ _mesh_y_var

unsigned int libMesh::DifferentiablePhysics::_mesh_y_var
protectedinherited

◆ _mesh_z_var

unsigned int libMesh::DifferentiablePhysics::_mesh_z_var
protectedinherited

◆ _mutex

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 137 of file reference_counter.h.

◆ _n_objects

Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects
staticprotectedinherited

◆ _numerical_jacobian_h_for_var

std::vector<Real> libMesh::FEMSystem::_numerical_jacobian_h_for_var
privateinherited

◆ _options_prefix

std::string libMesh::System::_options_prefix
privateinherited

Solver-package options prefix of this system's vectors and matrices.

Definition at line 2389 of file system.h.

Referenced by libMesh::System::add_matrix(), libMesh::System::add_matrix(), libMesh::System::add_vector(), libMesh::System::options_prefix(), and libMesh::System::set_options_prefix().

◆ _prefer_hash_table_matrix_assembly

bool libMesh::System::_prefer_hash_table_matrix_assembly
privateinherited

Whether to use hash table matrix assembly if the matrix sub-classes support it.

Definition at line 2374 of file system.h.

Referenced by libMesh::System::init_matrices(), and libMesh::System::prefer_hash_table_matrix_assembly().

◆ _prefix_with_name

bool libMesh::System::_prefix_with_name
privateinherited

Whether we are name prefixing solver options.

Definition at line 2384 of file system.h.

Referenced by libMesh::System::prefix_with_name(), and libMesh::System::prefix_with_name().

◆ _qoi

std::vector<Number> libMesh::System::_qoi
privateinherited

Values of the quantities of interest.

This vector needs to be both resized and filled by the user before any quantity of interest assembly is done and before any sensitivities are calculated. Use the get_qoi_values() accessor to get these values.

Definition at line 2398 of file system.h.

Referenced by libMesh::System::n_qois().

◆ _qoi_error_estimates

std::vector<Number> libMesh::System::_qoi_error_estimates
privateinherited

Vector to hold error estimates for qois, either from a steady state calculation, or from a single unsteady solver timestep.

Used by the library after resizing to match the size of the qoi vector. User code can use this for accumulating error estimates for example. Use the set_qoi_error_estimate()/get_qoi_error_estimate_value() accessors to set/get these values.

Definition at line 2408 of file system.h.

◆ _qoi_evaluate_derivative_function

void(* libMesh::System::_qoi_evaluate_derivative_function) (EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
privateinherited

Function to evaluate quantity of interest derivative.

Definition at line 2236 of file system.h.

◆ _qoi_evaluate_derivative_object

QOIDerivative* libMesh::System::_qoi_evaluate_derivative_object
privateinherited

Object to compute derivatives of quantities of interest.

Definition at line 2245 of file system.h.

◆ _qoi_evaluate_function

void(* libMesh::System::_qoi_evaluate_function) (EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
privateinherited

Function to evaluate quantity of interest.

Definition at line 2224 of file system.h.

◆ _qoi_evaluate_object

QOI* libMesh::System::_qoi_evaluate_object
privateinherited

Object to compute quantities of interest.

Definition at line 2231 of file system.h.

◆ _require_sparsity_pattern

bool libMesh::System::_require_sparsity_pattern
privateinherited

Whether any of our matrices require an initial sparsity pattern computation in order to determine preallocation.

Definition at line 2379 of file system.h.

Referenced by libMesh::System::init_matrices(), and libMesh::System::reinit().

◆ _sc_system_matrix

StaticCondensation* libMesh::ImplicitSystem::_sc_system_matrix
privateinherited

◆ _second_order_dot_vars

std::map<unsigned int,unsigned int> libMesh::DifferentiablePhysics::_second_order_dot_vars
protectedinherited

If the user adds any second order variables, then we need to also cache the map to their corresponding dot variable that will be added by this TimeSolver class.

Definition at line 560 of file diff_physics.h.

Referenced by libMesh::DifferentiableSystem::add_second_order_dot_vars(), and libMesh::DifferentiableSystem::get_second_order_dot_var().

◆ _second_order_vars

std::set<unsigned int> libMesh::DifferentiablePhysics::_second_order_vars
protectedinherited

◆ _solution_projection

bool libMesh::System::_solution_projection
privateinherited

Holds true if the solution vector should be projected onto a changed grid, false if it should be zeroed.

This is true by default.

Definition at line 2320 of file system.h.

Referenced by libMesh::System::project_solution_on_reinit(), and libMesh::System::restrict_vectors().

◆ _sys_name

const std::string libMesh::System::_sys_name
privateinherited

A name associated with this system.

Definition at line 2268 of file system.h.

Referenced by libMesh::System::clear(), libMesh::System::compare(), and libMesh::System::name().

◆ _sys_number

const unsigned int libMesh::System::_sys_number
privateinherited

The number associated with this system.

Definition at line 2273 of file system.h.

Referenced by libMesh::System::number().

◆ _time_evolving

std::vector<unsigned int> libMesh::DifferentiablePhysics::_time_evolving
protectedinherited

Stores unsigned int to tell us which variables are evolving as first order in time (1), second order in time (2), or are not time evolving (0).

Definition at line 543 of file diff_physics.h.

Referenced by libMesh::DifferentiablePhysics::clear_physics(), libMesh::DifferentiablePhysics::init_physics(), libMesh::DifferentiablePhysics::is_time_evolving(), and libMesh::DifferentiablePhysics::time_evolving().

◆ _vector_is_adjoint

std::map<std::string, int, std::less<> > libMesh::System::_vector_is_adjoint
privateinherited

Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs, -1 if primal.

Definition at line 2298 of file system.h.

Referenced by libMesh::System::add_vector(), libMesh::System::clear(), libMesh::System::remove_vector(), libMesh::System::set_vector_as_adjoint(), and libMesh::System::vector_is_adjoint().

◆ _vector_projections

std::map<std::string, bool, std::less<> > libMesh::System::_vector_projections
privateinherited

Holds true if a vector by that name should be projected onto a changed grid, false if it should be zeroed.

Definition at line 2292 of file system.h.

Referenced by libMesh::System::add_vector(), libMesh::System::clear(), libMesh::System::remove_vector(), libMesh::System::restrict_vectors(), libMesh::System::set_vector_preservation(), libMesh::System::vector_preservation(), and libMesh::System::write_header().

◆ _vectors

std::map<std::string, std::unique_ptr<NumericVector<Number> >, std::less<> > libMesh::System::_vectors
privateinherited

◆ _written_var_indices

std::vector<unsigned int> libMesh::System::_written_var_indices
privateinherited

This vector is used only when reading in a system from file.

Based on the system header, it keeps track of any index remapping between variable names in the data file and variable names in the already-constructed system. I.e. if we have a system with variables "A1", "A2", "B1", and "B2", but we read in a data file with only "A1" and "B1" defined, then we don't want to try and read in A2 or B2, and we don't want to assign A1 and B1 values to different dof indices.

Definition at line 2351 of file system.h.

Referenced by libMesh::System::read_header(), libMesh::System::read_parallel_data(), libMesh::System::read_serialized_blocked_dof_objects(), and libMesh::System::read_serialized_vector().

◆ adjoint_already_solved

bool libMesh::System::adjoint_already_solved
privateinherited

Has the adjoint problem already been solved? If the user sets adjoint_already_solved to true, we won't waste time solving it again.

Definition at line 2358 of file system.h.

Referenced by libMesh::System::is_adjoint_already_solved(), and libMesh::System::set_adjoint_already_solved().

◆ args

GetPot SolidSystem::args

Definition at line 58 of file solid_system.h.

Referenced by element_time_derivative(), init_data(), setup(), and side_time_derivative().

◆ assemble_before_solve

bool libMesh::System::assemble_before_solve
inherited

Flag which tells the system to whether or not to call the user assembly function during each call to solve().

By default, every call to solve() begins with a call to the user assemble, so this flag is true. (For explicit systems, "solving" the system occurs during the assembly step, so this flag is always true for explicit systems.)

You will only want to set this to false if you need direct control over when the system is assembled, and are willing to track the state of its assembly yourself. An example of such a case is an implicit system with multiple right hand sides. In this instance, a single assembly would likely be followed with multiple calls to solve.

The frequency system and Newmark system have their own versions of this flag, called _finished_assemble, which might be able to be replaced with this more general concept.

Definition at line 1621 of file system.h.

Referenced by libMesh::ImplicitSystem::adjoint_solve(), libMesh::ClawSystem::ClawSystem(), libMesh::System::disable_cache(), libMesh::ImplicitSystem::disable_cache(), main(), libMesh::RBConstruction::RBConstruction(), libMesh::RBSCMConstruction::RBSCMConstruction(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::CondensedEigenSystem::solve(), libMesh::EigenSystem::solve(), and libMesh::LinearImplicitSystem::solve().

◆ assemble_qoi_elements

bool libMesh::DifferentiableQoI::assemble_qoi_elements
inherited

If assemble_qoi_elements is false (it is true by default), the assembly loop for a quantity of interest or its derivatives will skip computing on mesh elements, and will only compute on mesh sides.

Definition at line 101 of file diff_qoi.h.

◆ assemble_qoi_internal_sides

bool libMesh::DifferentiableQoI::assemble_qoi_internal_sides
inherited

If assemble_qoi_internal_sides is true (it is false by default), the assembly loop for a quantity of interest or its derivatives will loop over element sides which do not fall on domain boundaries.

Definition at line 93 of file diff_qoi.h.

◆ assemble_qoi_sides

bool libMesh::DifferentiableQoI::assemble_qoi_sides
inherited

If assemble_qoi_sides is true (it is false by default), the assembly loop for a quantity of interest or its derivatives will loop over domain boundary sides.

To add domain interior sides, also set assemble_qoi_internal_sides to true.

Definition at line 85 of file diff_qoi.h.

Referenced by main().

◆ compute_internal_sides

bool libMesh::DifferentiablePhysics::compute_internal_sides
inherited

compute_internal_sides is false by default, indicating that side_* computations will only be done on boundary sides.

If compute_internal_sides is true, computations will be done on sides between elements as well.

Definition at line 156 of file diff_physics.h.

◆ current_local_solution

std::unique_ptr<NumericVector<Number> > libMesh::System::current_local_solution
inherited

All the values I need to compute my contribution to the simulation at hand.

Think of this as the current solution with any ghost values needed from other processors. This vector is necessarily larger than the solution vector in the case of a parallel simulation. The update() member is used to synchronize the contents of the solution and current_local_solution vectors.

Definition at line 1679 of file system.h.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::UniformRefinementEstimator::_estimate_error(), alternative_fe_assembly(), libMesh::NonlinearImplicitSystem::assembly(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), FETest< order, family, elem_type, CaseName >::checkGradU(), FETest< order, family, elem_type, CaseName >::checkU(), libMesh::System::clear(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::System::current_solution(), DMlibMeshFunction(), DMlibMeshJacobian(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), fe_assembly(), libMesh::StaticCondensation::init(), libMesh::System::init_data(), libMesh::FEMContext::pre_fe_reinit(), libMesh::System::re_update(), libMesh::System::reinit(), libMesh::System::restrict_vectors(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), save_initial_mesh(), libMesh::RBConstruction::set_context_solution_vec(), libMesh::System::set_options_prefix(), setup(), MeshFunctionTest::test_bad_gradient_var_with_out_of_mesh_value(), MeshFunctionTest::test_bad_hessian_var_with_out_of_mesh_value(), MeshFunctionTest::test_subdomain_id_sets(), MeshInputTest::testCopyElementVectorImpl(), FETest< order, family, elem_type, CaseName >::testGradUComp(), FETest< order, family, elem_type, CaseName >::testHessU(), FETest< order, family, elem_type, CaseName >::testHessUComp(), SystemsTest::testPetscOptionsPrefix(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::TransientRBConstruction::truth_solve(), libMesh::System::update(), libMesh::Nemesis_IO_Helper::write_element_values(), and libMesh::Nemesis_IO_Helper::write_nodal_solution().

◆ deltat

Real libMesh::DifferentiableSystem::deltat
inherited

◆ extra_quadrature_order

int libMesh::System::extra_quadrature_order
inherited

A member int that can be employed to indicate increased or reduced quadrature order.

Note
For FEMSystem users, by default, when calling the user-defined residual functions, the FEMSystem will first set up an appropriate FEType::default_quadrature_rule() object for performing the integration. This rule will integrate elements of order up to 2*p+1 exactly (where p is the sum of the base FEType and local p refinement levels), but if additional (or reduced) quadrature accuracy is desired then this extra_quadrature_order (default 0) will be added.

Definition at line 1652 of file system.h.

Referenced by libMesh::JumpErrorEstimator::estimate_error(), CurlCurlSystem::init_data(), and set_system_parameters().

◆ fe_reinit_during_postprocess

bool libMesh::FEMSystem::fe_reinit_during_postprocess
inherited

If fe_reinit_during_postprocess is true (it is true by default), FE objects will be reinit()ed with their default quadrature rules.

If false, FE objects will need to be reinit()ed by the user or will be in an undefined state.

Definition at line 176 of file fem_system.h.

◆ linear_solver

std::unique_ptr<LinearSolver<Number> > libMesh::ImplicitSystem::linear_solver
mutableinherited

◆ matrix

SparseMatrix<Number>* libMesh::ImplicitSystem::matrix
inherited

The system matrix.

Implicit systems are characterized by the need to solve the linear system Ax=b. This is the system matrix A.

Public access to this member variable will be deprecated in the future! Use get_system_matrix() instead.

Definition at line 311 of file implicit_system.h.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), add_M_C_K_helmholtz(), libMesh::ImplicitSystem::add_matrices(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::ImplicitSystem::assemble(), assemble_func(), assemble_temperature_jump(), libMesh::FEMSystem::assembly(), libMesh::LinearImplicitSystem::assembly(), libMesh::NonlinearImplicitSystem::assembly(), libMesh::ImplicitSystem::clear(), libMesh::NewmarkSystem::compute_matrix(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::ContinuationSystem::continuation_solve(), libMesh::ImplicitSystem::create_static_condensation_system_matrix(), DMCreateMatrix_libMesh(), DMlibMeshJacobian(), libMesh::RBConstruction::enrich_basis_from_rhs_terms(), fill_dirichlet_bc(), libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity(), libMesh::ImplicitSystem::get_system_matrix(), libMesh::ImplicitSystem::get_system_matrix(), main(), periodic_bc_test_poisson(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::EigenTimeSolver::solve(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::NonlinearImplicitSystem::solve(), libMesh::FrequencySystem::solve(), libMesh::NoxNonlinearSolver< T >::solve(), libMesh::ClawSystem::solve_conservation_law(), libMesh::ContinuationSystem::solve_tangent(), NonlinearImplicitSystemOperatorMatrixTest::testDefaultUsesSingleMatrixSolve(), NonlinearImplicitSystemOperatorMatrixTest::testOperatorMatrixUsesTwoMatrixSolve(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_solve(), libMesh::TransientRBConstruction::truth_solve(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), and libMesh::ImplicitSystem::weighted_sensitivity_solve().

◆ numerical_jacobian_h

Real libMesh::FEMSystem::numerical_jacobian_h
inherited

If calculating numeric jacobians is required, the FEMSystem will perturb each solution vector entry by numerical_jacobian_h when calculating finite differences.

This defaults to the libMesh TOLERANCE but can be set manually.

For ALE terms, the FEMSystem will perturb each mesh point in an element by numerical_jacobian_h * Elem::hmin()

Definition at line 187 of file fem_system.h.

Referenced by libMesh::FEMSystem::numerical_jacobian(), libMesh::FEMSystem::numerical_jacobian_h_for_var(), and set_system_parameters().

◆ parameters

Parameters libMesh::System::parameters
inherited

◆ postprocess_sides

bool libMesh::DifferentiableSystem::postprocess_sides
inherited

If postprocess_sides is true (it is false by default), the postprocessing loop will loop over all sides as well as all elements.

Definition at line 326 of file diff_system.h.

Referenced by main().

◆ print_element_jacobians

bool libMesh::DifferentiableSystem::print_element_jacobians
inherited

Set print_element_jacobians to true to print each J_elem contribution.

Definition at line 373 of file diff_system.h.

Referenced by NavierSystem::init_data(), CurlCurlSystem::init_data(), main(), and set_system_parameters().

◆ print_element_residuals

bool libMesh::DifferentiableSystem::print_element_residuals
inherited

Set print_element_residuals to true to print each R_elem contribution.

Definition at line 368 of file diff_system.h.

Referenced by main(), and set_system_parameters().

◆ print_element_solutions

bool libMesh::DifferentiableSystem::print_element_solutions
inherited

Set print_element_solutions to true to print each U_elem input.

Definition at line 363 of file diff_system.h.

Referenced by main().

◆ print_jacobian_norms

bool libMesh::DifferentiableSystem::print_jacobian_norms
inherited

Set print_jacobian_norms to true to print |J| whenever it is assembled.

Definition at line 353 of file diff_system.h.

Referenced by libMesh::FEMSystem::assembly(), main(), set_system_parameters(), set_system_parameters(), and set_system_parameters().

◆ print_jacobians

bool libMesh::DifferentiableSystem::print_jacobians
inherited

Set print_jacobians to true to print J whenever it is assembled.

Definition at line 358 of file diff_system.h.

Referenced by libMesh::FEMSystem::assembly(), NavierSystem::init_data(), CurlCurlSystem::init_data(), main(), set_system_parameters(), set_system_parameters(), and set_system_parameters().

◆ print_residual_norms

bool libMesh::DifferentiableSystem::print_residual_norms
inherited

Set print_residual_norms to true to print |F| whenever it is assembled.

Definition at line 343 of file diff_system.h.

Referenced by libMesh::FEMSystem::assembly(), main(), set_system_parameters(), set_system_parameters(), and set_system_parameters().

◆ print_residuals

bool libMesh::DifferentiableSystem::print_residuals
inherited

Set print_residuals to true to print F whenever it is assembled.

Definition at line 348 of file diff_system.h.

Referenced by libMesh::FEMSystem::assembly(), main(), set_system_parameters(), set_system_parameters(), and set_system_parameters().

◆ print_solution_norms

bool libMesh::DifferentiableSystem::print_solution_norms
inherited

Set print_residual_norms to true to print |U| whenever it is used in an assembly() call.

Definition at line 332 of file diff_system.h.

Referenced by libMesh::FEMSystem::assembly(), main(), set_system_parameters(), set_system_parameters(), and set_system_parameters().

◆ print_solutions

bool libMesh::DifferentiableSystem::print_solutions
inherited

Set print_solutions to true to print U whenever it is used in an assembly() call.

Definition at line 338 of file diff_system.h.

Referenced by libMesh::FEMSystem::assembly(), main(), set_system_parameters(), set_system_parameters(), and set_system_parameters().

◆ project_with_constraints

bool libMesh::System::project_with_constraints
privateinherited

Do we want to apply constraints while projecting vectors ?

Definition at line 2369 of file system.h.

Referenced by libMesh::System::get_project_with_constraints(), and libMesh::System::set_project_with_constraints().

◆ rhs

NumericVector<Number>* libMesh::ExplicitSystem::rhs
inherited

The system matrix.

Implicit systems are characterized by the need to solve the linear system Ax=b. This is the right-hand-side vector b.

Definition at line 124 of file explicit_system.h.

Referenced by libMesh::__libmesh_petsc_diff_solver_residual(), add_M_C_K_helmholtz(), libMesh::ExplicitSystem::add_system_rhs(), LinearElasticity::assemble(), libMesh::ImplicitSystem::assemble(), assemble(), assemble(), assemble_1D(), assemble_biharmonic(), libMesh::AdvectionSystem::assemble_claw_rhs(), assemble_divgrad(), assemble_elasticity(), assemble_ellipticdg(), assemble_func(), assemble_graddiv(), assemble_laplace(), assemble_matrix_and_rhs(), assemble_poisson(), assemble_poisson(), libMesh::ImplicitSystem::assemble_residual_derivatives(), assemble_shell(), assemble_shell(), assemble_stokes(), assemble_temperature_jump(), assemble_wave(), libMesh::FEMSystem::assembly(), libMesh::LinearImplicitSystem::assembly(), libMesh::NonlinearImplicitSystem::assembly(), assembly_with_dg_fem_context(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::ContinuationSystem::continuation_solve(), DMlibMeshFunction(), libMesh::RBConstruction::enrich_basis_from_rhs_terms(), fill_dirichlet_bc(), libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity(), libMesh::NewtonSolver::line_search(), periodic_bc_test_poisson(), HeatSystem::perturb_accumulate_residuals(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::NonlinearImplicitSystem::solve(), libMesh::FrequencySystem::solve(), libMesh::ContinuationSystem::solve_tangent(), SystemsTest::testPetscOptionsPrefix(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_solve(), libMesh::TransientRBConstruction::truth_solve(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::NewmarkSystem::update_rhs(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), and libMesh::ImplicitSystem::weighted_sensitivity_solve().

◆ solution

std::unique_ptr<NumericVector<Number> > libMesh::System::solution
inherited

Data structure to hold solution values.

Definition at line 1667 of file system.h.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::NewmarkSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::ContinuationSystem::apply_predictor(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::FEMSystem::assembly(), libMesh::LinearImplicitSystem::assembly(), libMesh::VariationalSmootherSystem::assembly(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::RBConstruction::check_if_zero_truth_solve(), libMesh::System::clear(), libMesh::System::compare(), compute_enriched_soln(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::NewmarkSolver::compute_initial_accel(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), LinearElasticity::compute_stresses(), LargeDeformationElasticity::compute_stresses(), LinearElasticityWithContact::compute_stresses(), compute_stresses(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ContinuationSystem::continuation_solve(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_elemental_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::Nemesis_IO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), create_wrapped_function(), DMCreateGlobalVector_libMesh(), DMlibMeshFunction(), DMlibMeshJacobian(), libMesh::UnsteadySolver::du(), libMesh::RBConstruction::enrich_RB_space(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::SmoothnessEstimator::estimate_smoothness(), libMesh::RBSCMConstruction::evaluate_stability_constant(), libMesh::EigenSystem::get_eigenpair(), libMesh::CondensedEigenSystem::get_eigenpair(), LinearElasticityWithContact::get_least_and_max_gap_function(), libMesh::System::init_data(), libMesh::ContinuationSystem::initialize_tangent(), libMesh::TransientRBConstruction::initialize_truth(), libMesh::RBConstruction::load_basis_function(), libMesh::RBConstruction::load_rb_solution(), libMesh::TransientRBConstruction::load_rb_solution(), main(), libMesh::DofMap::max_constraint_error(), libMesh::FEMSystem::mesh_position_get(), libMesh::ErrorVector::plot_error(), libMesh::RBConstruction::print_basis_function_orthogonality(), libMesh::InterMeshProjection::project_system_vectors(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), libMesh::System::re_update(), libMesh::System::read_parallel_data(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::System::read_serialized_data(), MeshFunctionTest::read_variable_info_from_output_data(), libMesh::System::reinit(), libMesh::System::restrict_vectors(), libMesh::MemoryHistoryData::retrieve_vectors(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), libMesh::ContinuationSystem::save_current_solution(), libMesh::TransientRBConstruction::set_error_temporal_data(), libMesh::System::set_options_prefix(), ParsedFEMFunctionTest::setUp(), setup(), WriteVecAndScalar::setupTests(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::TwostepTimeSolver::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::NonlinearImplicitSystem::solve(), libMesh::FrequencySystem::solve(), libMesh::ClawSystem::solve_conservation_law(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), libMesh::ContinuationSystem::solve_tangent(), libMesh::MemoryHistoryData::store_vectors(), ConstraintOperatorTest::test1DCoarseningOperator(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), ProjectSolutionTest::test_partial_project_solution(), SystemsTest::testBoundaryProjectCube(), ConstraintOperatorTest::testCoreform(), SystemsTest::testDofCouplingWithVarGroups(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), HeterogeneousNonlinearConstraintTest::testNonzeroDirichletValues(), SystemsTest::testPetscOptionsPrefix(), SystemsTest::testPostInitAddVector(), SystemsTest::testProjectCubeWithMeshFunction(), MeshInputTest::testProjectionRegression(), SystemsTest::testProjectScalarCoarsening(), WriteVecAndScalar::testSolution(), libMesh::RBConstruction::train_reduced_basis_with_POD(), libMesh::DirectSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::BoundaryVolumeSolutionTransfer::transfer_volume_boundary(), libMesh::RBConstruction::truth_solve(), libMesh::TransientRBConstruction::truth_solve(), libMesh::System::update(), update_current_local_solution(), libMesh::System::update_global_solution(), libMesh::System::update_global_solution(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::ContinuationSystem::update_solution(), libMesh::NewmarkSystem::update_u_v_a(), libMesh::DTKAdapter::update_variable_values(), libMesh::Nemesis_IO_Helper::write_nodal_solution(), libMesh::System::write_parallel_data(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::TransientRBConstruction::write_riesz_representors_to_files(), and libMesh::System::write_serialized_data().

◆ time

Real libMesh::System::time
inherited

For time-dependent problems, this is the time t at the beginning of the current timestep.

Note
For DifferentiableSystem users: do not access this time during an assembly! Use the DiffContext::time value instead to get correct results.

Definition at line 1689 of file system.h.

Referenced by libMesh::AdaptiveTimeSolver::adjoint_advance_timestep(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::TwostepTimeSolver::adjoint_solve(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubProjector::construct_projection(), HeatSystem::element_qoi(), fill_dirichlet_bc(), libMesh::ExactErrorEstimator::find_squared_element_error(), initialize(), libMesh::Euler2Solver::integrate_adjoint_refinement_error_estimate(), libMesh::EulerSolver::integrate_adjoint_refinement_error_estimate(), libMesh::UnsteadySolver::integrate_adjoint_sensitivity(), libMesh::Euler2Solver::integrate_qoi_timestep(), libMesh::EulerSolver::integrate_qoi_timestep(), main(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectInteriors::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectEdges::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectSides::operator()(), libMesh::System::reinit_constraints(), libMesh::System::reinit_dirichlet_constraint_values(), libMesh::UnsteadySolver::retrieve_timestep(), and libMesh::TwostepTimeSolver::solve().

◆ time_solver

std::unique_ptr<TimeSolver> libMesh::DifferentiableSystem::time_solver
inherited

◆ undefo_var

unsigned int SolidSystem::undefo_var[3]

◆ use_fixed_solution

bool libMesh::System::use_fixed_solution
inherited

A boolean to be set to true by systems using elem_fixed_solution, for optional use by e.g.

stabilized methods. False by default.

Note
For FEMSystem users, if this variable is set to true, it must be before init_data() is called.

Definition at line 1637 of file system.h.

Referenced by libMesh::NewmarkSolver::_general_residual(), libMesh::Euler2Solver::_general_residual(), libMesh::EulerSolver::_general_residual(), libMesh::SteadySolver::_general_residual(), libMesh::DifferentiableSystem::clear(), libMesh::DiffContext::DiffContext(), and libMesh::FEMContext::pre_fe_reinit().

◆ var

unsigned int SolidSystem::var[3]

◆ verify_analytic_jacobians

Real libMesh::FEMSystem::verify_analytic_jacobians
inherited

If verify_analytic_jacobian is equal to zero (as it is by default), no numeric jacobians will be calculated unless an overridden element_time_derivative(), element_constraint(), side_time_derivative(), or side_constraint() function cannot provide an analytic jacobian upon request.

If verify_analytic_jacobian is equal to the positive value tol, then any time a full analytic element jacobian can be calculated it will be tested against a numerical jacobian on the same element, and the program will abort if the relative error (in matrix l1 norms) exceeds tol.

Definition at line 215 of file fem_system.h.

Referenced by libMesh::FEMSystem::assembly(), CoupledSystem::init_data(), NavierSystem::init_data(), CurlCurlSystem::init_data(), set_system_parameters(), set_system_parameters(), and set_system_parameters().

◆ zero_out_matrix_and_rhs

bool libMesh::ImplicitSystem::zero_out_matrix_and_rhs
inherited

By default, the system will zero out the matrix and the right hand side.

If this flag is false, it is the responsibility of the client code to take care of setting these to zero before assembly begins

Definition at line 318 of file implicit_system.h.

Referenced by libMesh::ImplicitSystem::assemble().


The documentation for this class was generated from the following files: