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
PoissonSystem Class Reference

#include <poisson.h>

Inheritance diagram for PoissonSystem:
[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

 PoissonSystem (EquationSystems &es, const std::string &name_in, const unsigned int number_in)
 
std::string & fe_family ()
 
unsigned intfe_order ()
 
bool & analytic_jacobians ()
 
virtual void postprocess (void)
 Runs a postprocessing loop over all elements, and if postprocess_sides is true over all sides.
 
Numberget_QoI_value (std::string type, unsigned int QoI_index)
 
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< DiffContextbuild_context () override
 Builds a FEMContext object with enough information to do evaluations on each element.
 
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, Realget_linear_solve_parameters () const override
 
virtual std::pair< unsigned int, Realadjoint_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< DifferentiablePhysicsclone_physics () override
 We don't allow systems to be attached to each other.
 
virtual std::unique_ptr< DifferentiableQoIclone () override
 We don't allow systems to be attached to each other.
 
const DifferentiablePhysicsget_physics () const
 
DifferentiablePhysicsget_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 DifferentiableQoIget_qoi () const
 
DifferentiableQoIget_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.
 
TimeSolverget_time_solver ()
 
const TimeSolverget_time_solver () const
 Non-const version of the above.
 
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_typesystem ()
 
virtual void disable_cache () override
 Avoids use of any cached data that might affect any solve result.
 
virtual std::string system_type () const override
 
virtual void assemble_residual_derivatives (const ParameterVector &parameters) override
 Residual parameter derivative function.
 
virtual std::pair< unsigned int, Realsensitivity_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, Realweighted_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, Realweighted_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.
 
StaticCondensationget_static_condensation ()
 
void init ()
 Initializes degrees of freedom on the current mesh.
 
virtual void reinit_constraints ()
 Reinitializes the constraints for this system.
 
virtual void reinit_mesh ()
 Reinitializes the system with a new mesh.
 
bool is_initialized () const
 
virtual void update ()
 Update the local values to reflect the solution on neighboring processors.
 
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 MeshBaseget_mesh () const
 
MeshBaseget_mesh ()
 
const DofMapget_dof_map () const
 
DofMapget_dof_map ()
 
const EquationSystemsget_equation_systems () const
 
EquationSystemsget_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 Variablevariable (unsigned int var) const
 Return a constant reference to Variable var.
 
const VariableGroupvariable_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 FETypevariable_type (const unsigned int i) const
 
const FETypevariable_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
 
Constraintget_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< Numberget_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
 
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_time_derivative (bool request_jacobian, DiffContext &)
 Adds the time derivative contribution on side of 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 eulerian_residual (bool request_jacobian, DiffContext &)
 Adds a pseudo-convection contribution on elem to elem_residual, if the nodes of elem are being translated by a moving mesh.
 
virtual bool eulerian_residual (bool request_jacobian, DiffContext &context) override
 Adds a pseudo-convection contribution on elem to elem_residual, if the nodes of elem are being translated by a moving mesh.
 
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 Systemget_mesh_system () const
 
Systemget_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

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< TimeSolvertime_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

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)
 Adds the time derivative contribution on elem to elem_residual.
 
virtual void element_postprocess (DiffContext &context)
 Does any work that needs to be done on elem in a postprocessing loop.
 
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

Real alpha
 
unsigned int T_var
 
Number computed_QoI [1]
 
Number exact_QoI [1]
 
std::string _fe_family
 
unsigned int _fe_order
 
bool _analytic_jacobians
 
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::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 11 of file poisson.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 830 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 804 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 555 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 829 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 551 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 803 of file system.h.

Constructor & Destructor Documentation

◆ PoissonSystem()

PoissonSystem::PoissonSystem ( EquationSystems es,
const std::string &  name_in,
const unsigned int  number_in 
)
inline

Definition at line 14 of file poisson.h.

17 : FEMSystem(es, name_in, number_in),
18 _fe_family("LAGRANGE"), _fe_order(2),
19 _analytic_jacobians(true) { this->init_qois(1); computed_QoI[0] = 0.0; }
bool _analytic_jacobians
Definition poisson.h:76
unsigned int _fe_order
Definition poisson.h:73
std::string _fe_family
Definition poisson.h:72
Number computed_QoI[1]
Definition poisson.h:65
This class provides a specific system class.
Definition fem_system.h:55
void init_qois(unsigned int n_qois)
Accessors for qoi and qoi_error_estimates vectors.
Definition system.C:2169

References computed_QoI, and libMesh::System::init_qois().

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 2441 of file system.h.

2442{
2443 _active = true;
2444}
bool _active
Flag stating if the system is active or not.
Definition system.h:2252

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 2433 of file system.h.

2434{
2435 return _active;
2436}

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 1284 of file system.C.

1285{
1286 std::ostringstream adjoint_rhs_name;
1287 adjoint_rhs_name << "adjoint_rhs" << i;
1288
1289 return this->add_vector(adjoint_rhs_name.str(), false);
1290}
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:756

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 1220 of file system.C.

1221{
1222 std::ostringstream adjoint_name;
1223 adjoint_name << "adjoint_solution" << i;
1224
1225 NumericVector<Number> & returnval = this->add_vector(adjoint_name.str());
1226 this->set_vector_as_adjoint(adjoint_name.str(), i);
1227 return returnval;
1228}
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:1147
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:1636
const DofMap & get_dof_map() const
Definition system.h:2417
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:998
unsigned int n_matrices() const
Definition system.h:2638
virtual void add_matrices()
Insertion point for adding matrices in derived classes before init_matrices() is called.
Definition system.h:2017

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 998 of file system.C.

1001{
1002 parallel_object_only();
1003
1004 libmesh_assert(this->comm().verify(std::string(mat_name)));
1005 libmesh_assert(this->comm().verify(int(type)));
1006 libmesh_assert(this->comm().verify(int(mat_build_type)));
1007
1008 // Return the matrix if it is already there.
1009 if (auto it = this->_matrices.find(mat_name);
1010 it != this->_matrices.end())
1011 return *it->second;
1012
1013 // Otherwise build the matrix to return.
1014 std::unique_ptr<SparseMatrix<Number>> matrix;
1015 if (this->has_static_condensation())
1016 {
1017 if (mat_build_type == MatrixBuildType::DIAGONAL)
1018 libmesh_error_msg(
1019 "We do not currently support static condensation of the diagonal matrix type");
1020 matrix = std::make_unique<StaticCondensation>(this->get_mesh(),
1021 *this,
1022 this->get_dof_map(),
1023 this->get_dof_map().get_static_condensation());
1024 }
1025 else
1027 auto & mat = *matrix;
1028
1029 _matrices.emplace(mat_name, std::move(matrix));
1030
1031 _matrix_types.emplace(mat_name, type);
1032
1033 // Initialize it first if we've already initialized the others.
1034 this->late_matrix_init(mat, type);
1035
1036 return mat;
1037}
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:2277
bool has_static_condensation() const
Definition system.C:2669
std::map< std::string, ParallelType, std::less<> > _matrix_types
Holds the types of the matrices.
Definition system.h:2282
void late_matrix_init(SparseMatrix< Number > &mat, ParallelType type)
Helper function to keep DofMap forward declarable in system.h.
Definition system.C:1063
const MeshBase & get_mesh() const
Definition system.h:2401
SolverPackage default_solver_package()
Definition libmesh.C:1064

References libMesh::System::_matrices, libMesh::System::_matrix_types, 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(), and libMesh::NewmarkSystem::NewmarkSystem().

◆ 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 2646 of file system.h.

2648{
2649 // Return the matrix if it is already there.
2650 auto it = this->_matrices.find(mat_name);
2651 if (it != this->_matrices.end())
2652 return *it->second;
2653
2654 // Otherwise build the matrix to return.
2655 auto pr = _matrices.emplace(mat_name, std::make_unique<MatrixType<Number>>(this->comm()));
2656 _matrix_types.emplace(mat_name, type);
2657
2658 SparseMatrix<Number> & mat = *(pr.first->second);
2659
2660 // Initialize it first if we've already initialized the others.
2661 this->late_matrix_init(mat, type);
2662
2663 return mat;
2664}
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 1041 of file system.C.

1044{
1045 parallel_object_only();
1046
1047 const std::string namestr{mat_name};
1048
1049 libmesh_assert(this->comm().verify(namestr));
1050 libmesh_assert(this->comm().verify(int(type)));
1051
1052 SparseMatrix<Number> & mat = *matrix;
1053
1054 _matrices[namestr] = std::move(matrix);
1055 _matrix_types[namestr] = type;
1056
1057 // Initialize it first if we've already initialized the others.
1058 this->late_matrix_init(mat, type);
1059
1060 return mat;
1061}

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

◆ 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:2704
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:1344

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 1314 of file system.C.

1315{
1316 std::ostringstream sensitivity_rhs_name;
1317 sensitivity_rhs_name << "sensitivity_rhs" << i;
1318
1319 return this->add_vector(sensitivity_rhs_name.str(), false);
1320}

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 1169 of file system.C.

1170{
1171 std::ostringstream sensitivity_name;
1172 sensitivity_name << "sensitivity_solution" << i;
1173
1174 return this->add_vector(sensitivity_name.str());
1175}

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:2499

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 1344 of file system.C.

1347{
1348 return this->get_dof_map().add_variable(*this, var, type, active_subdomains);
1349}
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:3146

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(), OverlappingTestBase::init(), LaplaceSystem::init_data(), CoupledSystem::init_data(), HeatSystem::init_data(), init_data(), NavierSystem::init_data(), SolidSystem::init_data(), ElasticitySystem::init_data(), SimpleRBConstruction::init_data(), SimpleEIMConstruction::init_data(), ElasticityRBConstruction::init_data(), CurlCurlSystem::init_data(), HilbertSystem::init_data(), libMesh::AdvectionSystem::init_data(), libMesh::VariationalSmootherSystem::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(), 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(), DofMapTest::testConstraintLoopDetection(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testCopyNodalSolutionImpl(), ConstraintOperatorTest::testCoreform(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), SystemsTest::testDofCouplingWithVarGroups(), DofMapTest::testDofOwner(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), SystemsTest::testFirstScalarNumber(), MeshAssignTest::testMeshMoveAssign(), PeriodicBCTest::testPeriodicBC(), EquationSystemsTest::testPostInitAddElem(), EquationSystemsTest::testPostInitAddRealSystem(), SystemsTest::testProjectCubeWithMeshFunction(), MeshInputTest::testProjectionRegression(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), SystemsTest::testProjectScalarCoarsening(), InfFERadialTest::testRefinement(), EquationSystemsTest::testRefineThenReinitPreserveFlags(), EquationSystemsTest::testReinitWithNodeElem(), EquationSystemsTest::testRepartitionThenReinit(), EquationSystemsTest::testSelectivePRefine(), SystemsTest::testSetSystemParameterOverEquationSystem(), BoundaryInfoTest::testShellFaceConstraints(), MeshInputTest::testSingleElementImpl(), 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 1353 of file system.C.

1358{
1359 return this->add_variable(var,
1360 FEType(order, family).set_p_refinement(p_refinement),
1361 active_subdomains);
1362}

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 1386 of file system.C.

1389{
1390 return this->get_dof_map().add_variable_array(*this, vars, type, active_subdomains);
1391}
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:3377

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 1366 of file system.C.

1369{
1370 return this->get_dof_map().add_variables(*this, vars, type, active_subdomains);
1371}
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:3253

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 1375 of file system.C.

1380{
1381 return this->add_variables(vars,
1382 FEType(order, family).set_p_refinement(p_refinement),
1383 active_subdomains);
1384}
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:1366

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 756 of file system.C.

759{
760 parallel_object_only();
761
762 libmesh_assert(this->comm().verify(std::string(vec_name)));
763 libmesh_assert(this->comm().verify(int(type)));
764 libmesh_assert(this->comm().verify(projections));
765
766 // Return the vector if it is already there.
767 if (auto it = this->_vectors.find(vec_name);
768 it != this->_vectors.end())
769 {
770 // If the projection setting has *upgraded*, change it.
771 if (projections) // only do expensive lookup if needed
772 libmesh_map_find(_vector_projections, vec_name) = projections;
773
774 NumericVector<Number> & vec = *it->second;
775
776 // If we're in serial, our vectors are effectively SERIAL, so
777 // we'll ignore any type setting. If we're in parallel, we
778 // might have a type change to deal with.
779
780 if (this->n_processors() > 1)
781 {
782 // If the type setting has changed in a way we can't
783 // perceive as an upgrade or a downgrade, scream.
784 libmesh_assert_equal_to(type == SERIAL,
785 vec.type() == SERIAL);
786
787 // If the type setting has *upgraded*, change it.
788 if (type == GHOSTED && vec.type() == PARALLEL)
789 {
790 // A *really* late upgrade is expensive, but better not
791 // to risk zeroing data.
792 if (vec.initialized())
793 {
794 if (!vec.closed())
795 vec.close();
796
797 // Ideally we'd move parallel coefficients and then
798 // add ghosted coefficients, but copy and swap is
799 // simpler. If anyone actually ever uses this case
800 // for real we can look into optimizing it.
801 auto new_vec = NumericVector<Number>::build(this->comm());
802#ifdef LIBMESH_ENABLE_GHOSTED
803 new_vec->init (this->n_dofs(), this->n_local_dofs(),
804 _dof_map->get_send_list(), /*fast=*/false,
805 GHOSTED);
806#else
807 libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
808#endif
809
810 *new_vec = vec;
811 vec.swap(*new_vec);
812 }
813 else
814 // The PARALLEL vec is not yet initialized, so we can
815 // just "upgrade" it to GHOSTED.
816 vec.set_type(type);
817 }
818 }
819
820 // Any upgrades are done; we're happy here.
821 return vec;
822 }
823
824 // Otherwise, build the vector. The following emplace() is
825 // guaranteed to succeed because, if we made it here, we don't
826 // already have a vector named "vec_name". We pass the user's
827 // requested ParallelType directly to NumericVector::build() so
828 // that, even if the vector is not initialized now, it will get the
829 // right type when it is initialized later.
830 auto pr =
831 _vectors.emplace(vec_name,
832 NumericVector<Number>::build(this->comm(),
834 type));
835 auto buf = pr.first->second.get();
836 _vector_projections.emplace(vec_name, projections);
837
838 // Vectors are primal by default
839 _vector_is_adjoint.emplace(vec_name, -1);
840
841 // Initialize it if necessary
842 if (_is_initialized)
843 {
844 if (type == GHOSTED)
845 {
846#ifdef LIBMESH_ENABLE_GHOSTED
847 buf->init (this->n_dofs(), this->n_local_dofs(),
848 _dof_map->get_send_list(), /*fast=*/false,
849 GHOSTED);
850#else
851 libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
852#endif
853 }
854 else
855 buf->init (this->n_dofs(), this->n_local_dofs(), false, type);
856 }
857
858 return *buf;
859}
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:2272
bool _is_initialized
true when additional vectors and variables do not require immediate initialization,...
Definition system.h:2306
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition system.h:2260
dof_id_type n_dofs() const
Definition system.C:118
dof_id_type n_local_dofs() const
Definition system.C:155
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:2266
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc... and degrees of freedom.
Definition system.h:2225

References libMesh::System::_dof_map, libMesh::System::_is_initialized, 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::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 1252 of file system.C.

1253{
1254 std::ostringstream adjoint_name;
1255 adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1256
1257 NumericVector<Number> & returnval = this->add_vector(adjoint_name.str());
1258 this->set_vector_as_adjoint(adjoint_name.str(), i);
1259 return returnval;
1260}

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 1199 of file system.C.

1200{
1201 return this->add_vector("weighted_sensitivity_solution");
1202}

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:2191
unsigned int n_qois() const
Number of currently active quantities of interest.
Definition system.h:2562
NumericVector< Number > & get_sensitivity_rhs(unsigned int i=0)
Definition system.C:1324
bool is_adjoint_already_solved() const
Accessor for the adjoint_already_solved boolean.
Definition system.h:411
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}
std::unique_ptr< TimeSolver > time_solver
A pointer to the solver object we're going to use.
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().

◆ analytic_jacobians()

bool & PoissonSystem::analytic_jacobians ( )
inline

Definition at line 23 of file poisson.h.

23{ return _analytic_jacobians; }

References _analytic_jacobians.

Referenced by set_system_parameters().

◆ 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 1140 of file fem_system.C.

1141{
1142 LOG_SCOPE("assemble_qoi()", "FEMSystem");
1143
1144 const MeshBase & mesh = this->get_mesh();
1145
1146 this->update();
1147
1148 const unsigned int Nq = this->n_qois();
1149
1150 // the quantity of interest is assumed to be a sum of element and
1151 // side terms
1152 for (unsigned int i=0; i != Nq; ++i)
1153 if (qoi_indices.has_index(i))
1154 this->set_qoi(i, 0);
1155
1156 // Create a non-temporary qoi_contributions object, so we can query
1157 // its results after the reduction
1158 QoIContributions qoi_contributions(*this, *(this->get_qoi()), qoi_indices);
1159
1160 // Loop over every active mesh element on this processor
1162 qoi_contributions);
1163
1164 std::vector<Number> global_qoi = this->get_qoi_values();
1165 this->get_qoi()->parallel_op( this->comm(), global_qoi, qoi_contributions.qoi, qoi_indices );
1166 this->set_qoi(std::move(global_qoi));
1167}
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
const ConstElemRange & active_local_element_stored_range() const
Definition mesh_base.C:1954
void set_qoi(unsigned int qoi_index, Number qoi_value)
Definition system.C:2176
virtual void update()
Update the local values to reflect the solution on neighboring processors.
Definition system.C:498
MeshBase & mesh
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(), 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 1171 of file fem_system.C.

