libMesh
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
ConstantFirstOrderODE Class Referenceabstract

Implements ODE: 2.1. More...

Inheritance diagram for ConstantFirstOrderODE:
[legend]

Public Types

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

Public Member Functions

 ConstantFirstOrderODE (EquationSystems &es, const std::string &name_in, const unsigned int number_in)
 
virtual Number F (FEMContext &, unsigned int)
 
virtual Number M (FEMContext &, unsigned int)
 
virtual Number u (Real t)
 Exact solution as a function of time t. More...
 
virtual Number F (FEMContext &context, unsigned int qp)=0
 Value of F(u) More...
 
virtual Number M (FEMContext &context, unsigned int qp)=0
 Value of M(u). More...
 
virtual void init_data () override
 Initializes the member data fields associated with the system, so that, e.g., assemble() may be used. More...
 
virtual bool element_time_derivative (bool request_jacobian, DiffContext &context) override
 Note the nonlinear residual is F(u)-M(u) More...
 
virtual bool mass_residual (bool request_jacobian, DiffContext &context) override
 Note the nonlinear residual is F(u)-M(u) More...
 
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. More...
 
virtual void solve () override
 Invokes the solver associated with the system. More...
 
void mesh_position_get ()
 Tells the FEMSystem to set the degree of freedom coefficients which should correspond to mesh nodal coordinates. More...
 
void mesh_position_set ()
 Tells the FEMSystem to set the mesh nodal coordinates which should correspond to degree of freedom coefficients. More...
 
virtual std::unique_ptr< DiffContextbuild_context () override
 Builds a FEMContext object with enough information to do evaluations on each element. More...
 
virtual void init_context (DiffContext &) override
 
virtual void postprocess () override
 Runs a postprocessing loop over all elements, and if postprocess_sides is true over all sides. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
void numerical_elem_jacobian (FEMContext &context) const
 Uses the results of multiple element_residual() calls to numerically differentiate the corresponding jacobian on an element. More...
 
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. More...
 
void numerical_nonlocal_jacobian (FEMContext &context) const
 Uses the results of multiple side_residual() calls to numerically differentiate the corresponding jacobian on nonlocal DoFs. More...
 
virtual void clear () override
 Clear all the data structures associated with the system. More...
 
virtual void reinit () override
 Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be used. More...
 
virtual void assemble () override
 Prepares matrix and rhs for matrix assembly. More...
 
virtual LinearSolver< Number > * get_linear_solver () const override
 
virtual std::pair< unsigned int, Real > get_linear_solve_parameters () const override
 
virtual void release_linear_solver (LinearSolver< Number > *) const override
 Releases a pointer to a linear solver acquired by this->get_linear_solver() More...
 
virtual std::pair< unsigned int, Real > adjoint_solve (const QoISet &qoi_indices=QoISet()) override
 This function sets the _is_adjoint boolean member of TimeSolver to true and then calls the adjoint_solve in implicit system. More...
 
virtual std::unique_ptr< DifferentiablePhysicsclone_physics () override
 We don't allow systems to be attached to each other. More...
 
virtual std::unique_ptr< DifferentiableQoIclone () override
 We don't allow systems to be attached to each other. More...
 
const DifferentiablePhysicsget_physics () const
 
DifferentiablePhysicsget_physics ()
 
void attach_physics (DifferentiablePhysics *physics_in)
 Attach external Physics object. More...
 
void swap_physics (DifferentiablePhysics *&swap_physics)
 Swap current physics object with external object. More...
 
const DifferentiableQoIget_qoi () const
 
DifferentiableQoIget_qoi ()
 
void attach_qoi (DifferentiableQoI *qoi_in)
 Attach external QoI object. More...
 
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. More...
 
TimeSolver & get_time_solver ()
 
const TimeSolver & get_time_solver () const
 Non-const version of the above. More...
 
virtual void element_postprocess (DiffContext &)
 Does any work that needs to be done on elem in a postprocessing loop. More...
 
virtual void side_postprocess (DiffContext &)
 Does any work that needs to be done on side of elem in a postprocessing loop. More...
 
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. More...
 
bool have_first_order_scalar_vars () const
 Check for any first order vars that are also belong to FEFamily::SCALAR. More...
 
bool have_second_order_scalar_vars () const
 Check for any second order vars that are also belong to FEFamily::SCALAR. More...
 
sys_typesystem ()
 
virtual void disable_cache () override
 Avoids use of any cached data that might affect any solve result. More...
 
virtual std::string system_type () const override
 
virtual void assemble_residual_derivatives (const ParameterVector &parameters) override
 Residual parameter derivative function. More...
 
virtual std::pair< unsigned int, Real > sensitivity_solve (const ParameterVector &parameters) override
 Assembles & solves the linear system(s) (dR/du)*u_p = -dR/dp, for those parameters contained within parameters. More...
 
virtual std::pair< unsigned int, Real > weighted_sensitivity_solve (const ParameterVector &parameters, const ParameterVector &weights) override
 Assembles & solves the linear system(s) (dR/du)*u_w = sum(w_p*-dR/dp), for those parameters p contained within parameters weighted by the values w_p found within weights. More...
 
virtual std::pair< unsigned int, Real > weighted_sensitivity_adjoint_solve (const ParameterVector &parameters, const ParameterVector &weights, const QoISet &qoi_indices=QoISet()) override
 Assembles & solves the linear system(s) (dR/du)^T*z_w = sum(w_p*(d^2q/dudp - d^2R/dudp*z)), for those parameters p contained within parameters, weighted by the values w_p found within weights. More...
 
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]. More...
 
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]. More...
 
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). More...
 
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]. More...
 
SparseMatrix< Number > & add_matrix (const std::string &mat_name)
 Adds the additional matrix mat_name to this system. More...
 
template<template< typename > class>
SparseMatrix< Number > & add_matrix (const std::string &mat_name)
 Adds the additional matrix mat_name to this system. More...
 
void remove_matrix (const std::string &mat_name)
 Removes the additional matrix mat_name from this system. More...
 
bool have_matrix (const std::string &mat_name) const
 
const SparseMatrix< Number > * request_matrix (const std::string &mat_name) const
 
SparseMatrix< Number > * request_matrix (const std::string &mat_name)
 
const SparseMatrix< Number > & get_matrix (const std::string &mat_name) const
 
SparseMatrix< Number > & get_matrix (const std::string &mat_name)
 
virtual unsigned int n_matrices () const override
 
void init ()
 Initializes degrees of freedom on the current mesh. More...
 
virtual void reinit_constraints ()
 Reinitializes the constraints for this system. More...
 
bool is_initialized ()
 
virtual void update ()
 Update the local values to reflect the solution on neighboring processors. More...
 
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. More...
 
bool is_adjoint_already_solved () const
 Accessor for the adjoint_already_solved boolean. More...
 
void set_adjoint_already_solved (bool setting)
 Setter for the adjoint_already_solved boolean. More...
 
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]. More...
 
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) const
 Projects arbitrary functions onto the current solution. More...
 
void project_solution (FEMFunctionBase< Number > *f, FEMFunctionBase< Gradient > *g=nullptr) const
 Projects arbitrary functions onto the current solution. More...
 
void project_solution (ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters) const
 This method projects an arbitrary function onto the solution via L2 projections and nodal interpolations on each element. More...
 
void project_vector (NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
 Projects arbitrary functions onto a vector of degree of freedom values for the current system. More...
 
void project_vector (NumericVector< Number > &new_vector, FEMFunctionBase< Number > *f, FEMFunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
 Projects arbitrary functions onto a vector of degree of freedom values for the current system. More...
 
void project_vector (ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters, NumericVector< Number > &new_vector, int is_adjoint=-1) const
 Projects arbitrary functions onto a vector of degree of freedom values for the current system. More...
 
void boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr)
 Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system. More...
 
void boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters)
 Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system. More...
 
void boundary_project_vector (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
 Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system. More...
 
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) const
 Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system. More...
 
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. More...
 
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. More...
 
const MeshBase & get_mesh () const
 
MeshBase & get_mesh ()
 
const DofMap & get_dof_map () const
 
DofMap & get_dof_map ()
 
const EquationSystems & get_equation_systems () const
 
EquationSystems & get_equation_systems ()
 
bool active () const
 
void activate ()
 Activates the system. More...
 
void deactivate ()
 Deactivates the system. More...
 
void set_basic_system_only ()
 Sets the system to be "basic only": i.e. More...
 
vectors_iterator vectors_begin ()
 Beginning of vectors container. More...
 
const_vectors_iterator vectors_begin () const
 Beginning of vectors container. More...
 
vectors_iterator vectors_end ()
 End of vectors container. More...
 
const_vectors_iterator vectors_end () const
 End of vectors container. More...
 
NumericVector< Number > & add_vector (const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
 Adds the additional vector vec_name to this system. More...
 
void remove_vector (const std::string &vec_name)
 Removes the additional vector vec_name from this system. More...
 
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. More...
 
bool have_vector (const std::string &vec_name) const
 
const NumericVector< Number > * request_vector (const std::string &vec_name) const
 
NumericVector< Number > * request_vector (const std::string &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 (const std::string &vec_name) const
 
NumericVector< Number > & get_vector (const std::string &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. More...
 
int vector_is_adjoint (const std::string &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. More...
 
bool vector_preservation (const std::string &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_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 (const std::string &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. More...
 
unsigned int add_variable (const std::string &var, const Order order=FIRST, const FEFamily=LAGRANGE, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
 Adds the variable var to the list of variables for this system. More...
 
unsigned int add_variables (const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
 Adds the variable var to the list of variables for this system. More...
 
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)
 Adds the variable var to the list of variables for this system. More...
 
const Variable & variable (unsigned int var) const
 Return a constant reference to Variable var. More...
 
const VariableGroup & variable_group (unsigned int vg) const
 Return a constant reference to VariableGroup vg. More...
 
bool has_variable (const std::string &var) const
 
const std::string & variable_name (const unsigned int i) const
 
unsigned short int variable_number (const std::string &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. More...
 
unsigned int variable_scalar_number (const std::string &var, unsigned int component) const
 
unsigned int variable_scalar_number (unsigned int var_num, unsigned int component) const
 
const FEType & variable_type (const unsigned int i) const
 
const FEType & variable_type (const std::string &var) const
 
bool identify_variable_groups () const
 
void identify_variable_groups (const bool)
 Toggle automatic VariableGroup identification. More...
 
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, const std::string &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. More...
 
void read_legacy_data (Xdr &io, const bool read_additional_data=true)
 Reads additional data, namely vectors, for this System. More...
 
template<typename ValType >
void read_serialized_data (Xdr &io, const bool read_additional_data=true)
 Reads additional data, namely vectors, for this System. More...
 
void read_serialized_data (Xdr &io, const bool read_additional_data=true)
 Non-templated version for backward compatibility. More...
 
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. More...
 
std::size_t read_serialized_vectors (Xdr &io, const std::vector< NumericVector< Number > * > &vectors) const
 Non-templated version for backward compatibility. More...
 
template<typename InValType >
void read_parallel_data (Xdr &io, const bool read_additional_data)
 Reads additional data, namely vectors, for this System. More...
 
void read_parallel_data (Xdr &io, const bool read_additional_data)
 Non-templated version for backward compatibility. More...
 
void write_header (Xdr &io, const std::string &version, const bool write_additional_data) const
 Writes the basic data header for this System. More...
 
void write_serialized_data (Xdr &io, const bool write_additional_data=true) const
 Writes additional data, namely vectors, for this System. More...
 
std::size_t write_serialized_vectors (Xdr &io, const std::vector< const NumericVector< Number > * > &vectors) const
 Serialize & write a number of identically distributed vectors. More...
 
void write_parallel_data (Xdr &io, const bool write_additional_data) const
 Writes additional data, namely vectors, for this System. More...
 
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. More...
 
void attach_init_object (Initialization &init)
 Register a user class to use to initialize the system. More...
 
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. More...
 
void attach_assemble_object (Assembly &assemble)
 Register a user object to use in assembling the system matrix and RHS. More...
 
void attach_constraint_function (void fptr(EquationSystems &es, const std::string &name))
 Register a user function for imposing constraints. More...
 
void attach_constraint_object (Constraint &constrain)
 Register a user object for imposing constraints. More...
 
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. More...
 
void attach_QOI_object (QOI &qoi)
 Register a user object for evaluating the quantities of interest, whose values should be placed in System::qoi. More...
 
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. More...
 
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. More...
 
virtual void user_initialization ()
 Calls user's attached initialization function, or is overridden by the user in derived classes. More...
 
virtual void user_assembly ()
 Calls user's attached assembly function, or is overridden by the user in derived classes. More...
 
virtual void user_constrain ()
 Calls user's attached constraint function, or is overridden by the user in derived classes. More...
 
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. More...
 
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. More...
 
virtual void re_update ()
 Re-update the local values when the mesh has changed. More...
 
virtual void restrict_vectors ()
 Restrict vectors after the mesh has coarsened. More...
 
virtual void prolong_vectors ()
 Prolong vectors after the mesh has refined. More...
 
Number current_solution (const dof_id_type global_dof_number) const
 
unsigned int n_qois () const
 Number of currently active quantities of interest. More...
 
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. More...
 
Number point_value (unsigned int var, const Point &p, const NumericVector< Number > *sol) const
 Calls the parallel version of point_value(). More...
 
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. More...
 
Gradient point_gradient (unsigned int var, const Point &p, const NumericVector< Number > *sol) const
 Calls the parallel version of point_gradient(). More...
 
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. More...
 
Tensor point_hessian (unsigned int var, const Point &p, const NumericVector< Number > *sol) const
 Calls the parallel version of point_hessian(). More...
 
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. More...
 
void zero_variable (NumericVector< Number > &v, unsigned int var_num) const
 Zeroes all dofs in v that correspond to variable number var_num. More...
 
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. More...
 
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. More...
 
virtual void init_physics (const System &sys)
 Initialize any data structures associated with the physics. More...
 
virtual bool element_constraint (bool request_jacobian, DiffContext &)
 Adds the constraint contribution on elem to elem_residual. More...
 
virtual bool side_time_derivative (bool request_jacobian, DiffContext &)
 Adds the time derivative contribution on side of elem to elem_residual. More...
 
virtual bool side_constraint (bool request_jacobian, DiffContext &)
 Adds the constraint contribution on side of elem to elem_residual. More...
 
virtual bool nonlocal_time_derivative (bool request_jacobian, DiffContext &)
 Adds any nonlocal time derivative contributions (e.g. More...
 
virtual bool nonlocal_constraint (bool request_jacobian, DiffContext &)
 Adds any nonlocal constraint contributions (e.g. More...
 
virtual void time_evolving (unsigned int var)
 Tells the DiffSystem that variable var is evolving with respect to time. More...
 
virtual void time_evolving (unsigned int var, unsigned int order)
 Tells the DiffSystem that variable var is evolving with respect to time. More...
 
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. More...
 
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. More...
 
virtual bool side_mass_residual (bool request_jacobian, DiffContext &)
 Subtracts a mass vector contribution on side of elem from elem_residual. More...
 
virtual bool nonlocal_mass_residual (bool request_jacobian, DiffContext &c)
 Subtracts any nonlocal mass vector contributions (e.g. More...
 
virtual bool damping_residual (bool request_jacobian, DiffContext &)
 Subtracts a damping vector contribution on elem from elem_residual. More...
 
virtual bool side_damping_residual (bool request_jacobian, DiffContext &)
 Subtracts a damping vector contribution on side of elem from elem_residual. More...
 
virtual bool nonlocal_damping_residual (bool request_jacobian, DiffContext &)
 Subtracts any nonlocal damping vector contributions (e.g. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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 (std::vector< Number > &)
 Initialize system qoi. More...
 
virtual void clear_qoi ()
 Clear all the data structures associated with the QoI. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
virtual void thread_join (std::vector< Number > &qoi, const std::vector< Number > &other_qoi, const QoISet &qoi_indices)
 Method to combine thread-local qois. More...
 
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. More...
 
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. More...
 

Static Public Member Functions

static std::string get_info ()
 Gets a string containing the reference information. More...
 
static void print_info (std::ostream &out=libMesh::out)
 Prints the reference information, by default to libMesh::out. More...
 
static unsigned int n_objects ()
 Prints the number of outstanding (created, but not yet destroyed) objects. More...
 
static void enable_print_counter_info ()
 Methods to enable/disable the reference counter output from print_info() More...
 
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. More...
 
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. More...
 
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. More...
 
std::unique_ptr< TimeSolver > time_solver
 A pointer to the solver object we're going to use. More...
 
Real deltat
 For time-dependent problems, this is the amount delta t to advance the solution in time. More...
 
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. More...
 
bool print_solution_norms
 Set print_residual_norms to true to print |U| whenever it is used in an assembly() call. More...
 
bool print_solutions
 Set print_solutions to true to print U whenever it is used in an assembly() call. More...
 
bool print_residual_norms
 Set print_residual_norms to true to print |F| whenever it is assembled. More...
 
bool print_residuals
 Set print_residuals to true to print F whenever it is assembled. More...
 
bool print_jacobian_norms
 Set print_jacobian_norms to true to print |J| whenever it is assembled. More...
 
bool print_jacobians
 Set print_jacobians to true to print J whenever it is assembled. More...
 
bool print_element_solutions
 Set print_element_solutions to true to print each U_elem input. More...
 
bool print_element_residuals
 Set print_element_residuals to true to print each R_elem contribution. More...
 
bool print_element_jacobians
 Set print_element_jacobians to true to print each J_elem contribution. More...
 
SparseMatrix< Number > * matrix
 The system matrix. More...
 
bool zero_out_matrix_and_rhs
 By default, the system will zero out the matrix and the right hand side. More...
 
NumericVector< Number > * rhs
 The system matrix. More...
 
bool assemble_before_solve
 Flag which tells the system to whether or not to call the user assembly function during each call to solve(). More...
 
bool use_fixed_solution
 A boolean to be set to true by systems using elem_fixed_solution, for optional use by e.g. More...
 
int extra_quadrature_order
 A member int that can be employed to indicate increased or reduced quadrature order. More...
 
std::unique_ptr< NumericVector< Number > > solution
 Data structure to hold solution values. More...
 
std::unique_ptr< NumericVector< Number > > current_local_solution
 All the values I need to compute my contribution to the simulation at hand. More...
 
Real time
 For time-dependent problems, this is the time t at the beginning of the current timestep. More...
 
std::vector< Number > qoi
 Values of the quantities of interest. More...
 
bool compute_internal_sides
 compute_internal_sides is false by default, indicating that side_* computations will only be done on boundary sides. More...
 
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. More...
 
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. More...
 
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. More...
 

Protected Types

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

Protected Member Functions

void add_second_order_dot_vars ()
 Helper function to add "velocity" variables that are cousins to second order-in-time variables in the DifferentiableSystem. More...
 
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. More...
 
virtual void init_matrices ()
 Initializes the matrices associated with this system. More...
 
void project_vector (NumericVector< Number > &, int is_adjoint=-1) const
 Projects the vector defined on the old mesh onto the new mesh. More...
 
void project_vector (const NumericVector< Number > &, NumericVector< Number > &, int is_adjoint=-1) const
 Projects the vector defined on the old mesh onto the new mesh. More...
 
void increment_constructor_count (const std::string &name)
 Increments the construction counter. More...
 
void increment_destructor_count (const std::string &name)
 Increments the destruction counter. More...
 

Protected Attributes

unsigned int _u_var
 
DifferentiablePhysics_diff_physics
 Pointer to object to use for physics assembly evaluations. More...
 
DifferentiableQoIdiff_qoi
 Pointer to object to use for quantity of interest assembly evaluations. More...
 
const Parallel::Communicator & _communicator
 
System_mesh_sys
 System from which to acquire moving mesh information. More...
 
unsigned int _mesh_x_var
 Variables from which to acquire moving mesh information. More...
 
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). More...
 
std::set< unsigned int_first_order_vars
 Variable indices for those variables that are first order in time. More...
 
std::set< unsigned int_second_order_vars
 Variable indices for those variables that are second order in time. More...
 
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. More...
 

Static Protected Attributes

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

Private Member Functions

void add_system_matrix ()
 Add the system matrix to the _matrices data structure. More...
 
void add_system_rhs ()
 Add the system right-hand-side vector to the _vectors data structure. More...
 
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. More...
 
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. More...
 
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. More...
 
template<typename InValType >
numeric_index_type read_serialized_vector (Xdr &io, NumericVector< Number > *vec)
 Reads a vector for this System. More...
 
numeric_index_type read_serialized_vector (Xdr &io, NumericVector< Number > &vec)
 Non-templated version for backward compatibility. More...
 
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. More...
 
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. More...
 
dof_id_type write_serialized_vector (Xdr &io, const NumericVector< Number > &vec) const
 Writes a vector for this System. More...
 

Private Attributes

std::vector< Real > _numerical_jacobian_h_for_var
 
std::map< std::string, SparseMatrix< Number > * > _matrices
 Some systems need an arbitrary number of matrices. More...
 
bool _can_add_matrices
 true when additional matrices may still be added, false otherwise. More...
 
void(* _init_system_function )(EquationSystems &es, const std::string &name)
 Function that initializes the system. More...
 
Initialization_init_system_object
 Object that initializes the system. More...
 
void(* _assemble_system_function )(EquationSystems &es, const std::string &name)
 Function that assembles the system. More...
 
Assembly_assemble_system_object
 Object that assembles the system. More...
 
void(* _constrain_system_function )(EquationSystems &es, const std::string &name)
 Function to impose constraints. More...
 
Constraint_constrain_system_object
 Object that constrains the system. More...
 
void(* _qoi_evaluate_function )(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
 Function to evaluate quantity of interest. More...
 
QOI_qoi_evaluate_object
 Object to compute quantities of interest. More...
 
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. More...
 
QOIDerivative_qoi_evaluate_derivative_object
 Object to compute derivatives of quantities of interest. More...
 
std::unique_ptr< DofMap > _dof_map
 Data structure describing the relationship between nodes, variables, etc... More...
 
EquationSystems & _equation_systems
 Constant reference to the EquationSystems object used for the simulation. More...
 
MeshBase & _mesh
 Constant reference to the mesh data structure used for the simulation. More...
 
const std::string _sys_name
 A name associated with this system. More...
 
const unsigned int _sys_number
 The number associated with this system. More...
 
std::vector< Variable > _variables
 The Variable in this System. More...
 
std::vector< VariableGroup > _variable_groups
 The VariableGroup in this System. More...
 
std::map< std::string, unsigned short int_variable_numbers
 The variable numbers corresponding to user-specified names, useful for name-based lookups. More...
 
bool _active
 Flag stating if the system is active or not. More...
 
std::map< std::string, NumericVector< Number > * > _vectors
 Some systems need an arbitrary number of vectors. More...
 
std::map< std::string, bool > _vector_projections
 Holds true if a vector by that name should be projected onto a changed grid, false if it should be zeroed. More...
 
std::map< std::string, int_vector_is_adjoint
 Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs, -1 if primal. More...
 
std::map< std::string, ParallelType > _vector_types
 Holds the type of a vector. More...
 
bool _solution_projection
 Holds true if the solution vector should be projected onto a changed grid, false if it should be zeroed. More...
 
bool _basic_system_only
 Holds true if the components of more advanced system types (e.g. More...
 
bool _is_initialized
 true when additional vectors and variables do not require immediate initialization, false otherwise. More...
 
bool _identify_variable_groups
 true when VariableGroup structures should be automatically identified, false otherwise. More...
 
unsigned int _additional_data_written
 This flag is used only when reading in a system from file. More...
 
std::vector< unsigned int_written_var_indices
 This vector is used only when reading in a system from file. More...
 
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. More...
 
bool _hide_output
 Are we allowed to write this system to file? If _hide_output is true, then EquationSystems::write will ignore this system. More...
 

Detailed Description

Implements ODE: 2.1.

{u} = 5, u(0) = 0;

Definition at line 13 of file first_order_unsteady_solver_test.C.

Member Typedef Documentation

◆ const_matrices_iterator

typedef std::map<std::string, SparseMatrix<Number> *>::const_iterator libMesh::ImplicitSystem::const_matrices_iterator
inherited

Definition at line 307 of file implicit_system.h.

◆ const_vectors_iterator

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

Definition at line 757 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 117 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 532 of file system.h.

◆ matrices_iterator

typedef std::map<std::string, SparseMatrix<Number> *>::iterator libMesh::ImplicitSystem::matrices_iterator
inherited

Matrix iterator typedefs.

Definition at line 306 of file implicit_system.h.

◆ Parent

The type of the parent.

Definition at line 79 of file fem_system.h.

◆ sys_type

The type of system.

Definition at line 74 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 214 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 528 of file system.h.

◆ vectors_iterator

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

Vector iterator typedefs.

Definition at line 756 of file system.h.

Constructor & Destructor Documentation

◆ ConstantFirstOrderODE()

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

Definition at line 16 of file first_order_unsteady_solver_test.C.

19  : FirstOrderScalarSystemBase(es, name_in, number_in)
20  {}

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 102 of file diff_physics.C.

104 {
105  // For any problem we need time derivative terms
106  request_jacobian =
107  this->element_time_derivative(request_jacobian, context);
108 
109  // For a moving mesh problem we may need the pseudoconvection term too
110  return this->eulerian_residual(request_jacobian, context) &&
111  request_jacobian;
112 }

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

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

◆ activate()

void libMesh::System::activate ( )
inlineinherited

Activates the system.

Only active systems are solved.

Definition at line 2123 of file system.h.

2124 {
2125  _active = true;
2126 }

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

2116 {
2117  return _active;
2118 }

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

1010 {
1011  std::ostringstream adjoint_rhs_name;
1012  adjoint_rhs_name << "adjoint_rhs" << i;
1013 
1014  return this->add_vector(adjoint_rhs_name.str(), false);
1015 }

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

946 {
947  std::ostringstream adjoint_name;
948  adjoint_name << "adjoint_solution" << i;
949 
950  NumericVector<Number> & returnval = this->add_vector(adjoint_name.str());
951  this->set_vector_as_adjoint(adjoint_name.str(), i);
952  return returnval;
953 }

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 230 of file diff_system.C.

232 {
233  // We're assuming that there could be a lot more variables than
234  // boundary conditions, so we search each of the boundary conditions
235  // for this variable rather than looping over boundary conditions
236  // in a separate loop and searching through all the variables.
237  const DirichletBoundaries * all_dbcs =
239 
240  if (all_dbcs)
241  {
242  // We need to cache the DBCs to be added so that we add them
243  // after looping over the existing DBCs. Otherwise, we're polluting
244  // the thing we're looping over.
245  std::vector<DirichletBoundary *> new_dbcs;
246 
247  for (const auto & dbc : *all_dbcs)
248  {
249  libmesh_assert(dbc);
250 
251  // Look for second order variable in the current
252  // DirichletBoundary object
253  std::vector<unsigned int>::const_iterator dbc_var_it =
254  std::find( dbc->variables.begin(), dbc->variables.end(), var_idx );
255 
256  // If we found it, then we also need to add it's corresponding
257  // "dot" variable to a DirichletBoundary
258  std::vector<unsigned int> vars_to_add;
259  if (dbc_var_it != dbc->variables.end())
260  vars_to_add.push_back(dot_var_idx);
261 
262  if (!vars_to_add.empty())
263  {
264  // We need to check if the boundary condition is time-dependent.
265  // Currently, we cannot automatically differentiate w.r.t. time
266  // so if the user supplies a time-dependent Dirichlet BC, then
267  // we can't automatically support the Dirichlet BC for the
268  // "velocity" boundary condition, so we error. Otherwise,
269  // the "velocity boundary condition will just be zero.
270  bool is_time_evolving_bc = false;
271  if (dbc->f)
272  is_time_evolving_bc = dbc->f->is_time_dependent();
273  else if (dbc->f_fem)
274  // We it's a FEMFunctionBase object, it will be implicitly
275  // time-dependent since it is assumed to depend on the solution.
276  is_time_evolving_bc = true;
277  else
278  libmesh_error_msg("Could not find valid boundary function!");
279 
280  if (is_time_evolving_bc)
281  libmesh_error_msg("Cannot currently support time-dependent Dirichlet BC for dot variables!");
282 
283 
284  DirichletBoundary * new_dbc;
285 
286  if (dbc->f)
287  {
288  ZeroFunction<Number> zf;
289 
290  new_dbc = new DirichletBoundary(dbc->b, vars_to_add, zf);
291  }
292  else
293  libmesh_error();
294 
295  new_dbcs.push_back(new_dbc);
296  }
297  }
298 
299  // Let the DofMap make its own deep copy of the DirichletBC objects and delete our copy.
300  for (const auto & dbc : new_dbcs)
301  {
302  this->get_dof_map().add_dirichlet_boundary(*dbc);
303  delete dbc;
304  }
305 
306  } // if (all_dbcs)
307 }

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

SparseMatrix< Number > & libMesh::ImplicitSystem::add_matrix ( const std::string &  mat_name)
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 mayor 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

Definition at line 202 of file implicit_system.C.

203 {
204  // only add matrices before initializing...
205  if (!_can_add_matrices)
206  libmesh_error_msg("ERROR: Too late. Cannot add matrices to the system after initialization"
207  << "\n any more. You should have done this earlier.");
208 
209  // Return the matrix if it is already there.
210  if (this->have_matrix(mat_name))
211  return *(_matrices[mat_name]);
212 
213  // Otherwise build the matrix and return it.
214  SparseMatrix<Number> * buf = SparseMatrix<Number>::build(this->comm()).release();
215  _matrices.insert (std::make_pair (mat_name, buf));
216 
217  return *buf;
218 }

References libMesh::ImplicitSystem::_can_add_matrices, libMesh::ImplicitSystem::_matrices, libMesh::SparseMatrix< T >::build(), libMesh::ParallelObject::comm(), and libMesh::ImplicitSystem::have_matrix().

Referenced by libMesh::ImplicitSystem::add_system_matrix(), libMesh::EigenTimeSolver::init(), main(), and libMesh::NewmarkSystem::NewmarkSystem().

◆ add_matrix() [2/2]

template<template< typename > class MatrixType>
SparseMatrix< Number > & libMesh::ImplicitSystem::add_matrix ( const std::string &  mat_name)
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 mayor 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

Definition at line 454 of file implicit_system.h.

455 {
456  // only add matrices before initializing...
457  if (!_can_add_matrices)
458  libmesh_error_msg("ERROR: Too late. Cannot add matrices to the system after initialization"
459  << "\n any more. You should have done this earlier.");
460 
461  // Return the matrix if it is already there.
462  if (this->have_matrix(mat_name))
463  return *(_matrices[mat_name]);
464 
465  // Otherwise build the matrix and return it.
466  SparseMatrix<Number> * buf = libmesh_make_unique<MatrixType<Number>>(this->comm()).release();
467  _matrices.insert (std::make_pair (mat_name, buf));
468 
469  return *buf;
470 }

References libMesh::ImplicitSystem::_can_add_matrices, libMesh::ImplicitSystem::_matrices, libMesh::ParallelObject::comm(), and libMesh::ImplicitSystem::have_matrix().

◆ 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 198 of file diff_system.C.

199 {
200  const std::set<unsigned int> & second_order_vars = this->get_second_order_vars();
201  if (!second_order_vars.empty())
202  {
203  for (const auto & var_id : second_order_vars)
204  {
205  const Variable & var = this->variable(var_id);
206  std::string new_var_name = std::string("dot_")+var.name();
207 
208  unsigned int v_var_idx;
209 
210  if (var.active_subdomains().empty())
211  v_var_idx = this->add_variable( new_var_name, var.type() );
212  else
213  v_var_idx = this->add_variable( new_var_name, var.type(), &var.active_subdomains() );
214 
215  _second_order_dot_vars.insert(std::pair<unsigned int, unsigned int>(var_id, v_var_idx));
216 
217  // The new velocities are time evolving variables of first order
218  this->time_evolving( v_var_idx, 1 );
219 
220 #ifdef LIBMESH_ENABLE_DIRICHLET
221  // And if there are any boundary conditions set on the second order
222  // variable, we also need to set it on its velocity variable.
223  this->add_dot_var_dirichlet_bcs(var_id, v_var_idx);
224 #endif
225  }
226  }
227 }

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

1040 {
1041  std::ostringstream sensitivity_rhs_name;
1042  sensitivity_rhs_name << "sensitivity_rhs" << i;
1043 
1044  return this->add_vector(sensitivity_rhs_name.str(), false);
1045 }

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

895 {
896  std::ostringstream sensitivity_name;
897  sensitivity_name << "sensitivity_solution" << i;
898 
899  return this->add_vector(sensitivity_name.str());
900 }

References libMesh::System::add_vector().

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

◆ add_system_matrix()

void libMesh::ImplicitSystem::add_system_matrix ( )
privateinherited

Add the system matrix to the _matrices data structure.

Useful in initialization.

Definition at line 276 of file implicit_system.C.

277 {
278  // Possible that we cleared the _matrices but
279  // forgot to update the matrix pointer?
280  if (_matrices.empty())
281  matrix = nullptr;
282 
283  // Only need to add the matrix if it isn't there
284  // already!
285  if (matrix == nullptr)
286  matrix = &(this->add_matrix ("System Matrix"));
287 
289 }

References libMesh::ImplicitSystem::_matrices, libMesh::ImplicitSystem::add_matrix(), libMesh::libmesh_assert(), and libMesh::ImplicitSystem::matrix.

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

◆ 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 96 of file explicit_system.C.

97 {
98  // Possible that we cleared the _vectors but
99  // forgot to update the rhs pointer?
100  if (this->n_vectors() == 0)
101  rhs = nullptr;
102 
103 
104  // Only need to add the rhs if it isn't there
105  // already!
106  if (rhs == nullptr)
107  rhs = &(this->add_vector ("RHS Vector", false));
108 
110 }

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 ( const std::string &  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 1069 of file system.C.

1072 {
1073  libmesh_assert(!this->is_initialized());
1074 
1075  // Make sure the variable isn't there already
1076  // or if it is, that it's the type we want
1077  for (auto v : IntRange<unsigned int>(0, this->n_vars()))
1078  if (this->variable_name(v) == var)
1079  {
1080  if (this->variable_type(v) == type)
1081  return _variables[v].number();
1082 
1083  libmesh_error_msg("ERROR: incompatible variable " << var << " has already been added for this system!");
1084  }
1085 
1086  // Optimize for VariableGroups here - if the user is adding multiple
1087  // variables of the same FEType and subdomain restriction, catch
1088  // that here and add them as members of the same VariableGroup.
1089  //
1090  // start by setting this flag to whatever the user has requested
1091  // and then consider the conditions which should negate it.
1092  bool should_be_in_vg = this->identify_variable_groups();
1093 
1094  // No variable groups, nothing to add to
1095  if (!this->n_variable_groups())
1096  should_be_in_vg = false;
1097 
1098  else
1099  {
1100  VariableGroup & vg(_variable_groups.back());
1101 
1102  // get a pointer to their subdomain restriction, if any.
1103  const std::set<subdomain_id_type> * const
1104  their_active_subdomains (vg.implicitly_active() ?
1105  nullptr : &vg.active_subdomains());
1106 
1107  // Different types?
1108  if (vg.type() != type)
1109  should_be_in_vg = false;
1110 
1111  // they are restricted, we aren't?
1112  if (their_active_subdomains &&
1113  (!active_subdomains || (active_subdomains && active_subdomains->empty())))
1114  should_be_in_vg = false;
1115 
1116  // they aren't restricted, we are?
1117  if (!their_active_subdomains && (active_subdomains && !active_subdomains->empty()))
1118  should_be_in_vg = false;
1119 
1120  if (their_active_subdomains && active_subdomains)
1121  // restricted to different sets?
1122  if (*their_active_subdomains != *active_subdomains)
1123  should_be_in_vg = false;
1124 
1125  // OK, after all that, append the variable to the vg if none of the conditions
1126  // were violated
1127  if (should_be_in_vg)
1128  {
1129  const unsigned short curr_n_vars = cast_int<unsigned short>
1130  (this->n_vars());
1131 
1132  vg.append (var);
1133 
1134  _variables.push_back(vg(vg.n_variables()-1));
1135  _variable_numbers[var] = curr_n_vars;
1136  return curr_n_vars;
1137  }
1138  }
1139 
1140  // otherwise, fall back to adding a single variable group
1141  return this->add_variables (std::vector<std::string>(1, var),
1142  type,
1143  active_subdomains);
1144 }

References libMesh::System::_variable_groups, libMesh::System::_variable_numbers, libMesh::System::_variables, libMesh::System::add_variables(), libMesh::System::identify_variable_groups(), libMesh::System::is_initialized(), libMesh::libmesh_assert(), libMesh::System::n_variable_groups(), libMesh::System::n_vars(), libMesh::System::variable_name(), and libMesh::System::variable_type().

Referenced by libMesh::DifferentiableSystem::add_second_order_dot_vars(), libMesh::System::add_variable(), assemble_and_solve(), OverlappingTestBase::init(), SolidSystem::init_data(), CurlCurlSystem::init_data(), HeatSystem::init_data(), SimpleRBConstruction::init_data(), main(), libMesh::ErrorVector::plot_error(), libMesh::System::read_header(), RationalMapTest< elem_type >::setUp(), FETest< order, family, elem_type >::setUp(), SlitMeshRefinedSystemTest::setUp(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), SystemsTest::testAssemblyWithDgFemContext(), SystemsTest::testBlockRestrictedVarNDofs(), SystemsTest::testBoundaryProjectCube(), DofMapTest::testConstraintLoopDetection(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), SystemsTest::testDofCouplingWithVarGroups(), DofMapTest::testDofOwner(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusCopyElementSolution(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), EquationSystemsTest::testPostInitAddElem(), EquationSystemsTest::testPostInitAddRealSystem(), SystemsTest::testProjectCubeWithMeshFunction(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), EquationSystemsTest::testRefineThenReinitPreserveFlags(), EquationSystemsTest::testReinitWithNodeElem(), EquationSystemsTest::testRepartitionThenReinit(), BoundaryInfoTest::testShellFaceConstraints(), and WriteVecAndScalar::testWrite().

◆ add_variable() [2/2]

unsigned int libMesh::System::add_variable ( const std::string &  var,
const Order  order = FIRST,
const FEFamily  family = LAGRANGE,
const std::set< subdomain_id_type > *const  active_subdomains = nullptr 
)
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

Definition at line 1148 of file system.C.

1152 {
1153  return this->add_variable(var,
1154  FEType(order, family),
1155  active_subdomains);
1156 }

References libMesh::System::add_variable().

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

1163 {
1164  libmesh_assert(!this->is_initialized());
1165 
1166  // Make sure the variable isn't there already
1167  // or if it is, that it's the type we want
1168  for (auto ovar : vars)
1169  for (auto v : IntRange<unsigned int>(0, this->n_vars()))
1170  if (this->variable_name(v) == ovar)
1171  {
1172  if (this->variable_type(v) == type)
1173  return _variables[v].number();
1174 
1175  libmesh_error_msg("ERROR: incompatible variable " << ovar << " has already been added for this system!");
1176  }
1177 
1178  const unsigned short curr_n_vars = cast_int<unsigned short>
1179  (this->n_vars());
1180 
1181  const unsigned int next_first_component = this->n_components();
1182 
1183  // Add the variable group to the list
1184  _variable_groups.push_back((active_subdomains == nullptr) ?
1185  VariableGroup(this, vars, curr_n_vars,
1186  next_first_component, type) :
1187  VariableGroup(this, vars, curr_n_vars,
1188  next_first_component, type, *active_subdomains));
1189 
1190  const VariableGroup & vg (_variable_groups.back());
1191 
1192  // Add each component of the group individually
1193  for (auto v : IntRange<unsigned int>(0, vars.size()))
1194  {
1195  _variables.push_back (vg(v));
1196  _variable_numbers[vars[v]] = cast_int<unsigned short>
1197  (curr_n_vars+v);
1198  }
1199 
1200  libmesh_assert_equal_to ((curr_n_vars+vars.size()), this->n_vars());
1201 
1202  // BSK - Defer this now to System::init_data() so we can detect
1203  // VariableGroups 12/28/2012
1204  // // Add the variable group to the _dof_map
1205  // _dof_map->add_variable_group (vg);
1206 
1207  // Return the number of the new variable
1208  return cast_int<unsigned int>(curr_n_vars+vars.size()-1);
1209 }

References libMesh::System::_variable_groups, libMesh::System::_variable_numbers, libMesh::System::_variables, libMesh::System::is_initialized(), libMesh::libmesh_assert(), libMesh::System::n_components(), libMesh::System::n_vars(), libMesh::System::variable_name(), and libMesh::System::variable_type().

Referenced by libMesh::System::add_variable(), and libMesh::System::add_variables().

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

Definition at line 1213 of file system.C.

1217 {
1218  return this->add_variables(vars,
1219  FEType(order, family),
1220  active_subdomains);
1221 }

References libMesh::System::add_variables().

◆ add_vector()

NumericVector< Number > & libMesh::System::add_vector ( const std::string &  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

Definition at line 661 of file system.C.

664 {
665  // Return the vector if it is already there.
666  if (this->have_vector(vec_name))
667  return *(_vectors[vec_name]);
668 
669  // Otherwise build the vector
670  NumericVector<Number> * buf = NumericVector<Number>::build(this->comm()).release();
671  _vectors.insert (std::make_pair (vec_name, buf));
672  _vector_projections.insert (std::make_pair (vec_name, projections));
673 
674  _vector_types.insert (std::make_pair (vec_name, type));
675 
676  // Vectors are primal by default
677  _vector_is_adjoint.insert (std::make_pair (vec_name, -1));
678 
679  // Initialize it if necessary
680  if (_is_initialized)
681  {
682  if (type == GHOSTED)
683  {
684 #ifdef LIBMESH_ENABLE_GHOSTED
685  buf->init (this->n_dofs(), this->n_local_dofs(),
686  _dof_map->get_send_list(), false,
687  GHOSTED);
688 #else
689  libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
690 #endif
691  }
692  else
693  buf->init (this->n_dofs(), this->n_local_dofs(), false, type);
694  }
695 
696  return *buf;
697 }

References libMesh::System::_dof_map, libMesh::System::_is_initialized, libMesh::System::_vector_is_adjoint, libMesh::System::_vector_projections, libMesh::System::_vector_types, libMesh::System::_vectors, libMesh::NumericVector< T >::build(), libMesh::ParallelObject::comm(), libMesh::GHOSTED, libMesh::System::have_vector(), libMesh::NumericVector< T >::init(), libMesh::System::n_dofs(), and libMesh::System::n_local_dofs().

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(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::SecondOrderUnsteadySolver::init(), libMesh::UnsteadySolver::init(), libMesh::OptimizationSystem::init_data(), libMesh::ContinuationSystem::init_data(), main(), libMesh::NewmarkSystem::NewmarkSystem(), libMesh::System::read_header(), libMesh::FrequencySystem::set_frequencies(), libMesh::FrequencySystem::set_frequencies_by_range(), and libMesh::FrequencySystem::set_frequencies_by_steps().

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

978 {
979  std::ostringstream adjoint_name;
980  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
981 
982  NumericVector<Number> & returnval = this->add_vector(adjoint_name.str());
983  this->set_vector_as_adjoint(adjoint_name.str(), i);
984  return returnval;
985 }

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

925 {
926  return this->add_vector("weighted_sensitivity_solution");
927 }

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 686 of file implicit_system.C.

689 {
690  ParameterVector & parameters =
691  const_cast<ParameterVector &>(parameters_in);
692 
693  const unsigned int Np = cast_int<unsigned int>
694  (parameters.size());
695  const unsigned int Nq = this->n_qois();
696 
697  // An introduction to the problem:
698  //
699  // Residual R(u(p),p) = 0
700  // partial R / partial u = J = system matrix
701  //
702  // This implies that:
703  // d/dp(R) = 0
704  // (partial R / partial p) +
705  // (partial R / partial u) * (partial u / partial p) = 0
706 
707  // We first do an adjoint solve:
708  // J^T * z = (partial q / partial u)
709  // if we havent already or dont have an initial condition for the adjoint
710  if (!this->is_adjoint_already_solved())
711  {
712  this->adjoint_solve(qoi_indices);
713  }
714 
715  this->assemble_residual_derivatives(parameters_in);
716 
717  // Get ready to fill in sensitivities:
718  sensitivities.allocate_data(qoi_indices, *this, parameters);
719 
720  // We use the identities:
721  // dq/dp = (partial q / partial p) + (partial q / partial u) *
722  // (partial u / partial p)
723  // dq/dp = (partial q / partial p) + (J^T * z) *
724  // (partial u / partial p)
725  // dq/dp = (partial q / partial p) + z * J *
726  // (partial u / partial p)
727 
728  // Leading to our final formula:
729  // dq/dp = (partial q / partial p) - z * (partial R / partial p)
730 
731  // In the case of adjoints with heterogenous Dirichlet boundary
732  // function phi, where
733  // q := S(u) - R(u,phi)
734  // the final formula works out to:
735  // dq/dp = (partial S / partial p) - z * (partial R / partial p)
736  // Because we currently have no direct access to
737  // (partial S / partial p), we use the identity
738  // (partial S / partial p) = (partial q / partial p) +
739  // phi * (partial R / partial p)
740  // to derive an equivalent equation:
741  // dq/dp = (partial q / partial p) - (z-phi) * (partial R / partial p)
742 
743  // Since z-phi degrees of freedom are zero for constrained indices,
744  // we can use the same constrained -(partial R / partial p) that we
745  // use for forward sensitivity solves, taking into account the
746  // differing sign convention.
747  //
748  // Since that vector is constrained, its constrained indices are
749  // zero, so its product with phi is zero, so we can neglect the
750  // evaluation of phi terms.
751 
752  for (unsigned int j=0; j != Np; ++j)
753  {
754  // We currently get partial derivatives via central differencing
755 
756  // (partial q / partial p) ~= (q(p+dp)-q(p-dp))/(2*dp)
757  // (partial R / partial p) ~= (rhs(p+dp) - rhs(p-dp))/(2*dp)
758 
759  Number old_parameter = *parameters[j];
760 
761  const Real delta_p =
762  TOLERANCE * std::max(std::abs(old_parameter), 1e-3);
763 
764  *parameters[j] = old_parameter - delta_p;
765  this->assemble_qoi(qoi_indices);
766  std::vector<Number> qoi_minus = this->qoi;
767 
768  NumericVector<Number> & neg_partialR_partialp = this->get_sensitivity_rhs(j);
769 
770  *parameters[j] = old_parameter + delta_p;
771  this->assemble_qoi(qoi_indices);
772  std::vector<Number> & qoi_plus = this->qoi;
773 
774  std::vector<Number> partialq_partialp(Nq, 0);
775  for (unsigned int i=0; i != Nq; ++i)
776  if (qoi_indices.has_index(i))
777  partialq_partialp[i] = (qoi_plus[i] - qoi_minus[i]) / (2.*delta_p);
778 
779  // Don't leave the parameter changed
780  *parameters[j] = old_parameter;
781 
782  for (unsigned int i=0; i != Nq; ++i)
783  if (qoi_indices.has_index(i))
784  sensitivities[i][j] = partialq_partialp[i] +
785  neg_partialR_partialp.dot(this->get_adjoint_solution(i));
786  }
787 
788  // All parameters have been reset.
789  // Reset the original qoi.
790 
791  this->assemble_qoi(qoi_indices);
792 }

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

Referenced by 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 164 of file diff_system.C.

165 {
166  // Get the time solver object associated with the system, and tell it that
167  // we are solving the adjoint problem
168  this->get_time_solver().set_is_adjoint(true);
169 
170  return this->ImplicitSystem::adjoint_solve(qoi_indices);
171 }

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

Referenced by main().

◆ assemble()

void libMesh::DifferentiableSystem::assemble ( )
overridevirtualinherited

Prepares matrix and rhs for matrix assembly.

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

Reimplemented from libMesh::ImplicitSystem.

Definition at line 145 of file diff_system.C.

146 {
147  this->assembly(true, true);
148 }

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

1118 {
1119  LOG_SCOPE("assemble_qoi()", "FEMSystem");
1120 
1121  const MeshBase & mesh = this->get_mesh();
1122 
1123  this->update();
1124 
1125  const unsigned int Nq = this->n_qois();
1126 
1127  // the quantity of interest is assumed to be a sum of element and
1128  // side terms
1129  for (unsigned int i=0; i != Nq; ++i)
1130  if (qoi_indices.has_index(i))
1131  qoi[i] = 0;
1132 
1133  // Create a non-temporary qoi_contributions object, so we can query
1134  // its results after the reduction
1135  QoIContributions qoi_contributions(*this, *(this->diff_qoi), qoi_indices);
1136 
1137  // Loop over every active mesh element on this processor
1140  qoi_contributions);
1141 
1142  this->diff_qoi->parallel_op( this->comm(), this->qoi, qoi_contributions.qoi, qoi_indices );
1143 }

References libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::ParallelObject::comm(), libMesh::DifferentiableSystem::diff_qoi, libMesh::System::get_mesh(), libMesh::QoISet::has_index(), mesh, libMesh::System::n_qois(), libMesh::DifferentiableQoI::parallel_op(), libMesh::Threads::parallel_reduce(), libMesh::System::qoi, libMesh::StoredRange< iterator_type, object_type >::reset(), 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 1147 of file fem_system.C.

1150 {
1151  LOG_SCOPE("assemble_qoi_derivative()", "FEMSystem");
1152 
1153  const MeshBase & mesh = this->get_mesh();
1154 
1155  this->update();
1156 
1157  // The quantity of interest derivative assembly accumulates on
1158  // initially zero vectors
1159  for (auto i : IntRange<unsigned int>(0, this->n_qois()))
1160  if (qoi_indices.has_index(i))
1161  this->add_adjoint_rhs(i).zero();
1162 
1163  // Loop over every active mesh element on this processor
1166  QoIDerivativeContributions(*this, qoi_indices,
1167  *(this->diff_qoi),
1168  include_liftfunc,
1169  apply_constraints));
1170 
1171  for (auto i : IntRange<unsigned int>(0, this->n_qois()))
1172  if (qoi_indices.has_index(i))
1173  this->diff_qoi->finalize_derivative(this->get_adjoint_rhs(i),i);
1174 }

References libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::System::add_adjoint_rhs(), libMesh::DifferentiableSystem::diff_qoi, libMesh::DifferentiableQoI::finalize_derivative(), libMesh::System::get_mesh(), libMesh::QoISet::has_index(), mesh, libMesh::System::n_qois(), libMesh::Threads::parallel_for(), libMesh::StoredRange< iterator_type, object_type >::reset(), 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 643 of file implicit_system.C.

644 {
645  ParameterVector & parameters =
646  const_cast<ParameterVector &>(parameters_in);
647 
648  const unsigned int Np = cast_int<unsigned int>
649  (parameters.size());
650 
651  for (unsigned int p=0; p != Np; ++p)
652  {
653  NumericVector<Number> & sensitivity_rhs = this->add_sensitivity_rhs(p);
654 
655  // Approximate -(partial R / partial p) by
656  // (R(p-dp) - R(p+dp)) / (2*dp)
657 
658  Number old_parameter = *parameters[p];
659 
660  const Real delta_p =
661  TOLERANCE * std::max(std::abs(old_parameter), 1e-3);
662 
663  *parameters[p] -= delta_p;
664 
665  // this->assembly(true, false, true);
666  this->assembly(true, false, false);
667  this->rhs->close();
668  sensitivity_rhs = *this->rhs;
669 
670  *parameters[p] = old_parameter + delta_p;
671 
672  // this->assembly(true, false, true);
673  this->assembly(true, false, false);
674  this->rhs->close();
675 
676  sensitivity_rhs -= *this->rhs;
677  sensitivity_rhs /= (2*delta_p);
678  sensitivity_rhs.close();
679 
680  *parameters[p] = old_parameter;
681  }
682 }

References std::abs(), 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.

Definition at line 850 of file fem_system.C.

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

References libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::DenseMatrix< T >::add(), libMesh::FEMSystem::build_context(), libMesh::SparseMatrix< T >::close(), libMesh::NumericVector< 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::NumericVector< T >::l1_norm(), libMesh::SparseMatrix< T >::l1_norm(), libMesh::DenseMatrix< T >::l1_norm(), libMesh::libmesh_assert(), 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::StoredRange< iterator_type, object_type >::reset(), libMesh::ExplicitSystem::rhs, libMesh::SCALAR, libMesh::DenseVector< T >::size(), libMesh::System::solution, libMesh::DifferentiableSystem::time_solver, libMesh::Variable::type(), libMesh::System::variable_group(), libMesh::FEMSystem::verify_analytic_jacobians, libMesh::DenseMatrix< T >::zero(), libMesh::SparseMatrix< T >::zero(), and libMesh::NumericVector< T >::zero().

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

◆ attach_assemble_function()

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

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

Definition at line 1755 of file system.C.

1757 {
1759 
1760  if (_assemble_system_object != nullptr)
1761  {
1762  libmesh_here();
1763  libMesh::out << "WARNING: Cannot specify both assembly function and object!"
1764  << std::endl;
1765 
1766  _assemble_system_object = nullptr;
1767  }
1768 
1770 }

References libMesh::System::_assemble_system_function, libMesh::System::_assemble_system_object, fptr(), libMesh::libmesh_assert(), and libMesh::out.

Referenced by assemble_and_solve(), main(), SystemsTest::testAssemblyWithDgFemContext(), and SystemsTest::testDofCouplingWithVarGroups().

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

1775 {
1776  if (_assemble_system_function != nullptr)
1777  {
1778  libmesh_here();
1779  libMesh::out << "WARNING: Cannot specify both assembly object and function!"
1780  << std::endl;
1781 
1782  _assemble_system_function = nullptr;
1783  }
1784 
1785  _assemble_system_object = &assemble_in;
1786 }

References libMesh::System::_assemble_system_function, libMesh::System::_assemble_system_object, and libMesh::out.

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

1792 {
1794 
1795  if (_constrain_system_object != nullptr)
1796  {
1797  libmesh_here();
1798  libMesh::out << "WARNING: Cannot specify both constraint function and object!"
1799  << std::endl;
1800 
1801  _constrain_system_object = nullptr;
1802  }
1803 
1805 }

References libMesh::System::_constrain_system_function, libMesh::System::_constrain_system_object, fptr(), libMesh::libmesh_assert(), and libMesh::out.

◆ attach_constraint_object()

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

Register a user object for imposing constraints.

Definition at line 1809 of file system.C.

1810 {
1811  if (_constrain_system_function != nullptr)
1812  {
1813  libmesh_here();
1814  libMesh::out << "WARNING: Cannot specify both constraint object and function!"
1815  << std::endl;
1816 
1817  _constrain_system_function = nullptr;
1818  }
1819 
1820  _constrain_system_object = &constrain;
1821 }

References libMesh::System::_constrain_system_function, libMesh::System::_constrain_system_object, and libMesh::out.

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

1722 {
1724 
1725  if (_init_system_object != nullptr)
1726  {
1727  libmesh_here();
1728  libMesh::out << "WARNING: Cannot specify both initialization function and object!"
1729  << std::endl;
1730 
1731  _init_system_object = nullptr;
1732  }
1733 
1735 }

References libMesh::System::_init_system_function, libMesh::System::_init_system_object, fptr(), libMesh::libmesh_assert(), and libMesh::out.

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

1740 {
1741  if (_init_system_function != nullptr)
1742  {
1743  libmesh_here();
1744  libMesh::out << "WARNING: Cannot specify both initialization object and function!"
1745  << std::endl;
1746 
1747  _init_system_function = nullptr;
1748  }
1749 
1750  _init_system_object = &init_in;
1751 }

References libMesh::System::_init_system_function, libMesh::System::_init_system_object, and libMesh::out.

◆ attach_physics()

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

Attach external Physics object.

Definition at line 196 of file diff_system.h.

197  { this->_diff_physics = (physics_in->clone_physics()).release();
198  this->_diff_physics->init_physics(*this);}

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

◆ attach_qoi()

void libMesh::DifferentiableSystem::attach_qoi ( DifferentiableQoI qoi_in)
inlineinherited

Attach external QoI object.

Definition at line 224 of file diff_system.h.

225  { this->diff_qoi = (qoi_in->clone()).release();
226  // User needs to resize qoi system qoi accordingly
227  this->diff_qoi->init_qoi( this->qoi );}

References libMesh::DifferentiableQoI::clone(), libMesh::DifferentiableSystem::diff_qoi, libMesh::DifferentiableQoI::init_qoi(), and libMesh::System::qoi.

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

1863 {
1865 
1866  if (_qoi_evaluate_derivative_object != nullptr)
1867  {
1868  libmesh_here();
1869  libMesh::out << "WARNING: Cannot specify both QOI derivative function and object!"
1870  << std::endl;
1871 
1873  }
1874 
1876 }

References libMesh::System::_qoi_evaluate_derivative_function, libMesh::System::_qoi_evaluate_derivative_object, fptr(), libMesh::libmesh_assert(), and libMesh::out.

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

1881 {
1882  if (_qoi_evaluate_derivative_function != nullptr)
1883  {
1884  libmesh_here();
1885  libMesh::out << "WARNING: Cannot specify both QOI derivative object and function!"
1886  << std::endl;
1887 
1889  }
1890 
1891  _qoi_evaluate_derivative_object = &qoi_derivative;
1892 }

References libMesh::System::_qoi_evaluate_derivative_function, libMesh::System::_qoi_evaluate_derivative_object, and libMesh::out.

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

1828 {
1830 
1831  if (_qoi_evaluate_object != nullptr)
1832  {
1833  libmesh_here();
1834  libMesh::out << "WARNING: Cannot specify both QOI function and object!"
1835  << std::endl;
1836 
1837  _qoi_evaluate_object = nullptr;
1838  }
1839 
1841 }

References libMesh::System::_qoi_evaluate_function, libMesh::System::_qoi_evaluate_object, fptr(), libMesh::libmesh_assert(), and libMesh::out.

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

1846 {
1847  if (_qoi_evaluate_function != nullptr)
1848  {
1849  libmesh_here();
1850  libMesh::out << "WARNING: Cannot specify both QOI object and function!"
1851  << std::endl;
1852 
1853  _qoi_evaluate_function = nullptr;
1854  }
1855 
1856  _qoi_evaluate_object = &qoi_in;
1857 }

References libMesh::System::_qoi_evaluate_function, libMesh::System::_qoi_evaluate_object, and libMesh::out.

◆ 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 
)
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. If non-default Parameters are to be used, they can be provided in the parameters argument.

Definition at line 1126 of file system_projection.C.

1130 {
1131  this->boundary_project_vector(b, variables, *solution, f, g);
1132 
1133  solution->localize(*current_local_solution);
1134 }

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

Definition at line 1109 of file system_projection.C.

1114 {
1115  WrappedFunction<Number> f(*this, fptr, &parameters);
1116  WrappedFunction<Gradient> g(*this, gptr, &parameters);
1117  this->boundary_project_solution(b, variables, &f, &g);
1118 }

References 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 
) 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. If non-default Parameters are to be used, they can be provided in the parameters argument.

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

Definition at line 1162 of file system_projection.C.

1168 {
1169  LOG_SCOPE ("boundary_project_vector()", "System");
1170 
1172  (ConstElemRange (this->get_mesh().active_local_elements_begin(),
1173  this->get_mesh().active_local_elements_end() ),
1174  BoundaryProjectSolution(b, variables, *this, f, g,
1175  this->get_equation_systems().parameters,
1176  new_vector)
1177  );
1178 
1179  // We don't do SCALAR dofs when just projecting the boundary, so
1180  // we're done here.
1181 
1182  new_vector.close();
1183 
1184 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1185  if (is_adjoint == -1)
1186  this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
1187  else if (is_adjoint >= 0)
1189  is_adjoint);
1190 #else
1191  libmesh_ignore(is_adjoint);
1192 #endif
1193 }

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

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

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

Definition at line 1144 of file system_projection.C.

1151 {
1152  WrappedFunction<Number> f(*this, fptr, &parameters);
1153  WrappedFunction<Gradient> g(*this, gptr, &parameters);
1154  this->boundary_project_vector(b, variables, new_vector, &f, &g,
1155  is_adjoint);
1156 }

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

1315 {
1316  FEMContext * fc = new FEMContext(*this);
1317 
1318  DifferentiablePhysics * phys = this->get_physics();
1319 
1320  libmesh_assert (phys);
1321 
1322  // If we are solving a moving mesh problem, tell that to the Context
1323  fc->set_mesh_system(phys->get_mesh_system());
1324  fc->set_mesh_x_var(phys->get_mesh_x_var());
1325  fc->set_mesh_y_var(phys->get_mesh_y_var());
1326  fc->set_mesh_z_var(phys->get_mesh_z_var());
1327 
1328  fc->set_deltat_pointer( &deltat );
1329 
1330  // If we are solving the adjoint problem, tell that to the Context
1331  fc->is_adjoint() = this->get_time_solver().is_adjoint();
1332 
1333  return std::unique_ptr<DiffContext>(fc);
1334 }

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(), libMesh::DiffContext::is_adjoint(), libMesh::libmesh_assert(), libMesh::DiffContext::set_deltat_pointer(), libMesh::FEMContext::set_mesh_system(), libMesh::FEMContext::set_mesh_x_var(), libMesh::FEMContext::set_mesh_y_var(), and libMesh::FEMContext::set_mesh_z_var().

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

◆ calculate_norm() [1/2]

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

Definition at line 1378 of file system.C.

1381 {
1382  // This function must be run on all processors at once
1383  parallel_object_only();
1384 
1385  LOG_SCOPE ("calculate_norm()", "System");
1386 
1387  // Zero the norm before summation
1388  Real v_norm = 0.;
1389 
1390  if (norm.is_discrete())
1391  {
1392  //Check to see if all weights are 1.0 and all types are equal
1393  FEMNormType norm_type0 = norm.type(0);
1394  unsigned int check_var = 0, check_end = this->n_vars();
1395  for (; check_var != check_end; ++check_var)
1396  if ((norm.weight(check_var) != 1.0) || (norm.type(check_var) != norm_type0))
1397  break;
1398 
1399  //All weights were 1.0 so just do the full vector discrete norm
1400  if (check_var == this->n_vars())
1401  {
1402  if (norm_type0 == DISCRETE_L1)
1403  return v.l1_norm();
1404  if (norm_type0 == DISCRETE_L2)
1405  return v.l2_norm();
1406  if (norm_type0 == DISCRETE_L_INF)
1407  return v.linfty_norm();
1408  else
1409  libmesh_error_msg("Invalid norm_type0 = " << norm_type0);
1410  }
1411 
1412  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
1413  {
1414  // Skip any variables we don't need to integrate
1415  if (norm.weight(var) == 0.0)
1416  continue;
1417 
1418  v_norm += norm.weight(var) * discrete_var_norm(v, var, norm.type(var));
1419  }
1420 
1421  return v_norm;
1422  }
1423 
1424  // Localize the potentially parallel vector
1425  std::unique_ptr<NumericVector<Number>> local_v = NumericVector<Number>::build(this->comm());
1426  local_v->init(v.size(), true, SERIAL);
1427  v.localize (*local_v, _dof_map->get_send_list());
1428 
1429  // I'm not sure how best to mix Hilbert norms on some variables (for
1430  // which we'll want to square then sum then square root) with norms
1431  // like L_inf (for which we'll just want to take an absolute value
1432  // and then sum).
1433  bool using_hilbert_norm = true,
1434  using_nonhilbert_norm = true;
1435 
1436  // Loop over all variables
1437  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
1438  {
1439  // Skip any variables we don't need to integrate
1440  Real norm_weight_sq = norm.weight_sq(var);
1441  if (norm_weight_sq == 0.0)
1442  continue;
1443  Real norm_weight = norm.weight(var);
1444 
1445  // Check for unimplemented norms (rather than just returning 0).
1446  FEMNormType norm_type = norm.type(var);
1447  if ((norm_type==H1) ||
1448  (norm_type==H2) ||
1449  (norm_type==L2) ||
1450  (norm_type==H1_SEMINORM) ||
1451  (norm_type==H2_SEMINORM))
1452  {
1453  if (!using_hilbert_norm)
1454  libmesh_not_implemented();
1455  using_nonhilbert_norm = false;
1456  }
1457  else if ((norm_type==L1) ||
1458  (norm_type==L_INF) ||
1459  (norm_type==W1_INF_SEMINORM) ||
1460  (norm_type==W2_INF_SEMINORM))
1461  {
1462  if (!using_nonhilbert_norm)
1463  libmesh_not_implemented();
1464  using_hilbert_norm = false;
1465  }
1466  else
1467  libmesh_not_implemented();
1468 
1469  const FEType & fe_type = this->get_dof_map().variable_type(var);
1470 
1471  // Allow space for dims 0-3, even if we don't use them all
1472  std::vector<std::unique_ptr<FEBase>> fe_ptrs(4);
1473  std::vector<std::unique_ptr<QBase>> q_rules(4);
1474 
1475  const std::set<unsigned char> & elem_dims = _mesh.elem_dimensions();
1476 
1477  // Prepare finite elements for each dimension present in the mesh
1478  for (const auto & dim : elem_dims)
1479  {
1480  if (skip_dimensions && skip_dimensions->find(dim) != skip_dimensions->end())
1481  continue;
1482 
1483  // Construct quadrature and finite element objects
1484  q_rules[dim] = fe_type.default_quadrature_rule (dim);
1485  fe_ptrs[dim] = FEBase::build(dim, fe_type);
1486 
1487  // Attach quadrature rule to FE object
1488  fe_ptrs[dim]->attach_quadrature_rule (q_rules[dim].get());
1489  }
1490 
1491  std::vector<dof_id_type> dof_indices;
1492 
1493  // Begin the loop over the elements
1494  for (const auto & elem : this->get_mesh().active_local_element_ptr_range())
1495  {
1496  const unsigned int dim = elem->dim();
1497 
1498 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1499 
1500  // One way for implementing this would be to exchange the fe with the FEInterface- class.
1501  // However, it needs to be discussed whether integral-norms make sense for infinite elements.
1502  // or in which sense they could make sense.
1503  if (elem->infinite() )
1504  libmesh_not_implemented();
1505 
1506 #endif
1507 
1508  if (skip_dimensions && skip_dimensions->find(dim) != skip_dimensions->end())
1509  continue;
1510 
1511  FEBase * fe = fe_ptrs[dim].get();
1512  QBase * qrule = q_rules[dim].get();
1513  libmesh_assert(fe);
1514  libmesh_assert(qrule);
1515 
1516  const std::vector<Real> & JxW = fe->get_JxW();
1517  const std::vector<std::vector<Real>> * phi = nullptr;
1518  if (norm_type == H1 ||
1519  norm_type == H2 ||
1520  norm_type == L2 ||
1521  norm_type == L1 ||
1522  norm_type == L_INF)
1523  phi = &(fe->get_phi());
1524 
1525  const std::vector<std::vector<RealGradient>> * dphi = nullptr;
1526  if (norm_type == H1 ||
1527  norm_type == H2 ||
1528  norm_type == H1_SEMINORM ||
1529  norm_type == W1_INF_SEMINORM)
1530  dphi = &(fe->get_dphi());
1531 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1532  const std::vector<std::vector<RealTensor>> * d2phi = nullptr;
1533  if (norm_type == H2 ||
1534  norm_type == H2_SEMINORM ||
1535  norm_type == W2_INF_SEMINORM)
1536  d2phi = &(fe->get_d2phi());
1537 #endif
1538 
1539  fe->reinit (elem);
1540 
1541  this->get_dof_map().dof_indices (elem, dof_indices, var);
1542 
1543  const unsigned int n_qp = qrule->n_points();
1544 
1545  const unsigned int n_sf = cast_int<unsigned int>
1546  (dof_indices.size());
1547 
1548  // Begin the loop over the Quadrature points.
1549  for (unsigned int qp=0; qp<n_qp; qp++)
1550  {
1551  if (norm_type == L1)
1552  {
1553  Number u_h = 0.;
1554  for (unsigned int i=0; i != n_sf; ++i)
1555  u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1556  v_norm += norm_weight *
1557  JxW[qp] * std::abs(u_h);
1558  }
1559 
1560  if (norm_type == L_INF)
1561  {
1562  Number u_h = 0.;
1563  for (unsigned int i=0; i != n_sf; ++i)
1564  u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1565  v_norm = std::max(v_norm, norm_weight * std::abs(u_h));
1566  }
1567 
1568  if (norm_type == H1 ||
1569  norm_type == H2 ||
1570  norm_type == L2)
1571  {
1572  Number u_h = 0.;
1573  for (unsigned int i=0; i != n_sf; ++i)
1574  u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1575  v_norm += norm_weight_sq *
1576  JxW[qp] * TensorTools::norm_sq(u_h);
1577  }
1578 
1579  if (norm_type == H1 ||
1580  norm_type == H2 ||
1581  norm_type == H1_SEMINORM)
1582  {
1583  Gradient grad_u_h;
1584  for (unsigned int i=0; i != n_sf; ++i)
1585  grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
1586  v_norm += norm_weight_sq *
1587  JxW[qp] * grad_u_h.norm_sq();
1588  }
1589 
1590  if (norm_type == W1_INF_SEMINORM)
1591  {
1592  Gradient grad_u_h;
1593  for (unsigned int i=0; i != n_sf; ++i)
1594  grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
1595  v_norm = std::max(v_norm, norm_weight * grad_u_h.norm());
1596  }
1597 
1598 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1599  if (norm_type == H2 ||
1600  norm_type == H2_SEMINORM)
1601  {
1602  Tensor hess_u_h;
1603  for (unsigned int i=0; i != n_sf; ++i)
1604  hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
1605  v_norm += norm_weight_sq *
1606  JxW[qp] * hess_u_h.norm_sq();
1607  }
1608 
1609  if (norm_type == W2_INF_SEMINORM)
1610  {
1611  Tensor hess_u_h;
1612  for (unsigned int i=0; i != n_sf; ++i)
1613  hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
1614  v_norm = std::max(v_norm, norm_weight * hess_u_h.norm());
1615  }
1616 #endif
1617  }
1618  }
1619  }
1620 
1621  if (using_hilbert_norm)
1622  {
1623  this->comm().sum(v_norm);
1624  v_norm = std::sqrt(v_norm);
1625  }
1626  else
1627  {
1628  this->comm().max(v_norm);
1629  }
1630 
1631  return v_norm;
1632 }

References libMesh::System::_dof_map, libMesh::System::_mesh, std::abs(), libMesh::TypeVector< T >::add_scaled(), libMesh::TypeTensor< T >::add_scaled(), libMesh::FEGenericBase< OutputType >::build(), libMesh::NumericVector< T >::build(), libMesh::ParallelObject::comm(), libMesh::FEType::default_quadrature_rule(), dim, libMesh::DISCRETE_L1, libMesh::DISCRETE_L2, libMesh::DISCRETE_L_INF, libMesh::System::discrete_var_norm(), libMesh::DofMap::dof_indices(), libMesh::MeshBase::elem_dimensions(), libMesh::ReferenceElem::get(), libMesh::FEGenericBase< OutputType >::get_d2phi(), libMesh::System::get_dof_map(), libMesh::FEGenericBase< OutputType >::get_dphi(), libMesh::FEAbstract::get_JxW(), libMesh::System::get_mesh(), libMesh::FEGenericBase< OutputType >::get_phi(), 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 >::localize(), libMesh::QBase::n_points(), libMesh::System::n_vars(), std::norm(), libMesh::TypeVector< T >::norm(), libMesh::TypeTensor< T >::norm(), libMesh::TensorTools::norm_sq(), libMesh::TypeVector< T >::norm_sq(), libMesh::TypeTensor< T >::norm_sq(), libMesh::Real, libMesh::FEAbstract::reinit(), libMesh::SERIAL, libMesh::NumericVector< T >::size(), std::sqrt(), libMesh::DofMap::variable_type(), 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 1356 of file system.C.

1360 {
1361  //short circuit to save time
1362  if (norm_type == DISCRETE_L1 ||
1363  norm_type == DISCRETE_L2 ||
1364  norm_type == DISCRETE_L_INF)
1365  return discrete_var_norm(v,var,norm_type);
1366 
1367  // Not a discrete norm
1368  std::vector<FEMNormType> norms(this->n_vars(), L2);
1369  std::vector<Real> weights(this->n_vars(), 0.0);
1370  norms[var] = norm_type;
1371  weights[var] = 1.0;
1372  Real val = this->calculate_norm(v, SystemNorm(norms, weights), skip_dimensions);
1373  return val;
1374 }

References libMesh::DISCRETE_L1, libMesh::DISCRETE_L2, libMesh::DISCRETE_L_INF, libMesh::System::discrete_var_norm(), libMesh::L2, libMesh::System::n_vars(), and libMesh::Real.

Referenced by libMesh::AdaptiveTimeSolver::calculate_norm(), libMesh::UnsteadySolver::du(), main(), and output_norms().

◆ 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 69 of file diff_system.C.

70 {
71  // If we had an attached Physics object, delete it.
72  if (this->_diff_physics != this)
73  {
74  delete this->_diff_physics;
75  this->_diff_physics = this;
76  }
77  // If we had no attached Physics object, clear our own Physics data
78  else
79  this->clear_physics();
80 
81  // If we had an attached QoI object, delete it.
82  if (this->diff_qoi != this)
83  {
84  delete this->diff_qoi;
85  this->diff_qoi = this;
86  }
87  // If we had no attached QoI object, clear our own QoI data
88  else
89  this->clear_qoi();
90 
91  use_fixed_solution = false;
92 }

References libMesh::DifferentiableSystem::_diff_physics, libMesh::DifferentiablePhysics::clear_physics(), libMesh::DifferentiableQoI::clear_qoi(), libMesh::DifferentiableSystem::diff_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 33 of file diff_physics.C.

34 {
35  _time_evolving.resize(0);
36 }

References libMesh::DifferentiablePhysics::_time_evolving.

Referenced by libMesh::DifferentiableSystem::clear(), and libMesh::DifferentiablePhysics::~DifferentiablePhysics().

◆ 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
172  return std::unique_ptr<DifferentiableQoI>(this);
173  }

◆ 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
162  return std::unique_ptr<DifferentiablePhysics>(this);
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 94 of file parallel_object.h.

95  { return _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::__libmesh_tao_equality_constraints(), libMesh::__libmesh_tao_equality_constraints_jacobian(), libMesh::__libmesh_tao_gradient(), libMesh::__libmesh_tao_hessian(), libMesh::__libmesh_tao_inequality_constraints(), libMesh::__libmesh_tao_inequality_constraints_jacobian(), libMesh::__libmesh_tao_objective(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult_add(), libMesh::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), 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::ImplicitSystem::add_matrix(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::DynaIO::add_spline_constraints(), libMesh::System::add_vector(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::DofMap::attach_matrix(), libMesh::MeshTools::Generation::build_extrusion(), 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::System::calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), 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::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), 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::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), DMVariableBounds_libMesh(), libMesh::DTKSolutionTransfer::DTKSolutionTransfer(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::RBConstruction::enrich_RB_space(), libMesh::EpetraVector< T >::EpetraVector(), AssembleOptimization::equality_constraints(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::RBEIMConstruction::evaluate_mesh_function(), 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::DofMap::gather_constraints(), libMesh::MeshfreeInterpolation::gather_remote_data(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), AssembleOptimization::inequality_constraints(), AssembleOptimization::inequality_constraints_jacobian(), libMesh::LocationMap< T >::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::EigenSystem::init_matrices(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_rb_construction(), integrate_function(), 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_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::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_preconditioner_apply(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_postcheck(), libMesh::libmesh_petsc_snes_residual(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_new_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_new_nodes_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::MeshRefinement::make_refinement_compatible(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::FEMSystem::mesh_position_set(), LinearElasticityWithContact::move_mesh(), libMesh::DistributedMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::DofMap::n_constrained_dofs(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::MeshTools::n_levels(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::MeshTools::n_p_levels(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::ReplicatedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_n_elem(), libMesh::DistributedMesh::parallel_n_nodes(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::MeshTools::paranoid_n_levels(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::print_dof_constraints(), FEMParameters::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::System::read_legacy_data(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::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::MeshRefinement::refine_and_coarsen_elements(), libMesh::DistributedMesh::renumber_dof_objects(), LinearElasticityWithContact::residual_and_jacobian(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::TransientRBConstruction::set_error_temporal_data(), libMesh::RBEIMConstruction::set_explicit_sys_subvector(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::PetscDiffSolver::setup_petsc_data(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::split_mesh(), libMesh::BoundaryInfo::sync(), libMesh::MeshRefinement::test_level_one(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), libMesh::MeshRefinement::test_unflagged(), SystemsTest::testBlockRestrictedVarNDofs(), PointLocatorTest::testLocator(), BoundaryInfoTest::testMesh(), SystemsTest::testProjectCubeWithMeshFunction(), CheckpointIOTest::testSplitter(), libMesh::MeshTools::total_weight(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::RBEIMConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::VTKIO::write_nodal_data(), libMesh::RBEvaluation::write_out_vectors(), libMesh::TransientRBConstruction::write_riesz_representors_to_files(), libMesh::RBConstruction::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 514 of file system.C.

517 {
518  // we do not care for matrices, but for vectors
520  libmesh_assert (other_system._is_initialized);
521 
522  if (verbose)
523  {
524  libMesh::out << " Systems \"" << _sys_name << "\"" << std::endl;
525  libMesh::out << " comparing matrices not supported." << std::endl;
526  libMesh::out << " comparing names...";
527  }
528 
529  // compare the name: 0 means identical
530  const int name_result = _sys_name.compare(other_system.name());
531  if (verbose)
532  {
533  if (name_result == 0)
534  libMesh::out << " identical." << std::endl;
535  else
536  libMesh::out << " names not identical." << std::endl;
537  libMesh::out << " comparing solution vector...";
538  }
539 
540 
541  // compare the solution: -1 means identical
542  const int solu_result = solution->compare (*other_system.solution.get(),
543  threshold);
544 
545  if (verbose)
546  {
547  if (solu_result == -1)
548  libMesh::out << " identical up to threshold." << std::endl;
549  else
550  libMesh::out << " first difference occurred at index = "
551  << solu_result << "." << std::endl;
552  }
553 
554 
555  // safety check, whether we handle at least the same number
556  // of vectors
557  std::vector<int> ov_result;
558 
559  if (this->n_vectors() != other_system.n_vectors())
560  {
561  if (verbose)
562  {
563  libMesh::out << " Fatal difference. This system handles "
564  << this->n_vectors() << " add'l vectors," << std::endl
565  << " while the other system handles "
566  << other_system.n_vectors()
567  << " add'l vectors." << std::endl
568  << " Aborting comparison." << std::endl;
569  }
570  return false;
571  }
572  else if (this->n_vectors() == 0)
573  {
574  // there are no additional vectors...
575  ov_result.clear ();
576  }
577  else
578  {
579  // compare other vectors
580  for (auto & pr : _vectors)
581  {
582  if (verbose)
583  libMesh::out << " comparing vector \""
584  << pr.first << "\" ...";
585 
586  // assume they have the same name
587  const NumericVector<Number> & other_system_vector =
588  other_system.get_vector(pr.first);
589 
590  ov_result.push_back(pr.second->compare (other_system_vector,
591  threshold));
592 
593  if (verbose)
594  {
595  if (ov_result[ov_result.size()-1] == -1)
596  libMesh::out << " identical up to threshold." << std::endl;
597  else
598  libMesh::out << " first difference occurred at" << std::endl
599  << " index = " << ov_result[ov_result.size()-1] << "." << std::endl;
600  }
601  }
602  } // finished comparing additional vectors
603 
604 
605  bool overall_result;
606 
607  // sum up the results
608  if ((name_result==0) && (solu_result==-1))
609  {
610  if (ov_result.size()==0)
611  overall_result = true;
612  else
613  {
614  bool ov_identical;
615  unsigned int n = 0;
616  do
617  {
618  ov_identical = (ov_result[n]==-1);
619  n++;
620  }
621  while (ov_identical && n<ov_result.size());
622  overall_result = ov_identical;
623  }
624  }
625  else
626  overall_result = false;
627 
628  if (verbose)
629  {
630  libMesh::out << " finished comparisons, ";
631  if (overall_result)
632  libMesh::out << "found no differences." << std::endl << std::endl;
633  else
634  libMesh::out << "found differences." << std::endl << std::endl;
635  }
636 
637  return overall_result;
638 }

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.

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

◆ 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 SecondOrderScalarSystemFirstOrderTimeSolverBase, and SecondOrderScalarSystemSecondOrderTimeSolverBase.

Definition at line 375 of file diff_physics.h.

376  {
377  return request_jacobian;
378  }

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

◆ deactivate()

void libMesh::System::deactivate ( )
inlineinherited

Deactivates the system.

Only active systems are solved.

Definition at line 2131 of file system.h.

2132 {
2133  _active = false;
2134 }

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 293 of file implicit_system.C.

293  {
294  this->assemble_before_solve = true;
295  this->get_linear_solver()->reuse_preconditioner(false);
296 }

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

◆ disable_print_counter_info()

void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 106 of file reference_counter.C.

107 {
108  _enable_print_counter = false;
109  return;
110 }

References libMesh::ReferenceCounter::_enable_print_counter.

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

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

1340 {
1341  std::set<dof_id_type> var_indices;
1342  local_dof_indices(var, var_indices);
1343 
1344  if (norm_type == DISCRETE_L1)
1345  return v.subset_l1_norm(var_indices);
1346  if (norm_type == DISCRETE_L2)
1347  return v.subset_l2_norm(var_indices);
1348  if (norm_type == DISCRETE_L_INF)
1349  return v.subset_linfty_norm(var_indices);
1350  else
1351  libmesh_error_msg("Invalid norm_type = " << norm_type);
1352 }

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

Referenced by libMesh::System::calculate_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 143 of file diff_physics.h.

144  {
145  return request_jacobian;
146  }

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

◆ element_postprocess()

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

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

Reimplemented in LaplaceSystem, LaplaceSystem, and PoissonSystem.

Definition at line 281 of file diff_system.h.

281 {}

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

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 LaplaceSystem, LaplaceSystem, LaplaceQoI, and HeatSystem.

Definition at line 122 of file diff_qoi.h.

124  {}

◆ element_time_derivative()

virtual bool FirstOrderScalarSystemBase::element_time_derivative ( bool  request_jacobian,
DiffContext context 
)
inlineoverridevirtualinherited

Note the nonlinear residual is F(u)-M(u)

{u}

Reimplemented from libMesh::DifferentiablePhysics.

Reimplemented in SecondOrderScalarSystemFirstOrderTimeSolverBase.

Definition at line 118 of file time_solver_test_common.h.

120  {
121  FEMContext & c = cast_ref<FEMContext &>(context);
123 
124  const unsigned int n_u_dofs =
125  cast_int<unsigned int>(c.get_dof_indices(_u_var).size());
126  unsigned int n_qpoints = c.get_element_qrule().n_points();
127 
128  for (unsigned int qp=0; qp != n_qpoints; qp++)
129  {
130  Number Fval = this->F(c,qp);
131 
132  for (unsigned int i=0; i != n_u_dofs; i++)
133  Fu(i) += Fval;
134  }
135 
136  return request_jacobian;
137  }

References libMesh::DiffContext::get_dof_indices(), libMesh::DiffContext::get_elem_residual(), libMesh::FEMContext::get_element_qrule(), and libMesh::QBase::n_points().

◆ enable_print_counter_info()

void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

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

Definition at line 100 of file reference_counter.C.

101 {
102  _enable_print_counter = true;
103  return;
104 }

References libMesh::ReferenceCounter::_enable_print_counter.

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

Definition at line 295 of file diff_physics.h.

296  {
297  return request_jacobian;
298  }

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 : IntRange<unsigned int>(0, 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 }

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::DiffContext::n_vars(), and libMesh::UnsteadySolver::old_nonlinear_solution().

◆ F() [1/2]

virtual Number ConstantFirstOrderODE::F ( FEMContext &  ,
unsigned int   
)
inlinevirtual

Definition at line 22 of file first_order_unsteady_solver_test.C.

23  { return 5.0; }

◆ F() [2/2]

virtual Number FirstOrderScalarSystemBase::F ( FEMContext context,
unsigned int  qp 
)
pure virtualinherited

Value of F(u)

◆ 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 796 of file implicit_system.C.

799 {
800  ParameterVector & parameters =
801  const_cast<ParameterVector &>(parameters_in);
802 
803  const unsigned int Np = cast_int<unsigned int>
804  (parameters.size());
805  const unsigned int Nq = this->n_qois();
806 
807  // An introduction to the problem:
808  //
809  // Residual R(u(p),p) = 0
810  // partial R / partial u = J = system matrix
811  //
812  // This implies that:
813  // d/dp(R) = 0
814  // (partial R / partial p) +
815  // (partial R / partial u) * (partial u / partial p) = 0
816 
817  // We first solve for (partial u / partial p) for each parameter:
818  // J * (partial u / partial p) = - (partial R / partial p)
819 
820  this->sensitivity_solve(parameters);
821 
822  // Get ready to fill in sensitivities:
823  sensitivities.allocate_data(qoi_indices, *this, parameters);
824 
825  // We use the identity:
826  // dq/dp = (partial q / partial p) + (partial q / partial u) *
827  // (partial u / partial p)
828 
829  // We get (partial q / partial u) from the user
830  this->assemble_qoi_derivative(qoi_indices,
831  /* include_liftfunc = */ true,
832  /* apply_constraints = */ false);
833 
834  // We don't need these to be closed() in this function, but libMesh
835  // standard practice is to have them closed() by the time the
836  // function exits
837  for (auto i : IntRange<unsigned int>(0, this->n_qois()))
838  if (qoi_indices.has_index(i))
839  this->get_adjoint_rhs(i).close();
840 
841  for (unsigned int j=0; j != Np; ++j)
842  {
843  // We currently get partial derivatives via central differencing
844 
845  // (partial q / partial p) ~= (q(p+dp)-q(p-dp))/(2*dp)
846 
847  Number old_parameter = *parameters[j];
848 
849  const Real delta_p =
850  TOLERANCE * std::max(std::abs(old_parameter), 1e-3);
851 
852  *parameters[j] = old_parameter - delta_p;
853  this->assemble_qoi(qoi_indices);
854  std::vector<Number> qoi_minus = this->qoi;
855 
856  *parameters[j] = old_parameter + delta_p;
857  this->assemble_qoi(qoi_indices);
858  std::vector<Number> & qoi_plus = this->qoi;
859 
860  std::vector<Number> partialq_partialp(Nq, 0);
861  for (unsigned int i=0; i != Nq; ++i)
862  if (qoi_indices.has_index(i))
863  partialq_partialp[i] = (qoi_plus[i] - qoi_minus[i]) / (2.*delta_p);
864 
865  // Don't leave the parameter changed
866  *parameters[j] = old_parameter;
867 
868  for (unsigned int i=0; i != Nq; ++i)
869  if (qoi_indices.has_index(i))
870  sensitivities[i][j] = partialq_partialp[i] +
871  this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(j));
872  }
873 
874  // All parameters have been reset.
875  // We didn't cache the original rhs or matrix for memory reasons,
876  // but we can restore them to a state consistent solution -
877  // principle of least surprise.
878  this->assembly(true, true);
879  this->rhs->close();
880  this->matrix->close();
881  this->assemble_qoi(qoi_indices);
882 }

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

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

1020 {
1021  std::ostringstream adjoint_rhs_name;
1022  adjoint_rhs_name << "adjoint_rhs" << i;
1023 
1024  return this->get_vector(adjoint_rhs_name.str());
1025 }

References libMesh::System::get_vector().

Referenced by libMesh::ImplicitSystem::adjoint_solve(), 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 1029 of file system.C.

1030 {
1031  std::ostringstream adjoint_rhs_name;
1032  adjoint_rhs_name << "adjoint_rhs" << i;
1033 
1034  return this->get_vector(adjoint_rhs_name.str());
1035 }

References libMesh::System::get_vector().

◆ get_adjoint_solution() [1/2]

NumericVector< Number > & libMesh::System::get_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.

Definition at line 957 of file system.C.

958 {
959  std::ostringstream adjoint_name;
960  adjoint_name << "adjoint_solution" << i;
961 
962  return this->get_vector(adjoint_name.str());
963 }

References libMesh::System::get_vector().

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), main(), HeatSystem::perturb_accumulate_residuals(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().

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

968 {
969  std::ostringstream adjoint_name;
970  adjoint_name << "adjoint_solution" << i;
971 
972  return this->get_vector(adjoint_name.str());
973 }

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

1241 {
1242  all_variable_numbers.resize(n_vars());
1243 
1244  // Make sure the variable exists
1245  std::map<std::string, unsigned short int>::const_iterator
1246  it = _variable_numbers.begin();
1247  std::map<std::string, unsigned short int>::const_iterator
1248  it_end = _variable_numbers.end();
1249 
1250  unsigned int count = 0;
1251  for ( ; it != it_end; ++it)
1252  {
1253  all_variable_numbers[count] = it->second;
1254  count++;
1255  }
1256 }

References libMesh::System::_variable_numbers, and libMesh::System::n_vars().

Referenced by libMesh::RBEIMConstruction::initialize_rb_construction(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), and SystemsTest::testProjectCubeWithMeshFunction().

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

2108 {
2109  return *_dof_map;
2110 }

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

2100 {
2101  return *_dof_map;
2102 }

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::HPCoarsenTest::add_projection(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::NewmarkSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::EquationSystems::allgather(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), assemble(), LinearElasticity::assemble(), assemble_1D(), AssembleOptimization::assemble_A_and_F(), assemble_and_solve(), assemble_biharmonic(), assemble_elasticity(), assemble_ellipticdg(), assemble_helmholtz(), assemble_laplace(), assemble_mass(), assemble_matrices(), assemble_matrix_and_rhs(), assemble_poisson(), assemble_SchroedingerEquation(), assemble_shell(), assemble_stokes(), assemble_wave(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_sf(), libMesh::System::calculate_norm(), compute_jacobian(), compute_residual(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), MyConstraint::constrain(), libMesh::ExodusII_IO::copy_scalar_solution(), DMCreateDomainDecomposition_libMesh(), DMCreateFieldDecomposition_libMesh(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::RBEIMAssembly::evaluate_basis_function(), libMesh::System::get_info(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::SecondOrderUnsteadySolver::init_data(), libMesh::UnsteadySolver::init_data(), HeatSystem::init_data(), SimpleRBConstruction::init_data(), LaplaceSystem::init_dirichlet_bcs(), libMesh::RBEIMConstruction::init_dof_map_between_systems(), libMesh::EigenSystem::init_matrices(), libMesh::ImplicitSystem::init_matrices(), libMesh::CondensedEigenSystem::initialize_condensed_dofs(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::RBEIMAssembly::initialize_fe(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_rb_construction(), LaplaceYoung::jacobian(), LargeDeformationElasticity::jacobian(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_residual(), libMesh::libmesh_petsc_snes_residual_helper(), 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::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::RBSCMConstruction::perform_SCM_greedy(), libMesh::petsc_auto_fieldsplit(), libMesh::ErrorVector::plot_error(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::FEMContext::pre_fe_reinit(), libMesh::RBEIMAssembly::RBEIMAssembly(), libMesh::RBEIMConstruction::RBEIMConstruction(), libMesh::System::re_update(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::SecondOrderUnsteadySolver::reinit(), libMesh::UnsteadySolver::reinit(), libMesh::EigenSystem::reinit(), libMesh::ImplicitSystem::reinit(), libMesh::System::reinit_constraints(), libMesh::EquationSystems::reinit_solutions(), LaplaceYoung::residual(), LargeDeformationElasticity::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::PetscDMWrapper::set_point_range_in_section(), set_system_parameters(), FETest< order, family, elem_type >::setUp(), SolidSystem::side_time_derivative(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), SystemsTest::testBlockRestrictedVarNDofs(), DofMapTest::testConstraintLoopDetection(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), EquationSystemsTest::testDisableDefaultGhosting(), SystemsTest::testDofCouplingWithVarGroups(), DofMapTest::testDofOwner(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), SystemsTest::testProjectCubeWithMeshFunction(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), BoundaryInfoTest::testShellFaceConstraints(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::RBEIMConstruction::truth_solve(), libMesh::RBEIMConstruction::update_RB_system_matrices(), 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 725 of file system.h.

725 { return _equation_systems; }

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

720 { 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::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::RBEIMConstruction::get_explicit_system(), libMesh::ImplicitSystem::get_linear_solve_parameters(), SolidSystem::init_data(), HeatSystem::init_data(), libMesh::FrequencySystem::init_data(), libMesh::RBEIMConstruction::init_data(), libMesh::RBEIMConstruction::initialize_rb_construction(), LaplaceYoung::jacobian(), libMesh::RBSCMConstruction::load_matrix_B(), LinearElasticityWithContact::move_mesh(), libMesh::FrequencySystem::n_frequencies(), libMesh::RBSCMConstruction::perform_SCM_greedy(), libMesh::RBEIMConstruction::plot_parametrized_functions_in_training_set(), libMesh::System::point_gradient(), libMesh::System::point_value(), LaplaceYoung::residual(), LinearElasticityWithContact::residual_and_jacobian(), 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::NewmarkSystem::set_newmark_parameters(), libMesh::NonlinearImplicitSystem::set_solver_parameters(), SolidSystem::side_time_derivative(), libMesh::CondensedEigenSystem::solve(), libMesh::EigenSystem::solve(), libMesh::FrequencySystem::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), MeshFunctionTest::test_p_level(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::DirectSolutionTransfer::transfer(), libMesh::DTKSolutionTransfer::transfer(), libMesh::TransientRBConstruction::truth_solve(), libMesh::RBEIMConstruction::truth_solve(), 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 518 of file diff_physics.h.

519  { return _first_order_vars; }

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 & pr : _counts)
59  {
60  const std::string name(pr.first);
61  const unsigned int creations = pr.second.first;
62  const unsigned int destructions = pr.second.second;
63 
64  oss << "| " << name << " reference count information:\n"
65  << "| Creations: " << creations << '\n'
66  << "| Destructions: " << destructions << '\n';
67  }
68 
69  oss << " ---------------------------------------------------------------------------- \n";
70 
71  return oss.str();
72 
73 #else
74 
75  return "";
76 
77 #endif
78 }

References libMesh::ReferenceCounter::_counts, and libMesh::Quality::name().

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

1637 {
1638  std::ostringstream oss;
1639 
1640 
1641  const std::string & sys_name = this->name();
1642 
1643  oss << " System #" << this->number() << ", \"" << sys_name << "\"\n"
1644  << " Type \"" << this->system_type() << "\"\n"
1645  << " Variables=";
1646 
1647  for (auto vg : IntRange<unsigned int>(0, this->n_variable_groups()))
1648  {
1649  const VariableGroup & vg_description (this->variable_group(vg));
1650 
1651  if (vg_description.n_variables() > 1) oss << "{ ";
1652  for (auto vn : IntRange<unsigned int>(0, vg_description.n_variables()))
1653  oss << "\"" << vg_description.name(vn) << "\" ";
1654  if (vg_description.n_variables() > 1) oss << "} ";
1655  }
1656 
1657  oss << '\n';
1658 
1659  oss << " Finite Element Types=";
1660 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
1661  for (auto vg : IntRange<unsigned int>(0, this->n_variable_groups()))
1662  oss << "\""
1663  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
1664  << "\" ";
1665 #else
1666  for (auto vg : IntRange<unsigned int>(0, this->n_variable_groups()))
1667  {
1668  oss << "\""
1669  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
1670  << "\", \""
1671  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().radial_family)
1672  << "\" ";
1673  }
1674 
1675  oss << '\n' << " Infinite Element Mapping=";
1676  for (auto vg : IntRange<unsigned int>(0, this->n_variable_groups()))
1677  oss << "\""
1678  << Utility::enum_to_string<InfMapType>(this->get_dof_map().variable_group(vg).type().inf_map)
1679  << "\" ";
1680 #endif
1681 
1682  oss << '\n';
1683 
1684  oss << " Approximation Orders=";
1685  for (auto vg : IntRange<unsigned int>(0, this->n_variable_groups()))
1686  {
1687 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
1688  oss << "\""
1689  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
1690  << "\" ";
1691 #else
1692  oss << "\""
1693  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
1694  << "\", \""
1695  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().radial_order)
1696  << "\" ";
1697 #endif
1698  }
1699 
1700  oss << '\n';
1701 
1702  oss << " n_dofs()=" << this->n_dofs() << '\n';
1703  oss << " n_local_dofs()=" << this->n_local_dofs() << '\n';
1704 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1705  oss << " n_constrained_dofs()=" << this->n_constrained_dofs() << '\n';
1706  oss << " n_local_constrained_dofs()=" << this->n_local_constrained_dofs() << '\n';
1707 #endif
1708 
1709  oss << " " << "n_vectors()=" << this->n_vectors() << '\n';
1710  oss << " " << "n_matrices()=" << this->n_matrices() << '\n';
1711  // oss << " " << "n_additional_matrices()=" << this->n_additional_matrices() << '\n';
1712 
1713  oss << this->get_dof_map().get_info();
1714 
1715  return oss.str();
1716 }

References libMesh::FEType::family, libMesh::System::get_dof_map(), libMesh::DofMap::get_info(), libMesh::System::n_constrained_dofs(), libMesh::System::n_dofs(), libMesh::System::n_local_constrained_dofs(), libMesh::System::n_local_dofs(), libMesh::System::n_matrices(), libMesh::System::n_variable_groups(), libMesh::VariableGroup::n_variables(), libMesh::System::n_vectors(), libMesh::VariableGroup::name(), libMesh::System::name(), libMesh::System::number(), libMesh::System::system_type(), libMesh::Variable::type(), libMesh::DofMap::variable_group(), and libMesh::System::variable_group().

◆ 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 184 of file diff_system.C.

185 {
187  libmesh_assert_equal_to (&(time_solver->system()), this);
188  return std::make_pair(this->time_solver->diff_solver()->max_linear_iterations,
189  this->time_solver->diff_solver()->relative_residual_tolerance);
190 }

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 175 of file diff_system.C.

176 {
178  libmesh_assert_equal_to (&(time_solver->system()), this);
179  return this->time_solver->linear_solver().get();
180 }

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

Referenced by main().

◆ get_matrix() [1/2]

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

None of these matrices is involved in the solution process. Access is only granted when the matrix is already properly initialized.

Definition at line 269 of file implicit_system.C.

270 {
271  return *(libmesh_map_find(_matrices, mat_name));
272 }

References libMesh::ImplicitSystem::_matrices.

◆ get_matrix() [2/2]

const SparseMatrix< Number > & libMesh::ImplicitSystem::get_matrix ( const std::string &  mat_name) const
inherited
Returns
A const reference to this system's additional matrix named mat_name.

None of these matrices is involved in the solution process. Access is only granted when the matrix is already properly initialized.

Definition at line 262 of file implicit_system.C.

263 {
264  return *(libmesh_map_find(_matrices, mat_name));
265 }

References libMesh::ImplicitSystem::_matrices.

Referenced by add_M_C_K_helmholtz(), assemble(), assemble_helmholtz(), libMesh::NewmarkSystem::compute_matrix(), main(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), libMesh::EigenTimeSolver::solve(), and libMesh::NewmarkSystem::update_rhs().

◆ get_mesh() [1/2]

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

Definition at line 2091 of file system.h.

2092 {
2093  return _mesh;
2094 }

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

2084 {
2085  return _mesh;
2086 }

References libMesh::System::_mesh.

Referenced by libMesh::ExactSolution::_compute_error(), LinearElasticityWithContact::add_contact_edge_elements(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::HPCoarsenTest::add_projection(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), AssembleOptimization::assemble_A_and_F(), libMesh::FEMSystem::assemble_qoi(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::FEMSystem::assembly(), AssemblyA0::boundary_assembly(), AssemblyF0::boundary_assembly(), AssemblyA1::boundary_assembly(), AssemblyF1::boundary_assembly(), AssemblyF2::boundary_assembly(), AssemblyA2::boundary_assembly(), libMesh::System::calculate_norm(), compute_jacobian(), compute_residual(), LinearElasticityWithContact::compute_stresses(), DMCreateDomainDecomposition_libMesh(), DMCreateFieldDecomposition_libMesh(), DMlibMeshSetSystem_libMesh(), SolidSystem::element_time_derivative(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::GenericProjector(), LinearElasticityWithContact::get_least_and_max_gap_function(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), SolidSystem::init_data(), libMesh::System::init_data(), libMesh::RBEIMConstruction::init_dof_map_between_systems(), libMesh::EigenSystem::init_matrices(), libMesh::ImplicitSystem::init_matrices(), LinearElasticityWithContact::initialize_contact_load_paths(), libMesh::RBEIMAssembly::initialize_fe(), libMesh::System::local_dof_indices(), libMesh::DofMap::max_constraint_error(), libMesh::FEMSystem::mesh_position_get(), libMesh::FEMSystem::mesh_position_set(), LinearElasticityWithContact::move_mesh(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::petsc_auto_fieldsplit(), libMesh::RBEIMConstruction::plot_parametrized_functions_in_training_set(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::FEMSystem::postprocess(), libMesh::System::read_header(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::System::read_legacy_data(), libMesh::System::read_parallel_data(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::EigenSystem::reinit(), libMesh::ImplicitSystem::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::PetscDMWrapper::set_point_range_in_section(), SolidSystem::side_time_derivative(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::BoundaryVolumeSolutionTransfer::transfer_volume_boundary(), libMesh::TransientRBConstruction::truth_solve(), libMesh::RBEIMConstruction::truth_solve(), libMesh::RBConstruction::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 631 of file diff_physics.h.

632 {
633  return _mesh_sys;
634 }

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 625 of file diff_physics.h.

626 {
627  return _mesh_sys;
628 }

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 637 of file diff_physics.h.

638 {
639  return _mesh_x_var;
640 }

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 643 of file diff_physics.h.

644 {
645  return _mesh_y_var;
646 }

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 649 of file diff_physics.h.

650 {
651  return _mesh_z_var;
652 }

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 190 of file diff_system.h.

191  { return this->_diff_physics; }

References libMesh::DifferentiableSystem::_diff_physics.

◆ get_physics() [2/2]

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

◆ 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 218 of file diff_system.h.

219  { return this->diff_qoi; }

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 210 of file diff_system.h.

211  { return this->diff_qoi; }

References libMesh::DifferentiableSystem::diff_qoi.

◆ 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 310 of file diff_system.C.

311 {
312  // For SteadySolver or SecondOrderUnsteadySolvers, we just give back var
313  unsigned int dot_var = var;
314 
315  if (!time_solver->is_steady())
316  {
317  const UnsteadySolver & unsteady_solver =
318  cast_ref<const UnsteadySolver &>(*(time_solver.get()));
319 
320  if (unsteady_solver.time_order() == 1)
321  dot_var = this->_second_order_dot_vars.find(var)->second;
322  }
323 
324  return dot_var;
325 }

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

Referenced by libMesh::FirstOrderUnsteadySolver::compute_second_order_eqns().

◆ get_second_order_vars()

const std::set<unsigned int>& libMesh::DifferentiablePhysics::get_second_order_vars ( ) const
inlineinherited

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

1050 {
1051  std::ostringstream sensitivity_rhs_name;
1052  sensitivity_rhs_name << "sensitivity_rhs" << i;
1053 
1054  return this->get_vector(sensitivity_rhs_name.str());
1055 }

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

1060 {
1061  std::ostringstream sensitivity_rhs_name;
1062  sensitivity_rhs_name << "sensitivity_rhs" << i;
1063 
1064  return this->get_vector(sensitivity_rhs_name.str());
1065 }

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

905 {
906  std::ostringstream sensitivity_name;
907  sensitivity_name << "sensitivity_solution" << i;
908 
909  return this->get_vector(sensitivity_name.str());
910 }

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

915 {
916  std::ostringstream sensitivity_name;
917  sensitivity_name << "sensitivity_solution" << i;
918 
919  return this->get_vector(sensitivity_name.str());
920 }

References libMesh::System::get_vector().

◆ get_time_solver() [1/2]

TimeSolver & libMesh::DifferentiableSystem::get_time_solver ( )
inlineinherited
Returns
A pointer to the time solver attached to the calling system

Definition at line 416 of file diff_system.h.

417 {
419  libmesh_assert_equal_to (&(time_solver->system()), this);
420  return *time_solver;
421 }

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

Referenced by libMesh::DifferentiableSystem::adjoint_solve(), libMesh::FEMSystem::build_context(), libMesh::DiffContext::DiffContext(), libMesh::FEMSystem::postprocess(), libMesh::FEMContext::pre_fe_reinit(), and libMesh::DifferentiableSystem::solve().

◆ get_time_solver() [2/2]

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

Non-const version of the above.

Definition at line 424 of file diff_system.h.

425 {
427  libmesh_assert_equal_to (&(time_solver->system()), this);
428  return *time_solver;
429 }

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

◆ get_vector() [1/4]

NumericVector< Number > & libMesh::System::get_vector ( const std::string &  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 781 of file system.C.

782 {
783  return *(libmesh_map_find(_vectors, vec_name));
784 }

References libMesh::System::_vectors.

◆ get_vector() [2/4]

const NumericVector< Number > & libMesh::System::get_vector ( const std::string &  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 774 of file system.C.

775 {
776  return *(libmesh_map_find(_vectors, vec_name));
777 }

References libMesh::System::_vectors.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), add_M_C_K_helmholtz(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::NewmarkSolver::advance_timestep(), libMesh::AdaptiveTimeSolver::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_solution(), libMesh::System::get_sensitivity_rhs(), libMesh::System::get_sensitivity_solution(), libMesh::System::get_weighted_sensitivity_adjoint_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::SecondOrderUnsteadySolver::reinit(), libMesh::UnsteadySolver::reinit(), libMesh::MemorySolutionHistory::retrieve(), libMesh::UnsteadySolver::retrieve_timestep(), libMesh::TwostepTimeSolver::solve(), libMesh::FrequencySystem::solve(), libMesh::NewmarkSystem::update_rhs(), and libMesh::NewmarkSystem::update_u_v_a().

◆ get_vector() [3/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 804 of file system.C.

805 {
807  vectors_iterator v_end = vectors_end();
808  unsigned int num = 0;
809  while ((num<vec_num) && (v!=v_end))
810  {
811  num++;
812  ++v;
813  }
814  libmesh_assert (v != v_end);
815  return *(v->second);
816 }

References libMesh::libmesh_assert(), libMesh::System::vectors_begin(), and libMesh::System::vectors_end().

◆ get_vector() [4/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 788 of file system.C.

789 {
792  unsigned int num = 0;
793  while ((num<vec_num) && (v!=v_end))
794  {
795  num++;
796  ++v;
797  }
798  libmesh_assert (v != v_end);
799  return *(v->second);
800 }

References libMesh::libmesh_assert(), libMesh::System::vectors_begin(), and libMesh::System::vectors_end().

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

990 {
991  std::ostringstream adjoint_name;
992  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
993 
994  return this->get_vector(adjoint_name.str());
995 }

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

1000 {
1001  std::ostringstream adjoint_name;
1002  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1003 
1004  return this->get_vector(adjoint_name.str());
1005 }

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

932 {
933  return this->get_vector("weighted_sensitivity_solution");
934 }

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

939 {
940  return this->get_vector("weighted_sensitivity_solution");
941 }

References libMesh::System::get_vector().

◆ has_variable()

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

Definition at line 1225 of file system.C.

1226 {
1227  return _variable_numbers.count(var);
1228 }

References libMesh::System::_variable_numbers.

Referenced by 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 327 of file diff_system.C.

328 {
329  bool have_first_order_scalar_vars = false;
330 
331  if (this->have_first_order_vars())
332  for (const auto & var : this->get_first_order_vars())
333  if (this->variable(var).type().family == SCALAR)
335 
337 }

References libMesh::DifferentiablePhysics::get_first_order_vars(), libMesh::DifferentiablePhysics::have_first_order_vars(), libMesh::SCALAR, and libMesh::System::variable().

◆ have_first_order_vars()

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

◆ have_matrix()

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

Definition at line 439 of file implicit_system.h.

440 {
441  return (_matrices.count(mat_name));
442 }

References libMesh::ImplicitSystem::_matrices.

Referenced by libMesh::ImplicitSystem::add_matrix(), and 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 339 of file diff_system.C.

340 {
341  bool have_second_order_scalar_vars = false;
342 
343  if (this->have_second_order_vars())
344  for (const auto & var : this->get_second_order_vars())
345  if (this->variable(var).type().family == SCALAR)
347 
349 }

References libMesh::DifferentiablePhysics::get_second_order_vars(), libMesh::DifferentiablePhysics::have_second_order_vars(), libMesh::SCALAR, and libMesh::System::variable().

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

◆ have_second_order_vars()

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

◆ have_vector()

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

Definition at line 2275 of file system.h.

2276 {
2277  return (_vectors.count(vec_name));
2278 }

References libMesh::System::_vectors.

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

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

1712 { return _hide_output; }

References libMesh::System::_hide_output.

◆ identify_variable_groups() [1/2]

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

Definition at line 2251 of file system.h.

2252 {
2254 }

References libMesh::System::_identify_variable_groups.

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

◆ identify_variable_groups() [2/2]

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

Toggle automatic VariableGroup identification.

Definition at line 2259 of file system.h.

2260 {
2262 }

References libMesh::System::_identify_variable_groups.

◆ increment_constructor_count()

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

Increments the construction counter.

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

Definition at line 181 of file reference_counter.h.

182 {
183  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
184  std::pair<unsigned int, unsigned int> & p = _counts[name];
185 
186  p.first++;
187 }

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

◆ increment_destructor_count()

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

Increments the destruction counter.

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

Definition at line 194 of file reference_counter.h.

195 {
196  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
197  std::pair<unsigned int, unsigned int> & p = _counts[name];
198 
199  p.second++;
200 }

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

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

◆ init()

void libMesh::System::init ( )
inherited

Initializes degrees of freedom on the current mesh.

Sets the

Definition at line 237 of file system.C.

238 {
239  // Calling init() twice on the same system currently works evil
240  // magic, whether done directly or via EquationSystems::read()
241  libmesh_assert(!this->is_initialized());
242 
243  // First initialize any required data:
244  // either only the basic System data
245  if (_basic_system_only)
247  // or all the derived class' data too
248  else
249  this->init_data();
250 
251  // If no variables have been added to this system
252  // don't do anything
253  if (!this->n_vars())
254  return;
255 
256  // Then call the user-provided initialization function
257  this->user_initialization();
258 }

References libMesh::System::_basic_system_only, libMesh::System::init_data(), libMesh::System::is_initialized(), libMesh::libmesh_assert(), libMesh::System::n_vars(), and libMesh::System::user_initialization().

◆ init_context()

void FEMSystem::init_context ( DiffContext c)
overridevirtualinherited

Reimplemented from libMesh::DifferentiablePhysics.

Reimplemented in L2System, HeatSystem, HeatSystem, CoupledSystem, ElasticitySystem, LaplaceSystem, CurlCurlSystem, LaplaceSystem, PoissonSystem, LaplaceSystem, LaplaceSystem, CurlCurlSystem, SolidSystem, and NavierSystem.

Definition at line 1338 of file fem_system.C.

1339 {
1340  // Parent::init_context(c); // may be a good idea in derived classes
1341 
1342  // Although we do this in DiffSystem::build_context() and
1343  // FEMSystem::build_context() as well, we do it here just to be
1344  // extra sure that the deltat pointer gets set. Since the
1345  // intended behavior is for classes derived from FEMSystem to
1346  // call Parent::init_context() in their own init_context()
1347  // overloads, we can ensure that those classes get the correct
1348  // deltat pointers even if they have different build_context()
1349  // overloads.
1350  c.set_deltat_pointer ( &deltat );
1351 
1352  FEMContext & context = cast_ref<FEMContext &>(c);
1353 
1354  // Make sure we're prepared to do mass integration
1355  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
1356  if (this->get_physics()->is_time_evolving(var))
1357  {
1358  // Request shape functions based on FEType
1359  switch( FEInterface::field_type( this->variable_type(var) ) )
1360  {
1361  case( TYPE_SCALAR ):
1362  {
1363  FEBase * elem_fe = nullptr;
1364  context.get_element_fe(var, elem_fe);
1365  elem_fe->get_JxW();
1366  elem_fe->get_phi();
1367  }
1368  break;
1369  case( TYPE_VECTOR ):
1370  {
1371  FEGenericBase<RealGradient> * elem_fe = nullptr;
1372  context.get_element_fe(var, elem_fe);
1373  elem_fe->get_JxW();
1374  elem_fe->get_phi();
1375  }
1376  break;
1377  default:
1378  libmesh_error_msg("Unrecognized field type!");
1379  }
1380  }
1381 }

References libMesh::DifferentiableSystem::deltat, libMesh::FEInterface::field_type(), libMesh::FEMContext::get_element_fe(), libMesh::FEAbstract::get_JxW(), libMesh::FEGenericBase< OutputType >::get_phi(), libMesh::DifferentiableSystem::get_physics(), libMesh::DifferentiablePhysics::is_time_evolving(), libMesh::System::n_vars(), libMesh::DiffContext::set_deltat_pointer(), libMesh::TYPE_SCALAR, libMesh::TYPE_VECTOR, and libMesh::System::variable_type().

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

◆ init_data()

virtual void FirstOrderScalarSystemBase::init_data ( )
inlineoverridevirtualinherited

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

Reimplemented from libMesh::FEMSystem.

Reimplemented in SecondOrderScalarSystemSecondOrderTimeSolverBase.

Definition at line 110 of file time_solver_test_common.h.

111  {
112  _u_var = this->add_variable ("u", FIRST, LAGRANGE);
113  this->time_evolving(_u_var,1);
114  FEMSystem::init_data();
115  }

References libMesh::FIRST, libMesh::FEMSystem::init_data(), and libMesh::LAGRANGE.

◆ init_matrices()

void libMesh::ImplicitSystem::init_matrices ( )
protectedvirtualinherited

Initializes the matrices associated with this system.

Definition at line 105 of file implicit_system.C.

106 {
108 
109  // Check for quick return in case the system matrix
110  // (and by extension all the matrices) has already
111  // been initialized
112  if (matrix->initialized())
113  return;
114 
115  // Get a reference to the DofMap
116  DofMap & dof_map = this->get_dof_map();
117 
118  // no chance to add other matrices
119  _can_add_matrices = false;
120 
121  // Tell the matrices about the dof map, and vice versa
122  for (auto & pr : _matrices)
123  {
124  SparseMatrix<Number> & m = *(pr.second);
125  libmesh_assert (!m.initialized());
126 
127  // We want to allow repeated init() on systems, but we don't
128  // want to attach the same matrix to the DofMap twice
129  if (!dof_map.is_attached(m))
130  dof_map.attach_matrix (m);
131  }
132 
133  // Compute the sparsity pattern for the current
134  // mesh and DOF distribution. This also updates
135  // additional matrices, \p DofMap now knows them
136  dof_map.compute_sparsity (this->get_mesh());
137 
138  // Initialize matrices
139  for (auto & pr : _matrices)
140  pr.second->init ();
141 
142  // Set the additional matrices to 0.
143  for (auto & pr : _matrices)
144  pr.second->zero ();
145 }

References libMesh::ImplicitSystem::_can_add_matrices, libMesh::ImplicitSystem::_matrices, libMesh::DofMap::attach_matrix(), libMesh::DofMap::compute_sparsity(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::SparseMatrix< T >::initialized(), libMesh::DofMap::is_attached(), libMesh::libmesh_assert(), and libMesh::ImplicitSystem::matrix.

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

◆ init_physics()

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

Initialize any data structures associated with the physics.

Definition at line 40 of file diff_physics.C.

41 {
42  // give us flags for every variable that might be time evolving
43  _time_evolving.resize(sys.n_vars(), false);
44 }

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

Referenced by libMesh::DifferentiableSystem::attach_physics(), and libMesh::DifferentiableSystem::init_data().

◆ init_qoi()

virtual void libMesh::DifferentiableQoI::init_qoi ( std::vector< Number > &  )
inlinevirtualinherited

Initialize system qoi.

By default, does nothing in order to maintain backward compatibility for FEMSystem applications that control qoi.

Definition at line 71 of file diff_qoi.h.

71 {}

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

◆ is_adjoint_already_solved()

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

◆ is_first_order_var()

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

Definition at line 521 of file diff_physics.h.

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

References libMesh::DifferentiablePhysics::_first_order_vars.

◆ is_initialized()

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

Definition at line 2139 of file system.h.

2140 {
2141  return _is_initialized;
2142 }

References libMesh::System::_is_initialized.

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

◆ 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 278 of file diff_physics.h.

279  {
280  libmesh_assert_less(var,_time_evolving.size());
281  libmesh_assert( _time_evolving[var] == 0 ||
282  _time_evolving[var] == 1 ||
283  _time_evolving[var] == 2 );
284  return _time_evolving[var];
285  }

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

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

1261 {
1262  // Make sure the set is clear
1263  var_indices.clear();
1264 
1265  std::vector<dof_id_type> dof_indices;
1266 
1267  const dof_id_type
1268  first_local = this->get_dof_map().first_dof(),
1269  end_local = this->get_dof_map().end_dof();
1270 
1271  // Begin the loop over the elements
1272  for (const auto & elem : this->get_mesh().active_local_element_ptr_range())
1273  {
1274  this->get_dof_map().dof_indices (elem, dof_indices, var);
1275 
1276  for (dof_id_type dof : dof_indices)
1277  //If the dof is owned by the local processor
1278  if (first_local <= dof && dof < end_local)
1279  var_indices.insert(dof);
1280  }
1281 
1282  // we may have missed assigning DOFs to nodes that we own
1283  // but to which we have no connected elements matching our
1284  // variable restriction criterion. this will happen, for example,
1285  // if variable V is restricted to subdomain S. We may not own
1286  // any elements which live in S, but we may own nodes which are
1287  // *connected* to elements which do.
1288  for (const auto & node : this->get_mesh().local_node_ptr_range())
1289  {
1290  libmesh_assert(node);
1291  this->get_dof_map().dof_indices (node, dof_indices, var);
1292  for (auto dof : dof_indices)
1293  if (first_local <= dof && dof < end_local)
1294  var_indices.insert(dof);
1295  }
1296 }

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

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

◆ M() [1/2]

virtual Number ConstantFirstOrderODE::M ( FEMContext &  ,
unsigned int   
)
inlinevirtual

Definition at line 25 of file first_order_unsteady_solver_test.C.

26  { return Real(21)/10; }

References libMesh::Real.

◆ M() [2/2]

virtual Number FirstOrderScalarSystemBase::M ( FEMContext context,
unsigned int  qp 
)
pure virtualinherited

Value of M(u).

◆ mass_residual()

virtual bool FirstOrderScalarSystemBase::mass_residual ( bool  request_jacobian,
DiffContext context 
)
inlineoverridevirtualinherited

Note the nonlinear residual is F(u)-M(u)

{u}

Reimplemented from libMesh::FEMPhysics.

Reimplemented in SecondOrderScalarSystemFirstOrderTimeSolverBase, and SecondOrderScalarSystemSecondOrderTimeSolverBase.

Definition at line 140 of file time_solver_test_common.h.

142  {
143  FEMContext & c = cast_ref<FEMContext &>(context);
146 
147  const unsigned int n_u_dofs =
148  cast_int<unsigned int>(c.get_dof_indices(_u_var).size());
149  unsigned int n_qpoints = c.get_element_qrule().n_points();
150 
151  for (unsigned int qp=0; qp != n_qpoints; qp++)
152  {
153  libMesh::Number udot;
154  c.interior_rate(_u_var,qp,udot);
155 
156  Number Mval = this->M(c,qp);
157 
158  for (unsigned int i=0; i != n_u_dofs; i++)
159  {
160  Fu(i) -= Mval*udot;
161 
162  if (request_jacobian)
163  for (unsigned int j=0; j != n_u_dofs; j++)
164  Kuu(i,j) -= Mval*context.get_elem_solution_rate_derivative();
165  }
166  }
167 
168  return request_jacobian;
169  }

References libMesh::DiffContext::get_dof_indices(), libMesh::DiffContext::get_elem_jacobian(), libMesh::DiffContext::get_elem_residual(), libMesh::DiffContext::get_elem_solution_rate_derivative(), libMesh::FEMContext::get_element_qrule(), libMesh::FEMContext::interior_rate(), and libMesh::QBase::n_points().

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

1386 {
1387  // This function makes no sense unless we've already picked out some
1388  // variable(s) to reflect mesh position coordinates
1389  if (!_mesh_sys)
1390  libmesh_error_msg("_mesh_sys was nullptr!");
1391 
1392  // We currently assume mesh variables are in our own system
1393  if (_mesh_sys != this)
1394  libmesh_not_implemented();
1395 
1396  // Loop over every active mesh element on this processor
1397  const MeshBase & mesh = this->get_mesh();
1398 
1399  std::unique_ptr<DiffContext> con = this->build_context();
1400  FEMContext & _femcontext = cast_ref<FEMContext &>(*con);
1401  this->init_context(_femcontext);
1402 
1403  // Get the solution's mesh variables from every element
1404  for (const auto & elem : mesh.active_local_element_ptr_range())
1405  {
1406  _femcontext.pre_fe_reinit(*this, elem);
1407 
1408  _femcontext.elem_position_get();
1409 
1411  this->solution->insert(_femcontext.get_elem_solution(_mesh_x_var),
1412  _femcontext.get_dof_indices(_mesh_x_var) );
1414  this->solution->insert(_femcontext.get_elem_solution(_mesh_y_var),
1415  _femcontext.get_dof_indices(_mesh_y_var));
1417  this->solution->insert(_femcontext.get_elem_solution(_mesh_z_var),
1418  _femcontext.get_dof_indices(_mesh_z_var));
1419  }
1420 
1421  this->solution->close();
1422 
1423  // And make sure the current_local_solution is up to date too
1424  this->System::update();
1425 }

References libMesh::DifferentiablePhysics::_mesh_sys, libMesh::DifferentiablePhysics::_mesh_x_var, libMesh::DifferentiablePhysics::_mesh_y_var, libMesh::DifferentiablePhysics::_mesh_z_var, libMesh::MeshBase::active_local_element_ptr_range(), 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 1057 of file fem_system.C.

1058 {
1059  // If we don't need to move the mesh, we're done
1060  if (_mesh_sys != this)
1061  return;
1062 
1063  MeshBase & mesh = this->get_mesh();
1064 
1065  std::unique_ptr<DiffContext> con = this->build_context();
1066  FEMContext & _femcontext = cast_ref<FEMContext &>(*con);
1067  this->init_context(_femcontext);
1068 
1069  // Move every mesh element we can
1070  for (const auto & elem : mesh.active_local_element_ptr_range())
1071  {
1072  // We need the algebraic data
1073  _femcontext.pre_fe_reinit(*this, elem);
1074  // And when asserts are on, we also need the FE so
1075  // we can assert that the mesh data is of the right type.
1076 #ifndef NDEBUG
1077  _femcontext.elem_fe_reinit();
1078 #endif
1079 
1080  // This code won't handle moving subactive elements
1081  libmesh_assert(!_femcontext.get_elem().has_children());
1082 
1083  _femcontext.elem_position_set(1.);
1084  }
1085 
1086  // We've now got positions set on all local nodes (and some
1087  // semilocal nodes); let's request positions for non-local nodes
1088  // from their processors.
1089 
1090  SyncNodalPositions sync_object(mesh);
1092  (this->comm(), mesh.nodes_begin(), mesh.nodes_end(), sync_object);
1093 }

References libMesh::DifferentiablePhysics::_mesh_sys, libMesh::MeshBase::active_local_element_ptr_range(), 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::MeshBase::nodes_begin(), libMesh::MeshBase::nodes_end(), 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 2267 of file system.h.

2268 {
2269  return this->n_dofs() - this->n_constrained_dofs();
2270 }

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

◆ n_components()

unsigned int libMesh::System::n_components ( ) const
inlineinherited
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 2171 of file system.h.

2172 {
2173  if (_variables.empty())
2174  return 0;
2175 
2176  const Variable & last = _variables.back();
2177  return last.first_scalar_number() + last.n_components();
2178 }

References libMesh::System::_variables, libMesh::Variable::first_scalar_number(), and libMesh::Variable::n_components().

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

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

158 {
159 #ifdef LIBMESH_ENABLE_CONSTRAINTS
160 
161  return _dof_map->n_constrained_dofs();
162 
163 #else
164 
165  return 0;
166 
167 #endif
168 }

References libMesh::System::_dof_map.

Referenced by libMesh::System::get_info(), libMesh::System::n_active_dofs(), 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 150 of file system.C.

151 {
152  return _dof_map->n_dofs();
153 }

References libMesh::System::_dof_map.

Referenced by libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::System::add_vector(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::RBConstruction::enrich_RB_space(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::System::get_info(), libMesh::SecondOrderUnsteadySolver::init_data(), libMesh::UnsteadySolver::init_data(), libMesh::System::init_data(), libMesh::RBEIMConstruction::init_dof_map_between_systems(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_rb_construction(), 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::RBEIMAssembly::RBEIMAssembly(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::System::read_legacy_data(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::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::RBEIMConstruction::set_explicit_sys_subvector(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), SystemsTest::testProjectCubeWithMeshFunction(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::RBEIMConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::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 172 of file system.C.

173 {
174 #ifdef LIBMESH_ENABLE_CONSTRAINTS
175 
176  return _dof_map->n_local_constrained_dofs();
177 
178 #else
179 
180  return 0;
181 
182 #endif
183 }

References libMesh::System::_dof_map.

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

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

188 {
189  return _dof_map->n_dofs_on_processor (this->processor_id());
190 }

References libMesh::System::_dof_map, and libMesh::ParallelObject::processor_id().

Referenced by libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::System::add_vector(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::PetscDMWrapper::build_section(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::RBConstruction::enrich_RB_space(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::System::get_info(), libMesh::SecondOrderUnsteadySolver::init_data(), libMesh::UnsteadySolver::init_data(), libMesh::System::init_data(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_rb_construction(), main(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::RBEIMAssembly::RBEIMAssembly(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::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(), MeshFunctionTest::test_p_level(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), and libMesh::RBConstruction::update_residual_terms().

◆ n_matrices()

unsigned int libMesh::ImplicitSystem::n_matrices ( ) const
inlineoverridevirtualinherited
Returns
The number of matrices handled by this system

Reimplemented from libMesh::System.

Definition at line 446 of file implicit_system.h.

447 {
448  return cast_int<unsigned int>(_matrices.size());
449 }

References libMesh::ImplicitSystem::_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 83 of file reference_counter.h.

84  { return _n_objects; }

References libMesh::ReferenceCounter::_n_objects.

◆ n_processors()

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

Definition at line 100 of file parallel_object.h.

101  { return cast_int<processor_id_type>(_communicator.size()); }

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::DofMap::add_constraints_to_send_list(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::EnsightIO::EnsightIO(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), 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::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::partition(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::prepare_send_list(), libMesh::DofMap::print_dof_constraints(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::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(), OverlappingFunctorTest::run_partitioner_test(), libMesh::DofMap::scatter_constraints(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), CheckpointIOTest::testSplitter(), WriteVecAndScalar::testWrite(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), 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

◆ n_variable_groups()

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

Definition at line 2163 of file system.h.

2164 {
2165  return cast_int<unsigned int>(_variable_groups.size());
2166 }

References libMesh::System::_variable_groups.

Referenced by libMesh::System::add_variable(), libMesh::FEMSystem::assembly(), libMesh::System::get_info(), and libMesh::System::init_data().

◆ n_vars()

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

Definition at line 2155 of file system.h.

2156 {
2157  return cast_int<unsigned int>(_variables.size());
2158 }

References libMesh::System::_variables.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::PetscDMWrapper::add_dofs_helper(), libMesh::DiffContext::add_localized_vector(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::System::add_variable(), libMesh::System::add_variables(), libMesh::FEMContext::attach_quadrature_rules(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_section(), libMesh::System::calculate_norm(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::DGFEMContext::DGFEMContext(), libMesh::DiffContext::DiffContext(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::ErrorEstimator::estimate_errors(), libMesh::ExactSolution::ExactSolution(), libMesh::FEMContext::find_hardest_fe_type(), libMesh::EquationSystems::find_variable_numbers(), libMesh::System::get_all_variable_numbers(), libMesh::System::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::FEMSystem::init_context(), libMesh::RBEIMConstruction::init_context_with_sys(), libMesh::RBEIMConstruction::init_dof_map_between_systems(), libMesh::FEMContext::init_internal_data(), libMesh::DifferentiablePhysics::init_physics(), AssemblyA0::interior_assembly(), AssemblyA1::interior_assembly(), AssemblyA2::interior_assembly(), main(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), output_norms(), libMesh::petsc_auto_fieldsplit(), libMesh::FEMContext::pre_fe_reinit(), libMesh::System::re_update(), libMesh::System::read_legacy_data(), libMesh::System::read_parallel_data(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::HPCoarsenTest::select_refinement(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::SystemSubsetBySubdomain::set_var_nums(), OverlappingTestBase::setup_coupling_matrix(), SystemsTest::testDofCouplingWithVarGroups(), SlitMeshRefinedSystemTest::testRestart(), SlitMeshRefinedSystemTest::testSystem(), libMesh::RBEIMConstruction::truth_solve(), libMesh::RBEIMConstruction::update_RB_system_matrices(), 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 2283 of file system.h.

2284 {
2285  return cast_int<unsigned int>(_vectors.size());
2286 }

References libMesh::System::_vectors.

Referenced by libMesh::ExplicitSystem::add_system_rhs(), libMesh::System::compare(), libMesh::System::get_info(), main(), 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 228 of file diff_physics.h.

229  {
230  return request_jacobian;
231  }

Referenced by libMesh::EulerSolver::nonlocal_residual(), libMesh::Euler2Solver::nonlocal_residual(), libMesh::SteadySolver::nonlocal_residual(), libMesh::EigenTimeSolver::nonlocal_residual(), and libMesh::NewmarkSolver::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 407 of file diff_physics.h.

408  {
409  return request_jacobian;
410  }

Referenced by libMesh::EulerSolver::nonlocal_residual(), libMesh::Euler2Solver::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 63 of file diff_physics.C.

65 {
66  FEMContext & context = cast_ref<FEMContext &>(c);
67 
68  for (auto var : IntRange<unsigned int>(0, context.n_vars()))
69  {
70  if (!this->is_time_evolving(var))
71  continue;
72 
73  if (c.get_system().variable(var).type().family != SCALAR)
74  continue;
75 
76  const std::vector<dof_id_type> & dof_indices =
77  context.get_dof_indices(var);
78 
79  const unsigned int n_dofs = cast_int<unsigned int>
80  (dof_indices.size());
81 
82  DenseSubVector<Number> & Fs = context.get_elem_residual(var);
83  DenseSubMatrix<Number> & Kss = context.get_elem_jacobian( var, var );
84 
86  context.get_elem_solution(var);
87 
88  for (unsigned int i=0; i != n_dofs; ++i)
89  {
90  Fs(i) -= Us(i);
91 
92  if (request_jacobian)
93  Kss(i,i) -= context.elem_solution_rate_derivative;
94  }
95  }
96 
97  return request_jacobian;
98 }

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::DiffContext::n_vars(), libMesh::SCALAR, libMesh::Variable::type(), and libMesh::System::variable().

Referenced by libMesh::EulerSolver::nonlocal_residual(), libMesh::Euler2Solver::nonlocal_residual(), libMesh::EigenTimeSolver::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 210 of file diff_physics.h.

211  {
212  return request_jacobian;
213  }

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

◆ number()

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

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

1291 {
1292  LOG_SCOPE("numerical_elem_jacobian()", "FEMSystem");
1294 }

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

1180 {
1181  // Logging is done by numerical_elem_jacobian
1182  // or numerical_side_jacobian
1183 
1184  DenseVector<Number> original_residual(context.get_elem_residual());
1185  DenseVector<Number> backwards_residual(context.get_elem_residual());
1186  DenseMatrix<Number> numeric_jacobian(context.get_elem_jacobian());
1187 #ifdef DEBUG
1188  DenseMatrix<Number> old_jacobian(context.get_elem_jacobian());
1189 #endif
1190 
1191  Real numerical_point_h = 0.;
1192  if (_mesh_sys == this)
1193  numerical_point_h = numerical_jacobian_h * context.get_elem().hmin();
1194 
1195  const unsigned int n_dofs =
1196  cast_int<unsigned int>(context.get_dof_indices().size());
1197 
1198  for (auto v : IntRange<unsigned int>(0, context.n_vars()))
1199  {
1200  const Real my_h = this->numerical_jacobian_h_for_var(v);
1201 
1202  unsigned int j_offset = libMesh::invalid_uint;
1203 
1204  if (!context.get_dof_indices(v).empty())
1205  {
1206  for (auto i : IntRange<unsigned int>(0, n_dofs))
1207  if (context.get_dof_indices()[i] ==
1208  context.get_dof_indices(v)[0])
1209  j_offset = i;
1210 
1211  libmesh_assert_not_equal_to(j_offset, libMesh::invalid_uint);
1212  }
1213 
1214  for (auto j : IntRange<unsigned int>(0, context.get_dof_indices(v).size()))
1215  {
1216  const unsigned int total_j = j + j_offset;
1217 
1218  // Take the "minus" side of a central differenced first derivative
1219  Number original_solution = context.get_elem_solution(v)(j);
1220  context.get_elem_solution(v)(j) -= my_h;
1221 
1222  // Make sure to catch any moving mesh terms
1223  Real * coord = nullptr;
1224  if (_mesh_sys == this)
1225  {
1226  if (_mesh_x_var == v)
1227  coord = &(context.get_elem().point(j)(0));
1228  else if (_mesh_y_var == v)
1229  coord = &(context.get_elem().point(j)(1));
1230  else if (_mesh_z_var == v)
1231  coord = &(context.get_elem().point(j)(2));
1232  }
1233  if (coord)
1234  {
1235  // We have enough information to scale the perturbations
1236  // here appropriately
1237  context.get_elem_solution(v)(j) = original_solution - numerical_point_h;
1238  *coord = libmesh_real(context.get_elem_solution(v)(j));
1239  }
1240 
1241  context.get_elem_residual().zero();
1242  ((*time_solver).*(res))(false, context);
1243 #ifdef DEBUG
1244  libmesh_assert_equal_to (old_jacobian, context.get_elem_jacobian());
1245 #endif
1246  backwards_residual = context.get_elem_residual();
1247 
1248  // Take the "plus" side of a central differenced first derivative
1249  context.get_elem_solution(v)(j) = original_solution + my_h;
1250  if (coord)
1251  {
1252  context.get_elem_solution()(j) = original_solution + numerical_point_h;
1253  *coord = libmesh_real(context.get_elem_solution(v)(j));
1254  }
1255  context.get_elem_residual().zero();
1256  ((*time_solver).*(res))(false, context);
1257 #ifdef DEBUG
1258  libmesh_assert_equal_to (old_jacobian, context.get_elem_jacobian());
1259 #endif
1260 
1261  context.get_elem_solution(v)(j) = original_solution;
1262  if (coord)
1263  {
1264  *coord = libmesh_real(context.get_elem_solution(v)(j));
1265  for (auto i : IntRange<unsigned int>(0, n_dofs))
1266  {
1267  numeric_jacobian(i,total_j) =
1268  (context.get_elem_residual()(i) - backwards_residual(i)) /
1269  2. / numerical_point_h;
1270  }
1271  }
1272  else
1273  {
1274  for (auto i : IntRange<unsigned int>(0, n_dofs))
1275  {
1276  numeric_jacobian(i,total_j) =
1277  (context.get_elem_residual()(i) - backwards_residual(i)) /
1278  2. / my_h;
1279  }
1280  }
1281  }
1282  }
1283 
1284  context.get_elem_residual() = original_residual;
1285  context.get_elem_jacobian() = numeric_jacobian;
1286 }

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::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 259 of file fem_system.h.

260 {
261  if ((var_num >= _numerical_jacobian_h_for_var.size()) ||
262  _numerical_jacobian_h_for_var[var_num] == Real(0))
263  return numerical_jacobian_h;
264 
265  return _numerical_jacobian_h_for_var[var_num];
266 }

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

1307 {
1308  LOG_SCOPE("numerical_nonlocal_jacobian()", "FEMSystem");
1310 }

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

1299 {
1300  LOG_SCOPE("numerical_side_jacobian()", "FEMSystem");
1302 }

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 }

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

2104 {
2105  // This function must be called on every processor; there's no
2106  // telling where in the partition p falls.
2107  parallel_object_only();
2108 
2109  // And every processor had better agree about which point we're
2110  // looking for
2111 #ifndef NDEBUG
2112  libmesh_assert(this->comm().verify(p(0)));
2113 #if LIBMESH_DIM > 1
2114  libmesh_assert(this->comm().verify(p(1)));
2115 #endif
2116 #if LIBMESH_DIM > 2
2117  libmesh_assert(this->comm().verify(p(2)));
2118 #endif
2119 #endif // NDEBUG
2120 
2121  // Get a reference to the mesh object associated with the system object that calls this function
2122  const MeshBase & mesh = this->get_mesh();
2123 
2124  // Use an existing PointLocator or create a new one
2125  std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2126  PointLocatorBase & locator = *locator_ptr;
2127 
2128  if (!insist_on_success || !mesh.is_serial())
2129  locator.enable_out_of_mesh_mode();
2130 
2131  // Get a pointer to an element that contains p and allows us to
2132  // evaluate var
2133  const std::set<subdomain_id_type> & raw_subdomains =
2134  this->variable(var).active_subdomains();
2135  const std::set<subdomain_id_type> * implicit_subdomains =
2136  raw_subdomains.empty() ? nullptr : &raw_subdomains;
2137  const Elem * e = locator(p, implicit_subdomains);
2138 
2139  Gradient grad_u;
2140 
2141  if (e && this->get_dof_map().is_evaluable(*e, var))
2142  grad_u = point_gradient(var, p, *e, sol);
2143 
2144  // If I have an element containing p, then let's let everyone know
2145  processor_id_type lowest_owner =
2146  (e && (e->processor_id() == this->processor_id())) ?
2147  this->processor_id() : this->n_processors();
2148  this->comm().min(lowest_owner);
2149 
2150  // Everybody should get their value from a processor that was able
2151  // to compute it.
2152  // If nobody admits owning the point, we may have a problem.
2153  if (lowest_owner != this->n_processors())
2154  this->comm().broadcast(grad_u, lowest_owner);
2155  else
2156  libmesh_assert(!insist_on_success);
2157 
2158  return grad_u;
2159 }

References libMesh::Variable::active_subdomains(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::libmesh_assert(), mesh, libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), and libMesh::System::variable().

Referenced by line_print(), and libMesh::System::point_gradient().

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

2166 {
2167  // Ensuring that the given point is really in the element is an
2168  // expensive assert, but as long as debugging is turned on we might
2169  // as well try to catch a particularly nasty potential error
2170  libmesh_assert (e.contains_point(p));
2171 
2172  if (!sol)
2173  sol = this->current_local_solution.get();
2174 
2175  // Get the dof map to get the proper indices for our computation
2176  const DofMap & dof_map = this->get_dof_map();
2177 
2178  // write the element dimension into a separate variable.
2179  const unsigned int dim = e.dim();
2180 
2181  // Make sure we can evaluate on this element.
2182  libmesh_assert (dof_map.is_evaluable(e, var));
2183 
2184  // Need dof_indices for phi[i][j]
2185  std::vector<dof_id_type> dof_indices;
2186 
2187  // Fill in the dof_indices for our element
2188  dof_map.dof_indices (&e, dof_indices, var);
2189 
2190  // Get the no of dofs associated with this point
2191  const unsigned int num_dofs = cast_int<unsigned int>
2192  (dof_indices.size());
2193 
2194  FEType fe_type = dof_map.variable_type(var);
2195 
2196  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h.
2197  Point coor = FEMap::inverse_map(dim, &e, p);
2198 
2199  // get the shape function value via the FEInterface to also handle the case
2200  // of infinite elements correcly, the shape function is not fe->phi().
2201  FEComputeData fe_data(this->get_equation_systems(), coor);
2202  fe_data.enable_derivative();
2203  FEInterface::compute_data(dim, fe_type, &e, fe_data);
2204 
2205  // Get ready to accumulate a gradient
2206  Gradient grad_u;
2207 
2208  for (unsigned int l=0; l<num_dofs; l++)
2209  {
2210  // Chartesian coordinates have allways LIBMESH_DIM entries,
2211  // local coordinates have as many coordinates as the element has.
2212  for (std::size_t v=0; v<dim; v++)
2213  for (std::size_t xyz=0; xyz<LIBMESH_DIM; xyz++)
2214  {
2215  // FIXME: this needs better syntax: It is matrix-vector multiplication.
2216  grad_u(xyz) += fe_data.local_transform[v][xyz]
2217  * fe_data.dshape[l](v)
2218  * (*sol)(dof_indices[l]);
2219  }
2220  }
2221 
2222  return grad_u;
2223 }

References libMesh::FEInterface::compute_data(), libMesh::Elem::contains_point(), libMesh::System::current_local_solution, dim, libMesh::Elem::dim(), libMesh::DofMap::dof_indices(), libMesh::FEComputeData::dshape, libMesh::FEComputeData::enable_derivative(), libMesh::System::get_dof_map(), libMesh::System::get_equation_systems(), libMesh::FEMap::inverse_map(), 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 2227 of file system.C.

2228 {
2229  libmesh_assert(e);
2230  return this->point_gradient(var, p, *e);
2231 }

References libMesh::libmesh_assert(), and libMesh::System::point_gradient().

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

2236 {
2237  return this->point_gradient(var, p, true, sol);
2238 }

References libMesh::System::point_gradient().

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

2248 {
2249  // This function must be called on every processor; there's no
2250  // telling where in the partition p falls.
2251  parallel_object_only();
2252 
2253  // And every processor had better agree about which point we're
2254  // looking for
2255 #ifndef NDEBUG
2256  libmesh_assert(this->comm().verify(p(0)));
2257 #if LIBMESH_DIM > 1
2258  libmesh_assert(this->comm().verify(p(1)));
2259 #endif
2260 #if LIBMESH_DIM > 2
2261  libmesh_assert(this->comm().verify(p(2)));
2262 #endif
2263 #endif // NDEBUG
2264 
2265  // Get a reference to the mesh object associated with the system object that calls this function
2266  const MeshBase & mesh = this->get_mesh();
2267 
2268  // Use an existing PointLocator or create a new one
2269  std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2270  PointLocatorBase & locator = *locator_ptr;
2271 
2272  if (!insist_on_success || !mesh.is_serial())
2273  locator.enable_out_of_mesh_mode();
2274 
2275  // Get a pointer to an element that contains p and allows us to
2276  // evaluate var
2277  const std::set<subdomain_id_type> & raw_subdomains =
2278  this->variable(var).active_subdomains();
2279  const std::set<subdomain_id_type> * implicit_subdomains =
2280  raw_subdomains.empty() ? nullptr : &raw_subdomains;
2281  const Elem * e = locator(p, implicit_subdomains);
2282 
2283  Tensor hess_u;
2284 
2285  if (e && this->get_dof_map().is_evaluable(*e, var))
2286  hess_u = point_hessian(var, p, *e, sol);
2287 
2288  // If I have an element containing p, then let's let everyone know
2289  processor_id_type lowest_owner =
2290  (e && (e->processor_id() == this->processor_id())) ?
2291  this->processor_id() : this->n_processors();
2292  this->comm().min(lowest_owner);
2293 
2294  // Everybody should get their value from a processor that was able
2295  // to compute it.
2296  // If nobody admits owning the point, we may have a problem.
2297  if (lowest_owner != this->n_processors())
2298  this->comm().broadcast(hess_u, lowest_owner);
2299  else
2300  libmesh_assert(!insist_on_success);
2301 
2302  return hess_u;
2303 }

References libMesh::Variable::active_subdomains(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::libmesh_assert(), mesh, libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), and libMesh::System::variable().

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

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

2309 {
2310  // Ensuring that the given point is really in the element is an
2311  // expensive assert, but as long as debugging is turned on we might
2312  // as well try to catch a particularly nasty potential error
2313  libmesh_assert (e.contains_point(p));
2314 
2315  if (!sol)
2316  sol = this->current_local_solution.get();
2317 
2318 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
2319  if (e.infinite())
2320  libmesh_not_implemented();
2321 #endif
2322 
2323  // Get the dof map to get the proper indices for our computation
2324  const DofMap & dof_map = this->get_dof_map();
2325 
2326  // Make sure we can evaluate on this element.
2327  libmesh_assert (dof_map.is_evaluable(e, var));
2328 
2329  // Need dof_indices for phi[i][j]
2330  std::vector<dof_id_type> dof_indices;
2331 
2332  // Fill in the dof_indices for our element
2333  dof_map.dof_indices (&e, dof_indices, var);
2334 
2335  // Get the no of dofs associated with this point
2336  const unsigned int num_dofs = cast_int<unsigned int>
2337  (dof_indices.size());
2338 
2339  FEType fe_type = dof_map.variable_type(var);
2340 
2341  // Build a FE again so we can calculate u(p)
2342  std::unique_ptr<FEBase> fe (FEBase::build(e.dim(), fe_type));
2343 
2344  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
2345  // Build a vector of point co-ordinates to send to reinit
2346  std::vector<Point> coor(1, FEMap::inverse_map(e.dim(), &e, p));
2347 
2348  // Get the values of the shape function derivatives
2349  const std::vector<std::vector<RealTensor>> & d2phi = fe->get_d2phi();
2350 
2351  // Reinitialize the element and compute the shape function values at coor
2352  fe->reinit (&e, &coor);
2353 
2354  // Get ready to accumulate a hessian
2355  Tensor hess_u;
2356 
2357  for (unsigned int l=0; l<num_dofs; l++)
2358  {
2359  hess_u.add_scaled (d2phi[l][0], (*sol)(dof_indices[l]));
2360  }
2361 
2362  return hess_u;
2363 }

References libMesh::TypeTensor< T >::add_scaled(), libMesh::FEGenericBase< OutputType >::build(), libMesh::Elem::contains_point(), libMesh::System::current_local_solution, libMesh::Elem::dim(), libMesh::DofMap::dof_indices(), libMesh::System::get_dof_map(), libMesh::Elem::infinite(), libMesh::FEMap::inverse_map(), 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 2367 of file system.C.

2368 {
2369  libmesh_assert(e);
2370  return this->point_hessian(var, p, *e);
2371 }

References libMesh::libmesh_assert(), and libMesh::System::point_hessian().

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

2376 {
2377  return this->point_hessian(var, p, true, sol);
2378 }

References libMesh::System::point_hessian().

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

1975 {
1976  // This function must be called on every processor; there's no
1977  // telling where in the partition p falls.
1978  parallel_object_only();
1979 
1980  // And every processor had better agree about which point we're
1981  // looking for
1982 #ifndef NDEBUG
1983  libmesh_assert(this->comm().verify(p(0)));
1984 #if LIBMESH_DIM > 1
1985  libmesh_assert(this->comm().verify(p(1)));
1986 #endif
1987 #if LIBMESH_DIM > 2
1988  libmesh_assert(this->comm().verify(p(2)));
1989 #endif
1990 #endif // NDEBUG
1991 
1992  // Get a reference to the mesh object associated with the system object that calls this function
1993  const MeshBase & mesh = this->get_mesh();
1994 
1995  // Use an existing PointLocator or create a new one
1996  std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
1997  PointLocatorBase & locator = *locator_ptr;
1998 
1999  if (!insist_on_success || !mesh.is_serial())
2000  locator.enable_out_of_mesh_mode();
2001 
2002  // Get a pointer to an element that contains p and allows us to
2003  // evaluate var
2004  const std::set<subdomain_id_type> & raw_subdomains =
2005  this->variable(var).active_subdomains();
2006  const std::set<subdomain_id_type> * implicit_subdomains =
2007  raw_subdomains.empty() ? nullptr : &raw_subdomains;
2008  const Elem * e = locator(p, implicit_subdomains);
2009 
2010  Number u = 0;
2011 
2012  if (e && this->get_dof_map().is_evaluable(*e, var))
2013  u = point_value(var, p, *e, sol);
2014 
2015  // If I have an element containing p, then let's let everyone know
2016  processor_id_type lowest_owner =
2017  (e && (e->processor_id() == this->processor_id())) ?
2018  this->processor_id() : this->n_processors();
2019  this->comm().min(lowest_owner);
2020 
2021  // Everybody should get their value from a processor that was able
2022  // to compute it.
2023  // If nobody admits owning the point, we have a problem.
2024  if (lowest_owner != this->n_processors())
2025  this->comm().broadcast(u, lowest_owner);
2026  else
2027  libmesh_assert(!insist_on_success);
2028 
2029  return u;
2030 }

References libMesh::Variable::active_subdomains(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::libmesh_assert(), mesh, libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), and libMesh::System::variable().

Referenced by line_print(), main(), libMesh::System::point_value(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testExodusCopyElementSolution(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), SystemsTest::testProjectCubeWithMeshFunction(), and EquationSystemsTest::testRepartitionThenReinit().

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

2036 {
2037  // Ensuring that the given point is really in the element is an
2038  // expensive assert, but as long as debugging is turned on we might
2039  // as well try to catch a particularly nasty potential error
2040  libmesh_assert (e.contains_point(p));
2041 
2042  if (!sol)
2043  sol = this->current_local_solution.get();
2044 
2045  // Get the dof map to get the proper indices for our computation
2046  const DofMap & dof_map = this->get_dof_map();
2047 
2048  // Make sure we can evaluate on this element.
2049  libmesh_assert (dof_map.is_evaluable(e, var));
2050 
2051  // Need dof_indices for phi[i][j]
2052  std::vector<dof_id_type> dof_indices;
2053 
2054  // Fill in the dof_indices for our element
2055  dof_map.dof_indices (&e, dof_indices, var);
2056 
2057  // Get the no of dofs associated with this point
2058  const unsigned int num_dofs = cast_int<unsigned int>
2059  (dof_indices.size());
2060 
2061  FEType fe_type = dof_map.variable_type(var);
2062 
2063  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h.
2064  Point coor = FEMap::inverse_map(e.dim(), &e, p);
2065 
2066  // get the shape function value via the FEInterface to also handle the case
2067  // of infinite elements correcly, the shape function is not fe->phi().
2068  FEComputeData fe_data(this->get_equation_systems(), coor);
2069  FEInterface::compute_data(e.dim(), fe_type, &e, fe_data);
2070 
2071  // Get ready to accumulate a value
2072  Number u = 0;
2073 
2074  for (unsigned int l=0; l<num_dofs; l++)
2075  {
2076  u += fe_data.shape[l] * (*sol)(dof_indices[l]);
2077  }
2078 
2079  return u;
2080 }

References libMesh::FEInterface::compute_data(), libMesh::Elem::contains_point(), libMesh::System::current_local_solution, libMesh::Elem::dim(), libMesh::DofMap::dof_indices(), libMesh::System::get_dof_map(), libMesh::System::get_equation_systems(), libMesh::FEMap::inverse_map(), libMesh::DofMap::is_evaluable(), libMesh::libmesh_assert(), 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 2084 of file system.C.

2085 {
2086  libmesh_assert(e);
2087  return this->point_value(var, p, *e);
2088 }

References libMesh::libmesh_assert(), and libMesh::System::point_value().

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

2093 {
2094  return this->point_value(var, p, true, sol);
2095 }

References libMesh::System::point_value().

◆ postprocess()

void FEMSystem::postprocess ( void  )
overridevirtualinherited

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

Reimplemented from libMesh::DifferentiableSystem.

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

Definition at line 1097 of file fem_system.C.

1098 {
1099  LOG_SCOPE("postprocess()", "FEMSystem");
1100 
1101  const MeshBase & mesh = this->get_mesh();
1102 
1103  this->update();
1104 
1105  // Get the time solver object associated with the system, and tell it that
1106  // we are not solving the adjoint problem
1107  this->get_time_solver().set_is_adjoint(false);
1108 
1109  // Loop over every active mesh element on this processor
1112  PostprocessContributions(*this));
1113 }

References libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::System::get_mesh(), libMesh::DifferentiableSystem::get_time_solver(), mesh, libMesh::Threads::parallel_for(), libMesh::StoredRange< iterator_type, object_type >::reset(), libMesh::TimeSolver::set_is_adjoint(), and libMesh::System::update().

Referenced by main(), PoissonSystem::postprocess(), and LaplaceSystem::postprocess().

◆ print_info()

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

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

Definition at line 87 of file reference_counter.C.

88 {
90  out_stream << ReferenceCounter::get_info();
91 }

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

◆ processor_id()

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

Definition at line 106 of file parallel_object.h.

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

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::EquationSystems::_read_impl(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), 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_scalar_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::ExodusII_IO_Helper::create(), libMesh::DistributedMesh::delete_elem(), libMesh::DistributedMesh::delete_node(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::RBEIMConstruction::evaluate_mesh_function(), libMesh::MeshFunction::find_element(), libMesh::MeshFunction::find_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMap::first_dof(), libMesh::DofMap::first_old_dof(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::DofMap::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::DofMap::get_local_constraints(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), 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::DofMap::is_evaluable(), libMesh::SparsityPattern::Build::join(), libMesh::DofMap::last_dof(), libMesh::TransientRBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEIMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEIMEvaluation::legacy_write_out_interpolation_points_elem(), 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(), libMesh::DofMap::local_variable_indices(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), AugmentSparsityOnInterface::mesh_reinit(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMap::n_local_dofs(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::SparsityPattern::Build::operator()(), libMesh::DistributedMesh::own_node(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::print_dof_constraints(), 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::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::System::read_legacy_data(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::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::DistributedMesh::renumber_dof_objects(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::LaplaceMeshSmoother::smooth(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testDynaReadElem(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusCopyElementSolution(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), BoundaryInfoTest::testShellFaceConstraints(), CheckpointIOTest::testSplitter(), WriteVecAndScalar::testWrite(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::Parallel::Packing< Node * >::unpack(), libMesh::Parallel::Packing< Elem * >::unpack(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::DTKAdapter::update_variable_values(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::CheckpointIO::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_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::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::VTKIO::write_nodal_data(), libMesh::UCDIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::RBEvaluation::write_out_vectors(), 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::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_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 
) 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. If non-default Parameters are to be used, they can be provided in the parameters argument.

Definition at line 963 of file system_projection.C.

965 {
966  this->project_vector(*solution, f, g);
967 
968  solution->localize(*current_local_solution, _dof_map->get_send_list());
969 }

◆ project_solution() [2/3]

void libMesh::System::project_solution ( FunctionBase< Number > *  f,
FunctionBase< Gradient > *  g = nullptr 
) 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. If non-default Parameters are to be used, they can be provided in the parameters argument.

Definition at line 950 of file system_projection.C.

952 {
953  this->project_vector(*solution, f, g);
954 
955  solution->localize(*current_local_solution, _dof_map->get_send_list());
956 }

Referenced by init_sys(), initialize(), main(), FETest< order, family, elem_type >::setUp(), SlitMeshRefinedSystemTest::setUp(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testExodusCopyElementSolution(), SystemsTest::testProjectCubeWithMeshFunction(), EquationSystemsTest::testRepartitionThenReinit(), and libMesh::MeshfreeSolutionTransfer::transfer().

◆ project_solution() [3/3]

void libMesh::System::project_solution ( ValueFunctionPointer  fptr,
GradientFunctionPointer  gptr,
const Parameters parameters 
) const
inherited

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

Definition at line 936 of file system_projection.C.

939 {
940  WrappedFunction<Number> f(*this, fptr, &parameters);
941  WrappedFunction<Gradient> g(*this, gptr, &parameters);
942  this->project_solution(&f, &g);
943 }

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

803  { return _solution_projection; }

References libMesh::System::_solution_projection.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), and libMesh::MemorySolutionHistory::store().

◆ project_vector() [1/5]

void libMesh::System::project_vector ( const NumericVector< Number > &  old_v,
NumericVector< Number > &  new_v,
int  is_adjoint = -1 
) 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 270 of file system_projection.C.

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

References libMesh::NumericVector< T >::clear(), libMesh::NumericVector< T >::close(), libMesh::NumericVector< T >::get(), libMesh::GHOSTED, libMesh::index_range(), libMesh::NumericVector< T >::init(), libMesh::Utility::iota(), libMesh::libmesh_assert(), libMesh::libmesh_ignore(), libMesh::NumericVector< T >::local_size(), libMesh::NumericVector< T >::localize(), n_vars, libMesh::PARALLEL, libMesh::Threads::parallel_reduce(), 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(), and libMesh::BuildProjectionList::unique().

◆ project_vector() [2/5]

void libMesh::System::project_vector ( NumericVector< Number > &  vector,
int  is_adjoint = -1 
) 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 252 of file system_projection.C.

254 {
255  // Create a copy of the vector, which currently
256  // contains the old data.
257  std::unique_ptr<NumericVector<Number>>
258  old_vector (vector.clone());
259 
260  // Project the old vector to the new vector
261  this->project_vector (*old_vector, vector, is_adjoint);
262 }

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 
) 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. If non-default Parameters are to be used, they can be provided in the parameters argument.

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

Definition at line 1017 of file system_projection.C.

1021 {
1022  LOG_SCOPE ("project_fem_vector()", "System");
1023 
1024  libmesh_assert (f);
1025 
1026  ConstElemRange active_local_range
1027  (this->get_mesh().active_local_elements_begin(),
1028  this->get_mesh().active_local_elements_end() );
1029 
1030  VectorSetAction<Number> setter(new_vector);
1031 
1032  const unsigned int n_variables = this->n_vars();
1033 
1034  std::vector<unsigned int> vars(n_variables);
1035  std::iota(vars.begin(), vars.end(), 0);
1036 
1037  // Use a typedef to make the calling sequence for parallel_for() a bit more readable
1038  typedef
1039  GenericProjector<FEMFunctionWrapper<Number>, FEMFunctionWrapper<Gradient>,
1040  Number, VectorSetAction<Number>> FEMProjector;
1041 
1042  FEMFunctionWrapper<Number> fw(*f);
1043 
1044  if (g)
1045  {
1046  FEMFunctionWrapper<Gradient> gw(*g);
1047 
1048  FEMProjector projector(*this, fw, &gw, setter, vars);
1049  projector.project(active_local_range);
1050  }
1051  else
1052  {
1053  FEMProjector projector(*this, fw, nullptr, setter, vars);
1054  projector.project(active_local_range);
1055  }
1056 
1057  // Also, load values into the SCALAR dofs
1058  // Note: We assume that all SCALAR dofs are on the
1059  // processor with highest ID
1060  if (this->processor_id() == (this->n_processors()-1))
1061  {
1062  // FIXME: Do we want to first check for SCALAR vars before building this? [PB]
1063  FEMContext context( *this );
1064 
1065  const DofMap & dof_map = this->get_dof_map();
1066  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
1067  if (this->variable(var).type().family == SCALAR)
1068  {
1069  // FIXME: We reinit with an arbitrary element in case the user
1070  // doesn't override FEMFunctionBase::component. Is there
1071  // any use case we're missing? [PB]
1072  context.pre_fe_reinit(*this, *(this->get_mesh().active_local_elements_begin()));
1073 
1074  std::vector<dof_id_type> SCALAR_indices;
1075  dof_map.SCALAR_dof_indices (SCALAR_indices, var);
1076  const unsigned int n_SCALAR_dofs =
1077  cast_int<unsigned int>(SCALAR_indices.size());
1078 
1079  for (unsigned int i=0; i<n_SCALAR_dofs; i++)
1080  {
1081  const dof_id_type global_index = SCALAR_indices[i];
1082  const unsigned int component_index =
1083  this->variable_scalar_number(var,i);
1084 
1085  new_vector.set(global_index, f->component(context, component_index, Point(), this->time));
1086  }
1087  }
1088  }
1089 
1090  new_vector.close();
1091 
1092 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1093  if (is_adjoint == -1)
1094  this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
1095  else if (is_adjoint >= 0)
1097  is_adjoint);
1098 #else
1099  libmesh_ignore(is_adjoint);
1100 #endif
1101 }

References libMesh::NumericVector< T >::close(), libMesh::FEMFunctionBase< Output >::component(), libMesh::Utility::iota(), libMesh::libmesh_assert(), libMesh::libmesh_ignore(), n_vars, libMesh::FEMContext::pre_fe_reinit(), libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), and libMesh::NumericVector< T >::set().

◆ project_vector() [4/5]

void libMesh::System::project_vector ( NumericVector< Number > &  new_vector,
FunctionBase< Number > *  f,
FunctionBase< Gradient > *  g = nullptr,
int  is_adjoint = -1 
) 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. If non-default Parameters are to be used, they can be provided in the parameters argument.

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

Definition at line 991 of file system_projection.C.

995 {
996  LOG_SCOPE ("project_vector(FunctionBase)", "System");
997 
998  libmesh_assert(f);
999 
1000  WrappedFunctor<Number> f_fem(*f);
1001 
1002  if (g)
1003  {
1004  WrappedFunctor<Gradient> g_fem(*g);
1005 
1006  this->project_vector(new_vector, &f_fem, &g_fem, is_adjoint);
1007  }
1008  else
1009  this->project_vector(new_vector, &f_fem, nullptr, is_adjoint);
1010 }

References libMesh::libmesh_assert().

Referenced by main(), libMesh::NewmarkSolver::project_initial_accel(), libMesh::SecondOrderUnsteadySolver::project_initial_rate(), 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 
) 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.

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

Definition at line 976 of file system_projection.C.

981 {
982  WrappedFunction<Number> f(*this, fptr, &parameters);
983  WrappedFunction<Gradient> g(*this, gptr, &parameters);
984  this->project_vector(new_vector, &f, &g, is_adjoint);
985 }

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

871 {
872  LOG_SCOPE ("projection_matrix()", "System");
873 
874  const unsigned int n_variables = this->n_vars();
875 
876  if (n_variables)
877  {
878  ConstElemRange active_local_elem_range
879  (this->get_mesh().active_local_elements_begin(),
880  this->get_mesh().active_local_elements_end());
881 
882  std::vector<unsigned int> vars(n_variables);
883  std::iota(vars.begin(), vars.end(), 0);
884 
885  // Use a typedef to make the calling sequence for parallel_for() a bit more readable
886  typedef OldSolutionCoefs<Real, &FEMContext::point_value> OldSolutionValueCoefs;
887  typedef OldSolutionCoefs<RealGradient, &FEMContext::point_gradient> OldSolutionGradientCoefs;
888 
889  typedef
890  GenericProjector<OldSolutionValueCoefs,
891  OldSolutionGradientCoefs,
892  DynamicSparseNumberArray<Real,dof_id_type>,
893  MatrixFillAction<Real, Number> > ProjMatFiller;
894 
895  OldSolutionValueCoefs f(*this);
896  OldSolutionGradientCoefs g(*this);
897  MatrixFillAction<Real, Number> setter(proj_mat);
898 
899  ProjMatFiller mat_filler(*this, f, &g, setter, vars);
900  mat_filler.project(active_local_elem_range);
901 
902  // Set the SCALAR dof transfer entries too.
903  // Note: We assume that all SCALAR dofs are on the
904  // processor with highest ID
905  if (this->processor_id() == (this->n_processors()-1))
906  {
907  const DofMap & dof_map = this->get_dof_map();
908  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
909  if (this->variable(var).type().family == SCALAR)
910  {
911  // We can just map SCALAR dofs directly across
912  std::vector<dof_id_type> new_SCALAR_indices, old_SCALAR_indices;
913  dof_map.SCALAR_dof_indices (new_SCALAR_indices, var, false);
914  dof_map.SCALAR_dof_indices (old_SCALAR_indices, var, true);
915  const unsigned int new_n_dofs =
916  cast_int<unsigned int>(new_SCALAR_indices.size());
917 
918  for (unsigned int i=0; i<new_n_dofs; i++)
919  {
920  proj_mat.set( new_SCALAR_indices[i],
921  old_SCALAR_indices[i], 1);
922  }
923  }
924  }
925  }
926 }

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

Referenced by libMesh::PetscDMWrapper::init_and_attach_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 380 of file system.C.

381 {
382 #ifdef LIBMESH_ENABLE_AMR
383  // Currently project_vector handles both restriction and prolongation
384  this->restrict_vectors();
385 #endif
386 }

References libMesh::System::restrict_vectors().

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

◆ 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 1091 of file implicit_system.C.

1094 {
1095  // We currently get partial derivatives via finite differencing
1096  const Real delta_p = TOLERANCE;
1097 
1098  ParameterVector & parameters =
1099  const_cast<ParameterVector &>(parameters_in);
1100 
1101  // We'll use one temporary vector for matrix-vector-vector products
1102  std::unique_ptr<NumericVector<Number>> tempvec = this->solution->zero_clone();
1103 
1104  // And another temporary vector to hold a copy of the true solution
1105  // so we can safely perturb this->solution.
1106  std::unique_ptr<NumericVector<Number>> oldsolution = this->solution->clone();
1107 
1108  const unsigned int Np = cast_int<unsigned int>
1109  (parameters.size());
1110  const unsigned int Nq = this->n_qois();
1111 
1112  // For each quantity of interest q, the parameter sensitivity
1113  // Hessian is defined as q''_{kl} = {d^2 q}/{d p_k d p_l}.
1114  //
1115  // We calculate it from values and partial derivatives of the
1116  // quantity of interest function Q, solution u, adjoint solution z,
1117  // and residual R, as:
1118  //
1119  // q''_{kl} =
1120  // Q''_{kl} + Q''_{uk}(u)*u'_l + Q''_{ul}(u) * u'_k +
1121  // Q''_{uu}(u)*u'_k*u'_l -
1122  // R''_{kl}(u,z) -
1123  // R''_{uk}(u,z)*u'_l - R''_{ul}(u,z)*u'_k -
1124  // R''_{uu}(u,z)*u'_k*u'_l
1125  //
1126  // See the adjoints model document for more details.
1127 
1128  // We first do an adjoint solve to get z for each quantity of
1129  // interest
1130  // if we havent already or dont have an initial condition for the adjoint
1131  if (!this->is_adjoint_already_solved())
1132  {
1133  this->adjoint_solve(qoi_indices);
1134  }
1135 
1136  // And a sensitivity solve to get u_k for each parameter
1137  this->sensitivity_solve(parameters);
1138 
1139  // Get ready to fill in second derivatives:
1140  sensitivities.allocate_hessian_data(qoi_indices, *this, parameters);
1141 
1142  for (unsigned int k=0; k != Np; ++k)
1143  {
1144  Number old_parameterk = *parameters[k];
1145 
1146  // The Hessian is symmetric, so we just calculate the lower
1147  // triangle and the diagonal, and we get the upper triangle from
1148  // the transpose of the lower
1149 
1150  for (unsigned int l=0; l != k+1; ++l)
1151  {
1152  // The second partial derivatives with respect to parameters
1153  // are all calculated via a central finite difference
1154  // stencil:
1155  // F''_{kl} ~= (F(p+dp*e_k+dp*e_l) - F(p+dp*e_k-dp*e_l) -
1156  // F(p-dp*e_k+dp*e_l) + F(p-dp*e_k-dp*e_l))/(4*dp^2)
1157  // We will add Q''_{kl}(u) and subtract R''_{kl}(u,z) at the
1158  // same time.
1159  //
1160  // We have to be careful with the perturbations to handle
1161  // the k=l case
1162 
1163  Number old_parameterl = *parameters[l];
1164 
1165  *parameters[k] += delta_p;
1166  *parameters[l] += delta_p;
1167  this->assemble_qoi(qoi_indices);
1168  this->assembly(true, false, true);
1169  this->rhs->close();
1170  std::vector<Number> partial2q_term = this->qoi;
1171  std::vector<Number> partial2R_term(this->n_qois());
1172  for (unsigned int i=0; i != Nq; ++i)
1173  if (qoi_indices.has_index(i))
1174  partial2R_term[i] = this->rhs->dot(this->get_adjoint_solution(i));
1175 
1176  *parameters[l] -= 2.*delta_p;
1177  this->assemble_qoi(qoi_indices);
1178  this->assembly(true, false, true);
1179  this->rhs->close();
1180  for (unsigned int i=0; i != Nq; ++i)
1181  if (qoi_indices.has_index(i))
1182  {
1183  partial2q_term[i] -= this->qoi[i];
1184  partial2R_term[i] -= this->rhs->dot(this->get_adjoint_solution(i));
1185  }
1186 
1187  *parameters[k] -= 2.*delta_p;
1188  this->assemble_qoi(qoi_indices);
1189  this->assembly(true, false, true);
1190  this->rhs->close();
1191  for (unsigned int i=0; i != Nq; ++i)
1192  if (qoi_indices.has_index(i))
1193  {
1194  partial2q_term[i] += this->qoi[i];
1195  partial2R_term[i] += this->rhs->dot(this->get_adjoint_solution(i));
1196  }
1197 
1198  *parameters[l] += 2.*delta_p;
1199  this->assemble_qoi(qoi_indices);
1200  this->assembly(true, false, true);
1201  this->rhs->close();
1202  for (unsigned int i=0; i != Nq; ++i)
1203  if (qoi_indices.has_index(i))
1204  {
1205  partial2q_term[i] -= this->qoi[i];
1206  partial2R_term[i] -= this->rhs->dot(this->get_adjoint_solution(i));
1207  partial2q_term[i] /= (4. * delta_p * delta_p);
1208  partial2R_term[i] /= (4. * delta_p * delta_p);
1209  }
1210 
1211  for (unsigned int i=0; i != Nq; ++i)
1212  if (qoi_indices.has_index(i))
1213  {
1214  Number current_terms = partial2q_term[i] - partial2R_term[i];
1215  sensitivities.second_derivative(i,k,l) += current_terms;
1216  if (k != l)
1217  sensitivities.second_derivative(i,l,k) += current_terms;
1218  }
1219 
1220  // Don't leave the parameters perturbed
1221  *parameters[l] = old_parameterl;
1222  *parameters[k] = old_parameterk;
1223  }
1224 
1225  // We get (partial q / partial u) and
1226  // (partial R / partial u) from the user, but centrally
1227  // difference to get q_uk and R_uk terms:
1228  // (partial^2 q / partial u partial k)
1229  // q_uk*u'_l = (q_u(p+dp*e_k)*u'_l - q_u(p-dp*e_k)*u'_l)/(2*dp)
1230  // 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)
1231  //
1232  // To avoid creating Nq temporary vectors, we add these
1233  // subterms to the sensitivities output one by one.
1234  //
1235  // FIXME: this is probably a bad order of operations for
1236  // controlling floating point error.
1237 
1238  *parameters[k] = old_parameterk + delta_p;
1239  this->assembly(false, true);
1240  this->matrix->close();
1241  this->assemble_qoi_derivative(qoi_indices,
1242  /* include_liftfunc = */ true,
1243  /* apply_constraints = */ false);
1244 
1245  for (unsigned int l=0; l != Np; ++l)
1246  {
1247  this->matrix->vector_mult(*tempvec, this->get_sensitivity_solution(l));
1248  for (unsigned int i=0; i != Nq; ++i)
1249  if (qoi_indices.has_index(i))
1250  {
1251  this->get_adjoint_rhs(i).close();
1252  Number current_terms =
1253  (this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(l)) -
1254  tempvec->dot(this->get_adjoint_solution(i))) / (2.*delta_p);
1255  sensitivities.second_derivative(i,k,l) += current_terms;
1256 
1257  // We use the _uk terms twice; symmetry lets us reuse
1258  // these calculations for the _ul terms.
1259 
1260  sensitivities.second_derivative(i,l,k) += current_terms;
1261  }
1262  }
1263 
1264  *parameters[k] = old_parameterk - delta_p;
1265  this->assembly(false, true);
1266  this->matrix->close();
1267  this->assemble_qoi_derivative(qoi_indices,
1268  /* include_liftfunc = */ true,
1269  /* apply_constraints = */ false);
1270 
1271  for (unsigned int l=0; l != Np; ++l)
1272  {
1273  this->matrix->vector_mult(*tempvec, this->get_sensitivity_solution(l));
1274  for (unsigned int i=0; i != Nq; ++i)
1275  if (qoi_indices.has_index(i))
1276  {
1277  this->get_adjoint_rhs(i).close();
1278  Number current_terms =
1279  (-this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(l)) +
1280  tempvec->dot(this->get_adjoint_solution(i))) / (2.*delta_p);
1281  sensitivities.second_derivative(i,k,l) += current_terms;
1282 
1283  // We use the _uk terms twice; symmetry lets us reuse
1284  // these calculations for the _ul terms.
1285 
1286  sensitivities.second_derivative(i,l,k) += current_terms;
1287  }
1288  }
1289 
1290  // Don't leave the parameter perturbed
1291  *parameters[k] = old_parameterk;
1292 
1293  // Our last remaining terms are -R_uu(u,z)*u_k*u_l and
1294  // Q_uu(u)*u_k*u_l
1295  //
1296  // We take directional central finite differences of R_u and Q_u
1297  // to approximate these terms, e.g.:
1298  //
1299  // Q_uu(u)*u_k ~= (Q_u(u+dp*u_k) - Q_u(u-dp*u_k))/(2*dp)
1300 
1301  *this->solution = this->get_sensitivity_solution(k);
1302  *this->solution *= delta_p;
1303  *this->solution += *oldsolution;
1304 
1305  // We've modified solution, so we need to update before calling
1306  // assembly since assembly may only use current_local_solution
1307  this->update();
1308  this->assembly(false, true);
1309  this->matrix->close();
1310  this->assemble_qoi_derivative(qoi_indices,
1311  /* include_liftfunc = */ true,
1312  /* apply_constraints = */ false);
1313 
1314  // The Hessian is symmetric, so we just calculate the lower
1315  // triangle and the diagonal, and we get the upper triangle from
1316  // the transpose of the lower
1317  //
1318  // Note that, because we took the directional finite difference
1319  // with respect to k and not l, we've added an O(delta_p^2)
1320  // error to any permutational symmetry in the Hessian...
1321  for (unsigned int l=0; l != k+1; ++l)
1322  {
1323  this->matrix->vector_mult(*tempvec, this->get_sensitivity_solution(l));
1324  for (unsigned int i=0; i != Nq; ++i)
1325  if (qoi_indices.has_index(i))
1326  {
1327  this->get_adjoint_rhs(i).close();
1328  Number current_terms =
1329  (this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(l)) -
1330  tempvec->dot(this->get_adjoint_solution(i))) / (2.*delta_p);
1331  sensitivities.second_derivative(i,k,l) += current_terms;
1332  if (k != l)
1333  sensitivities.second_derivative(i,l,k) += current_terms;
1334  }
1335  }
1336 
1337  *this->solution = this->get_sensitivity_solution(k);
1338  *this->solution *= -delta_p;
1339  *this->solution += *oldsolution;
1340 
1341  // We've modified solution, so we need to update before calling
1342  // assembly since assembly may only use current_local_solution
1343  this->update();
1344  this->assembly(false, true);
1345  this->matrix->close();
1346  this->assemble_qoi_derivative(qoi_indices,
1347  /* include_liftfunc = */ true,
1348  /* apply_constraints = */ false);
1349 
1350  for (unsigned int l=0; l != k+1; ++l)
1351  {
1352  this->matrix->vector_mult(*tempvec, this->get_sensitivity_solution(l));
1353  for (unsigned int i=0; i != Nq; ++i)
1354  if (qoi_indices.has_index(i))
1355  {
1356  this->get_adjoint_rhs(i).close();
1357  Number current_terms =
1358  (-this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(l)) +
1359  tempvec->dot(this->get_adjoint_solution(i))) / (2.*delta_p);
1360  sensitivities.second_derivative(i,k,l) += current_terms;
1361  if (k != l)
1362  sensitivities.second_derivative(i,l,k) += current_terms;
1363  }
1364  }
1365 
1366  // Don't leave the solution perturbed
1367  *this->solution = *oldsolution;
1368  }
1369 
1370  // All parameters have been reset.
1371  // Don't leave the qoi or system changed - principle of least
1372  // surprise.
1373  // We've modified solution, so we need to update before calling
1374  // assembly since assembly may only use current_local_solution
1375  this->update();
1376  this->assembly(true, true);
1377  this->rhs->close();
1378  this->matrix->close();
1379  this->assemble_qoi(qoi_indices);
1380 }

References libMesh::ImplicitSystem::adjoint_solve(), libMesh::SensitivityData::allocate_hessian_data(), libMesh::ExplicitSystem::assemble_qoi(), libMesh::ExplicitSystem::assemble_qoi_derivative(), libMesh::ImplicitSystem::assembly(), libMesh::SparseMatrix< T >::close(), libMesh::NumericVector< T >::close(), libMesh::NumericVector< T >::dot(), libMesh::System::get_adjoint_rhs(), libMesh::System::get_adjoint_solution(), libMesh::System::get_sensitivity_solution(), libMesh::QoISet::has_index(), libMesh::System::is_adjoint_already_solved(), libMesh::ImplicitSystem::matrix, libMesh::System::n_qois(), libMesh::System::qoi, 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 886 of file implicit_system.C.

890 {
891  // We currently get partial derivatives via finite differencing
892  const Real delta_p = TOLERANCE;
893 
894  ParameterVector & parameters =
895  const_cast<ParameterVector &>(parameters_in);
896 
897  // We'll use a single temporary vector for matrix-vector-vector products
898  std::unique_ptr<NumericVector<Number>> tempvec = this->solution->zero_clone();
899 
900  const unsigned int Np = cast_int<unsigned int>
901  (parameters.size());
902  const unsigned int Nq = this->n_qois();
903 
904  // For each quantity of interest q, the parameter sensitivity
905  // Hessian is defined as q''_{kl} = {d^2 q}/{d p_k d p_l}.
906  // Given a vector of parameter perturbation weights w_l, this
907  // function evaluates the hessian-vector product sum_l(q''_{kl}*w_l)
908  //
909  // We calculate it from values and partial derivatives of the
910  // quantity of interest function Q, solution u, adjoint solution z,
911  // parameter sensitivity adjoint solutions z^l, and residual R, as:
912  //
913  // sum_l(q''_{kl}*w_l) =
914  // sum_l(w_l * Q''_{kl}) + Q''_{uk}(u)*(sum_l(w_l u'_l)) -
915  // R'_k(u, sum_l(w_l*z^l)) - R'_{uk}(u,z)*(sum_l(w_l u'_l) -
916  // sum_l(w_l*R''_{kl}(u,z))
917  //
918  // See the adjoints model document for more details.
919 
920  // We first do an adjoint solve to get z for each quantity of
921  // interest
922  // if we havent already or dont have an initial condition for the adjoint
923  if (!this->is_adjoint_already_solved())
924  {
925  this->adjoint_solve(qoi_indices);
926  }
927 
928  // Get ready to fill in sensitivities:
929  sensitivities.allocate_data(qoi_indices, *this, parameters);
930 
931  // We can't solve for all the solution sensitivities u'_l or for all
932  // of the parameter sensitivity adjoint solutions z^l without
933  // requiring O(Nq*Np) linear solves. So we'll solve directly for their
934  // weighted sum - this is just O(Nq) solves.
935 
936  // First solve for sum_l(w_l u'_l).
937  this->weighted_sensitivity_solve(parameters, vector);
938 
939  // Then solve for sum_l(w_l z^l).
940  this->weighted_sensitivity_adjoint_solve(parameters, vector, qoi_indices);
941 
942  for (unsigned int k=0; k != Np; ++k)
943  {
944  // We approximate sum_l(w_l * Q''_{kl}) with a central
945  // differencing perturbation:
946  // sum_l(w_l * Q''_{kl}) ~=
947  // (Q(p + dp*w_l*e_l + dp*e_k) - Q(p - dp*w_l*e_l + dp*e_k) -
948  // Q(p + dp*w_l*e_l - dp*e_k) + Q(p - dp*w_l*e_l - dp*e_k))/(4*dp^2)
949 
950  // The sum(w_l*R''_kl) term requires the same sort of perturbation,
951  // and so we subtract it in at the same time:
952  // sum_l(w_l * R''_{kl}) ~=
953  // (R(p + dp*w_l*e_l + dp*e_k) - R(p - dp*w_l*e_l + dp*e_k) -
954  // R(p + dp*w_l*e_l - dp*e_k) + R(p - dp*w_l*e_l - dp*e_k))/(4*dp^2)
955 
956  ParameterVector oldparameters, parameterperturbation;
957  parameters.deep_copy(oldparameters);
958  vector.deep_copy(parameterperturbation);
959  parameterperturbation *= delta_p;
960  parameters += parameterperturbation;
961 
962  Number old_parameter = *parameters[k];
963 
964  *parameters[k] = old_parameter + delta_p;
965  this->assemble_qoi(qoi_indices);
966  this->assembly(true, false, true);
967  this->rhs->close();
968  std::vector<Number> partial2q_term = this->qoi;
969  std::vector<Number> partial2R_term(this->n_qois());
970  for (unsigned int i=0; i != Nq; ++i)
971  if (qoi_indices.has_index(i))
972  partial2R_term[i] = this->rhs->dot(this->get_adjoint_solution(i));
973 
974  *parameters[k] = old_parameter - delta_p;
975  this->assemble_qoi(qoi_indices);
976  this->assembly(true, false, true);
977  this->rhs->close();
978  for (unsigned int i=0; i != Nq; ++i)
979  if (qoi_indices.has_index(i))
980  {
981  partial2q_term[i] -= this->qoi[i];
982  partial2R_term[i] -= this->rhs->dot(this->get_adjoint_solution(i));
983  }
984 
985  oldparameters.value_copy(parameters);
986  parameterperturbation *= -1.0;
987  parameters += parameterperturbation;
988 
989  // Re-center old_parameter, which may be affected by vector
990  old_parameter = *parameters[k];
991 
992  *parameters[k] = old_parameter + delta_p;
993  this->assemble_qoi(qoi_indices);
994  this->assembly(true, false, true);
995  this->rhs->close();
996  for (unsigned int i=0; i != Nq; ++i)
997  if (qoi_indices.has_index(i))
998  {
999  partial2q_term[i] -= this->qoi[i];
1000  partial2R_term[i] -= this->rhs->dot(this->get_adjoint_solution(i));
1001  }
1002 
1003  *parameters[k] = old_parameter - delta_p;
1004  this->assemble_qoi(qoi_indices);
1005  this->assembly(true, false, true);
1006  this->rhs->close();
1007  for (unsigned int i=0; i != Nq; ++i)
1008  if (qoi_indices.has_index(i))
1009  {
1010  partial2q_term[i] += this->qoi[i];
1011  partial2R_term[i] += this->rhs->dot(this->get_adjoint_solution(i));
1012  }
1013 
1014  for (unsigned int i=0; i != Nq; ++i)
1015  if (qoi_indices.has_index(i))
1016  {
1017  partial2q_term[i] /= (4. * delta_p * delta_p);
1018  partial2R_term[i] /= (4. * delta_p * delta_p);
1019  }
1020 
1021  for (unsigned int i=0; i != Nq; ++i)
1022  if (qoi_indices.has_index(i))
1023  sensitivities[i][k] = partial2q_term[i] - partial2R_term[i];
1024 
1025  // We get (partial q / partial u), R, and
1026  // (partial R / partial u) from the user, but centrally
1027  // difference to get q_uk, R_k, and R_uk terms:
1028  // (partial R / partial k)
1029  // 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)
1030  // (partial^2 q / partial u partial k)
1031  // q_uk = (q_u(p+dp*e_k) - q_u(p-dp*e_k))/(2*dp)
1032  // (partial^2 R / partial u partial k)
1033  // 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)
1034 
1035  // To avoid creating Nq temporary vectors for q_uk or R_uk, we add
1036  // subterms to the sensitivities output one by one.
1037  //
1038  // FIXME: this is probably a bad order of operations for
1039  // controlling floating point error.
1040 
1041  *parameters[k] = old_parameter + delta_p;
1042  this->assembly(true, true);
1043  this->rhs->close();
1044  this->matrix->close();
1045  this->assemble_qoi_derivative(qoi_indices,
1046  /* include_liftfunc = */ true,
1047  /* apply_constraints = */ false);
1048 
1049  this->matrix->vector_mult(*tempvec, this->get_weighted_sensitivity_solution());
1050 
1051  for (unsigned int i=0; i != Nq; ++i)
1052  if (qoi_indices.has_index(i))
1053  {
1054  this->get_adjoint_rhs(i).close();
1055  sensitivities[i][k] += (this->get_adjoint_rhs(i).dot(this->get_weighted_sensitivity_solution()) -
1057  this->get_adjoint_solution(i).dot(*tempvec)) / (2.*delta_p);
1058  }
1059 
1060  *parameters[k] = old_parameter - delta_p;
1061  this->assembly(true, true);
1062  this->rhs->close();
1063  this->matrix->close();
1064  this->assemble_qoi_derivative(qoi_indices,
1065  /* include_liftfunc = */ true,
1066  /* apply_constraints = */ false);
1067 
1068  this->matrix->vector_mult(*tempvec, this->get_weighted_sensitivity_solution());
1069 
1070  for (unsigned int i=0; i != Nq; ++i)
1071  if (qoi_indices.has_index(i))
1072  {
1073  this->get_adjoint_rhs(i).close();
1074  sensitivities[i][k] += (-this->get_adjoint_rhs(i).dot(this->get_weighted_sensitivity_solution()) +
1076  this->get_adjoint_solution(i).dot(*tempvec)) / (2.*delta_p);
1077  }
1078  }
1079 
1080  // All parameters have been reset.
1081  // Don't leave the qoi or system changed - principle of least
1082  // surprise.
1083  this->assembly(true, true);
1084  this->rhs->close();
1085  this->matrix->close();
1086  this->assemble_qoi(qoi_indices);
1087 }

References libMesh::ImplicitSystem::adjoint_solve(), libMesh::SensitivityData::allocate_data(), libMesh::ExplicitSystem::assemble_qoi(), libMesh::ExplicitSystem::assemble_qoi_derivative(), libMesh::ImplicitSystem::assembly(), libMesh::SparseMatrix< T >::close(), libMesh::NumericVector< T >::close(), libMesh::ParameterVector::deep_copy(), libMesh::NumericVector< T >::dot(), libMesh::System::get_adjoint_rhs(), libMesh::System::get_adjoint_solution(), 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::System::qoi, 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 498 of file system.C.

501 {
502  // Forward sensitivities are more efficient for Nq > Np
503  if (qoi_indices.size(*this) > parameters.size())
504  forward_qoi_parameter_sensitivity(qoi_indices, parameters, sensitivities);
505  // Adjoint sensitivities are more efficient for Np > Nq,
506  // and an adjoint may be more reusable than a forward
507  // solution sensitivity in the Np == Nq case.
508  else
509  adjoint_qoi_parameter_sensitivity(qoi_indices, parameters, sensitivities);
510 }

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

430 {
431  parallel_object_only();
432 
433  // If this system is empty... don't do anything!
434  if (!this->n_vars())
435  return;
436 
437  const std::vector<dof_id_type> & send_list = this->get_dof_map().get_send_list ();
438 
439  // Check sizes
440  libmesh_assert_equal_to (current_local_solution->size(), solution->size());
441  // Not true with ghosted vectors
442  // libmesh_assert_equal_to (current_local_solution->local_size(), solution->size());
443  // libmesh_assert (!send_list.empty());
444  libmesh_assert_less_equal (send_list.size(), solution->size());
445 
446  // Create current_local_solution from solution. This will
447  // put a local copy of solution into current_local_solution.
448  solution->localize (*current_local_solution, send_list);
449 }

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,
const std::string &  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 114 of file system_io.C.

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

References libMesh::System::_additional_data_written, libMesh::System::_written_var_indices, libMesh::System::add_variable(), libMesh::System::add_vector(), libMesh::System::clear(), libMesh::ParallelObject::comm(), 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_impl(), and libMesh::RBEvaluation::read_in_vectors_from_multiple_files().

◆ read_legacy_data()

void libMesh::System::read_legacy_data ( Xdr io,
const bool  read_additional_data = true 
)
inherited

Reads additional data, namely vectors, for this System.

Definition at line 309 of file system_io.C.

311 {
312  libmesh_deprecated();
313 
314  // This method implements the output of the vectors
315  // contained in this System object, embedded in the
316  // output of an EquationSystems<T_sys>.
317  //
318  // 10.) The global solution vector, re-ordered to be node-major
319  // (More on this later.)
320  //
321  // for each additional vector in the object
322  //
323  // 11.) The global additional vector, re-ordered to be
324  // node-major (More on this later.)
325  libmesh_assert (io.reading());
326 
327  // read and reordering buffers
328  std::vector<Number> global_vector;
329  std::vector<Number> reordered_vector;
330 
331  // 10.)
332  // Read and set the solution vector
333  {
334  if (this->processor_id() == 0)
335  io.data (global_vector);
336  this->comm().broadcast(global_vector);
337 
338  // Remember that the stored vector is node-major.
339  // We need to put it into whatever application-specific
340  // ordering we may have using the dof_map.
341  reordered_vector.resize(global_vector.size());
342 
343  //libMesh::out << "global_vector.size()=" << global_vector.size() << std::endl;
344  //libMesh::out << "this->n_dofs()=" << this->n_dofs() << std::endl;
345 
346  libmesh_assert_equal_to (global_vector.size(), this->n_dofs());
347 
348  dof_id_type cnt=0;
349 
350  const unsigned int sys = this->number();
351  const unsigned int nv = cast_int<unsigned int>
352  (this->_written_var_indices.size());
353  libmesh_assert_less_equal (nv, this->n_vars());
354 
355  for (unsigned int data_var=0; data_var<nv; data_var++)
356  {
357  const unsigned int var = _written_var_indices[data_var];
358 
359  // First reorder the nodal DOF values
360  for (auto & node : this->get_mesh().node_ptr_range())
361  for (auto index : IntRange<unsigned int>(0, node->n_comp(sys,var)))
362  {
363  libmesh_assert_not_equal_to (node->dof_number(sys, var, index),
365 
366  libmesh_assert_less (cnt, global_vector.size());
367 
368  reordered_vector[node->dof_number(sys, var, index)] =
369  global_vector[cnt++];
370  }
371 
372  // Then reorder the element DOF values
373  for (auto & elem : this->get_mesh().active_element_ptr_range())
374  for (auto index : IntRange<unsigned int>(0, elem->n_comp(sys,var)))
375  {
376  libmesh_assert_not_equal_to (elem->dof_number(sys, var, index),
378 
379  libmesh_assert_less (cnt, global_vector.size());
380 
381  reordered_vector[elem->dof_number(sys, var, index)] =
382  global_vector[cnt++];
383  }
384  }
385 
386  *(this->solution) = reordered_vector;
387  }
388 
389  // For each additional vector, simply go through the list.
390  // ONLY attempt to do this IF additional data was actually
391  // written to the file for this system (controlled by the
392  // _additional_data_written flag).
393  if (this->_additional_data_written)
394  {
395  const std::size_t nvecs = this->_vectors.size();
396 
397  // If the number of additional vectors written is non-zero, and
398  // the number of additional vectors we have is non-zero, and
399  // they don't match, then something is wrong and we can't be
400  // sure we're reading data into the correct places.
401  if (read_additional_data && nvecs &&
402  nvecs != this->_additional_data_written)
403  libmesh_error_msg
404  ("Additional vectors in file do not match system");
405 
406  std::map<std::string, NumericVector<Number> *>::iterator
407  pos = this->_vectors.begin();
408 
409  for (std::size_t i = 0; i != this->_additional_data_written; ++i)
410  {
411  // 11.)
412  // Read the values of the vec-th additional vector.
413  // Prior do _not_ clear, but fill with zero, since the
414  // additional vectors _have_ to have the same size
415  // as the solution vector
416  std::fill (global_vector.begin(), global_vector.end(), libMesh::zero);
417 
418  if (this->processor_id() == 0)
419  io.data (global_vector);
420 
421  // If read_additional_data==true and we have additional vectors,
422  // then we will keep this vector data; otherwise we are going to
423  // throw it away.
424  if (read_additional_data && nvecs)
425  {
426  this->comm().broadcast(global_vector);
427 
428  // Remember that the stored vector is node-major.
429  // We need to put it into whatever application-specific
430  // ordering we may have using the dof_map.
431  std::fill (reordered_vector.begin(),
432  reordered_vector.end(),
433  libMesh::zero);
434 
435  reordered_vector.resize(global_vector.size());
436 
437  libmesh_assert_equal_to (global_vector.size(), this->n_dofs());
438 
439  dof_id_type cnt=0;
440 
441  const unsigned int sys = this->number();
442  const unsigned int nv = cast_int<unsigned int>
443  (this->_written_var_indices.size());
444  libmesh_assert_less_equal (nv, this->n_vars());
445 
446  for (unsigned int data_var=0; data_var<nv; data_var++)
447  {
448  const unsigned int var = _written_var_indices[data_var];
449  // First reorder the nodal DOF values
450  for (auto & node : this->get_mesh().node_ptr_range())
451  for (auto index : IntRange<unsigned int>(0, node->n_comp(sys,var)))
452  {
453  libmesh_assert_not_equal_to (node->dof_number(sys, var, index),
455 
456  libmesh_assert_less (cnt, global_vector.size());
457 
458  reordered_vector[node->dof_number(sys, var, index)] =
459  global_vector[cnt++];
460  }
461 
462  // Then reorder the element DOF values
463  for (auto & elem : this->get_mesh().active_element_ptr_range())
464  for (auto index : IntRange<unsigned int>(0, elem->n_comp(sys,var)))
465  {
466  libmesh_assert_not_equal_to (elem->dof_number(sys, var, index),
468 
469  libmesh_assert_less (cnt, global_vector.size());
470 
471  reordered_vector[elem->dof_number(sys, var, index)] =
472  global_vector[cnt++];
473  }
474  }
475 
476  // use the overloaded operator=(std::vector) to assign the values
477  *(pos->second) = reordered_vector;
478  }
479 
480  // If we've got vectors then we need to be iterating through
481  // those too
482  if (pos != this->_vectors.end())
483  ++pos;
484  }
485  } // end if (_additional_data_written)
486 }

References libMesh::System::_additional_data_written, libMesh::System::_vectors, libMesh::System::_written_var_indices, libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::System::get_mesh(), libMesh::DofObject::invalid_id, libMesh::libmesh_assert(), libMesh::System::n_dofs(), libMesh::System::n_vars(), libMesh::System::number(), libMesh::ParallelObject::processor_id(), libMesh::Xdr::reading(), libMesh::System::solution, and libMesh::zero.

◆ 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 492 of file system_io.C.

494 {
514  // PerfLog pl("IO Performance",false);
515  // pl.push("read_parallel_data");
516  dof_id_type total_read_size = 0;
517 
518  libmesh_assert (io.reading());
519  libmesh_assert (io.is_open());
520 
521  // build the ordered nodes and element maps.
522  // when writing/reading parallel files we need to iterate
523  // over our nodes/elements in order of increasing global id().
524  // however, this is not guaranteed to be ordering we obtain
525  // by using the node_iterators/element_iterators directly.
526  // so build a set, sorted by id(), that provides the ordering.
527  // further, for memory economy build the set but then transfer
528  // its contents to vectors, which will be sorted.
529  std::vector<const DofObject *> ordered_nodes, ordered_elements;
530  {
531  std::set<const DofObject *, CompareDofObjectsByID>
532  ordered_nodes_set (this->get_mesh().local_nodes_begin(),
533  this->get_mesh().local_nodes_end());
534 
535  ordered_nodes.insert(ordered_nodes.end(),
536  ordered_nodes_set.begin(),
537  ordered_nodes_set.end());
538  }
539  {
540  std::set<const DofObject *, CompareDofObjectsByID>
541  ordered_elements_set (this->get_mesh().local_elements_begin(),
542  this->get_mesh().local_elements_end());
543 
544  ordered_elements.insert(ordered_elements.end(),
545  ordered_elements_set.begin(),
546  ordered_elements_set.end());
547  }
548 
549  // std::vector<Number> io_buffer;
550  std::vector<InValType> io_buffer;
551 
552  // 9.)
553  //
554  // Actually read the solution components
555  // for the ith system to disk
556  io.data(io_buffer);
557 
558  total_read_size += cast_int<dof_id_type>(io_buffer.size());
559 
560  const unsigned int sys_num = this->number();
561  const unsigned int nv = cast_int<unsigned int>
562  (this->_written_var_indices.size());
563  libmesh_assert_less_equal (nv, this->n_vars());
564 
565  dof_id_type cnt=0;
566 
567  // Loop over each non-SCALAR variable and each node, and read out the value.
568  for (unsigned int data_var=0; data_var<nv; data_var++)
569  {
570  const unsigned int var = _written_var_indices[data_var];
571  if (this->variable(var).type().family != SCALAR)
572  {
573  // First read the node DOF values
574  for (const auto & node : ordered_nodes)
575  for (auto comp : IntRange<unsigned int>(0, node->n_comp(sys_num,var)))
576  {
577  libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
579  libmesh_assert_less (cnt, io_buffer.size());
580  this->solution->set(node->dof_number(sys_num, var, comp), io_buffer[cnt++]);
581  }
582 
583  // Then read the element DOF values
584  for (const auto & elem : ordered_elements)
585  for (auto comp : IntRange<unsigned int>(0, elem->n_comp(sys_num,var)))
586  {
587  libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
589  libmesh_assert_less (cnt, io_buffer.size());
590  this->solution->set(elem->dof_number(sys_num, var, comp), io_buffer[cnt++]);
591  }
592  }
593  }
594 
595  // Finally, read the SCALAR variables on the last processor
596  for (unsigned int data_var=0; data_var<nv; data_var++)
597  {
598  const unsigned int var = _written_var_indices[data_var];
599  if (this->variable(var).type().family == SCALAR)
600  {
601  if (this->processor_id() == (this->n_processors()-1))
602  {
603  const DofMap & dof_map = this->get_dof_map();
604  std::vector<dof_id_type> SCALAR_dofs;
605  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
606 
607  for (auto dof : SCALAR_dofs)
608  this->solution->set(dof, io_buffer[cnt++]);
609  }
610  }
611  }
612 
613  // And we're done setting solution entries
614  this->solution->close();
615 
616  // For each additional vector, simply go through the list.
617  // ONLY attempt to do this IF additional data was actually
618  // written to the file for this system (controlled by the
619  // _additional_data_written flag).
620  if (this->_additional_data_written)
621  {
622  const std::size_t nvecs = this->_vectors.size();
623 
624  // If the number of additional vectors written is non-zero, and
625  // the number of additional vectors we have is non-zero, and
626  // they don't match, then something is wrong and we can't be
627  // sure we're reading data into the correct places.
628  if (read_additional_data && nvecs &&
629  nvecs != this->_additional_data_written)
630  libmesh_error_msg
631  ("Additional vectors in file do not match system");
632 
633  std::map<std::string, NumericVector<Number> *>::const_iterator
634  pos = _vectors.begin();
635 
636  for (std::size_t i = 0; i != this->_additional_data_written; ++i)
637  {
638  cnt=0;
639  io_buffer.clear();
640 
641  // 10.)
642  //
643  // Actually read the additional vector components
644  // for the ith system from disk
645  io.data(io_buffer);
646 
647  total_read_size += cast_int<dof_id_type>(io_buffer.size());
648 
649  // If read_additional_data==true and we have additional vectors,
650  // then we will keep this vector data; otherwise we are going to
651  // throw it away.
652  if (read_additional_data && nvecs)
653  {
654  // Loop over each non-SCALAR variable and each node, and read out the value.
655  for (unsigned int data_var=0; data_var<nv; data_var++)
656  {
657  const unsigned int var = _written_var_indices[data_var];
658  if (this->variable(var).type().family != SCALAR)
659  {
660  // First read the node DOF values
661  for (const auto & node : ordered_nodes)
662  for (auto comp : IntRange<unsigned int>(0, node->n_comp(sys_num,var)))
663  {
664  libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
666  libmesh_assert_less (cnt, io_buffer.size());
667  pos->second->set(node->dof_number(sys_num, var, comp), io_buffer[cnt++]);
668  }
669 
670  // Then read the element DOF values
671  for (const auto & elem : ordered_elements)
672  for (auto comp : IntRange<unsigned int>(0, elem->n_comp(sys_num,var)))
673  {
674  libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
676  libmesh_assert_less (cnt, io_buffer.size());
677  pos->second->set(elem->dof_number(sys_num, var, comp), io_buffer[cnt++]);
678  }
679  }
680  }
681 
682  // Finally, read the SCALAR variables on the last processor
683  for (unsigned int data_var=0; data_var<nv; data_var++)
684  {
685  const unsigned int var = _written_var_indices[data_var];
686  if (this->variable(var).type().family == SCALAR)
687  {
688  if (this->processor_id() == (this->n_processors()-1))
689  {
690  const DofMap & dof_map = this->get_dof_map();
691  std::vector<dof_id_type> SCALAR_dofs;
692  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
693 
694  for (auto dof : SCALAR_dofs)
695  pos->second->set(dof, io_buffer[cnt++]);
696  }
697  }
698  }
699 
700  // And we're done setting entries for this variable
701  pos->second->close();
702  }
703 
704  // If we've got vectors then we need to be iterating through
705  // those too
706  if (pos != this->_vectors.end())
707  ++pos;
708  }
709  }
710 
711  // const Real
712  // dt = pl.get_elapsed_time(),
713  // rate = total_read_size*sizeof(Number)/dt;
714 
715  // libMesh::err << "Read " << total_read_size << " \"Number\" values\n"
716  // << " Elapsed time = " << dt << '\n'
717  // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
718 
719  // pl.pop("read_parallel_data");
720 }

References libMesh::System::_additional_data_written, libMesh::System::_vectors, libMesh::System::_written_var_indices, libMesh::Xdr::data(), libMesh::FEType::family, libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::DofObject::invalid_id, libMesh::Xdr::is_open(), libMesh::libmesh_assert(), 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, libMesh::Variable::type(), and libMesh::System::variable().

◆ read_parallel_data() [2/2]

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

1317  { 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 1120 of file system_io.C.

1123 {
1124  unsigned int n_assigned_vals = 0; // the number of values assigned, this will be returned.
1125 
1126  // Processor 0 will read the block from the buffer stream and send it to the last processor
1127  const unsigned int n_SCALAR_dofs = this->variable(var).type().order.get_order();
1128  std::vector<Number> input_buffer(n_SCALAR_dofs);
1129  if (this->processor_id() == 0)
1130  io.data_stream(input_buffer.data(), n_SCALAR_dofs);
1131 
1132 #ifdef LIBMESH_HAVE_MPI
1133  if (this->n_processors() > 1)
1134  {
1135  const Parallel::MessageTag val_tag = this->comm().get_unique_tag();
1136 
1137  // Post the receive on the last processor
1138  if (this->processor_id() == (this->n_processors()-1))
1139  this->comm().receive(0, input_buffer, val_tag);
1140 
1141  // Send the data to processor 0
1142  if (this->processor_id() == 0)
1143  this->comm().send(this->n_processors()-1, input_buffer, val_tag);
1144  }
1145 #endif
1146 
1147  // Finally, set the SCALAR values
1148  if (this->processor_id() == (this->n_processors()-1))
1149  {
1150  const DofMap & dof_map = this->get_dof_map();
1151  std::vector<dof_id_type> SCALAR_dofs;
1152  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
1153 
1154  for (auto i : index_range(SCALAR_dofs))
1155  {
1156  if (vec)
1157  vec->set (SCALAR_dofs[i], input_buffer[i]);
1158  ++n_assigned_vals;
1159  }
1160  }
1161 
1162  return n_assigned_vals;
1163 }

References libMesh::ParallelObject::comm(), libMesh::Xdr::data_stream(), libMesh::System::get_dof_map(), libMesh::OrderWrapper::get_order(), libMesh::index_range(), libMesh::ParallelObject::n_processors(), libMesh::FEType::order, libMesh::ParallelObject::processor_id(), libMesh::DofMap::SCALAR_dof_indices(), 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 810 of file system_io.C.

817 {
818  //-------------------------------------------------------
819  // General order: (IO format 0.7.4 & greater)
820  //
821  // for (objects ...)
822  // for (vecs ....)
823  // for (vars ....)
824  // for (comps ...)
825  //
826  // where objects are nodes or elements, sorted to be
827  // partition independent,
828  // vecs are one or more *identically distributed* solution
829  // coefficient vectors, vars are one or more variables
830  // to write, and comps are all the components for said
831  // vars on the object.
832 
833  // variables to read. Unless specified otherwise, defaults to _written_var_indices.
834  std::vector<unsigned int> vars_to_read (_written_var_indices);
835 
836  if (var_to_read != libMesh::invalid_uint)
837  {
838  vars_to_read.clear();
839  vars_to_read.push_back(var_to_read);
840  }
841 
842  const unsigned int
843  sys_num = this->number(),
844  num_vecs = cast_int<unsigned int>(vecs.size());
845  const dof_id_type
846  io_blksize = cast_int<dof_id_type>(std::min(max_io_blksize, static_cast<std::size_t>(n_objs))),
847  num_blks = cast_int<unsigned int>(std::ceil(static_cast<double>(n_objs)/
848  static_cast<double>(io_blksize)));
849 
850  libmesh_assert_less_equal (_written_var_indices.size(), this->n_vars());
851 
852  std::size_t n_read_values=0;
853 
854  std::vector<std::vector<dof_id_type>> xfer_ids(num_blks); // The global IDs and # of components for the local objects in all blocks
855  std::vector<std::vector<Number>> recv_vals(num_blks); // The raw values for the local objects in all blocks
856  std::vector<Parallel::Request>
857  id_requests(num_blks), val_requests(num_blks);
858  std::vector<Parallel::MessageTag>
859  id_tags(num_blks), val_tags(num_blks);
860 
861  // ------------------------------------------------------
862  // First pass - count the number of objects in each block
863  // traverse all the objects and figure out which block they
864  // will ultimately live in.
865  std::vector<std::size_t>
866  xfer_ids_size (num_blks,0),
867  recv_vals_size (num_blks,0);
868 
869 
870  for (iterator_type it=begin; it!=end; ++it)
871  {
872  const dof_id_type
873  id = (*it)->id(),
874  block = id/io_blksize;
875 
876  libmesh_assert_less (block, num_blks);
877 
878  xfer_ids_size[block] += 2; // for each object, we send its id, as well as the total number of components for all variables
879 
880  dof_id_type n_comp_tot=0;
881  for (const auto & var : vars_to_read)
882  n_comp_tot += (*it)->n_comp(sys_num, var); // for each variable, we will receive the nonzero components
883 
884  recv_vals_size[block] += n_comp_tot*num_vecs;
885  }
886 
887  // knowing the recv_vals_size[block] for each processor allows
888  // us to sum them and find the global size for each block.
889  std::vector<std::size_t> tot_vals_size(recv_vals_size);
890  this->comm().sum (tot_vals_size);
891 
892 
893  //------------------------------------------
894  // Collect the ids & number of values needed
895  // for all local objects, binning them into
896  // 'blocks' that will be sent to processor 0
897  for (dof_id_type blk=0; blk<num_blks; blk++)
898  {
899  // Each processor should build up its transfer buffers for its
900  // local objects in [first_object,last_object).
901  const dof_id_type
902  first_object = blk*io_blksize,
903  last_object = std::min(cast_int<dof_id_type>((blk+1)*io_blksize), n_objs);
904 
905  // convenience
906  std::vector<dof_id_type> & ids (xfer_ids[blk]);
907  std::vector<Number> & vals (recv_vals[blk]);
908 
909  // we now know the number of values we will store for each block,
910  // so we can do efficient preallocation
911  ids.clear(); ids.reserve (xfer_ids_size[blk]);
912  vals.resize(recv_vals_size[blk]);
913 
914  if (recv_vals_size[blk] != 0) // only if there are nonzero values to receive
915  for (iterator_type it=begin; it!=end; ++it)
916  if (((*it)->id() >= first_object) && // object in [first_object,last_object)
917  ((*it)->id() < last_object))
918  {
919  ids.push_back((*it)->id());
920 
921  unsigned int n_comp_tot=0;
922 
923  for (const auto & var : vars_to_read)
924  n_comp_tot += (*it)->n_comp(sys_num, var);
925 
926  ids.push_back (n_comp_tot*num_vecs);
927  }
928 
929 #ifdef LIBMESH_HAVE_MPI
930  id_tags[blk] = this->comm().get_unique_tag(100*num_blks + blk);
931  val_tags[blk] = this->comm().get_unique_tag(200*num_blks + blk);
932 
933  // nonblocking send the data for this block
934  this->comm().send (0, ids, id_requests[blk], id_tags[blk]);
935 
936  // Go ahead and post the receive too
937  this->comm().receive (0, vals, val_requests[blk], val_tags[blk]);
938 #endif
939  }
940 
941  //---------------------------------------------------
942  // Here processor 0 will read and distribute the data.
943  // We have to do this block-wise to ensure that we
944  // do not exhaust memory on processor 0.
945 
946  // give these variables scope outside the block to avoid reallocation
947  std::vector<std::vector<dof_id_type>> recv_ids (this->n_processors());
948  std::vector<std::vector<Number>> send_vals (this->n_processors());
949  std::vector<Parallel::Request> reply_requests (this->n_processors());
950  std::vector<unsigned int> obj_val_offsets; // map to traverse entry-wise rather than processor-wise
951  std::vector<Number> input_vals; // The input buffer for the current block
952  std::vector<InValType> input_vals_tmp; // The input buffer for the current block
953 
954  for (dof_id_type blk=0; blk<num_blks; blk++)
955  {
956  // Each processor should build up its transfer buffers for its
957  // local objects in [first_object,last_object).
958  const dof_id_type
959  first_object = blk*io_blksize,
960  last_object = std::min(cast_int<dof_id_type>((blk+1)*io_blksize), n_objs),
961  n_objects_blk = last_object - first_object;
962 
963  // Processor 0 has a special job. It needs to gather the requested indices
964  // in [first_object,last_object) from all processors, read the data from
965  // disk, and reply
966  if (this->processor_id() == 0)
967  {
968  // we know the input buffer size for this block and can begin reading it now
969  input_vals.resize(tot_vals_size[blk]);
970  input_vals_tmp.resize(tot_vals_size[blk]);
971 
972  // a ThreadedIO object to perform asynchronous file IO
973  ThreadedIO<InValType> threaded_io(io, input_vals_tmp);
974  Threads::Thread async_io(threaded_io);
975 
976  // offset array. this will define where each object's values
977  // map into the actual input_vals buffer. this must get
978  // 0-initialized because 0-component objects are not actually sent
979  obj_val_offsets.resize (n_objects_blk); std::fill (obj_val_offsets.begin(), obj_val_offsets.end(), 0);
980  recv_vals_size.resize(this->n_processors()); // reuse this to count how many values are going to each processor
981 
982 #ifndef NDEBUG
983  std::size_t n_vals_blk = 0;
984 #endif
985 
986  // loop over all processors and process their index request
987  for (processor_id_type comm_step=0, tnp=this->n_processors(); comm_step != tnp; ++comm_step)
988  {
989 #ifdef LIBMESH_HAVE_MPI
990  // blocking receive indices for this block, imposing no particular order on processor
991  Parallel::Status id_status (this->comm().probe (Parallel::any_source, id_tags[blk]));
992  std::vector<dof_id_type> & ids (recv_ids[id_status.source()]);
993  std::size_t & n_vals_proc (recv_vals_size[id_status.source()]);
994  this->comm().receive (id_status.source(), ids, id_tags[blk]);
995 #else
996  // straight copy without MPI
997  std::vector<dof_id_type> & ids (recv_ids[0]);
998  std::size_t & n_vals_proc (recv_vals_size[0]);
999  ids = xfer_ids[blk];
1000 #endif
1001 
1002  n_vals_proc = 0;
1003 
1004  // note its possible we didn't receive values for objects in
1005  // this block if they have no components allocated.
1006  for (std::size_t idx=0, sz=ids.size(); idx<sz; idx+=2)
1007  {
1008  const dof_id_type
1009  local_idx = ids[idx+0]-first_object,
1010  n_vals_tot_allvecs = ids[idx+1];
1011 
1012  libmesh_assert_less (local_idx, n_objects_blk);
1013 
1014  obj_val_offsets[local_idx] = n_vals_tot_allvecs;
1015  n_vals_proc += n_vals_tot_allvecs;
1016  }
1017 
1018 #ifndef NDEBUG
1019  n_vals_blk += n_vals_proc;
1020 #endif
1021  }
1022 
1023  // We need the offsets into the input_vals vector for each object.
1024  // fortunately, this is simply the partial sum of the total number
1025  // of components for each object
1026  std::partial_sum(obj_val_offsets.begin(), obj_val_offsets.end(),
1027  obj_val_offsets.begin());
1028 
1029  libmesh_assert_equal_to (n_vals_blk, obj_val_offsets.back());
1030  libmesh_assert_equal_to (n_vals_blk, tot_vals_size[blk]);
1031 
1032  // Wait for read completion
1033  async_io.join();
1034  // now copy the values back to the main vector for transfer
1035  for (auto i_val : index_range(input_vals))
1036  input_vals[i_val] = input_vals_tmp[i_val];
1037 
1038  n_read_values += input_vals.size();
1039 
1040  // pack data replies for each processor
1041  for (auto proc : IntRange<processor_id_type>(0, this->n_processors()))
1042  {
1043  const std::vector<dof_id_type> & ids (recv_ids[proc]);
1044  std::vector<Number> & vals (send_vals[proc]);
1045  const std::size_t & n_vals_proc (recv_vals_size[proc]);
1046 
1047  vals.clear(); vals.reserve(n_vals_proc);
1048 
1049  for (std::size_t idx=0, sz=ids.size(); idx<sz; idx+=2)
1050  {
1051  const dof_id_type
1052  local_idx = ids[idx+0]-first_object,
1053  n_vals_tot_allvecs = ids[idx+1];
1054 
1055  std::vector<Number>::const_iterator in_vals(input_vals.begin());
1056  if (local_idx != 0)
1057  std::advance (in_vals, obj_val_offsets[local_idx-1]);
1058 
1059  for (unsigned int val=0; val<n_vals_tot_allvecs; val++, ++in_vals)
1060  {
1061  libmesh_assert (in_vals != input_vals.end());
1062  //libMesh::out << "*in_vals=" << *in_vals << '\n';
1063  vals.push_back(*in_vals);
1064  }
1065  }
1066 
1067 #ifdef LIBMESH_HAVE_MPI
1068  // send the relevant values to this processor
1069  this->comm().send (proc, vals, reply_requests[proc], val_tags[blk]);
1070 #else
1071  recv_vals[blk] = vals;
1072 #endif
1073  }
1074  } // end processor 0 read/reply
1075 
1076  // all processors complete the (already posted) read for this block
1077  {
1078  Parallel::wait (val_requests[blk]);
1079 
1080  const std::vector<Number> & vals (recv_vals[blk]);
1081  std::vector<Number>::const_iterator val_it(vals.begin());
1082 
1083  if (!recv_vals[blk].empty()) // nonzero values to receive
1084  for (iterator_type it=begin; it!=end; ++it)
1085  if (((*it)->id() >= first_object) && // object in [first_object,last_object)
1086  ((*it)->id() < last_object))
1087  // unpack & set the values
1088  for (auto & vec : vecs)
1089  for (const auto & var : vars_to_read)
1090  {
1091  const unsigned int n_comp = (*it)->n_comp(sys_num, var);
1092 
1093  for (unsigned int comp=0; comp<n_comp; comp++, ++val_it)
1094  {
1095  const dof_id_type dof_index = (*it)->dof_number (sys_num, var, comp);
1096  libmesh_assert (val_it != vals.end());
1097  if (vec)
1098  {
1099  libmesh_assert_greater_equal (dof_index, vec->first_local_index());
1100  libmesh_assert_less (dof_index, vec->last_local_index());
1101  //libMesh::out << "dof_index, *val_it = \t" << dof_index << ", " << *val_it << '\n';
1102  vec->set (dof_index, *val_it);
1103  }
1104  }
1105  }
1106  }
1107 
1108  // processor 0 needs to make sure all replies have been handed off
1109  if (this->processor_id () == 0)
1110  Parallel::wait(reply_requests);
1111  }
1112 
1113  Parallel::wait(id_requests);
1114 
1115  return n_read_values;
1116 }

References libMesh::System::_written_var_indices, libMesh::ParallelObject::comm(), end, libMesh::MeshTools::Generation::Private::idx(), libMesh::index_range(), libMesh::invalid_uint, libMesh::Threads::NonConcurrentThread::join(), libMesh::libmesh_assert(), libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMesh::System::number(), and libMesh::ParallelObject::processor_id().

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 724 of file system_io.C.

726 {
727  // This method implements the input of the vectors
728  // contained in this System object, embedded in the
729  // output of an EquationSystems<T_sys>.
730  //
731  // 10.) The global solution vector, re-ordered to be node-major
732  // (More on this later.)
733  //
734  // for each additional vector in the object
735  //
736  // 11.) The global additional vector, re-ordered to be
737  // node-major (More on this later.)
738  parallel_object_only();
739  std::string comment;
740 
741  // PerfLog pl("IO Performance",false);
742  // pl.push("read_serialized_data");
743  // std::size_t total_read_size = 0;
744 
745  // 10.)
746  // Read the global solution vector
747  {
748  // total_read_size +=
749  this->read_serialized_vector<InValType>(io, this->solution.get());
750 
751  // get the comment
752  if (this->processor_id() == 0)
753  io.comment (comment);
754  }
755 
756  // 11.)
757  // Only read additional vectors if data is available, and only use
758  // that data to fill our vectors if the user requested it.
759  if (this->_additional_data_written)
760  {
761  const std::size_t nvecs = this->_vectors.size();
762 
763  // If the number of additional vectors written is non-zero, and
764  // the number of additional vectors we have is non-zero, and
765  // they don't match, then we can't read additional vectors
766  // and be sure we're reading data into the correct places.
767  if (read_additional_data && nvecs &&
768  nvecs != this->_additional_data_written)
769  libmesh_error_msg
770  ("Additional vectors in file do not match system");
771 
772  std::map<std::string, NumericVector<Number> *>::const_iterator
773  pos = _vectors.begin();
774 
775  for (std::size_t i = 0; i != this->_additional_data_written; ++i)
776  {
777  // Read data, but only put it into a vector if we've been
778  // asked to and if we have a corresponding vector to read.
779 
780  // total_read_size +=
781  this->read_serialized_vector<InValType>
782  (io, (read_additional_data && nvecs) ? pos->second : nullptr);
783 
784  // get the comment
785  if (this->processor_id() == 0)
786  io.comment (comment);
787 
788 
789  // If we've got vectors then we need to be iterating through
790  // those too
791  if (pos != this->_vectors.end())
792  ++pos;
793  }
794  }
795 
796  // const Real
797  // dt = pl.get_elapsed_time(),
798  // rate = total_read_size*sizeof(Number)/dt;
799 
800  // libMesh::out << "Read " << total_read_size << " \"Number\" values\n"
801  // << " Elapsed time = " << dt << '\n'
802  // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
803 
804  // pl.pop("read_serialized_data");
805 }

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::TransientRBConstruction::read_riesz_representors_from_files(), and libMesh::RBConstruction::read_riesz_representors_from_files().

◆ read_serialized_data() [2/2]

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

1275  { 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 1835 of file system.h.

1837  { return read_serialized_vector<Number>(io, &vec); }

◆ read_serialized_vector() [2/2]

template<typename InValType >
numeric_index_type libMesh::System::read_serialized_vector ( 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 1167 of file system_io.C.

1169 {
1170  parallel_object_only();
1171 
1172 #ifndef NDEBUG
1173  // In parallel we better be reading a parallel vector -- if not
1174  // we will not set all of its components below!!
1175  if (this->n_processors() > 1 && vec)
1176  {
1177  libmesh_assert (vec->type() == PARALLEL ||
1178  vec->type() == GHOSTED);
1179  }
1180 #endif
1181 
1182  libmesh_assert (io.reading());
1183 
1184  // vector length
1185  unsigned int vector_length=0; // FIXME? size_t would break binary compatibility...
1186 #ifndef NDEBUG
1187  std::size_t n_assigned_vals=0;
1188 #endif
1189 
1190  // Get the buffer size
1191  if (this->processor_id() == 0)
1192  io.data(vector_length, "# vector length");
1193  this->comm().broadcast(vector_length);
1194 
1195  const unsigned int nv = cast_int<unsigned int>
1196  (this->_written_var_indices.size());
1197  const dof_id_type
1198  n_nodes = this->get_mesh().n_nodes(),
1199  n_elem = this->get_mesh().n_elem();
1200 
1201  libmesh_assert_less_equal (nv, this->n_vars());
1202 
1203  // for newer versions, read variables node/elem major
1204  if (io.version() >= LIBMESH_VERSION_ID(0,7,4))
1205  {
1206  //---------------------------------
1207  // Collect the values for all nodes
1208 #ifndef NDEBUG
1209  n_assigned_vals +=
1210 #endif
1211  this->read_serialized_blocked_dof_objects (n_nodes,
1212  this->get_mesh().local_nodes_begin(),
1213  this->get_mesh().local_nodes_end(),
1214  InValType(),
1215  io,
1216  std::vector<NumericVector<Number> *> (1,vec));
1217 
1218 
1219  //------------------------------------
1220  // Collect the values for all elements
1221 #ifndef NDEBUG
1222  n_assigned_vals +=
1223 #endif
1225  this->get_mesh().local_elements_begin(),
1226  this->get_mesh().local_elements_end(),
1227  InValType(),
1228  io,
1229  std::vector<NumericVector<Number> *> (1,vec));
1230  }
1231 
1232  // for older versions, read variables var-major
1233  else
1234  {
1235  // Loop over each variable in the system, and then each node/element in the mesh.
1236  for (unsigned int data_var=0; data_var<nv; data_var++)
1237  {
1238  const unsigned int var = _written_var_indices[data_var];
1239  if (this->variable(var).type().family != SCALAR)
1240  {
1241  //---------------------------------
1242  // Collect the values for all nodes
1243 #ifndef NDEBUG
1244  n_assigned_vals +=
1245 #endif
1246  this->read_serialized_blocked_dof_objects (n_nodes,
1247  this->get_mesh().local_nodes_begin(),
1248  this->get_mesh().local_nodes_end(),
1249  InValType(),
1250  io,
1251  std::vector<NumericVector<Number> *> (1,vec),
1252  var);
1253 
1254 
1255  //------------------------------------
1256  // Collect the values for all elements
1257 #ifndef NDEBUG
1258  n_assigned_vals +=
1259 #endif
1261  this->get_mesh().local_elements_begin(),
1262  this->get_mesh().local_elements_end(),
1263  InValType(),
1264  io,
1265  std::vector<NumericVector<Number> *> (1,vec),
1266  var);
1267  } // end variable loop
1268  }
1269  }
1270 
1271  //-------------------------------------------
1272  // Finally loop over all the SCALAR variables
1273  for (unsigned int data_var=0; data_var<nv; data_var++)
1274  {
1275  const unsigned int var = _written_var_indices[data_var];
1276  if (this->variable(var).type().family == SCALAR)
1277  {
1278 #ifndef NDEBUG
1279  n_assigned_vals +=
1280 #endif
1281  this->read_SCALAR_dofs (var, io, vec);
1282  }
1283  }
1284 
1285  if (vec)
1286  vec->close();
1287 
1288 #ifndef NDEBUG
1289  this->comm().sum (n_assigned_vals);
1290  libmesh_assert_equal_to (n_assigned_vals, vector_length);
1291 #endif
1292 
1293  return vector_length;
1294 }

References libMesh::System::_written_var_indices, libMesh::NumericVector< T >::close(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::System::get_mesh(), libMesh::GHOSTED, libMesh::libmesh_assert(), libMesh::MeshBase::n_elem(), libMesh::MeshTools::n_elem(), n_nodes, libMesh::MeshBase::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::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 2199 of file system_io.C.

2201 {
2202  parallel_object_only();
2203 
2204  // Error checking
2205  // #ifndef NDEBUG
2206  // // In parallel we better be reading a parallel vector -- if not
2207  // // we will not set all of its components below!!
2208  // if (this->n_processors() > 1)
2209  // {
2210  // libmesh_assert (vec.type() == PARALLEL ||
2211  // vec.type() == GHOSTED);
2212  // }
2213  // #endif
2214 
2215  libmesh_assert (io.reading());
2216 
2217  if (this->processor_id() == 0)
2218  {
2219  // sizes
2220  unsigned int num_vecs=0;
2221  dof_id_type vector_length=0;
2222 
2223  // Get the number of vectors
2224  io.data(num_vecs);
2225  // Get the buffer size
2226  io.data(vector_length);
2227 
2228  libmesh_assert_equal_to (num_vecs, vectors.size());
2229 
2230  if (num_vecs != 0)
2231  {
2232  libmesh_assert_not_equal_to (vectors[0], 0);
2233  libmesh_assert_equal_to (vectors[0]->size(), vector_length);
2234  }
2235  }
2236 
2237  // no need to actually communicate these.
2238  // this->comm().broadcast(num_vecs);
2239  // this->comm().broadcast(vector_length);
2240 
2241  // Cache these - they are not free!
2242  const dof_id_type
2243  n_nodes = this->get_mesh().n_nodes(),
2244  n_elem = this->get_mesh().n_elem();
2245 
2246  std::size_t read_length = 0;
2247 
2248  //---------------------------------
2249  // Collect the values for all nodes
2250  read_length +=
2251  this->read_serialized_blocked_dof_objects (n_nodes,
2252  this->get_mesh().local_nodes_begin(),
2253  this->get_mesh().local_nodes_end(),
2254  InValType(),
2255  io,
2256  vectors);
2257 
2258  //------------------------------------
2259  // Collect the values for all elements
2260  read_length +=
2262  this->get_mesh().local_elements_begin(),
2263  this->get_mesh().local_elements_end(),
2264  InValType(),
2265  io,
2266  vectors);
2267 
2268  //-------------------------------------------
2269  // Finally loop over all the SCALAR variables
2270  for (NumericVector<Number> * vec : vectors)
2271  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
2272  if (this->variable(var).type().family == SCALAR)
2273  {
2274  libmesh_assert_not_equal_to (vec, 0);
2275 
2276  read_length +=
2277  this->read_SCALAR_dofs (var, io, vec);
2278  }
2279 
2280  //---------------------------------------
2281  // last step - must close all the vectors
2282  for (NumericVector<Number> * vec : vectors)
2283  {
2284  libmesh_assert_not_equal_to (vec, 0);
2285  vec->close();
2286  }
2287 
2288  return read_length;
2289 }

References libMesh::Xdr::data(), libMesh::System::get_mesh(), libMesh::libmesh_assert(), libMesh::MeshBase::n_elem(), libMesh::MeshTools::n_elem(), n_nodes, libMesh::MeshBase::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, and libMesh::System::variable().

Referenced by libMesh::RBEvaluation::read_in_vectors_from_multiple_files().

◆ read_serialized_vectors() [2/2]

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

1295  { 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::ImplicitSystem.

Definition at line 96 of file diff_system.C.

97 {
99 
101  libmesh_assert_equal_to (&(time_solver->system()), this);
102 
103  time_solver->reinit();
104 }

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

◆ reinit_constraints()

void libMesh::System::reinit_constraints ( )
virtualinherited

◆ release_linear_solver()

void libMesh::DifferentiableSystem::release_linear_solver ( LinearSolver< Number > *  ) const
overridevirtualinherited

Releases a pointer to a linear solver acquired by this->get_linear_solver()

Reimplemented from libMesh::ImplicitSystem.

Definition at line 194 of file diff_system.C.

195 {
196 }

◆ remove_matrix()

void libMesh::ImplicitSystem::remove_matrix ( const std::string &  mat_name)
inherited

Removes the additional matrix mat_name from this system.

Definition at line 221 of file implicit_system.C.

222 {
223  matrices_iterator pos = _matrices.find (mat_name);
224 
225  //Return if the matrix does not exist
226  if (pos == _matrices.end())
227  return;
228 
229  delete pos->second;
230 
231  _matrices.erase(pos);
232 }

References libMesh::ImplicitSystem::_matrices.

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

◆ remove_vector()

void libMesh::System::remove_vector ( const std::string &  vec_name)
inherited

Removes the additional vector vec_name from this system.

Definition at line 699 of file system.C.

700 {
701  vectors_iterator pos = _vectors.find(vec_name);
702 
703  //Return if the vector does not exist
704  if (pos == _vectors.end())
705  return;
706 
707  delete pos->second;
708 
709  _vectors.erase(pos);
710 
711  _vector_projections.erase(vec_name);
712  _vector_is_adjoint.erase(vec_name);
713  _vector_types.erase(vec_name);
714 }

References libMesh::System::_vector_is_adjoint, libMesh::System::_vector_projections, libMesh::System::_vector_types, and libMesh::System::_vectors.

◆ request_matrix() [1/2]

SparseMatrix< Number > * libMesh::ImplicitSystem::request_matrix ( const std::string &  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 249 of file implicit_system.C.

250 {
251  // Make sure the matrix exists
252  matrices_iterator pos = _matrices.find (mat_name);
253 
254  if (pos == _matrices.end())
255  return nullptr;
256 
257  return pos->second;
258 }

References libMesh::ImplicitSystem::_matrices.

◆ request_matrix() [2/2]

const SparseMatrix< Number > * libMesh::ImplicitSystem::request_matrix ( const std::string &  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 236 of file implicit_system.C.

237 {
238  // Make sure the matrix exists
239  const_matrices_iterator pos = _matrices.find (mat_name);
240 
241  if (pos == _matrices.end())
242  return nullptr;
243 
244  return pos->second;
245 }

References libMesh::ImplicitSystem::_matrices.

Referenced by libMesh::ImplicitSystem::sensitivity_solve(), libMesh::NewtonSolver::solve(), and libMesh::LinearImplicitSystem::solve().

◆ request_vector() [1/4]

NumericVector< Number > * libMesh::System::request_vector ( const std::string &  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 728 of file system.C.

729 {
730  vectors_iterator pos = _vectors.find(vec_name);
731 
732  if (pos == _vectors.end())
733  return nullptr;
734 
735  return pos->second;
736 }

References libMesh::System::_vectors.

◆ request_vector() [2/4]

const NumericVector< Number > * libMesh::System::request_vector ( const std::string &  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 716 of file system.C.

717 {
718  const_vectors_iterator pos = _vectors.find(vec_name);
719 
720  if (pos == _vectors.end())
721  return nullptr;
722 
723  return pos->second;
724 }

References libMesh::System::_vectors.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error().

◆ request_vector() [3/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 757 of file system.C.

758 {
760  vectors_iterator v_end = vectors_end();
761  unsigned int num = 0;
762  while ((num<vec_num) && (v!=v_end))
763  {
764  num++;
765  ++v;
766  }
767  if (v==v_end)
768  return nullptr;
769  return v->second;
770 }

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

◆ request_vector() [4/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 740 of file system.C.

741 {
744  unsigned int num = 0;
745  while ((num<vec_num) && (v!=v_end))
746  {
747  num++;
748  ++v;
749  }
750  if (v==v_end)
751  return nullptr;
752  return v->second;
753 }

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

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

455 {
456  if (subset != nullptr)
457  libmesh_not_implemented();
458 }

◆ restrict_vectors()

void libMesh::System::restrict_vectors ( )
virtualinherited

Restrict vectors after the mesh has coarsened.

Definition at line 324 of file system.C.

325 {
326 #ifdef LIBMESH_ENABLE_AMR
327  // Restrict the _vectors on the coarsened cells
328  for (auto & pr : _vectors)
329  {
330  NumericVector<Number> * v = pr.second;
331 
332  if (_vector_projections[pr.first])
333  {
334  this->project_vector (*v, this->vector_is_adjoint(pr.first));
335  }
336  else
337  {
338  ParallelType type = _vector_types[pr.first];
339 
340  if (type == GHOSTED)
341  {
342 #ifdef LIBMESH_ENABLE_GHOSTED
343  pr.second->init (this->n_dofs(), this->n_local_dofs(),
344  _dof_map->get_send_list(), false,
345  GHOSTED);
346 #else
347  libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
348 #endif
349  }
350  else
351  pr.second->init (this->n_dofs(), this->n_local_dofs(), false, type);
352  }
353  }
354 
355  const std::vector<dof_id_type> & send_list = _dof_map->get_send_list ();
356 
357  // Restrict the solution on the coarsened cells
359  this->project_vector (*solution);
360  // Or at least make sure the solution vector is the correct size
361  else
362  solution->init (this->n_dofs(), this->n_local_dofs(), true, PARALLEL);
363 
364 #ifdef LIBMESH_ENABLE_GHOSTED
365  current_local_solution->init(this->n_dofs(),
366  this->n_local_dofs(), send_list,
367  false, GHOSTED);
368 #else
369  current_local_solution->init(this->n_dofs());
370 #endif
371 
373  solution->localize (*current_local_solution, send_list);
374 
375 #endif // LIBMESH_ENABLE_AMR
376 }

References libMesh::System::_dof_map, libMesh::System::_solution_projection, libMesh::System::_vector_projections, libMesh::System::_vector_types, libMesh::System::_vectors, libMesh::System::current_local_solution, 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 301 of file implicit_system.C.

302 {
303  // Log how long the linear solve takes.
304  LOG_SCOPE("sensitivity_solve()", "ImplicitSystem");
305 
306  // The forward system should now already be solved.
307  // Now assemble the corresponding sensitivity system.
308 
309  if (this->assemble_before_solve)
310  {
311  // Build the Jacobian
312  this->assembly(false, true);
313  this->matrix->close();
314 
315  // Reset and build the RHS from the residual derivatives
316  this->assemble_residual_derivatives(parameters);
317  }
318 
319  // The sensitivity problem is linear
320  LinearSolver<Number> * linear_solver = this->get_linear_solver();
321 
322  // Our iteration counts and residuals will be sums of the individual
323  // results
324  std::pair<unsigned int, Real> solver_params =
326  std::pair<unsigned int, Real> totalrval = std::make_pair(0,0.0);
327 
328  // Solve the linear system.
329  SparseMatrix<Number> * pc = this->request_matrix("Preconditioner");
330  for (auto p : IntRange<unsigned int>(0, parameters.size()))
331  {
332  std::pair<unsigned int, Real> rval =
333  linear_solver->solve (*matrix, pc,
334  this->add_sensitivity_solution(p),
335  this->get_sensitivity_rhs(p),
336  double(solver_params.second),
337  solver_params.first);
338 
339  totalrval.first += rval.first;
340  totalrval.second += rval.second;
341  }
342 
343  // The linear solver may not have fit our constraints exactly
344 #ifdef LIBMESH_ENABLE_CONSTRAINTS
345  for (auto p : IntRange<unsigned int>(0, parameters.size()))
347  (*this, &this->get_sensitivity_solution(p),
348  /* homogeneous = */ true);
349 #endif
350 
351  this->release_linear_solver(linear_solver);
352 
353  return totalrval;
354 }

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::ImplicitSystem::matrix, libMesh::ImplicitSystem::release_linear_solver(), libMesh::ImplicitSystem::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 402 of file system.h.

403  { 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 2147 of file system.h.

2148 {
2149  _basic_system_only = true;
2150 }

References libMesh::System::_basic_system_only.

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

◆ 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 581 of file diff_physics.h.

582 {
583  // For now we assume that we're doing fully coupled mesh motion
584  // if (sys && sys != this)
585  // libmesh_not_implemented();
586 
587  // For the foreseeable future we'll assume that we keep these
588  // Systems in the same EquationSystems
589  // libmesh_assert_equal_to (&this->get_equation_systems(),
590  // &sys->get_equation_systems());
591 
592  // And for the immediate future this code may not even work
593  libmesh_experimental();
594 
595  _mesh_sys = sys;
596 }

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 601 of file diff_physics.h.

602 {
603  _mesh_x_var = var;
604 }

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 609 of file diff_physics.h.

610 {
611  _mesh_y_var = var;
612 }

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 617 of file diff_physics.h.

618 {
619  _mesh_z_var = var;
620 }

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 269 of file fem_system.h.

271 {
272  if (_numerical_jacobian_h_for_var.size() <= var_num)
273  _numerical_jacobian_h_for_var.resize(var_num+1,Real(0));
274 
275  libmesh_assert_greater(new_h, 0);
276 
277  _numerical_jacobian_h_for_var[var_num] = new_h;
278 }

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

◆ 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 241 of file diff_system.h.

242  {
243  time_solver.reset(_time_solver.release());
244  }

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

875 {
876  // We reserve -1 for vectors which get primal constraints, -2 for
877  // vectors which get no constraints
878  libmesh_assert_greater_equal(qoi_num, -2);
879  _vector_is_adjoint[vec_name] = qoi_num;
880 }

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

857 {
858  _vector_projections[vec_name] = preserve;
859 }

References libMesh::System::_vector_projections.

Referenced by main().

◆ 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 192 of file diff_physics.h.

193  {
194  return request_jacobian;
195  }

Referenced by libMesh::EulerSolver::side_residual(), libMesh::Euler2Solver::side_residual(), libMesh::SteadySolver::side_residual(), libMesh::EigenTimeSolver::side_residual(), and libMesh::NewmarkSolver::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 392 of file diff_physics.h.

393  {
394  return request_jacobian;
395  }

Referenced by libMesh::EulerSolver::side_residual(), libMesh::Euler2Solver::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 336 of file diff_physics.h.

337  {
338  return request_jacobian;
339  }

Referenced by libMesh::EulerSolver::side_residual(), libMesh::Euler2Solver::side_residual(), libMesh::EigenTimeSolver::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 287 of file diff_system.h.

287 {}

◆ 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, LaplaceSystem, and CoupledSystemQoI.

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

Definition at line 172 of file diff_physics.h.

173  {
174  return request_jacobian;
175  }

Referenced by libMesh::EulerSolver::side_residual(), libMesh::Euler2Solver::side_residual(), libMesh::SteadySolver::side_residual(), libMesh::EigenTimeSolver::side_residual(), and libMesh::NewmarkSolver::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.

Definition at line 1046 of file fem_system.C.

1047 {
1048  // We are solving the primal problem
1049  Parent::solve();
1050 
1051  // On a moving mesh we want the mesh to reflect the new solution
1052  this->mesh_position_set();
1053 }

References libMesh::FEMSystem::mesh_position_set(), and libMesh::DifferentiableSystem::solve().

Referenced by main().

◆ swap_physics()

void libMesh::DifferentiableSystem::swap_physics ( DifferentiablePhysics *&  swap_physics)
inherited

Swap current physics object with external object.

Definition at line 353 of file diff_system.C.

354 {
356 }

References libMesh::DifferentiableSystem::_diff_physics, and swap().

◆ system()

sys_type& libMesh::ImplicitSystem::system ( )
inlineinherited
Returns
A reference to *this.

Definition at line 82 of file implicit_system.h.

82 { 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 libMesh::OptimizationSystem, libMesh::NonlinearImplicitSystem, libMesh::LinearImplicitSystem, libMesh::RBConstruction, libMesh::FrequencySystem, libMesh::NewmarkSystem, libMesh::TransientSystem< RBConstruction >, and SolidSystem.

Definition at line 118 of file implicit_system.h.

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

virtual void libMesh::DifferentiablePhysics::time_evolving ( unsigned int  var)
inlinevirtualinherited

Tells the DiffSystem that variable var is evolving with respect to time.

In general, the user's init() function should call 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).

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 250 of file diff_physics.h.

251  {
252  libmesh_deprecated();
253  this->time_evolving(var,1);
254  }

Referenced by libMesh::DifferentiableSystem::add_second_order_dot_vars(), CurlCurlSystem::init_data(), and HeatSystem::init_data().

◆ time_evolving() [2/2]

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 46 of file diff_physics.C.

48 {
49  if (order != 1 && order != 2)
50  libmesh_error_msg("Input order must be 1 or 2!");
51 
52  if (_time_evolving.size() <= var)
53  _time_evolving.resize(var+1, 0);
54 
55  _time_evolving[var] = order;
56 
57  if (order == 1)
58  _first_order_vars.insert(var);
59  else
60  _second_order_vars.insert(var);
61 }

References libMesh::DifferentiablePhysics::_first_order_vars, libMesh::DifferentiablePhysics::_second_order_vars, and libMesh::DifferentiablePhysics::_time_evolving.

◆ u()

virtual Number ConstantFirstOrderODE::u ( Real  t)
inlinevirtual

Exact solution as a function of time t.

Implements FirstOrderScalarSystemBase.

Definition at line 28 of file first_order_unsteady_solver_test.C.

29  { return Real(50)/21*t; }

References libMesh::Real.

◆ update()

void libMesh::System::update ( )
virtualinherited

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

Reimplemented in SolidSystem.

Definition at line 408 of file system.C.

409 {
410  libmesh_assert(solution->closed());
411 
412  const std::vector<dof_id_type> & send_list = _dof_map->get_send_list ();
413 
414  // Check sizes
415  libmesh_assert_equal_to (current_local_solution->size(), solution->size());
416  // More processors than elements => empty send_list
417  // libmesh_assert (!send_list.empty());
418  libmesh_assert_less_equal (send_list.size(), solution->size());
419 
420  // Create current_local_solution from solution. This will
421  // put a local copy of solution into current_local_solution.
422  // Only the necessary values (specified by the send_list)
423  // are copied to minimize communication
424  solution->localize (*current_local_solution, send_list);
425 }

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(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), DMlibMeshFunction(), DMlibMeshJacobian(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::TransientRBConstruction::initialize_truth(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::NewtonSolver::line_search(), libMesh::RBEIMConstruction::load_basis_function(), libMesh::RBConstruction::load_basis_function(), libMesh::RBEIMConstruction::load_rb_solution(), libMesh::RBConstruction::load_rb_solution(), libMesh::TransientRBConstruction::load_rb_solution(), libMesh::FEMSystem::mesh_position_get(), HeatSystem::perturb_accumulate_residuals(), libMesh::FEMSystem::postprocess(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::NewtonSolver::solve(), libMesh::ExplicitSystem::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::NonlinearImplicitSystem::solve(), libMesh::OptimizationSystem::solve(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::DirectSolutionTransfer::transfer(), and libMesh::RBEIMConstruction::truth_solve().

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

643 {
644  global_soln.resize (solution->size());
645 
646  solution->localize (global_soln);
647 }

References libMesh::System::solution.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::ExactErrorEstimator::estimate_error(), and main().

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

653 {
654  global_soln.resize (solution->size());
655 
656  solution->localize_to_one (global_soln, dest_proc);
657 }

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

1911 {
1912  // Call the user-provided assembly function,
1913  // if it was provided
1914  if (_assemble_system_function != nullptr)
1916 
1917  // ...or the user-provided assembly object.
1918  else if (_assemble_system_object != nullptr)
1920 }

References libMesh::System::_assemble_system_function, libMesh::System::_assemble_system_object, libMesh::System::_equation_systems, libMesh::System::Assembly::assemble(), and libMesh::System::name().

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

1925 {
1926  // Call the user-provided constraint function,
1927  // if it was provided
1928  if (_constrain_system_function!= nullptr)
1930 
1931  // ...or the user-provided constraint object.
1932  else if (_constrain_system_object != nullptr)
1934 }

References libMesh::System::_constrain_system_function, libMesh::System::_constrain_system_object, libMesh::System::_equation_systems, libMesh::System::Constraint::constrain(), and libMesh::System::name().

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

1897 {
1898  // Call the user-provided initialization function,
1899  // if it was provided
1900  if (_init_system_function != nullptr)
1901  this->_init_system_function (_equation_systems, this->name());
1902 
1903  // ...or the user-provided initialization object.
1904  else if (_init_system_object != nullptr)
1906 }

References libMesh::System::_equation_systems, libMesh::System::_init_system_function, libMesh::System::_init_system_object, libMesh::System::Initialization::initialize(), and libMesh::System::name().

Referenced by libMesh::System::init(), and libMesh::NewmarkSystem::initial_conditions().

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

1939 {
1940  // Call the user-provided quantity of interest function,
1941  // if it was provided
1942  if (_qoi_evaluate_function != nullptr)
1943  this->_qoi_evaluate_function(_equation_systems, this->name(), qoi_indices);
1944 
1945  // ...or the user-provided QOI function object.
1946  else if (_qoi_evaluate_object != nullptr)
1947  this->_qoi_evaluate_object->qoi(qoi_indices);
1948 }

References libMesh::System::_equation_systems, libMesh::System::_qoi_evaluate_function, libMesh::System::_qoi_evaluate_object, libMesh::System::name(), and libMesh::System::QOI::qoi().

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

1955 {
1956  // Call the user-provided quantity of interest derivative,
1957  // if it was provided
1958  if (_qoi_evaluate_derivative_function != nullptr)
1960  (_equation_systems, this->name(), qoi_indices, include_liftfunc,
1961  apply_constraints);
1962 
1963  // ...or the user-provided QOI derivative function object.
1964  else if (_qoi_evaluate_derivative_object != nullptr)
1966  (qoi_indices, include_liftfunc, apply_constraints);
1967 }

References libMesh::System::_equation_systems, libMesh::System::_qoi_evaluate_derivative_function, libMesh::System::_qoi_evaluate_derivative_object, libMesh::System::name(), and libMesh::System::QOIDerivative::qoi_derivative().

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

◆ variable()

const Variable & libMesh::System::variable ( unsigned int  var) const
inlineinherited

◆ variable_group()

const VariableGroup & libMesh::System::variable_group ( unsigned int  vg) const
inlineinherited

Return a constant reference to VariableGroup vg.

Definition at line 2193 of file system.h.

2194 {
2195  libmesh_assert_less (vg, _variable_groups.size());
2196 
2197  return _variable_groups[vg];
2198 }

References libMesh::System::_variable_groups.

Referenced by libMesh::FEMSystem::assembly(), libMesh::System::get_info(), and libMesh::System::init_data().

◆ variable_name()

const std::string & libMesh::System::variable_name ( const unsigned int  i) const
inlineinherited

◆ variable_number()

unsigned short int libMesh::System::variable_number ( const std::string &  var) const
inherited
Returns
The variable number associated with the user-specified variable named var.

Definition at line 1232 of file system.C.

1233 {
1234  auto var_num = libmesh_map_find(_variable_numbers, var);
1235  libmesh_assert_equal_to (_variables[var_num].name(), var);
1236  return var_num;
1237 }

References libMesh::System::_variable_numbers, libMesh::System::_variables, and libMesh::System::name().

Referenced by libMesh::ExactSolution::_compute_error(), LinearElasticity::assemble(), AssembleOptimization::assemble_A_and_F(), assemble_elasticity(), assemble_matrix_and_rhs(), assemble_shell(), assemble_stokes(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::find_squared_element_error(), LargeDeformationElasticity::jacobian(), line_print(), main(), LinearElasticityWithContact::move_mesh(), libMesh::System::read_header(), LargeDeformationElasticity::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::System::variable_type(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().

◆ variable_scalar_number() [1/2]

unsigned int libMesh::System::variable_scalar_number ( const std::string &  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 2214 of file system.h.

2216 {
2217  return variable_scalar_number(this->variable_number(var), component);
2218 }

References libMesh::System::variable_number().

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::ExodusII_IO::copy_scalar_solution(), and libMesh::ExactErrorEstimator::find_squared_element_error().

◆ variable_scalar_number() [2/2]

unsigned int libMesh::System::variable_scalar_number ( unsigned int  var_num,
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 var_num

Irony: currently our only non-scalar-valued variable type is SCALAR.

Definition at line 2224 of file system.h.

2226 {
2227  return _variables[var_num].first_scalar_number() + component;
2228 }

References libMesh::System::_variables.

◆ variable_type() [1/2]

const FEType & libMesh::System::variable_type ( const std::string &  var) const
inlineinherited
Returns
The finite element type for variable var.

Definition at line 2243 of file system.h.

2244 {
2245  return _variables[this->variable_number(var)].type();
2246 }

References libMesh::System::_variables, and libMesh::System::variable_number().

◆ variable_type() [2/2]

const FEType & libMesh::System::variable_type ( const unsigned int  i) const
inlineinherited

◆ vector_is_adjoint()

int libMesh::System::vector_is_adjoint ( const std::string &  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 884 of file system.C.

885 {
886  libmesh_assert(_vector_is_adjoint.find(vec_name) !=
887  _vector_is_adjoint.end());
888 
889  return _vector_is_adjoint.find(vec_name)->second;
890 }

References libMesh::System::_vector_is_adjoint, and libMesh::libmesh_assert().

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

835 {
838 
839  for (; v != v_end; ++v)
840  {
841  // Check if the current vector is the one whose name we want
842  if (&vec_reference == v->second)
843  break; // exit loop if it is
844  }
845 
846  // Before returning, make sure we didnt loop till the end and not find any match
847  libmesh_assert (v != v_end);
848 
849  // Return the string associated with the current vector
850  return v->first;
851 }

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

821 {
824  unsigned int num = 0;
825  while ((num<vec_num) && (v!=v_end))
826  {
827  num++;
828  ++v;
829  }
830  libmesh_assert (v != v_end);
831  return v->first;
832 }

References libMesh::libmesh_assert(), libMesh::System::vectors_begin(), and libMesh::System::vectors_end().

Referenced by main().

◆ vector_preservation()

bool libMesh::System::vector_preservation ( const std::string &  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 863 of file system.C.

864 {
865  if (_vector_projections.find(vec_name) == _vector_projections.end())
866  return false;
867 
868  return _vector_projections.find(vec_name)->second;
869 }

References libMesh::System::_vector_projections.

Referenced by libMesh::MemorySolutionHistory::store().

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

2302 {
2303  return _vectors.begin();
2304 }

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

2314 {
2315  return _vectors.end();
2316 }

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 412 of file implicit_system.C.

415 {
416  // Log how long the linear solve takes.
417  LOG_SCOPE("weighted_sensitivity_adjoint_solve()", "ImplicitSystem");
418 
419  // We currently get partial derivatives via central differencing
420  const Real delta_p = TOLERANCE;
421 
422  ParameterVector & parameters =
423  const_cast<ParameterVector &>(parameters_in);
424 
425  // The forward system should now already be solved.
426  // The adjoint system should now already be solved.
427  // Now we're assembling a weighted sum of adjoint-adjoint systems:
428  //
429  // dR/du (u, sum_l(w_l*z^l)) = sum_l(w_l*(Q''_ul - R''_ul (u, z)))
430 
431  // FIXME: The derivation here does not yet take adjoint boundary
432  // conditions into account.
433 #ifdef LIBMESH_ENABLE_DIRICHLET
434  for (auto i : IntRange<unsigned int>(0, this->n_qois()))
435  if (qoi_indices.has_index(i))
437 #endif
438 
439  // We'll assemble the rhs first, because the R'' term will require
440  // perturbing the jacobian
441 
442  // We'll use temporary rhs vectors, because we haven't (yet) found
443  // any good reasons why users might want to save these:
444 
445  std::vector<std::unique_ptr<NumericVector<Number>>> temprhs(this->n_qois());
446  for (auto i : IntRange<unsigned int>(0, this->n_qois()))
447  if (qoi_indices.has_index(i))
448  temprhs[i] = this->rhs->zero_clone();
449 
450  // We approximate the _l partial derivatives via a central
451  // differencing perturbation in the w_l direction:
452  //
453  // sum_l(w_l*v_l) ~= (v(p + dp*w_l*e_l) - v(p - dp*w_l*e_l))/(2*dp)
454 
455  // PETSc doesn't implement SGEMX, so neither does NumericVector,
456  // so we want to avoid calculating f -= R'*z. We'll thus evaluate
457  // the above equation by first adding -v(p+dp...), then multiplying
458  // the intermediate result vectors by -1, then adding -v(p-dp...),
459  // then finally dividing by 2*dp.
460 
461  ParameterVector oldparameters, parameterperturbation;
462  parameters.deep_copy(oldparameters);
463  weights.deep_copy(parameterperturbation);
464  parameterperturbation *= delta_p;
465  parameters += parameterperturbation;
466 
467  this->assembly(false, true);
468  this->matrix->close();
469 
470  // Take the discrete adjoint, so that we can calculate R_u(u,z) with
471  // a matrix-vector product of R_u and z.
473 
474  this->assemble_qoi_derivative(qoi_indices,
475  /* include_liftfunc = */ false,
476  /* apply_constraints = */ true);
477  for (auto i : IntRange<unsigned int>(0, this->n_qois()))
478  if (qoi_indices.has_index(i))
479  {
480  this->get_adjoint_rhs(i).close();
481  *(temprhs[i]) -= this->get_adjoint_rhs(i);
482  this->matrix->vector_mult_add(*(temprhs[i]), this->get_adjoint_solution(i));
483  *(temprhs[i]) *= -1.0;
484  }
485 
486  oldparameters.value_copy(parameters);
487  parameterperturbation *= -1.0;
488  parameters += parameterperturbation;
489 
490  this->assembly(false, true);
491  this->matrix->close();
493 
494  this->assemble_qoi_derivative(qoi_indices,
495  /* include_liftfunc = */ false,
496  /* apply_constraints = */ true);
497  for (auto i : IntRange<unsigned int>(0, this->n_qois()))
498  if (qoi_indices.has_index(i))
499  {
500  this->get_adjoint_rhs(i).close();
501  *(temprhs[i]) -= this->get_adjoint_rhs(i);
502  this->matrix->vector_mult_add(*(temprhs[i]), this->get_adjoint_solution(i));
503  *(temprhs[i]) /= (2.0*delta_p);
504  }
505 
506  // Finally, assemble the jacobian at the non-perturbed parameter
507  // values. Ignore assemble_before_solve; if we had a good
508  // non-perturbed matrix before we've already overwritten it.
509  oldparameters.value_copy(parameters);
510 
511  // if (this->assemble_before_solve)
512  {
513  // Build the Jacobian
514  this->assembly(false, true);
515  this->matrix->close();
516 
517  // Take the discrete adjoint
519  }
520 
521  // The weighted adjoint-adjoint problem is linear
522  LinearSolver<Number> * linear_solver = this->get_linear_solver();
523 
524  // Our iteration counts and residuals will be sums of the individual
525  // results
526  std::pair<unsigned int, Real> solver_params =
528  std::pair<unsigned int, Real> totalrval = std::make_pair(0,0.0);
529 
530  for (auto i : IntRange<unsigned int>(0, this->n_qois()))
531  if (qoi_indices.has_index(i))
532  {
533  const std::pair<unsigned int, Real> rval =
534  linear_solver->solve (*matrix, this->add_weighted_sensitivity_adjoint_solution(i),
535  *(temprhs[i]),
536  double(solver_params.second),
537  solver_params.first);
538 
539  totalrval.first += rval.first;
540  totalrval.second += rval.second;
541  }
542 
543  this->release_linear_solver(linear_solver);
544 
545  // The linear solver may not have fit our constraints exactly
546 #ifdef LIBMESH_ENABLE_CONSTRAINTS
547  for (auto i : IntRange<unsigned int>(0, this->n_qois()))
548  if (qoi_indices.has_index(i))
551  /* homogeneous = */ true);
552 #endif
553 
554  return totalrval;
555 }

References libMesh::System::add_weighted_sensitivity_adjoint_solution(), libMesh::ExplicitSystem::assemble_qoi_derivative(), libMesh::ImplicitSystem::assembly(), libMesh::SparseMatrix< T >::close(), libMesh::NumericVector< 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::ImplicitSystem::matrix, libMesh::System::n_qois(), libMesh::Real, libMesh::ImplicitSystem::release_linear_solver(), 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 560 of file implicit_system.C.

562 {
563  // Log how long the linear solve takes.
564  LOG_SCOPE("weighted_sensitivity_solve()", "ImplicitSystem");
565 
566  // We currently get partial derivatives via central differencing
567  const Real delta_p = TOLERANCE;
568 
569  ParameterVector & parameters =
570  const_cast<ParameterVector &>(parameters_in);
571 
572  // The forward system should now already be solved.
573 
574  // Now we're assembling a weighted sum of sensitivity systems:
575  //
576  // dR/du (u, v)(sum(w_l*u'_l)) = -sum_l(w_l*R'_l (u, v)) forall v
577 
578  // We'll assemble the rhs first, because the R' term will require
579  // perturbing the system, and some applications may not be able to
580  // assemble a perturbed residual without simultaneously constructing
581  // a perturbed jacobian.
582 
583  // We approximate the _l partial derivatives via a central
584  // differencing perturbation in the w_l direction:
585  //
586  // sum_l(w_l*v_l) ~= (v(p + dp*w_l*e_l) - v(p - dp*w_l*e_l))/(2*dp)
587 
588  ParameterVector oldparameters, parameterperturbation;
589  parameters.deep_copy(oldparameters);
590  weights.deep_copy(parameterperturbation);
591  parameterperturbation *= delta_p;
592  parameters += parameterperturbation;
593 
594  this->assembly(true, false, true);
595  this->rhs->close();
596 
597  std::unique_ptr<NumericVector<Number>> temprhs = this->rhs->clone();
598 
599  oldparameters.value_copy(parameters);
600  parameterperturbation *= -1.0;
601  parameters += parameterperturbation;
602 
603  this->assembly(true, false, true);
604  this->rhs->close();
605 
606  *temprhs -= *(this->rhs);
607  *temprhs /= (2.0*delta_p);
608 
609  // Finally, assemble the jacobian at the non-perturbed parameter
610  // values
611  oldparameters.value_copy(parameters);
612 
613  // Build the Jacobian
614  this->assembly(false, true);
615  this->matrix->close();
616 
617  // The weighted sensitivity problem is linear
618  LinearSolver<Number> * linear_solver = this->get_linear_solver();
619 
620  std::pair<unsigned int, Real> solver_params =
622 
623  const std::pair<unsigned int, Real> rval =
624  linear_solver->solve (*matrix, this->add_weighted_sensitivity_solution(),
625  *temprhs,
626  double(solver_params.second),
627  solver_params.first);
628 
629  this->release_linear_solver(linear_solver);
630 
631  // The linear solver may not have fit our constraints exactly
632 #ifdef LIBMESH_ENABLE_CONSTRAINTS
634  (*this, &this->get_weighted_sensitivity_solution(),
635  /* homogeneous = */ true);
636 #endif
637 
638  return rval;
639 }

References libMesh::System::add_weighted_sensitivity_solution(), libMesh::ImplicitSystem::assembly(), libMesh::NumericVector< T >::clone(), libMesh::SparseMatrix< T >::close(), libMesh::NumericVector< 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::ImplicitSystem::release_linear_solver(), 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,
const std::string &  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 1298 of file system_io.C.

1301 {
1335  libmesh_assert (io.writing());
1336 
1337 
1338  // Only write the header information
1339  // if we are processor 0.
1340  if (this->get_mesh().processor_id() != 0)
1341  return;
1342 
1343  std::string comment;
1344  char buf[80];
1345 
1346  // 5.)
1347  // Write the number of variables in the system
1348 
1349  {
1350  // set up the comment
1351  comment = "# No. of Variables in System \"";
1352  comment += this->name();
1353  comment += "\"";
1354 
1355  unsigned int nv = this->n_vars();
1356  io.data (nv, comment.c_str());
1357  }
1358 
1359 
1360  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
1361  {
1362  // 6.)
1363  // Write the name of the var-th variable
1364  {
1365  // set up the comment
1366  comment = "# Name, Variable No. ";
1367  std::sprintf(buf, "%u", var);
1368  comment += buf;
1369  comment += ", System \"";
1370  comment += this->name();
1371  comment += "\"";
1372 
1373  std::string var_name = this->variable_name(var);
1374  io.data (var_name, comment.c_str());
1375  }
1376 
1377  // 6.1.) Variable subdomains
1378  {
1379  // set up the comment
1380  comment = "# Subdomains, Variable \"";
1381  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1382  comment += buf;
1383  comment += "\", System \"";
1384  comment += this->name();
1385  comment += "\"";
1386 
1387  const std::set<subdomain_id_type> & domains = this->variable(var).active_subdomains();
1388  std::vector<subdomain_id_type> domain_array;
1389  domain_array.assign(domains.begin(), domains.end());
1390  io.data (domain_array, comment.c_str());
1391  }
1392 
1393  // 7.)
1394  // Write the approximation order of the var-th variable
1395  // in this system
1396  {
1397  // set up the comment
1398  comment = "# Approximation Order, Variable \"";
1399  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1400  comment += buf;
1401  comment += "\", System \"";
1402  comment += this->name();
1403  comment += "\"";
1404 
1405  int order = static_cast<int>(this->variable_type(var).order);
1406  io.data (order, comment.c_str());
1407  }
1408 
1409 
1410 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1411 
1412  // do the same for radial_order
1413  {
1414  comment = "# Radial Approximation Order, Variable \"";
1415  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1416  comment += buf;
1417  comment += "\", System \"";
1418  comment += this->name();
1419  comment += "\"";
1420 
1421  int rad_order = static_cast<int>(this->variable_type(var).radial_order);
1422  io.data (rad_order, comment.c_str());
1423  }
1424 
1425 #endif
1426 
1427  // Write the Finite Element type of the var-th variable
1428  // in this System
1429  {
1430  // set up the comment
1431  comment = "# FE Family, Variable \"";
1432  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1433  comment += buf;
1434  comment += "\", System \"";
1435  comment += this->name();
1436  comment += "\"";
1437 
1438  const FEType & type = this->variable_type(var);
1439  int fam = static_cast<int>(type.family);
1440  io.data (fam, comment.c_str());
1441 
1442 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1443 
1444  comment = "# Radial FE Family, Variable \"";
1445  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1446  comment += buf;
1447  comment += "\", System \"";
1448  comment += this->name();
1449  comment += "\"";
1450 
1451  int radial_fam = static_cast<int>(type.radial_family);
1452  io.data (radial_fam, comment.c_str());
1453 
1454  comment = "# Infinite Mapping Type, Variable \"";
1455  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1456  comment += buf;
1457  comment += "\", System \"";
1458  comment += this->name();
1459  comment += "\"";
1460 
1461  int i_map = static_cast<int>(type.inf_map);
1462  io.data (i_map, comment.c_str());
1463 #endif
1464  }
1465  } // end of the variable loop
1466 
1467  // 8.)
1468  // Write the number of additional vectors in the System.
1469  // If write_additional_data==false, then write zero for
1470  // the number of additional vectors.
1471  {
1472  {
1473  // set up the comment
1474  comment = "# No. of Additional Vectors, System \"";
1475  comment += this->name();
1476  comment += "\"";
1477 
1478  unsigned int nvecs = write_additional_data ? this->n_vectors () : 0;
1479  io.data (nvecs, comment.c_str());
1480  }
1481 
1482  if (write_additional_data)
1483  {
1484  unsigned int cnt=0;
1485  for (const auto & pr : _vectors)
1486  {
1487  // 9.)
1488  // write the name of the cnt-th additional vector
1489  comment = "# Name of ";
1490  std::sprintf(buf, "%d", cnt++);
1491  comment += buf;
1492  comment += "th vector";
1493  std::string vec_name = pr.first;
1494 
1495  io.data (vec_name, comment.c_str());
1496  }
1497  }
1498  }
1499 }

References 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::System::n_vars(), libMesh::System::n_vectors(), libMesh::System::name(), libMesh::ParallelObject::processor_id(), libMesh::FEType::radial_family, 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 1503 of file system_io.C.

1505 {
1525  // PerfLog pl("IO Performance",false);
1526  // pl.push("write_parallel_data");
1527  // std::size_t total_written_size = 0;
1528 
1529  std::string comment;
1530 
1531  libmesh_assert (io.writing());
1532 
1533  std::vector<Number> io_buffer; io_buffer.reserve(this->solution->local_size());
1534 
1535  // build the ordered nodes and element maps.
1536  // when writing/reading parallel files we need to iterate
1537  // over our nodes/elements in order of increasing global id().
1538  // however, this is not guaranteed to be ordering we obtain
1539  // by using the node_iterators/element_iterators directly.
1540  // so build a set, sorted by id(), that provides the ordering.
1541  // further, for memory economy build the set but then transfer
1542  // its contents to vectors, which will be sorted.
1543  std::vector<const DofObject *> ordered_nodes, ordered_elements;
1544  {
1545  std::set<const DofObject *, CompareDofObjectsByID>
1546  ordered_nodes_set (this->get_mesh().local_nodes_begin(),
1547  this->get_mesh().local_nodes_end());
1548 
1549  ordered_nodes.insert(ordered_nodes.end(),
1550  ordered_nodes_set.begin(),
1551  ordered_nodes_set.end());
1552  }
1553  {
1554  std::set<const DofObject *, CompareDofObjectsByID>
1555  ordered_elements_set (this->get_mesh().local_elements_begin(),
1556  this->get_mesh().local_elements_end());
1557 
1558  ordered_elements.insert(ordered_elements.end(),
1559  ordered_elements_set.begin(),
1560  ordered_elements_set.end());
1561  }
1562 
1563  const unsigned int sys_num = this->number();
1564  const unsigned int nv = this->n_vars();
1565 
1566  // Loop over each non-SCALAR variable and each node, and write out the value.
1567  for (unsigned int var=0; var<nv; var++)
1568  if (this->variable(var).type().family != SCALAR)
1569  {
1570  // First write the node DOF values
1571  for (const auto & node : ordered_nodes)
1572  for (auto comp : IntRange<unsigned int>(0, node->n_comp(sys_num,var)))
1573  {
1574  libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
1576 
1577  io_buffer.push_back((*this->solution)(node->dof_number(sys_num, var, comp)));
1578  }
1579 
1580  // Then write the element DOF values
1581  for (const auto & elem : ordered_elements)
1582  for (auto comp : IntRange<unsigned int>(0, elem->n_comp(sys_num,var)))
1583  {
1584  libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
1586 
1587  io_buffer.push_back((*this->solution)(elem->dof_number(sys_num, var, comp)));
1588  }
1589  }
1590 
1591  // Finally, write the SCALAR data on the last processor
1592  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
1593  if (this->variable(var).type().family == SCALAR)
1594  {
1595  if (this->processor_id() == (this->n_processors()-1))
1596  {
1597  const DofMap & dof_map = this->get_dof_map();
1598  std::vector<dof_id_type> SCALAR_dofs;
1599  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
1600 
1601  for (auto dof : SCALAR_dofs)
1602  io_buffer.push_back((*this->solution)(dof));
1603  }
1604  }
1605 
1606  // 9.)
1607  //
1608  // Actually write the reordered solution vector
1609  // for the ith system to disk
1610 
1611  // set up the comment
1612  {
1613  comment = "# System \"";
1614  comment += this->name();
1615  comment += "\" Solution Vector";
1616  }
1617 
1618  io.data (io_buffer, comment.c_str());
1619 
1620  // total_written_size += io_buffer.size();
1621 
1622  // Only write additional vectors if wanted
1623  if (write_additional_data)
1624  {
1625  for (auto & pr : _vectors)
1626  {
1627  io_buffer.clear();
1628  io_buffer.reserve(pr.second->local_size());
1629 
1630  // Loop over each non-SCALAR variable and each node, and write out the value.
1631  for (unsigned int var=0; var<nv; var++)
1632  if (this->variable(var).type().family != SCALAR)
1633  {
1634  // First write the node DOF values
1635  for (const auto & node : ordered_nodes)
1636  for (auto comp : IntRange<unsigned int>(0, node->n_comp(sys_num,var)))
1637  {
1638  libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
1640 
1641  io_buffer.push_back((*pr.second)(node->dof_number(sys_num, var, comp)));
1642  }
1643 
1644  // Then write the element DOF values
1645  for (const auto & elem : ordered_elements)
1646  for (auto comp : IntRange<unsigned int>(0, elem->n_comp(sys_num,var)))
1647  {
1648  libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
1650 
1651  io_buffer.push_back((*pr.second)(elem->dof_number(sys_num, var, comp)));
1652  }
1653  }
1654 
1655  // Finally, write the SCALAR data on the last processor
1656  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
1657  if (this->variable(var).type().family == SCALAR)
1658  {
1659  if (this->processor_id() == (this->n_processors()-1))
1660  {
1661  const DofMap & dof_map = this->get_dof_map();
1662  std::vector<dof_id_type> SCALAR_dofs;
1663  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
1664 
1665  for (auto dof : SCALAR_dofs)
1666  io_buffer.push_back((*pr.second)(dof));
1667  }
1668  }
1669 
1670  // 10.)
1671  //
1672  // Actually write the reordered additional vector
1673  // for this system to disk
1674 
1675  // set up the comment
1676  {
1677  comment = "# System \"";
1678  comment += this->name();
1679  comment += "\" Additional Vector \"";
1680  comment += pr.first;
1681  comment += "\"";
1682  }
1683 
1684  io.data (io_buffer, comment.c_str());
1685 
1686  // total_written_size += io_buffer.size();
1687  }
1688  }
1689 
1690  // const Real
1691  // dt = pl.get_elapsed_time(),
1692  // rate = total_written_size*sizeof(Number)/dt;
1693 
1694  // libMesh::err << "Write " << total_written_size << " \"Number\" values\n"
1695  // << " Elapsed time = " << dt << '\n'
1696  // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
1697 
1698  // pl.pop("write_parallel_data");
1699 }

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::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 2097 of file system_io.C.

2100 {
2101  unsigned int written_length=0;
2102  std::vector<Number> vals; // The raw values for the local objects in the current block
2103  // Collect the SCALARs for the current variable
2104  if (this->processor_id() == (this->n_processors()-1))
2105  {
2106  const DofMap & dof_map = this->get_dof_map();
2107  std::vector<dof_id_type> SCALAR_dofs;
2108  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
2109  const unsigned int n_scalar_dofs = cast_int<unsigned int>
2110  (SCALAR_dofs.size());
2111 
2112  for (unsigned int i=0; i<n_scalar_dofs; i++)
2113  {
2114  vals.push_back( vec(SCALAR_dofs[i]) );
2115  }
2116  }
2117 
2118 #ifdef LIBMESH_HAVE_MPI
2119  if (this->n_processors() > 1)
2120  {
2121  const Parallel::MessageTag val_tag(1);
2122 
2123  // Post the receive on processor 0
2124  if (this->processor_id() == 0)
2125  {
2126  this->comm().receive(this->n_processors()-1, vals, val_tag);
2127  }
2128 
2129  // Send the data to processor 0
2130  if (this->processor_id() == (this->n_processors()-1))
2131  {
2132  this->comm().send(0, vals, val_tag);
2133  }
2134  }
2135 #endif
2136 
2137  // -------------------------------------------------------
2138  // Write the output on processor 0.
2139  if (this->processor_id() == 0)
2140  {
2141  const unsigned int vals_size =
2142  cast_int<unsigned int>(vals.size());
2143  io.data_stream (vals.data(), vals_size);
2144  written_length += vals_size;
2145  }
2146 
2147  return written_length;
2148 }

References libMesh::ParallelObject::comm(), libMesh::Xdr::data_stream(), libMesh::System::get_dof_map(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), and libMesh::DofMap::SCALAR_dof_indices().

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 1811 of file system_io.C.

1817 {
1818  parallel_object_only();
1819 
1820  //-------------------------------------------------------
1821  // General order: (IO format 0.7.4 & greater)
1822  //
1823  // for (objects ...)
1824  // for (vecs ....)
1825  // for (vars ....)
1826  // for (comps ...)
1827  //
1828  // where objects are nodes or elements, sorted to be
1829  // partition independent,
1830  // vecs are one or more *identically distributed* solution
1831  // coefficient vectors, vars are one or more variables
1832  // to write, and comps are all the components for said
1833  // vars on the object.
1834 
1835  // We will write all variables unless requested otherwise.
1836  std::vector<unsigned int> vars_to_write(1, var_to_write);
1837 
1838  if (var_to_write == libMesh::invalid_uint)
1839  {
1840  vars_to_write.clear(); vars_to_write.reserve(this->n_vars());
1841  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
1842  vars_to_write.push_back(var);
1843  }
1844 
1845  const dof_id_type io_blksize = cast_int<dof_id_type>
1846  (std::min(max_io_blksize, static_cast<std::size_t>(n_objs)));
1847 
1848  const unsigned int
1849  sys_num = this->number(),
1850  num_vecs = cast_int<unsigned int>(vecs.size()),
1851  num_blks = cast_int<unsigned int>(std::ceil(static_cast<double>(n_objs)/
1852  static_cast<double>(io_blksize)));
1853 
1854  // libMesh::out << "io_blksize = " << io_blksize
1855  // << ", num_objects = " << n_objs
1856  // << ", num_blks = " << num_blks
1857  // << std::endl;
1858 
1859  std::size_t written_length=0; // The numer of values written. This will be returned
1860  std::vector<std::vector<dof_id_type>> xfer_ids(num_blks); // The global IDs and # of components for the local objects in all blocks
1861  std::vector<std::vector<Number>> send_vals(num_blks); // The raw values for the local objects in all blocks
1862  std::vector<Parallel::Request>
1863  id_requests(num_blks), val_requests(num_blks); // send request handle for each block
1864  std::vector<Parallel::MessageTag>
1865  id_tags(num_blks), val_tags(num_blks); // tag number for each block
1866 
1867  // ------------------------------------------------------
1868  // First pass - count the number of objects in each block
1869  // traverse all the objects and figure out which block they
1870  // will ultimately live in.
1871  std::vector<unsigned int>
1872  xfer_ids_size (num_blks,0),
1873  send_vals_size (num_blks,0);
1874 
1875  for (iterator_type it=begin; it!=end; ++it)
1876  {
1877  const dof_id_type
1878  id = (*it)->id(),
1879  block = id/io_blksize;
1880 
1881  libmesh_assert_less (block, num_blks);
1882 
1883  xfer_ids_size[block] += 2; // for each object, we store its id, as well as the total number of components for all variables
1884 
1885  unsigned int n_comp_tot=0;
1886 
1887  for (const auto & var : vars_to_write)
1888  n_comp_tot += (*it)->n_comp(sys_num, var); // for each variable, we will store the nonzero components
1889 
1890  send_vals_size[block] += n_comp_tot*num_vecs;
1891  }
1892 
1893  //-----------------------------------------
1894  // Collect the values for all local objects,
1895  // binning them into 'blocks' that will be
1896  // sent to processor 0
1897  for (unsigned int blk=0; blk<num_blks; blk++)
1898  {
1899  // libMesh::out << "Writing object block " << blk << std::endl;
1900 
1901  // Each processor should build up its transfer buffers for its
1902  // local objects in [first_object,last_object).
1903  const dof_id_type
1904  first_object = blk*io_blksize,
1905  last_object = std::min(cast_int<dof_id_type>((blk+1)*io_blksize), n_objs);
1906 
1907  // convenience
1908  std::vector<dof_id_type> & ids (xfer_ids[blk]);
1909  std::vector<Number> & vals (send_vals[blk]);
1910 
1911  // we now know the number of values we will store for each block,
1912  // so we can do efficient preallocation
1913  ids.clear(); ids.reserve (xfer_ids_size[blk]);
1914  vals.clear(); vals.reserve (send_vals_size[blk]);
1915 
1916  if (send_vals_size[blk] != 0) // only send if we have nonzero components to write
1917  for (iterator_type it=begin; it!=end; ++it)
1918  if (((*it)->id() >= first_object) && // object in [first_object,last_object)
1919  ((*it)->id() < last_object))
1920  {
1921  ids.push_back((*it)->id());
1922 
1923  // count the total number of nonzeros transferred for this object
1924  {
1925  unsigned int n_comp_tot=0;
1926 
1927  for (const auto & var : vars_to_write)
1928  n_comp_tot += (*it)->n_comp(sys_num, var);
1929 
1930  ids.push_back (n_comp_tot*num_vecs); // even if 0 - processor 0 has no way of knowing otherwise...
1931  }
1932 
1933  // pack the values to send
1934  for (const auto & vec : vecs)
1935  for (const auto & var : vars_to_write)
1936  {
1937  const unsigned int n_comp = (*it)->n_comp(sys_num, var);
1938 
1939  for (unsigned int comp=0; comp<n_comp; comp++)
1940  {
1941  libmesh_assert_greater_equal ((*it)->dof_number(sys_num, var, comp), vec->first_local_index());
1942  libmesh_assert_less ((*it)->dof_number(sys_num, var, comp), vec->last_local_index());
1943  vals.push_back((*vec)((*it)->dof_number(sys_num, var, comp)));
1944  }
1945  }
1946  }
1947 
1948 #ifdef LIBMESH_HAVE_MPI
1949  id_tags[blk] = this->comm().get_unique_tag(100*num_blks + blk);
1950  val_tags[blk] = this->comm().get_unique_tag(200*num_blks + blk);
1951 
1952  // nonblocking send the data for this block
1953  this->comm().send (0, ids, id_requests[blk], id_tags[blk]);
1954  this->comm().send (0, vals, val_requests[blk], val_tags[blk]);
1955 #endif
1956  }
1957 
1958 
1959  if (this->processor_id() == 0)
1960  {
1961  std::vector<std::vector<dof_id_type>> recv_ids (this->n_processors());
1962  std::vector<std::vector<Number>> recv_vals (this->n_processors());
1963  std::vector<unsigned int> obj_val_offsets; // map to traverse entry-wise rather than processor-wise
1964  std::vector<Number> output_vals; // The output buffer for the current block
1965 
1966  // a ThreadedIO object to perform asynchronous file IO
1967  ThreadedIO<Number> threaded_io(io, output_vals);
1968  std::unique_ptr<Threads::Thread> async_io;
1969 
1970  for (unsigned int blk=0; blk<num_blks; blk++)
1971  {
1972  // Each processor should build up its transfer buffers for its
1973  // local objects in [first_object,last_object).
1974  const dof_id_type
1975  first_object = cast_int<dof_id_type>(blk*io_blksize),
1976  last_object = std::min(cast_int<dof_id_type>((blk+1)*io_blksize), n_objs),
1977  n_objects_blk = last_object - first_object;
1978 
1979  // offset array. this will define where each object's values
1980  // map into the actual output_vals buffer. this must get
1981  // 0-initialized because 0-component objects are not actually sent
1982  obj_val_offsets.resize (n_objects_blk); std::fill (obj_val_offsets.begin(), obj_val_offsets.end(), 0);
1983 
1984  std::size_t n_val_recvd_blk=0;
1985 
1986  // receive this block of data from all processors.
1987  for (processor_id_type comm_step=0, tnp=this->n_processors(); comm_step != tnp; ++comm_step)
1988  {
1989 #ifdef LIBMESH_HAVE_MPI
1990  // blocking receive indices for this block, imposing no particular order on processor
1991  Parallel::Status id_status (this->comm().probe (Parallel::any_source, id_tags[blk]));
1992  std::vector<dof_id_type> & ids (recv_ids[id_status.source()]);
1993  this->comm().receive (id_status.source(), ids, id_tags[blk]);
1994 #else
1995  std::vector<dof_id_type> & ids (recv_ids[0]);
1996  ids = xfer_ids[blk];
1997 #endif
1998 
1999  // note its possible we didn't receive values for objects in
2000  // this block if they have no components allocated.
2001  for (std::size_t idx=0, sz=ids.size(); idx<sz; idx+=2)
2002  {
2003  const dof_id_type
2004  local_idx = ids[idx+0]-first_object,
2005  n_vals_tot_allvecs = ids[idx+1];
2006 
2007  libmesh_assert_less (local_idx, n_objects_blk);
2008  libmesh_assert_less (local_idx, obj_val_offsets.size());
2009 
2010  obj_val_offsets[local_idx] = n_vals_tot_allvecs;
2011  }
2012 
2013 #ifdef LIBMESH_HAVE_MPI
2014  // blocking receive values for this block, imposing no particular order on processor
2015  Parallel::Status val_status (this->comm().probe (Parallel::any_source, val_tags[blk]));
2016  std::vector<Number> & vals (recv_vals[val_status.source()]);
2017  this->comm().receive (val_status.source(), vals, val_tags[blk]);
2018 #else
2019  // straight copy without MPI
2020  std::vector<Number> & vals (recv_vals[0]);
2021  vals = send_vals[blk];
2022 #endif
2023 
2024  n_val_recvd_blk += vals.size();
2025  }
2026 
2027  // We need the offsets into the output_vals vector for each object.
2028  // fortunately, this is simply the partial sum of the total number
2029  // of components for each object
2030  std::partial_sum(obj_val_offsets.begin(), obj_val_offsets.end(),
2031  obj_val_offsets.begin());
2032 
2033  // wait on any previous asynchronous IO - this *must* complete before
2034  // we start messing with the output_vals buffer!
2035  if (async_io.get()) async_io->join();
2036 
2037  // this is the actual output buffer that will be written to disk.
2038  // at ths point we finally know wha size it will be.
2039  output_vals.resize(n_val_recvd_blk);
2040 
2041  // pack data from all processors into output values
2042  for (auto proc : IntRange<unsigned int>(0, this->n_processors()))
2043  {
2044  const std::vector<dof_id_type> & ids (recv_ids [proc]);
2045  const std::vector<Number> & vals(recv_vals[proc]);
2046  std::vector<Number>::const_iterator proc_vals(vals.begin());
2047 
2048  for (std::size_t idx=0, sz=ids.size(); idx<sz; idx+=2)
2049  {
2050  const dof_id_type
2051  local_idx = ids[idx+0]-first_object,
2052  n_vals_tot_allvecs = ids[idx+1];
2053 
2054  // put this object's data into the proper location
2055  // in the output buffer
2056  std::vector<Number>::iterator out_vals(output_vals.begin());
2057  if (local_idx != 0)
2058  std::advance (out_vals, obj_val_offsets[local_idx-1]);
2059 
2060  for (unsigned int val=0; val<n_vals_tot_allvecs; val++, ++out_vals, ++proc_vals)
2061  {
2062  libmesh_assert (out_vals != output_vals.end());
2063  libmesh_assert (proc_vals != vals.end());
2064  *out_vals = *proc_vals;
2065  }
2066  }
2067  }
2068 
2069  // output_vals buffer is now filled for this block.
2070  // write it to disk
2071  async_io = libmesh_make_unique<Threads::Thread>(threaded_io);
2072  written_length += output_vals.size();
2073  }
2074 
2075  // wait on any previous asynchronous IO - this *must* complete before
2076  // our stuff goes out of scope
2077  async_io->join();
2078  }
2079 
2080  Parallel::wait(id_requests);
2081  Parallel::wait(val_requests);
2082 
2083  // we need some synchronization here. Because this method
2084  // can be called for a range of nodes, then a range of elements,
2085  // we need some mechanism to prevent processors from racing past
2086  // to the next range and overtaking ongoing communication. one
2087  // approach would be to figure out unique tags for each range,
2088  // but for now we just impose a barrier here. And might as
2089  // well have it do some useful work.
2090  this->comm().broadcast(written_length);
2091 
2092  return written_length;
2093 }

References libMesh::ParallelObject::comm(), end, libMesh::MeshTools::Generation::Private::idx(), libMesh::invalid_uint, libMesh::libmesh_assert(), libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMesh::System::number(), and libMesh::ParallelObject::processor_id().

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 1703 of file system_io.C.

1705 {
1719  parallel_object_only();
1720  std::string comment;
1721 
1722  // PerfLog pl("IO Performance",false);
1723  // pl.push("write_serialized_data");
1724  // std::size_t total_written_size = 0;
1725 
1726  // total_written_size +=
1727  this->write_serialized_vector(io, *this->solution);
1728 
1729  // set up the comment
1730  if (this->processor_id() == 0)
1731  {
1732  comment = "# System \"";
1733  comment += this->name();
1734  comment += "\" Solution Vector";
1735 
1736  io.comment (comment);
1737  }
1738 
1739  // Only write additional vectors if wanted
1740  if (write_additional_data)
1741  {
1742  for (auto & pair : this->_vectors)
1743  {
1744  // total_written_size +=
1745  this->write_serialized_vector(io, *pair.second);
1746 
1747  // set up the comment
1748  if (this->processor_id() == 0)
1749  {
1750  comment = "# System \"";
1751  comment += this->name();
1752  comment += "\" Additional Vector \"";
1753  comment += pair.first;
1754  comment += "\"";
1755  io.comment (comment);
1756  }
1757  }
1758  }
1759 
1760  // const Real
1761  // dt = pl.get_elapsed_time(),
1762  // rate = total_written_size*sizeof(Number)/dt;
1763 
1764  // libMesh::out << "Write " << total_written_size << " \"Number\" values\n"
1765  // << " Elapsed time = " << dt << '\n'
1766  // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
1767 
1768  // pl.pop("write_serialized_data");
1769 
1770 
1771 
1772 
1773  // // test the new method
1774  // {
1775  // std::vector<std::string> names;
1776  // std::vector<NumericVector<Number> *> vectors_to_write;
1777 
1778  // names.push_back("Solution Vector");
1779  // vectors_to_write.push_back(this->solution.get());
1780 
1781  // // Only write additional vectors if wanted
1782  // if (write_additional_data)
1783  // {
1784  // std::map<std::string, NumericVector<Number> *>::const_iterator
1785  // pos = _vectors.begin();
1786 
1787  // for (; pos != this->_vectors.end(); ++pos)
1788  // {
1789  // names.push_back("Additional Vector " + pos->first);
1790  // vectors_to_write.push_back(pos->second);
1791  // }
1792  // }
1793 
1794  // total_written_size =
1795  // this->write_serialized_vectors (io, names, vectors_to_write);
1796 
1797  // const Real
1798  // dt2 = pl.get_elapsed_time(),
1799  // rate2 = total_written_size*sizeof(Number)/(dt2-dt);
1800 
1801  // libMesh::out << "Write (new) " << total_written_size << " \"Number\" values\n"
1802  // << " Elapsed time = " << (dt2-dt) << '\n'
1803  // << " Rate = " << rate2/1.e6 << "(MB/sec)\n\n";
1804 
1805  // }
1806 }

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::TransientRBConstruction::write_riesz_representors_to_files(), and libMesh::RBConstruction::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 2152 of file system_io.C.

2154 {
2155  parallel_object_only();
2156 
2157  libmesh_assert (io.writing());
2158 
2159  dof_id_type vec_length = vec.size();
2160  if (this->processor_id() == 0) io.data (vec_length, "# vector length");
2161 
2162  dof_id_type written_length = 0;
2163 
2164  //---------------------------------
2165  // Collect the values for all nodes
2166  written_length += cast_int<dof_id_type>
2167  (this->write_serialized_blocked_dof_objects (std::vector<const NumericVector<Number> *>(1,&vec),
2168  this->get_mesh().n_nodes(),
2169  this->get_mesh().local_nodes_begin(),
2170  this->get_mesh().local_nodes_end(),
2171  io));
2172 
2173  //------------------------------------
2174  // Collect the values for all elements
2175  written_length += cast_int<dof_id_type>
2176  (this->write_serialized_blocked_dof_objects (std::vector<const NumericVector<Number> *>(1,&vec),
2177  this->get_mesh().n_elem(),
2178  this->get_mesh().local_elements_begin(),
2179  this->get_mesh().local_elements_end(),
2180  io));
2181 
2182  //-------------------------------------------
2183  // Finally loop over all the SCALAR variables
2184  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
2185  if (this->variable(var).type().family == SCALAR)
2186  {
2187  written_length +=
2188  this->write_SCALAR_dofs (vec, var, io);
2189  }
2190 
2191  if (this->processor_id() == 0)
2192  libmesh_assert_equal_to (written_length, vec_length);
2193 
2194  return written_length;
2195 }

References libMesh::Xdr::data(), libMesh::System::get_mesh(), libMesh::libmesh_assert(), libMesh::MeshTools::n_elem(), n_nodes, libMesh::System::n_vars(), libMesh::ParallelObject::processor_id(), libMesh::SCALAR, libMesh::NumericVector< T >::size(), 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 2293 of file system_io.C.

2295 {
2296  parallel_object_only();
2297 
2298  libmesh_assert (io.writing());
2299 
2300  // Cache these - they are not free!
2301  const dof_id_type
2302  n_nodes = this->get_mesh().n_nodes(),
2303  n_elem = this->get_mesh().n_elem();
2304 
2305  std::size_t written_length = 0;
2306 
2307  if (this->processor_id() == 0)
2308  {
2309  unsigned int
2310  n_vec = cast_int<unsigned int>(vectors.size());
2311  dof_id_type
2312  vec_size = vectors.empty() ? 0 : vectors[0]->size();
2313  // Set the number of vectors
2314  io.data(n_vec, "# number of vectors");
2315  // Set the buffer size
2316  io.data(vec_size, "# vector length");
2317  }
2318 
2319  //---------------------------------
2320  // Collect the values for all nodes
2321  written_length +=
2322  this->write_serialized_blocked_dof_objects (vectors,
2323  n_nodes,
2324  this->get_mesh().local_nodes_begin(),
2325  this->get_mesh().local_nodes_end(),
2326  io);
2327 
2328  //------------------------------------
2329  // Collect the values for all elements
2330  written_length +=
2331  this->write_serialized_blocked_dof_objects (vectors,
2332  n_elem,
2333  this->get_mesh().local_elements_begin(),
2334  this->get_mesh().local_elements_end(),
2335  io);
2336 
2337  //-------------------------------------------
2338  // Finally loop over all the SCALAR variables
2339  for (const NumericVector<Number> * vec : vectors)
2340  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
2341  if (this->variable(var).type().family == SCALAR)
2342  {
2343  libmesh_assert_not_equal_to (vec, 0);
2344 
2345  written_length +=
2346  this->write_SCALAR_dofs (*vec, var, io);
2347  }
2348 
2349  return written_length;
2350 }

References libMesh::Xdr::data(), libMesh::System::get_mesh(), libMesh::libmesh_assert(), libMesh::MeshBase::n_elem(), libMesh::MeshTools::n_elem(), n_nodes, libMesh::MeshBase::n_nodes(), libMesh::System::n_vars(), libMesh::ParallelObject::processor_id(), libMesh::SCALAR, 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 1300 of file system.C.

1302 {
1303  /* Make sure the call makes sense. */
1304  libmesh_assert_less (var_num, this->n_vars());
1305 
1306  /* Get a reference to the mesh. */
1307  const MeshBase & mesh = this->get_mesh();
1308 
1309  /* Check which system we are. */
1310  const unsigned int sys_num = this->number();
1311 
1312  // Loop over nodes.
1313  for (const auto & node : mesh.local_node_ptr_range())
1314  {
1315  unsigned int n_comp = node->n_comp(sys_num,var_num);
1316  for (unsigned int i=0; i<n_comp; i++)
1317  {
1318  const dof_id_type index = node->dof_number(sys_num,var_num,i);
1319  v.set(index,0.0);
1320  }
1321  }
1322 
1323  // Loop over elements.
1324  for (const auto & elem : mesh.active_local_element_ptr_range())
1325  {
1326  unsigned int n_comp = elem->n_comp(sys_num,var_num);
1327  for (unsigned int i=0; i<n_comp; i++)
1328  {
1329  const dof_id_type index = elem->dof_number(sys_num,var_num,i);
1330  v.set(index,0.0);
1331  }
1332  }
1333 }

References libMesh::System::get_mesh(), mesh, libMesh::System::n_vars(), libMesh::System::number(), 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 1977 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 2034 of file system.h.

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

◆ _assemble_system_function

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

◆ _assemble_system_object

Assembly* libMesh::System::_assemble_system_object
privateinherited

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

Referenced by libMesh::System::init(), and libMesh::System::set_basic_system_only().

◆ _can_add_matrices

bool libMesh::ImplicitSystem::_can_add_matrices
privateinherited

true when additional matrices may still be added, false otherwise.

Definition at line 431 of file implicit_system.h.

Referenced by libMesh::ImplicitSystem::add_matrix(), libMesh::ImplicitSystem::clear(), and libMesh::ImplicitSystem::init_matrices().

◆ _communicator

const Parallel::Communicator& libMesh::ParallelObject::_communicator
protectedinherited

◆ _constrain_system_function

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

◆ _constrain_system_object

Constraint* libMesh::System::_constrain_system_object
privateinherited

◆ _counts

ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited

◆ _diff_physics

DifferentiablePhysics* libMesh::DifferentiableSystem::_diff_physics
protectedinherited

Pointer to object to use for physics assembly evaluations.

Defaults to this for backwards compatibility; in the future users should create separate physics objects.

Definition at line 370 of file diff_system.h.

Referenced by libMesh::DifferentiableSystem::attach_physics(), libMesh::DifferentiableSystem::clear(), libMesh::DifferentiableSystem::get_physics(), libMesh::DifferentiableSystem::init_data(), libMesh::DifferentiableSystem::swap_physics(), and libMesh::DifferentiableSystem::~DifferentiableSystem().

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

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

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

◆ _identify_variable_groups

bool libMesh::System::_identify_variable_groups
privateinherited

true when VariableGroup structures should be automatically identified, false otherwise.

Defaults to true.

Definition at line 2027 of file system.h.

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

◆ _init_system_function

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

◆ _init_system_object

Initialization* libMesh::System::_init_system_object
privateinherited

◆ _is_initialized

bool libMesh::System::_is_initialized
privateinherited

true when additional vectors and variables do not require immediate initialization, false otherwise.

Definition at line 2021 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, SparseMatrix<Number> *> libMesh::ImplicitSystem::_matrices
privateinherited

◆ _mesh

MeshBase& libMesh::System::_mesh
privateinherited

Constant reference to the mesh data structure used for the simulation.

Definition at line 1946 of file system.h.

Referenced by libMesh::System::calculate_norm(), 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 135 of file reference_counter.h.

◆ _n_objects

Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects
staticprotectedinherited

The number of objects.

Print the reference count information when the number returns to 0.

Definition at line 130 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().

◆ _numerical_jacobian_h_for_var

std::vector<Real> libMesh::FEMSystem::_numerical_jacobian_h_for_var
privateinherited

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

Referenced by libMesh::System::attach_QOI_derivative(), libMesh::System::attach_QOI_derivative_object(), libMesh::System::user_QOI_derivative(), and libMesh::System::~System().

◆ _qoi_evaluate_derivative_object

QOIDerivative* libMesh::System::_qoi_evaluate_derivative_object
privateinherited

Object to compute derivatives of quantities of interest.

Definition at line 1928 of file system.h.

Referenced by libMesh::System::attach_QOI_derivative(), libMesh::System::attach_QOI_derivative_object(), libMesh::System::user_QOI_derivative(), and libMesh::System::~System().

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

Referenced by libMesh::System::attach_QOI_function(), libMesh::System::attach_QOI_object(), libMesh::System::user_QOI(), and libMesh::System::~System().

◆ _qoi_evaluate_object

QOI* libMesh::System::_qoi_evaluate_object
privateinherited

Object to compute quantities of interest.

Definition at line 1914 of file system.h.

Referenced by libMesh::System::attach_QOI_function(), libMesh::System::attach_QOI_object(), libMesh::System::user_QOI(), and libMesh::System::~System().

◆ _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 572 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 2009 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 1951 of file system.h.

Referenced by 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 1956 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 555 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().

◆ _u_var

unsigned int FirstOrderScalarSystemBase::_u_var
protectedinherited

Definition at line 172 of file time_solver_test_common.h.

◆ _variable_groups

std::vector<VariableGroup> libMesh::System::_variable_groups
privateinherited

◆ _variable_numbers

std::map<std::string, unsigned short int> libMesh::System::_variable_numbers
privateinherited

The variable numbers corresponding to user-specified names, useful for name-based lookups.

Definition at line 1972 of file system.h.

Referenced by libMesh::System::add_variable(), libMesh::System::add_variables(), libMesh::System::clear(), libMesh::System::get_all_variable_numbers(), libMesh::System::has_variable(), and libMesh::System::variable_number().

◆ _variables

std::vector<Variable> libMesh::System::_variables
privateinherited

◆ _vector_is_adjoint

std::map<std::string, int> 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 1997 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> 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 1991 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(), and libMesh::System::vector_preservation().

◆ _vector_types

std::map<std::string, ParallelType> libMesh::System::_vector_types
privateinherited

◆ _vectors

std::map<std::string, NumericVector<Number> * > 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 2046 of file system.h.

Referenced by libMesh::System::read_header(), libMesh::System::read_legacy_data(), 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 2053 of file system.h.

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

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

Referenced by libMesh::ImplicitSystem::adjoint_solve(), libMesh::ImplicitSystem::disable_cache(), libMesh::System::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 154 of file diff_physics.h.

◆ current_local_solution

std::unique_ptr<NumericVector<Number> > libMesh::System::current_local_solution
inherited

All the values I need to compute my contribution to the simulation at hand.

Think of this as the current solution with any ghost values needed from other processors. This vector is necessarily larger than the solution vector in the case of a parallel simulation. The update() member is used to synchronize the contents of the solution and current_local_solution vectors.

Definition at line 1551 of file system.h.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::NonlinearImplicitSystem::assembly(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::System::clear(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::System::current_solution(), DMlibMeshFunction(), DMlibMeshJacobian(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::System::init_data(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_residual(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), 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(), FETest< order, family, elem_type >::testGradU(), FETest< order, family, elem_type >::testGradUComp(), FETest< order, family, elem_type >::testU(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::TransientRBConstruction::truth_solve(), libMesh::System::update(), and libMesh::Nemesis_IO_Helper::write_nodal_solution().

◆ deltat

Real libMesh::DifferentiableSystem::deltat
inherited

◆ diff_qoi

DifferentiableQoI* libMesh::DifferentiableSystem::diff_qoi
protectedinherited

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 377 of file diff_system.h.

Referenced by libMesh::FEMSystem::assemble_qoi(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::DifferentiableSystem::attach_qoi(), libMesh::DifferentiableSystem::clear(), libMesh::DifferentiableSystem::get_qoi(), and libMesh::DifferentiableSystem::~DifferentiableSystem().

◆ 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 1524 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 170 of file fem_system.h.

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

Definition at line 393 of file implicit_system.h.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), add_M_C_K_helmholtz(), libMesh::ImplicitSystem::add_system_matrix(), libMesh::ImplicitSystem::adjoint_solve(), assemble(), libMesh::ImplicitSystem::assemble(), LinearElasticity::assemble(), assemble_1D(), assemble_biharmonic(), assemble_elasticity(), assemble_ellipticdg(), assemble_helmholtz(), assemble_laplace(), assemble_matrix_and_rhs(), assemble_poisson(), assemble_shell(), assemble_stokes(), assemble_wave(), libMesh::FEMSystem::assembly(), libMesh::LinearImplicitSystem::assembly(), libMesh::NonlinearImplicitSystem::assembly(), assembly_with_dg_fem_context(), libMesh::NewmarkSystem::compute_matrix(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::ContinuationSystem::continuation_solve(), DMlibMeshJacobian(), libMesh::RBConstruction::enrich_basis_from_rhs_terms(), fill_dirichlet_bc(), libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity(), libMesh::ImplicitSystem::init_matrices(), main(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::NoxNonlinearSolver< Number >::solve(), libMesh::EigenTimeSolver::solve(), libMesh::FrequencySystem::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::NonlinearImplicitSystem::solve(), libMesh::ContinuationSystem::solve_tangent(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::truth_solve(), libMesh::RBConstruction::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 181 of file fem_system.h.

Referenced by libMesh::FEMSystem::numerical_jacobian(), libMesh::FEMSystem::numerical_jacobian_h_for_var(), and set_system_parameters().

◆ 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 314 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 361 of file diff_system.h.

Referenced by CurlCurlSystem::init_data(), 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 356 of file diff_system.h.

Referenced by 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 351 of file diff_system.h.

◆ 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 341 of file diff_system.h.

Referenced by libMesh::FEMSystem::assembly(), 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 346 of file diff_system.h.

Referenced by libMesh::FEMSystem::assembly(), CurlCurlSystem::init_data(), 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 331 of file diff_system.h.

Referenced by libMesh::FEMSystem::assembly(), 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 336 of file diff_system.h.

Referenced by libMesh::FEMSystem::assembly(), 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 320 of file diff_system.h.

Referenced by libMesh::FEMSystem::assembly(), 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 326 of file diff_system.h.

Referenced by libMesh::FEMSystem::assembly(), and set_system_parameters().

◆ qoi

std::vector<Number> libMesh::System::qoi
inherited

◆ 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 114 of file explicit_system.h.

Referenced by libMesh::__libmesh_petsc_diff_solver_residual(), add_M_C_K_helmholtz(), libMesh::ExplicitSystem::add_system_rhs(), assemble(), libMesh::ImplicitSystem::assemble(), LinearElasticity::assemble(), assemble_1D(), assemble_biharmonic(), assemble_elasticity(), assemble_ellipticdg(), assemble_laplace(), assemble_matrix_and_rhs(), assemble_poisson(), libMesh::ImplicitSystem::assemble_residual_derivatives(), assemble_shell(), assemble_stokes(), assemble_wave(), libMesh::FEMSystem::assembly(), libMesh::LinearImplicitSystem::assembly(), libMesh::NonlinearImplicitSystem::assembly(), assembly_with_dg_fem_context(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::Problem_Interface::computeF(), 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(), HeatSystem::perturb_accumulate_residuals(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::FrequencySystem::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::NonlinearImplicitSystem::solve(), libMesh::ContinuationSystem::solve_tangent(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::truth_solve(), libMesh::RBEIMConstruction::truth_solve(), libMesh::RBConstruction::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 1539 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::NewmarkSolver::advance_timestep(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::ContinuationSystem::apply_predictor(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::FEMSystem::assembly(), libMesh::LinearImplicitSystem::assembly(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::System::clear(), libMesh::System::compare(), libMesh::RBEIMConstruction::compute_best_fit_error(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::NewmarkSolver::compute_initial_accel(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ContinuationSystem::continuation_solve(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), DMCreateGlobalVector_libMesh(), DMlibMeshFunction(), DMlibMeshJacobian(), libMesh::UnsteadySolver::du(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::RBConstruction::enrich_RB_space(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::RBSCMConstruction::evaluate_stability_constant(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::EigenSystem::get_eigenpair(), LinearElasticityWithContact::get_least_and_max_gap_function(), libMesh::System::init_data(), libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set(), libMesh::ContinuationSystem::initialize_tangent(), libMesh::TransientRBConstruction::initialize_truth(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::RBEIMConstruction::load_basis_function(), libMesh::RBConstruction::load_basis_function(), libMesh::RBEIMConstruction::load_rb_solution(), 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::RBEIMConstruction::plot_parametrized_functions_in_training_set(), libMesh::RBConstruction::print_basis_function_orthogonality(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), libMesh::System::re_update(), libMesh::System::read_legacy_data(), libMesh::System::read_parallel_data(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::System::read_serialized_data(), libMesh::System::reinit(), libMesh::System::restrict_vectors(), libMesh::MemorySolutionHistory::retrieve(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), libMesh::ContinuationSystem::save_current_solution(), libMesh::TransientRBConstruction::set_error_temporal_data(), setup(), libMesh::TwostepTimeSolver::solve(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::FrequencySystem::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::NonlinearImplicitSystem::solve(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), libMesh::ContinuationSystem::solve_tangent(), libMesh::MemorySolutionHistory::store(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), SystemsTest::testBoundaryProjectCube(), SystemsTest::testDofCouplingWithVarGroups(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), SystemsTest::testProjectCubeWithMeshFunction(), WriteVecAndScalar::testWrite(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::DirectSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::BoundaryVolumeSolutionTransfer::transfer_volume_boundary(), libMesh::TransientRBConstruction::truth_solve(), libMesh::RBEIMConstruction::truth_solve(), libMesh::RBConstruction::truth_solve(), libMesh::System::update(), libMesh::System::update_global_solution(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::RBEIMConstruction::update_RB_system_matrices(), 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::TransientRBConstruction::write_riesz_representors_to_files(), libMesh::RBConstruction::write_riesz_representors_to_files(), and libMesh::System::write_serialized_data().

◆ time

Real libMesh::System::time
inherited

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

Referenced by libMesh::EulerSolver::_general_residual(), libMesh::Euler2Solver::_general_residual(), libMesh::SteadySolver::_general_residual(), libMesh::NewmarkSolver::_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 209 of file fem_system.h.

Referenced by libMesh::FEMSystem::assembly(), CurlCurlSystem::init_data(), 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 400 of file implicit_system.h.

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


The documentation for this class was generated from the following file:
libMesh::DifferentiablePhysics::_first_order_vars
std::set< unsigned int > _first_order_vars
Variable indices for those variables that are first order in time.
Definition: diff_physics.h:560
libMesh::LinearSolver::reuse_preconditioner
virtual void reuse_preconditioner(bool)
Set the same_preconditioner flag, which indicates if we reuse the same preconditioner for subsequent ...
Definition: linear_solver.C:129
libMesh::DISCRETE_L_INF
Definition: enum_norm_type.h:54
libMesh::ImplicitSystem::assemble_residual_derivatives
virtual void assemble_residual_derivatives(const ParameterVector &parameters) override
Residual parameter derivative function.
Definition: implicit_system.C:643
libMesh::DifferentiableSystem::swap_physics
void swap_physics(DifferentiablePhysics *&swap_physics)
Swap current physics object with external object.
Definition: diff_system.C:353
libMesh::SparseMatrix::close
virtual void close()=0
Calls the SparseMatrix's internal assembly routines, ensuring that the values are consistent across p...
libMesh::System::write_serialized_vector
dof_id_type write_serialized_vector(Xdr &io, const NumericVector< Number > &vec) const
Writes a vector for this System.
Definition: system_io.C:2152
libMesh::ImplicitSystem::request_matrix
const SparseMatrix< Number > * request_matrix(const std::string &mat_name) const
Definition: implicit_system.C:236
libMesh::DifferentiableSystem::deltat
Real deltat
For time-dependent problems, this is the amount delta t to advance the solution in time.
Definition: diff_system.h:260
libMesh::System::_vector_projections
std::map< std::string, bool > _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:1991
libMesh::NumericVector::zero
virtual void zero()=0
Set all entries to zero.
libMesh::dof_id_type
uint8_t dof_id_type
Definition: id_types.h:67
libMesh::Number
Real Number
Definition: libmesh_common.h:195
libMesh::DiffContext::get_elem_residual
const DenseVector< Number > & get_elem_residual() const
Const accessor for element residual.
Definition: diff_context.h:249
libMesh::System::boundary_project_solution
void boundary_project_solution(const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr)
Projects arbitrary boundary functions onto a vector of degree of freedom values for the current syste...
Definition: system_projection.C:1126
libMesh::FEMContext::get_element_qrule
const QBase & get_element_qrule() const
Accessor for element interior quadrature rule for the dimension of the current _elem.
Definition: fem_context.h:790
libMesh::System::n_vars
unsigned int n_vars() const
Definition: system.h:2155
libMesh::System::have_vector
bool have_vector(const std::string &vec_name) const
Definition: system.h:2275
libMesh::FEMContext::elem_position_get
void elem_position_get()
Uses the geometry of elem to set the coordinate data specified by mesh_*_position configuration.
Definition: fem_context.C:1485
libMesh::System::get_equation_systems
const EquationSystems & get_equation_systems() const
Definition: system.h:720
libMesh::OrderWrapper::get_order
int get_order() const
Explicitly request the order as an int.
Definition: fe_type.h:77
libMesh::invalid_uint
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value.
Definition: libmesh.h:249
libMesh::DifferentiablePhysics::_mesh_x_var
unsigned int _mesh_x_var
Variables from which to acquire moving mesh information.
Definition: diff_physics.h:548
libMesh::System::project_vector
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
Projects arbitrary functions onto a vector of degree of freedom values for the current system.
Definition: system_projection.C:991
libMesh::FEMSystem::init_context
virtual void init_context(DiffContext &) override
Definition: fem_system.C:1338
libMesh::System::get_sensitivity_rhs
NumericVector< Number > & get_sensitivity_rhs(unsigned int i=0)
Definition: system.C:1049
libMesh::DifferentiableSystem::print_jacobian_norms
bool print_jacobian_norms
Set print_jacobian_norms to true to print |J| whenever it is assembled.
Definition: diff_system.h:341
libMesh::System::is_initialized
bool is_initialized()
Definition: system.h:2139
libMesh::DifferentiablePhysics::time_evolving
virtual void time_evolving(unsigned int var)
Tells the DiffSystem that variable var is evolving with respect to time.
Definition: diff_physics.h:250
libMesh::System::_is_initialized
bool _is_initialized
true when additional vectors and variables do not require immediate initialization,...
Definition: system.h:2021
libMesh::MeshTools::n_elem
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).
Definition: mesh_tools.C:705
libMesh::DofMap::prepare_send_list
void prepare_send_list()
Takes the _send_list vector (which may have duplicate entries) and sorts it.
Definition: dof_map.C:1651
libMesh::System::_variable_groups
std::vector< VariableGroup > _variable_groups
The VariableGroup in this System.
Definition: system.h:1966
libMesh::System::vectors_iterator
std::map< std::string, NumericVector< Number > * >::iterator vectors_iterator
Vector iterator typedefs.
Definition: system.h:756
libMesh::System::_constrain_system_function
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Function to impose constraints.
Definition: system.h:1896
libMesh::FEType::family
FEFamily family
The type of finite element.
Definition: fe_type.h:203
libMesh::ExplicitSystem::rhs
NumericVector< Number > * rhs
The system matrix.
Definition: explicit_system.h:114
libMesh::System::boundary_project_vector
void boundary_project_vector(const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
Projects arbitrary boundary functions onto a vector of degree of freedom values for the current syste...
Definition: system_projection.C:1162
libMesh::DifferentiableSystem::print_residual_norms
bool print_residual_norms
Set print_residual_norms to true to print |F| whenever it is assembled.
Definition: diff_system.h:331
libMesh::DofMap::get_dirichlet_boundaries
const DirichletBoundaries * get_dirichlet_boundaries() const
Definition: dof_map.h:1333
libMesh::DofMap::dof_indices
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Fills the vector di with the global degree of freedom indices for the element.
Definition: dof_map.C:1967
libMesh::ImplicitSystem::get_linear_solve_parameters
virtual std::pair< unsigned int, Real > get_linear_solve_parameters() const
Definition: implicit_system.C:1410
libMesh::DiffContext::get_dof_indices
const std::vector< dof_id_type > & get_dof_indices() const
Accessor for element dof indices.
Definition: diff_context.h:367
libMesh::L_INF
Definition: enum_norm_type.h:42
libMesh::PARALLEL
Definition: enum_parallel_type.h:36
libMesh::DofMap::add_dirichlet_boundary
void add_dirichlet_boundary(const DirichletBoundary &dirichlet_boundary)
Adds a copy of the specified Dirichlet boundary to the system.
Definition: dof_map_constraints.C:4390
libMesh::System::_dof_map
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:1934
FirstOrderScalarSystemBase::F
virtual Number F(FEMContext &context, unsigned int qp)=0
Value of F(u)
libMesh::System::add_variables
unsigned int add_variables(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
Definition: system.C:1160
libMesh::ImplicitSystem::adjoint_solve
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...
Definition: implicit_system.C:359
libMesh::DifferentiablePhysics
This class provides a specific system class.
Definition: diff_physics.h:76
libMesh::QoISet::has_index
bool has_index(std::size_t) const
Return whether or not this index is in the set to be calculated.
Definition: qoi_set.h:221
libMesh::NumericVector::subset_linfty_norm
virtual Real subset_linfty_norm(const std::set< numeric_index_type > &indices) const
Definition: numeric_vector.C:342
libMesh::libmesh_real
T libmesh_real(T a)
Definition: libmesh_common.h:166
libMesh::MeshBase::active_local_element_ptr_range
virtual SimpleRange< element_iterator > active_local_element_ptr_range()=0
libMesh::System::_assemble_system_function
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Function that assembles the system.
Definition: system.h:1885
libMesh::MeshBase::active_local_elements_begin
virtual element_iterator active_local_elements_begin()=0
libMesh::DenseSubMatrix
Defines a dense submatrix for use in Finite Element-type computations.
Definition: dense_submatrix.h:45
libMesh::TYPE_SCALAR
Definition: enum_fe_family.h:93
libMesh::DofMap::has_adjoint_dirichlet_boundaries
bool has_adjoint_dirichlet_boundaries(unsigned int q) const
Definition: dof_map_constraints.C:4409
libMesh::DifferentiablePhysics::is_time_evolving
bool is_time_evolving(unsigned int var) const
Definition: diff_physics.h:278
libMesh::DofMap::get_info
std::string get_info() const
Gets summary info about the sparsity bandwidth and constraints.
Definition: dof_map.C:2843
libMesh::System::_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:2059
libMesh::DifferentiableSystem::print_residuals
bool print_residuals
Set print_residuals to true to print F whenever it is assembled.
Definition: diff_system.h:336
libMesh::QBase::n_points
unsigned int n_points() const
Definition: quadrature.h:126
libMesh::DISCRETE_L2
Definition: enum_norm_type.h:53
FirstOrderScalarSystemBase::FirstOrderScalarSystemBase
FirstOrderScalarSystemBase(EquationSystems &es, const std::string &name_in, const unsigned int number_in)
Definition: time_solver_test_common.h:94
libMesh::MeshBase::n_elem
virtual dof_id_type n_elem() const =0
libMesh::System::get_adjoint_solution
NumericVector< Number > & get_adjoint_solution(unsigned int i=0)
Definition: system.C:957
libMesh::System::system_type
virtual std::string system_type() const
Definition: system.h:495
libMesh::System::_vectors
std::map< std::string, NumericVector< Number > * > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:1985
libMesh::System::get_weighted_sensitivity_adjoint_solution
NumericVector< Number > & get_weighted_sensitivity_adjoint_solution(unsigned int i=0)
Definition: system.C:989
libMesh::System::_vector_types
std::map< std::string, ParallelType > _vector_types
Holds the type of a vector.
Definition: system.h:2002
libMesh::SparseMatrix::vector_mult
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.
Definition: sparse_matrix.C:170
libMesh::System::variable_name
const std::string & variable_name(const unsigned int i) const
Definition: system.h:2203
libMesh::System::read_serialized_blocked_dof_objects
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:810
libMesh::SERIAL
Definition: enum_parallel_type.h:35
libMesh::index_range
IntRange< std::size_t > index_range(const std::vector< T > &vec)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:106
libMesh::RealGradient
RealVectorValue RealGradient
Definition: hp_coarsentest.h:49
libMesh::ImplicitSystem::reinit
virtual void reinit() override
Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be use...
Definition: implicit_system.C:149
libMesh::DiffContext::n_vars
unsigned int n_vars() const
Number of variables in solution.
Definition: diff_context.h:99
libMesh::DenseVector::zero
virtual void zero() override
Set every element in the vector to 0.
Definition: dense_vector.h:379
libMesh::L1
Definition: enum_norm_type.h:41
libMesh::System::n_vectors
unsigned int n_vectors() const
Definition: system.h:2283
libMesh::XYZ
Definition: enum_fe_family.h:46
libMesh::DenseMatrix::add
boostcopy::enable_if_c< ScalarTraits< T2 >::value, void >::type add(const T2 factor, const DenseMatrix< T3 > &mat)
Adds factor times mat to this matrix.
Definition: dense_matrix.h:945
libMesh::System::add_sensitivity_solution
NumericVector< Number > & add_sensitivity_solution(unsigned int i=0)
Definition: system.C:894
libMesh::FEMContext::pre_fe_reinit
virtual void pre_fe_reinit(const System &, const Elem *e)
Reinitializes local data vectors/matrices on the current geometric element.
Definition: fem_context.C:1642
libMesh::System::restrict_vectors
virtual void restrict_vectors()
Restrict vectors after the mesh has coarsened.
Definition: system.C:324
libMesh::NumericVector::close
virtual void close()=0
Calls the NumericVector's internal assembly routines, ensuring that the values are consistent across ...
libMesh::DiffContext::is_adjoint
bool is_adjoint() const
Accessor for querying whether we need to do a primal or adjoint solve.
Definition: diff_context.h:470
libMesh::FEGenericBase
This class forms the foundation from which generic finite elements may be derived.
Definition: exact_error_estimator.h:39
libMesh::SparseMatrix::initialized
virtual bool initialized() const
Definition: sparse_matrix.h:103
libMesh::H1_SEMINORM
Definition: enum_norm_type.h:43
libMesh::ImplicitSystem::add_matrix
SparseMatrix< Number > & add_matrix(const std::string &mat_name)
Adds the additional matrix mat_name to this system.
Definition: implicit_system.C:202
libMesh::System::identify_variable_groups
bool identify_variable_groups() const
Definition: system.h:2251
libMesh::System::_identify_variable_groups
bool _identify_variable_groups
true when VariableGroup structures should be automatically identified, false otherwise.
Definition: system.h:2027
libMesh::NumericVector::init
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.
libMesh::FEAbstract::get_JxW
const std::vector< Real > & get_JxW() const
Definition: fe_abstract.h:244
end
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end.
Definition: variant_filter_iterator.h:343
libMesh::ReferenceCounter::_counts
static Counts _counts
Actually holds the data.
Definition: reference_counter.h:122
std::sqrt
MetaPhysicL::DualNumber< T, D > sqrt(const MetaPhysicL::DualNumber< T, D > &in)
libMesh::FEMContext::get_elem
const Elem & get_elem() const
Accessor for current Elem object.
Definition: fem_context.h:896
libMesh::TOLERANCE
static const Real TOLERANCE
Definition: libmesh_common.h:128
libMesh::ImplicitSystem::_matrices
std::map< std::string, SparseMatrix< Number > * > _matrices
Some systems need an arbitrary number of matrices.
Definition: implicit_system.h:426
libMesh::System::_active
bool _active
Flag stating if the system is active or not.
Definition: system.h:1977
libMesh::ParallelObject::comm
const Parallel::Communicator & comm() const
Definition: parallel_object.h:94
libMesh::DenseMatrix< Number >
libMesh::System::get_adjoint_rhs
NumericVector< Number > & get_adjoint_rhs(unsigned int i=0)
Definition: system.C:1019
libMesh::DifferentiableSystem::print_solution_norms
bool print_solution_norms
Set print_residual_norms to true to print |U| whenever it is used in an assembly() call.
Definition: diff_system.h:320
libMesh::GHOSTED
Definition: enum_parallel_type.h:37
libMesh::NumericVector::clone
virtual std::unique_ptr< NumericVector< T > > clone() const =0
libMesh::DofMap::process_constraints
void process_constraints(MeshBase &)
Postprocesses any constrained degrees of freedom to be constrained only in terms of unconstrained dof...
Definition: dof_map_constraints.C:3334
libMesh::DifferentiableQoI::clear_qoi
virtual void clear_qoi()
Clear all the data structures associated with the QoI.
Definition: diff_qoi.h:77
libMesh::System::number
unsigned int number() const
Definition: system.h:2075
libMesh::ReferenceCounter::_n_objects
static Threads::atomic< unsigned int > _n_objects
The number of objects.
Definition: reference_counter.h:130
libMesh::Variable::type
const FEType & type() const
Definition: variable.h:119
libMesh::W2_INF_SEMINORM
Definition: enum_norm_type.h:50
libMesh::H2
Definition: enum_norm_type.h:38
libMesh::FEMFunctionBase::component
virtual Output component(const FEMContext &, unsigned int i, const Point &p, Real time=0.)
Definition: fem_function_base.h:132
mesh
MeshBase & mesh
Definition: mesh_communication.C:1257
libMesh::DifferentiablePhysics::_mesh_sys
System * _mesh_sys
System from which to acquire moving mesh information.
Definition: diff_physics.h:543
libMesh::MeshBase::mesh_dimension
unsigned int mesh_dimension() const
Definition: mesh_base.C:135
libMesh::ImplicitSystem::get_linear_solver
virtual LinearSolver< Number > * get_linear_solver() const
Definition: implicit_system.C:1384
libMesh::DifferentiablePhysics::_second_order_dot_vars
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...
Definition: diff_physics.h:572
FirstOrderScalarSystemBase::M
virtual Number M(FEMContext &context, unsigned int qp)=0
Value of M(u).
libMesh::W1_INF_SEMINORM
Definition: enum_norm_type.h:49
libMesh::DofMap::first_dof
dof_id_type first_dof(const processor_id_type proc) const
Definition: dof_map.h:650
libMesh::System::read_SCALAR_dofs
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:1120
libMesh::System::variable
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2183
libMesh::DifferentiablePhysics::_second_order_vars
std::set< unsigned int > _second_order_vars
Variable indices for those variables that are second order in time.
Definition: diff_physics.h:565
libMesh::System::use_fixed_solution
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:1509
libMesh::Variable::active_subdomains
const std::set< subdomain_id_type > & active_subdomains() const
Definition: variable.h:150
libMesh::ReferenceCounter::get_info
static std::string get_info()
Gets a string containing the reference information.
Definition: reference_counter.C:47
libMesh::System::local_dof_indices
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:1259
libMesh::System::n_matrices
virtual unsigned int n_matrices() const
Definition: system.h:2289
libMesh::System::is_adjoint_already_solved
bool is_adjoint_already_solved() const
Accessor for the adjoint_already_solved boolean.
Definition: system.h:396
libMesh::DifferentiablePhysics::get_mesh_system
const System * get_mesh_system() const
Definition: diff_physics.h:625
libMesh::System::QOI::qoi
virtual void qoi(const QoISet &qoi_indices)=0
Quantity of interest function.
dim
unsigned int dim
Definition: adaptivity_ex3.C:113
libMesh::Elem::point
const Point & point(const unsigned int i) const
Definition: elem.h:1955
libMesh::NumericVector::build
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
Definition: numeric_vector.C:49
libMesh::ImplicitSystem::const_matrices_iterator
std::map< std::string, SparseMatrix< Number > * >::const_iterator const_matrices_iterator
Definition: implicit_system.h:307
libMesh::System::_init_system_function
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Function that initializes the system.
Definition: system.h:1874
libMesh::TimeSolver::element_residual
virtual bool element_residual(bool request_jacobian, DiffContext &)=0
This method uses the DifferentiablePhysics element_time_derivative(), element_constraint(),...
libMesh::System::_qoi_evaluate_function
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Function to evaluate quantity of interest.
Definition: system.h:1907
libMesh::System::get_weighted_sensitivity_solution
NumericVector< Number > & get_weighted_sensitivity_solution()
Definition: system.C:931
libMesh::NumericVector::size
virtual numeric_index_type size() const =0
libMesh::System::vector_is_adjoint
int vector_is_adjoint(const std::string &vec_name) const
Definition: system.C:884
libMesh::System::QOIDerivative::qoi_derivative
virtual void qoi_derivative(const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)=0
Quantity of interest derivative function.
libMesh::DifferentiableSystem::time_solver
std::unique_ptr< TimeSolver > time_solver
A pointer to the solver object we're going to use.
Definition: diff_system.h:233
libMesh::zero
const Number zero
.
Definition: libmesh.h:243
libMesh::System::n_qois
unsigned int n_qois() const
Number of currently active quantities of interest.
Definition: system.h:2328
libMesh::DofMap::enforce_adjoint_constraints_exactly
void enforce_adjoint_constraints_exactly(NumericVector< Number > &v, unsigned int q) const
Heterogenously constrains the numeric vector v, which represents an adjoint solution defined on the m...
Definition: dof_map.h:2058
libMesh::System::n_components
unsigned int n_components() const
Definition: system.h:2171
libMesh::System::_basic_system_only
bool _basic_system_only
Holds true if the components of more advanced system types (e.g.
Definition: system.h:2015
libMesh::System::assemble_before_solve
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:1493
libMesh::FEMSystem::numerical_jacobian_h
Real numerical_jacobian_h
If calculating numeric jacobians is required, the FEMSystem will perturb each solution vector entry b...
Definition: fem_system.h:181
libMesh::ImplicitSystem::weighted_sensitivity_solve
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...
Definition: implicit_system.C:560
libMesh::System::add_adjoint_rhs
NumericVector< Number > & add_adjoint_rhs(unsigned int i=0)
Definition: system.C:1009
libMesh::System::_init_system_object
Initialization * _init_system_object
Object that initializes the system.
Definition: system.h:1880
libMesh::libmesh_assert
libmesh_assert(ctx)
libMesh::FEMContext::interior_rate
void interior_rate(unsigned int var, unsigned int qp, OutputType &u) const
Definition: fem_context.C:1318
libMesh::DifferentiablePhysics::_mesh_y_var
unsigned int _mesh_y_var
Definition: diff_physics.h:548
libMesh::IntRange
The IntRange templated class is intended to make it easy to loop over integers which are indices of a...
Definition: int_range.h:53
libMesh::FEMNormType
FEMNormType
Definition: enum_norm_type.h:34
libMesh::FEMSystem::numerical_jacobian
void numerical_jacobian(TimeSolverResPtr res, FEMContext &context) const
Uses the results of multiple res calls to numerically differentiate the corresponding jacobian.
Definition: fem_system.C:1178
libMesh::System::n_variable_groups
unsigned int n_variable_groups() const
Definition: system.h:2163
libMesh::TimeSolver::nonlocal_residual
virtual bool nonlocal_residual(bool request_jacobian, DiffContext &)=0
This method uses the DifferentiablePhysics nonlocal_time_derivative(), nonlocal_constraint(),...
libMesh::DifferentiableSystem::_diff_physics
DifferentiablePhysics * _diff_physics
Pointer to object to use for physics assembly evaluations.
Definition: diff_system.h:370
libMesh::MeshBase
This is the MeshBase class.
Definition: mesh_base.h:78
libMesh::Threads::Thread
NonConcurrentThread Thread
Use the non-concurrent placeholder.
Definition: threads_none.h:43
std::abs
MetaPhysicL::DualNumber< T, D > abs(const MetaPhysicL::DualNumber< T, D > &in)
libMesh::Threads::parallel_for
void parallel_for(const Range &range, const Body &body)
Execute the provided function object in parallel on the specified range.
Definition: threads_none.h:73
libMesh::System::vectors_end
vectors_iterator vectors_end()
End of vectors container.
Definition: system.h:2307
libMesh::NumericVector::localize
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.
libMesh::NumericVector::subset_l2_norm
virtual Real subset_l2_norm(const std::set< numeric_index_type > &indices) const
Definition: numeric_vector.C:327
libMesh::DifferentiablePhysics::get_second_order_vars
const std::set< unsigned int > & get_second_order_vars() const
Definition: diff_physics.h:531
libMesh::System::qoi
std::vector< Number > qoi
Values of the quantities of interest.
Definition: system.h:1574
libMesh::System::vectors_begin
vectors_iterator vectors_begin()
Beginning of vectors container.
Definition: system.h:2295
libMesh::FEMap::inverse_map
static Point inverse_map(const unsigned int dim, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true)
Definition: fe_map.C:1622
libMesh::System::_mesh
MeshBase & _mesh
Constant reference to the mesh data structure used for the simulation.
Definition: system.h:1946
libMesh::System::_variables
std::vector< Variable > _variables
The Variable in this System.
Definition: system.h:1961
libMesh::DifferentiableQoI::init_qoi
virtual void init_qoi(std::vector< Number > &)
Initialize system qoi.
Definition: diff_qoi.h:71
libMesh::ParallelObject::n_processors
processor_id_type n_processors() const
Definition: parallel_object.h:100
libMesh::System::n_local_dofs
dof_id_type n_local_dofs() const
Definition: system.C:187
libMesh::DifferentiablePhysics::element_time_derivative
virtual bool element_time_derivative(bool request_jacobian, DiffContext &)
Adds the time derivative contribution on elem to elem_residual.
Definition: diff_physics.h:125
libMesh::System::variable_scalar_number
unsigned int variable_scalar_number(const std::string &var, unsigned int component) const
Definition: system.h:2214
libMesh::System::_qoi_evaluate_derivative_function
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:1919
libMesh::System::variable_group
const VariableGroup & variable_group(unsigned int vg) const
Return a constant reference to VariableGroup vg.
Definition: system.h:2193
libMesh::FEBase
FEGenericBase< Real > FEBase
Definition: exact_error_estimator.h:39
libMesh::ImplicitSystem::_can_add_matrices
bool _can_add_matrices
true when additional matrices may still be added, false otherwise.
Definition: implicit_system.h:431
libMesh::DiffContext::set_deltat_pointer
void set_deltat_pointer(Real *dt)
Points the _deltat member of this class at a timestep value stored in the creating System,...
Definition: diff_context.C:103
libMesh::Utility::iota
void iota(ForwardIter first, ForwardIter last, T value)
Utility::iota is a duplication of the SGI STL extension std::iota.
Definition: utility.h:105
libMesh::Threads::spin_mtx
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition: threads.C:29
libMesh::System::set_vector_as_adjoint
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:873
libMesh::ImplicitSystem::assembly
virtual void assembly(bool, bool, bool=false, bool=false)
Assembles a residual in rhs and/or a jacobian in matrix, as requested.
Definition: implicit_system.h:161
libMesh::System::get_mesh
const MeshBase & get_mesh() const
Definition: system.h:2083
libMesh::ParallelObject::processor_id
processor_id_type processor_id() const
Definition: parallel_object.h:106
libMesh::System::n_local_constrained_dofs
dof_id_type n_local_constrained_dofs() const
Definition: system.C:172
libMesh::libmesh_ignore
void libmesh_ignore(const Args &...)
Definition: libmesh_common.h:526
libMesh::DofMap::enforce_constraints_exactly
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:2054
libMesh::FEGenericBase::build
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
libMesh::DofObject::invalid_id
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:421
libMesh::System::add_variable
unsigned int add_variable(const std::string &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:1069
libMesh::System::current_local_solution
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:1551
libMesh::System::Constraint::constrain
virtual void constrain()=0
Constraint function.
libMesh::DifferentiableSystem::print_jacobians
bool print_jacobians
Set print_jacobians to true to print J whenever it is assembled.
Definition: diff_system.h:346
libMesh::DifferentiableSystem::solve
virtual void solve() override
Invokes the solver associated with the system.
Definition: diff_system.C:152
libMesh::System::get_sensitivity_solution
NumericVector< Number > & get_sensitivity_solution(unsigned int i=0)
Definition: system.C:904
libMesh::DifferentiableSystem::get_time_solver
TimeSolver & get_time_solver()
Definition: diff_system.h:416
libMesh::ParallelObject::_communicator
const Parallel::Communicator & _communicator
Definition: parallel_object.h:112
libMesh::ConstElemRange
StoredRange< MeshBase::const_element_iterator, const Elem * > ConstElemRange
Definition: elem_range.h:34
libMesh::processor_id_type
uint8_t processor_id_type
Definition: id_types.h:104
libMesh::MeshBase::active_local_elements_end
virtual element_iterator active_local_elements_end()=0
libMesh::DifferentiablePhysics::get_mesh_x_var
unsigned int get_mesh_x_var() const
Definition: diff_physics.h:637
libMesh::ImplicitSystem::matrix
SparseMatrix< Number > * matrix
The system matrix.
Definition: implicit_system.h:393
libMesh::TypeVector::add_scaled
void add_scaled(const TypeVector< T2 > &, const T &)
Add a scaled value to this vector without creating a temporary.
Definition: type_vector.h:665
libMesh::MeshBase::elem_dimensions
const std::set< unsigned char > & elem_dimensions() const
Definition: mesh_base.h:225
libMesh::System::write_SCALAR_dofs
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:2097
libMesh::SparseMatrix::vector_mult_add
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.
Definition: sparse_matrix.C:180
libMesh::System::_sys_number
const unsigned int _sys_number
The number associated with this system.
Definition: system.h:1956
libMesh::MeshTools::Generation::Private::idx
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.
Definition: mesh_generation.C:72
libMesh::TypeTensor::add_scaled
void add_scaled(const TypeTensor< T2 > &, const T &)
Add a scaled tensor to this tensor without creating a temporary.
Definition: type_tensor.h:869
libMesh::Threads::parallel_reduce
void parallel_reduce(const Range &range, Body &body)
Execute the provided reduction operation in parallel on the specified range.
Definition: threads_none.h:101
libMesh::ImplicitSystem::sensitivity_solve
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...
Definition: implicit_system.C:301
libMesh::ImplicitSystem::have_matrix
bool have_matrix(const std::string &mat_name) const
Definition: implicit_system.h:439
libMesh::TimeSolver::set_is_adjoint
void set_is_adjoint(bool _is_adjoint_value)
Accessor for setting whether we need to do a primal or adjoint solve.
Definition: time_solver.h:239
libMesh::NumericVector::local_size
virtual numeric_index_type local_size() const =0
libMesh::System::_written_var_indices
std::vector< unsigned int > _written_var_indices
This vector is used only when reading in a system from file.
Definition: system.h:2046
libMesh::DofMap::variable_type
const FEType & variable_type(const unsigned int c) const
Definition: dof_map.h:1924
libMesh::DifferentiableQoI::finalize_derivative
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
libMesh::ExplicitSystem::assemble_qoi
virtual void assemble_qoi(const QoISet &qoi_indices=QoISet()) override
Prepares qoi for quantity of interest assembly, then calls user qoi function.
Definition: explicit_system.C:56
libMesh::FEMContext::elem_position_set
void elem_position_set(Real theta)
Uses the coordinate data specified by mesh_*_position configuration to set the geometry of elem to th...
Definition: fem_context.h:1238
n_nodes
const dof_id_type n_nodes
Definition: tecplot_io.C:68
gptr
Gradient gptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:95
libMesh::DiffContext::get_elem_solution_rate_derivative
Real get_elem_solution_rate_derivative() const
The derivative of the current elem_solution_rate w.r.t.
Definition: diff_context.h:445
libMesh::DenseVector::size
virtual unsigned int size() const override
Definition: dense_vector.h:92
libMesh::NumericVector::l1_norm
virtual Real l1_norm() const =0
libMesh::DofMap::get_send_list
const std::vector< dof_id_type > & get_send_list() const
Definition: dof_map.h:496
libMesh::SyncNodalPositions
Definition: parallel_ghost_sync.h:782
libMesh::H2_SEMINORM
Definition: enum_norm_type.h:44
libMesh::ImplicitSystem::matrices_iterator
std::map< std::string, SparseMatrix< Number > * >::iterator matrices_iterator
Matrix iterator typedefs.
Definition: implicit_system.h:306
libMesh::NumericVector::clear
virtual void clear()
Restores the NumericVector<T> to a pristine state.
Definition: numeric_vector.h:811
libMesh::System::_additional_data_written
unsigned int _additional_data_written
This flag is used only when reading in a system from file.
Definition: system.h:2034
libMesh::ImplicitSystem::release_linear_solver
virtual void release_linear_solver(LinearSolver< Number > *) const
Releases a pointer to a linear solver acquired by this->get_linear_solver()
Definition: implicit_system.C:1418
libMesh::DifferentiablePhysics::have_first_order_vars
bool have_first_order_vars() const
Definition: diff_physics.h:512
libMesh::DifferentiablePhysics::get_mesh_z_var
unsigned int get_mesh_z_var() const
Definition: diff_physics.h:649
libMesh::DenseMatrix::zero
virtual void zero() override
Set every element in the matrix to 0.
Definition: dense_matrix.h:838
libMesh::System::Assembly::assemble
virtual void assemble()=0
Assembly function.
libMesh::MONOMIAL
Definition: enum_fe_family.h:39
libMesh::System::_assemble_system_object
Assembly * _assemble_system_object
Object that assembles the system.
Definition: system.h:1891
libMesh::FEMSystem::build_context
virtual std::unique_ptr< DiffContext > build_context() override
Builds a FEMContext object with enough information to do evaluations on each element.
Definition: fem_system.C:1314
libMesh::DofMap::create_dof_constraints
void create_dof_constraints(const MeshBase &, Real time=0)
Rebuilds the raw degree of freedom and DofObject constraints.
Definition: dof_map_constraints.C:1206
libMesh::MeshBase::nodes_end
virtual node_iterator nodes_end()=0
libMesh::System::time
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
Definition: system.h:1561
libMesh::DenseSubVector< Number >
libMesh::DifferentiablePhysics::_mesh_z_var
unsigned int _mesh_z_var
Definition: diff_physics.h:548
libMesh::FEMSystem::_numerical_jacobian_h_for_var
std::vector< Real > _numerical_jacobian_h_for_var
Definition: fem_system.h:252
libMesh::NumericVector::linfty_norm
virtual Real linfty_norm() const =0
libMesh::System::variable_type
const FEType & variable_type(const unsigned int i) const
Definition: system.h:2233
libMesh::MeshBase::n_nodes
virtual dof_id_type n_nodes() const =0
libMesh::System::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:2053
libMesh::FEMContext::set_mesh_system
virtual void set_mesh_system(System *sys)
Tells the FEMContext that system sys contains the isoparametric Lagrangian variables which correspond...
Definition: fem_context.h:830
FirstOrderScalarSystemBase::_u_var
unsigned int _u_var
Definition: time_solver_test_common.h:172
libMesh::System::discrete_var_norm
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:1337
libMesh::FEMSystem::mesh_position_set
void mesh_position_set()
Tells the FEMSystem to set the mesh nodal coordinates which should correspond to degree of freedom co...
Definition: fem_system.C:1057
libMesh::DifferentiableSystem::have_first_order_scalar_vars
bool have_first_order_scalar_vars() const
Check for any first order vars that are also belong to FEFamily::SCALAR.
Definition: diff_system.C:327
libMesh::TimeSolver::is_adjoint
bool is_adjoint() const
Accessor for querying whether we need to do a primal or adjoint solve.
Definition: time_solver.h:232
libMesh::FEMContext::elem_fe_reinit
virtual void elem_fe_reinit(const std::vector< Point > *const pts=nullptr)
Reinitializes interior FE objects on the current geometric element.
Definition: fem_context.C:1436
libMesh::System::_constrain_system_object
Constraint * _constrain_system_object
Object that constrains the system.
Definition: system.h:1902
libMesh::Parallel::sync_dofobject_data_by_id
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.
Definition: parallel_ghost_sync.h:338
libMesh::DifferentiableSystem::diff_qoi
DifferentiableQoI * diff_qoi
Pointer to object to use for quantity of interest assembly evaluations.
Definition: diff_system.h:377
libMesh::Gradient
NumberVectorValue Gradient
Definition: exact_solution.h:58
libMesh::DifferentiablePhysics::clear_physics
virtual void clear_physics()
Clear any data structures associated with the physics.
Definition: diff_physics.C:33
libMesh::DifferentiableQoI::parallel_op
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
libMesh::FEMContext::get_element_fe
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.
Definition: fem_context.h:275
libMesh::System::solution
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1539
swap
void swap(Iterator &lhs, Iterator &rhs)
swap, used to implement op=
Definition: variant_filter_iterator.h:478
libMesh::ReferenceElem::get
const Elem & get(const ElemType type_in)
Definition: reference_elem.C:237
libMesh::TensorTools::norm_sq
T norm_sq(std::complex< T > a)
Definition: tensor_tools.h:85
libMesh::MeshBase::nodes_begin
virtual node_iterator nodes_begin()=0
Iterate over all the nodes in the Mesh.
libMesh::FEMContext::set_mesh_y_var
void set_mesh_y_var(unsigned int y_var)
Accessor for y-variable of moving mesh System.
Definition: fem_context.h:870
libMesh::SparseMatrix::build
static std::unique_ptr< SparseMatrix< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
Builds a SparseMatrix<T> using the linear solver package specified by solver_package.
Definition: sparse_matrix.C:130
libMesh::System::point_value
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:1971
libMesh::FEType::order
OrderWrapper order
The approximation order of the element.
Definition: fe_type.h:197
libMesh::DISCRETE_L1
Definition: enum_norm_type.h:52
libMesh::FEMSystem::verify_analytic_jacobians
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:209
libMesh::NumericVector::set
virtual void set(const numeric_index_type i, const T value)=0
Sets v(i) = value.
libMesh::System::_qoi_evaluate_derivative_object
QOIDerivative * _qoi_evaluate_derivative_object
Object to compute derivatives of quantities of interest.
Definition: system.h:1928
libMesh::Elem::hmin
virtual Real hmin() const
Definition: elem.C:359
libMesh::System::name
const std::string & name() const
Definition: system.h:2067
libMesh::FEInterface::field_type
static FEFieldType field_type(const FEType &fe_type)
Definition: fe_interface.C:1683
libMesh::System::init_data
virtual void init_data()
Initializes the data for the system.
Definition: system.C:262
libMesh::TYPE_VECTOR
Definition: enum_fe_family.h:94
libMesh::System::n_constrained_dofs
dof_id_type n_constrained_dofs() const
Definition: system.C:157
libMesh::DiffContext::get_elem_jacobian
const DenseMatrix< Number > & get_elem_jacobian() const
Const accessor for element Jacobian.
Definition: diff_context.h:283
libMesh::DifferentiablePhysics::eulerian_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...
Definition: diff_physics.h:295
libMesh::DiffContext::get_elem_solution
const DenseVector< Number > & get_elem_solution() const
Accessor for element solution.
Definition: diff_context.h:111
libMesh::Elem::has_children
bool has_children() const
Definition: elem.h:2383
libMesh::BasicOStreamProxy::precision
std::streamsize precision() const
Get the associated write precision.
Definition: ostream_proxy.h:189
libMesh::L2
Definition: enum_norm_type.h:36
libMesh::DifferentiableSystem::get_physics
const DifferentiablePhysics * get_physics() const
Definition: diff_system.h:181
libMesh::System::variable_number
unsigned short int variable_number(const std::string &var) const
Definition: system.C:1232
libMesh::System::write_serialized_blocked_dof_objects
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:1811
libMesh::NumericVector::l2_norm
virtual Real l2_norm() const =0
libMesh::on_command_line
bool on_command_line(std::string arg)
Definition: libmesh.C:898
libMesh::DifferentiableSystem::assembly
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.
std::norm
MetaPhysicL::DualNumber< T, D > norm(const MetaPhysicL::DualNumber< T, D > &in)
libMesh::System::_equation_systems
EquationSystems & _equation_systems
Constant reference to the EquationSystems object used for the simulation.
Definition: system.h:1940
libMesh::System::calculate_norm
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
Definition: system.C:1356
libMesh::System::clear
virtual void clear()
Clear all the data structures associated with the system.
Definition: system.C:205
libMesh::System::forward_qoi_parameter_sensitivity
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:2375
libMesh::DifferentiableSystem::print_solutions
bool print_solutions
Set print_solutions to true to print U whenever it is used in an assembly() call.
Definition: diff_system.h:326
libMesh::System::add_vector
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
Definition: system.C:661
libMesh::ParallelType
ParallelType
Defines an enum for parallel data structure types.
Definition: enum_parallel_type.h:33
libMesh::DifferentiablePhysics::_time_evolving
std::vector< unsigned int > _time_evolving
Stores unsigned int to tell us which variables are evolving as first order in time (1),...
Definition: diff_physics.h:555
libMesh::SparseMatrix::l1_norm
virtual Real l1_norm() const =0
libMesh::NumericVector::get
virtual void get(const std::vector< numeric_index_type > &index, T *values) const
Access multiple components at once.
Definition: numeric_vector.h:821
libMesh::System::get_dof_map
const DofMap & get_dof_map() const
Definition: system.h:2099
libMesh::System::n_dofs
dof_id_type n_dofs() const
Definition: system.C:150
libMesh::System::user_initialization
virtual void user_initialization()
Calls user's attached initialization function, or is overridden by the user in derived classes.
Definition: system.C:1896
libMesh::DenseMatrix::l1_norm
auto l1_norm() const -> decltype(std::abs(T(0)))
Definition: dense_matrix.h:1052
libMesh::SparseMatrix::set
virtual void set(const numeric_index_type i, const numeric_index_type j, const T value)=0
Set the element (i,j) to value.
libMesh::err
OStreamProxy err
libMesh::LAGRANGE
Definition: enum_fe_family.h:36
libMesh::System::_qoi_evaluate_object
QOI * _qoi_evaluate_object
Object to compute quantities of interest.
Definition: system.h:1914
libMesh::SCALAR
Definition: enum_fe_family.h:58
libMesh::FEGenericBase::get_phi
const std::vector< std::vector< OutputShape > > & get_phi() const
Definition: fe_base.h:206
libMesh::H1
Definition: enum_norm_type.h:37
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::FEMSystem::numerical_jacobian_h_for_var
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:259
libMesh::SparseMatrix::get_transpose
virtual void get_transpose(SparseMatrix< T > &dest) const =0
Copies the transpose of the matrix into dest, which may be *this.
libMesh::DifferentiablePhysics::have_second_order_vars
bool have_second_order_vars() const
Definition: diff_physics.h:525
libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve
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)),...
Definition: implicit_system.C:412
libMesh::DifferentiablePhysics::get_first_order_vars
const std::set< unsigned int > & get_first_order_vars() const
Definition: diff_physics.h:518
libMesh::System::user_constrain
virtual void user_constrain()
Calls user's attached constraint function, or is overridden by the user in derived classes.
Definition: system.C:1924
libMesh::ReferenceCounter::_enable_print_counter
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called.
Definition: reference_counter.h:141
libMesh::FEMSystem::numerical_nonlocal_jacobian
void numerical_nonlocal_jacobian(FEMContext &context) const
Uses the results of multiple side_residual() calls to numerically differentiate the corresponding jac...
Definition: fem_system.C:1306
libMesh::System::add_weighted_sensitivity_solution
NumericVector< Number > & add_weighted_sensitivity_solution()
Definition: system.C:924
libMesh::System::project_solution
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr) const
Projects arbitrary functions onto the current solution.
Definition: system_projection.C:950
libMesh::Tensor
NumberTensorValue Tensor
Definition: exact_solution.h:56
fptr
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:80
libMesh::System::Initialization::initialize
virtual void initialize()=0
Initialization function.
libMesh::DifferentiablePhysics::get_mesh_y_var
unsigned int get_mesh_y_var() const
Definition: diff_physics.h:643
libMesh::System::add_weighted_sensitivity_adjoint_solution
NumericVector< Number > & add_weighted_sensitivity_adjoint_solution(unsigned int i=0)
Definition: system.C:977
libMesh::TimeSolver::side_residual
virtual bool side_residual(bool request_jacobian, DiffContext &)=0
This method uses the DifferentiablePhysics side_time_derivative(), side_constraint(),...
libMesh::DifferentiablePhysics::init_physics
virtual void init_physics(const System &sys)
Initialize any data structures associated with the physics.
Definition: diff_physics.C:40
libMesh::out
OStreamProxy out
libMesh::NumericVector::subset_l1_norm
virtual Real subset_l1_norm(const std::set< numeric_index_type > &indices) const
Definition: numeric_vector.C:312
libMesh::System::get_vector
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:774
libMesh::System::_variable_numbers
std::map< std::string, unsigned short int > _variable_numbers
The variable numbers corresponding to user-specified names, useful for name-based lookups.
Definition: system.h:1972
libMesh::System::update
virtual void update()
Update the local values to reflect the solution on neighboring processors.
Definition: system.C:408
libMesh::SparseMatrix::zero
virtual void zero()=0
Set all entries to 0.
libMesh::System::add_sensitivity_rhs
NumericVector< Number > & add_sensitivity_rhs(unsigned int i=0)
Definition: system.C:1039
libMesh::FIRST
Definition: enum_order.h:42
libMesh::NumericVector::zero_clone
virtual std::unique_ptr< NumericVector< T > > zero_clone() const =0
libMesh::NumericVector::type
ParallelType type() const
Definition: numeric_vector.h:160
libMesh::System::_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:2009
libMesh::FEMContext::set_mesh_z_var
void set_mesh_z_var(unsigned int z_var)
Accessor for z-variable of moving mesh System.
Definition: fem_context.h:884
libMesh::System::point_gradient
Gradient point_gradient(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2100
libMesh::NumericVector::dot
virtual T dot(const NumericVector< T > &v) const =0
libMesh::Quality::name
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
libMesh::System::point_hessian
Tensor point_hessian(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2244
libMesh::System::_sys_name
const std::string _sys_name
A name associated with this system.
Definition: system.h:1951
libMesh::DenseVector< Number >
libMesh::System::const_vectors_iterator
std::map< std::string, NumericVector< Number > * >::const_iterator const_vectors_iterator
Definition: system.h:757
libMesh::System::adjoint_qoi_parameter_sensitivity
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:2366
libMesh::DifferentiableSystem::add_dot_var_dirichlet_bcs
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...
Definition: diff_system.C:230
libMesh::DofMap::variable_group
const VariableGroup & variable_group(const unsigned int c) const
Definition: dof_map.h:1884
libMesh::ExplicitSystem::assemble_qoi_derivative
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...
Definition: explicit_system.C:69
libMesh::FEMContext::set_mesh_x_var
void set_mesh_x_var(unsigned int x_var)
Accessor for x-variable of moving mesh System.
Definition: fem_context.h:856
libMesh::DofMap::end_dof
dof_id_type end_dof(const processor_id_type proc) const
Definition: dof_map.h:692
libMesh::FEInterface::compute_data
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,...
Definition: fe_interface.C:1028
libMesh::System::_vector_is_adjoint
std::map< std::string, int > _vector_is_adjoint
Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs,...
Definition: system.h:1997
libMesh::DifferentiableSystem::have_second_order_scalar_vars
bool have_second_order_scalar_vars() const
Check for any second order vars that are also belong to FEFamily::SCALAR.
Definition: diff_system.C:339
libMesh::FEMContext
This class provides all data required for a physics package (e.g.
Definition: fem_context.h:62