1174{
1175 LOG_SCOPE("assemble_qoi_derivative()", "FEMSystem");
1176
1177 const MeshBase & mesh = this->get_mesh();
1178
1179 this->update();
1180
1181 // The quantity of interest derivative assembly accumulates on
1182 // initially zero vectors
1183 for (auto i : make_range(this->n_qois()))
1184 if (qoi_indices.has_index(i))
1185 this->add_adjoint_rhs(i).zero();
1186
1187 // Loop over every active mesh element on this processor
1189 QoIDerivativeContributions(*this, qoi_indices,
1190 *(this->get_qoi()),
1191 include_liftfunc,
1192 apply_constraints));
1193
1194 for (auto i : make_range(this->n_qois()))
1195 if (qoi_indices.has_index(i))
1196 this->get_qoi()->finalize_derivative(this->get_adjoint_rhs(i),i);
1197}
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:1284
NumericVector< Number > & get_adjoint_rhs(unsigned int i=0)
Definition system.C:1294
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::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:1314

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 875 of file fem_system.C.

878{
879 libmesh_assert(get_residual || get_jacobian);
880
881 // Log residual and jacobian and combined performance separately
882#ifdef LIBMESH_ENABLE_PERFORMANCE_LOGGING
883 const char * log_name;
884 if (get_residual && get_jacobian)
885 log_name = "assembly()";
886 else if (get_residual)
887 log_name = "assembly(get_residual)";
888 else
889 log_name = "assembly(get_jacobian)";
890
891 LOG_SCOPE(log_name, "FEMSystem");
892#endif
893
894 const MeshBase & mesh = this->get_mesh();
895
897 {
898 this->solution->close();
899
900 std::streamsize old_precision = libMesh::out.precision();
902 libMesh::out << "|U| = "
903 << this->solution->l1_norm()
904 << std::endl;
905 libMesh::out.precision(old_precision);
906 }
907 if (print_solutions)
908 {
909 std::streamsize old_precision = libMesh::out.precision();
911 libMesh::out << "U = [" << *(this->solution)
912 << "];" << std::endl;
913 libMesh::out.precision(old_precision);
914 }
915
916 // Is this definitely necessary? [RHS]
917 // Yes. [RHS 2012]
918 if (get_jacobian)
919 matrix->zero();
920 if (get_residual)
921 rhs->zero();
922
923 // Stupid C++ lets you set *Real* verify_analytic_jacobians = true!
925 {
926 libMesh::err << "WARNING! verify_analytic_jacobians was set "
927 << "to absurdly large value of "
928 << verify_analytic_jacobians << std::endl;
929 libMesh::err << "Resetting to 1e-6!" << std::endl;
931 }
932
933 // In time-dependent problems, the nonlinear function we're trying
934 // to solve at each timestep may depend on the particular solver
935 // we're using
937
938 // Build the residual and jacobian contributions on every active
939 // mesh element on this processor
942 AssemblyContributions(*this, get_residual, get_jacobian,
943 apply_heterogeneous_constraints,
944 apply_no_constraints));
945
946 // Check and see if we have SCALAR variables
947 bool have_scalar = false;
948 for (auto i : make_range(this->n_variable_groups()))
949 {
950 if (this->variable_group(i).type().family == SCALAR)
951 {
952 have_scalar = true;
953 break;
954 }
955 }
956
957 // SCALAR dofs are stored on the last processor, so we'll evaluate
958 // their equation terms there and only if we have a SCALAR variable
959 if (this->processor_id() == (this->n_processors()-1) && have_scalar)
960 {
961 std::unique_ptr<DiffContext> con = this->build_context();
962 FEMContext & _femcontext = cast_ref<FEMContext &>(*con);
963 this->init_context(_femcontext);
964 _femcontext.pre_fe_reinit(*this, nullptr);
965
966 bool jacobian_computed =
967 this->time_solver->nonlocal_residual(get_jacobian, _femcontext);
968
969 // Nonlocal residuals are likely to be length 0, in which case we
970 // don't need to do any more. And we shouldn't try to do any
971 // more; lots of DenseVector/DenseMatrix code assumes rank>0.
972 if (_femcontext.get_elem_residual().size())
973 {
974 // Compute a numeric jacobian if we have to
975 if (get_jacobian && !jacobian_computed)
976 {
977 // Make sure we didn't compute a jacobian and lie about it
978 libmesh_assert_equal_to (_femcontext.get_elem_jacobian().l1_norm(), 0.0);
979 // Logging of numerical jacobians is done separately
980 this->numerical_nonlocal_jacobian(_femcontext);
981 }
982
983 // Compute a numeric jacobian if we're asked to verify the
984 // analytic jacobian we got
985 if (get_jacobian && jacobian_computed &&
986 this->verify_analytic_jacobians != 0.0)
987 {
988 DenseMatrix<Number> analytic_jacobian(_femcontext.get_elem_jacobian());
989
990 _femcontext.get_elem_jacobian().zero();
991 // Logging of numerical jacobians is done separately
992 this->numerical_nonlocal_jacobian(_femcontext);
993
994 Real analytic_norm = analytic_jacobian.l1_norm();
995 Real numerical_norm = _femcontext.get_elem_jacobian().l1_norm();
996
997 // If we can continue, we'll probably prefer the analytic jacobian
998 analytic_jacobian.swap(_femcontext.get_elem_jacobian());
999
1000 // The matrix "analytic_jacobian" will now hold the error matrix
1001 analytic_jacobian.add(-1.0, _femcontext.get_elem_jacobian());
1002 Real error_norm = analytic_jacobian.l1_norm();
1003
1004 Real relative_error = error_norm /
1005 std::max(analytic_norm, numerical_norm);
1006
1007 if (relative_error > this->verify_analytic_jacobians)
1008 {
1009 libMesh::err << "Relative error " << relative_error
1010 << " detected in analytic jacobian on nonlocal dofs!"
1011 << std::endl;
1012
1013 std::streamsize old_precision = libMesh::out.precision();
1015 libMesh::out << "J_analytic nonlocal = "
1016 << _femcontext.get_elem_jacobian() << std::endl;
1017 analytic_jacobian.add(1.0, _femcontext.get_elem_jacobian());
1018 libMesh::out << "J_numeric nonlocal = "
1019 << analytic_jacobian << std::endl;
1020
1021 libMesh::out.precision(old_precision);
1022
1023 libmesh_error_msg("Relative error too large, exiting!");
1024 }
1025 }
1026
1027 add_element_system
1028 (*this, get_residual, get_jacobian,
1029 apply_heterogeneous_constraints, apply_no_constraints, _femcontext);
1030 }
1031 }
1032
1033 if (get_residual && (print_residual_norms || print_residuals))
1034 this->rhs->close();
1035 if (get_residual && print_residual_norms)
1036 {
1037 std::streamsize old_precision = libMesh::out.precision();
1039 libMesh::out << "|F| = " << this->rhs->l1_norm() << std::endl;
1040 libMesh::out.precision(old_precision);
1041 }
1042 if (get_residual && print_residuals)
1043 {
1044 std::streamsize old_precision = libMesh::out.precision();
1046 libMesh::out << "F = [" << *(this->rhs) << "];" << std::endl;
1047 libMesh::out.precision(old_precision);
1048 }
1049
1050 if (get_jacobian && (print_jacobian_norms || print_jacobians))
1051 this->matrix->close();
1052 if (get_jacobian && print_jacobian_norms)
1053 {
1054 std::streamsize old_precision = libMesh::out.precision();
1056 libMesh::out << "|J| = " << this->matrix->l1_norm() << std::endl;
1057 libMesh::out.precision(old_precision);
1058 }
1059 if (get_jacobian && print_jacobians)
1060 {
1061 std::streamsize old_precision = libMesh::out.precision();
1063 libMesh::out << "J = [" << *(this->matrix) << "];" << std::endl;
1064 libMesh::out.precision(old_precision);
1065 }
1066}
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:63
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:1655
const VariableGroup & variable_group(unsigned int vg) const
Return a constant reference to VariableGroup vg.
Definition system.C:2709
unsigned int n_variable_groups() const
Definition system.C:2699
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::DenseMatrix< T >::l1_norm(), libMesh::NumericVector< T >::l1_norm(), libMesh::SparseMatrix< T >::l1_norm(), libMesh::libmesh_assert(), 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::VariationalSmootherSystem::assembly(), 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 1959 of file system.C.

1961{
1963
1964 if (_assemble_system_object != nullptr)
1965 {
1966 libmesh_warning("WARNING: Cannot specify both assembly function and object!");
1967
1968 _assemble_system_object = nullptr;
1969 }
1970
1972}
Assembly * _assemble_system_object
Object that assembles the system.
Definition system.h:2182
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Function that assembles the system.
Definition system.h:2176
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 1976 of file system.C.

1977{
1978 if (_assemble_system_function != nullptr)
1979 {
1980 libmesh_warning("WARNING: Cannot specify both assembly object and function!");
1981
1982 _assemble_system_function = nullptr;
1983 }
1984
1985 _assemble_system_object = &assemble_in;
1986}

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 1990 of file system.C.

1992{
1994
1995 if (_constrain_system_object != nullptr)
1996 {
1997 libmesh_warning("WARNING: Cannot specify both constraint function and object!");
1998
1999 _constrain_system_object = nullptr;
2000 }
2001
2003}
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Function to impose constraints.
Definition system.h:2187
Constraint * _constrain_system_object
Object that constrains the system.
Definition system.h:2193

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 2007 of file system.C.

2008{
2009 if (_constrain_system_function != nullptr)
2010 {
2011 libmesh_warning("WARNING: Cannot specify both constraint object and function!");
2012
2014 }
2015
2016 _constrain_system_object = &constrain;
2017}

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

◆ 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 1928 of file system.C.

1930{
1932
1933 if (_init_system_object != nullptr)
1934 {
1935 libmesh_warning("WARNING: Cannot specify both initialization function and object!");
1936
1937 _init_system_object = nullptr;
1938 }
1939
1941}
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Function that initializes the system.
Definition system.h:2165
Initialization * _init_system_object
Object that initializes the system.
Definition system.h:2171

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 1945 of file system.C.

1946{
1947 if (_init_system_function != nullptr)
1948 {
1949 libmesh_warning("WARNING: Cannot specify both initialization object and function!");
1950
1951 _init_system_function = nullptr;
1952 }
1953
1954 _init_system_object = &init_in;
1955}

◆ 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 2064 of file system.C.

2066{
2068
2069 if (_qoi_evaluate_derivative_object != nullptr)
2070 {
2071 libmesh_warning("WARNING: Cannot specify both QOI derivative function and object!");
2072
2074 }
2075
2077}
QOIDerivative * _qoi_evaluate_derivative_object
Object to compute derivatives of quantities of interest.
Definition system.h:2219
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:2210

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 2081 of file system.C.

2082{
2083 if (_qoi_evaluate_derivative_function != nullptr)
2084 {
2085 libmesh_warning("WARNING: Cannot specify both QOI derivative object and function!");
2086
2088 }
2089
2090 _qoi_evaluate_derivative_object = &qoi_derivative;
2091}

◆ 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 2032 of file system.C.

2035{
2037
2038 if (_qoi_evaluate_object != nullptr)
2039 {
2040 libmesh_warning("WARNING: Cannot specify both QOI function and object!");
2041
2042 _qoi_evaluate_object = nullptr;
2043 }
2044
2046}
QOI * _qoi_evaluate_object
Object to compute quantities of interest.
Definition system.h:2205
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Function to evaluate quantity of interest.
Definition system.h:2198

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 2050 of file system.C.

2051{
2052 if (_qoi_evaluate_function != nullptr)
2053 {
2054 libmesh_warning("WARNING: Cannot specify both QOI object and function!");
2055
2056 _qoi_evaluate_function = nullptr;
2057 }
2058
2059 _qoi_evaluate_object = &qoi_in;
2060}

◆ 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 1306 of file system_projection.C.

1311{
1312 this->boundary_project_vector(b, variables, *solution, f, g, -1 /*is_adjoint*/, active_local_range);
1313
1314 solution->localize(*current_local_solution);
1315}
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:1667
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 1287 of file system_projection.C.

1294{
1295 WrappedFunction<Number> f(*this, fptr, &function_parameters);
1296 WrappedFunction<Gradient> g(*this, gptr, &function_parameters);
1297 this->boundary_project_solution(b, variables, &f, &g, active_local_range);
1298}
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 1344 of file system_projection.C.

1351{
1352 LOG_SCOPE ("boundary_project_vector()", "System");
1353
1354 if (!active_local_range)
1355 {
1356 active_local_range.emplace
1357 (this->get_mesh().active_local_elements_begin(),
1358 this->get_mesh().active_local_elements_end());
1359 }
1360
1362 (active_local_range.value(),
1363 BoundaryProjectSolution(b, variables, *this, f, g,
1365 new_vector)
1366 );
1367
1368 // We don't do SCALAR dofs when just projecting the boundary, so
1369 // we're done here.
1370
1371 new_vector.close();
1372
1373#ifdef LIBMESH_ENABLE_CONSTRAINTS
1374 if (is_adjoint == -1)
1375 this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
1376 else if (is_adjoint >= 0)
1378 is_adjoint);
1379#else
1380 libmesh_ignore(is_adjoint);
1381#endif
1382}
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:2518
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:2522
Parameters parameters
Parameters for the system. If a parameter is not provided, it should be retrieved from the EquationSy...
Definition system.h:1588
const EquationSystems & get_equation_systems() const
Definition system.h:767
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 1325 of file system_projection.C.

1333{
1334 WrappedFunction<Number> f(*this, fptr, &function_parameters);
1335 WrappedFunction<Gradient> g(*this, gptr, &function_parameters);
1336 this->boundary_project_vector(b, variables, new_vector, &f, &g,
1337 is_adjoint, active_local_range);
1338}

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 1337 of file fem_system.C.

1338{
1339 auto fc = std::make_unique<FEMContext>(*this);
1340
1341 DifferentiablePhysics * phys = this->get_physics();
1342
1343 libmesh_assert (phys);
1344
1345 // If we are solving a moving mesh problem, tell that to the Context
1346 fc->set_mesh_system(phys->get_mesh_system());
1347 fc->set_mesh_x_var(phys->get_mesh_x_var());
1348 fc->set_mesh_y_var(phys->get_mesh_y_var());
1349 fc->set_mesh_z_var(phys->get_mesh_z_var());
1350
1351 fc->set_deltat_pointer( &deltat );
1352
1353 // If we are solving the adjoint problem, tell that to the Context
1354 fc->is_adjoint() = this->get_time_solver().is_adjoint();
1355
1356 return fc;
1357}
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::VariationalSmootherSystem::compute_mesh_quality_info(), libMesh::FEMSystem::mesh_position_get(), libMesh::FEMSystem::mesh_position_set(), and libMesh::VariationalSmootherSystem::prepare_for_smoothing().

◆ 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 1533 of file system.C.

1536{
1537 // This function must be run on all processors at once
1538 parallel_object_only();
1539
1540 LOG_SCOPE ("calculate_norm()", "System");
1541
1542 // Zero the norm before summation
1543 Real v_norm = 0.;
1544
1545 if (norm.is_discrete())
1546 {
1547 //Check to see if all weights are 1.0 and all types are equal
1548 FEMNormType norm_type0 = norm.type(0);
1549 unsigned int check_var = 0, check_end = this->n_vars();
1550 for (; check_var != check_end; ++check_var)
1551 if ((norm.weight(check_var) != 1.0) || (norm.type(check_var) != norm_type0))
1552 break;
1553
1554 //All weights were 1.0 so just do the full vector discrete norm
1555 if (check_var == this->n_vars())
1556 {
1557 if (norm_type0 == DISCRETE_L1)
1558 return v.l1_norm();
1559 if (norm_type0 == DISCRETE_L2)
1560 return v.l2_norm();
1561 if (norm_type0 == DISCRETE_L_INF)
1562 return v.linfty_norm();
1563 else
1564 libmesh_error_msg("Invalid norm_type0 = " << Utility::enum_to_string(norm_type0));
1565 }
1566
1567 for (auto var : make_range(this->n_vars()))
1568 {
1569 // Skip any variables we don't need to integrate
1570 if (norm.weight(var) == 0.0)
1571 continue;
1572
1573 v_norm += norm.weight(var) * discrete_var_norm(v, var, norm.type(var));
1574 }
1575
1576 return v_norm;
1577 }
1578
1579 // Localize the potentially parallel vector
1580 std::unique_ptr<NumericVector<Number>> local_v = NumericVector<Number>::build(this->comm());
1581 local_v->init(v.size(), v.local_size(), _dof_map->get_send_list(),
1582 true, GHOSTED);
1583 v.localize (*local_v, _dof_map->get_send_list());
1584
1585 // I'm not sure how best to mix Hilbert norms on some variables (for
1586 // which we'll want to square then sum then square root) with norms
1587 // like L_inf (for which we'll just want to take an absolute value
1588 // and then sum).
1589 bool using_hilbert_norm = true,
1590 using_nonhilbert_norm = true;
1591
1592 // Loop over all variables
1593 for (auto var : make_range(this->n_vars()))
1594 {
1595 // Skip any variables we don't need to integrate
1596 Real norm_weight_sq = norm.weight_sq(var);
1597 if (norm_weight_sq == 0.0)
1598 continue;
1599 Real norm_weight = norm.weight(var);
1600
1601 // Check for unimplemented norms (rather than just returning 0).
1602 FEMNormType norm_type = norm.type(var);
1603 if ((norm_type==H1) ||
1604 (norm_type==H2) ||
1605 (norm_type==L2) ||
1606 (norm_type==H1_SEMINORM) ||
1607 (norm_type==H2_SEMINORM))
1608 {
1609 if (!using_hilbert_norm)
1610 libmesh_not_implemented();
1611 using_nonhilbert_norm = false;
1612 }
1613 else if ((norm_type==L1) ||
1614 (norm_type==L_INF) ||
1615 (norm_type==W1_INF_SEMINORM) ||
1616 (norm_type==W2_INF_SEMINORM))
1617 {
1618 if (!using_nonhilbert_norm)
1619 libmesh_not_implemented();
1620 using_hilbert_norm = false;
1621 }
1622 else
1623 libmesh_not_implemented();
1624
1625 const FEType & fe_type = this->get_dof_map().variable_type(var);
1626
1627 // Allow space for dims 0-3, and for both scalar and vector
1628 // elements, even if we don't use them all
1629 std::vector<std::unique_ptr<FEBase>> fe_ptrs(4);
1630 std::vector<std::unique_ptr<FEVectorBase>> vec_fe_ptrs(4);
1631 std::vector<std::unique_ptr<QBase>> q_rules(4);
1632
1633 const std::set<unsigned char> & elem_dims = _mesh.elem_dimensions();
1634
1635 // Prepare finite elements for each dimension present in the mesh
1636 for (const auto & dim : elem_dims)
1637 {
1638 if (skip_dimensions && skip_dimensions->find(dim) != skip_dimensions->end())
1639 continue;
1640
1641 // Construct quadrature and finite element objects
1642 q_rules[dim] = fe_type.default_quadrature_rule (dim);
1643
1644 const FEFieldType field_type = FEInterface::field_type(fe_type);
1645 if (field_type == TYPE_SCALAR)
1646 {
1647 fe_ptrs[dim] = FEBase::build(dim, fe_type);
1648 fe_ptrs[dim]->attach_quadrature_rule (q_rules[dim].get());
1649 }
1650 else
1651 {
1652 vec_fe_ptrs[dim] = FEVectorBase::build(dim, fe_type);
1653 vec_fe_ptrs[dim]->attach_quadrature_rule (q_rules[dim].get());
1654 libmesh_assert_equal_to(field_type, TYPE_VECTOR);
1655 }
1656
1657 }
1658
1659 std::vector<dof_id_type> dof_indices;
1660
1661 // Begin the loop over the elements
1662 for (const auto & elem : this->get_mesh().active_local_element_ptr_range())
1663 {
1664 const unsigned int dim = elem->dim();
1665
1666 // One way for implementing this would be to exchange the fe with the FEInterface- class.
1667 // However, it needs to be discussed whether integral-norms make sense for infinite elements.
1668 // or in which sense they could make sense.
1669 if (elem->infinite() )
1670 libmesh_not_implemented();
1671
1672 if (skip_dimensions && skip_dimensions->find(dim) != skip_dimensions->end())
1673 continue;
1674
1675 QBase * qrule = q_rules[dim].get();
1676 libmesh_assert(qrule);
1677
1678 this->get_dof_map().dof_indices (elem, dof_indices, var);
1679
1680 auto element_calculation = [&dof_indices, &elem,
1681 norm_type, norm_weight, norm_weight_sq, &qrule,
1682 &local_v, &v_norm](auto & fe) {
1683 typedef typename std::remove_reference<decltype(fe)>::type::OutputShape OutputShape;
1684 typedef typename TensorTools::MakeNumber<OutputShape>::type OutputNumberShape;
1685 typedef typename std::remove_reference<decltype(fe)>::type::OutputGradient OutputGradient;
1686 typedef typename TensorTools::MakeNumber<OutputGradient>::type OutputNumberGradient;
1687
1688 const std::vector<Real> & JxW = fe.get_JxW();
1689 const std::vector<std::vector<OutputShape>> * phi = nullptr;
1690 if (norm_type == H1 ||
1691 norm_type == H2 ||
1692 norm_type == L2 ||
1693 norm_type == L1 ||
1694 norm_type == L_INF)
1695 phi = &(fe.get_phi());
1696
1697 const std::vector<std::vector<OutputGradient>> * dphi = nullptr;
1698 if (norm_type == H1 ||
1699 norm_type == H2 ||
1700 norm_type == H1_SEMINORM ||
1701 norm_type == W1_INF_SEMINORM)
1702 dphi = &(fe.get_dphi());
1703
1704#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1705 typedef typename std::remove_reference<decltype(fe)>::type::OutputTensor OutputTensor;
1706
1707 const std::vector<std::vector<OutputTensor>> * d2phi = nullptr;
1708 if (norm_type == H2 ||
1709 norm_type == H2_SEMINORM ||
1710 norm_type == W2_INF_SEMINORM)
1711 d2phi = &(fe.get_d2phi());
1712#endif
1713
1714 fe.reinit (elem);
1715
1716 const unsigned int n_qp = qrule->n_points();
1717
1718 const unsigned int n_sf = cast_int<unsigned int>
1719 (dof_indices.size());
1720
1721 // Begin the loop over the Quadrature points.
1722 for (unsigned int qp=0; qp<n_qp; qp++)
1723 {
1724 if (norm_type == L1)
1725 {
1726 OutputNumberShape u_h = 0.;
1727 for (unsigned int i=0; i != n_sf; ++i)
1728 u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1729 v_norm += norm_weight *
1730 JxW[qp] * TensorTools::norm(u_h);
1731 }
1732
1733 if (norm_type == L_INF)
1734 {
1735 OutputNumberShape u_h = 0.;
1736 for (unsigned int i=0; i != n_sf; ++i)
1737 u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1738 v_norm = std::max(v_norm, norm_weight * TensorTools::norm(u_h));
1739 }
1740
1741 if (norm_type == H1 ||
1742 norm_type == H2 ||
1743 norm_type == L2)
1744 {
1745 OutputNumberShape u_h = 0.;
1746 for (unsigned int i=0; i != n_sf; ++i)
1747 u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1748 v_norm += norm_weight_sq *
1749 JxW[qp] * TensorTools::norm_sq(u_h);
1750 }
1751
1752 if (norm_type == H1 ||
1753 norm_type == H2 ||
1754 norm_type == H1_SEMINORM)
1755 {
1756 OutputNumberGradient grad_u_h;
1757 for (unsigned int i=0; i != n_sf; ++i)
1758 grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
1759 v_norm += norm_weight_sq *
1760 JxW[qp] * grad_u_h.norm_sq();
1761 }
1762
1763 if (norm_type == W1_INF_SEMINORM)
1764 {
1765 OutputNumberGradient grad_u_h;
1766 for (unsigned int i=0; i != n_sf; ++i)
1767 grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
1768 v_norm = std::max(v_norm, norm_weight * grad_u_h.norm());
1769 }
1770
1771#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1772 typedef typename TensorTools::MakeNumber<OutputTensor>::type OutputNumberTensor;
1773
1774 if (norm_type == H2 ||
1775 norm_type == H2_SEMINORM)
1776 {
1777 OutputNumberTensor hess_u_h;
1778 for (unsigned int i=0; i != n_sf; ++i)
1779 hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
1780 v_norm += norm_weight_sq *
1781 JxW[qp] * hess_u_h.norm_sq();
1782 }
1783
1784 if (norm_type == W2_INF_SEMINORM)
1785 {
1786 OutputNumberTensor hess_u_h;
1787 for (unsigned int i=0; i != n_sf; ++i)
1788 hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
1789 v_norm = std::max(v_norm, norm_weight * hess_u_h.norm());
1790 }
1791#endif
1792 }
1793 };
1794
1795 FEBase * scalar_fe = fe_ptrs[dim].get();
1796 FEVectorBase * vec_fe = vec_fe_ptrs[dim].get();
1797
1798 if (scalar_fe)
1799 {
1800 libmesh_assert(!vec_fe);
1801 element_calculation(*scalar_fe);
1802 }
1803
1804 if (vec_fe)
1805 {
1806 libmesh_assert(!scalar_fe);
1807 element_calculation(*vec_fe);
1808 }
1809 }
1810 }
1811
1812 if (using_hilbert_norm)
1813 {
1814 this->comm().sum(v_norm);
1815 v_norm = std::sqrt(v_norm);
1816 }
1817 else
1818 {
1819 this->comm().max(v_norm);
1820 }
1821
1822 return v_norm;
1823}
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:2201
const FEType & variable_type(const unsigned int i) const
Definition dof_map.h:2388
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:430
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:1492
MeshBase & _mesh
Constant reference to the mesh data structure used for the simulation.
Definition system.h:2237
unsigned int n_vars() const
Definition system.C:2674
const Elem & get(const ElemType type_in)
auto norm(const T &a)
auto norm_sq(const T &a)
std::string enum_to_string(const T e)
FEGenericBase< RealGradient > FEVectorBase
Definition fe_base.h:818
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 1511 of file system.C.

1515{
1516 //short circuit to save time
1517 if (norm_type == DISCRETE_L1 ||
1518 norm_type == DISCRETE_L2 ||
1519 norm_type == DISCRETE_L_INF)
1520 return discrete_var_norm(v,var,norm_type);
1521
1522 // Not a discrete norm
1523 std::vector<FEMNormType> norms(this->n_vars(), L2);
1524 std::vector<Real> weights(this->n_vars(), 0.0);
1525 norms[var] = norm_type;
1526 weights[var] = 1.0;
1527 Real val = this->calculate_norm(v, SystemNorm(norms, weights), skip_dimensions);
1528 return val;
1529}
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
Definition system.C:1511

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 2028 of file system.h.

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

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:1625

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::System::add_vector(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), 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::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::MeshBase::cache_elem_data(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::MeshTetInterface::check_hull_integrity(), 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::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::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::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), 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_mffd_interface(), 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::MeshBase::n_constraint_rows(), 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(), LaplaceSystem::postprocess(), 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::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(), 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::testPoly2TriRefinementBase(), SystemsTest::testProjectCubeWithMeshFunction(), SystemsTest::testProjectScalarCoarsening(), BoundaryInfoTest::testRenumber(), BoundaryInfoTest::testSelectiveRenumber(), BoundaryMeshSubdomainTest::testSingleSubdomain(), 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 606 of file system.C.

609{
610 // we do not care for matrices, but for vectors
612 libmesh_assert (other_system._is_initialized);
613
614 if (verbose)
615 {
616 libMesh::out << " Systems \"" << _sys_name << "\"" << std::endl;
617 libMesh::out << " comparing matrices not supported." << std::endl;
618 libMesh::out << " comparing names...";
619 }
620
621 // compare the name: 0 means identical
622 const int name_result = _sys_name.compare(other_system.name());
623 if (verbose)
624 {
625 if (name_result == 0)
626 libMesh::out << " identical." << std::endl;
627 else
628 libMesh::out << " names not identical." << std::endl;
629 libMesh::out << " comparing solution vector...";
630 }
631
632
633 // compare the solution: -1 means identical
634 const int solu_result = solution->compare (*other_system.solution.get(),
635 threshold);
636
637 if (verbose)
638 {
639 if (solu_result == -1)
640 libMesh::out << " identical up to threshold." << std::endl;
641 else
642 libMesh::out << " first difference occurred at index = "
643 << solu_result << "." << std::endl;
644 }
645
646
647 // safety check, whether we handle at least the same number
648 // of vectors
649 std::vector<int> ov_result;
650
651 if (this->n_vectors() != other_system.n_vectors())
652 {
653 if (verbose)
654 {
655 libMesh::out << " Fatal difference. This system handles "
656 << this->n_vectors() << " add'l vectors," << std::endl
657 << " while the other system handles "
658 << other_system.n_vectors()
659 << " add'l vectors." << std::endl
660 << " Aborting comparison." << std::endl;
661 }
662 return false;
663 }
664 else if (this->n_vectors() == 0)
665 {
666 // there are no additional vectors...
667 ov_result.clear ();
668 }
669 else
670 {
671 // compare other vectors
672 for (auto & [vec_name, vec] : _vectors)
673 {
674 if (verbose)
675 libMesh::out << " comparing vector \""
676 << vec_name << "\" ...";
677
678 // assume they have the same name
679 const NumericVector<Number> & other_system_vector =
680 other_system.get_vector(vec_name);
681
682 ov_result.push_back(vec->compare(other_system_vector, threshold));
683
684 if (verbose)
685 {
686 if (ov_result[ov_result.size()-1] == -1)
687 libMesh::out << " identical up to threshold." << std::endl;
688 else
689 libMesh::out << " first difference occurred at" << std::endl
690 << " index = " << ov_result[ov_result.size()-1] << "." << std::endl;
691 }
692 }
693 } // finished comparing additional vectors
694
695
696 bool overall_result;
697
698 // sum up the results
699 if ((name_result==0) && (solu_result==-1))
700 {
701 if (ov_result.size()==0)
702 overall_result = true;
703 else
704 {
705 bool ov_identical;
706 unsigned int n = 0;
707 do
708 {
709 ov_identical = (ov_result[n]==-1);
710 n++;
711 }
712 while (ov_identical && n<ov_result.size());
713 overall_result = ov_identical;
714 }
715 }
716 else
717 overall_result = false;
718
719 if (verbose)
720 {
721 libMesh::out << " finished comparisons, ";
722 if (overall_result)
723 libMesh::out << "found no differences." << std::endl << std::endl;
724 else
725 libMesh::out << "found differences." << std::endl << std::endl;
726 }
727
728 return overall_result;
729}
const std::string _sys_name
A name associated with this system.
Definition system.h:2242

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 2059 of file system.h.

2059{ 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:2664

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 2449 of file system.h.

2450{
2451 _active = false;
2452}

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:1609

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 1492 of file system.C.

1495{
1496 std::set<dof_id_type> var_indices;
1497 local_dof_indices(var, var_indices);
1498
1499 if (norm_type == DISCRETE_L1)
1500 return v.subset_l1_norm(var_indices);
1501 if (norm_type == DISCRETE_L2)
1502 return v.subset_l2_norm(var_indices);
1503 if (norm_type == DISCRETE_L_INF)
1504 return v.subset_linfty_norm(var_indices);
1505 else
1506 libmesh_error_msg("Invalid norm_type = " << Utility::enum_to_string(norm_type));
1507}
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:1409

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()

void PoissonSystem::element_postprocess ( DiffContext )
protectedvirtual

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

Reimplemented from libMesh::DifferentiableSystem.

Definition at line 17 of file element_postprocess.C.

18{
19 FEMContext & c = cast_ref<FEMContext &>(context);
20
21 FEBase * elem_fe = nullptr;
22 c.get_element_fe( 0, elem_fe );
23
24 // Element Jacobian * quadrature weights for interior integration
25 const std::vector<Real> & JxW = elem_fe->get_JxW();
26
27 const std::vector<Point> & xyz = elem_fe->get_xyz();
28
29 // The number of local degrees of freedom in each variable
30
31 unsigned int n_qpoints = c.get_element_qrule().n_points();
32
33 Number dQoI_0 = 0.;
34
35 // Loop over quadrature points
36
37 for (unsigned int qp = 0; qp != n_qpoints; qp++)
38 {
39 // Get co-ordinate locations of the current quadrature point
40 const Real x = xyz[qp](0);
41 const Real y = xyz[qp](1);
42
43 Real f = -alpha * ( ( (- 4 * alpha * alpha) * exp(-alpha*x) * y * (1 - y) ) + ( -8 + ( 8 * exp(-alpha*x) ) + ( 8 * ( 1 - exp(-alpha) )* x) ) );
44
45 Real s = x * (1 - x) * (1 - y);
46 RealVectorValue U ((1-y)*(1-(2*x)),-x*(1-x));
47
48 Gradient grad_u = c.interior_gradient(0, qp);
49
50 // Flux with weight s = R(u^h, s) = int ( f*s - alpha*(grad_u*grad_s) ) dx
51 dQoI_0 += JxW[qp] * ( (f * s) - (alpha * (U * grad_u)) );
52 }
53
54 // Update the computed value of the global functional R, by adding the contribution from this element
55
56 computed_QoI[0] = computed_QoI[0] + dQoI_0;
57
58}
virtual_for_inffe const std::vector< Real > & get_JxW() const
virtual_for_inffe const std::vector< Point > & get_xyz() const
This class forms the foundation from which generic finite elements may be derived.
Definition fe_base.h:86
Gradient interior_gradient(unsigned int var, unsigned int qp) const
const QBase & get_element_qrule() const
Accessor for element interior quadrature rule for the dimension of the current _elem.
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 n_points() const
Definition quadrature.h:131

References alpha, computed_QoI, libMesh::FEMContext::get_element_fe(), libMesh::FEMContext::get_element_qrule(), libMesh::FEAbstract::get_JxW(), libMesh::FEAbstract::get_xyz(), libMesh::FEMContext::interior_gradient(), libMesh::QBase::n_points(), and libMesh::Real.

◆ 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 PoissonSystem::element_time_derivative ( bool  request_jacobian,
DiffContext  
)
protectedvirtual

Adds the time derivative 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 need to reimplement this for their particular PDE.

To implement the physics model du/dt = F(u), the user should examine u = elem_solution and add (F(u), phi_i) to elem_residual in elem_time_derivative().

Reimplemented from libMesh::DifferentiablePhysics.

Definition at line 117 of file poisson.C.

119{
120 // Are the jacobians specified analytically ?
121 bool compute_jacobian = request_jacobian && _analytic_jacobians;
122
123 FEMContext & c = cast_ref<FEMContext &>(context);
124
125 // First we get some references to cell-specific data that
126 // will be used to assemble the linear system.
127 FEBase* elem_fe = nullptr;
128 c.get_element_fe( 0, elem_fe );
129
130 // Element Jacobian * quadrature weights for interior integration
131 const std::vector<Real> & JxW = elem_fe->get_JxW();
132
133 // Element basis functions
134 const std::vector<std::vector<Real>> & phi = elem_fe->get_phi();
135 const std::vector<std::vector<RealGradient>> & dphi = elem_fe->get_dphi();
136
137 // Quadrature point locations
138 const std::vector<Point > & q_point = elem_fe->get_xyz();
139
140 // The number of local degrees of freedom in each variable
141 const unsigned int n_T_dofs = c.n_dof_indices(0);
142
143 // The subvectors and submatrices we need to fill:
146
147 // Now we will build the element Jacobian and residual.
148 // Constructing the residual requires the solution and its
149 // gradient from the previous timestep. This must be
150 // calculated at each quadrature point by summing the
151 // solution degree-of-freedom values by the appropriate
152 // weight functions.
153 unsigned int n_qpoints = c.get_element_qrule().n_points();
154
155 for (unsigned int qp=0; qp != n_qpoints; qp++)
156 {
157 // Compute the solution gradient at the Newton iterate
158 Gradient grad_T = c.interior_gradient(0, qp);
159
160 // Location of the current qp
161 const Real x = q_point[qp](0);
162 const Real y = q_point[qp](1);
163
164 // Forcing function
165 Real f = -alpha * ( ( (- 4 * alpha * alpha) * exp(-alpha*x) * y * (1 - y) ) + ( -8 + ( 8 * exp(-alpha*x) ) + ( 8 * ( 1 - exp(-alpha) )* x) ) );
166
167 // The residual contribution from this element
168 for (unsigned int i=0; i != n_T_dofs; i++)
169 F(i) += JxW[qp] * ( (f * phi[i][qp]) - alpha*(grad_T * dphi[i][qp]) ) ;
171 for (unsigned int i=0; i != n_T_dofs; i++)
172 for (unsigned int j=0; j != n_T_dofs; ++j)
173 // The analytic jacobian
174 K(i,j) += JxW[qp] * ( -alpha*(dphi[i][qp] * dphi[j][qp]) );
175 } // end of the quadrature point qp-loop
176
177 return compute_jacobian;
178}
Defines a dense submatrix for use in Finite Element-type computations.
Defines a dense subvector for use in finite element computations.
unsigned int n_dof_indices() const
Total number of dof indices on the element.
const std::vector< std::vector< OutputShape > > & get_phi() const
Definition fe_base.h:207
const std::vector< std::vector< OutputGradient > > & get_dphi() const
Definition fe_base.h:230
void compute_jacobian(const NumericVector< Number > &, SparseMatrix< Number > &J, NonlinearImplicitSystem &system)
Definition assembly.C:315

References _analytic_jacobians, alpha, compute_jacobian(), libMesh::FEGenericBase< OutputType >::get_dphi(), 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::FEAbstract::get_xyz(), libMesh::FEMContext::interior_gradient(), libMesh::DiffContext::n_dof_indices(), libMesh::QBase::n_points(), and libMesh::Real.

◆ 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() [1/2]

virtual bool libMesh::DifferentiablePhysics::eulerian_residual ( bool  request_jacobian,
DiffContext  
)
inlinevirtualinherited

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 in libMesh::FEMPhysics, and SolidSystem.

Definition at line 277 of file diff_physics.h.

279 {
280 return request_jacobian;
281 }

Referenced by libMesh::DifferentiablePhysics::_eulerian_time_deriv().

◆ eulerian_residual() [2/2]

bool libMesh::FEMPhysics::eulerian_residual ( bool  request_jacobian,
DiffContext context 
)
overridevirtualinherited

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

This function assumes that the user's time derivative equations (except for any equations involving unknown mesh xyz coordinates themselves) are expressed in an Eulerian frame of reference, and that the user is satisfied with an unstabilized convection term. Lagrangian equations will probably require overriding eulerian_residual() with a blank function; ALE or stabilized formulations will require reimplementing eulerian_residual() entirely.

Reimplemented from libMesh::DifferentiablePhysics.

Reimplemented in SolidSystem.

Definition at line 38 of file fem_physics.C.

40{
41 // Only calculate a mesh movement residual if it's necessary
42 if (!_mesh_sys)
43 return request_jacobian;
44
45 libmesh_not_implemented();
46
47#if 0
48 FEMContext & context = cast_ref<FEMContext &>(c);
49
50 // This function only supports fully coupled mesh motion for now
51 libmesh_assert_equal_to (_mesh_sys, this);
52
53 unsigned int n_qpoints = (context.get_element_qrule())->n_points();
54
55 const unsigned int n_x_dofs = (_mesh_x_var == libMesh::invalid_uint) ?
56 0 : context.dof_indices_var[_mesh_x_var].size();
57 const unsigned int n_y_dofs = (_mesh_y_var == libMesh::invalid_uint) ?
58 0 : context.dof_indices_var[_mesh_y_var].size();
59 const unsigned int n_z_dofs = (_mesh_z_var == libMesh::invalid_uint) ?
60 0 : context.dof_indices_var[_mesh_z_var].size();
61
62 const unsigned int mesh_xyz_var = n_x_dofs ? _mesh_x_var :
63 (n_y_dofs ? _mesh_y_var :
64 (n_z_dofs ? _mesh_z_var :
66
67 // If we're our own _mesh_sys, we'd better be in charge of
68 // at least one coordinate, and we'd better have the same
69 // FE type for all coordinates we are in charge of
70 libmesh_assert_not_equal_to (mesh_xyz_var, libMesh::invalid_uint);
71 libmesh_assert(!n_x_dofs || context.element_fe_var[_mesh_x_var] ==
72 context.element_fe_var[mesh_xyz_var]);
73 libmesh_assert(!n_y_dofs || context.element_fe_var[_mesh_y_var] ==
74 context.element_fe_var[mesh_xyz_var]);
75 libmesh_assert(!n_z_dofs || context.element_fe_var[_mesh_z_var] ==
76 context.element_fe_var[mesh_xyz_var]);
77
78 const std::vector<std::vector<Real>> & psi =
79 context.element_fe_var[mesh_xyz_var]->get_phi();
80
81 for (auto var : make_range(context.n_vars()))
82 {
83 // Mesh motion only affects time-evolving variables
84 if (this->is_time_evolving(var))
85 continue;
86
87 // The mesh coordinate variables themselves are Lagrangian,
88 // not Eulerian, and no convective term is desired.
89 if (/*_mesh_sys == this && */
90 (var == _mesh_x_var ||
91 var == _mesh_y_var ||
92 var == _mesh_z_var))
93 continue;
94
95 // Some of this code currently relies on the assumption that
96 // we can pull mesh coordinate data from our own system
97 if (_mesh_sys != this)
98 libmesh_not_implemented();
99
100 // This residual should only be called by unsteady solvers:
101 // if the mesh is steady, there's no mesh convection term!
102 UnsteadySolver * unsteady;
103 if (this->time_solver->is_steady())
104 return request_jacobian;
105 else
106 unsteady = cast_ptr<UnsteadySolver*>(this->time_solver.get());
107
108 const std::vector<Real> & JxW =
109 context.element_fe_var[var]->get_JxW();
110
111 const std::vector<std::vector<Real>> & phi =
112 context.element_fe_var[var]->get_phi();
113
114 const std::vector<std::vector<RealGradient>> & dphi =
115 context.element_fe_var[var]->get_dphi();
116
117 const unsigned int n_u_dofs = context.dof_indices_var[var].size();
118
119 DenseSubVector<Number> & Fu = *context.elem_subresiduals[var];
120 DenseSubMatrix<Number> & Kuu = *context.elem_subjacobians[var][var];
121
122 DenseSubMatrix<Number> * Kux = n_x_dofs ?
123 context.elem_subjacobians[var][_mesh_x_var] : nullptr;
124 DenseSubMatrix<Number> * Kuy = n_y_dofs ?
125 context.elem_subjacobians[var][_mesh_y_var] : nullptr;
126 DenseSubMatrix<Number> * Kuz = n_z_dofs ?
127 context.elem_subjacobians[var][_mesh_z_var] : nullptr;
128
129 std::vector<Real> delta_x(n_x_dofs, 0.);
130 std::vector<Real> delta_y(n_y_dofs, 0.);
131 std::vector<Real> delta_z(n_z_dofs, 0.);
132
133 for (unsigned int i = 0; i != n_x_dofs; ++i)
134 {
135 unsigned int j = context.dof_indices_var[_mesh_x_var][i];
136 delta_x[i] = libmesh_real(this->current_solution(j)) -
137 libmesh_real(unsteady->old_nonlinear_solution(j));
138 }
139
140 for (unsigned int i = 0; i != n_y_dofs; ++i)
141 {
142 unsigned int j = context.dof_indices_var[_mesh_y_var][i];
143 delta_y[i] = libmesh_real(this->current_solution(j)) -
144 libmesh_real(unsteady->old_nonlinear_solution(j));
145 }
146
147 for (unsigned int i = 0; i != n_z_dofs; ++i)
148 {
149 unsigned int j = context.dof_indices_var[_mesh_z_var][i];
150 delta_z[i] = libmesh_real(this->current_solution(j)) -
151 libmesh_real(unsteady->old_nonlinear_solution(j));
152 }
153
154 for (unsigned int qp = 0; qp != n_qpoints; ++qp)
155 {
156 Gradient grad_u = context.interior_gradient(var, qp);
157 RealGradient convection(0.);
158
159 for (unsigned int i = 0; i != n_x_dofs; ++i)
160 convection(0) += delta_x[i] * psi[i][qp];
161 for (unsigned int i = 0; i != n_y_dofs; ++i)
162 convection(1) += delta_y[i] * psi[i][qp];
163 for (unsigned int i = 0; i != n_z_dofs; ++i)
164 convection(2) += delta_z[i] * psi[i][qp];
165
166 for (unsigned int i = 0; i != n_u_dofs; ++i)
167 {
168 Number JxWxPhiI = JxW[qp] * phi[i][qp];
169 Fu(i) += (convection * grad_u) * JxWxPhiI;
170 if (request_jacobian)
171 {
172 Number JxWxPhiI = JxW[qp] * phi[i][qp];
173 for (unsigned int j = 0; j != n_u_dofs; ++j)
174 Kuu(i,j) += JxWxPhiI * (convection * dphi[j][qp]);
175
176 Number JxWxPhiIoverDT = JxWxPhiI/this->deltat;
177
178 Number JxWxPhiIxDUDXoverDT = JxWxPhiIoverDT * grad_u(0);
179 for (unsigned int j = 0; j != n_x_dofs; ++j)
180 (*Kux)(i,j) += JxWxPhiIxDUDXoverDT * psi[j][qp];
181
182 Number JxWxPhiIxDUDYoverDT = JxWxPhiIoverDT * grad_u(1);
183 for (unsigned int j = 0; j != n_y_dofs; ++j)
184 (*Kuy)(i,j) += JxWxPhiIxDUDYoverDT * psi[j][qp];
185
186 Number JxWxPhiIxDUDZoverDT = JxWxPhiIoverDT * grad_u(2);
187 for (unsigned int j = 0; j != n_z_dofs; ++j)
188 (*Kuz)(i,j) += JxWxPhiIxDUDZoverDT * psi[j][qp];
189 }
190 }
191 }
192 }
193#endif // 0
194
195 return request_jacobian;
196}
unsigned int n_vars
unsigned int _mesh_x_var
Variables from which to acquire moving mesh information.
bool is_time_evolving(unsigned int var) const
System * _mesh_sys
System from which to acquire moving mesh information.
NumberVectorValue Gradient
T libmesh_real(T a)
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
RealVectorValue RealGradient

References libMesh::DifferentiablePhysics::_mesh_sys, libMesh::DifferentiablePhysics::_mesh_x_var, libMesh::DifferentiablePhysics::_mesh_y_var, libMesh::DifferentiablePhysics::_mesh_z_var, libMesh::FEMContext::get_element_qrule(), libMesh::FEMContext::interior_gradient(), libMesh::invalid_uint, libMesh::DifferentiablePhysics::is_time_evolving(), libMesh::libmesh_assert(), libMesh::libmesh_real(), libMesh::make_range(), libMesh::DiffContext::n_vars(), and libMesh::UnsteadySolver::old_nonlinear_solution().

◆ fe_family()

std::string & PoissonSystem::fe_family ( )
inline

Definition at line 21 of file poisson.h.

21{ return _fe_family; }

References _fe_family.

Referenced by set_system_parameters().

◆ fe_order()

unsigned int & PoissonSystem::fe_order ( )
inline

Definition at line 22 of file poisson.h.

22{ return _fe_order; }

References _fe_order.

Referenced by set_system_parameters().

◆ 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:1179

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 1294 of file system.C.

1295{
1296 std::ostringstream adjoint_rhs_name;
1297 adjoint_rhs_name << "adjoint_rhs" << i;
1298
1299 return this->get_vector(adjoint_rhs_name.str());
1300}
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition system.C:931

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 1304 of file system.C.

1305{
1306 std::ostringstream adjoint_rhs_name;
1307 adjoint_rhs_name << "adjoint_rhs" << i;
1308
1309 return this->get_vector(adjoint_rhs_name.str());
1310}

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 1242 of file system.C.

1243{
1244 std::ostringstream adjoint_name;
1245 adjoint_name << "adjoint_solution" << i;
1246
1247 return this->get_vector(adjoint_name.str());
1248}

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 1403 of file system.C.

1404{
1405 this->get_dof_map().get_all_variable_numbers(all_variable_numbers);
1406}
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:3389

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 2024 of file system.C.

2025{
2026 libmesh_assert_msg(_constrain_system_object,"No constraint object available.");
2028}

◆ 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 2425 of file system.h.

2426{
2427 return *_dof_map;
2428}

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 2417 of file system.h.

2418{
2419 return *_dof_map;
2420}

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(), 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(), libMesh::PetscNonlinearSolver< Number >::force_new_preconditioner(), 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(), init_data(), NavierSystem::init_data(), ElasticitySystem::init_data(), SimpleRBConstruction::init_data(), ElasticityRBConstruction::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::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(), SolidSystem::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(), 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(), MeshAssignTest::testMeshMoveAssign(), PeriodicBCTest::testPeriodicBC(), SystemsTest::testPostInitAddVectorTypeChange(), SystemsTest::testProjectCubeWithMeshFunction(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), SystemsTest::testProjectScalarCoarsening(), 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 772 of file system.h.

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

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 767 of file system.h.

767{ 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(), SolidSystem::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(), SolidSystem::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(), SolidSystem::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(), SolidSystem::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 1827 of file system.C.

1828{
1829 std::ostringstream oss;
1830
1831
1832 const std::string & sys_name = this->name();
1833
1834 oss << " System #" << this->number() << ", \"" << sys_name << "\"\n"
1835 << " Type \"" << this->system_type() << "\"\n"
1836 << " Variables=";
1837
1838 for (auto vg : make_range(this->n_variable_groups()))
1839 {
1840 const VariableGroup & vg_description (this->variable_group(vg));
1841
1842 if (vg_description.n_variables() > 1) oss << "{ ";
1843 for (auto vn : make_range(vg_description.n_variables()))
1844 oss << "\"" << vg_description.name(vn) << "\" ";
1845 if (vg_description.n_variables() > 1) oss << "} ";
1846 }
1847
1848 oss << '\n';
1849
1850 oss << " Finite Element Types=";
1851#ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
1852 for (auto vg : make_range(this->n_variable_groups()))
1853 oss << "\""
1854 << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
1855 << "\" ";
1856#else
1857 for (auto vg : make_range(this->n_variable_groups()))
1858 {
1859 oss << "\""
1860 << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
1861 << "\", \""
1862 << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().radial_family)
1863 << "\" ";
1864 }
1865
1866 oss << '\n' << " Infinite Element Mapping=";
1867 for (auto vg : make_range(this->n_variable_groups()))
1868 oss << "\""
1869 << Utility::enum_to_string<InfMapType>(this->get_dof_map().variable_group(vg).type().inf_map)
1870 << "\" ";
1871#endif
1872
1873 oss << '\n';
1874
1875 oss << " Approximation Orders=";
1876 for (auto vg : make_range(this->n_variable_groups()))
1877 {
1878#ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
1879 oss << "\""
1880 << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
1881 << "\" ";
1882#else
1883 oss << "\""
1884 << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
1885 << "\", \""
1886 << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().radial_order)
1887 << "\" ";
1888#endif
1889 }
1890
1891 oss << '\n';
1892
1893 if (this->is_initialized())
1894 {
1895 oss << " n_dofs()=" << this->n_dofs() << '\n';
1896 dof_id_type local_dofs = this->n_local_dofs();
1897 oss << " n_local_dofs()=" << local_dofs << '\n';
1898 this->comm().max(local_dofs);
1899 oss << " max(n_local_dofs())=" << local_dofs << '\n';
1900#ifdef LIBMESH_ENABLE_CONSTRAINTS
1901 if (this->n_constrained_dofs())
1902 {
1903 oss << " n_constrained_dofs()=" << this->n_constrained_dofs() << '\n';
1904 oss << " n_local_constrained_dofs()=" << this->n_local_constrained_dofs() << '\n';
1905 dof_id_type local_unconstrained_dofs = this->n_local_dofs() - this->n_local_constrained_dofs();
1906 this->comm().max(local_unconstrained_dofs);
1907 oss << " max(local unconstrained dofs)=" << local_unconstrained_dofs << '\n';
1908 }
1909#endif
1910 if (this->has_static_condensation())
1911 oss << " n uncondensed dofs="
1912 << this->get_dof_map().get_static_condensation().n_dofs() << '\n';
1913 }
1914 else
1915 oss << " (still uninitialized)\n";
1916
1917 oss << " " << "n_vectors()=" << this->n_vectors() << '\n';
1918 oss << " " << "n_matrices()=" << this->n_matrices() << '\n';
1919 // oss << " " << "n_additional_matrices()=" << this->n_additional_matrices() << '\n';
1920
1921 oss << this->get_dof_map().get_info();
1922
1923 return oss.str();
1924}
dof_id_type n_dofs() const
StaticCondensationDofMap & get_static_condensation()
Definition dof_map.h:2859
std::string get_info() const
Gets summary info about the sparsity bandwidth and constraints.
Definition dof_map.C:2985
const std::string & name() const
Definition system.h:2385
bool is_initialized() const
Definition system.h:2457
virtual std::string system_type() const
Definition system.h:510
dof_id_type n_constrained_dofs() const
Definition system.C:125
dof_id_type n_local_constrained_dofs() const
Definition system.C:140
unsigned int number() const
Definition system.h:2393
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 1118 of file system.C.

1119{
1120 return *libmesh_map_find(_matrices, mat_name);
1121}

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 2409 of file system.h.

2410{
2411 return _mesh;
2412}

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 2401 of file system.h.

2402{
2403 return _mesh;
2404}

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(), 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::FEMSystem::assemble_qoi_derivative(), libMesh::FEMSystem::assembly(), libMesh::VariationalSmootherSystem::assembly(), AssemblyF0::boundary_assembly(), AssemblyF1::boundary_assembly(), AssemblyF2::boundary_assembly(), AssemblyA0::boundary_assembly(), AssemblyA1::boundary_assembly(), AssemblyA2::boundary_assembly(), compute_jacobian(), libMesh::VariationalSmootherSystem::compute_mesh_quality_info(), compute_residual(), LinearElasticityWithContact::compute_stresses(), libMesh::VariationalSmootherConstraint::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(), SolidSystem::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(), SolidSystem::init_data(), ElasticitySystem::init_data(), ElasticityRBConstruction::init_data(), libMesh::System::init_data(), libMesh::VariationalSmootherSystem::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::VariationalSmootherSystem::prepare_for_smoothing(), 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(), SolidSystem::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(), SolidSystem::side_time_derivative(), libMesh::PetscDiffSolver::solve(), libMesh::ClawSystem::solve_conservation_law(), 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}

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}

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 1837 of file system.h.

1838 {
1840 }
bool project_with_constraints
Do we want to apply constraints while projecting vectors ?
Definition system.h:2343

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 2211 of file system.C.

2212{
2213 libmesh_assert(qoi_index < _qoi_error_estimates.size());
2214 return _qoi_error_estimates[qoi_index];
2215}
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:2377

References libMesh::libmesh_assert().

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

◆ get_QoI_value()

Number & PoissonSystem::get_QoI_value ( std::string  type,
unsigned int  QoI_index 
)
inline

Definition at line 29 of file poisson.h.

30 {
31 if (type == "exact")
32 {
33 return exact_QoI[QoI_index];
34 }
35 else
36 {
37 return computed_QoI[QoI_index];
38 }
39 }
Number exact_QoI[1]
Definition poisson.h:69

References computed_QoI, and exact_QoI.

Referenced by 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 1324 of file system.C.

1325{
1326 std::ostringstream sensitivity_rhs_name;
1327 sensitivity_rhs_name << "sensitivity_rhs" << i;
1328
1329 return this->get_vector(sensitivity_rhs_name.str());
1330}

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 1334 of file system.C.

1335{
1336 std::ostringstream sensitivity_rhs_name;
1337 sensitivity_rhs_name << "sensitivity_rhs" << i;
1338
1339 return this->get_vector(sensitivity_rhs_name.str());
1340}

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 1179 of file system.C.

1180{
1181 std::ostringstream sensitivity_name;
1182 sensitivity_name << "sensitivity_solution" << i;
1183
1184 return this->get_vector(sensitivity_name.str());
1185}

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 1189 of file system.C.

1190{
1191 std::ostringstream sensitivity_name;
1192 sensitivity_name << "sensitivity_solution" << i;
1193
1194 return this->get_vector(sensitivity_name.str());
1195}

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:1111

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 958 of file system.C.

959{
960 // If we don't have that many vectors, throw an error
961 libmesh_assert_less(vec_num, _vectors.size());
962
963 // Otherwise return a reference to the vec_num'th vector
964 auto it = vectors_begin();
965 std::advance(it, vec_num);
966 return *(it->second);
967}
vectors_iterator vectors_begin()
Beginning of vectors container.
Definition system.h:2505

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 945 of file system.C.

946{
947 // If we don't have that many vectors, throw an error
948 libmesh_assert_less(vec_num, _vectors.size());
949
950 // Otherwise return a reference to the vec_num'th vector
951 auto it = vectors_begin();
952 std::advance(it, vec_num);
953 return *(it->second);
954}

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 938 of file system.C.

939{
940 return *(libmesh_map_find(_vectors, vec_name));
941}

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 931 of file system.C.

932{
933 return *(libmesh_map_find(_vectors, vec_name));
934}

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(), 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 1264 of file system.C.

1265{
1266 std::ostringstream adjoint_name;
1267 adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1268
1269 return this->get_vector(adjoint_name.str());
1270}

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 1274 of file system.C.

1275{
1276 std::ostringstream adjoint_name;
1277 adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1278
1279 return this->get_vector(adjoint_name.str());
1280}

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 1206 of file system.C.

1207{
1208 return this->get_vector("weighted_sensitivity_solution");
1209}

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 1213 of file system.C.

1214{
1215 return this->get_vector("weighted_sensitivity_solution");
1216}

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 2019 of file system.C.

2020{
2021 return _constrain_system_object != nullptr;
2022}

◆ 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 1393 of file system.C.

1394{
1395 return this->get_dof_map().has_variable(var);
1396}
bool has_variable(std::string_view var) const
Definition dof_map.h:2986

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 1933 of file system.h.

1933{ 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 2491 of file system.h.

2492{
2493 return (_vectors.count(vec_name));
2494}

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 1852 of file system.h.

1852{ 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:2338

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 2684 of file system.C.

2685{
2686 return this->get_dof_map().identify_variable_groups();
2687}
bool identify_variable_groups() const
Definition dof_map.h:2951

◆ identify_variable_groups() [2/2]

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

Toggle automatic VariableGroup identification.

Definition at line 2689 of file system.C.

2690{
2692}

◆ 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 196 of file system.C.

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

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

Referenced by libMesh::StaticCondensationDofMap::reinit().

◆ init_context()

void PoissonSystem::init_context ( DiffContext context)
protectedvirtual

Reimplemented from libMesh::FEMSystem.

Definition at line 91 of file poisson.C.

92{
93 FEMContext & c = cast_ref<FEMContext &>(context);
94
95 // Now make sure we have requested all the data
96 // we need to build the linear system.
97 FEBase* elem_fe = nullptr;
98 c.get_element_fe( 0, elem_fe );
99 elem_fe->get_JxW();
100 elem_fe->get_phi();
101 elem_fe->get_dphi();
102 elem_fe->get_xyz();
103
104 FEBase* side_fe = nullptr;
105 c.get_side_fe( 0, side_fe );
106
107 side_fe->get_JxW();
108 side_fe->get_phi();
109 side_fe->get_dphi();
110 side_fe->get_xyz();
111
112}
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 PoissonSystem::init_data ( )
protectedvirtual

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

Reimplemented from libMesh::FEMSystem.

Definition at line 58 of file poisson.C.

59{
60 T_var =
61 this->add_variable ("T", static_cast<Order>(_fe_order),
62 Utility::string_to_enum<FEFamily>(_fe_family));
63
64 GetPot infile("poisson.in");
65 exact_QoI[0] = infile("QoI_0", 0.0);
66 alpha = infile("alpha", 100.0);
67
68 // The temperature is evolving, with a first order time derivative
69 this->time_evolving(T_var, 1);
70
71#ifdef LIBMESH_ENABLE_DIRICHLET
72 // Now we will set the Dirichlet boundary conditions
73
74 // For the adjoint problem, we will only set the bottom boundary to a non-zero value
75 const boundary_id_type bottom_bdry_id = 0;
76
77 // The zero function pointer for the primal all bdry bcs
79 // Boundary function for bottom bdry adjoint condition
80 BdyFunction bottom_adjoint(T_var);
81
83
84 this->get_dof_map().add_adjoint_dirichlet_boundary(DirichletBoundary ({bottom_bdry_id}, {T_var}, &bottom_adjoint), 0);
85#endif // LIBMESH_ENABLE_DIRICHLET
86
87 // Do the parent's initialization after variables are defined
88 FEMSystem::init_data();
89}
unsigned int T_var
Definition poisson.h:61
This class allows one to associate Dirichlet boundary values with a given set of mesh boundary ids an...
void add_dirichlet_boundary(const DirichletBoundary &dirichlet_boundary)
Adds a copy of the specified Dirichlet boundary to the system.
void add_adjoint_dirichlet_boundary(const DirichletBoundary &dirichlet_boundary, unsigned int q)
Adds a copy of the specified Dirichlet boundary to the system, corresponding to the adjoint problem d...
ConstFunction that simply returns 0.
int8_t boundary_id_type
Definition id_types.h:51

References _fe_family, _fe_order, libMesh::DofMap::add_adjoint_dirichlet_boundary(), libMesh::DofMap::add_dirichlet_boundary(), libMesh::System::add_variable(), alpha, exact_QoI, libMesh::System::get_dof_map(), T_var, libMesh::DifferentiablePhysics::time_evolving(), and libMesh::zero.

◆ init_matrices()

void libMesh::System::init_matrices ( )
protectedvirtualinherited

Initializes the matrices associated with this system.

Reimplemented in libMesh::EigenSystem.

Definition at line 311 of file system.C.

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

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 2169 of file system.C.

2170{
2171 _qoi.resize(n_qois);
2173}

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

◆ is_adjoint_already_solved()

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

Accessor for the adjoint_already_solved boolean.

Definition at line 411 of file system.h.

412 { 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:2332

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 2457 of file system.h.

2458{
2459 return _is_initialized;
2460}

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 1063 of file system.C.

1065{
1067 {
1068 this->get_dof_map().attach_matrix(mat);
1069 mat.init(type);
1070 }
1071}
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 1409 of file system.C.

1411{
1412 // Make sure the set is clear
1413 var_indices.clear();
1414
1415 std::vector<dof_id_type> dof_indices;
1416
1417 const dof_id_type
1418 first_local = this->get_dof_map().first_dof(),
1419 end_local = this->get_dof_map().end_dof();
1420
1421 // Begin the loop over the elements
1422 for (const auto & elem : this->get_mesh().active_local_element_ptr_range())
1423 {
1424 this->get_dof_map().dof_indices (elem, dof_indices, var);
1425
1426 for (dof_id_type dof : dof_indices)
1427 //If the dof is owned by the local processor
1428 if (first_local <= dof && dof < end_local)
1429 var_indices.insert(dof);
1430 }
1431
1432 // we may have missed assigning DOFs to nodes that we own
1433 // but to which we have no connected elements matching our
1434 // variable restriction criterion. this will happen, for example,
1435 // if variable V is restricted to subdomain S. We may not own
1436 // any elements which live in S, but we may own nodes which are
1437 // *connected* to elements which do.
1438 for (const auto & node : this->get_mesh().local_node_ptr_range())
1439 {
1440 libmesh_assert(node);
1441 this->get_dof_map().dof_indices (node, dof_indices, var);
1442 for (auto dof : dof_indices)
1443 if (first_local <= dof && dof < end_local)
1444 var_indices.insert(dof);
1445 }
1446}
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}

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 2529 of file system.h.

2530{
2531 return _matrices.begin();
2532}

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 2535 of file system.h.

2536{
2537 return _matrices.begin();
2538}

References libMesh::System::_matrices.

◆ matrices_end() [1/2]

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

End of matrices container.

Definition at line 2541 of file system.h.

2542{
2543 return _matrices.end();
2544}

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 2547 of file system.h.

2548{
2549 return _matrices.end();
2550}

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 1414 of file fem_system.C.

1415{
1416 // This function makes no sense unless we've already picked out some
1417 // variable(s) to reflect mesh position coordinates
1418 libmesh_error_msg_if(!_mesh_sys, "_mesh_sys was nullptr!");
1419
1420 // We currently assume mesh variables are in our own system
1421 if (_mesh_sys != this)
1422 libmesh_not_implemented();
1423
1424 // Loop over every active mesh element on this processor
1425 const MeshBase & mesh = this->get_mesh();
1426
1427 std::unique_ptr<DiffContext> con = this->build_context();
1428 FEMContext & _femcontext = cast_ref<FEMContext &>(*con);
1429 this->init_context(_femcontext);
1430
1431 // Get the solution's mesh variables from every element
1432 for (const auto & elem : mesh.active_local_element_ptr_range())
1433 {
1434 _femcontext.pre_fe_reinit(*this, elem);
1435
1436 _femcontext.elem_position_get();
1437
1439 this->solution->insert(_femcontext.get_elem_solution(_mesh_x_var),
1440 _femcontext.get_dof_indices(_mesh_x_var) );
1442 this->solution->insert(_femcontext.get_elem_solution(_mesh_y_var),
1443 _femcontext.get_dof_indices(_mesh_y_var));
1445 this->solution->insert(_femcontext.get_elem_solution(_mesh_z_var),
1446 _femcontext.get_dof_indices(_mesh_z_var));
1447 }
1448
1449 this->solution->close();
1450
1451 // And make sure the current_local_solution is up to date too
1452 this->System::update();
1453}
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.

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 SolidSystem::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 1081 of file fem_system.C.

1082{
1083 // If we don't need to move the mesh, we're done
1084 if (_mesh_sys != this)
1085 return;
1086
1087 MeshBase & mesh = this->get_mesh();
1088
1089 std::unique_ptr<DiffContext> con = this->build_context();
1090 FEMContext & _femcontext = cast_ref<FEMContext &>(*con);
1091 this->init_context(_femcontext);
1092
1093 // Move every mesh element we can
1094 for (const auto & elem : mesh.active_local_element_ptr_range())
1095 {
1096 // We need the algebraic data
1097 _femcontext.pre_fe_reinit(*this, elem);
1098 // And when asserts are on, we also need the FE so
1099 // we can assert that the mesh data is of the right type.
1100#ifndef NDEBUG
1101 _femcontext.elem_fe_reinit();
1102#endif
1103
1104 // This code won't handle moving subactive elements
1105 libmesh_assert(!_femcontext.get_elem().has_children());
1106
1107 _femcontext.elem_position_set(1.);
1108 }
1109
1110 // We've now got positions set on all local nodes (and some
1111 // semilocal nodes); let's request positions for non-local nodes
1112 // from their processors.
1113
1114 SyncNodalPositions sync_object(mesh);
1116 (this->comm(), mesh.nodes_begin(), mesh.nodes_end(), sync_object);
1117}
bool has_children() const
Definition elem.h:2996
const Elem & get_elem() const
Accessor for current Elem object.
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 SolidSystem::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 2483 of file system.h.

2484{
2485 return this->n_dofs() - this->n_constrained_dofs();
2486}

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 2694 of file system.C.

2695{
2696 return this->get_dof_map().n_components(this->get_mesh());
2697}
unsigned int n_components(const MeshBase &mesh) const
Definition dof_map.h:2963

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 125 of file system.C.

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

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 118 of file system.C.

119{
120 return _dof_map->n_dofs();
121}

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(), 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 140 of file system.C.

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

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 155 of file system.C.

156{
157 return _dof_map->n_local_dofs();
158}

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 2638 of file system.h.

2639{
2640 return cast_int<unsigned int>(_matrices.size());
2641}

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::DistributedMesh::add_node(), libMesh::System::add_vector(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), 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::DistributedMesh::DistributedMesh(), 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_contiguous_dof_ids(), 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::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::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_unique_id(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), WriteVecAndScalar::setupTests(), libMesh::RBEIMEvaluation::side_gather_bfs(), DistributedMeshTest::testRemoteElemError(), CheckpointIOTest::testSplitter(), libMesh::DistributedMesh::update_parallel_id_counts(), 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 2562 of file system.h.

2563{
2564 libmesh_assert_equal_to(this->_qoi.size(), this->_qoi_error_estimates.size());
2565
2566 return cast_int<unsigned int>(this->_qoi.size());
2567}

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 2699 of file system.C.

2700{
2701 return this->get_dof_map().n_variable_groups();
2702}
unsigned int n_variable_groups() const
Definition dof_map.h:733

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 2674 of file system.C.

2675{
2676 return this->get_dof_map().n_vars();
2677}
unsigned int n_vars() const
Definition dof_map.h:2937

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 2499 of file system.h.

2500{
2501 return cast_int<unsigned int>(_vectors.size());
2502}

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}

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 2393 of file system.h.

2394{
2395 return _sys_number;
2396}
const unsigned int _sys_number
The number associated with this system.
Definition system.h:2247

References libMesh::System::_sys_number.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::PetscDMWrapper::add_dofs_helper(), assemble_matrix_and_rhs(), assemble_shell(), libMesh::VariationalSmootherSystem::assembly(), libMesh::EquationSystems::build_parallel_solution_vector(), 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(), libMesh::VariationalSmootherSystem::init_data(), 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(), SolidSystem::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(), 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 1313 of file fem_system.C.

1314{
1315 LOG_SCOPE("numerical_elem_jacobian()", "FEMSystem");
1317}
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 1201 of file fem_system.C.

1203{
1204 // Logging is done by numerical_elem_jacobian
1205 // or numerical_side_jacobian
1206
1207 DenseVector<Number> original_residual(context.get_elem_residual());
1208 DenseVector<Number> backwards_residual(context.get_elem_residual());
1209 DenseMatrix<Number> numeric_jacobian(context.get_elem_jacobian());
1210#ifdef DEBUG
1211 DenseMatrix<Number> old_jacobian(context.get_elem_jacobian());
1212#endif
1213
1214 Real numerical_point_h = 0.;
1215 if (_mesh_sys == this)
1216 numerical_point_h = numerical_jacobian_h * context.get_elem().hmin();
1217
1218 const unsigned int n_dofs =
1219 cast_int<unsigned int>(context.get_dof_indices().size());
1220
1221 for (auto v : make_range(context.n_vars()))
1222 {
1223 const Real my_h = this->numerical_jacobian_h_for_var(v);
1224
1225 unsigned int j_offset = libMesh::invalid_uint;
1226
1227 if (!context.get_dof_indices(v).empty())
1228 {
1229 for (auto i : make_range(n_dofs))
1230 if (context.get_dof_indices()[i] ==
1231 context.get_dof_indices(v)[0])
1232 j_offset = i;
1233
1234 libmesh_assert_not_equal_to(j_offset, libMesh::invalid_uint);
1235 }
1236
1237 for (auto j : make_range(context.get_dof_indices(v).size()))
1238 {
1239 const unsigned int total_j = j + j_offset;
1240
1241 // Take the "minus" side of a central differenced first derivative
1242 Number original_solution = context.get_elem_solution(v)(j);
1243 context.get_elem_solution(v)(j) -= my_h;
1244
1245 // Make sure to catch any moving mesh terms
1246 Real * coord = nullptr;
1247 if (_mesh_sys == this)
1248 {
1249 if (_mesh_x_var == v)
1250 coord = &(context.get_elem().point(j)(0));
1251 else if (_mesh_y_var == v)
1252 coord = &(context.get_elem().point(j)(1));
1253 else if (_mesh_z_var == v)
1254 coord = &(context.get_elem().point(j)(2));
1255 }
1256 if (coord)
1257 {
1258 // We have enough information to scale the perturbations
1259 // here appropriately
1260 context.get_elem_solution(v)(j) = original_solution - numerical_point_h;
1261 *coord = libmesh_real(context.get_elem_solution(v)(j));
1262 }
1263
1264 context.get_elem_residual().zero();
1265 ((*time_solver).*(res))(false, context);
1266#ifdef DEBUG
1267 libmesh_assert_equal_to (old_jacobian, context.get_elem_jacobian());
1268#endif
1269 backwards_residual = context.get_elem_residual();
1270
1271 // Take the "plus" side of a central differenced first derivative
1272 context.get_elem_solution(v)(j) = original_solution + my_h;
1273 if (coord)
1274 {
1275 context.get_elem_solution()(j) = original_solution + numerical_point_h;
1276 *coord = libmesh_real(context.get_elem_solution(v)(j));
1277 }
1278 context.get_elem_residual().zero();
1279 ((*time_solver).*(res))(false, context);
1280#ifdef DEBUG
1281 libmesh_assert_equal_to (old_jacobian, context.get_elem_jacobian());
1282#endif
1283
1284 context.get_elem_solution(v)(j) = original_solution;
1285 if (coord)
1286 {
1287 *coord = libmesh_real(context.get_elem_solution(v)(j));
1288 for (auto i : make_range(n_dofs))
1289 {
1290 numeric_jacobian(i,total_j) =
1291 (context.get_elem_residual()(i) - backwards_residual(i)) /
1292 2. / numerical_point_h;
1293 }
1294 }
1295 else
1296 {
1297 for (auto i : make_range(n_dofs))
1298 {
1299 numeric_jacobian(i,total_j) =
1300 (context.get_elem_residual()(i) - backwards_residual(i)) /
1301 2. / my_h;
1302 }
1303 }
1304 }
1305 }
1306
1307 context.get_elem_residual() = original_residual;
1308 context.get_elem_jacobian() = numeric_jacobian;
1309}
Defines a dense vector for use in Finite Element-type computations.
virtual void zero() override final
Set every element in the vector to 0.
const Point & point(const unsigned int i) const
Definition elem.h:2462
virtual Real hmin() const
Definition elem.C:683
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

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 1329 of file fem_system.C.

1330{
1331 LOG_SCOPE("numerical_nonlocal_jacobian()", "FEMSystem");
1333}
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 1321 of file fem_system.C.

1322{
1323 LOG_SCOPE("numerical_side_jacobian()", "FEMSystem");
1325}
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().

◆ 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 2348 of file system.C.

2352{
2353 // This function must be called on every processor; there's no
2354 // telling where in the partition p falls.
2355 parallel_object_only();
2356
2357 // And every processor had better agree about which point we're
2358 // looking for
2359#ifndef NDEBUG
2360 libmesh_assert(this->comm().verify(p(0)));
2361#if LIBMESH_DIM > 1
2362 libmesh_assert(this->comm().verify(p(1)));
2363#endif
2364#if LIBMESH_DIM > 2
2365 libmesh_assert(this->comm().verify(p(2)));
2366#endif
2367#endif // NDEBUG
2368
2369 // Get a reference to the mesh object associated with the system object that calls this function
2370 const MeshBase & mesh = this->get_mesh();
2371
2372 // Use an existing PointLocator or create a new one
2373 std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2374 PointLocatorBase & locator = *locator_ptr;
2375
2376 if (!insist_on_success || !mesh.is_serial())
2377 locator.enable_out_of_mesh_mode();
2378
2379 // Get a pointer to an element that contains p and allows us to
2380 // evaluate var
2381 const std::set<subdomain_id_type> & raw_subdomains =
2382 this->variable(var).active_subdomains();
2383 const std::set<subdomain_id_type> * implicit_subdomains =
2384 raw_subdomains.empty() ? nullptr : &raw_subdomains;
2385 const Elem * e = locator(p, implicit_subdomains);
2386
2387 Gradient grad_u;
2388
2389 if (e && this->get_dof_map().is_evaluable(*e, var))
2390 grad_u = point_gradient(var, p, *e, sol);
2391
2392 // If I have an element containing p, then let's let everyone know
2393 processor_id_type lowest_owner =
2394 (e && (e->processor_id() == this->processor_id())) ?
2395 this->processor_id() : this->n_processors();
2396 this->comm().min(lowest_owner);
2397
2398 // Everybody should get their value from a processor that was able
2399 // to compute it.
2400 // If nobody admits owning the point, we may have a problem.
2401 if (lowest_owner != this->n_processors())
2402 this->comm().broadcast(grad_u, lowest_owner);
2403 else
2404 libmesh_assert(!insist_on_success);
2405
2406 return grad_u;
2407}
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:2348
const std::set< subdomain_id_type > & active_subdomains() const
Definition variable.h:181

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 2410 of file system.C.

2414{
2415 // Ensuring that the given point is really in the element is an
2416 // expensive assert, but as long as debugging is turned on we might
2417 // as well try to catch a particularly nasty potential error
2418 libmesh_assert (e.contains_point(p));
2419
2420 if (!sol)
2421 sol = this->current_local_solution.get();
2422
2423 // Get the dof map to get the proper indices for our computation
2424 const DofMap & dof_map = this->get_dof_map();
2425
2426 // write the element dimension into a separate variable.
2427 const unsigned int dim = e.dim();
2428
2429 // Make sure we can evaluate on this element.
2430 libmesh_assert (dof_map.is_evaluable(e, var));
2431
2432 // Need dof_indices for phi[i][j]
2433 std::vector<dof_id_type> dof_indices;
2434
2435 // Fill in the dof_indices for our element
2436 dof_map.dof_indices (&e, dof_indices, var);
2437
2438 // Get the no of dofs associated with this point
2439 const unsigned int num_dofs = cast_int<unsigned int>
2440 (dof_indices.size());
2441
2442 FEType fe_type = dof_map.variable_type(var);
2443
2444 // Map the physical co-ordinates to the master co-ordinates
2445 Point coor = FEMap::inverse_map(dim, &e, p);
2446
2447 // get the shape function value via the FEInterface to also handle the case
2448 // of infinite elements correctly, the shape function is not fe->phi().
2449 FEComputeData fe_data(this->get_equation_systems(), coor);
2450 fe_data.enable_derivative();
2451 FEInterface::compute_data(dim, fe_type, &e, fe_data);
2452
2453 // Get ready to accumulate a gradient
2454 Gradient grad_u;
2455
2456 for (unsigned int l=0; l<num_dofs; l++)
2457 {
2458 // Chartesian coordinates have always LIBMESH_DIM entries,
2459 // local coordinates have as many coordinates as the element has.
2460 for (std::size_t v=0; v<dim; v++)
2461 for (std::size_t xyz=0; xyz<LIBMESH_DIM; xyz++)
2462 {
2463 // FIXME: this needs better syntax: It is matrix-vector multiplication.
2464 grad_u(xyz) += fe_data.local_transform[v][xyz]
2465 * fe_data.dshape[l](v)
2466 * (*sol)(dof_indices[l]);
2467 }
2468 }
2469
2470 return grad_u;
2471}
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 2475 of file system.C.

2476{
2477 libmesh_assert(e);
2478 return this->point_gradient(var, p, *e);
2479}

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 2483 of file system.C.

2484{
2485 return this->point_gradient(var, p, true, sol);
2486}

◆ 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 2492 of file system.C.

2496{
2497 // This function must be called on every processor; there's no
2498 // telling where in the partition p falls.
2499 parallel_object_only();
2500
2501 // And every processor had better agree about which point we're
2502 // looking for
2503#ifndef NDEBUG
2504 libmesh_assert(this->comm().verify(p(0)));
2505#if LIBMESH_DIM > 1
2506 libmesh_assert(this->comm().verify(p(1)));
2507#endif
2508#if LIBMESH_DIM > 2
2509 libmesh_assert(this->comm().verify(p(2)));
2510#endif
2511#endif // NDEBUG
2512
2513 // Get a reference to the mesh object associated with the system object that calls this function
2514 const MeshBase & mesh = this->get_mesh();
2515
2516 // Use an existing PointLocator or create a new one
2517 std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2518 PointLocatorBase & locator = *locator_ptr;
2519
2520 if (!insist_on_success || !mesh.is_serial())
2521 locator.enable_out_of_mesh_mode();
2522
2523 // Get a pointer to an element that contains p and allows us to
2524 // evaluate var
2525 const std::set<subdomain_id_type> & raw_subdomains =
2526 this->variable(var).active_subdomains();
2527 const std::set<subdomain_id_type> * implicit_subdomains =
2528 raw_subdomains.empty() ? nullptr : &raw_subdomains;
2529 const Elem * e = locator(p, implicit_subdomains);
2530
2531 Tensor hess_u;
2532
2533 if (e && this->get_dof_map().is_evaluable(*e, var))
2534 hess_u = point_hessian(var, p, *e, sol);
2535
2536 // If I have an element containing p, then let's let everyone know
2537 processor_id_type lowest_owner =
2538 (e && (e->processor_id() == this->processor_id())) ?
2539 this->processor_id() : this->n_processors();
2540 this->comm().min(lowest_owner);
2541
2542 // Everybody should get their value from a processor that was able
2543 // to compute it.
2544 // If nobody admits owning the point, we may have a problem.
2545 if (lowest_owner != this->n_processors())
2546 this->comm().broadcast(hess_u, lowest_owner);
2547 else
2548 libmesh_assert(!insist_on_success);
2549
2550 return hess_u;
2551}
Tensor point_hessian(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition system.C:2492
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 2553 of file system.C.

2557{
2558 // Ensuring that the given point is really in the element is an
2559 // expensive assert, but as long as debugging is turned on we might
2560 // as well try to catch a particularly nasty potential error
2561 libmesh_assert (e.contains_point(p));
2562
2563 if (!sol)
2564 sol = this->current_local_solution.get();
2565
2566 if (e.infinite())
2567 libmesh_not_implemented();
2568
2569 // Get the dof map to get the proper indices for our computation
2570 const DofMap & dof_map = this->get_dof_map();
2571
2572 // Make sure we can evaluate on this element.
2573 libmesh_assert (dof_map.is_evaluable(e, var));
2574
2575 // Need dof_indices for phi[i][j]
2576 std::vector<dof_id_type> dof_indices;
2577
2578 // Fill in the dof_indices for our element
2579 dof_map.dof_indices (&e, dof_indices, var);
2580
2581 // Get the no of dofs associated with this point
2582 const unsigned int num_dofs = cast_int<unsigned int>
2583 (dof_indices.size());
2584
2585 FEType fe_type = dof_map.variable_type(var);
2586
2587 // Build a FE again so we can calculate u(p)
2588 std::unique_ptr<FEBase> fe (FEBase::build(e.dim(), fe_type));
2589
2590 // Map the physical co-ordinates to the master co-ordinates
2591 // Build a vector of point co-ordinates to send to reinit
2592 std::vector<Point> coor(1, FEMap::inverse_map(e.dim(), &e, p));
2593
2594 // Get the values of the shape function derivatives
2595 const std::vector<std::vector<RealTensor>> & d2phi = fe->get_d2phi();
2596
2597 // Reinitialize the element and compute the shape function values at coor
2598 fe->reinit (&e, &coor);
2599
2600 // Get ready to accumulate a hessian
2601 Tensor hess_u;
2602
2603 for (unsigned int l=0; l<num_dofs; l++)
2604 {
2605 hess_u.add_scaled (d2phi[l][0], (*sol)(dof_indices[l]));
2606 }
2607
2608 return hess_u;
2609}
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 2613 of file system.C.

2614{
2615 libmesh_assert(e);
2616 return this->point_hessian(var, p, *e);
2617}

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 2621 of file system.C.

2622{
2623 return this->point_hessian(var, p, true, sol);
2624}

◆ 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 2219 of file system.C.

2223{
2224 // This function must be called on every processor; there's no
2225 // telling where in the partition p falls.
2226 parallel_object_only();
2227
2228 // And every processor had better agree about which point we're
2229 // looking for
2230#ifndef NDEBUG
2231 libmesh_assert(this->comm().verify(p(0)));
2232#if LIBMESH_DIM > 1
2233 libmesh_assert(this->comm().verify(p(1)));
2234#endif
2235#if LIBMESH_DIM > 2
2236 libmesh_assert(this->comm().verify(p(2)));
2237#endif
2238#endif // NDEBUG
2239
2240 // Get a reference to the mesh object associated with the system object that calls this function
2241 const MeshBase & mesh = this->get_mesh();
2242
2243 // Use an existing PointLocator or create a new one
2244 std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2245 PointLocatorBase & locator = *locator_ptr;
2246
2247 if (!insist_on_success || !mesh.is_serial())
2248 locator.enable_out_of_mesh_mode();
2249
2250 // Get a pointer to an element that contains p and allows us to
2251 // evaluate var
2252 const std::set<subdomain_id_type> & raw_subdomains =
2253 this->variable(var).active_subdomains();
2254 const std::set<subdomain_id_type> * implicit_subdomains =
2255 raw_subdomains.empty() ? nullptr : &raw_subdomains;
2256 const Elem * e = locator(p, implicit_subdomains);
2257
2258 Number u = 0;
2259
2260 if (e && this->get_dof_map().is_evaluable(*e, var))
2261 u = point_value(var, p, *e, sol);
2262
2263 // If I have an element containing p, then let's let everyone know
2264 processor_id_type lowest_owner =
2265 (e && (e->processor_id() == this->processor_id())) ?
2266 this->processor_id() : this->n_processors();
2267 this->comm().min(lowest_owner);
2268
2269 // Everybody should get their value from a processor that was able
2270 // to compute it.
2271 // If nobody admits owning the point, we have a problem.
2272 if (lowest_owner != this->n_processors())
2273 this->comm().broadcast(u, lowest_owner);
2274 else
2275 libmesh_assert(!insist_on_success);
2276
2277 return u;
2278}
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition system.C:2219

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

Referenced by line_print(), main(), NavierSystem::postprocess(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testCopyNodalSolutionImpl(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), PeriodicBCTest::testPeriodicBC(), 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 2280 of file system.C.

2284{
2285 // Ensuring that the given point is really in the element is an
2286 // expensive assert, but as long as debugging is turned on we might
2287 // as well try to catch a particularly nasty potential error
2288 libmesh_assert (e.contains_point(p));
2289
2290 if (!sol)
2291 sol = this->current_local_solution.get();
2292
2293 // Get the dof map to get the proper indices for our computation
2294 const DofMap & dof_map = this->get_dof_map();
2295
2296 // Make sure we can evaluate on this element.
2297 libmesh_assert (dof_map.is_evaluable(e, var));
2298
2299 // Need dof_indices for phi[i][j]
2300 std::vector<dof_id_type> dof_indices;
2301
2302 // Fill in the dof_indices for our element
2303 dof_map.dof_indices (&e, dof_indices, var);
2304
2305 // Get the no of dofs associated with this point
2306 const unsigned int num_dofs = cast_int<unsigned int>
2307 (dof_indices.size());
2308
2309 FEType fe_type = dof_map.variable_type(var);
2310
2311 // Map the physical co-ordinates to the master co-ordinates
2312 Point coor = FEMap::inverse_map(e.dim(), &e, p);
2313
2314 // get the shape function value via the FEInterface to also handle the case
2315 // of infinite elements correctly, the shape function is not fe->phi().
2316 FEComputeData fe_data(this->get_equation_systems(), coor);
2317 FEInterface::compute_data(e.dim(), fe_type, &e, fe_data);
2318
2319 // Get ready to accumulate a value
2320 Number u = 0;
2321
2322 for (unsigned int l=0; l<num_dofs; l++)
2323 {
2324 u += fe_data.shape[l] * (*sol)(dof_indices[l]);
2325 }
2326
2327 return u;
2328}

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 2332 of file system.C.

2333{
2334 libmesh_assert(e);
2335 return this->point_value(var, p, *e);
2336}

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 2340 of file system.C.

2341{
2342 return this->point_value(var, p, true, sol);
2343}

◆ 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 PoissonSystem::postprocess ( void  )
virtual

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

Reimplemented from libMesh::FEMSystem.

Definition at line 182 of file poisson.C.

183{
184 // Reset the array holding the computed QoIs
185 computed_QoI[0] = 0.0;
186
187 FEMSystem::postprocess();
188
189 this->comm().sum(computed_QoI[0]);
190}

References libMesh::ParallelObject::comm(), computed_QoI, and libMesh::Parallel::Communicator::sum().

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 2667 of file system.h.

2668{
2669 libmesh_error_msg_if(
2671 "System::prefer_hash_table_matrix_assembly() should be called before matrices are initialized");
2673}

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 1980 of file system.h.

1980{ 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 1974 of file system.h.

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

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 1969 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::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::ExodusII_IO_Helper::create(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DistributedMesh::DistributedMesh(), 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::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::LaplaceMeshSmoother::init(), 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_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), 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::MeshBase::n_constraint_rows(), 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_unique_id(), 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(), 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::testExodusFileMappings(), MeshInputTest::testExodusIGASidesets(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), 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::testTetgenIO(), MeshSmootherTest::testVariationalSmoother(), libMesh::MeshTools::total_weight(), libMesh::NetGenMeshInterface::triangulate(), libMesh::Parallel::Packing< Elem * >::unpack(), libMesh::Parallel::Packing< Node * >::unpack(), libMesh::DistributedMesh::update_parallel_id_counts(), 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 1080 of file system_projection.C.

1084{
1085 this->project_vector(*solution, f, g, /*is_adjoint=*/-1, active_local_range, variable_numbers);
1086
1087 solution->localize(*current_local_solution, _dof_map->get_send_list());
1088}
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 1065 of file system_projection.C.

1069{
1070 this->project_vector(*solution, f, g, /*is_adjoint=*/-1, active_local_range, variable_numbers);
1071
1072 solution->localize(*current_local_solution, _dof_map->get_send_list());
1073}

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(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyNodalSolutionImpl(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), 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 1049 of file system_projection.C.

1054{
1055 WrappedFunction<Number> f(*this, fptr, &function_parameters);
1056 WrappedFunction<Gradient> g(*this, gptr, &function_parameters);
1057 this->project_solution(&f, &g, active_local_range, variable_numbers);
1058}
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 884 of file system.h.

885 { 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:2294

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 267 of file system_projection.C.

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

251{
252 // Create a copy of the vector, which currently
253 // contains the old data.
254 std::unique_ptr<NumericVector<Number>>
255 old_vector (vector.clone());
256
257 // Project the old vector to the new vector
258 this->project_vector (*old_vector, vector, is_adjoint, active_local_range, variable_numbers);
259}
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 1140 of file system_projection.C.

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

1118{
1119 LOG_SCOPE ("project_vector(FunctionBase)", "System");
1120
1121 libmesh_assert(f);
1122
1123 WrappedFunctor<Number> f_fem(*f);
1124
1125 if (g)
1126 {
1127 WrappedFunctor<Gradient> g_fem(*g);
1128
1129 this->project_vector(new_vector, &f_fem, &g_fem, is_adjoint, active_local_range, variable_numbers);
1130 }
1131 else
1132 this->project_vector(new_vector, &f_fem, nullptr, is_adjoint, active_local_range, variable_numbers);
1133}

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 1095 of file system_projection.C.

1102{
1103 WrappedFunction<Number> f(*this, fptr, &function_parameters);
1104 WrappedFunction<Gradient> g(*this, gptr, &function_parameters);
1105 this->project_vector(new_vector, &f, &g, is_adjoint, active_local_range, variable_numbers);
1106}

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 983 of file system_projection.C.

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

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 432 of file system.C.

433{
434#ifdef LIBMESH_ENABLE_AMR
435 // Currently project_vector handles both restriction and prolongation
436 this->restrict_vectors();
437#endif
438}
virtual void restrict_vectors()
Restrict vectors after the mesh has coarsened.
Definition system.C:374

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:2184
NumericVector< Number > & get_adjoint_solution(unsigned int i=0)
Definition system.C:1232

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:1264
NumericVector< Number > & get_weighted_sensitivity_solution()
Definition system.C:1206

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 590 of file system.C.

593{
594 // Forward sensitivities are more efficient for Nq > Np
595 if (qoi_indices.size(*this) > parameters_vec.size())
596 forward_qoi_parameter_sensitivity(qoi_indices, parameters_vec, sensitivities);
597 // Adjoint sensitivities are more efficient for Np > Nq,
598 // and an adjoint may be more reusable than a forward
599 // solution sensitivity in the Np == Nq case.
600 else
601 adjoint_qoi_parameter_sensitivity(qoi_indices, parameters_vec, sensitivities);
602}
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:2602
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:2611

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 521 of file system.C.

522{
523 parallel_object_only();
524
525 // If this system is empty... don't do anything!
526 if (!this->n_vars())
527 return;
528
529 const std::vector<dof_id_type> & send_list = this->get_dof_map().get_send_list ();
530
531 // Check sizes
532 libmesh_assert_equal_to (current_local_solution->size(), solution->size());
533 // Not true with ghosted vectors
534 // libmesh_assert_equal_to (current_local_solution->local_size(), solution->size());
535 // libmesh_assert (!send_list.empty());
536 libmesh_assert_less_equal (send_list.size(), solution->size());
537
538 // Create current_local_solution from solution. This will
539 // put a local copy of solution into current_local_solution.
540 solution->localize (*current_local_solution, send_list);
541}
const std::vector< dof_id_type > & get_send_list() const
Definition dof_map.h:533

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 libmesh-users@lists.sourceforge.net 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}
unsigned int mesh_dimension() const
Definition mesh_base.C:430
std::vector< unsigned int > _written_var_indices
This vector is used only when reading in a system from file.
Definition system.h:2325
virtual void clear()
Clear all the data structures associated with the system.
Definition system.C:173
unsigned int variable_number(std::string_view var) const
Definition system.C:1398
unsigned int _additional_data_written
This flag is used only when reading in a system from file.
Definition system.h:2313
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 1412 of file system.h.

1414 { 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 1370 of file system.h.

1372 { 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 2126 of file system.h.

2128 { 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 1390 of file system.h.

1392 { 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:442

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 483 of file system.C.

484{
485 parallel_object_only();
486
487#ifdef LIBMESH_ENABLE_CONSTRAINTS
491 if (libMesh::on_command_line ("--print-constraints"))
493#endif
495}
void prepare_send_list()
Takes the _send_list vector (which may have duplicate entries) and sorts it.
Definition dof_map.C:1835
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:2123

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_mesh()

void libMesh::System::reinit_mesh ( )
virtualinherited

Reinitializes the system with a new mesh.

Definition at line 289 of file system.C.

290{
291 parallel_object_only();
292
293 // First initialize any required data:
294 // either only the basic System data
297 // or all the derived class' data too
298 else
299 this->init_data();
300
301 // If no variables have been added to this system
302 // don't do anything
303 if (!this->n_vars())
304 return;
305
306 // Then call the user-provided initialization function
307 this->user_initialization();
308
309}
virtual void user_initialization()
Calls user's attached initialization function, or is overridden by the user in derived classes.
Definition system.C:2095
bool _basic_system_only
Holds true if the components of more advanced system types (e.g.
Definition system.h:2300
virtual void init_data()
Initializes the data for the system.
Definition system.C:207

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 1076 of file system.C.

1077{
1078 parallel_object_only(); // Not strictly needed, but the only safe way to keep in sync
1079
1080 if (const auto pos = _matrices.find(mat_name);
1081 pos != _matrices.end())
1082 _matrices.erase(pos); // erase()'d entries are destroyed
1083}

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 861 of file system.C.

862{
863 parallel_object_only(); // Not strictly needed, but the only safe way to keep in sync
864
865 if (const auto pos = _vectors.find(vec_name);
866 pos != _vectors.end())
867 {
868 _vectors.erase(pos);
869 auto proj_it = _vector_projections.find(vec_name);
870 libmesh_assert(proj_it != _vector_projections.end());
871 _vector_projections.erase(proj_it);
872
873 auto adj_it = _vector_is_adjoint.find(vec_name);
874 libmesh_assert(adj_it != _vector_is_adjoint.end());
875 _vector_is_adjoint.erase(adj_it);
876 }
877}

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 1099 of file system.C.

1100{
1101 if (auto pos = _matrices.find(mat_name);
1102 pos != _matrices.end())
1103 return pos->second.get();
1104
1105 // Otherwise, mat_name does not exist
1106 return nullptr;
1107}

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 1087 of file system.C.

1088{
1089 if (const auto pos = _matrices.find(mat_name);
1090 pos != _matrices.end())
1091 return pos->second.get();
1092
1093 // Otherwise, mat_name does not exist
1094 return nullptr;
1095}

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 917 of file system.C.

918{
919 // If we don't have that many vectors, return nullptr
920 if (vec_num >= _vectors.size())
921 return nullptr;
922
923 // Otherwise return a pointer to the vec_num'th vector
924 auto it = vectors_begin();
925 std::advance(it, vec_num);
926 return it->second.get();
927}

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 903 of file system.C.

904{
905 // If we don't have that many vectors, return nullptr
906 if (vec_num >= _vectors.size())
907 return nullptr;
908
909 // Otherwise return a pointer to the vec_num'th vector
910 auto it = vectors_begin();
911 std::advance(it, vec_num);
912 return it->second.get();
913}

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 891 of file system.C.

892{
893 if (auto pos = _vectors.find(vec_name);
894 pos != _vectors.end())
895 return pos->second.get();
896
897 // Otherwise, vec_name was not found
898 return nullptr;
899}

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 879 of file system.C.

880{
881 if (const auto pos = _vectors.find(vec_name);
882 pos != _vectors.end())
883 return pos->second.get();
884
885 // Otherwise, vec_name was not found
886 return nullptr;
887}

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 545 of file system.C.

547{
548 if (subset != nullptr)
549 libmesh_not_implemented();
550}

◆ restrict_vectors()

void libMesh::System::restrict_vectors ( )
virtualinherited

Restrict vectors after the mesh has coarsened.

Definition at line 374 of file system.C.

375{
376 parallel_object_only();
377
378#ifdef LIBMESH_ENABLE_AMR
379 // Restrict the _vectors on the coarsened cells
380 for (auto & [vec_name, vec] : _vectors)
381 {
382 NumericVector<Number> * v = vec.get();
383
384 if (_vector_projections[vec_name])
385 {
386 this->project_vector (*v, this->vector_is_adjoint(vec_name));
387 }
388 else
389 {
390 const ParallelType type = vec->type();
391
392 if (type == GHOSTED)
393 {
394#ifdef LIBMESH_ENABLE_GHOSTED
395 vec->init (this->n_dofs(), this->n_local_dofs(),
396 _dof_map->get_send_list(), /*fast=*/false,
397 GHOSTED);
398#else
399 libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
400#endif
401 }
402 else
403 vec->init (this->n_dofs(), this->n_local_dofs(), false, type);
404 }
405 }
406
407 const std::vector<dof_id_type> & send_list = _dof_map->get_send_list ();
408
409 // Restrict the solution on the coarsened cells
411 this->project_vector (*solution);
412 // Or at least make sure the solution vector is the correct size
413 else
414 solution->init (this->n_dofs(), this->n_local_dofs(), true, PARALLEL);
415
416#ifdef LIBMESH_ENABLE_GHOSTED
417 current_local_solution->init(this->n_dofs(),
418 this->n_local_dofs(), send_list,
419 false, GHOSTED);
420#else
421 current_local_solution->init(this->n_dofs());
422#endif
423
425 solution->localize (*current_local_solution, send_list);
426
427#endif // LIBMESH_ENABLE_AMR
428}
int vector_is_adjoint(std::string_view vec_name) const
Definition system.C:1160

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().

◆ 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:1169
const SparseMatrix< Number > * request_matrix(std::string_view mat_name) const
Definition system.C:1087
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 417 of file system.h.

418 { 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 2465 of file system.h.

2466{
2467 _basic_system_only = true;
2468}

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 SolidSystem::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 SolidSystem::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 SolidSystem::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 SolidSystem::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_project_with_constraints()

void libMesh::System::set_project_with_constraints ( bool  _project_with_constraints)
inlineinherited

Definition at line 1842 of file system.h.

1843 {
1844 project_with_constraints = _project_with_constraints;
1845 }

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 2197 of file system.C.

2198{
2199 libmesh_assert_equal_to(this->_qoi.size(), new_qoi.size());
2200 this->_qoi = std::move(new_qoi);
2201}

◆ 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 1147 of file system.C.

1149{
1150 parallel_object_only(); // Not strictly needed, but the only safe way to keep in sync
1151
1152 // We reserve -1 for vectors which get primal constraints, -2 for
1153 // vectors which get no constraints
1154 libmesh_assert_greater_equal(qoi_num, -2);
1155 _vector_is_adjoint[vec_name] = qoi_num;
1156}

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 1125 of file system.C.

1127{
1128 parallel_object_only(); // Not strictly needed, but the only safe way to keep in sync
1129
1130 _vector_projections[vec_name] = preserve;
1131}

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()

virtual bool libMesh::DifferentiablePhysics::side_time_derivative ( bool  request_jacobian,
DiffContext  
)
inlinevirtualinherited

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 in SolidSystem, ElasticitySystem, ElasticitySystem, CurlCurlSystem, and CurlCurlSystem.

Definition at line 174 of file diff_physics.h.

176 {
177 return request_jacobian;
178 }

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

◆ 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 1070 of file fem_system.C.

1071{
1072 // We are solving the primal problem
1073 Parent::solve();
1074
1075 // On a moving mesh we want the mesh to reflect the new solution
1076 this->mesh_position_set();
1077}
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(), and libMesh::VariationalSmootherSystem::solve().

◆ solve_for_unconstrained_dofs()

void libMesh::System::solve_for_unconstrained_dofs ( NumericVector< Number > &  vec,
int  is_adjoint = -1 
) const
inherited

Definition at line 2103 of file system_projection.C.

2105{
2106 const DofMap & dof_map = this->get_dof_map();
2107
2108 std::unique_ptr<SparseMatrix<Number>> mat =
2110
2111 std::unique_ptr<SparsityPattern::Build> sp;
2112
2113 if (dof_map.computed_sparsity_already())
2114 dof_map.update_sparsity_pattern(*mat);
2115 else
2116 {
2117 mat->attach_dof_map(dof_map);
2118 sp = dof_map.build_sparsity(this->get_mesh());
2119 mat->attach_sparsity_pattern(*sp);
2120 }
2121
2122 mat->init();
2123
2124 libmesh_assert_equal_to(vec.size(), dof_map.n_dofs());
2125 libmesh_assert_equal_to(vec.local_size(), dof_map.n_local_dofs());
2126
2127 std::unique_ptr<NumericVector<Number>> rhs =
2129
2130 rhs->init(dof_map.n_dofs(), dof_map.n_local_dofs(), false,
2131 PARALLEL);
2132
2133 // Here we start with the unconstrained (and indeterminate) linear
2134 // system, K*u = f, where K is the identity matrix for constrained
2135 // DoFs and 0 elsewhere, and f is the current solution values for
2136 // constrained DoFs and 0 elsewhere.
2137 // We then apply the usual heterogeneous constraint matrix C and
2138 // offset h, where u = C*x + h,
2139 // to get C^T*K*C*x = C^T*f - C^T*K*h
2140 // - a constrained and no-longer-singular system that finds the
2141 // closest approximation for the unconstrained degrees of freedom.
2142 //
2143 // Here, though "closest" is in an algebraic sense; we're
2144 // effectively using a pseudoinverse that optimizes in a
2145 // discretization-dependent norm. That only seems to give ~0.1%
2146 // excess error even in coarse unit test cases, but at some point it
2147 // might be reasonable to weight K and f properly.
2148
2149 for (dof_id_type d : IntRange<dof_id_type>(dof_map.first_dof(),
2150 dof_map.end_dof()))
2151 {
2152 if (dof_map.is_constrained_dof(d))
2153 {
2154 DenseMatrix<Number> K(1,1);
2155 DenseVector<Number> F(1);
2156 std::vector<dof_id_type> dof_indices(1, d);
2157 K(0,0) = 1;
2158 F(0) = (*this->solution)(d);
2159 dof_map.heterogenously_constrain_element_matrix_and_vector
2160 (K, F, dof_indices, false, is_adjoint);
2161 mat->add_matrix(K, dof_indices);
2162 rhs->add_vector(F, dof_indices);
2163 }
2164 }
2165
2166 std::unique_ptr<LinearSolver<Number>> linear_solver =
2168
2169 linear_solver->solve(*mat, vec, *rhs,
2170 double(this->get_equation_systems().parameters.get<Real>("linear solver tolerance")),
2171 this->get_equation_systems().parameters.get<unsigned int>("linear solver maximum iterations"));
2172}
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.
const T & get(std::string_view) const
Definition parameters.h:451

References libMesh::DofMap::build_sparsity(), libMesh::DofMap::computed_sparsity_already(), libMesh::DofMapBase::end_dof(), libMesh::DofMapBase::first_dof(), libMesh::NumericVector< T >::get(), libMesh::DofMap::heterogenously_constrain_element_matrix_and_vector(), libMesh::DofMap::is_constrained_dof(), libMesh::NumericVector< T >::local_size(), libMesh::DofMap::n_dofs(), libMesh::DofMap::n_local_dofs(), 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 libMesh::ImplicitSystem::system_type ( ) const
inlineoverridevirtualinherited
Returns
"Implicit". Helps in identifying the system type in an equation system file.

Reimplemented from libMesh::ExplicitSystem.

Reimplemented in SolidSystem, libMesh::ClawSystem, libMesh::RBConstruction, libMesh::FrequencySystem, libMesh::LinearImplicitSystem, libMesh::NewmarkSystem, libMesh::NonlinearImplicitSystem, libMesh::OptimizationSystem, and libMesh::TransientSystem< RBConstruction >.

Definition at line 117 of file implicit_system.h.

117{ return "Implicit"; }

◆ 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(), init_data(), NavierSystem::init_data(), ElasticitySystem::init_data(), CurlCurlSystem::init_data(), FirstOrderScalarSystemBase::init_data(), SecondOrderScalarSystemSecondOrderTimeSolverBase::init_data(), and SigmaPhysics::init_data().

◆ update()

void libMesh::System::update ( )
virtualinherited

Update the local values to reflect the solution on neighboring processors.

Reimplemented in SolidSystem.

Definition at line 498 of file system.C.

499{
500 parallel_object_only();
501
502 libmesh_assert(solution->closed());
503
504 const std::vector<dof_id_type> & send_list = _dof_map->get_send_list ();
505
506 // Check sizes
507 libmesh_assert_equal_to (current_local_solution->size(), solution->size());
508 // More processors than elements => empty send_list
509 // libmesh_assert (!send_list.empty());
510 libmesh_assert_less_equal (send_list.size(), solution->size());
511
512 // Create current_local_solution from solution. This will
513 // put a local copy of solution into current_local_solution.
514 // Only the necessary values (specified by the send_list)
515 // are copied to minimize communication
516 solution->localize (*current_local_solution, send_list);
517}

References libMesh::System::_dof_map, libMesh::System::current_local_solution, libMesh::libmesh_assert(), and libMesh::System::solution.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::FEMSystem::assemble_qoi(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::NonlinearImplicitSystem::assembly(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::NewmarkSolver::compute_initial_accel(), LinearElasticity::compute_stresses(), LargeDeformationElasticity::compute_stresses(), LinearElasticityWithContact::compute_stresses(), compute_stresses(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), 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(), DMlibMeshFunction(), DMlibMeshJacobian(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::TransientRBConstruction::initialize_truth(), libMesh::Euler2Solver::integrate_adjoint_refinement_error_estimate(), libMesh::EulerSolver::integrate_adjoint_refinement_error_estimate(), libMesh::NewtonSolver::line_search(), libMesh::RBConstruction::load_basis_function(), libMesh::RBConstruction::load_rb_solution(), libMesh::TransientRBConstruction::load_rb_solution(), main(), libMesh::FEMSystem::mesh_position_get(), HeatSystem::perturb_accumulate_residuals(), libMesh::ErrorVector::plot_error(), libMesh::FEMSystem::postprocess(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::FileSolutionHistory::retrieve(), libMesh::MemorySolutionHistory::retrieve(), ParsedFEMFunctionTest::setUp(), libMesh::NewtonSolver::solve(), libMesh::ExplicitSystem::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::NonlinearImplicitSystem::solve(), libMesh::OptimizationSystem::solve(), libMesh::ClawSystem::solve_conservation_law(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), libMesh::DirectSolutionTransfer::transfer(), libMesh::MeshFunctionSolutionTransfer::transfer(), and update_current_local_solution().

◆ 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 733 of file system.C.

734{
735 parallel_object_only();
736
737 global_soln.resize (solution->size());
738
739 solution->localize (global_soln);
740}

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 744 of file system.C.

746{
747 parallel_object_only();
748
749 global_soln.resize (solution->size());
750
751 solution->localize_to_one (global_soln, dest_proc);
752}

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 2109 of file system.C.

2110{
2111 // Call the user-provided assembly function,
2112 // if it was provided
2113 if (_assemble_system_function != nullptr)
2115
2116 // ...or the user-provided assembly object.
2117 else if (_assemble_system_object != nullptr)
2119}
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 2123 of file system.C.

2124{
2125 // Call the user-provided constraint function,
2126 // if it was provided
2127 if (_constrain_system_function!= nullptr)
2129
2130 // ...or the user-provided constraint object.
2131 else if (_constrain_system_object != nullptr)
2133}
virtual void constrain()=0
Constraint function.

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

◆ 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 2095 of file system.C.

2096{
2097 // Call the user-provided initialization function,
2098 // if it was provided
2099 if (_init_system_function != nullptr)
2101
2102 // ...or the user-provided initialization object.
2103 else if (_init_system_object != nullptr)
2105}
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 2137 of file system.C.

2138{
2139 // Call the user-provided quantity of interest function,
2140 // if it was provided
2141 if (_qoi_evaluate_function != nullptr)
2142 this->_qoi_evaluate_function(_equation_systems, this->name(), qoi_indices);
2143
2144 // ...or the user-provided QOI function object.
2145 else if (_qoi_evaluate_object != nullptr)
2146 this->_qoi_evaluate_object->qoi(qoi_indices);
2147}
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 2151 of file system.C.

2154{
2155 // Call the user-provided quantity of interest derivative,
2156 // if it was provided
2157 if (_qoi_evaluate_derivative_function != nullptr)
2159 (_equation_systems, this->name(), qoi_indices, include_liftfunc,
2160 apply_constraints);
2161
2162 // ...or the user-provided QOI derivative function object.
2163 else if (_qoi_evaluate_derivative_object != nullptr)
2165 (qoi_indices, include_liftfunc, apply_constraints);
2166}
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 2704 of file system.C.

2705{
2706 return this->get_dof_map().variable(i);
2707}

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 2709 of file system.C.

2710{
2711 return this->get_dof_map().variable_group(vg);
2712}
const VariableGroup & variable_group(const unsigned int c) const
Definition dof_map.h:2348

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 1398 of file system.C.

1399{
1400 return this->get_dof_map().variable_number(var);
1401}
unsigned int variable_number(std::string_view var) const
Definition dof_map.h:2991

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 2474 of file system.h.

2476{
2477 return variable_scalar_number(this->variable_number(var), component);
2478}

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 2715 of file system.C.

2717{
2718 return this->get_dof_map().variable_scalar_number(var_num, component);
2719}
unsigned int variable_scalar_number(unsigned int var_num, unsigned int component) const
Definition dof_map.h:2974

◆ 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 2721 of file system.C.

2722{
2723 return this->get_dof_map().variable_type(i);
2724}

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(), 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 2726 of file system.C.

2727{
2728 return this->get_dof_map().variable_type(var);
2729}

◆ 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 1160 of file system.C.

1161{
1162 const auto it = _vector_is_adjoint.find(vec_name);
1164 return it->second;
1165}

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 982 of file system.C.

983{
984 // Linear search for a vector whose pointer matches vec_reference
985 auto it = std::find_if(vectors_begin(), vectors_end(),
986 [&vec_reference](const decltype(_vectors)::value_type & pr)
987 { return &vec_reference == pr.second.get(); });
988
989 // Before returning, make sure we didn't loop till the end and not find any match
990 libmesh_assert (it != vectors_end());
991
992 // Return the string associated with the current vector
993 return it->first;
994}
vectors_iterator vectors_end()
End of vectors container.
Definition system.h:2517

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 971 of file system.C.

972{
973 // If we don't have that many vectors, throw an error
974 libmesh_assert_less(vec_num, _vectors.size());
975
976 // Otherwise return a reference to the vec_num'th vector name
977 auto it = vectors_begin();
978 std::advance(it, vec_num);
979 return it->first;
980}

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 1135 of file system.C.

1136{
1137 if (auto it = _vector_projections.find(vec_name);
1138 it != _vector_projections.end())
1139 return it->second;
1140
1141 // vec_name was not in the map, return false
1142 return false;
1143}

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 2511 of file system.h.

2512{
2513 return _vectors.begin();
2514}

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 2523 of file system.h.

2524{
2525 return _vectors.end();
2526}

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:1252

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:1199

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:2679

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 1450 of file system.C.

1452{
1453 /* Make sure the call makes sense. */
1454 libmesh_assert_less (var_num, this->n_vars());
1455
1456 /* Get a reference to the mesh. */
1457 const MeshBase & mesh = this->get_mesh();
1458
1459 /* Check which system we are. */
1460 const unsigned int sys_num = this->number();
1461
1462 // Loop over nodes.
1463 for (const auto & node : mesh.local_node_ptr_range())
1464 {
1465 unsigned int n_comp = node->n_comp(sys_num,var_num);
1466 for (unsigned int i=0; i<n_comp; i++)
1467 {
1468 const dof_id_type index = node->dof_number(sys_num,var_num,i);
1469 v.set(index,0.0);
1470 }
1471 }
1472
1473 // Loop over elements.
1475 (mesh.active_local_element_stored_range(),
1476 [sys_num, var_num, &v](const ConstElemRange & range)
1477 {
1478 for (const Elem * elem : range)
1479 {
1480 unsigned int n_comp = elem->n_comp(sys_num,var_num);
1481 for (unsigned int i=0; i<n_comp; i++)
1482 {
1483 const dof_id_type index = elem->dof_number(sys_num,var_num,i);
1484 v.set(index,0.0);
1485 }
1486 }
1487 });
1488}

References libMesh::System::get_mesh(), mesh, libMesh::System::n_vars(), libMesh::System::number(), libMesh::Threads::parallel_for(), and libMesh::NumericVector< T >::set().

Member Data Documentation

◆ _active

bool libMesh::System::_active
privateinherited

Flag stating if the system is active or not.

Definition at line 2252 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 2313 of file system.h.

Referenced by libMesh::System::read_header(), libMesh::System::read_parallel_data(), and libMesh::System::read_serialized_data().

◆ _analytic_jacobians

bool PoissonSystem::_analytic_jacobians
protected

Definition at line 76 of file poisson.h.

Referenced by analytic_jacobians(), and element_time_derivative().

◆ _assemble_system_function

void(* libMesh::System::_assemble_system_function) (EquationSystems &es, const std::string &name)
privateinherited

Function that assembles the system.

Definition at line 2176 of file system.h.

◆ _assemble_system_object

Assembly* libMesh::System::_assemble_system_object
privateinherited

Object that assembles the system.

Definition at line 2182 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 2300 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 2187 of file system.h.

◆ _constrain_system_object

Constraint* libMesh::System::_constrain_system_object
privateinherited

Object that constrains the system.

Definition at line 2193 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 2231 of file system.h.

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

◆ _fe_family

std::string PoissonSystem::_fe_family
protected

Definition at line 72 of file poisson.h.

Referenced by fe_family(), and init_data().

◆ _fe_order

unsigned int PoissonSystem::_fe_order
protected

Definition at line 73 of file poisson.h.

Referenced by fe_order(), and init_data().

◆ _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 2338 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 2165 of file system.h.

◆ _init_system_object

Initialization* libMesh::System::_init_system_object
privateinherited

Object that initializes the system.

Definition at line 2171 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 2306 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 2287 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 2282 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 2237 of file system.h.

Referenced by libMesh::System::get_mesh(), libMesh::System::get_mesh(), and libMesh::System::reinit_constraints().

◆ _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

◆ _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 2348 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 2358 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 2367 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 2377 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 2210 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 2219 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 2198 of file system.h.

◆ _qoi_evaluate_object

QOI* libMesh::System::_qoi_evaluate_object
privateinherited

Object to compute quantities of interest.

Definition at line 2205 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 2353 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 2294 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 2242 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 2247 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 2272 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 2266 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 2325 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 2332 of file system.h.

Referenced by libMesh::System::is_adjoint_already_solved(), and libMesh::System::set_adjoint_already_solved().

◆ alpha

Real PoissonSystem::alpha
protected

Definition at line 58 of file poisson.h.

Referenced by element_postprocess(), element_time_derivative(), and init_data().

◆ 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 1609 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.

◆ computed_QoI

Number PoissonSystem::computed_QoI[1]
protected

Definition at line 65 of file poisson.h.

Referenced by element_postprocess(), get_QoI_value(), PoissonSystem(), and postprocess().

◆ 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 1667 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::VariationalSmootherSystem::assembly(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), 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::PetscNonlinearSolver< Number >::force_new_preconditioner(), 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(), SolidSystem::save_initial_mesh(), libMesh::RBConstruction::set_context_solution_vec(), 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 >::testGradU(), FETest< order, family, elem_type, CaseName >::testGradUComp(), FETest< order, family, elem_type, CaseName >::testHessU(), FETest< order, family, elem_type, CaseName >::testHessUComp(), FETest< order, family, elem_type, CaseName >::testU(), 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

◆ exact_QoI

Number PoissonSystem::exact_QoI[1]
protected

Definition at line 69 of file poisson.h.

Referenced by get_QoI_value(), and init_data().

◆ 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 1640 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(), 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 2343 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(), libMesh::VariationalSmootherSystem::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(), 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 1655 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::VariationalSmootherSystem::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(), 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(), 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::System::write_parallel_data(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::TransientRBConstruction::write_riesz_representors_to_files(), and libMesh::System::write_serialized_data().

◆ T_var

unsigned int PoissonSystem::T_var
protected

Definition at line 61 of file poisson.h.

Referenced by init_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 1677 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::UnsteadySolver::retrieve_timestep(), and libMesh::TwostepTimeSolver::solve().

◆ time_solver

std::unique_ptr<TimeSolver> libMesh::DifferentiableSystem::time_solver
inherited

◆ 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 1625 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().

◆ 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: