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

#include <eim_classes.h>

Inheritance diagram for SimpleEIMConstruction:
[legend]

Public Types

enum  BEST_FIT_TYPE { PROJECTION_BEST_FIT , EIM_BEST_FIT , POD_BEST_FIT }
 
typedef RBEIMEvaluation::QpDataMap QpDataMap
 Type of the data structure used to map from (elem id) -> [n_vars][n_qp] data.
 
typedef RBEIMEvaluation::SideQpDataMap SideQpDataMap
 Type of the data structure used to map from (elem id,side_index) -> [n_vars][n_qp] data.
 
typedef RBEIMEvaluation::NodeDataMap NodeDataMap
 Type of the data structure used to map from node id -> [n_vars] data.
 
typedef RBConstructionBase< Systemsys_type
 The type of system.
 
typedef Number(* ValueFunctionPointer) (const Point &p, const Parameters &Parameters, const std::string &sys_name, const std::string &unknown_name)
 Projects arbitrary functions onto the current solution.
 
typedef Gradient(* GradientFunctionPointer) (const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name)
 
typedef std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> >::iterator vectors_iterator
 Vector iterator typedefs.
 
typedef std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> >::const_iterator const_vectors_iterator
 
typedef std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> >::iterator matrices_iterator
 Matrix iterator typedefs.
 
typedef std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> >::const_iterator const_matrices_iterator
 

Public Member Functions

 SimpleEIMConstruction (EquationSystems &es, const std::string &name_in, const unsigned int number_in)
 Constructor.
 
virtual void init_data ()
 Initialize data structures.
 
virtual std::unique_ptr< ElemAssembly > build_eim_assembly (unsigned int index)
 Provide an implementation of build_eim_assembly.
 
 SimpleEIMConstruction (EquationSystems &es, const std::string &name_in, const unsigned int number_in)
 Constructor.
 
virtual std::unique_ptr< ElemAssembly > build_eim_assembly (unsigned int index)
 Provide an implementation of build_eim_assembly.
 
virtual void init_data ()
 Initialize data structures.
 
virtual void clear () override
 Clear this object.
 
void set_rb_eim_evaluation (RBEIMEvaluation &rb_eim_eval_in)
 Set the RBEIMEvaluation object.
 
RBEIMEvaluation & get_rb_eim_evaluation ()
 Get a reference to the RBEvaluation object.
 
const RBEIMEvaluation & get_rb_eim_evaluation () const
 Get a const reference to the RBEvaluation object.
 
void initialize_eim_construction ()
 Perform initialization of this object to prepare for running train_eim_approximation().
 
virtual void process_parameters_file (const std::string &parameters_filename)
 Read parameters in from file and set up this system accordingly.
 
void set_rb_construction_parameters (unsigned int n_training_samples_in, bool deterministic_training_in, int training_parameters_random_seed_in, bool quiet_mode_in, unsigned int Nmax_in, Real rel_training_tolerance_in, Real abs_training_tolerance_in, const RBParameters &mu_min_in, const RBParameters &mu_max_in, const std::map< std::string, std::vector< Real > > &discrete_parameter_values_in, const std::map< std::string, bool > &log_scaling, std::map< std::string, std::vector< RBParameter > > *training_sample_list=nullptr)
 Set the state of this RBConstruction object based on the arguments to this function.
 
virtual void set_best_fit_type_flag (const std::string &best_fit_type_string)
 Specify which type of "best fit" we use to guide the EIM greedy algorithm.
 
virtual void print_info ()
 Print out info that describes the current setup of this RBConstruction.
 
void apply_normalization_to_solution_snapshots ()
 Rescale solution snapshots so that they all have unity norm.
 
virtual Real train_eim_approximation ()
 Generate the EIM approximation for the specified parametrized function using either POD or the Greedy Algorithm.
 
virtual Real train_eim_approximation_with_greedy ()
 Generate the EIM approximation for the specified parametrized function using the Greedy Algorithm.
 
virtual Real train_eim_approximation_with_POD ()
 Generate the EIM approximation for the specified parametrized function using Proper Orthogonal Decomposition (POD).
 
virtual void initialize_eim_assembly_objects ()
 Build a vector of ElemAssembly objects that accesses the basis functions stored in this RBEIMConstruction object.
 
std::vector< std::unique_ptr< ElemAssembly > > & get_eim_assembly_objects ()
 
virtual void init_context (FEMContext &)
 Pre-request FE data needed for calculations.
 
void set_rel_training_tolerance (Real new_training_tolerance)
 Get/set the relative tolerance for the basis training.
 
Real get_rel_training_tolerance ()
 
void set_abs_training_tolerance (Real new_training_tolerance)
 Get/set the absolute tolerance for the basis training.
 
Real get_abs_training_tolerance ()
 
unsigned int get_Nmax () const
 Get/set Nmax, the maximum number of RB functions we are willing to compute.
 
virtual void set_Nmax (unsigned int Nmax)
 
void enable_set_Nmax_from_n_snapshots (int increment)
 Call this method to set _set_Nmax_from_n_snapshots=true and _Nmax_from_n_snapshots_increment=increment.
 
void disable_set_Nmax_from_n_snapshots ()
 Call this method to set _set_Nmax_from_n_snapshots=false and reset _Nmax_from_n_snapshots_increment to 0.
 
Real get_max_abs_value_in_training_set () const
 Get the maximum value (across all processors) from the parametrized functions in the training set.
 
void store_eim_solutions_for_training_set ()
 Get the EIM solution vector at all parametrized functions in the training set.
 
const QpDataMapget_parametrized_function_from_training_set (unsigned int training_index) const
 Get a const reference to the specified parametrized function from the training set.
 
const SideQpDataMapget_side_parametrized_function_from_training_set (unsigned int training_index) const
 
const NodeDataMapget_node_parametrized_function_from_training_set (unsigned int training_index) const
 
const std::unordered_map< dof_id_type, std::vector< Real > > & get_local_quad_point_JxW ()
 Get the interior and side quadrature weights.
 
const std::map< std::pair< dof_id_type, unsigned int >, std::vector< Real > > & get_local_side_quad_point_JxW ()
 
unsigned int get_n_parametrized_functions_for_training () const
 Get the number of parametrized functions used for training.
 
void reinit_eim_projection_matrix ()
 Zero the _eim_projection_matrix and resize it to be get_Nmax() x get_Nmax().
 
sys_typesystem ()
 
void set_quiet_mode (bool quiet_mode_in)
 Set the quiet_mode flag.
 
bool is_quiet () const
 Is the system in quiet mode?
 
void set_normalize_solution_snapshots (bool value)
 Set the boolean option that indicates if we normalization solution snapshots or not.
 
numeric_index_type get_n_training_samples () const
 Get the number of global training samples.
 
numeric_index_type get_local_n_training_samples () const
 Get the total number of training samples local to this processor.
 
numeric_index_type get_first_local_training_index () const
 Get the first local index of the training parameters.
 
numeric_index_type get_last_local_training_index () const
 Get the last local index of the training parameters.
 
virtual void initialize_training_parameters (const RBParameters &mu_min, const RBParameters &mu_max, const unsigned int n_global_training_samples, const std::map< std::string, bool > &log_param_scale, const bool deterministic=true)
 Initialize the parameter ranges and indicate whether deterministic or random training parameters should be used and whether or not we want the parameters to be scaled logarithmically.
 
virtual void load_training_set (const std::map< std::string, std::vector< RBParameter > > &new_training_set)
 Overwrite the training parameters with new_training_set.
 
void set_training_parameter_values (const std::string &param_name, const std::vector< RBParameter > &values)
 Overwrite the local training samples for param_name using values.
 
void broadcast_parameters (const unsigned int proc_id)
 Broadcasts parameters from processor proc_id to all processors.
 
void set_training_random_seed (int seed)
 Set the seed that is used to randomly generate training parameters.
 
void set_deterministic_training_parameter_name (const std::string &name)
 In some cases we only want to allow discrete parameter values, instead of parameters that may take any value in a specified interval.
 
const std::string & get_deterministic_training_parameter_name () const
 Get the name of the parameter that we will generate deterministic training parameters for.
 
void init ()
 Initializes degrees of freedom on the current mesh.
 
virtual void reinit ()
 Reinitializes degrees of freedom and other required data on the current mesh.
 
virtual void reinit_constraints ()
 Reinitializes the constraints for this system.
 
virtual void reinit_mesh ()
 Reinitializes the system with a new mesh.
 
bool is_initialized () const
 
virtual void update ()
 Update the local values to reflect the solution on neighboring processors.
 
virtual void assemble ()
 Prepares matrix and _dof_map for matrix assembly.
 
virtual void assemble_qoi (const QoISet &qoi_indices=QoISet())
 Calls user qoi function.
 
virtual void assemble_qoi_derivative (const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
 Calls user qoi derivative function.
 
virtual void assemble_residual_derivatives (const ParameterVector &parameters)
 Calls residual parameter derivative function.
 
virtual void restrict_solve_to (const SystemSubset *subset, const SubsetSolveMode subset_solve_mode=SUBSET_ZERO)
 After calling this method, any solve will be restricted to the given subdomain.
 
virtual void solve ()
 Solves the system.
 
virtual std::pair< unsigned int, Real > sensitivity_solve (const ParameterVector &parameters)
 Solves the sensitivity system, for the provided parameters.
 
virtual std::pair< unsigned int, Real > weighted_sensitivity_solve (const ParameterVector &parameters, const ParameterVector &weights)
 Assembles & solves the linear system(s) (dR/du)*u_w = sum(w_p*-dR/dp), for those parameters p contained within parameters weighted by the values w_p found within weights.
 
virtual std::pair< unsigned int, Real > adjoint_solve (const QoISet &qoi_indices=QoISet())
 Solves the adjoint system, for the specified qoi indices, or for every qoi if qoi_indices is nullptr.
 
virtual std::pair< unsigned int, Real > weighted_sensitivity_adjoint_solve (const ParameterVector &parameters, const ParameterVector &weights, const QoISet &qoi_indices=QoISet())
 Assembles & solves the linear system(s) (dR/du)^T*z_w = sum(w_p*(d^2q/dudp - d^2R/dudp*z)), for those parameters p contained within parameters, weighted by the values w_p found within weights.
 
bool is_adjoint_already_solved () const
 Accessor for the adjoint_already_solved boolean.
 
void set_adjoint_already_solved (bool setting)
 Setter for the adjoint_already_solved boolean.
 
virtual void qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
 Solves for the derivative of each of the system's quantities of interest q in qoi[qoi_indices] with respect to each parameter in parameters, placing the result for qoi i and parameter j into sensitivities[i][j].
 
virtual void adjoint_qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
 Solves for parameter sensitivities using the adjoint method.
 
virtual void forward_qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
 Solves for parameter sensitivities using the forward method.
 
virtual void qoi_parameter_hessian (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &hessian)
 For each of the system's quantities of interest q in qoi[qoi_indices], and for a vector of parameters p, the parameter sensitivity Hessian H_ij is defined as H_ij = (d^2 q)/(d p_i d p_j) This Hessian is the output of this method, where for each q_i, H_jk is stored in hessian.second_derivative(i,j,k).
 
virtual void qoi_parameter_hessian_vector_product (const QoISet &qoi_indices, const ParameterVector &parameters, const ParameterVector &vector, SensitivityData &product)
 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].
 
virtual bool compare (const System &other_system, const Real threshold, const bool verbose) const
 
const std::string & name () const
 
virtual std::string system_type () const
 
void project_solution (FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, std::optional< ConstElemRange > active_local_range=std::nullopt, std::optional< std::vector< unsigned int > > variable_numbers=std::nullopt) const
 Projects arbitrary functions onto the current solution.
 
void project_solution (FEMFunctionBase< Number > *f, FEMFunctionBase< Gradient > *g=nullptr, std::optional< ConstElemRange > active_local_range=std::nullopt, std::optional< std::vector< unsigned int > > variable_numbers=std::nullopt) const
 Projects arbitrary functions onto the current solution.
 
void project_solution (ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters, std::optional< ConstElemRange > active_local_range=std::nullopt, std::optional< std::vector< unsigned int > > variable_numbers=std::nullopt) const
 This method projects an arbitrary function onto the solution via L2 projections and nodal interpolations on each element.
 
void project_vector (NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1, std::optional< ConstElemRange > active_local_range=std::nullopt, std::optional< std::vector< unsigned int > > variable_numbers=std::nullopt) const
 Projects arbitrary functions onto a vector of degree of freedom values for the current system.
 
void project_vector (NumericVector< Number > &new_vector, FEMFunctionBase< Number > *f, FEMFunctionBase< Gradient > *g=nullptr, int is_adjoint=-1, std::optional< ConstElemRange > active_local_range=std::nullopt, std::optional< std::vector< unsigned int > > variable_numbers=std::nullopt) const
 Projects arbitrary functions onto a vector of degree of freedom values for the current system.
 
void project_vector (ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters, NumericVector< Number > &new_vector, int is_adjoint=-1, std::optional< ConstElemRange > active_local_range=std::nullopt, std::optional< std::vector< unsigned int > > variable_numbers=std::nullopt) const
 Projects arbitrary functions onto a vector of degree of freedom values for the current system.
 
void boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, std::optional< ConstElemRange > active_local_range=std::nullopt)
 Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system.
 
void boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters, std::optional< ConstElemRange > active_local_range=std::nullopt)
 Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system.
 
void boundary_project_vector (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1, std::optional< ConstElemRange > active_local_range=std::nullopt) const
 Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system.
 
void boundary_project_vector (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters, NumericVector< Number > &new_vector, int is_adjoint=-1, std::optional< ConstElemRange > active_local_range=std::nullopt) const
 Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system.
 
unsigned int number () const
 
void update_global_solution (std::vector< Number > &global_soln) const
 Fill the input vector global_soln so that it contains the global solution on all processors.
 
void update_global_solution (std::vector< Number > &global_soln, const processor_id_type dest_proc) const
 Fill the input vector global_soln so that it contains the global solution on processor dest_proc.
 
const MeshBase & get_mesh () const
 
MeshBase & get_mesh ()
 
const DofMap & get_dof_map () const
 
DofMap & get_dof_map ()
 
const EquationSystems & get_equation_systems () const
 
EquationSystems & get_equation_systems ()
 
bool active () const
 
void activate ()
 Activates the system.
 
void deactivate ()
 Deactivates the system.
 
void set_basic_system_only ()
 Sets the system to be "basic only": i.e.
 
vectors_iterator vectors_begin ()
 Beginning of vectors container.
 
const_vectors_iterator vectors_begin () const
 Beginning of vectors container.
 
vectors_iterator vectors_end ()
 End of vectors container.
 
const_vectors_iterator vectors_end () const
 End of vectors container.
 
matrices_iterator matrices_begin ()
 Beginning of matrices container.
 
const_matrices_iterator matrices_begin () const
 Beginning of matrices container.
 
matrices_iterator matrices_end ()
 End of matrices container.
 
const_matrices_iterator matrices_end () const
 End of matrices container.
 
NumericVector< Number > & add_vector (std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
 Adds the additional vector vec_name to this system.
 
void remove_vector (std::string_view vec_name)
 Removes the additional vector vec_name from this system.
 
bool & project_solution_on_reinit (void)
 Tells the System whether or not to project the solution vector onto new grids when the system is reinitialized.
 
bool have_vector (std::string_view vec_name) const
 
const NumericVector< Number > * request_vector (std::string_view vec_name) const
 
NumericVector< Number > * request_vector (std::string_view vec_name)
 
const NumericVector< Number > * request_vector (const unsigned int vec_num) const
 
NumericVector< Number > * request_vector (const unsigned int vec_num)
 
const NumericVector< Number > & get_vector (std::string_view vec_name) const
 
NumericVector< Number > & get_vector (std::string_view vec_name)
 
const NumericVector< Number > & get_vector (const unsigned int vec_num) const
 
NumericVector< Number > & get_vector (const unsigned int vec_num)
 
const std::string & vector_name (const unsigned int vec_num) const
 
const std::string & vector_name (const NumericVector< Number > &vec_reference) const
 
void set_vector_as_adjoint (const std::string &vec_name, int qoi_num)
 Allows one to set the QoI index controlling whether the vector identified by vec_name represents a solution from the adjoint (qoi_num >= 0) or primal (qoi_num == -1) space.
 
int vector_is_adjoint (std::string_view vec_name) const
 
void set_vector_preservation (const std::string &vec_name, bool preserve)
 Allows one to set the boolean controlling whether the vector identified by vec_name should be "preserved": projected to new meshes, saved, etc.
 
bool vector_preservation (std::string_view vec_name) const
 
NumericVector< Number > & add_adjoint_solution (unsigned int i=0)
 
NumericVector< Number > & get_adjoint_solution (unsigned int i=0)
 
const NumericVector< Number > & get_adjoint_solution (unsigned int i=0) const
 
NumericVector< Number > & add_sensitivity_solution (unsigned int i=0)
 
NumericVector< Number > & get_sensitivity_solution (unsigned int i=0)
 
const NumericVector< Number > & get_sensitivity_solution (unsigned int i=0) const
 
NumericVector< Number > & add_weighted_sensitivity_adjoint_solution (unsigned int i=0)
 
NumericVector< Number > & get_weighted_sensitivity_adjoint_solution (unsigned int i=0)
 
const NumericVector< Number > & get_weighted_sensitivity_adjoint_solution (unsigned int i=0) const
 
NumericVector< Number > & add_weighted_sensitivity_solution ()
 
NumericVector< Number > & get_weighted_sensitivity_solution ()
 
const NumericVector< Number > & get_weighted_sensitivity_solution () const
 
NumericVector< Number > & add_adjoint_rhs (unsigned int i=0)
 
NumericVector< Number > & get_adjoint_rhs (unsigned int i=0)
 
const NumericVector< Number > & get_adjoint_rhs (unsigned int i=0) const
 
NumericVector< Number > & add_sensitivity_rhs (unsigned int i=0)
 
NumericVector< Number > & get_sensitivity_rhs (unsigned int i=0)
 
const NumericVector< Number > & get_sensitivity_rhs (unsigned int i=0) const
 
unsigned int n_vectors () const
 
unsigned int n_matrices () const
 
unsigned int n_vars () const
 
unsigned int n_variable_groups () const
 
unsigned int n_components () const
 
dof_id_type n_dofs () const
 
dof_id_type n_active_dofs () const
 
dof_id_type n_constrained_dofs () const
 
dof_id_type n_local_constrained_dofs () const
 
dof_id_type n_local_dofs () const
 
unsigned int add_variable (std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
 Adds the variable var to the list of variables for this system.
 
unsigned int add_variable (std::string_view var, const Order order=FIRST, const FEFamily=LAGRANGE, const std::set< subdomain_id_type > *const active_subdomains=nullptr, const bool p_refinement=true)
 Adds the variable var to the list of variables for this system.
 
unsigned int add_variables (const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
 Adds the variables vars to the list of variables for this system.
 
unsigned int add_variables (const std::vector< std::string > &vars, const Order order=FIRST, const FEFamily=LAGRANGE, const std::set< subdomain_id_type > *const active_subdomains=nullptr, const bool p_refinement=true)
 Adds the variable var to the list of variables for this system.
 
unsigned int add_variable_array (const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
 Adds variables vars to the list of variables for this system.
 
const Variable & variable (unsigned int var) const
 Return a constant reference to Variable var.
 
const VariableGroup & variable_group (unsigned int vg) const
 Return a constant reference to VariableGroup vg.
 
bool has_variable (std::string_view var) const
 
const std::string & variable_name (const unsigned int i) const
 
unsigned int variable_number (std::string_view var) const
 
void get_all_variable_numbers (std::vector< unsigned int > &all_variable_numbers) const
 Fills all_variable_numbers with all the variable numbers for the variables that have been added to this system.
 
unsigned int variable_scalar_number (std::string_view var, unsigned int component) const
 
unsigned int variable_scalar_number (unsigned int var_num, unsigned int component) const
 
const FEType & variable_type (const unsigned int i) const
 
const FEType & variable_type (std::string_view var) const
 
bool identify_variable_groups () const
 
void identify_variable_groups (const bool)
 Toggle automatic VariableGroup identification.
 
Real calculate_norm (const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
 
Real calculate_norm (const NumericVector< Number > &v, const SystemNorm &norm, std::set< unsigned int > *skip_dimensions=nullptr) const
 
void read_header (Xdr &io, std::string_view version, const bool read_header=true, const bool read_additional_data=true, const bool read_legacy_format=false)
 Reads the basic data header for this System.
 
template<typename ValType >
void read_serialized_data (Xdr &io, const bool read_additional_data=true)
 Reads additional data, namely vectors, for this System.
 
void read_serialized_data (Xdr &io, const bool read_additional_data=true)
 Non-templated version for backward compatibility.
 
template<typename InValType >
std::size_t read_serialized_vectors (Xdr &io, const std::vector< NumericVector< Number > * > &vectors) const
 Read a number of identically distributed vectors.
 
std::size_t read_serialized_vectors (Xdr &io, const std::vector< NumericVector< Number > * > &vectors) const
 Non-templated version for backward compatibility.
 
template<typename InValType >
void read_parallel_data (Xdr &io, const bool read_additional_data)
 Reads additional data, namely vectors, for this System.
 
void read_parallel_data (Xdr &io, const bool read_additional_data)
 Non-templated version for backward compatibility.
 
void write_header (Xdr &io, std::string_view version, const bool write_additional_data) const
 Writes the basic data header for this System.
 
void write_serialized_data (Xdr &io, const bool write_additional_data=true) const
 Writes additional data, namely vectors, for this System.
 
std::size_t write_serialized_vectors (Xdr &io, const std::vector< const NumericVector< Number > * > &vectors) const
 Serialize & write a number of identically distributed vectors.
 
void write_parallel_data (Xdr &io, const bool write_additional_data) const
 Writes additional data, namely vectors, for this System.
 
std::string get_info () const
 
void attach_init_function (void fptr(EquationSystems &es, const std::string &name))
 Register a user function to use in initializing the system.
 
void attach_init_object (Initialization &init)
 Register a user class to use to initialize the system.
 
void attach_assemble_function (void fptr(EquationSystems &es, const std::string &name))
 Register a user function to use in assembling the system matrix and RHS.
 
void attach_assemble_object (Assembly &assemble)
 Register a user object to use in assembling the system matrix and RHS.
 
void attach_constraint_function (void fptr(EquationSystems &es, const std::string &name))
 Register a user function for imposing constraints.
 
void attach_constraint_object (Constraint &constrain)
 Register a user object for imposing constraints.
 
bool has_constraint_object () const
 
Constraintget_constraint_object ()
 Return the user object for imposing constraints.
 
void attach_QOI_function (void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices))
 Register a user function for evaluating the quantities of interest, whose values should be placed in System::qoi.
 
void attach_QOI_object (QOI &qoi)
 Register a user object for evaluating the quantities of interest, whose values should be placed in System::qoi.
 
void attach_QOI_derivative (void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints))
 Register a user function for evaluating derivatives of a quantity of interest with respect to test functions, whose values should be placed in System::rhs.
 
void attach_QOI_derivative_object (QOIDerivative &qoi_derivative)
 Register a user object for evaluating derivatives of a quantity of interest with respect to test functions, whose values should be placed in System::rhs.
 
virtual void user_initialization ()
 Calls user's attached initialization function, or is overridden by the user in derived classes.
 
virtual void user_assembly ()
 Calls user's attached assembly function, or is overridden by the user in derived classes.
 
virtual void user_constrain ()
 Calls user's attached constraint function, or is overridden by the user in derived classes.
 
virtual void user_QOI (const QoISet &qoi_indices)
 Calls user's attached quantity of interest function, or is overridden by the user in derived classes.
 
virtual void user_QOI_derivative (const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
 Calls user's attached quantity of interest derivative function, or is overridden by the user in derived classes.
 
virtual void re_update ()
 Re-update the local values when the mesh has changed.
 
virtual void restrict_vectors ()
 Restrict vectors after the mesh has coarsened.
 
virtual void prolong_vectors ()
 Prolong vectors after the mesh has refined.
 
virtual void disable_cache ()
 Avoids use of any cached data that might affect any solve result.
 
Number current_solution (const dof_id_type global_dof_number) const
 
unsigned int n_qois () const
 Number of currently active quantities of interest.
 
void init_qois (unsigned int n_qois)
 Accessors for qoi and qoi_error_estimates vectors.
 
void set_qoi (unsigned int qoi_index, Number qoi_value)
 
void set_qoi (std::vector< Number > new_qoi)
 
Number get_qoi_value (unsigned int qoi_index) const
 
std::vector< Number > get_qoi_values () const
 Returns a copy of qoi, not a reference.
 
void set_qoi_error_estimate (unsigned int qoi_index, Number qoi_error_estimate)
 
Number get_qoi_error_estimate_value (unsigned int qoi_index) const
 
Number point_value (unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
 
Number point_value (unsigned int var, const Point &p, const Elem &e, const NumericVector< Number > *sol=nullptr) const
 
Number point_value (unsigned int var, const Point &p, const Elem *e) const
 Calls the version of point_value() which takes a reference.
 
Number point_value (unsigned int var, const Point &p, const NumericVector< Number > *sol) const
 Calls the parallel version of point_value().
 
Gradient point_gradient (unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
 
Gradient point_gradient (unsigned int var, const Point &p, const Elem &e, const NumericVector< Number > *sol=nullptr) const
 
Gradient point_gradient (unsigned int var, const Point &p, const Elem *e) const
 Calls the version of point_gradient() which takes a reference.
 
Gradient point_gradient (unsigned int var, const Point &p, const NumericVector< Number > *sol) const
 Calls the parallel version of point_gradient().
 
Tensor point_hessian (unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
 
Tensor point_hessian (unsigned int var, const Point &p, const Elem &e, const NumericVector< Number > *sol=nullptr) const
 
Tensor point_hessian (unsigned int var, const Point &p, const Elem *e) const
 Calls the version of point_hessian() which takes a reference.
 
Tensor point_hessian (unsigned int var, const Point &p, const NumericVector< Number > *sol) const
 Calls the parallel version of point_hessian().
 
void local_dof_indices (const unsigned int var, std::set< dof_id_type > &var_indices) const
 Fills the std::set with the degrees of freedom on the local processor corresponding the the variable number passed in.
 
void zero_variable (NumericVector< Number > &v, unsigned int var_num) const
 Zeroes all dofs in v that correspond to variable number var_num.
 
bool get_project_with_constraints ()
 Setter and getter functions for project_with_constraints boolean.
 
void set_project_with_constraints (bool _project_with_constraints)
 
bool & hide_output ()
 
void projection_matrix (SparseMatrix< Number > &proj_mat) const
 This method creates a projection matrix which corresponds to the operation of project_vector between old and new solution spaces.
 
SparseMatrix< Number > & add_matrix (std::string_view mat_name, ParallelType type=PARALLEL, MatrixBuildType mat_build_type=MatrixBuildType::AUTOMATIC)
 Adds the additional matrix mat_name to this system.
 
template<template< typename > class>
SparseMatrix< Number > & add_matrix (std::string_view mat_name, ParallelType=PARALLEL)
 Adds the additional matrix mat_name to this system.
 
SparseMatrix< Number > & add_matrix (std::string_view mat_name, std::unique_ptr< SparseMatrix< Number > > matrix, ParallelType type=PARALLEL)
 Adds the additional matrix mat_name to this system.
 
void remove_matrix (std::string_view mat_name)
 Removes the additional matrix mat_name from this system.
 
bool have_matrix (std::string_view mat_name) const
 
const SparseMatrix< Number > * request_matrix (std::string_view mat_name) const
 
SparseMatrix< Number > * request_matrix (std::string_view mat_name)
 
const SparseMatrix< Number > & get_matrix (std::string_view mat_name) const
 
SparseMatrix< Number > & get_matrix (std::string_view mat_name)
 
void prefer_hash_table_matrix_assembly (bool preference)
 Sets whether to use hash table matrix assembly if the matrix sub-classes support it.
 
void prefix_with_name (bool value)
 Instructs this system to prefix solve options with its name for solvers that leverage prefixes.
 
bool prefix_with_name () const
 
std::string prefix () const
 
virtual void create_static_condensation ()
 Request that static condensation be performed for this system.
 
bool has_static_condensation () const
 
void solve_for_unconstrained_dofs (NumericVector< Number > &, int is_adjoint=-1) const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 
void initialize_parameters (const RBParameters &mu_min_in, const RBParameters &mu_max_in, const std::map< std::string, std::vector< Real > > &discrete_parameter_values)
 Initialize the parameter ranges and set current_parameters.
 
void initialize_parameters (const RBParametrized &rb_parametrized)
 Initialize the parameter ranges and set current_parameters.
 
unsigned int get_n_params () const
 Get the number of parameters.
 
unsigned int get_n_continuous_params () const
 Get the number of continuous parameters.
 
unsigned int get_n_discrete_params () const
 Get the number of discrete parameters.
 
const RBParameters & get_parameters () const
 Get the current parameters.
 
bool set_parameters (const RBParameters &params)
 Set the current parameters to params The parameters are checked for validity; an error is thrown if the number of parameters or samples is different than expected.
 
const RBParameters & get_parameters_min () const
 Get an RBParameters object that specifies the minimum allowable value for each parameter.
 
const RBParameters & get_parameters_max () const
 Get an RBParameters object that specifies the maximum allowable value for each parameter.
 
Real get_parameter_min (const std::string &param_name) const
 Get minimum allowable value of parameter param_name.
 
Real get_parameter_max (const std::string &param_name) const
 Get maximum allowable value of parameter param_name.
 
void print_parameters () const
 Print the current parameters.
 
void write_parameter_data_to_files (const std::string &continuous_param_file_name, const std::string &discrete_param_file_name, const bool write_binary_data)
 Write out the parameter ranges to files.
 
void read_parameter_data_from_files (const std::string &continuous_param_file_name, const std::string &discrete_param_file_name, const bool read_binary_data)
 Read in the parameter ranges from files.
 
bool is_discrete_parameter (const std::string &mu_name) const
 Is parameter mu_name discrete?
 
const std::map< std::string, std::vector< Real > > & get_discrete_parameter_values () const
 Get a const reference to the discrete parameter values.
 
void print_discrete_parameter_values () const
 Print out all the discrete parameter values.
 

Static Public Member Functions

static void print_info (std::ostream &out_stream=libMesh::out)
 Prints the reference information, by default to libMesh::out.
 
static void print_info (std::ostream &out_stream=libMesh::out)
 Prints the reference information, by default to libMesh::out.
 
static std::pair< std::size_t, std::size_t > generate_training_parameters_random (const Parallel::Communicator &communicator, const std::map< std::string, bool > &log_param_scale, std::map< std::string, std::vector< RBParameter > > &local_training_parameters_in, const unsigned int n_global_training_samples_in, const RBParameters &min_parameters, const RBParameters &max_parameters, const int training_parameters_random_seed=-1, const bool serial_training_set=false)
 Static helper function for generating a randomized set of parameters.
 
static std::pair< std::size_t, std::size_t > generate_training_parameters_deterministic (const Parallel::Communicator &communicator, const std::map< std::string, bool > &log_param_scale, std::map< std::string, std::vector< RBParameter > > &local_training_parameters_in, const unsigned int n_global_training_samples_in, const RBParameters &min_parameters, const RBParameters &max_parameters, const bool serial_training_set=false)
 Static helper function for generating a deterministic set of parameters.
 
static std::string get_info ()
 Gets a string containing the reference information.
 
static std::string get_info ()
 Gets a string containing the reference information.
 
static unsigned int n_objects ()
 Prints the number of outstanding (created, but not yet destroyed) objects.
 
static unsigned int n_objects ()
 Prints the number of outstanding (created, but not yet destroyed) objects.
 
static void enable_print_counter_info ()
 Methods to enable/disable the reference counter output from print_info().
 
static void enable_print_counter_info ()
 Methods to enable/disable the reference counter output from print_info().
 
static void disable_print_counter_info ()
 
static void disable_print_counter_info ()
 
static Real get_closest_value (Real value, const std::vector< Real > &list_of_values)
 

Public Attributes

BEST_FIT_TYPE best_fit_type_flag
 Enum that indicates which type of "best fit" algorithm we should use.
 
Parameters parameters
 Parameters for the system. If a parameter is not provided, it should be retrieved from the EquationSystems.
 
bool assemble_before_solve
 Flag which tells the system to whether or not to call the user assembly function during each call to solve().
 
bool use_fixed_solution
 A boolean to be set to true by systems using elem_fixed_solution, for optional use by e.g.
 
int extra_quadrature_order
 A member int that can be employed to indicate increased or reduced quadrature order.
 
std::unique_ptr< NumericVector< Number > > solution
 Data structure to hold solution values.
 
std::unique_ptr< NumericVector< Number > > current_local_solution
 All the values I need to compute my contribution to the simulation at hand.
 
Real time
 For time-dependent problems, this is the time t at the beginning of the current timestep.
 
bool verbose_mode
 Public boolean to toggle verbose mode.
 

Protected Types

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

Protected Member Functions

bool enrich_eim_approximation_on_sides (const SideQpDataMap &side_pf, bool add_basis_function, EimPointData *eim_point_data)
 Implementation of enrich_eim_approximation() for the case of element sides.
 
bool enrich_eim_approximation_on_nodes (const NodeDataMap &node_pf, bool add_basis_function, EimPointData *eim_point_data)
 Implementation of enrich_eim_approximation() for the case of element nodes.
 
bool enrich_eim_approximation_on_interiors (const QpDataMap &interior_pf, bool add_basis_function, EimPointData *eim_point_data)
 Implementation of enrich_eim_approximation() for the case of element interiors.
 
void update_eim_matrices (bool set_eim_error_indicator)
 Update the matrices used in training the EIM approximation.
 
RBParameters get_params_from_training_set (unsigned int global_index)
 Return the RBParameters in index global_index of the global training set.
 
void set_params_from_training_set (unsigned int global_index)
 Set parameters to the RBParameters stored in index global_index of the global training set.
 
virtual void set_params_from_training_set_and_broadcast (unsigned int global_index)
 Load the specified training parameter and then broadcast to all processors.
 
void project_vector (NumericVector< Number > &, int is_adjoint=-1, std::optional< ConstElemRange > active_local_range=std::nullopt, std::optional< std::vector< unsigned int > > variable_numbers=std::nullopt) const
 Projects the vector defined on the old mesh onto the new mesh.
 
void project_vector (const NumericVector< Number > &, NumericVector< Number > &, int is_adjoint=-1, std::optional< ConstElemRange > active_local_range=std::nullopt, std::optional< std::vector< unsigned int > > variable_numbers=std::nullopt) const
 Projects the vector defined on the old mesh onto the new mesh.
 
virtual void add_matrices ()
 Insertion point for adding matrices in derived classes before init_matrices() is called.
 
virtual void init_matrices ()
 Initializes the matrices associated with this system.
 
bool can_add_matrices () const
 
virtual bool condense_constrained_dofs () const
 Whether this object should condense out constrained degrees of freedom.
 
void increment_constructor_count (const std::string &name) noexcept
 Increments the construction counter.
 
void increment_constructor_count (const std::string &name) noexcept
 Increments the construction counter.
 
void increment_destructor_count (const std::string &name) noexcept
 Increments the destruction counter.
 
void increment_destructor_count (const std::string &name) noexcept
 Increments the destruction counter.
 

Static Protected Member Functions

static void get_global_max_error_pair (const Parallel::Communicator &communicator, std::pair< numeric_index_type, Real > &error_pair)
 Static function to return the error pair (index,error) that is corresponds to the largest error on all processors.
 

Protected Attributes

bool quiet_mode
 Flag to indicate whether we print out extra information during the Offline stage.
 
bool serial_training_set
 This boolean flag indicates whether or not the training set should be the same on all processors.
 
bool _normalize_solution_snapshots
 Set this boolean to true if we want to normalize solution snapshots used in training to have norm of 1.
 
std::unique_ptr< NumericVector< Number > > inner_product_storage_vector
 We keep an extra temporary vector that is useful for performing inner products (avoids unnecessary memory allocation/deallocation).
 
const Parallel::Communicator & _communicator
 

Static Protected Attributes

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

Private Member Functions

std::pair< Real, unsigned intcompute_max_eim_error ()
 Find the training sample that has the largest EIM approximation error based on the current EIM approximation.
 
void initialize_parametrized_functions_in_training_set ()
 Compute and store the parametrized function for each parameter in the training set at all the stored qp locations.
 
void initialize_qp_data ()
 Initialize the data associated with each quad point (location, JxW, etc.) so that we can use this in evaluation of the parametrized functions.
 
Number inner_product (const QpDataMap &v, const QpDataMap &w, bool apply_comp_scaling)
 Evaluate the inner product of vec1 and vec2 which specify values at quadrature points.
 
Number side_inner_product (const SideQpDataMap &v, const SideQpDataMap &w, bool apply_comp_scaling)
 Same as inner_product() except for side data.
 
Number node_inner_product (const NodeDataMap &v, const NodeDataMap &w, bool apply_comp_scaling)
 Same as inner_product() except for node data.
 
template<class DataMap >
Real get_max_abs_value (const DataMap &v) const
 Get the maximum absolute value from a vector stored in the format that we use for basis functions.
 
Real get_node_max_abs_value (const NodeDataMap &v) const
 Get the maximum absolute value from a vector stored in the format that we use for basis functions.
 
void enrich_eim_approximation (unsigned int training_index, bool add_basis_function, EimPointData *eim_point_data)
 Add a new basis function to the EIM approximation.
 
EimPointData get_random_point (const QpDataMap &v)
 Helper function that identifies a random EIM point from v.
 
EimPointData get_random_point (const SideQpDataMap &v)
 
EimPointData get_random_point (const NodeDataMap &v)
 
EimPointData get_random_point_from_training_sample ()
 Get a random point using the 0^th training sample as input to get_random_point().
 
void late_matrix_init (SparseMatrix< Number > &mat, ParallelType type)
 Helper function to keep DofMap forward declarable in system.h.
 
Real discrete_var_norm (const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type) const
 Finds the discrete norm for the entries in the vector corresponding to Dofs associated with var.
 
template<typename iterator_type , typename InValType >
std::size_t read_serialized_blocked_dof_objects (const dof_id_type n_objects, const iterator_type begin, const iterator_type end, const InValType dummy, Xdr &io, const std::vector< NumericVector< Number > * > &vecs, const unsigned int var_to_read=libMesh::invalid_uint) const
 Reads an input vector from the stream io and assigns the values to a set of DofObjects.
 
unsigned int read_SCALAR_dofs (const unsigned int var, Xdr &io, NumericVector< Number > *vec) const
 Reads the SCALAR dofs from the stream io and assigns the values to the appropriate entries of vec.
 
template<typename InValType >
numeric_index_type read_serialized_vector (Xdr &io, NumericVector< Number > *vec)
 Reads a vector for this System.
 
numeric_index_type read_serialized_vector (Xdr &io, NumericVector< Number > &vec)
 Non-templated version for backward compatibility.
 
template<typename iterator_type >
std::size_t write_serialized_blocked_dof_objects (const std::vector< const NumericVector< Number > * > &vecs, const dof_id_type n_objects, const iterator_type begin, const iterator_type end, Xdr &io, const unsigned int var_to_write=libMesh::invalid_uint) const
 Writes an output vector to the stream io for a set of DofObjects.
 
unsigned int write_SCALAR_dofs (const NumericVector< Number > &vec, const unsigned int var, Xdr &io) const
 Writes the SCALAR dofs associated with var to the stream io.
 
dof_id_type write_serialized_vector (Xdr &io, const NumericVector< Number > &vec) const
 Writes a vector for this System.
 
void write_parameter_ranges_to_file (const std::string &file_name, const bool write_binary)
 Write out the parameter ranges to file.
 
void write_discrete_parameter_values_to_file (const std::string &file_name, const bool write_binary_data)
 Write out the discrete parameter values to file.
 
void read_parameter_ranges_from_file (const std::string &file_name, const bool read_binary, RBParameters &param_min, RBParameters &param_max)
 Read in the parameter ranges from file.
 
void read_discrete_parameter_values_from_file (const std::string &file_name, const bool read_binary_data, std::map< std::string, std::vector< Real > > &discrete_parameter_values_in)
 Read in the discrete parameter values from file, if we have any.
 
bool check_if_valid_params (const RBParameters &params) const
 Helper function to check that params is valid:
 

Static Private Member Functions

template<class DataMap >
static void scale_parametrized_function (DataMap &local_pf, Number scaling_factor)
 Scale all values in pf by scaling_factor.
 
static void scale_node_parametrized_function (NodeDataMap &local_pf, Number scaling_factor)
 Scale all values in pf by scaling_factor The templated function above handles the elem and side cases, and this separate case handles the node case.
 
static unsigned int get_random_int_0_to_n (unsigned int n)
 Static helper function that is used by get_random_point().
 
static bool is_value_in_list (Real value, const std::vector< Real > &list_of_values, Real tol)
 Helper function to check if the specified value is in the list of values (within a tolerance given by tol).
 

Private Attributes

unsigned int _Nmax
 Maximum number of EIM basis functions we are willing to use.
 
bool _set_Nmax_from_n_snapshots
 If _set_Nmax_from_n_snapshots=true, then we overrule Nmax to be Nmax += _Nmax_from_n_snapshots_increment.
 
int _Nmax_from_n_snapshots_increment
 
Real _rel_training_tolerance
 Relative and absolute tolerances for training the EIM approximation.
 
Real _abs_training_tolerance
 
DenseMatrix< Number > _eim_projection_matrix
 The matrix we use in order to perform L2 projections of parametrized functions as part of EIM training.
 
RBEIMEvaluation * _rb_eim_eval
 The RBEIMEvaluation object that we use to perform the EIM training.
 
std::vector< std::unique_ptr< ElemAssembly > > _rb_eim_assembly_objects
 The vector of assembly objects that are created to point to this RBEIMConstruction.
 
std::vector< QpDataMap_local_parametrized_functions_for_training
 The parametrized functions that are used for training.
 
std::vector< SideQpDataMap_local_side_parametrized_functions_for_training
 Same as _local_parametrized_functions_for_training except for side data.
 
std::vector< NodeDataMap_local_node_parametrized_functions_for_training
 Same as _local_parametrized_functions_for_training except for node data.
 
Real _max_abs_value_in_training_set
 Maximum value in _local_parametrized_functions_for_training across all processors.
 
unsigned int _max_abs_value_in_training_set_index
 The training sample index at which we found _max_abs_value_in_training_set.
 
std::vector< Real > _component_scaling_in_training_set
 Keep track of a scaling factor for each component of the parametrized functions in the training set which "scales up" each component to have a similar magnitude as the largest component encountered in the training set.
 
std::unordered_map< dof_id_type, std::vector< Point > > _local_quad_point_locations
 The quadrature point locations, quadrature point weights (JxW), and subdomain IDs on every element local to this processor.
 
std::unordered_map< dof_id_type, std::vector< Real > > _local_quad_point_JxW
 
std::unordered_map< dof_id_type, subdomain_id_type > _local_quad_point_subdomain_ids
 
std::unordered_map< dof_id_type, std::vector< std::vector< Point > > > _local_quad_point_locations_perturbations
 EIM approximations often arise when applying a geometric mapping to a Reduced Basis formulation.
 
std::map< std::pair< dof_id_type, unsigned int >, std::vector< Point > > _local_side_quad_point_locations
 Same as above except for side data.
 
std::map< std::pair< dof_id_type, unsigned int >, std::vector< Real > > _local_side_quad_point_JxW
 
std::map< std::pair< dof_id_type, unsigned int >, subdomain_id_type > _local_side_quad_point_subdomain_ids
 
std::map< std::pair< dof_id_type, unsigned int >, boundary_id_type > _local_side_quad_point_boundary_ids
 
std::map< std::pair< dof_id_type, unsigned int >, std::vector< std::vector< Point > > > _local_side_quad_point_locations_perturbations
 
std::unordered_map< dof_id_type, Point > _local_node_locations
 Same as above except for node data.
 
std::unordered_map< dof_id_type, boundary_id_type > _local_node_boundary_ids
 
std::map< std::pair< dof_id_type, unsigned int >, unsigned int_local_side_quad_point_side_types
 For side data, we also store "side type" info.
 
bool _training_parameters_initialized
 Boolean flag to indicate whether or not the parameter ranges have been initialized.
 
std::map< std::string, std::vector< RBParameter > > _training_parameters
 The training samples for each parameter.
 
numeric_index_type _first_local_index
 The first sample-vector index from the global vector which is stored in the _training_parameters on this processor.
 
numeric_index_type _n_local_training_samples
 
numeric_index_type _n_global_training_samples
 
int _training_parameters_random_seed
 If < 0, use std::time() * processor_id() to seed the random number generator for the training parameters (default).
 
void(* _init_system_function )(EquationSystems &es, const std::string &name)
 Function that initializes the system.
 
Initialization_init_system_object
 Object that initializes the system.
 
void(* _assemble_system_function )(EquationSystems &es, const std::string &name)
 Function that assembles the system.
 
Assembly_assemble_system_object
 Object that assembles the system.
 
void(* _constrain_system_function )(EquationSystems &es, const std::string &name)
 Function to impose constraints.
 
Constraint_constrain_system_object
 Object that constrains the system.
 
void(* _qoi_evaluate_function )(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
 Function to evaluate quantity of interest.
 
QOI_qoi_evaluate_object
 Object to compute quantities of interest.
 
void(* _qoi_evaluate_derivative_function )(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
 Function to evaluate quantity of interest derivative.
 
QOIDerivative_qoi_evaluate_derivative_object
 Object to compute derivatives of quantities of interest.
 
std::unique_ptr< DofMap > _dof_map
 Data structure describing the relationship between nodes, variables, etc... and degrees of freedom.
 
EquationSystems & _equation_systems
 Constant reference to the EquationSystems object used for the simulation.
 
MeshBase & _mesh
 Constant reference to the mesh data structure used for the simulation.
 
const std::string _sys_name
 A name associated with this system.
 
const unsigned int _sys_number
 The number associated with this system.
 
bool _active
 Flag stating if the system is active or not.
 
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
 Some systems need an arbitrary number of vectors.
 
std::map< std::string, bool, std::less<> > _vector_projections
 Holds true if a vector by that name should be projected onto a changed grid, false if it should be zeroed.
 
std::map< std::string, int, std::less<> > _vector_is_adjoint
 Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs, -1 if primal.
 
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
 Some systems need an arbitrary number of matrices.
 
std::map< std::string, ParallelType, std::less<> > _matrix_types
 Holds the types of the matrices.
 
bool _matrices_initialized
 false when additional matrices being added require initialization, true otherwise.
 
bool _solution_projection
 Holds true if the solution vector should be projected onto a changed grid, false if it should be zeroed.
 
bool _basic_system_only
 Holds true if the components of more advanced system types (e.g.
 
bool _is_initialized
 true when additional vectors and variables do not require immediate initialization, false otherwise.
 
unsigned int _additional_data_written
 This flag is used only when reading in a system from file.
 
std::vector< unsigned int_written_var_indices
 This vector is used only when reading in a system from file.
 
bool adjoint_already_solved
 Has the adjoint problem already been solved? If the user sets adjoint_already_solved to true, we won't waste time solving it again.
 
bool _hide_output
 Are we allowed to write this system to file? If _hide_output is true, then EquationSystems::write will ignore this system.
 
bool project_with_constraints
 Do we want to apply constraints while projecting vectors ?
 
bool _prefer_hash_table_matrix_assembly
 Whether to use hash table matrix assembly if the matrix sub-classes support it.
 
bool _require_sparsity_pattern
 Whether any of our matrices require an initial sparsity pattern computation in order to determine preallocation.
 
bool _prefix_with_name
 Whether we are name prefixing solver options.
 
std::vector< Number > _qoi
 Values of the quantities of interest.
 
std::vector< Number > _qoi_error_estimates
 Vector to hold error estimates for qois, either from a steady state calculation, or from a single unsteady solver timestep.
 
bool parameters_initialized
 Flag indicating whether the parameters have been initialized.
 
RBParameters parameters_min
 Vectors that define the ranges (min and max) for the parameters.
 
RBParameters parameters_max
 
std::map< std::string, std::vector< Real > > _discrete_parameter_values
 Map that defines the allowable values of any discrete parameters.
 

Detailed Description

Definition at line 41 of file eim_classes.h.

Member Typedef Documentation

◆ const_matrices_iterator

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

Definition at line 830 of file system.h.

◆ const_vectors_iterator

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

Definition at line 804 of file system.h.

◆ Counts [1/2]

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

Data structure to log the information.

The log is identified by the class name.

Definition at line 119 of file reference_counter.h.

◆ Counts [2/2]

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

Data structure to log the information.

The log is identified by the class name.

Definition at line 119 of file reference_counter.h.

◆ GradientFunctionPointer

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

Definition at line 555 of file system.h.

◆ matrices_iterator

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

Matrix iterator typedefs.

Definition at line 829 of file system.h.

◆ NodeDataMap

typedef RBEIMEvaluation::NodeDataMap libMesh::RBEIMConstruction::NodeDataMap
inherited

Type of the data structure used to map from node id -> [n_vars] data.

Definition at line 105 of file rb_eim_construction.h.

◆ QpDataMap

typedef RBEIMEvaluation::QpDataMap libMesh::RBEIMConstruction::QpDataMap
inherited

Type of the data structure used to map from (elem id) -> [n_vars][n_qp] data.

Definition at line 95 of file rb_eim_construction.h.

◆ SideQpDataMap

typedef RBEIMEvaluation::SideQpDataMap libMesh::RBEIMConstruction::SideQpDataMap
inherited

Type of the data structure used to map from (elem id,side_index) -> [n_vars][n_qp] data.

Definition at line 100 of file rb_eim_construction.h.

◆ sys_type

typedef RBConstructionBase<System > libMesh::RBConstructionBase< System >::sys_type
inherited

The type of system.

Definition at line 82 of file rb_construction_base.h.

◆ ValueFunctionPointer

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

Projects arbitrary functions onto the current solution.

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

Definition at line 551 of file system.h.

◆ vectors_iterator

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

Vector iterator typedefs.

Definition at line 803 of file system.h.

Member Enumeration Documentation

◆ BEST_FIT_TYPE

Enumerator
PROJECTION_BEST_FIT 
EIM_BEST_FIT 
POD_BEST_FIT 

Definition at line 71 of file rb_eim_construction.h.

Constructor & Destructor Documentation

◆ SimpleEIMConstruction() [1/2]

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

Constructor.

Definition at line 48 of file eim_classes.h.

51 : RBEIMConstruction(es, name_in, number_in)
52 {
53 }
This class is part of the rbOOmit framework.

◆ SimpleEIMConstruction() [2/2]

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

Constructor.

Definition at line 46 of file eim_classes.h.

49 : RBEIMConstruction(es, name_in, number_in)
50 {
51 }

Member Function Documentation

◆ activate()

void libMesh::System::activate ( )
inlineinherited

Activates the system.

Only active systems are solved.

Definition at line 2441 of file system.h.

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

References libMesh::System::_active.

◆ active()

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

Definition at line 2433 of file system.h.

2434{
2435 return _active;
2436}

References libMesh::System::_active.

◆ add_adjoint_rhs()

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

Definition at line 1284 of file system.C.

1285{
1286 std::ostringstream adjoint_rhs_name;
1287 adjoint_rhs_name << "adjoint_rhs" << i;
1288
1289 return this->add_vector(adjoint_rhs_name.str(), false);
1290}
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
Definition system.C:756

References libMesh::System::add_vector().

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

◆ add_adjoint_solution()

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

Definition at line 1220 of file system.C.

1221{
1222 std::ostringstream adjoint_name;
1223 adjoint_name << "adjoint_solution" << i;
1224
1225 NumericVector<Number> & returnval = this->add_vector(adjoint_name.str());
1226 this->set_vector_as_adjoint(adjoint_name.str(), i);
1227 return returnval;
1228}
void set_vector_as_adjoint(const std::string &vec_name, int qoi_num)
Allows one to set the QoI index controlling whether the vector identified by vec_name represents a so...
Definition system.C:1147
template class LIBMESH_EXPORT NumericVector< Number >

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

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

◆ add_matrices()

virtual void libMesh::System::add_matrices ( )
inlineprotectedvirtualinherited

Insertion point for adding matrices in derived classes before init_matrices() is called.

Reimplemented in libMesh::CondensedEigenSystem, libMesh::EigenSystem, and libMesh::ImplicitSystem.

Definition at line 2017 of file system.h.

2017{}

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

◆ add_matrix() [1/3]

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

Adds the additional matrix mat_name to this system.

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

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

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

Definition at line 998 of file system.C.

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

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

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

◆ add_matrix() [2/3]

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

Adds the additional matrix mat_name to this system.

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

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

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

Definition at line 2646 of file system.h.

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

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

◆ add_matrix() [3/3]

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

Adds the additional matrix mat_name to this system.

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

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

Definition at line 1041 of file system.C.

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

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

◆ add_sensitivity_rhs()

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

Definition at line 1314 of file system.C.

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

References libMesh::System::add_vector().

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

◆ add_sensitivity_solution()

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

Definition at line 1169 of file system.C.

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

References libMesh::System::add_vector().

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

◆ add_variable() [1/2]

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

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

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

Returns
The index number for the new variable.

Definition at line 1344 of file system.C.

1347{
1348 return this->get_dof_map().add_variable(*this, var, type, active_subdomains);
1349}
unsigned int add_variable(System &sys, std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
Definition dof_map.C:3146

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

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

◆ add_variable() [2/2]

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

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

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

Definition at line 1353 of file system.C.

1358{
1359 return this->add_variable(var,
1360 FEType(order, family).set_p_refinement(p_refinement),
1361 active_subdomains);
1362}
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
Definition system.C:1344

References libMesh::System::add_variable().

◆ add_variable_array()

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

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

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

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

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

Definition at line 1386 of file system.C.

1389{
1390 return this->get_dof_map().add_variable_array(*this, vars, type, active_subdomains);
1391}
unsigned int add_variable_array(System &sys, const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds variables vars to the list of variables for this system.
Definition dof_map.C:3377

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

Referenced by DofMapTest::testArrayDofIndicesWithType().

◆ add_variables() [1/2]

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

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

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

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

Definition at line 1366 of file system.C.

1369{
1370 return this->get_dof_map().add_variables(*this, vars, type, active_subdomains);
1371}
unsigned int add_variables(System &sys, const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variables vars to the list of variables for this system.
Definition dof_map.C:3253

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

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

◆ add_variables() [2/2]

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

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

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

Definition at line 1375 of file system.C.

1380{
1381 return this->add_variables(vars,
1382 FEType(order, family).set_p_refinement(p_refinement),
1383 active_subdomains);
1384}
unsigned int add_variables(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variables vars to the list of variables for this system.
Definition system.C:1366

References libMesh::System::add_variables().

◆ add_vector()

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

Adds the additional vector vec_name to this system.

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

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

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

Definition at line 756 of file system.C.

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

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

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

◆ add_weighted_sensitivity_adjoint_solution()

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

Definition at line 1252 of file system.C.

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

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

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

◆ add_weighted_sensitivity_solution()

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

Definition at line 1199 of file system.C.

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

References libMesh::System::add_vector().

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

◆ adjoint_qoi_parameter_sensitivity()

void libMesh::System::adjoint_qoi_parameter_sensitivity ( const QoISet qoi_indices,
const ParameterVector parameters,
SensitivityData sensitivities 
)
inlinevirtualinherited

Solves for parameter sensitivities using the adjoint method.

This method is only implemented in some derived classes.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2602 of file system.h.

2605{
2606 libmesh_not_implemented();
2607}

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

◆ adjoint_solve()

std::pair< unsigned int, Real > libMesh::System::adjoint_solve ( const QoISet qoi_indices = QoISet())
inlinevirtualinherited

Solves the adjoint system, for the specified qoi indices, or for every qoi if qoi_indices is nullptr.

Must be overridden in derived systems.

Returns
A pair with the total number of linear iterations performed and the (sum of the) final residual norms

This method is only implemented in some derived classes.

Reimplemented in libMesh::DifferentiableSystem, and libMesh::ImplicitSystem.

Definition at line 2586 of file system.h.

2587{
2588 libmesh_not_implemented();
2589}

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), and libMesh::AdjointResidualErrorEstimator::estimate_error().

◆ apply_normalization_to_solution_snapshots()

void libMesh::RBEIMConstruction::apply_normalization_to_solution_snapshots ( )
inherited

Rescale solution snapshots so that they all have unity norm.

This is relevant if training samples have differing magnitudes and we want to approximate them all with equal accuracy.

Definition at line 639 of file rb_eim_construction.C.

640{
641 LOG_SCOPE("apply_normalization_to_solution_snapshots()", "RBEIMConstruction");
642
643 libMesh::out << "Normalizing solution snapshots" << std::endl;
644
645 bool apply_comp_scaling = !get_rb_eim_evaluation().scale_components_in_enrichment().empty();
646 unsigned int n_snapshots = get_n_training_samples();
647 RBEIMEvaluation & rbe = get_rb_eim_evaluation();
648
649 for (unsigned int i=0; i<n_snapshots; i++)
650 {
651 Real norm_val = 0.;
652 if (rbe.get_parametrized_function().on_mesh_sides())
653 {
654 norm_val = std::sqrt(std::real(side_inner_product(
657 apply_comp_scaling)));
658
659 if (norm_val > 0.)
661 }
662 else if (rbe.get_parametrized_function().on_mesh_nodes())
663 {
664 norm_val = std::sqrt(std::real(node_inner_product(
667 apply_comp_scaling)));
668
669 if (norm_val > 0.)
671 }
672 else
673 {
674 norm_val = std::sqrt(std::real(inner_product(
677 apply_comp_scaling)));
678
679 if (norm_val > 0.)
681 }
682
683 // Since we're rescaling the training samples, we should also rescale
684 // _max_abs_value_in_training_set in the same way. We obtained the
685 // _max_abs_value_in_training_set value from the sample with index
686 // _max_abs_value_in_training_set_index, so we rescale using the norm
687 // of this sample here. Note that the value we obtain may not be exactly
688 // equal to the max value we would obtain after looping over all the
689 // normalized samples, because we normalized in the L2 norm rather than
690 // in the max norm, but it should be close to this "true max" value. The
691 // main use-case of _max_abs_value_in_training_set is to scale the relative
692 // error tolerance in the Greedy training, and the L2-norm-scaled value of
693 // _max_abs_value_in_training_set that we obtain here should be sufficient
694 // for that purpose.
695 if ((i == _max_abs_value_in_training_set_index) && (norm_val > 0.))
697 }
698
699 libMesh::out << "Maximum absolute value in the training set after normalization: "
700 << _max_abs_value_in_training_set << std::endl << std::endl;
701}
numeric_index_type get_n_training_samples() const
Get the number of global training samples.
std::vector< QpDataMap > _local_parametrized_functions_for_training
The parametrized functions that are used for training.
Number node_inner_product(const NodeDataMap &v, const NodeDataMap &w, bool apply_comp_scaling)
Same as inner_product() except for node data.
static void scale_parametrized_function(DataMap &local_pf, Number scaling_factor)
Scale all values in pf by scaling_factor.
unsigned int _max_abs_value_in_training_set_index
The training sample index at which we found _max_abs_value_in_training_set.
Number inner_product(const QpDataMap &v, const QpDataMap &w, bool apply_comp_scaling)
Evaluate the inner product of vec1 and vec2 which specify values at quadrature points.
static void scale_node_parametrized_function(NodeDataMap &local_pf, Number scaling_factor)
Scale all values in pf by scaling_factor The templated function above handles the elem and side cases...
std::vector< SideQpDataMap > _local_side_parametrized_functions_for_training
Same as _local_parametrized_functions_for_training except for side data.
Number side_inner_product(const SideQpDataMap &v, const SideQpDataMap &w, bool apply_comp_scaling)
Same as inner_product() except for side data.
Real _max_abs_value_in_training_set
Maximum value in _local_parametrized_functions_for_training across all processors.
std::vector< NodeDataMap > _local_node_parametrized_functions_for_training
Same as _local_parametrized_functions_for_training except for node data.
RBEIMEvaluation & get_rb_eim_evaluation()
Get a reference to the RBEvaluation object.
const std::set< unsigned int > & scale_components_in_enrichment() const
Get _scale_components_in_enrichment.
OStreamProxy out
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
boost::multiprecision::float128 real(const boost::multiprecision::float128 in)

References libMesh::RBEIMConstruction::_local_node_parametrized_functions_for_training, libMesh::RBEIMConstruction::_local_parametrized_functions_for_training, libMesh::RBEIMConstruction::_local_side_parametrized_functions_for_training, libMesh::RBEIMConstruction::_max_abs_value_in_training_set, libMesh::RBEIMConstruction::_max_abs_value_in_training_set_index, libMesh::RBConstructionBase< System >::get_n_training_samples(), libMesh::RBEIMEvaluation::get_parametrized_function(), libMesh::RBEIMConstruction::get_rb_eim_evaluation(), libMesh::RBEIMConstruction::inner_product(), libMesh::RBEIMConstruction::node_inner_product(), libMesh::RBParametrizedFunction::on_mesh_nodes(), libMesh::RBParametrizedFunction::on_mesh_sides(), libMesh::out, std::real(), libMesh::Real, libMesh::RBEIMEvaluation::scale_components_in_enrichment(), libMesh::RBEIMConstruction::scale_node_parametrized_function(), libMesh::RBEIMConstruction::scale_parametrized_function(), and libMesh::RBEIMConstruction::side_inner_product().

Referenced by libMesh::RBEIMConstruction::train_eim_approximation().

◆ assemble()

void libMesh::System::assemble ( )
virtualinherited

Prepares matrix and _dof_map for matrix assembly.

Does not actually assemble anything. For matrix assembly, use the assemble() in derived classes. Should be overridden in derived classes.

Reimplemented in libMesh::DifferentiableSystem, libMesh::FrequencySystem, libMesh::ImplicitSystem, libMesh::LinearImplicitSystem, and libMesh::NewmarkSystem.

Definition at line 554 of file system.C.

555{
556 // Log how long the user's assembly code takes
557 LOG_SCOPE("assemble()", "System");
558
559 // Call the user-specified assembly function
560 this->user_assembly();
561}
virtual void user_assembly()
Calls user's attached assembly function, or is overridden by the user in derived classes.
Definition system.C:2109

References libMesh::System::user_assembly().

Referenced by libMesh::ImplicitSystem::assemble(), libMesh::CondensedEigenSystem::solve(), libMesh::EigenSystem::solve(), and libMesh::ExplicitSystem::solve().

◆ assemble_qoi()

void libMesh::System::assemble_qoi ( const QoISet qoi_indices = QoISet())
virtualinherited

Calls user qoi function.

Can be overridden in derived classes.

Reimplemented in libMesh::FEMSystem, and libMesh::ExplicitSystem.

Definition at line 565 of file system.C.

566{
567 // Log how long the user's assembly code takes
568 LOG_SCOPE("assemble_qoi()", "System");
569
570 // Call the user-specified quantity of interest function
571 this->user_QOI(qoi_indices);
572}
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.
Definition system.C:2137

References libMesh::System::user_QOI().

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

◆ assemble_qoi_derivative()

void libMesh::System::assemble_qoi_derivative ( const QoISet qoi_indices = QoISet(),
bool  include_liftfunc = true,
bool  apply_constraints = true 
)
virtualinherited

Calls user qoi derivative function.

Can be overridden in derived classes.

Reimplemented in libMesh::ExplicitSystem, and libMesh::FEMSystem.

Definition at line 576 of file system.C.

579{
580 // Log how long the user's assembly code takes
581 LOG_SCOPE("assemble_qoi_derivative()", "System");
582
583 // Call the user-specified quantity of interest function
584 this->user_QOI_derivative(qoi_indices, include_liftfunc,
585 apply_constraints);
586}
virtual void user_QOI_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
Calls user's attached quantity of interest derivative function, or is overridden by the user in deriv...
Definition system.C:2151

References libMesh::System::user_QOI_derivative().

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

◆ assemble_residual_derivatives()

void libMesh::System::assemble_residual_derivatives ( const ParameterVector parameters)
inlinevirtualinherited

Calls residual parameter derivative function.

Library subclasses use finite differences by default.

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

This method is only implemented in some derived classes.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2553 of file system.h.

2554{
2555 libmesh_not_implemented();
2556}

◆ attach_assemble_function()

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

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

Definition at line 1959 of file system.C.

1961{
1963
1964 if (_assemble_system_object != nullptr)
1965 {
1966 libmesh_warning("WARNING: Cannot specify both assembly function and object!");
1967
1968 _assemble_system_object = nullptr;
1969 }
1970
1972}
Assembly * _assemble_system_object
Object that assembles the system.
Definition system.h:2182
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Function that assembles the system.
Definition system.h:2176
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition projection.C:81

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

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

◆ attach_assemble_object()

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

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

Definition at line 1976 of file system.C.

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

Referenced by main().

◆ attach_constraint_function()

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

Register a user function for imposing constraints.

Definition at line 1990 of file system.C.

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

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

◆ attach_constraint_object()

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

Register a user object for imposing constraints.

Definition at line 2007 of file system.C.

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

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

◆ attach_init_function()

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

Register a user function to use in initializing the system.

Definition at line 1928 of file system.C.

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

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

Referenced by main(), and main().

◆ attach_init_object()

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

Register a user class to use to initialize the system.

Note
This is exclusive with the attach_init_function.

Definition at line 1945 of file system.C.

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

◆ attach_QOI_derivative()

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

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

Definition at line 2064 of file system.C.

2066{
2068
2069 if (_qoi_evaluate_derivative_object != nullptr)
2070 {
2071 libmesh_warning("WARNING: Cannot specify both QOI derivative function and object!");
2072
2074 }
2075
2077}
QOIDerivative * _qoi_evaluate_derivative_object
Object to compute derivatives of quantities of interest.
Definition system.h:2219
void(* _qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
Function to evaluate quantity of interest derivative.
Definition system.h:2210

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

◆ attach_QOI_derivative_object()

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

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

Definition at line 2081 of file system.C.

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

◆ attach_QOI_function()

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

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

Definition at line 2032 of file system.C.

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

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

◆ attach_QOI_object()

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

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

Definition at line 2050 of file system.C.

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

◆ boundary_project_solution() [1/2]

void libMesh::System::boundary_project_solution ( const std::set< boundary_id_type > &  b,
const std::vector< unsigned int > &  variables,
FunctionBase< Number > *  f,
FunctionBase< Gradient > *  g = nullptr,
std::optional< ConstElemRange active_local_range = std::nullopt 
)
inherited

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

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

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

Definition at line 1306 of file system_projection.C.

1311{
1312 this->boundary_project_vector(b, variables, *solution, f, g, -1 /*is_adjoint*/, active_local_range);
1313
1314 solution->localize(*current_local_solution);
1315}
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition system.h:1667
void boundary_project_vector(const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1, std::optional< ConstElemRange > active_local_range=std::nullopt) const
Projects arbitrary boundary functions onto a vector of degree of freedom values for the current syste...
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition system.h:1655
static const Real b

References b.

Referenced by SystemsTest::testBoundaryProjectCube().

◆ boundary_project_solution() [2/2]

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

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

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

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

Definition at line 1287 of file system_projection.C.

1294{
1295 WrappedFunction<Number> f(*this, fptr, &function_parameters);
1296 WrappedFunction<Gradient> g(*this, gptr, &function_parameters);
1297 this->boundary_project_solution(b, variables, &f, &g, active_local_range);
1298}
void boundary_project_solution(const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, std::optional< ConstElemRange > active_local_range=std::nullopt)
Projects arbitrary boundary functions onto a vector of degree of freedom values for the current syste...
Gradient gptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition projection.C:96

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

◆ boundary_project_vector() [1/2]

void libMesh::System::boundary_project_vector ( const std::set< boundary_id_type > &  b,
const std::vector< unsigned int > &  variables,
NumericVector< Number > &  new_vector,
FunctionBase< Number > *  f,
FunctionBase< Gradient > *  g = nullptr,
int  is_adjoint = -1,
std::optional< ConstElemRange active_local_range = std::nullopt 
) const
inherited

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

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

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

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

Definition at line 1344 of file system_projection.C.

1351{
1352 LOG_SCOPE ("boundary_project_vector()", "System");
1353
1354 if (!active_local_range)
1355 {
1356 active_local_range.emplace
1357 (this->get_mesh().active_local_elements_begin(),
1358 this->get_mesh().active_local_elements_end());
1359 }
1360
1362 (active_local_range.value(),
1363 BoundaryProjectSolution(b, variables, *this, f, g,
1365 new_vector)
1366 );
1367
1368 // We don't do SCALAR dofs when just projecting the boundary, so
1369 // we're done here.
1370
1371 new_vector.close();
1372
1373#ifdef LIBMESH_ENABLE_CONSTRAINTS
1374 if (is_adjoint == -1)
1375 this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
1376 else if (is_adjoint >= 0)
1378 is_adjoint);
1379#else
1380 libmesh_ignore(is_adjoint);
1381#endif
1382}
void enforce_constraints_exactly(const System &system, NumericVector< Number > *v=nullptr, bool homogeneous=false) const
Constrains the numeric vector v, which represents a solution defined on the mesh.
Definition dof_map.h:2518
void enforce_adjoint_constraints_exactly(NumericVector< Number > &v, unsigned int q) const
Heterogeneously constrains the numeric vector v, which represents an adjoint solution defined on the ...
Definition dof_map.h:2522
virtual void close()=0
Calls the NumericVector's internal assembly routines, ensuring that the values are consistent across ...
Parameters parameters
Parameters for the system. If a parameter is not provided, it should be retrieved from the EquationSy...
Definition system.h:1588
const EquationSystems & get_equation_systems() const
Definition system.h:767
void parallel_for(const Range &range, const Body &body, unsigned int n_threads=libMesh::n_threads())
Execute the provided function object in parallel on the specified range.
void libmesh_ignore(const Args &...)

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

◆ boundary_project_vector() [2/2]

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

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

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

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

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

Definition at line 1325 of file system_projection.C.

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

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

◆ broadcast_parameters()

void libMesh::RBConstructionBase< System >::broadcast_parameters ( const unsigned int  proc_id)
inherited

Broadcasts parameters from processor proc_id to all processors.

This broadcasts the RBParameters object from .get_parameters(), and then sets it on all processors with .set_parameters().

Definition at line 165 of file rb_construction_base.C.

721{
722 libmesh_assert_less (proc_id, this->n_processors());
723
724 // create a copy of the current parameters
725 RBParameters current_parameters = get_parameters();
726 libmesh_error_msg_if(current_parameters.n_samples()!=1,
727 "Only single-sample RBParameter objects can be broadcast.");
728
729 // Serialize the current_parameters to current_parameters_vector in order to broadcast.
730 // We handle multiple samples and vector values.
731 // However, the vector values are assumed to remain the same size across samples.
732 const std::size_t nparams = current_parameters.n_parameters();
733 const std::size_t nsamples = current_parameters.n_samples();
734
735 // First we get the sizes of all the parameter value vectors.
736 std::vector<std::size_t> param_value_sizes;
737 param_value_sizes.reserve(nparams);
738 for (const auto & pr : current_parameters)
739 param_value_sizes.push_back(pr.second[0].size());
740
741 // Broadcast the sizes vector and reserve memory.
742 this->comm().broadcast(param_value_sizes, proc_id);
743 std::size_t buffsize = std::accumulate(param_value_sizes.cbegin(), param_value_sizes.cend(), 0ul);
744 std::vector<Real> serialized_parameters;
745 serialized_parameters.reserve(buffsize);
746
747 // Then we serialize the parameters/sample/value vectors into a single vector.
748 for (const auto & pr : current_parameters)
749 {
750 for (const auto sample_idx : make_range(nsamples))
751 serialized_parameters.insert(serialized_parameters.end(),
752 pr.second[sample_idx].cbegin(),
753 pr.second[sample_idx].cend());
754 }
755
756 // Do the broadcasts.
757 this->comm().broadcast(serialized_parameters, proc_id);
758
759 // Deserialize into the copy of the RBParameters object.
760 std::size_t param_idx = 0;
761 auto val_idx = serialized_parameters.cbegin();
762 for (const auto & pr : current_parameters)
763 {
764 const std::size_t param_value_size = param_value_sizes[param_idx];
765 for (const auto sample_idx: make_range(nsamples))
766 {
767 auto end_val_idx = std::next(val_idx,param_value_size);
768 RBParameter sample_val(val_idx, end_val_idx);
769 current_parameters.set_value(pr.first, sample_idx, sample_val);
770 val_idx = end_val_idx;
771 }
772 ++param_idx;
773 }
774
775 // Overwrite the parameters globally.
776 set_parameters(current_parameters);
777}
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
const RBParameters & get_parameters() const
Get the current parameters.
bool set_parameters(const RBParameters &params)
Set the current parameters to params The parameters are checked for validity; an error is thrown if t...
std::vector< Real > RBParameter
Typedef for an individual RB parameter.
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition int_range.h:176

◆ build_eim_assembly() [1/2]

virtual std::unique_ptr< ElemAssembly > SimpleEIMConstruction::build_eim_assembly ( unsigned int  index)
inlinevirtual

Provide an implementation of build_eim_assembly.

Implements libMesh::RBEIMConstruction.

Definition at line 68 of file eim_classes.h.

69 {
70 return std::make_unique<EIM_F>(*this, index);
71 }

◆ build_eim_assembly() [2/2]

virtual std::unique_ptr< ElemAssembly > SimpleEIMConstruction::build_eim_assembly ( unsigned int  index)
inlinevirtual

Provide an implementation of build_eim_assembly.

Implements libMesh::RBEIMConstruction.

Definition at line 56 of file eim_classes.h.

57 {
58 return std::make_unique<AssemblyEIM>(*this, index);
59 }

◆ calculate_norm() [1/2]

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

Definition at line 1533 of file system.C.

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

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

◆ calculate_norm() [2/2]

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

Definition at line 1511 of file system.C.

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

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

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

◆ can_add_matrices()

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

Definition at line 2028 of file system.h.

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

References libMesh::System::_matrices_initialized.

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

◆ check_if_valid_params()

bool libMesh::RBParametrized::check_if_valid_params ( const RBParameters params) const
privateinherited

Helper function to check that params is valid:

  • same number of parameters (error)
  • parameter values are within the min/max range (warning)
  • discrete values are correctly discrete within tolerance (warning) Warnings are only printed if "verbose_mode" is true.

Definition at line 378 of file rb_parametrized.C.

379{
380 // Check if number of parameters are correct.
381 libmesh_error_msg_if(params.n_parameters() != get_n_params(),
382 "Error: Number of parameters don't match; found "
383 << params.n_parameters() << ", expected "
384 << get_n_params());
385
386 bool is_valid = true;
387 std::string prev_param_name = "";
388 for (const auto & [param_name, sample_vec] : params)
389 {
390 std::size_t sample_idx = 0;
391 const Real & min_value = get_parameter_min(param_name);
392 const Real & max_value = get_parameter_max(param_name);
393 for (const auto & value_vec : sample_vec)
394 {
395 for (const auto & value : value_vec)
396 {
397 // Check every parameter value (including across samples and vector-values)
398 // to ensure it's within the min/max range.
399 const bool outside_range = ((value < min_value) || (value > max_value));
400 is_valid = is_valid && !outside_range;
401 if (outside_range && verbose_mode)
402 {
403 libMesh::out << "Warning: parameter " << param_name << " value="
404 << value << " outside acceptable range: ("
405 << min_value << ", " << max_value << ")";
406 }
407
408 // For discrete params, make sure params.get_value(param_name) is sufficiently
409 // close to one of the discrete parameter values.
410 // Note that vector-values not yet supported in discrete parameters,
411 // and the .get_sample_value() call will throw an error if the user
412 // tries to do it.
413 if (const auto it = get_discrete_parameter_values().find(param_name);
414 it != get_discrete_parameter_values().end())
415 {
416 const bool is_value_discrete =
417 is_value_in_list(params.get_sample_value(param_name, sample_idx),
418 it->second,
419 TOLERANCE);
420 is_valid = is_valid && is_value_discrete;
421 if (!is_value_discrete && verbose_mode)
422 libMesh::out << "Warning: parameter " << param_name << " value="
423 << value << " is not in discrete value list.";
424 }
425 }
426 ++sample_idx;
427 }
428 }
429 return is_valid;
430}
unsigned int get_n_params() const
Get the number of parameters.
const std::map< std::string, std::vector< Real > > & get_discrete_parameter_values() const
Get a const reference to the discrete parameter values.
static bool is_value_in_list(Real value, const std::vector< Real > &list_of_values, Real tol)
Helper function to check if the specified value is in the list of values (within a tolerance given by...
Real get_parameter_max(const std::string &param_name) const
Get maximum allowable value of parameter param_name.
Real get_parameter_min(const std::string &param_name) const
Get minimum allowable value of parameter param_name.
bool verbose_mode
Public boolean to toggle verbose mode.
static constexpr Real TOLERANCE
static const bool value
Definition xdr_io.C:55

References libMesh::RBParametrized::get_discrete_parameter_values(), libMesh::RBParametrized::get_n_params(), libMesh::RBParametrized::get_parameter_max(), libMesh::RBParametrized::get_parameter_min(), libMesh::RBParameters::get_sample_value(), libMesh::RBParametrized::is_value_in_list(), libMesh::RBParameters::n_parameters(), libMesh::out, libMesh::Real, libMesh::TOLERANCE, value, and libMesh::RBParametrized::verbose_mode.

Referenced by libMesh::RBParametrized::set_parameters().

◆ clear()

void libMesh::RBEIMConstruction::clear ( )
overridevirtualinherited

Clear this object.

Reimplemented from libMesh::RBConstructionBase< System >.

Definition at line 127 of file rb_eim_construction.C.

128{
130
132
135 _local_quad_point_JxW.clear();
137
144
146 _local_node_locations.clear();
148
150}
void resize(const unsigned int new_m, const unsigned int new_n)
Resizes the matrix to the specified size and calls zero().
virtual void clear()
Clear all the data structures associated with the system.
std::unordered_map< dof_id_type, boundary_id_type > _local_node_boundary_ids
std::unordered_map< dof_id_type, std::vector< Point > > _local_quad_point_locations
The quadrature point locations, quadrature point weights (JxW), and subdomain IDs on every element lo...
std::unordered_map< dof_id_type, Point > _local_node_locations
Same as above except for node data.
std::unordered_map< dof_id_type, subdomain_id_type > _local_quad_point_subdomain_ids
DenseMatrix< Number > _eim_projection_matrix
The matrix we use in order to perform L2 projections of parametrized functions as part of EIM trainin...
std::vector< std::unique_ptr< ElemAssembly > > _rb_eim_assembly_objects
The vector of assembly objects that are created to point to this RBEIMConstruction.
std::unordered_map< dof_id_type, std::vector< Real > > _local_quad_point_JxW
std::map< std::pair< dof_id_type, unsigned int >, std::vector< Point > > _local_side_quad_point_locations
Same as above except for side data.
std::map< std::pair< dof_id_type, unsigned int >, boundary_id_type > _local_side_quad_point_boundary_ids
std::map< std::pair< dof_id_type, unsigned int >, unsigned int > _local_side_quad_point_side_types
For side data, we also store "side type" info.
std::map< std::pair< dof_id_type, unsigned int >, subdomain_id_type > _local_side_quad_point_subdomain_ids
std::map< std::pair< dof_id_type, unsigned int >, std::vector< Real > > _local_side_quad_point_JxW

References libMesh::RBEIMConstruction::_eim_projection_matrix, libMesh::RBEIMConstruction::_local_node_boundary_ids, libMesh::RBEIMConstruction::_local_node_locations, libMesh::RBEIMConstruction::_local_node_parametrized_functions_for_training, libMesh::RBEIMConstruction::_local_parametrized_functions_for_training, libMesh::RBEIMConstruction::_local_quad_point_JxW, libMesh::RBEIMConstruction::_local_quad_point_locations, libMesh::RBEIMConstruction::_local_quad_point_subdomain_ids, libMesh::RBEIMConstruction::_local_side_parametrized_functions_for_training, libMesh::RBEIMConstruction::_local_side_quad_point_boundary_ids, libMesh::RBEIMConstruction::_local_side_quad_point_JxW, libMesh::RBEIMConstruction::_local_side_quad_point_locations, libMesh::RBEIMConstruction::_local_side_quad_point_side_types, libMesh::RBEIMConstruction::_local_side_quad_point_subdomain_ids, libMesh::RBEIMConstruction::_rb_eim_assembly_objects, libMesh::RBConstructionBase< Base >::clear(), and libMesh::DenseMatrix< T >::resize().

◆ comm()

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

Definition at line 97 of file parallel_object.h.

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

References libMesh::ParallelObject::_communicator.

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

◆ compare()

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

Definition at line 606 of file system.C.

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

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

◆ compute_max_eim_error()

std::pair< Real, unsigned int > libMesh::RBEIMConstruction::compute_max_eim_error ( )
privateinherited

Find the training sample that has the largest EIM approximation error based on the current EIM approximation.

Return the maximum error, and the training sample index at which it occurred.

Definition at line 1371 of file rb_eim_construction.C.

1372{
1373 LOG_SCOPE("compute_max_eim_error()", "RBEIMConstruction");
1374
1375 if (get_n_params() == 0)
1376 {
1377 // Just return 0 if we have no parameters.
1378 return std::make_pair(0.,0);
1379 }
1380
1381 // keep track of the maximum error
1382 unsigned int max_err_index = 0;
1383 Real max_err = 0.;
1384
1385 libmesh_error_msg_if(get_n_training_samples() != get_local_n_training_samples(),
1386 "Error: Training samples should be the same on all procs");
1387
1388 const unsigned int RB_size = get_rb_eim_evaluation().get_n_basis_functions();
1389
1391 {
1392 for (auto training_index : make_range(get_n_training_samples()))
1393 {
1394 if (get_rb_eim_evaluation().get_parametrized_function().on_mesh_sides())
1395 {
1396 // Make a copy of the pre-computed solution for the specified training sample
1397 // since we will modify it below to compute the best fit error.
1398 SideQpDataMap solution_copy = _local_side_parametrized_functions_for_training[training_index];
1399
1400 // Perform an L2 projection in order to find the best approximation to
1401 // the parametrized function from the current EIM space.
1402 DenseVector<Number> best_fit_rhs(RB_size);
1403 for (unsigned int i=0; i<RB_size; i++)
1404 {
1405 best_fit_rhs(i) = side_inner_product(solution_copy,
1406 get_rb_eim_evaluation().get_side_basis_function(i),
1407 /*apply_comp_scaling*/ false);
1408 }
1409
1410 // Now compute the best fit by an LU solve
1411 DenseMatrix<Number> RB_inner_product_matrix_N(RB_size);
1412 _eim_projection_matrix.get_principal_submatrix(RB_size, RB_inner_product_matrix_N);
1413
1414 DenseVector<Number> best_fit_coeffs;
1415 RB_inner_product_matrix_N.lu_solve(best_fit_rhs, best_fit_coeffs);
1416
1417 get_rb_eim_evaluation().side_decrement_vector(solution_copy, best_fit_coeffs);
1418 Real best_fit_error = get_max_abs_value(solution_copy);
1419
1420 if (best_fit_error > max_err)
1421 {
1422 max_err_index = training_index;
1423 max_err = best_fit_error;
1424 }
1425 }
1426 else if (get_rb_eim_evaluation().get_parametrized_function().on_mesh_nodes())
1427 {
1428 // Make a copy of the pre-computed solution for the specified training sample
1429 // since we will modify it below to compute the best fit error.
1430 NodeDataMap solution_copy = _local_node_parametrized_functions_for_training[training_index];
1431
1432 // Perform an L2 projection in order to find the best approximation to
1433 // the parametrized function from the current EIM space.
1434 DenseVector<Number> best_fit_rhs(RB_size);
1435 for (unsigned int i=0; i<RB_size; i++)
1436 {
1437 best_fit_rhs(i) = node_inner_product(solution_copy,
1438 get_rb_eim_evaluation().get_node_basis_function(i),
1439 /*apply_comp_scaling*/ false);
1440 }
1441
1442 // Now compute the best fit by an LU solve
1443 DenseMatrix<Number> RB_inner_product_matrix_N(RB_size);
1444 _eim_projection_matrix.get_principal_submatrix(RB_size, RB_inner_product_matrix_N);
1445
1446 DenseVector<Number> best_fit_coeffs;
1447 RB_inner_product_matrix_N.lu_solve(best_fit_rhs, best_fit_coeffs);
1448
1449 get_rb_eim_evaluation().node_decrement_vector(solution_copy, best_fit_coeffs);
1450 Real best_fit_error = get_node_max_abs_value(solution_copy);
1451
1452 if (best_fit_error > max_err)
1453 {
1454 max_err_index = training_index;
1455 max_err = best_fit_error;
1456 }
1457 }
1458 else
1459 {
1460 // Make a copy of the pre-computed solution for the specified training sample
1461 // since we will modify it below to compute the best fit error.
1462 QpDataMap solution_copy = _local_parametrized_functions_for_training[training_index];
1463
1464 // Perform an L2 projection in order to find the best approximation to
1465 // the parametrized function from the current EIM space.
1466 DenseVector<Number> best_fit_rhs(RB_size);
1467 for (unsigned int i=0; i<RB_size; i++)
1468 {
1469 best_fit_rhs(i) = inner_product(solution_copy,
1470 get_rb_eim_evaluation().get_basis_function(i),
1471 /*apply_comp_scaling*/ false);
1472 }
1473
1474 // Now compute the best fit by an LU solve
1475 DenseMatrix<Number> RB_inner_product_matrix_N(RB_size);
1476 _eim_projection_matrix.get_principal_submatrix(RB_size, RB_inner_product_matrix_N);
1477
1478 DenseVector<Number> best_fit_coeffs;
1479 RB_inner_product_matrix_N.lu_solve(best_fit_rhs, best_fit_coeffs);
1480
1481 get_rb_eim_evaluation().decrement_vector(solution_copy, best_fit_coeffs);
1482 Real best_fit_error = get_max_abs_value(solution_copy);
1483
1484 if (best_fit_error > max_err)
1485 {
1486 max_err_index = training_index;
1487 max_err = best_fit_error;
1488 }
1489 }
1490 }
1491 }
1493 {
1494 // Perform EIM solve in order to find the approximation to solution
1495 // (rb_eim_solve provides the EIM basis function coefficients used below)
1496
1497 std::vector<RBParameters> training_parameters_copy(get_n_training_samples());
1498 for (auto training_index : make_range(get_n_training_samples()))
1499 {
1500 training_parameters_copy[training_index] = get_params_from_training_set(training_index);
1501 }
1502
1503 get_rb_eim_evaluation().rb_eim_solves(training_parameters_copy, RB_size);
1504 const std::vector<DenseVector<Number>> & rb_eim_solutions = get_rb_eim_evaluation().get_rb_eim_solutions();
1505
1506 for (auto training_index : make_range(get_n_training_samples()))
1507 {
1508 const DenseVector<Number> & best_fit_coeffs = rb_eim_solutions[training_index];
1509
1510 if (get_rb_eim_evaluation().get_parametrized_function().on_mesh_sides())
1511 {
1512 SideQpDataMap solution_copy = _local_side_parametrized_functions_for_training[training_index];
1513 get_rb_eim_evaluation().side_decrement_vector(solution_copy, best_fit_coeffs);
1514 Real best_fit_error = get_max_abs_value(solution_copy);
1515
1516 if (best_fit_error > max_err)
1517 {
1518 max_err_index = training_index;
1519 max_err = best_fit_error;
1520 }
1521 }
1522 else if (get_rb_eim_evaluation().get_parametrized_function().on_mesh_nodes())
1523 {
1524 NodeDataMap solution_copy = _local_node_parametrized_functions_for_training[training_index];
1525 get_rb_eim_evaluation().node_decrement_vector(solution_copy, best_fit_coeffs);
1526 Real best_fit_error = get_node_max_abs_value(solution_copy);
1527
1528 if (best_fit_error > max_err)
1529 {
1530 max_err_index = training_index;
1531 max_err = best_fit_error;
1532 }
1533 }
1534 else
1535 {
1536 QpDataMap solution_copy = _local_parametrized_functions_for_training[training_index];
1537 get_rb_eim_evaluation().decrement_vector(solution_copy, best_fit_coeffs);
1538 Real best_fit_error = get_max_abs_value(solution_copy);
1539
1540 if (best_fit_error > max_err)
1541 {
1542 max_err_index = training_index;
1543 max_err = best_fit_error;
1544 }
1545 }
1546 }
1547 }
1548 else
1549 {
1550 libmesh_error_msg("EIM best fit type not recognized");
1551 }
1552
1553 return std::make_pair(max_err,max_err_index);
1554}
void get_principal_submatrix(unsigned int sub_m, unsigned int sub_n, DenseMatrix< T > &dest) const
Put the sub_m x sub_n principal submatrix into dest.
RBParameters get_params_from_training_set(unsigned int global_index)
Return the RBParameters in index global_index of the global training set.
numeric_index_type get_local_n_training_samples() const
Get the total number of training samples local to this processor.
RBEIMEvaluation::NodeDataMap NodeDataMap
Type of the data structure used to map from node id -> [n_vars] data.
BEST_FIT_TYPE best_fit_type_flag
Enum that indicates which type of "best fit" algorithm we should use.
Real get_node_max_abs_value(const NodeDataMap &v) const
Get the maximum absolute value from a vector stored in the format that we use for basis functions.
RBEIMEvaluation::QpDataMap QpDataMap
Type of the data structure used to map from (elem id) -> [n_vars][n_qp] data.
Real get_max_abs_value(const DataMap &v) const
Get the maximum absolute value from a vector stored in the format that we use for basis functions.
RBEIMEvaluation::SideQpDataMap SideQpDataMap
Type of the data structure used to map from (elem id,side_index) -> [n_vars][n_qp] data.
void decrement_vector(QpDataMap &v, const DenseVector< Number > &coeffs)
Subtract coeffs[i]*basis_function[i] from v.
unsigned int get_n_basis_functions() const
Return the current number of EIM basis functions.
void rb_eim_solves(const std::vector< RBParameters > &mus, unsigned int N)
Perform rb_eim_solves at each mu in mus and store the results in _rb_eim_solutions.
void side_decrement_vector(SideQpDataMap &v, const DenseVector< Number > &coeffs)
Same as decrement_vector() except for Side data.
const std::vector< DenseVector< Number > > & get_rb_eim_solutions() const
Return the EIM solution coefficients from the most recent call to rb_eim_solves().
void node_decrement_vector(NodeDataMap &v, const DenseVector< Number > &coeffs)
Same as decrement_vector() except for node data.

References libMesh::RBEIMConstruction::_eim_projection_matrix, libMesh::RBEIMConstruction::_local_node_parametrized_functions_for_training, libMesh::RBEIMConstruction::_local_parametrized_functions_for_training, libMesh::RBEIMConstruction::_local_side_parametrized_functions_for_training, libMesh::RBEIMConstruction::best_fit_type_flag, libMesh::RBEIMEvaluation::decrement_vector(), libMesh::RBEIMConstruction::EIM_BEST_FIT, libMesh::RBConstructionBase< System >::get_local_n_training_samples(), libMesh::RBEIMConstruction::get_max_abs_value(), libMesh::RBEIMEvaluation::get_n_basis_functions(), libMesh::RBParametrized::get_n_params(), libMesh::RBConstructionBase< System >::get_n_training_samples(), libMesh::RBEIMConstruction::get_node_max_abs_value(), libMesh::RBEIMEvaluation::get_parametrized_function(), libMesh::RBConstructionBase< System >::get_params_from_training_set(), libMesh::DenseMatrix< T >::get_principal_submatrix(), libMesh::RBEIMConstruction::get_rb_eim_evaluation(), libMesh::RBEIMEvaluation::get_rb_eim_solutions(), libMesh::RBEIMConstruction::inner_product(), libMesh::DenseMatrix< T >::lu_solve(), libMesh::make_range(), libMesh::RBEIMEvaluation::node_decrement_vector(), libMesh::RBEIMConstruction::node_inner_product(), libMesh::RBParametrizedFunction::on_mesh_sides(), libMesh::RBEIMConstruction::PROJECTION_BEST_FIT, libMesh::RBEIMEvaluation::rb_eim_solves(), libMesh::Real, libMesh::RBEIMEvaluation::side_decrement_vector(), and libMesh::RBEIMConstruction::side_inner_product().

Referenced by libMesh::RBEIMConstruction::train_eim_approximation_with_greedy().

◆ condense_constrained_dofs()

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

Whether this object should condense out constrained degrees of freedom.

Reimplemented in libMesh::CondensedEigenSystem.

Definition at line 2059 of file system.h.

2059{ return false; }

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

◆ create_static_condensation()

void libMesh::System::create_static_condensation ( )
virtualinherited

Request that static condensation be performed for this system.

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

Definition at line 2664 of file system.C.

2665{
2666 this->get_dof_map().create_static_condensation(this->get_mesh(), *this);
2667}
void create_static_condensation(MeshBase &mesh, System &system)
Add a static condensation class.
Definition dof_map.C:3135

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

◆ current_solution()

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

◆ deactivate()

void libMesh::System::deactivate ( )
inlineinherited

Deactivates the system.

Only active systems are solved.

Definition at line 2449 of file system.h.

2450{
2451 _active = false;
2452}

References libMesh::System::_active.

◆ disable_cache()

void libMesh::System::disable_cache ( )
inlinevirtualinherited

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

Should be overridden in derived systems.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2559 of file system.h.

2559{ assemble_before_solve = true; }
bool assemble_before_solve
Flag which tells the system to whether or not to call the user assembly function during each call to ...
Definition system.h:1609

References libMesh::System::assemble_before_solve.

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

◆ disable_print_counter_info() [1/2]

void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 100 of file reference_counter.C.

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

References libMesh::ReferenceCounter::_enable_print_counter.

◆ disable_print_counter_info() [2/2]

void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 100 of file reference_counter.C.

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

References libMesh::ReferenceCounter::_enable_print_counter.

◆ disable_set_Nmax_from_n_snapshots()

void libMesh::RBEIMConstruction::disable_set_Nmax_from_n_snapshots ( )
inherited

Call this method to set _set_Nmax_from_n_snapshots=false and reset _Nmax_from_n_snapshots_increment to 0.

Definition at line 1226 of file rb_eim_construction.C.

1227{
1230}
bool _set_Nmax_from_n_snapshots
If _set_Nmax_from_n_snapshots=true, then we overrule Nmax to be Nmax += _Nmax_from_n_snapshots_increm...

References libMesh::RBEIMConstruction::_Nmax_from_n_snapshots_increment, and libMesh::RBEIMConstruction::_set_Nmax_from_n_snapshots.

◆ discrete_var_norm()

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

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

Definition at line 1492 of file system.C.

1495{
1496 std::set<dof_id_type> var_indices;
1497 local_dof_indices(var, var_indices);
1498
1499 if (norm_type == DISCRETE_L1)
1500 return v.subset_l1_norm(var_indices);
1501 if (norm_type == DISCRETE_L2)
1502 return v.subset_l2_norm(var_indices);
1503 if (norm_type == DISCRETE_L_INF)
1504 return v.subset_linfty_norm(var_indices);
1505 else
1506 libmesh_error_msg("Invalid norm_type = " << Utility::enum_to_string(norm_type));
1507}
virtual Real subset_l1_norm(const std::set< numeric_index_type > &indices) const
virtual Real subset_l2_norm(const std::set< numeric_index_type > &indices) const
virtual Real subset_linfty_norm(const std::set< numeric_index_type > &indices) const
void local_dof_indices(const unsigned int var, std::set< dof_id_type > &var_indices) const
Fills the std::set with the degrees of freedom on the local processor corresponding the the variable ...
Definition system.C:1409

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

◆ enable_print_counter_info() [1/2]

void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

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

Enabled by default.

Definition at line 94 of file reference_counter.C.

95{
97 return;
98}

References libMesh::ReferenceCounter::_enable_print_counter.

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

◆ enable_print_counter_info() [2/2]

void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

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

Enabled by default.

Definition at line 94 of file reference_counter.C.

95{
97 return;
98}

References libMesh::ReferenceCounter::_enable_print_counter.

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

◆ enable_set_Nmax_from_n_snapshots()

void libMesh::RBEIMConstruction::enable_set_Nmax_from_n_snapshots ( int  increment)
inherited

Call this method to set _set_Nmax_from_n_snapshots=true and _Nmax_from_n_snapshots_increment=increment.

This means that we will overrule Nmax to be n_snapshots + increment, where increment can be positive or negative (typically it should be negative to limit Nmax to be less that the number of snapshots).

Definition at line 1220 of file rb_eim_construction.C.

1221{
1224}

References libMesh::RBEIMConstruction::_Nmax_from_n_snapshots_increment, and libMesh::RBEIMConstruction::_set_Nmax_from_n_snapshots.

◆ enrich_eim_approximation()

void libMesh::RBEIMConstruction::enrich_eim_approximation ( unsigned int  training_index,
bool  add_basis_function,
EimPointData eim_point_data 
)
privateinherited

Add a new basis function to the EIM approximation.

Definition at line 2342 of file rb_eim_construction.C.

2345{
2346 LOG_SCOPE("enrich_eim_approximation()", "RBEIMConstruction");
2347
2348 RBEIMEvaluation & eim_eval = get_rb_eim_evaluation();
2349
2350 set_params_from_training_set(training_index);
2351
2352 if (eim_eval.get_parametrized_function().on_mesh_sides())
2354 add_basis_function,
2355 eim_point_data);
2356 else if (eim_eval.get_parametrized_function().on_mesh_nodes())
2358 add_basis_function,
2359 eim_point_data);
2360 else
2361 {
2363 add_basis_function,
2364 eim_point_data);
2365 }
2366}
void set_params_from_training_set(unsigned int global_index)
Set parameters to the RBParameters stored in index global_index of the global training set.
bool enrich_eim_approximation_on_sides(const SideQpDataMap &side_pf, bool add_basis_function, EimPointData *eim_point_data)
Implementation of enrich_eim_approximation() for the case of element sides.
bool enrich_eim_approximation_on_nodes(const NodeDataMap &node_pf, bool add_basis_function, EimPointData *eim_point_data)
Implementation of enrich_eim_approximation() for the case of element nodes.
bool enrich_eim_approximation_on_interiors(const QpDataMap &interior_pf, bool add_basis_function, EimPointData *eim_point_data)
Implementation of enrich_eim_approximation() for the case of element interiors.

References libMesh::RBEIMConstruction::_local_node_parametrized_functions_for_training, libMesh::RBEIMConstruction::_local_parametrized_functions_for_training, libMesh::RBEIMConstruction::_local_side_parametrized_functions_for_training, libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_nodes(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), libMesh::RBEIMEvaluation::get_parametrized_function(), libMesh::RBEIMConstruction::get_rb_eim_evaluation(), libMesh::RBParametrizedFunction::on_mesh_nodes(), libMesh::RBParametrizedFunction::on_mesh_sides(), and libMesh::RBConstructionBase< System >::set_params_from_training_set().

Referenced by libMesh::RBEIMConstruction::train_eim_approximation_with_greedy().

◆ enrich_eim_approximation_on_interiors()

bool libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors ( const QpDataMap interior_pf,
bool  add_basis_function,
EimPointData eim_point_data 
)
protectedinherited

Implementation of enrich_eim_approximation() for the case of element interiors.

Definition at line 2677 of file rb_eim_construction.C.

2680{
2681 // Make a copy of the input parametrized function, since we will modify this below
2682 // to give us a new basis function.
2683 QpDataMap local_pf = interior_pf;
2684
2685 RBEIMEvaluation & eim_eval = get_rb_eim_evaluation();
2686
2687 // If we have at least one basis function, then we need to use
2688 // rb_eim_solve() to find the EIM interpolation error. Otherwise,
2689 // just use solution as is.
2690 if (!eim_point_data && (eim_eval.get_n_basis_functions() > 0))
2691 {
2692 // Get the right-hand side vector for the EIM approximation
2693 // by sampling the parametrized function (stored in solution)
2694 // at the interpolation points.
2695 unsigned int RB_size = eim_eval.get_n_basis_functions();
2696 DenseVector<Number> EIM_rhs(RB_size);
2697 for (unsigned int i=0; i<RB_size; i++)
2698 {
2699 EIM_rhs(i) =
2701 local_pf,
2702 eim_eval.get_interpolation_points_elem_id(i),
2703 eim_eval.get_interpolation_points_comp(i),
2704 eim_eval.get_interpolation_points_qp(i));
2705 }
2706
2707 eim_eval.set_parameters( get_parameters() );
2708 DenseVector<Number> rb_eim_solution = eim_eval.rb_eim_solve(EIM_rhs);
2709
2710 // Load the "EIM residual" into solution by subtracting
2711 // the EIM approximation
2712 eim_eval.decrement_vector(local_pf, rb_eim_solution);
2713 }
2714
2715 // Find the quadrature point at which local_pf (which now stores
2716 // the "EIM residual") has maximum absolute value
2717 Number optimal_value = 0.;
2718 Point optimal_point;
2719 unsigned int optimal_comp = 0;
2720 dof_id_type optimal_elem_id = DofObject::invalid_id;
2721 subdomain_id_type optimal_subdomain_id = 0;
2722 unsigned int optimal_qp = 0;
2723 std::vector<Point> optimal_point_perturbs;
2724 std::vector<Real> optimal_point_phi_i_qp;
2725 ElemType optimal_elem_type = INVALID_ELEM;
2726 std::vector<Real> optimal_JxW_all_qp;
2727 std::vector<std::vector<Real>> optimal_phi_i_all_qp;
2728 Order optimal_qrule_order = INVALID_ORDER;
2729 Point optimal_dxyzdxi_elem_center;
2730 Point optimal_dxyzdeta_elem_center;
2731
2732 // Initialize largest_abs_value to be negative so that it definitely gets updated.
2733 Real largest_abs_value = -1.;
2734
2735 // In order to compute phi_i_qp, we initialize a FEMContext
2736 FEMContext con(*this);
2737 for (auto dim : con.elem_dimensions())
2738 {
2739 auto fe = con.get_element_fe(/*var=*/0, dim);
2740 fe->get_phi();
2741 fe->get_JxW();
2742 fe->get_dxyzdxi();
2743 fe->get_dxyzdeta();
2744 }
2745
2746 for (const auto & [elem_id, comp_and_qp] : local_pf)
2747 {
2748 // Also initialize phi in order to compute phi_i_qp
2749 const Elem & elem_ref = get_mesh().elem_ref(elem_id);
2750 con.pre_fe_reinit(*this, &elem_ref);
2751
2752 auto elem_fe = con.get_element_fe(/*var=*/0, elem_ref.dim());
2753 const std::vector<std::vector<Real>> & phi = elem_fe->get_phi();
2754 const auto & JxW = elem_fe->get_JxW();
2755 const auto & dxyzdxi = elem_fe->get_dxyzdxi();
2756 const auto & dxyzdeta = elem_fe->get_dxyzdeta();
2757
2758 elem_fe->reinit(&elem_ref);
2759
2760 for (const auto & comp : index_range(comp_and_qp))
2761 {
2762 const std::vector<Number> & qp_values = comp_and_qp[comp];
2763
2764 for (auto qp : index_range(qp_values))
2765 {
2766 Number value = qp_values[qp];
2767 Real abs_value = std::abs(value);
2768
2769 if (get_rb_eim_evaluation().scale_components_in_enrichment().count(comp))
2770 abs_value *= _component_scaling_in_training_set[comp];
2771
2772 bool update_optimal_point = false;
2773 if (!eim_point_data)
2774 update_optimal_point = (abs_value > largest_abs_value);
2775 else
2776 update_optimal_point = (elem_id == eim_point_data->elem_id) &&
2777 (comp == eim_point_data->comp_index) &&
2778 (qp == eim_point_data->qp_index);
2779
2780 if (update_optimal_point)
2781 {
2782 largest_abs_value = abs_value;
2783 optimal_value = value;
2784 optimal_comp = comp;
2785 optimal_elem_id = elem_id;
2786 optimal_qp = qp;
2787 optimal_elem_type = elem_ref.type();
2788
2789 optimal_point_phi_i_qp.resize(phi.size());
2790 for (auto i : index_range(phi))
2791 optimal_point_phi_i_qp[i] = phi[i][qp];
2792
2793 const auto & point_list =
2794 libmesh_map_find(_local_quad_point_locations, elem_id);
2795
2796 libmesh_error_msg_if(qp >= point_list.size(), "Error: Invalid qp");
2797
2798 optimal_point = point_list[qp];
2799
2800 optimal_subdomain_id = libmesh_map_find(_local_quad_point_subdomain_ids, elem_id);
2801
2802 if (get_rb_eim_evaluation().get_parametrized_function().requires_xyz_perturbations)
2803 {
2804 const auto & perturb_list =
2805 libmesh_map_find(_local_quad_point_locations_perturbations, elem_id);
2806
2807 libmesh_error_msg_if(qp >= perturb_list.size(), "Error: Invalid qp");
2808
2809 optimal_point_perturbs = perturb_list[qp];
2810 }
2811
2812 if (get_rb_eim_evaluation().get_parametrized_function().requires_all_elem_qp_data)
2813 {
2814 optimal_JxW_all_qp = JxW;
2815 optimal_phi_i_all_qp = phi;
2816 }
2817
2818 if (get_rb_eim_evaluation().get_parametrized_function().requires_all_elem_center_data)
2819 {
2820 optimal_qrule_order = con.get_element_qrule().get_order();
2821 // Get data derivatives at vertex average
2822 std::vector<Point> nodes = { elem_ref.reference_elem()->vertex_average() };
2823 elem_fe->reinit (&elem_ref, &nodes);
2824
2825 Point dxyzdxi_pt, dxyzdeta_pt;
2826 if (con.get_elem_dim()>0)
2827 dxyzdxi_pt = dxyzdxi[0];
2828 if (con.get_elem_dim()>1)
2829 dxyzdeta_pt = dxyzdeta[0];
2830
2831 optimal_dxyzdxi_elem_center = dxyzdxi_pt;
2832 optimal_dxyzdeta_elem_center = dxyzdeta_pt;
2833
2834 elem_fe->reinit(&elem_ref);
2835 }
2836 }
2837 }
2838 }
2839 }
2840
2841 // Find out which processor has the largest of the abs values
2842 // and broadcast from that processor.
2843 unsigned int proc_ID_index;
2844 this->comm().maxloc(largest_abs_value, proc_ID_index);
2845
2846 this->comm().broadcast(optimal_value, proc_ID_index);
2847 this->comm().broadcast(optimal_point, proc_ID_index);
2848 this->comm().broadcast(optimal_comp, proc_ID_index);
2849 this->comm().broadcast(optimal_elem_id, proc_ID_index);
2850 this->comm().broadcast(optimal_subdomain_id, proc_ID_index);
2851 this->comm().broadcast(optimal_qp, proc_ID_index);
2852 this->comm().broadcast(optimal_point_perturbs, proc_ID_index);
2853 this->comm().broadcast(optimal_point_phi_i_qp, proc_ID_index);
2854 this->comm().broadcast(optimal_JxW_all_qp, proc_ID_index);
2855 this->comm().broadcast(optimal_phi_i_all_qp, proc_ID_index);
2856 this->comm().broadcast(optimal_dxyzdxi_elem_center, proc_ID_index);
2857 this->comm().broadcast(optimal_dxyzdeta_elem_center, proc_ID_index);
2858
2859 // Cast optimal_elem_type to an int in order to broadcast it
2860 {
2861 int optimal_elem_type_int = static_cast<int>(optimal_elem_type);
2862 this->comm().broadcast(optimal_elem_type_int, proc_ID_index);
2863 optimal_elem_type = static_cast<ElemType>(optimal_elem_type_int);
2864 }
2865
2866 // Cast optimal_qrule_order to an int in order to broadcast it
2867 {
2868 int optimal_qrule_order_int = static_cast<int>(optimal_qrule_order);
2869 this->comm().broadcast(optimal_qrule_order_int, proc_ID_index);
2870 optimal_qrule_order = static_cast<Order>(optimal_qrule_order_int);
2871 }
2872
2873 libmesh_error_msg_if(optimal_elem_id == DofObject::invalid_id, "Error: Invalid element ID");
2874
2875 if (add_basis_function)
2876 {
2877 if (optimal_value == 0.)
2878 {
2879 libMesh::out << "Encountered linearly dependent data in EIM enrichment, hence skip adding new basis function" << std::endl;
2880 return true;
2881 }
2882
2883 // Scale local_pf so that its largest value is 1.0
2884 scale_parametrized_function(local_pf, 1./optimal_value);
2885
2886 // Add local_pf as the new basis function and store data
2887 // associated with the interpolation point.
2888 eim_eval.add_basis_function(local_pf);
2889 }
2890
2891 eim_eval.add_interpolation_data(optimal_point,
2892 optimal_comp,
2893 optimal_elem_id,
2894 optimal_subdomain_id,
2895 optimal_qp,
2896 optimal_point_perturbs,
2897 optimal_point_phi_i_qp,
2898 optimal_elem_type,
2899 optimal_JxW_all_qp,
2900 optimal_phi_i_all_qp,
2901 optimal_qrule_order,
2902 optimal_dxyzdxi_elem_center,
2903 optimal_dxyzdeta_elem_center);
2904
2905 // In this case we did not encounter a linearly dependent basis function, so return false
2906 return false;
2907}
void maxloc(T &r, unsigned int &max_id) const
static constexpr dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition dof_object.h:473
virtual const Elem & elem_ref(const dof_id_type i) const
Definition mesh_base.h:788
std::vector< Real > _component_scaling_in_training_set
Keep track of a scaling factor for each component of the parametrized functions in the training set w...
std::unordered_map< dof_id_type, std::vector< std::vector< Point > > > _local_quad_point_locations_perturbations
EIM approximations often arise when applying a geometric mapping to a Reduced Basis formulation.
static Number get_parametrized_function_value(const Parallel::Communicator &comm, const QpDataMap &pf, dof_id_type elem_id, unsigned int comp, unsigned int qp)
Same as above, except that we just return the value at the qp^th quadrature point.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition int_range.h:153
ElemType
Defines an enum for geometric element types.
TestClass subdomain_id_type
Based on the 4-byte comment warning above, this probably doesn't work with exodusII at all....
Definition id_types.h:43
uint8_t dof_id_type
Definition id_types.h:67
@ INVALID_ORDER
Definition enum_order.h:88

References libMesh::RBEIMConstruction::_component_scaling_in_training_set, libMesh::RBEIMConstruction::_local_quad_point_locations, libMesh::RBEIMConstruction::_local_quad_point_locations_perturbations, libMesh::RBEIMConstruction::_local_quad_point_subdomain_ids, libMesh::RBEIMEvaluation::add_basis_function(), libMesh::RBEIMEvaluation::add_interpolation_data(), libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::EimPointData::comp_index, libMesh::RBEIMEvaluation::decrement_vector(), dim, libMesh::Elem::dim(), libMesh::FEMContext::elem_dimensions(), libMesh::EimPointData::elem_id, libMesh::MeshBase::elem_ref(), libMesh::FEMContext::get_elem_dim(), libMesh::FEMContext::get_element_fe(), libMesh::FEMContext::get_element_qrule(), libMesh::RBEIMEvaluation::get_interpolation_points_comp(), libMesh::RBEIMEvaluation::get_interpolation_points_elem_id(), libMesh::RBEIMEvaluation::get_interpolation_points_qp(), libMesh::System::get_mesh(), libMesh::RBEIMEvaluation::get_n_basis_functions(), libMesh::QBase::get_order(), libMesh::RBParametrized::get_parameters(), libMesh::RBEIMEvaluation::get_parametrized_function_value(), libMesh::RBEIMConstruction::get_rb_eim_evaluation(), libMesh::index_range(), libMesh::INVALID_ELEM, libMesh::DofObject::invalid_id, libMesh::INVALID_ORDER, libMesh::Parallel::Communicator::maxloc(), libMesh::out, libMesh::FEMContext::pre_fe_reinit(), libMesh::EimPointData::qp_index, libMesh::RBEIMEvaluation::rb_eim_solve(), libMesh::Real, libMesh::Elem::reference_elem(), libMesh::RBEIMConstruction::scale_parametrized_function(), libMesh::RBParametrized::set_parameters(), libMesh::Elem::type(), value, and libMesh::Elem::vertex_average().

Referenced by libMesh::RBEIMConstruction::enrich_eim_approximation(), and libMesh::RBEIMConstruction::train_eim_approximation_with_POD().

◆ enrich_eim_approximation_on_nodes()

bool libMesh::RBEIMConstruction::enrich_eim_approximation_on_nodes ( const NodeDataMap node_pf,
bool  add_basis_function,
EimPointData eim_point_data 
)
protectedinherited

Implementation of enrich_eim_approximation() for the case of element nodes.

Definition at line 2563 of file rb_eim_construction.C.

2566{
2567 // Make a copy of the input parametrized function, since we will modify this below
2568 // to give us a new basis function.
2569 NodeDataMap local_pf = node_pf;
2570
2571 RBEIMEvaluation & eim_eval = get_rb_eim_evaluation();
2572
2573 // If we have at least one basis function, then we need to use
2574 // rb_eim_solve() to find the EIM interpolation error. Otherwise,
2575 // just use solution as is.
2576 if (!eim_point_data && (eim_eval.get_n_basis_functions() > 0))
2577 {
2578 // Get the right-hand side vector for the EIM approximation
2579 // by sampling the parametrized function (stored in solution)
2580 // at the interpolation points.
2581 unsigned int RB_size = eim_eval.get_n_basis_functions();
2582 DenseVector<Number> EIM_rhs(RB_size);
2583 for (unsigned int i=0; i<RB_size; i++)
2584 {
2585 EIM_rhs(i) =
2587 local_pf,
2588 eim_eval.get_interpolation_points_node_id(i),
2589 eim_eval.get_interpolation_points_comp(i));
2590 }
2591
2592 eim_eval.set_parameters( get_parameters() );
2593 DenseVector<Number> rb_eim_solution = eim_eval.rb_eim_solve(EIM_rhs);
2594
2595 // Load the "EIM residual" into solution by subtracting
2596 // the EIM approximation
2597 eim_eval.node_decrement_vector(local_pf, rb_eim_solution);
2598 }
2599
2600 // Find the quadrature point at which local_pf (which now stores
2601 // the "EIM residual") has maximum absolute value
2602 Number optimal_value = 0.;
2603 Point optimal_point;
2604 unsigned int optimal_comp = 0;
2605 dof_id_type optimal_node_id = DofObject::invalid_id;
2606 boundary_id_type optimal_boundary_id = 0;
2607
2608 // Initialize largest_abs_value to be negative so that it definitely gets updated.
2609 Real largest_abs_value = -1.;
2610
2611 for (const auto & [node_id, values] : local_pf)
2612 {
2613 for (unsigned int comp : index_range(values))
2614 {
2615 Number value = values[comp];
2616 Real abs_value = std::abs(value);
2617
2618 bool update_optimal_point = false;
2619 if (!eim_point_data)
2620 update_optimal_point = (abs_value > largest_abs_value);
2621 else
2622 update_optimal_point = (node_id == eim_point_data->node_id) &&
2623 (comp == eim_point_data->comp_index);
2624
2625 if (update_optimal_point)
2626 {
2627 largest_abs_value = abs_value;
2628 optimal_value = value;
2629 optimal_comp = comp;
2630 optimal_node_id = node_id;
2631
2632 optimal_point = libmesh_map_find(_local_node_locations, node_id);
2633
2634 optimal_boundary_id = libmesh_map_find(_local_node_boundary_ids, node_id);
2635 }
2636 }
2637 }
2638
2639 // Find out which processor has the largest of the abs values
2640 // and broadcast from that processor.
2641 unsigned int proc_ID_index;
2642 this->comm().maxloc(largest_abs_value, proc_ID_index);
2643
2644 this->comm().broadcast(optimal_value, proc_ID_index);
2645 this->comm().broadcast(optimal_point, proc_ID_index);
2646 this->comm().broadcast(optimal_comp, proc_ID_index);
2647 this->comm().broadcast(optimal_node_id, proc_ID_index);
2648 this->comm().broadcast(optimal_boundary_id, proc_ID_index);
2649
2650 libmesh_error_msg_if(optimal_node_id == DofObject::invalid_id, "Error: Invalid node ID");
2651
2652 if (add_basis_function)
2653 {
2654 if (optimal_value == 0.)
2655 {
2656 libMesh::out << "Encountered linearly dependent data in EIM enrichment, hence skip adding new basis function" << std::endl;
2657 return true;
2658 }
2659
2660 // Scale local_pf so that its largest value is 1.0
2661 scale_node_parametrized_function(local_pf, 1./optimal_value);
2662
2663 // Add local_pf as the new basis function and store data
2664 // associated with the interpolation point.
2665 eim_eval.add_node_basis_function(local_pf);
2666 }
2667
2668 eim_eval.add_node_interpolation_data(optimal_point,
2669 optimal_comp,
2670 optimal_node_id,
2671 optimal_boundary_id);
2672
2673 // In this case we did not encounter a linearly dependent basis function, so return false
2674 return false;
2675}
static Number get_parametrized_function_node_value(const Parallel::Communicator &comm, const NodeDataMap &pf, dof_id_type node_id, unsigned int comp)
Same as get_parametrized_function_value() except for node data.
int8_t boundary_id_type
Definition id_types.h:51

References libMesh::RBEIMConstruction::_local_node_boundary_ids, libMesh::RBEIMConstruction::_local_node_locations, libMesh::RBEIMEvaluation::add_node_basis_function(), libMesh::RBEIMEvaluation::add_node_interpolation_data(), libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::EimPointData::comp_index, libMesh::RBEIMEvaluation::get_interpolation_points_comp(), libMesh::RBEIMEvaluation::get_interpolation_points_node_id(), libMesh::RBEIMEvaluation::get_n_basis_functions(), libMesh::RBParametrized::get_parameters(), libMesh::RBEIMEvaluation::get_parametrized_function_node_value(), libMesh::RBEIMConstruction::get_rb_eim_evaluation(), libMesh::index_range(), libMesh::DofObject::invalid_id, libMesh::Parallel::Communicator::maxloc(), libMesh::RBEIMEvaluation::node_decrement_vector(), libMesh::EimPointData::node_id, libMesh::out, libMesh::RBEIMEvaluation::rb_eim_solve(), libMesh::Real, libMesh::RBEIMConstruction::scale_node_parametrized_function(), libMesh::RBParametrized::set_parameters(), and value.

Referenced by libMesh::RBEIMConstruction::enrich_eim_approximation(), and libMesh::RBEIMConstruction::train_eim_approximation_with_POD().

◆ enrich_eim_approximation_on_sides()

bool libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides ( const SideQpDataMap side_pf,
bool  add_basis_function,
EimPointData eim_point_data 
)
protectedinherited

Implementation of enrich_eim_approximation() for the case of element sides.

If add_basis_function is true, then we add an extra basis function to the EIM basis. If it is false, then we only store the data associated with the interpolation point that we identify, which can be relevant when setting up data for the error indicator, for example.

If eim_point_data is not nullptr, then we add the extra point that is specified rather than looking for the "optimal point" in interior_pf.

Returns
true if side_pf is linearly dependent to the existing basis, and in this case we skip adding the basis function since we do not want to add linearly dependent data to the basis.

Definition at line 2368 of file rb_eim_construction.C.

2371{
2372 // Make a copy of the input parametrized function, since we will modify this below
2373 // to give us a new basis function.
2374 SideQpDataMap local_pf = side_pf;
2375
2376 RBEIMEvaluation & eim_eval = get_rb_eim_evaluation();
2377
2378 // If we have at least one basis function, then we need to use
2379 // rb_eim_solve() to find the EIM interpolation error. Otherwise,
2380 // just use solution as is.
2381 if (!eim_point_data && (eim_eval.get_n_basis_functions() > 0))
2382 {
2383 // Get the right-hand side vector for the EIM approximation
2384 // by sampling the parametrized function (stored in solution)
2385 // at the interpolation points.
2386 unsigned int RB_size = eim_eval.get_n_basis_functions();
2387 DenseVector<Number> EIM_rhs(RB_size);
2388 for (unsigned int i=0; i<RB_size; i++)
2389 {
2390 EIM_rhs(i) =
2392 local_pf,
2393 eim_eval.get_interpolation_points_elem_id(i),
2394 eim_eval.get_interpolation_points_side_index(i),
2395 eim_eval.get_interpolation_points_comp(i),
2396 eim_eval.get_interpolation_points_qp(i));
2397 }
2398
2399 eim_eval.set_parameters( get_parameters() );
2400 DenseVector<Number> rb_eim_solution = eim_eval.rb_eim_solve(EIM_rhs);
2401
2402 // Load the "EIM residual" into solution by subtracting
2403 // the EIM approximation
2404 eim_eval.side_decrement_vector(local_pf, rb_eim_solution);
2405 }
2406
2407 // Find the quadrature point at which local_pf (which now stores
2408 // the "EIM residual") has maximum absolute value
2409 Number optimal_value = 0.;
2410 Point optimal_point;
2411 unsigned int optimal_comp = 0;
2412 dof_id_type optimal_elem_id = DofObject::invalid_id;
2413 unsigned int optimal_side_index = 0;
2414 subdomain_id_type optimal_subdomain_id = 0;
2415 boundary_id_type optimal_boundary_id = 0;
2416 unsigned int optimal_qp = 0;
2417 std::vector<Point> optimal_point_perturbs;
2418 std::vector<Real> optimal_point_phi_i_qp;
2419
2420 // Initialize largest_abs_value to be negative so that it definitely gets updated.
2421 Real largest_abs_value = -1.;
2422
2423 // In order to compute phi_i_qp, we initialize a FEMContext
2424 FEMContext con(*this);
2425 init_context(con);
2426
2427 for (const auto & [elem_and_side, comp_and_qp] : local_pf)
2428 {
2429 dof_id_type elem_id = elem_and_side.first;
2430 unsigned int side_index = elem_and_side.second;
2431
2432 const Elem & elem_ref = get_mesh().elem_ref(elem_id);
2433 con.pre_fe_reinit(*this, &elem_ref);
2434
2435 unsigned int side_type = libmesh_map_find(_local_side_quad_point_side_types, elem_and_side);
2436
2437 std::vector<std::vector<Real>> phi;
2438 // side_type == 0 --> standard side
2439 // side_type == 1 --> shellface
2440 if (side_type == 0)
2441 {
2442 // TODO: We only want the "dofs on side" entries
2443 // from phi_side. Could do this by initing an FE object
2444 // on the side itself, rather than using get_side_fe().
2445 auto side_fe = con.get_side_fe(/*var=*/ 0);
2446 side_fe->reinit(&elem_ref, side_index);
2447
2448 phi = side_fe->get_phi();
2449 }
2450 else if (side_type == 1)
2451 {
2452 con.elem_fe_reinit();
2453
2454 auto elem_fe = con.get_element_fe(/*var=*/0, elem_ref.dim());
2455 phi = elem_fe->get_phi();
2456 }
2457 else
2458 libmesh_error_msg ("Unrecognized side_type: " << side_type);
2459
2460 for (const auto & comp : index_range(comp_and_qp))
2461 {
2462 const std::vector<Number> & qp_values = comp_and_qp[comp];
2463
2464 for (auto qp : index_range(qp_values))
2465 {
2466 Number value = qp_values[qp];
2467 Real abs_value = std::abs(value);
2468
2469 bool update_optimal_point = false;
2470 if (!eim_point_data)
2471 update_optimal_point = (abs_value > largest_abs_value);
2472 else
2473 update_optimal_point = (elem_id == eim_point_data->elem_id) &&
2474 (side_index == eim_point_data->side_index) &&
2475 (comp == eim_point_data->comp_index) &&
2476 (qp == eim_point_data->qp_index);
2477
2478 if (update_optimal_point)
2479 {
2480 largest_abs_value = abs_value;
2481 optimal_value = value;
2482 optimal_comp = comp;
2483 optimal_elem_id = elem_id;
2484 optimal_side_index = side_index;
2485 optimal_qp = qp;
2486
2487 optimal_point_phi_i_qp.resize(phi.size());
2488 for (auto i : index_range(phi))
2489 optimal_point_phi_i_qp[i] = phi[i][qp];
2490
2491 const auto & point_list =
2492 libmesh_map_find(_local_side_quad_point_locations, elem_and_side);
2493
2494 libmesh_error_msg_if(qp >= point_list.size(), "Error: Invalid qp");
2495
2496 optimal_point = point_list[qp];
2497
2498 optimal_subdomain_id = libmesh_map_find(_local_side_quad_point_subdomain_ids, elem_and_side);
2499 optimal_boundary_id = libmesh_map_find(_local_side_quad_point_boundary_ids, elem_and_side);
2500
2501 if (get_rb_eim_evaluation().get_parametrized_function().requires_xyz_perturbations)
2502 {
2503 const auto & perturb_list =
2504 libmesh_map_find(_local_side_quad_point_locations_perturbations, elem_and_side);
2505
2506 libmesh_error_msg_if(qp >= perturb_list.size(), "Error: Invalid qp");
2507
2508 optimal_point_perturbs = perturb_list[qp];
2509 }
2510 }
2511 }
2512 }
2513 }
2514
2515 // Find out which processor has the largest of the abs values
2516 // and broadcast from that processor.
2517 unsigned int proc_ID_index;
2518 this->comm().maxloc(largest_abs_value, proc_ID_index);
2519
2520 this->comm().broadcast(optimal_value, proc_ID_index);
2521 this->comm().broadcast(optimal_point, proc_ID_index);
2522 this->comm().broadcast(optimal_comp, proc_ID_index);
2523 this->comm().broadcast(optimal_elem_id, proc_ID_index);
2524 this->comm().broadcast(optimal_side_index, proc_ID_index);
2525 this->comm().broadcast(optimal_subdomain_id, proc_ID_index);
2526 this->comm().broadcast(optimal_boundary_id, proc_ID_index);
2527 this->comm().broadcast(optimal_qp, proc_ID_index);
2528 this->comm().broadcast(optimal_point_perturbs, proc_ID_index);
2529 this->comm().broadcast(optimal_point_phi_i_qp, proc_ID_index);
2530
2531 libmesh_error_msg_if(optimal_elem_id == DofObject::invalid_id, "Error: Invalid element ID");
2532
2533 if (add_basis_function)
2534 {
2535 if (optimal_value == 0.)
2536 {
2537 libMesh::out << "Encountered linearly dependent data in EIM enrichment, hence skip adding new basis function" << std::endl;
2538 return true;
2539 }
2540
2541 // Scale local_pf so that its largest value is 1.0
2542 scale_parametrized_function(local_pf, 1./optimal_value);
2543
2544 // Add local_pf as the new basis function and store data
2545 // associated with the interpolation point.
2546 eim_eval.add_side_basis_function(local_pf);
2547 }
2548
2549 eim_eval.add_side_interpolation_data(optimal_point,
2550 optimal_comp,
2551 optimal_elem_id,
2552 optimal_side_index,
2553 optimal_subdomain_id,
2554 optimal_boundary_id,
2555 optimal_qp,
2556 optimal_point_perturbs,
2557 optimal_point_phi_i_qp);
2558
2559 // In this case we did not encounter a linearly dependent basis function, so return false
2560 return false;
2561}
virtual void init_context(FEMContext &)
Pre-request FE data needed for calculations.
std::map< std::pair< dof_id_type, unsigned int >, std::vector< std::vector< Point > > > _local_side_quad_point_locations_perturbations
static Number get_parametrized_function_side_value(const Parallel::Communicator &comm, const SideQpDataMap &pf, dof_id_type elem_id, unsigned int side_index, unsigned int comp, unsigned int qp)
Same as get_parametrized_function_value() except for side data.

References libMesh::RBEIMConstruction::_local_side_quad_point_boundary_ids, libMesh::RBEIMConstruction::_local_side_quad_point_locations, libMesh::RBEIMConstruction::_local_side_quad_point_locations_perturbations, libMesh::RBEIMConstruction::_local_side_quad_point_side_types, libMesh::RBEIMConstruction::_local_side_quad_point_subdomain_ids, libMesh::RBEIMEvaluation::add_side_basis_function(), libMesh::RBEIMEvaluation::add_side_interpolation_data(), libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::EimPointData::comp_index, libMesh::Elem::dim(), libMesh::FEMContext::elem_fe_reinit(), libMesh::EimPointData::elem_id, libMesh::MeshBase::elem_ref(), libMesh::FEMContext::get_element_fe(), libMesh::RBEIMEvaluation::get_interpolation_points_comp(), libMesh::RBEIMEvaluation::get_interpolation_points_elem_id(), libMesh::RBEIMEvaluation::get_interpolation_points_qp(), libMesh::RBEIMEvaluation::get_interpolation_points_side_index(), libMesh::System::get_mesh(), libMesh::RBEIMEvaluation::get_n_basis_functions(), libMesh::RBParametrized::get_parameters(), libMesh::RBEIMEvaluation::get_parametrized_function_side_value(), libMesh::RBEIMConstruction::get_rb_eim_evaluation(), libMesh::FEMContext::get_side_fe(), libMesh::index_range(), libMesh::RBEIMConstruction::init_context(), libMesh::DofObject::invalid_id, libMesh::Parallel::Communicator::maxloc(), libMesh::out, libMesh::FEMContext::pre_fe_reinit(), libMesh::EimPointData::qp_index, libMesh::RBEIMEvaluation::rb_eim_solve(), libMesh::Real, libMesh::RBEIMConstruction::scale_parametrized_function(), libMesh::RBParametrized::set_parameters(), libMesh::RBEIMEvaluation::side_decrement_vector(), libMesh::EimPointData::side_index, and value.

Referenced by libMesh::RBEIMConstruction::enrich_eim_approximation(), and libMesh::RBEIMConstruction::train_eim_approximation_with_POD().

◆ forward_qoi_parameter_sensitivity()

void libMesh::System::forward_qoi_parameter_sensitivity ( const QoISet qoi_indices,
const ParameterVector parameters,
SensitivityData sensitivities 
)
inlinevirtualinherited

Solves for parameter sensitivities using the forward method.

This method is only implemented in some derived classes.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2611 of file system.h.

2614{
2615 libmesh_not_implemented();
2616}

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

◆ generate_training_parameters_deterministic()

std::pair< std::size_t, std::size_t > libMesh::RBConstructionBase< System >::generate_training_parameters_deterministic ( const Parallel::Communicator communicator,
const std::map< std::string, bool > &  log_param_scale,
std::map< std::string, std::vector< RBParameter > > &  local_training_parameters_in,
const unsigned int  n_global_training_samples_in,
const RBParameters min_parameters,
const RBParameters max_parameters,
const bool  serial_training_set = false 
)
staticinherited

Static helper function for generating a deterministic set of parameters.

Only works with 1 or 2 parameters (as defined by the lengths of min/max parameters vectors), otherwise throws an error. The parameter n_global_training_samples_in is the total number of parameters to generate, and they will be split across all the processors (unless serial_training_set=true) in the local_training_parameters_in map.

Returns
a pair of {first_local_index,last_local_index}

Definition at line 217 of file rb_construction_base.C.

579{
580 libmesh_assert_equal_to ( min_parameters.n_parameters(), max_parameters.n_parameters() );
581 const unsigned int num_params = min_parameters.n_parameters();
582
583 if (num_params == 0)
584 return {0,0};
585
586 if (num_params > 3)
587 libmesh_not_implemented_msg("ERROR: Deterministic training sample generation "
588 "not implemented for more than three parameters.");
589
590 // TODO - we don't support vector-data here yet. This would only apply in the case where
591 // min or max are vector-valued, and all the generated points need to stay within those ranges.
592 // But typically we expect that if we're calling this function, we only have 1 min and 1 max,
593 // so the generated values are single-valued as well. The .get_value() calls will throw an error
594 // if this is not the case.
595
596 // Reinitialize training_parameters_in (but don't remove existing keys!)
597 const auto &[n_local_training_samples, first_local_index] =
598 calculate_n_local_samples_and_index(communicator, n_global_training_samples_in,
599 serial_training_set);
600 const auto last_local_index = first_local_index + n_local_training_samples;
601 for (const auto & pr : min_parameters)
602 local_training_parameters_in[pr.first] = std::vector<RBParameter>(n_local_training_samples);
603
604 // n_training_samples_per_param has 3 entries, but entries after "num_params"
605 // are unused so we just set their value to 1. We need to set it to 1 (rather
606 // than 0) so that we don't skip the inner part of the triply-nested loop over
607 // n_training_samples_per_param below.
608 std::vector<unsigned int> n_training_samples_per_param(3);
609 for (unsigned int param=0; param<3; param++)
610 {
611 if (param < num_params)
612 {
613 n_training_samples_per_param[param] =
614 static_cast<unsigned int>( std::round(std::pow(static_cast<Real>(n_global_training_samples_in), 1./num_params)) );
615 }
616 else
617 {
618 n_training_samples_per_param[param] = 1;
619 }
620 }
621
622 {
623 // The current implementation assumes that we have the same number of
624 // samples in each parameter, so we check that n_training_samples_in
625 // is consistent with this assumption.
626 unsigned int total_samples_check = 1;
627 for (unsigned int n_samples : n_training_samples_per_param)
628 {
629 total_samples_check *= n_samples;
630 }
631
632 libmesh_error_msg_if(total_samples_check != n_global_training_samples_in,
633 "Error: Number of training samples = "
634 << n_global_training_samples_in
635 << " does not enable a uniform grid of samples with "
636 << num_params << " parameters. Try "
637 << total_samples_check << " samples instead?");
638 }
639
640 // First we make a list of training samples associated with each parameter,
641 // then we take a tensor product to obtain the final set of training samples.
642 std::vector<std::vector<Real>> training_samples_per_param(num_params);
643 {
644 unsigned int i = 0;
645 for (const auto & pr : min_parameters)
646 {
647 const std::string & param_name = pr.first;
648 const bool use_log_scaling = libmesh_map_find(log_param_scale, param_name);
649 Real min_param = min_parameters.get_value(param_name);
650 Real max_param = max_parameters.get_value(param_name);
651
652 training_samples_per_param[i].resize(n_training_samples_per_param[i]);
653
654 for (unsigned int j=0; j<n_training_samples_per_param[i]; j++)
655 {
656 // Generate log10 scaled training parameters
657 if (use_log_scaling)
658 {
659 Real epsilon = 1.e-6; // Prevent rounding errors triggering asserts
660 Real log_min = std::log10(min_param + epsilon);
661 Real log_range = std::log10( (max_param-epsilon) / (min_param+epsilon) );
662 Real step_size = log_range /
663 std::max((unsigned int)1,(n_training_samples_per_param[i]-1));
664
665 if (j<(n_training_samples_per_param[i]-1))
666 {
667 training_samples_per_param[i][j] = std::pow(10., log_min + j*step_size );
668 }
669 else
670 {
671 // due to rounding error, the last parameter can be slightly
672 // bigger than max_parameters, hence snap back to the max
673 training_samples_per_param[i][j] = max_param;
674 }
675 }
676 else
677 {
678 // Generate linearly scaled training parameters
679 Real step_size = (max_param - min_param) /
680 std::max((unsigned int)1,(n_training_samples_per_param[i]-1));
681 training_samples_per_param[i][j] = j*step_size + min_param;
682 }
683
684 }
685 i++;
686 }
687 }
688
689 // Now load into training_samples_in
690 {
691 std::vector<unsigned int> indices(3);
692 unsigned int index_count = 0;
693 for (indices[0]=0; indices[0]<n_training_samples_per_param[0]; indices[0]++)
694 {
695 for (indices[1]=0; indices[1]<n_training_samples_per_param[1]; indices[1]++)
696 {
697 for (indices[2]=0; indices[2]<n_training_samples_per_param[2]; indices[2]++)
698 {
699 unsigned int param_count = 0;
700 for (const auto & pr : min_parameters)
701 {
702 std::vector<RBParameter> & training_vector =
703 libmesh_map_find(local_training_parameters_in, pr.first);
704 if (first_local_index <= index_count && index_count < last_local_index)
705 training_vector[index_count - first_local_index] =
706 {training_samples_per_param[param_count][indices[param_count]]};
707
708 param_count++;
709 }
710 index_count++;
711 }
712 }
713 }
714 }
715 return {first_local_index, first_local_index+n_local_training_samples};
716}

◆ generate_training_parameters_random()

std::pair< std::size_t, std::size_t > libMesh::RBConstructionBase< System >::generate_training_parameters_random ( const Parallel::Communicator communicator,
const std::map< std::string, bool > &  log_param_scale,
std::map< std::string, std::vector< RBParameter > > &  local_training_parameters_in,
const unsigned int  n_global_training_samples_in,
const RBParameters min_parameters,
const RBParameters max_parameters,
const int  training_parameters_random_seed = -1,
const bool  serial_training_set = false 
)
staticinherited

Static helper function for generating a randomized set of parameters.

The parameter n_global_training_samples_in is the total number of parameters to generate, and they will be split across all the processors (unless serial_training_set=true) in the local_training_parameters_in map.

Returns
a pair of {first_local_index,last_local_index}

Definition at line 199 of file rb_construction_base.C.

480{
481 const unsigned int num_params = min_parameters.n_parameters();
482 libmesh_error_msg_if(num_params!=max_parameters.n_parameters(),
483 "Number of parameters must be identical for min/max.");
484
485 // Clear training_parameters_in
486 local_training_parameters_in.clear();
487
488 if (num_params == 0)
489 return {0,0};
490
491 if (training_parameters_random_seed < 0)
492 {
493 if (!serial_training_set)
494 {
495 // seed the random number generator with the system time
496 // and the processor ID so that the seed is different
497 // on different processors
498 std::srand( static_cast<unsigned>( std::time(0)*(1+communicator.rank()) ));
499 }
500 else
501 {
502 // seed the random number generator with the system time
503 // only so that the seed is the same on all processors
504 //
505 // Note that we broadcast the time on processor 0 to make
506 // sure all processors agree.
507 unsigned int current_time = static_cast<unsigned>( std::time(0) );
508 communicator.broadcast(current_time, 0);
509 std::srand(current_time);
510 }
511 }
512 else
513 {
514 if (!serial_training_set)
515 {
516 // seed the random number generator with the provided value
517 // and the processor ID so that the seed is different
518 // on different processors
519 std::srand( static_cast<unsigned>( training_parameters_random_seed*(1+communicator.rank()) ));
520 }
521 else
522 {
523 // seed the random number generator with the provided value
524 // so that the seed is the same on all processors
525 std::srand( static_cast<unsigned>( training_parameters_random_seed ));
526 }
527 }
528
529 // TODO - we don't support vector-data here yet. This would only apply in the case where
530 // min or max are vector-valued, and all the generated points need to stay within those ranges.
531 // But typically we expect that if we're calling this function, we only have 1 min and 1 max,
532 // so the generated values are single-valued as well. The .get_value() calls will throw an error
533 // if this is not the case.
534
535 // initialize training_parameters_in
536 const auto & [n_local_training_samples, first_local_index] =
537 calculate_n_local_samples_and_index(communicator, n_global_training_samples_in,
538 serial_training_set);
539 for (const auto & pr : min_parameters)
540 local_training_parameters_in[pr.first] = std::vector<RBParameter>(n_local_training_samples);
541
542 // finally, set the values
543 for (auto & [param_name, sample_vector] : local_training_parameters_in)
544 {
545 for (auto i : make_range(n_local_training_samples))
546 {
547 Real random_number = static_cast<Real>(std::rand()) / RAND_MAX; // in range [0,1]
548
549 // Generate log10 scaled training parameters
550 if (libmesh_map_find(log_param_scale, param_name))
551 {
552 Real log_min = std::log10(min_parameters.get_value(param_name));
553 Real log_range = std::log10(max_parameters.get_value(param_name) / min_parameters.get_value(param_name));
554
555 sample_vector[i] = {std::pow(Real(10.), log_min + random_number*log_range )};
556 }
557 // Generate linearly scaled training parameters
558 else
559 {
560 sample_vector[i] = {
561 random_number * (max_parameters.get_value(param_name) -
562 min_parameters.get_value(param_name)) +
563 min_parameters.get_value(param_name)};
564 }
565 }
566 }
567 return {first_local_index, first_local_index+n_local_training_samples};
568}
DIE A HORRIBLE DEATH HERE typedef MPI_Comm communicator

◆ get_abs_training_tolerance()

Real libMesh::RBEIMConstruction::get_abs_training_tolerance ( )
inherited

◆ get_adjoint_rhs() [1/2]

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

Definition at line 1294 of file system.C.

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

References libMesh::System::get_vector().

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

◆ get_adjoint_rhs() [2/2]

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

Definition at line 1304 of file system.C.

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

References libMesh::System::get_vector().

◆ get_adjoint_solution() [1/2]

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

◆ get_adjoint_solution() [2/2]

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

Definition at line 1242 of file system.C.

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

References libMesh::System::get_vector().

◆ get_all_variable_numbers()

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

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

Definition at line 1403 of file system.C.

1404{
1405 this->get_dof_map().get_all_variable_numbers(all_variable_numbers);
1406}
void get_all_variable_numbers(std::vector< unsigned int > &all_variable_numbers) const
Fills all_variable_numbers with all the variable numbers for the variables that have been added to th...
Definition dof_map.C:3389

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

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

◆ get_closest_value()

Real libMesh::RBParametrized::get_closest_value ( Real  value,
const std::vector< Real > &  list_of_values 
)
staticinherited
Returns
The closest entry to value from list_of_values.

Definition at line 432 of file rb_parametrized.C.

433{
434 libmesh_error_msg_if(list_of_values.empty(), "Error: list_of_values is empty.");
435
436 Real min_distance = std::numeric_limits<Real>::max();
437 Real closest_val = 0.;
438 for (const auto & current_value : list_of_values)
439 {
440 Real distance = std::abs(value - current_value);
441 if (distance < min_distance)
442 {
443 min_distance = distance;
444 closest_val = current_value;
445 }
446 }
447
448 return closest_val;
449}
Real distance(const Point &p)

References distance(), libMesh::Real, and value.

Referenced by libMesh::RBParametrized::is_value_in_list().

◆ get_constraint_object()

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

Return the user object for imposing constraints.

Definition at line 2024 of file system.C.

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

◆ get_deterministic_training_parameter_name()

const std::string & libMesh::RBConstructionBase< System >::get_deterministic_training_parameter_name ( ) const
inherited

Get the name of the parameter that we will generate deterministic training parameters for.

◆ get_discrete_parameter_values()

const std::map< std::string, std::vector< Real > > & libMesh::RBParametrized::get_discrete_parameter_values ( ) const
inherited

Get a const reference to the discrete parameter values.

Definition at line 359 of file rb_parametrized.C.

360{
361 libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::get_discrete_parameter_values");
362
364}
std::map< std::string, std::vector< Real > > _discrete_parameter_values
Map that defines the allowable values of any discrete parameters.
bool parameters_initialized
Flag indicating whether the parameters have been initialized.

References libMesh::RBParametrized::_discrete_parameter_values, and libMesh::RBParametrized::parameters_initialized.

Referenced by libMesh::RBDataSerialization::add_parameter_ranges_to_builder(), libMesh::RBParametrized::check_if_valid_params(), libMesh::RBParametrized::get_n_discrete_params(), libMesh::RBParametrized::initialize_parameters(), libMesh::RBParametrized::print_discrete_parameter_values(), and libMesh::RBParametrized::write_discrete_parameter_values_to_file().

◆ get_dof_map() [1/2]

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

Definition at line 2425 of file system.h.

2426{
2427 return *_dof_map;
2428}

References libMesh::System::_dof_map.

◆ get_dof_map() [2/2]

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

Definition at line 2417 of file system.h.

2418{
2419 return *_dof_map;
2420}

References libMesh::System::_dof_map.

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

◆ get_eim_assembly_objects()

std::vector< std::unique_ptr< ElemAssembly > > & libMesh::RBEIMConstruction::get_eim_assembly_objects ( )
inherited
Returns
The vector of assembly objects that point to this RBEIMConstruction.

Definition at line 1160 of file rb_eim_construction.C.

1161{
1163}

References libMesh::RBEIMConstruction::_rb_eim_assembly_objects.

Referenced by main().

◆ get_equation_systems() [1/2]

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

Definition at line 772 of file system.h.

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

References libMesh::System::_equation_systems.

◆ get_equation_systems() [2/2]

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

Definition at line 767 of file system.h.

767{ return _equation_systems; }

References libMesh::System::_equation_systems.

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

◆ get_first_local_training_index()

numeric_index_type libMesh::RBConstructionBase< System >::get_first_local_training_index ( ) const
inherited

Get the first local index of the training parameters.

Definition at line 128 of file rb_construction_base.C.

192{
193 libmesh_error_msg_if(!_training_parameters_initialized,
194 "Error: training parameters must first be initialized.");
195
196 // First we check if there are no parameters here, and in that case we
197 // return 0 for a serial training set and comm().rank() for a parallel
198 // training set. This is consistent with get_n_training_samples(), and
199 // avoids accessing training_parameters.begin() when training_parameters
200 // is empty.
201 if (_training_parameters.empty())
202 {
203 if (serial_training_set)
204 return 0;
205 else
206 return this->comm().rank();
207 }
208
209 return _first_local_index;
210}
processor_id_type rank() const
std::map< std::string, std::vector< RBParameter > > _training_parameters
The training samples for each parameter.
numeric_index_type _first_local_index
The first sample-vector index from the global vector which is stored in the _training_parameters on t...

◆ get_global_max_error_pair()

void libMesh::RBConstructionBase< System >::get_global_max_error_pair ( const Parallel::Communicator communicator,
std::pair< numeric_index_type, Real > &  error_pair 
)
staticprotectedinherited

Static function to return the error pair (index,error) that is corresponds to the largest error on all processors.

Definition at line 255 of file rb_construction_base.C.

136{
137 // Set error_pair.second to the maximum global value and also
138 // find which processor contains the maximum value
139 unsigned int proc_ID_index;
140 communicator.maxloc(error_pair.second, proc_ID_index);
141
142 // Then broadcast error_pair.first from proc_ID_index
143 communicator.broadcast(error_pair.first, proc_ID_index);
144}

◆ get_info() [1/3]

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

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

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

References libMesh::ReferenceCounter::_counts.

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

◆ get_info() [2/3]

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

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

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

References libMesh::ReferenceCounter::_counts.

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

◆ get_info() [3/3]

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

Definition at line 1827 of file system.C.

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

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

Referenced by SystemsTest::testUninitializedInfo().

◆ get_last_local_training_index()

numeric_index_type libMesh::RBConstructionBase< System >::get_last_local_training_index ( ) const
inherited

Get the last local index of the training parameters.

Definition at line 133 of file rb_construction_base.C.

214{
215 libmesh_error_msg_if(!_training_parameters_initialized,
216 "Error: training parameters must first be initialized.");
217
218 if (_training_parameters.empty())
219 return 0;
220
222}

◆ get_local_n_training_samples()

numeric_index_type libMesh::RBConstructionBase< System >::get_local_n_training_samples ( ) const
inherited

Get the total number of training samples local to this processor.

Definition at line 123 of file rb_construction_base.C.

176{
177 libmesh_error_msg_if(!_training_parameters_initialized,
178 "Error: training parameters must first be initialized.");
179
180 // First we check if there are no parameters here, and in that case we
181 // return 1 for both serial and parallel training sets. This is consistent
182 // with get_n_training_samples(), and avoids accessing
183 // training_parameters.begin() when training_parameters is empty.
184 if (_training_parameters.empty())
185 return 1;
186
188}

◆ get_local_quad_point_JxW()

const std::unordered_map< dof_id_type, std::vector< Real > > & libMesh::RBEIMConstruction::get_local_quad_point_JxW ( )
inherited

Get the interior and side quadrature weights.

Definition at line 1341 of file rb_eim_construction.C.

1342{
1343 return _local_quad_point_JxW;
1344}

References libMesh::RBEIMConstruction::_local_quad_point_JxW.

◆ get_local_side_quad_point_JxW()

const std::map< std::pair< dof_id_type, unsigned int >, std::vector< Real > > & libMesh::RBEIMConstruction::get_local_side_quad_point_JxW ( )
inherited

Definition at line 1346 of file rb_eim_construction.C.

1347{
1349}

References libMesh::RBEIMConstruction::_local_side_quad_point_JxW.

◆ get_matrix() [1/2]

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

Definition at line 1118 of file system.C.

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

References libMesh::System::_matrices.

◆ get_matrix() [2/2]

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

◆ get_max_abs_value()

template<class DataMap >
Real libMesh::RBEIMConstruction::get_max_abs_value ( const DataMap &  v) const
inlineprivateinherited

Get the maximum absolute value from a vector stored in the format that we use for basis functions.

Definition at line 394 of file rb_eim_construction.h.

395 {
396 Real max_value = 0.;
397
398 for (const auto & pr : v)
399 {
400 const auto & v_comp_and_qp = pr.second;
401
402 for (const auto & comp : index_range(v_comp_and_qp))
403 {
404 Real comp_scaling = 1.;
405 if (get_rb_eim_evaluation().scale_components_in_enrichment().count(comp))
406 {
407 // Make sure that _component_scaling_in_training_set is initialized
408 libmesh_error_msg_if(comp >= _component_scaling_in_training_set.size(),
409 "Invalid vector index");
410 comp_scaling = _component_scaling_in_training_set[comp];
411 }
412
413 const std::vector<Number> & v_qp = v_comp_and_qp[comp];
414 for (Number value : v_qp)
415 max_value = std::max(max_value, std::abs(value * comp_scaling));
416 }
417 }
418
419 comm().max(max_value);
420 return max_value;
421 }

References libMesh::RBEIMConstruction::_component_scaling_in_training_set, libMesh::ParallelObject::comm(), libMesh::RBEIMConstruction::get_rb_eim_evaluation(), libMesh::index_range(), libMesh::Parallel::Communicator::max(), libMesh::Real, libMesh::RBEIMEvaluation::scale_components_in_enrichment(), and value.

Referenced by libMesh::RBEIMConstruction::compute_max_eim_error().

◆ get_max_abs_value_in_training_set()

Real libMesh::RBEIMConstruction::get_max_abs_value_in_training_set ( ) const
inherited

Get the maximum value (across all processors) from the parametrized functions in the training set.

Definition at line 1232 of file rb_eim_construction.C.

1233{
1235}

References libMesh::RBEIMConstruction::_max_abs_value_in_training_set.

Referenced by libMesh::RBEIMConstruction::train_eim_approximation_with_greedy().

◆ get_mesh() [1/2]

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

Definition at line 2409 of file system.h.

2410{
2411 return _mesh;
2412}

References libMesh::System::_mesh.

◆ get_mesh() [2/2]

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

Definition at line 2401 of file system.h.

2402{
2403 return _mesh;
2404}

References libMesh::System::_mesh.

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

◆ get_n_continuous_params()

unsigned int libMesh::RBParametrized::get_n_continuous_params ( ) const
inherited

Get the number of continuous parameters.

Definition at line 112 of file rb_parametrized.C.

113{
114 libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::get_n_continuous_params");
115
117
118 return static_cast<unsigned int>(get_n_params() - get_n_discrete_params());
119}
unsigned int get_n_discrete_params() const
Get the number of discrete parameters.

References libMesh::RBParametrized::get_n_discrete_params(), libMesh::RBParametrized::get_n_params(), libMesh::libmesh_assert(), and libMesh::RBParametrized::parameters_initialized.

Referenced by libMesh::RBDataSerialization::add_parameter_ranges_to_builder(), and libMesh::RBParametrized::write_parameter_ranges_to_file().

◆ get_n_discrete_params()

unsigned int libMesh::RBParametrized::get_n_discrete_params ( ) const
inherited

Get the number of discrete parameters.

Definition at line 121 of file rb_parametrized.C.

122{
123 libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::get_n_discrete_params");
124
125 return cast_int<unsigned int>
127}

References libMesh::RBParametrized::get_discrete_parameter_values(), and libMesh::RBParametrized::parameters_initialized.

Referenced by libMesh::RBDataSerialization::add_parameter_ranges_to_builder(), libMesh::RBParametrized::get_n_continuous_params(), and libMesh::RBParametrized::write_discrete_parameter_values_to_file().

◆ get_n_parametrized_functions_for_training()

unsigned int libMesh::RBEIMConstruction::get_n_parametrized_functions_for_training ( ) const
inherited

Get the number of parametrized functions used for training.

Definition at line 1351 of file rb_eim_construction.C.

1352{
1353 if (get_rb_eim_evaluation().get_parametrized_function().on_mesh_sides())
1355 else if (get_rb_eim_evaluation().get_parametrized_function().on_mesh_nodes())
1357 else
1359}

References libMesh::RBEIMConstruction::_local_node_parametrized_functions_for_training, libMesh::RBEIMConstruction::_local_parametrized_functions_for_training, libMesh::RBEIMConstruction::_local_side_parametrized_functions_for_training, and libMesh::RBEIMConstruction::get_rb_eim_evaluation().

◆ get_n_params()

unsigned int libMesh::RBParametrized::get_n_params ( ) const
inherited

◆ get_n_training_samples()

numeric_index_type libMesh::RBConstructionBase< System >::get_n_training_samples ( ) const
inherited

Get the number of global training samples.

Definition at line 118 of file rb_construction_base.C.

154{
155 libmesh_error_msg_if(!_training_parameters_initialized,
156 "Error: training parameters must first be initialized.");
157
158 // First we check if there are no parameters here, and in that case we
159 // return 1 since a single training sample is sufficient to generate an
160 // RB approximation if there are no parameters. Note that in parallel,
161 // and when we don't have a serial training set, set return comm().size()
162 // so that each processor is assigned a single (empty) training sample.
163 if (_training_parameters.empty())
164 {
165 if (serial_training_set)
166 return 1;
167 else
168 return this->comm().size();
169 }
170
172}
processor_id_type size() const

◆ get_Nmax()

unsigned int libMesh::RBEIMConstruction::get_Nmax ( ) const
inherited

Get/set Nmax, the maximum number of RB functions we are willing to compute.

Definition at line 1210 of file rb_eim_construction.C.

1211{
1212 return _Nmax;
1213}
unsigned int _Nmax
Maximum number of EIM basis functions we are willing to use.

References libMesh::RBEIMConstruction::_Nmax.

Referenced by libMesh::RBEIMConstruction::print_info(), libMesh::RBEIMConstruction::reinit_eim_projection_matrix(), libMesh::RBEIMConstruction::train_eim_approximation_with_greedy(), and libMesh::RBEIMConstruction::train_eim_approximation_with_POD().

◆ get_node_max_abs_value()

Real libMesh::RBEIMConstruction::get_node_max_abs_value ( const NodeDataMap v) const
privateinherited

Get the maximum absolute value from a vector stored in the format that we use for basis functions.

This case handles NodeDataMap.

Definition at line 2314 of file rb_eim_construction.C.

2315{
2316 Real max_value = 0.;
2317
2318 for (const auto & pr : v)
2319 {
2320 const auto & values = pr.second;
2321 for (const auto & comp : index_range(values))
2322 {
2323 const auto & value = values[comp];
2324
2325 Real comp_scaling = 1.;
2326 if (get_rb_eim_evaluation().scale_components_in_enrichment().count(comp))
2327 {
2328 // Make sure that _component_scaling_in_training_set is initialized
2329 libmesh_error_msg_if(comp >= _component_scaling_in_training_set.size(),
2330 "Invalid vector index");
2331 comp_scaling = _component_scaling_in_training_set[comp];
2332 }
2333
2334 max_value = std::max(max_value, std::abs(value * comp_scaling));
2335 }
2336 }
2337
2338 comm().max(max_value);
2339 return max_value;
2340}

References libMesh::RBEIMConstruction::_component_scaling_in_training_set, libMesh::ParallelObject::comm(), libMesh::RBEIMConstruction::get_rb_eim_evaluation(), libMesh::index_range(), libMesh::Parallel::Communicator::max(), libMesh::Real, libMesh::RBEIMEvaluation::scale_components_in_enrichment(), and value.

Referenced by libMesh::RBEIMConstruction::compute_max_eim_error().

◆ get_node_parametrized_function_from_training_set()

const RBEIMEvaluation::NodeDataMap & libMesh::RBEIMConstruction::get_node_parametrized_function_from_training_set ( unsigned int  training_index) const
inherited

Definition at line 1334 of file rb_eim_construction.C.

1335{
1336 libmesh_error_msg_if(training_index >= _local_node_parametrized_functions_for_training.size(),
1337 "Invalid index: " << training_index);
1339}

References libMesh::RBEIMConstruction::_local_node_parametrized_functions_for_training.

◆ get_parameter_max()

Real libMesh::RBParametrized::get_parameter_max ( const std::string &  param_name) const
inherited

Get maximum allowable value of parameter param_name.

Definition at line 171 of file rb_parametrized.C.

172{
173 libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::get_parameter_max");
174
175 return parameters_max.get_value(param_name);
176}
Real get_value(const std::string &param_name) const
Get the value of the specified parameter, throw an error if it does not exist.

References libMesh::RBParameters::get_value(), libMesh::RBParametrized::parameters_initialized, and libMesh::RBParametrized::parameters_max.

Referenced by libMesh::RBParametrized::check_if_valid_params(), main(), libMesh::RBEIMConstruction::print_info(), libMesh::RBSCMConstruction::print_info(), and libMesh::RBConstruction::print_info().

◆ get_parameter_min()

Real libMesh::RBParametrized::get_parameter_min ( const std::string &  param_name) const
inherited

Get minimum allowable value of parameter param_name.

Definition at line 164 of file rb_parametrized.C.

165{
166 libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::get_parameter_min");
167
168 return parameters_min.get_value(param_name);
169}

References libMesh::RBParameters::get_value(), libMesh::RBParametrized::parameters_initialized, and libMesh::RBParametrized::parameters_min.

Referenced by libMesh::RBParametrized::check_if_valid_params(), main(), libMesh::RBEIMConstruction::print_info(), libMesh::RBSCMConstruction::print_info(), and libMesh::RBConstruction::print_info().

◆ get_parameters()

const RBParameters & libMesh::RBParametrized::get_parameters ( ) const
inherited

Get the current parameters.

Definition at line 143 of file rb_parametrized.C.

144{
145 libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::get_parameters");
146
147 return parameters;
148}
RBParameters parameters
Vector storing the current parameters.

References libMesh::RBParametrized::parameters, and libMesh::RBParametrized::parameters_initialized.

Referenced by libMesh::TransientRBConstruction::add_scaled_mass_matrix(), libMesh::TransientRBEvaluation::cache_online_residual_terms(), libMesh::RBEvaluation::compute_residual_dual_norm(), libMesh::RBSCMConstruction::compute_SCM_bounds_on_training_set(), libMesh::RBSCMConstruction::enrich_C_J(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_nodes(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), libMesh::RBEvaluation::eval_output_dual_norm(), libMesh::RBSCMConstruction::evaluate_stability_constant(), libMesh::RBConstruction::get_RB_error_bound(), libMesh::RBSCMEvaluation::get_SCM_LB(), libMesh::RBSCMEvaluation::get_SCM_UB(), SimpleRBEvaluation::get_stability_lower_bound(), libMesh::RBConstruction::greedy_termination_test(), libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set(), libMesh::RBSCMEvaluation::legacy_read_offline_data_from_files(), main(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::RBConstruction::preevaluate_thetas(), libMesh::RBEIMConstruction::print_info(), libMesh::RBSCMConstruction::print_info(), libMesh::RBConstruction::print_info(), libMesh::RBParametrized::print_parameters(), libMesh::RBSCMConstruction::process_parameters_file(), libMesh::TransientRBEvaluation::rb_solve(), libMesh::RBEvaluation::rb_solve(), libMesh::RBSCMEvaluation::save_current_parameters(), libMesh::RBEIMConstruction::train_eim_approximation_with_greedy(), libMesh::RBEIMConstruction::train_eim_approximation_with_POD(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_solve(), libMesh::TransientRBConstruction::truth_solve(), libMesh::TransientRBEvaluation::uncached_compute_residual_dual_norm(), and libMesh::RBConstruction::update_greedy_param_list().

◆ get_parameters_max()

const RBParameters & libMesh::RBParametrized::get_parameters_max ( ) const
inherited

◆ get_parameters_min()

const RBParameters & libMesh::RBParametrized::get_parameters_min ( ) const
inherited

◆ get_parametrized_function_from_training_set()

const RBEIMEvaluation::QpDataMap & libMesh::RBEIMConstruction::get_parametrized_function_from_training_set ( unsigned int  training_index) const
inherited

Get a const reference to the specified parametrized function from the training set.

Definition at line 1320 of file rb_eim_construction.C.

1321{
1322 libmesh_error_msg_if(training_index >= _local_parametrized_functions_for_training.size(),
1323 "Invalid index: " << training_index);
1324 return _local_parametrized_functions_for_training[training_index];
1325}

References libMesh::RBEIMConstruction::_local_parametrized_functions_for_training.

◆ get_params_from_training_set()

RBParameters libMesh::RBConstructionBase< System >::get_params_from_training_set ( unsigned int  global_index)
protectedinherited

Return the RBParameters in index global_index of the global training set.

Why do we use an index here? RBParameters supports loading the full sample set. This seems probably unnecessary now to load individually. Maybe it's a memory issue?

Definition at line 238 of file rb_construction_base.C.

232{
233 libmesh_error_msg_if(!_training_parameters_initialized,
234 "Error: training parameters must first be initialized.");
235
236 // If the _training_parameters are empty, return an empty RBParameters.
237 // Otherwise, create a new RBParameters object from the single sample requested.
238 RBParameters params;
239 if (!_training_parameters.empty())
240 {
241 libmesh_error_msg_if((global_index < this->get_first_local_training_index()) ||
242 (global_index >= this->get_last_local_training_index()),
243 "Error: index "
244 << global_index
245 << " must be within range: "
247 << " - "
249
250 const numeric_index_type local_index = global_index - get_first_local_training_index();
251 for (const auto & [param_name, sample_vector] : _training_parameters)
252 params.set_value(param_name, sample_vector[local_index]);
253
254 // Copy all extra values into the new RBParameters.
255 // We assume that the samples may be indexed differently for extra parameters,
256 // so we don't just copy the local_index value.
257 const auto & mine = get_parameters();
258 for (const auto & [key, extra_sample_vector] :
259 as_range(mine.extra_begin(), mine.extra_end()))
260 {
261 for (const auto idx : index_range(extra_sample_vector))
262 params.set_extra_value(key, idx, extra_sample_vector[idx]);
263 }
264 }
265
266 return params;
267}
numeric_index_type get_first_local_training_index() const
Get the first local index of the training parameters.
numeric_index_type get_last_local_training_index() const
Get the last local index of the training parameters.
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.
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
Helper function that allows us to treat a homogenous pair as a range.
dof_id_type numeric_index_type
Definition id_types.h:99

◆ get_project_with_constraints()

bool libMesh::System::get_project_with_constraints ( )
inlineinherited

Setter and getter functions for project_with_constraints boolean.

Definition at line 1837 of file system.h.

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

References libMesh::System::project_with_constraints.

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

◆ get_qoi_error_estimate_value()

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

Definition at line 2211 of file system.C.

2212{
2213 libmesh_assert(qoi_index < _qoi_error_estimates.size());
2214 return _qoi_error_estimates[qoi_index];
2215}
std::vector< Number > _qoi_error_estimates
Vector to hold error estimates for qois, either from a steady state calculation, or from a single uns...
Definition system.h:2377

References libMesh::libmesh_assert().

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

◆ get_qoi_value()

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

◆ get_qoi_values()

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

◆ get_random_int_0_to_n()

unsigned int libMesh::RBEIMConstruction::get_random_int_0_to_n ( unsigned int  n)
staticprivateinherited

Static helper function that is used by get_random_point().

Definition at line 3091 of file rb_eim_construction.C.

3092{
3093 // std::random_device seed;
3094 // std::mt19937 gen{seed()};
3095 // We do not use a random seed here, since we generally prefer our results
3096 // to reproducible, rather than fully random. If desired we could provide an
3097 // option to use the random seed approach (commented out above).
3098 std::default_random_engine gen;
3099 std::uniform_int_distribution<> dist{0, static_cast<int>(n)};
3100 return dist(gen);
3101}

Referenced by libMesh::RBEIMConstruction::get_random_point(), libMesh::RBEIMConstruction::get_random_point(), and libMesh::RBEIMConstruction::get_random_point().

◆ get_random_point() [1/3]

EimPointData libMesh::RBEIMConstruction::get_random_point ( const NodeDataMap v)
privateinherited

Definition at line 3289 of file rb_eim_construction.C.

3290{
3291 EimPointData eim_point_data;
3292
3293 // If we have more than one process, then we need to do a parallel union
3294 // of v to make sure that we have data from all processors. Our approach
3295 // here is to set v_ptr to either v or global_v, depending on whether we
3296 // are in parallel or serial. The purpose of this approach is to avoid
3297 // making a copy of v in the case that this is a serial job.
3298 NodeDataMap const * v_ptr = nullptr;
3299 NodeDataMap global_v;
3300 if (comm().size() > 1)
3301 {
3302 global_v = v;
3303
3304 // We only use global_v on proc 0, so we set the second argument of
3305 // set_union() to zero here to indicate that we only need the result
3306 // on proc 0.
3307 comm().set_union(global_v, 0);
3308 v_ptr = &global_v;
3309 }
3310 else
3311 {
3312 v_ptr = &v;
3313 }
3314
3315 bool error_finding_new_node = false;
3316 if (comm().rank() == 0)
3317 {
3318 const VectorizedEvalInput & vec_eval_input = get_rb_eim_evaluation().get_vec_eval_input();
3319
3320 {
3321 std::set<dof_id_type> previous_node_ids(vec_eval_input.node_ids.begin(), vec_eval_input.node_ids.end());
3322
3323 // See discussion above in the QpDataMap case for the justification
3324 // of how we set up new_node_ids below.
3325 std::set<dof_id_type> new_node_ids;
3326 for (const auto & v_pair : *v_ptr)
3327 if (previous_node_ids.count(v_pair.first) == 0)
3328 new_node_ids.insert(v_pair.first);
3329
3330 // If new_node_ids is empty then we set error_finding_new_node
3331 // to true. We then broadcast the value of error_finding_new_node to all
3332 // processors below in order to ensure that all processors agree on whether
3333 // or not there was an error.
3334 error_finding_new_node = (new_node_ids.empty());
3335
3336 if (!error_finding_new_node)
3337 {
3338 unsigned int random_node_idx = get_random_int_0_to_n(new_node_ids.size()-1);
3339
3340 auto item = new_node_ids.begin();
3341 std::advance(item, random_node_idx);
3342 eim_point_data.node_id = *item;
3343 }
3344 }
3345
3346 if (!error_finding_new_node)
3347 {
3348 const auto & vars = libmesh_map_find(*v_ptr,eim_point_data.node_id);
3349 eim_point_data.comp_index = get_random_int_0_to_n(vars.size()-1);
3350 }
3351 }
3352
3353 comm().broadcast(error_finding_new_node);
3354 libmesh_error_msg_if(error_finding_new_node, "Could not find new node in get_random_point()");
3355
3356 // Broadcast the values computed above from rank 0
3357 comm().broadcast(eim_point_data.node_id);
3358 comm().broadcast(eim_point_data.comp_index);
3359
3360 return eim_point_data;
3361}
void set_union(T &data, const unsigned int root_id) const
static unsigned int get_random_int_0_to_n(unsigned int n)
Static helper function that is used by get_random_point().
const VectorizedEvalInput & get_vec_eval_input() const
Get the VectorizedEvalInput data.

References libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::EimPointData::comp_index, libMesh::RBEIMConstruction::get_random_int_0_to_n(), libMesh::RBEIMConstruction::get_rb_eim_evaluation(), libMesh::RBEIMEvaluation::get_vec_eval_input(), libMesh::EimPointData::node_id, libMesh::VectorizedEvalInput::node_ids, and libMesh::Parallel::Communicator::set_union().

◆ get_random_point() [2/3]

EimPointData libMesh::RBEIMConstruction::get_random_point ( const QpDataMap v)
privateinherited

Helper function that identifies a random EIM point from v.

Definition at line 3103 of file rb_eim_construction.C.

3104{
3105 EimPointData eim_point_data;
3106
3107 // If we have more than one process, then we need to do a parallel union
3108 // of v to make sure that we have data from all processors. Our approach
3109 // here is to set v_ptr to either v or global_v, depending on whether we
3110 // are in parallel or serial. The purpose of this approach is to avoid
3111 // making a copy of v in the case that this is a serial job.
3112 QpDataMap const * v_ptr = nullptr;
3113 QpDataMap global_v;
3114 if (comm().size() > 1)
3115 {
3116 global_v = v;
3117
3118 // We only use global_v on proc 0, so we set the second argument of
3119 // set_union() to zero here to indicate that we only need the result
3120 // on proc 0.
3121 comm().set_union(global_v, 0);
3122 v_ptr = &global_v;
3123 }
3124 else
3125 {
3126 v_ptr = &v;
3127 }
3128
3129 bool error_finding_new_element = false;
3130 if (comm().rank() == 0)
3131 {
3132 const VectorizedEvalInput & vec_eval_input = get_rb_eim_evaluation().get_vec_eval_input();
3133
3134 {
3135 std::set<dof_id_type> previous_elem_ids(vec_eval_input.elem_ids.begin(), vec_eval_input.elem_ids.end());
3136
3137 // We ensure that we select a point that has not been selected previously
3138 // by setting up new_elem_ids to contain only elements that are not in
3139 // previous_elem_ids, and then selecting the elem_id at random from new_elem_ids.
3140 // We give an error if there are no elements in new_elem_ids. This is potentially
3141 // an overzealous assertion since we could pick an element that has already
3142 // been selected as long as we pick a (comp_index, qp_index) that has not already
3143 // been selected for that element.
3144 //
3145 // However, in general we do not expect all elements to be selected in the EIM
3146 // training, so it is reasonable to use the simple assertion below. Moreover, by
3147 // ensuring that we choose a new element we should typically ensure that the
3148 // randomly selected point has some separation from the previous EIM points, which
3149 // is typically desirable if we want EIM evaluations that are independent from
3150 // the EIM points (e.g. for EIM error indicator purposes).
3151 std::set<dof_id_type> new_elem_ids;
3152 for (const auto & v_pair : *v_ptr)
3153 if (previous_elem_ids.count(v_pair.first) == 0)
3154 new_elem_ids.insert(v_pair.first);
3155
3156 // If new_elem_ids is empty then we set error_finding_new_element to true.
3157 // We then broadcast the value of error_finding_new_element to all processors
3158 // below in order to ensure that all processors agree on whether or not
3159 // there was an error.
3160 error_finding_new_element = (new_elem_ids.empty());
3161
3162 if (!error_finding_new_element)
3163 {
3164 unsigned int random_elem_idx = get_random_int_0_to_n(new_elem_ids.size()-1);
3165
3166 auto item = new_elem_ids.begin();
3167 std::advance(item, random_elem_idx);
3168 eim_point_data.elem_id = *item;
3169 }
3170 }
3171
3172 if (!error_finding_new_element)
3173 {
3174 {
3175 const auto & vars_and_qps = libmesh_map_find(*v_ptr,eim_point_data.elem_id);
3176 eim_point_data.comp_index = get_random_int_0_to_n(vars_and_qps.size()-1);
3177 }
3178
3179 {
3180 const auto & qps = libmesh_map_find(*v_ptr,eim_point_data.elem_id)[eim_point_data.comp_index];
3181 eim_point_data.qp_index = get_random_int_0_to_n(qps.size()-1);
3182 }
3183 }
3184 }
3185
3186 comm().broadcast(error_finding_new_element);
3187 libmesh_error_msg_if(error_finding_new_element, "Could not find new element in get_random_point()");
3188
3189 // Broadcast the values computed above from rank 0
3190 comm().broadcast(eim_point_data.elem_id);
3191 comm().broadcast(eim_point_data.comp_index);
3192 comm().broadcast(eim_point_data.qp_index);
3193
3194 return eim_point_data;
3195}

References libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::EimPointData::comp_index, libMesh::EimPointData::elem_id, libMesh::VectorizedEvalInput::elem_ids, libMesh::RBEIMConstruction::get_random_int_0_to_n(), libMesh::RBEIMConstruction::get_rb_eim_evaluation(), libMesh::RBEIMEvaluation::get_vec_eval_input(), libMesh::EimPointData::qp_index, and libMesh::Parallel::Communicator::set_union().

Referenced by libMesh::RBEIMConstruction::get_random_point_from_training_sample(), and libMesh::RBEIMConstruction::train_eim_approximation_with_POD().

◆ get_random_point() [3/3]

EimPointData libMesh::RBEIMConstruction::get_random_point ( const SideQpDataMap v)
privateinherited

Definition at line 3197 of file rb_eim_construction.C.

3198{
3199 EimPointData eim_point_data;
3200
3201 // If we have more than one process, then we need to do a parallel union
3202 // of v to make sure that we have data from all processors. Our approach
3203 // here is to set v_ptr to either v or global_v, depending on whether we
3204 // are in parallel or serial. The purpose of this approach is to avoid
3205 // making a copy of v in the case that this is a serial job.
3206 SideQpDataMap const * v_ptr = nullptr;
3207 SideQpDataMap global_v;
3208 if (comm().size() > 1)
3209 {
3210 global_v = v;
3211
3212 // We only use global_v on proc 0, so we set the second argument of
3213 // set_union() to zero here to indicate that we only need the result
3214 // on proc 0.
3215 comm().set_union(global_v, 0);
3216 v_ptr = &global_v;
3217 }
3218 else
3219 {
3220 v_ptr = &v;
3221 }
3222
3223 bool error_finding_new_element_and_side = false;
3224 if (comm().rank() == 0)
3225 {
3226 const VectorizedEvalInput & vec_eval_input = get_rb_eim_evaluation().get_vec_eval_input();
3227
3228 std::pair<dof_id_type,unsigned int> elem_and_side;
3229 {
3230 std::set<std::pair<dof_id_type,unsigned int>> previous_elem_and_side_ids;
3231 for (const auto idx : index_range(vec_eval_input.elem_ids))
3232 {
3233 previous_elem_and_side_ids.insert(
3234 std::make_pair(vec_eval_input.elem_ids[idx],
3235 vec_eval_input.side_indices[idx]));
3236 }
3237
3238 // See discussion above in the QpDataMap case for the justification
3239 // of how we set up new_elem_and_side_ids below.
3240 std::set<std::pair<dof_id_type,unsigned int>> new_elem_and_side_ids;
3241 for (const auto & v_pair : *v_ptr)
3242 if (previous_elem_and_side_ids.count(v_pair.first) == 0)
3243 new_elem_and_side_ids.insert(v_pair.first);
3244
3245 // If new_elem_and_side_ids is empty then we set error_finding_new_element_and_side
3246 // to true. We then broadcast the value of error_finding_new_element_and_side to all
3247 // processors below in order to ensure that all processors agree on whether
3248 // or not there was an error.
3249 error_finding_new_element_and_side = (new_elem_and_side_ids.empty());
3250
3251 if (!error_finding_new_element_and_side)
3252 {
3253 unsigned int random_elem_and_side_idx = get_random_int_0_to_n(new_elem_and_side_ids.size()-1);
3254
3255 auto item = new_elem_and_side_ids.begin();
3256 std::advance(item, random_elem_and_side_idx);
3257 elem_and_side = *item;
3258 eim_point_data.elem_id = elem_and_side.first;
3259 eim_point_data.side_index = elem_and_side.second;
3260 }
3261 }
3262
3263 if (!error_finding_new_element_and_side)
3264 {
3265 {
3266 const auto & vars_and_qps = libmesh_map_find(*v_ptr,elem_and_side);
3267 eim_point_data.comp_index = get_random_int_0_to_n(vars_and_qps.size()-1);
3268 }
3269
3270 {
3271 const auto & qps = libmesh_map_find(*v_ptr,elem_and_side)[eim_point_data.comp_index];
3272 eim_point_data.qp_index = get_random_int_0_to_n(qps.size()-1);
3273 }
3274 }
3275 }
3276
3277 comm().broadcast(error_finding_new_element_and_side);
3278 libmesh_error_msg_if(error_finding_new_element_and_side, "Could not find new (element,side) in get_random_point()");
3279
3280 // Broadcast the values computed above from rank 0
3281 comm().broadcast(eim_point_data.elem_id);
3282 comm().broadcast(eim_point_data.side_index);
3283 comm().broadcast(eim_point_data.comp_index);
3284 comm().broadcast(eim_point_data.qp_index);
3285
3286 return eim_point_data;
3287}

References libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::EimPointData::comp_index, libMesh::EimPointData::elem_id, libMesh::VectorizedEvalInput::elem_ids, libMesh::RBEIMConstruction::get_random_int_0_to_n(), libMesh::RBEIMConstruction::get_rb_eim_evaluation(), libMesh::RBEIMEvaluation::get_vec_eval_input(), libMesh::index_range(), libMesh::EimPointData::qp_index, libMesh::Parallel::Communicator::set_union(), libMesh::EimPointData::side_index, and libMesh::VectorizedEvalInput::side_indices.

◆ get_random_point_from_training_sample()

EimPointData libMesh::RBEIMConstruction::get_random_point_from_training_sample ( )
privateinherited

◆ get_rb_eim_evaluation() [1/2]

RBEIMEvaluation & libMesh::RBEIMConstruction::get_rb_eim_evaluation ( )
inherited

Get a reference to the RBEvaluation object.

Definition at line 157 of file rb_eim_construction.C.

158{
159 libmesh_error_msg_if(!_rb_eim_eval, "Error: RBEIMEvaluation object hasn't been initialized yet");
160 return *_rb_eim_eval;
161}
RBEIMEvaluation * _rb_eim_eval
The RBEIMEvaluation object that we use to perform the EIM training.

References libMesh::RBEIMConstruction::_rb_eim_eval.

Referenced by libMesh::RBEIMConstruction::apply_normalization_to_solution_snapshots(), libMesh::RBEIMConstruction::compute_max_eim_error(), libMesh::RBEIMConstruction::enrich_eim_approximation(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_nodes(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), libMesh::RBEIMAssembly::evaluate_basis_function(), libMesh::RBEIMAssembly::evaluate_node_basis_function(), libMesh::RBEIMAssembly::evaluate_side_basis_function(), libMesh::RBEIMConstruction::get_max_abs_value(), libMesh::RBEIMConstruction::get_n_parametrized_functions_for_training(), libMesh::RBEIMConstruction::get_node_max_abs_value(), libMesh::RBEIMConstruction::get_random_point(), libMesh::RBEIMConstruction::get_random_point(), libMesh::RBEIMConstruction::get_random_point(), libMesh::RBEIMConstruction::get_random_point_from_training_sample(), libMesh::RBEIMConstruction::initialize_eim_assembly_objects(), libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set(), libMesh::RBEIMConstruction::initialize_qp_data(), libMesh::RBEIMConstruction::reinit_eim_projection_matrix(), libMesh::RBEIMConstruction::set_rb_construction_parameters(), libMesh::RBEIMConstruction::store_eim_solutions_for_training_set(), libMesh::RBEIMConstruction::train_eim_approximation_with_greedy(), libMesh::RBEIMConstruction::train_eim_approximation_with_POD(), and libMesh::RBEIMConstruction::update_eim_matrices().

◆ get_rb_eim_evaluation() [2/2]

const RBEIMEvaluation & libMesh::RBEIMConstruction::get_rb_eim_evaluation ( ) const
inherited

Get a const reference to the RBEvaluation object.

Definition at line 163 of file rb_eim_construction.C.

164{
165 libmesh_error_msg_if(!_rb_eim_eval, "Error: RBEIMEvaluation object hasn't been initialized yet");
166 return *_rb_eim_eval;
167}

References libMesh::RBEIMConstruction::_rb_eim_eval.

◆ get_rel_training_tolerance()

Real libMesh::RBEIMConstruction::get_rel_training_tolerance ( )
inherited

◆ get_sensitivity_rhs() [1/2]

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

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

Definition at line 1324 of file system.C.

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

References libMesh::System::get_vector().

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

◆ get_sensitivity_rhs() [2/2]

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

Definition at line 1334 of file system.C.

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

References libMesh::System::get_vector().

◆ get_sensitivity_solution() [1/2]

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

Definition at line 1179 of file system.C.

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

References libMesh::System::get_vector().

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

◆ get_sensitivity_solution() [2/2]

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

Definition at line 1189 of file system.C.

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

References libMesh::System::get_vector().

◆ get_side_parametrized_function_from_training_set()

const RBEIMEvaluation::SideQpDataMap & libMesh::RBEIMConstruction::get_side_parametrized_function_from_training_set ( unsigned int  training_index) const
inherited

Definition at line 1327 of file rb_eim_construction.C.

1328{
1329 libmesh_error_msg_if(training_index >= _local_side_parametrized_functions_for_training.size(),
1330 "Invalid index: " << training_index);
1332}

References libMesh::RBEIMConstruction::_local_side_parametrized_functions_for_training.

◆ get_vector() [1/4]

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

Definition at line 958 of file system.C.

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

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

◆ get_vector() [2/4]

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

Definition at line 945 of file system.C.

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

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

◆ get_vector() [3/4]

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

Definition at line 938 of file system.C.

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

References libMesh::System::_vectors.

◆ get_vector() [4/4]

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

Definition at line 931 of file system.C.

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

References libMesh::System::_vectors.

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

◆ get_weighted_sensitivity_adjoint_solution() [1/2]

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

Definition at line 1264 of file system.C.

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

References libMesh::System::get_vector().

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

◆ get_weighted_sensitivity_adjoint_solution() [2/2]

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

Definition at line 1274 of file system.C.

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

References libMesh::System::get_vector().

◆ get_weighted_sensitivity_solution() [1/2]

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

Definition at line 1206 of file system.C.

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

References libMesh::System::get_vector().

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

◆ get_weighted_sensitivity_solution() [2/2]

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

Definition at line 1213 of file system.C.

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

References libMesh::System::get_vector().

◆ has_constraint_object()

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

Definition at line 2019 of file system.C.

2020{
2021 return _constrain_system_object != nullptr;
2022}

◆ has_static_condensation()

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

◆ has_variable()

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

Definition at line 1393 of file system.C.

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

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

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

◆ have_matrix()

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

Definition at line 1933 of file system.h.

1933{ return _matrices.count(mat_name); }

References libMesh::System::_matrices.

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

◆ have_vector()

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

Definition at line 2491 of file system.h.

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

References libMesh::System::_vectors.

◆ hide_output()

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

Definition at line 1852 of file system.h.

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

References libMesh::System::_hide_output.

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

◆ identify_variable_groups() [1/2]

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

Definition at line 2684 of file system.C.

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

◆ identify_variable_groups() [2/2]

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

Toggle automatic VariableGroup identification.

Definition at line 2689 of file system.C.

2690{
2692}

◆ increment_constructor_count() [1/2]

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

Increments the construction counter.

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

Definition at line 183 of file reference_counter.h.

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

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

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

◆ increment_constructor_count() [2/2]

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

Increments the construction counter.

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

Definition at line 183 of file reference_counter.h.

184{
185 libmesh_try
186 {
187 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
188 std::pair<unsigned int, unsigned int> & p = _counts[name];
189 p.first++;
190 }
191 libmesh_catch (...)
192 {
193 auto stream = libMesh::err.get();
194 stream->exceptions(stream->goodbit); // stream must not throw
195 libMesh::err << "Encountered unrecoverable error while calling "
196 << "ReferenceCounter::increment_constructor_count() "
197 << "for a(n) " << name << " object." << std::endl;
198 std::terminate();
199 }
200}

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

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

◆ increment_destructor_count() [1/2]

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

Increments the destruction counter.

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

Definition at line 207 of file reference_counter.h.

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

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

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

◆ increment_destructor_count() [2/2]

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

Increments the destruction counter.

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

Definition at line 207 of file reference_counter.h.

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

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

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

◆ init()

void libMesh::System::init ( )
inherited

Initializes degrees of freedom on the current mesh.

Sets the

Definition at line 196 of file system.C.

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

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

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

◆ init_context()

void libMesh::RBEIMConstruction::init_context ( FEMContext c)
virtualinherited

Pre-request FE data needed for calculations.

Definition at line 1165 of file rb_eim_construction.C.

1166{
1167 // Pre-request FE data for all element dimensions present in the
1168 // mesh. Note: we currently pre-request FE data for all variables
1169 // in the current system but in some cases that may be overkill, for
1170 // example if only variable 0 is used.
1171 const System & sys = c.get_system();
1172 const MeshBase & mesh = sys.get_mesh();
1173
1174 for (unsigned int dim=1; dim<=3; ++dim)
1175 if (mesh.elem_dimensions().count(dim))
1176 for (auto var : make_range(sys.n_vars()))
1177 {
1178 auto fe = c.get_element_fe(var, dim);
1179 fe->get_JxW();
1180 fe->get_xyz();
1181 fe->get_phi();
1182
1183 auto side_fe = c.get_side_fe(var, dim);
1184 side_fe->get_JxW();
1185 side_fe->get_xyz();
1186 side_fe->get_phi();
1187 }
1188}
System(EquationSystems &es, const std::string &name, const unsigned int number)
Constructor.
Definition system.C:64
MeshBase & mesh

References dim, libMesh::FEMContext::get_element_fe(), libMesh::System::get_mesh(), libMesh::FEMContext::get_side_fe(), libMesh::DiffContext::get_system(), libMesh::make_range(), mesh, and libMesh::System::n_vars().

Referenced by libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), and libMesh::RBEIMConstruction::initialize_qp_data().

◆ init_data() [1/2]

virtual void SimpleEIMConstruction::init_data ( )
inlinevirtual

Initialize data structures.

Reimplemented from libMesh::RBConstructionBase< System >.

Definition at line 58 of file eim_classes.h.

59 {
60 this->add_variable ("eim_var", libMesh::FIRST);
61
62 RBEIMConstruction::init_data();
63 }

References libMesh::System::add_variable(), and libMesh::FIRST.

◆ init_data() [2/2]

virtual void SimpleEIMConstruction::init_data ( )
inlinevirtual

Initialize data structures.

Reimplemented from libMesh::RBConstructionBase< System >.

Definition at line 64 of file eim_classes.h.

65 {
66 this->add_variable ("eim_var", libMesh::FIRST);
67
68 RBEIMConstruction::init_data();
69 }

References libMesh::System::add_variable(), and libMesh::FIRST.

◆ init_matrices()

void libMesh::System::init_matrices ( )
protectedvirtualinherited

Initializes the matrices associated with this system.

Reimplemented in libMesh::EigenSystem.

Definition at line 311 of file system.C.

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

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

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

◆ init_qois()

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

Accessors for qoi and qoi_error_estimates vectors.

Definition at line 2169 of file system.C.

2170{
2171 _qoi.resize(n_qois);
2173}
unsigned int n_qois() const
Number of currently active quantities of interest.
Definition system.h:2562

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

◆ initialize_eim_assembly_objects()

void libMesh::RBEIMConstruction::initialize_eim_assembly_objects ( )
virtualinherited

Build a vector of ElemAssembly objects that accesses the basis functions stored in this RBEIMConstruction object.

This is useful for performing the Offline stage of the Reduced Basis method where we want to use assembly functions based on this EIM approximation.

Definition at line 1153 of file rb_eim_construction.C.

1154{
1156 for (auto i : make_range(get_rb_eim_evaluation().get_n_basis_functions()))
1158}
virtual std::unique_ptr< ElemAssembly > build_eim_assembly(unsigned int bf_index)=0
Build an element assembly object that will access basis function bf_index.

References libMesh::RBEIMConstruction::_rb_eim_assembly_objects, libMesh::RBEIMConstruction::build_eim_assembly(), libMesh::RBEIMConstruction::get_rb_eim_evaluation(), and libMesh::make_range().

Referenced by main().

◆ initialize_eim_construction()

void libMesh::RBEIMConstruction::initialize_eim_construction ( )
inherited

Perform initialization of this object to prepare for running train_eim_approximation().

Definition at line 226 of file rb_eim_construction.C.

227{
229}
void initialize_parametrized_functions_in_training_set()
Compute and store the parametrized function for each parameter in the training set at all the stored ...

References libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set().

Referenced by main().

◆ initialize_parameters() [1/2]

void libMesh::RBParametrized::initialize_parameters ( const RBParameters mu_min_in,
const RBParameters mu_max_in,
const std::map< std::string, std::vector< Real > > &  discrete_parameter_values 
)
inherited

Initialize the parameter ranges and set current_parameters.

Parameter ranges are inclusive. The input min/max RBParameters should have exactly 1 sample each. Vector-valued samples are not currently supported for the min/max parameters or for discrete parameters.

Definition at line 53 of file rb_parametrized.C.

56{
57 // Check that the min/max vectors have the same size.
58 libmesh_error_msg_if(mu_min_in.n_parameters() != mu_max_in.n_parameters(),
59 "Error: Invalid mu_min/mu_max in initialize_parameters(), different number of parameters.");
60 libmesh_error_msg_if(mu_min_in.n_samples() != 1 ||
61 mu_max_in.n_samples() != 1,
62 "Error: Invalid mu_min/mu_max in initialize_parameters(), only 1 sample supported.");
63
64 // Ensure all the values are valid for min and max.
65 auto pr_min = mu_min_in.begin_serialized();
66 auto pr_max = mu_max_in.begin_serialized();
67 for (; pr_min != mu_min_in.end_serialized(); ++pr_min, ++pr_max)
68 libmesh_error_msg_if((*pr_min).second > (*pr_max).second,
69 "Error: Invalid mu_min/mu_max in RBParameters constructor.");
70
71 parameters_min = mu_min_in;
72 parameters_max = mu_max_in;
73
74 // Add in min/max values due to the discrete parameters
75 for (const auto & [name, vals] : discrete_parameter_values)
76 {
77 libmesh_error_msg_if(vals.empty(), "Error: List of discrete parameters for " << name << " is empty.");
78
79 Real min_val = *std::min_element(vals.begin(), vals.end());
80 Real max_val = *std::max_element(vals.begin(), vals.end());
81
82 libmesh_assert_less_equal(min_val, max_val);
83
84 parameters_min.set_value(name, min_val);
85 parameters_max.set_value(name, max_val);
86 }
87
88 _discrete_parameter_values = discrete_parameter_values;
89
91
92 // Initialize the current parameters to parameters_min
94}
void set_value(const std::string &param_name, Real value)
Set the value of the specified parameter.

References libMesh::RBParametrized::_discrete_parameter_values, libMesh::RBParameters::begin_serialized(), libMesh::RBParameters::end_serialized(), libMesh::RBParameters::n_parameters(), libMesh::RBParameters::n_samples(), libMesh::RBParametrized::parameters_initialized, libMesh::RBParametrized::parameters_max, libMesh::RBParametrized::parameters_min, libMesh::Real, libMesh::RBParametrized::set_parameters(), and libMesh::RBParameters::set_value().

Referenced by libMesh::RBConstruction::enrich_basis_from_rhs_terms(), libMesh::RBParametrized::initialize_parameters(), libMesh::RBDataDeserialization::load_parameter_ranges(), libMesh::RBSCMConstruction::perform_SCM_greedy(), libMesh::RBSCMConstruction::process_parameters_file(), libMesh::RBParametrized::read_parameter_data_from_files(), libMesh::RBConstruction::set_rb_construction_parameters(), libMesh::RBEIMConstruction::set_rb_construction_parameters(), RBParametersTest::testRBParametrized(), libMesh::RBEIMConstruction::train_eim_approximation_with_greedy(), libMesh::RBEIMConstruction::train_eim_approximation_with_POD(), libMesh::RBConstruction::train_reduced_basis_with_greedy(), and libMesh::RBConstruction::train_reduced_basis_with_POD().

◆ initialize_parameters() [2/2]

void libMesh::RBParametrized::initialize_parameters ( const RBParametrized rb_parametrized)
inherited

Initialize the parameter ranges and set current_parameters.

Definition at line 96 of file rb_parametrized.C.

97{
98 initialize_parameters(rb_parametrized.get_parameters_min(),
99 rb_parametrized.get_parameters_max(),
100 rb_parametrized.get_discrete_parameter_values());
101}
void initialize_parameters(const RBParameters &mu_min_in, const RBParameters &mu_max_in, const std::map< std::string, std::vector< Real > > &discrete_parameter_values)
Initialize the parameter ranges and set current_parameters.

References libMesh::RBParametrized::get_discrete_parameter_values(), libMesh::RBParametrized::get_parameters_max(), libMesh::RBParametrized::get_parameters_min(), and libMesh::RBParametrized::initialize_parameters().

◆ initialize_parametrized_functions_in_training_set()

void libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set ( )
privateinherited

Compute and store the parametrized function for each parameter in the training set at all the stored qp locations.

Definition at line 1556 of file rb_eim_construction.C.

1557{
1558 LOG_SCOPE("initialize_parametrized_functions_in_training_set()", "RBEIMConstruction");
1559
1560 libmesh_error_msg_if(!serial_training_set,
1561 "Error: We must have serial_training_set==true in "
1562 "RBEIMConstruction::initialize_parametrized_functions_in_training_set");
1563
1564 libMesh::out << "Initializing parametrized functions in training set..." << std::endl;
1565
1566 RBEIMEvaluation & eim_eval = get_rb_eim_evaluation();
1567
1568 if (eim_eval.get_parametrized_function().is_lookup_table)
1569 eim_eval.get_parametrized_function().initialize_lookup_table();
1570
1571 // Store the locations of all quadrature points
1573
1574 // Keep track of the largest value in our parametrized functions
1575 // in the training set. We can use this value for normalization
1576 // purposes, for example.
1578
1579 unsigned int n_comps = eim_eval.get_parametrized_function().get_n_components();
1580
1581 // Keep track of the maximum value per component. This will allow
1582 // us to scale the components to all have a similar magnitude,
1583 // which is helpful during the error assessment for the basis
1584 // enrichment to ensure that components with smaller magnitude
1585 // are not ignored.
1586 std::vector<Real> max_abs_value_per_component_in_training_set(n_comps);
1587
1588 if (eim_eval.get_parametrized_function().on_mesh_sides())
1589 {
1591 for (auto i : make_range(get_n_training_samples()))
1592 {
1593 libMesh::out << "Initializing parametrized function for training sample "
1594 << (i+1) << " of " << get_n_training_samples() << std::endl;
1595
1597
1598 eim_eval.get_parametrized_function().preevaluate_parametrized_function_on_mesh_sides(get_parameters(),
1604 *this);
1605
1606 for (const auto & [elem_side_pair, xyz_vector] : _local_side_quad_point_locations)
1607 {
1608 std::vector<std::vector<Number>> comps_and_qps(n_comps);
1609 for (unsigned int comp=0; comp<n_comps; comp++)
1610 {
1611 comps_and_qps[comp].resize(xyz_vector.size());
1612 for (unsigned int qp : index_range(xyz_vector))
1613 {
1614 Number value =
1615 eim_eval.get_parametrized_function().lookup_preevaluated_side_value_on_mesh(comp,
1616 elem_side_pair.first,
1617 elem_side_pair.second,
1618 qp);
1619 comps_and_qps[comp][qp] = value;
1620
1621 Real abs_value = std::abs(value);
1622 if (abs_value > _max_abs_value_in_training_set)
1623 {
1626 }
1627
1628 if (abs_value > max_abs_value_per_component_in_training_set[comp])
1629 max_abs_value_per_component_in_training_set[comp] = abs_value;
1630 }
1631 }
1632
1633 _local_side_parametrized_functions_for_training[i][elem_side_pair] = comps_and_qps;
1634 }
1635 }
1636
1637 libMesh::out << "Parametrized functions in training set initialized" << std::endl;
1638
1639 unsigned int max_id = 0;
1642 libMesh::out << "Maximum absolute value in the training set: "
1643 << _max_abs_value_in_training_set << std::endl << std::endl;
1644
1645 // Calculate the maximum value for each component in the training set
1646 // across all components
1647 comm().max(max_abs_value_per_component_in_training_set);
1648
1649 // We store the maximum value across all components divided by the maximum value for this component
1650 // so that when we scale using these factors all components should have a magnitude on the same
1651 // order as the maximum component.
1652 _component_scaling_in_training_set.resize(n_comps);
1653 for (unsigned int i : make_range(n_comps))
1654 {
1655 if ((eim_eval.scale_components_in_enrichment().count(i) == 0) ||
1656 max_abs_value_per_component_in_training_set[i] == 0.)
1658 else
1659 _component_scaling_in_training_set[i] = _max_abs_value_in_training_set / max_abs_value_per_component_in_training_set[i];
1660 }
1661 }
1662 else if (eim_eval.get_parametrized_function().on_mesh_nodes())
1663 {
1665 for (auto i : make_range(get_n_training_samples()))
1666 {
1667 libMesh::out << "Initializing parametrized function for training sample "
1668 << (i+1) << " of " << get_n_training_samples() << std::endl;
1669
1671
1672 eim_eval.get_parametrized_function().preevaluate_parametrized_function_on_mesh_nodes(get_parameters(),
1675 *this);
1676
1677 for (const auto & pr : _local_node_locations)
1678 {
1679 const auto & node_id = pr.first;
1680
1681 std::vector<Number> comps(n_comps);
1682 for (unsigned int comp=0; comp<n_comps; comp++)
1683 {
1684 Number value =
1685 eim_eval.get_parametrized_function().lookup_preevaluated_node_value_on_mesh(comp,
1686 node_id);
1687 comps[comp] = value;
1688
1689 Real abs_value = std::abs(value);
1690 if (abs_value > _max_abs_value_in_training_set)
1691 {
1694 }
1695
1696 if (abs_value > max_abs_value_per_component_in_training_set[comp])
1697 max_abs_value_per_component_in_training_set[comp] = abs_value;
1698 }
1699
1701 }
1702 }
1703
1704 libMesh::out << "Parametrized functions in training set initialized" << std::endl;
1705
1706 unsigned int max_id = 0;
1709 libMesh::out << "Maximum absolute value in the training set: "
1710 << _max_abs_value_in_training_set << std::endl << std::endl;
1711
1712 // Calculate the maximum value for each component in the training set
1713 // across all components
1714 comm().max(max_abs_value_per_component_in_training_set);
1715
1716 // We store the maximum value across all components divided by the maximum value for this component
1717 // so that when we scale using these factors all components should have a magnitude on the same
1718 // order as the maximum component.
1719 _component_scaling_in_training_set.resize(n_comps);
1720 for (unsigned int i : make_range(n_comps))
1721 {
1722 if ((eim_eval.scale_components_in_enrichment().count(i) == 0) ||
1723 max_abs_value_per_component_in_training_set[i] == 0.)
1725 else
1726 _component_scaling_in_training_set[i] = _max_abs_value_in_training_set / max_abs_value_per_component_in_training_set[i];
1727 }
1728 }
1729 else
1730 {
1732 for (auto i : make_range(get_n_training_samples()))
1733 {
1734 libMesh::out << "Initializing parametrized function for training sample "
1735 << (i+1) << " of " << get_n_training_samples() << std::endl;
1736
1738
1739 eim_eval.get_parametrized_function().preevaluate_parametrized_function_on_mesh(get_parameters(),
1743 *this);
1744
1745 for (const auto & [elem_id, xyz_vector] : _local_quad_point_locations)
1746 {
1747 std::vector<std::vector<Number>> comps_and_qps(n_comps);
1748 for (unsigned int comp=0; comp<n_comps; comp++)
1749 {
1750 comps_and_qps[comp].resize(xyz_vector.size());
1751 for (unsigned int qp : index_range(xyz_vector))
1752 {
1753 Number value =
1754 eim_eval.get_parametrized_function().lookup_preevaluated_value_on_mesh(comp, elem_id, qp);
1755 comps_and_qps[comp][qp] = value;
1756
1757 Real abs_value = std::abs(value);
1758 if (abs_value > _max_abs_value_in_training_set)
1759 {
1762 }
1763
1764 if (abs_value > max_abs_value_per_component_in_training_set[comp])
1765 max_abs_value_per_component_in_training_set[comp] = abs_value;
1766 }
1767 }
1768
1769 _local_parametrized_functions_for_training[i][elem_id] = comps_and_qps;
1770 }
1771 }
1772
1773 libMesh::out << "Parametrized functions in training set initialized" << std::endl;
1774
1775 unsigned int max_id = 0;
1778 libMesh::out << "Maximum absolute value in the training set: "
1779 << _max_abs_value_in_training_set << std::endl << std::endl;
1780
1781 // Calculate the maximum value for each component in the training set
1782 // across all components
1783 comm().max(max_abs_value_per_component_in_training_set);
1784
1785 // We store the maximum value across all components divided by the maximum value for this component
1786 // so that when we scale using these factors all components should have a magnitude on the same
1787 // order as the maximum component.
1788 _component_scaling_in_training_set.resize(n_comps);
1789 for (unsigned int i : make_range(n_comps))
1790 {
1791 if ((eim_eval.scale_components_in_enrichment().count(i) == 0) ||
1792 max_abs_value_per_component_in_training_set[i] == 0.)
1794 else
1795 _component_scaling_in_training_set[i] = _max_abs_value_in_training_set / max_abs_value_per_component_in_training_set[i];
1796 }
1797 }
1798 // This function does nothing if rb_property_map from RBParametrizedFunction
1799 // is empty which would result in an empty rb_property_map in VectorizedEvalInput
1800 // stored in RBEIMEvaluation.
1801 eim_eval.initialize_rb_property_map();
1802}
bool serial_training_set
This boolean flag indicates whether or not the training set should be the same on all processors.
void initialize_qp_data()
Initialize the data associated with each quad point (location, JxW, etc.) so that we can use this in ...

References libMesh::RBEIMConstruction::_component_scaling_in_training_set, libMesh::RBEIMConstruction::_local_node_boundary_ids, libMesh::RBEIMConstruction::_local_node_locations, libMesh::RBEIMConstruction::_local_node_parametrized_functions_for_training, libMesh::RBEIMConstruction::_local_parametrized_functions_for_training, libMesh::RBEIMConstruction::_local_quad_point_locations, libMesh::RBEIMConstruction::_local_quad_point_locations_perturbations, libMesh::RBEIMConstruction::_local_quad_point_subdomain_ids, libMesh::RBEIMConstruction::_local_side_parametrized_functions_for_training, libMesh::RBEIMConstruction::_local_side_quad_point_boundary_ids, libMesh::RBEIMConstruction::_local_side_quad_point_locations, libMesh::RBEIMConstruction::_local_side_quad_point_locations_perturbations, libMesh::RBEIMConstruction::_local_side_quad_point_side_types, libMesh::RBEIMConstruction::_local_side_quad_point_subdomain_ids, libMesh::RBEIMConstruction::_max_abs_value_in_training_set, libMesh::RBEIMConstruction::_max_abs_value_in_training_set_index, libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::RBParametrizedFunction::get_n_components(), libMesh::RBConstructionBase< System >::get_n_training_samples(), libMesh::RBParametrized::get_parameters(), libMesh::RBEIMEvaluation::get_parametrized_function(), libMesh::RBEIMConstruction::get_rb_eim_evaluation(), libMesh::index_range(), libMesh::RBParametrizedFunction::initialize_lookup_table(), libMesh::RBEIMConstruction::initialize_qp_data(), libMesh::RBEIMEvaluation::initialize_rb_property_map(), libMesh::RBParametrizedFunction::is_lookup_table, libMesh::RBParametrizedFunction::lookup_preevaluated_node_value_on_mesh(), libMesh::RBParametrizedFunction::lookup_preevaluated_side_value_on_mesh(), libMesh::RBParametrizedFunction::lookup_preevaluated_value_on_mesh(), libMesh::make_range(), libMesh::Parallel::Communicator::max(), libMesh::Parallel::Communicator::maxloc(), libMesh::RBParametrizedFunction::on_mesh_nodes(), libMesh::RBParametrizedFunction::on_mesh_sides(), libMesh::out, libMesh::RBParametrizedFunction::preevaluate_parametrized_function_on_mesh(), libMesh::RBParametrizedFunction::preevaluate_parametrized_function_on_mesh_nodes(), libMesh::RBParametrizedFunction::preevaluate_parametrized_function_on_mesh_sides(), libMesh::Real, libMesh::RBEIMEvaluation::scale_components_in_enrichment(), libMesh::RBConstructionBase< System >::serial_training_set, libMesh::RBConstructionBase< System >::set_params_from_training_set(), and value.

Referenced by libMesh::RBEIMConstruction::initialize_eim_construction().

◆ initialize_qp_data()

void libMesh::RBEIMConstruction::initialize_qp_data ( )
privateinherited

Initialize the data associated with each quad point (location, JxW, etc.) so that we can use this in evaluation of the parametrized functions.

Definition at line 1804 of file rb_eim_construction.C.

1805{
1806 LOG_SCOPE("initialize_qp_data()", "RBEIMConstruction");
1807
1808 if (!get_rb_eim_evaluation().get_parametrized_function().requires_xyz_perturbations)
1809 {
1810 libMesh::out << "Initializing quadrature point locations" << std::endl;
1811 }
1812 else
1813 {
1814 libMesh::out << "Initializing quadrature point and perturbation locations" << std::endl;
1815 }
1816
1817 // Compute truth representation via L2 projection
1818 const MeshBase & mesh = this->get_mesh();
1819
1820 FEMContext context(*this);
1821 init_context(context);
1822
1823 if (get_rb_eim_evaluation().get_parametrized_function().on_mesh_sides())
1824 {
1825 const std::set<boundary_id_type> & parametrized_function_boundary_ids =
1827 libmesh_error_msg_if (parametrized_function_boundary_ids.empty(),
1828 "Need to have non-empty boundary IDs to initialize side data");
1829
1835
1837
1838 // BoundaryInfo and related data structures
1839 const auto & binfo = mesh.get_boundary_info();
1840 std::vector<boundary_id_type> side_boundary_ids;
1841
1842 for (const auto & elem : mesh.active_local_element_ptr_range())
1843 {
1844 dof_id_type elem_id = elem->id();
1845
1846 context.pre_fe_reinit(*this, elem);
1847
1848 // elem_fe is used for shellface data
1849 auto elem_fe = context.get_element_fe(/*var=*/0, elem->dim());
1850 const std::vector<Real> & JxW = elem_fe->get_JxW();
1851 const std::vector<Point> & xyz = elem_fe->get_xyz();
1852
1853 // side_fe is used for element side data
1854 auto side_fe = context.get_side_fe(/*var=*/0, elem->dim());
1855 const std::vector<Real> & JxW_side = side_fe->get_JxW();
1856 const std::vector< Point > & xyz_side = side_fe->get_xyz();
1857
1858 for (context.side = 0;
1859 context.side != context.get_elem().n_sides();
1860 ++context.side)
1861 {
1862 // skip non-boundary elements
1863 if(!context.get_elem().neighbor_ptr(context.side))
1864 {
1865 binfo.boundary_ids(elem, context.side, side_boundary_ids);
1866
1867 bool has_side_boundary_id = false;
1868 boundary_id_type matching_boundary_id = BoundaryInfo::invalid_id;
1869 for (boundary_id_type side_boundary_id : side_boundary_ids)
1870 if(parametrized_function_boundary_ids.count(side_boundary_id))
1871 {
1872 has_side_boundary_id = true;
1873 matching_boundary_id = side_boundary_id;
1874 break;
1875 }
1876
1877 if(has_side_boundary_id)
1878 {
1879 context.get_side_fe(/*var=*/0, elem->dim())->reinit(elem, context.side);
1880
1881 auto elem_side_pair = std::make_pair(elem_id, context.side);
1882
1883 _local_side_quad_point_locations[elem_side_pair] = xyz_side;
1884 _local_side_quad_point_JxW[elem_side_pair] = JxW_side;
1885 _local_side_quad_point_subdomain_ids[elem_side_pair] = elem->subdomain_id();
1886 _local_side_quad_point_boundary_ids[elem_side_pair] = matching_boundary_id;
1887
1888 // This is a standard side (not a shellface) so set side type to 0
1889 _local_side_quad_point_side_types[elem_side_pair] = 0;
1890
1891 if (get_rb_eim_evaluation().get_parametrized_function().requires_xyz_perturbations)
1892 {
1894
1895 std::vector<std::vector<Point>> xyz_perturb_vec_at_qps;
1896
1897 for (const Point & xyz_qp : xyz_side)
1898 {
1899 std::vector<Point> xyz_perturb_vec;
1900 if (elem->dim() == 3)
1901 {
1902 // In this case we have a 3D element, and hence the side is 2D.
1903 //
1904 // We use the following approach to perturb xyz:
1905 // 1) inverse map xyz to the reference element
1906 // 2) perturb on the reference element in the (xi,eta) "directions"
1907 // 3) map the perturbed points back to the physical element
1908 // This approach is necessary to ensure that the perturbed points
1909 // are still in the element's side.
1910
1911 std::unique_ptr<const Elem> elem_side;
1912 elem->build_side_ptr(elem_side, context.side);
1913
1914 Point xi_eta =
1915 FEMap::inverse_map(elem_side->dim(),
1916 elem_side.get(),
1917 xyz_qp,
1918 /*Newton iteration tolerance*/ TOLERANCE,
1919 /*secure*/ true);
1920
1921 // Inverse map should map back to a 2D reference domain
1922 libmesh_assert(std::abs(xi_eta(2)) < TOLERANCE);
1923
1924 Point xi_eta_perturb = xi_eta;
1925
1926 xi_eta_perturb(0) += fd_delta;
1927 Point xyz_perturb_0 =
1928 FEMap::map(elem_side->dim(),
1929 elem_side.get(),
1930 xi_eta_perturb);
1931 xi_eta_perturb(0) -= fd_delta;
1932
1933 xi_eta_perturb(1) += fd_delta;
1934 Point xyz_perturb_1 =
1935 FEMap::map(elem_side->dim(),
1936 elem_side.get(),
1937 xi_eta_perturb);
1938 xi_eta_perturb(1) -= fd_delta;
1939
1940 // Finally, we rescale xyz_perturb_0 and xyz_perturb_1 so that
1941 // (xyz_perturb - xyz_qp).norm() == fd_delta, since this is
1942 // required in order to compute finite differences correctly.
1943 Point unit_0 = (xyz_perturb_0-xyz_qp).unit();
1944 Point unit_1 = (xyz_perturb_1-xyz_qp).unit();
1945
1946 xyz_perturb_vec.emplace_back(xyz_qp + fd_delta*unit_0);
1947 xyz_perturb_vec.emplace_back(xyz_qp + fd_delta*unit_1);
1948 }
1949 else
1950 {
1951 // We current do nothing for sides of dim=2 or dim=1 elements
1952 // since we have no need for this capability so far.
1953 // Support for these cases could be added if it is needed.
1954 }
1955
1956 xyz_perturb_vec_at_qps.emplace_back(xyz_perturb_vec);
1957 }
1958
1959 _local_side_quad_point_locations_perturbations[elem_side_pair] = xyz_perturb_vec_at_qps;
1960 }
1961 }
1962 }
1963 }
1964
1965 // In the case of 2D elements, we also check the shellfaces
1966 if (elem->dim() == 2)
1967 for (unsigned int shellface_index=0; shellface_index<2; shellface_index++)
1968 {
1969 binfo.shellface_boundary_ids(elem, shellface_index, side_boundary_ids);
1970
1971 bool has_side_boundary_id = false;
1972 boundary_id_type matching_boundary_id = BoundaryInfo::invalid_id;
1973 for (boundary_id_type side_boundary_id : side_boundary_ids)
1974 if(parametrized_function_boundary_ids.count(side_boundary_id))
1975 {
1976 has_side_boundary_id = true;
1977 matching_boundary_id = side_boundary_id;
1978 break;
1979 }
1980
1981 if(has_side_boundary_id)
1982 {
1983 context.elem_fe_reinit();
1984
1985 // We use shellface_index as the side_index since shellface boundary conditions
1986 // are stored separately from side boundary conditions in BoundaryInfo.
1987 auto elem_side_pair = std::make_pair(elem_id, shellface_index);
1988
1989 _local_side_quad_point_locations[elem_side_pair] = xyz;
1990 _local_side_quad_point_JxW[elem_side_pair] = JxW;
1991 _local_side_quad_point_subdomain_ids[elem_side_pair] = elem->subdomain_id();
1992 _local_side_quad_point_boundary_ids[elem_side_pair] = matching_boundary_id;
1993
1994 // This is a shellface (not a standard side) so set side type to 1
1995 _local_side_quad_point_side_types[elem_side_pair] = 1;
1996
1997 if (get_rb_eim_evaluation().get_parametrized_function().requires_xyz_perturbations)
1998 {
2000
2001 std::vector<std::vector<Point>> xyz_perturb_vec_at_qps;
2002
2003 for (const Point & xyz_qp : xyz)
2004 {
2005 std::vector<Point> xyz_perturb_vec;
2006 // Here we follow the same approach as above for getting xyz_perturb_vec,
2007 // except that we are using the element itself instead of its side.
2008 {
2009 Point xi_eta =
2010 FEMap::inverse_map(elem->dim(),
2011 elem,
2012 xyz_qp,
2013 /*Newton iteration tolerance*/ TOLERANCE,
2014 /*secure*/ true);
2015
2016 // Inverse map should map back to a 2D reference domain
2017 libmesh_assert(std::abs(xi_eta(2)) < TOLERANCE);
2018
2019 Point xi_eta_perturb = xi_eta;
2020
2021 xi_eta_perturb(0) += fd_delta;
2022 Point xyz_perturb_0 =
2023 FEMap::map(elem->dim(),
2024 elem,
2025 xi_eta_perturb);
2026 xi_eta_perturb(0) -= fd_delta;
2027
2028 xi_eta_perturb(1) += fd_delta;
2029 Point xyz_perturb_1 =
2030 FEMap::map(elem->dim(),
2031 elem,
2032 xi_eta_perturb);
2033 xi_eta_perturb(1) -= fd_delta;
2034
2035 // Finally, we rescale xyz_perturb_0 and xyz_perturb_1 so that
2036 // (xyz_perturb - xyz_qp).norm() == fd_delta, since this is
2037 // required in order to compute finite differences correctly.
2038 Point unit_0 = (xyz_perturb_0-xyz_qp).unit();
2039 Point unit_1 = (xyz_perturb_1-xyz_qp).unit();
2040
2041 xyz_perturb_vec.emplace_back(xyz_qp + fd_delta*unit_0);
2042 xyz_perturb_vec.emplace_back(xyz_qp + fd_delta*unit_1);
2043 }
2044
2045 xyz_perturb_vec_at_qps.emplace_back(xyz_perturb_vec);
2046 }
2047
2048 _local_side_quad_point_locations_perturbations[elem_side_pair] = xyz_perturb_vec_at_qps;
2049 }
2050 }
2051 }
2052 }
2053 }
2055 {
2056 const std::set<boundary_id_type> & parametrized_function_boundary_ids =
2058 libmesh_error_msg_if (parametrized_function_boundary_ids.empty(),
2059 "Need to have non-empty boundary IDs to initialize node data");
2060
2061 _local_node_locations.clear();
2063
2064 const auto & binfo = mesh.get_boundary_info();
2065
2066 // Make a set with all the nodes that have nodesets. Use
2067 // a set so that we don't have any duplicate entries. We
2068 // deal with duplicate entries below by getting all boundary
2069 // IDs on each node.
2070 std::set<dof_id_type> nodes_with_nodesets;
2071 for (const auto & t : binfo.build_node_list())
2072 nodes_with_nodesets.insert(std::get<0>(t));
2073
2074 // To be filled in by BoundaryInfo calls in loop below
2075 std::vector<boundary_id_type> node_boundary_ids;
2076
2077 for (dof_id_type node_id : nodes_with_nodesets)
2078 {
2079 const Node * node = mesh.node_ptr(node_id);
2080
2081 if (node->processor_id() != mesh.comm().rank())
2082 continue;
2083
2084 binfo.boundary_ids(node, node_boundary_ids);
2085
2086 bool has_node_boundary_id = false;
2087 boundary_id_type matching_boundary_id = BoundaryInfo::invalid_id;
2088 for (boundary_id_type node_boundary_id : node_boundary_ids)
2089 if(parametrized_function_boundary_ids.count(node_boundary_id))
2090 {
2091 has_node_boundary_id = true;
2092 matching_boundary_id = node_boundary_id;
2093 break;
2094 }
2095
2096 if(has_node_boundary_id)
2097 {
2098 _local_node_locations[node_id] = *node;
2099 _local_node_boundary_ids[node_id] = matching_boundary_id;
2100 }
2101 }
2102 }
2103 else
2104 {
2107 _local_quad_point_JxW.clear();
2108
2110
2111 for (const auto & elem : mesh.active_local_element_ptr_range())
2112 {
2113 auto elem_fe = context.get_element_fe(/*var=*/0, elem->dim());
2114 const std::vector<Real> & JxW = elem_fe->get_JxW();
2115 const std::vector<Point> & xyz = elem_fe->get_xyz();
2116
2117 dof_id_type elem_id = elem->id();
2118
2119 context.pre_fe_reinit(*this, elem);
2120 context.elem_fe_reinit();
2121
2122 _local_quad_point_locations[elem_id] = xyz;
2123 _local_quad_point_JxW[elem_id] = JxW;
2124 _local_quad_point_subdomain_ids[elem_id] = elem->subdomain_id();
2125
2126 if (get_rb_eim_evaluation().get_parametrized_function().requires_xyz_perturbations)
2127 {
2129
2130 std::vector<std::vector<Point>> xyz_perturb_vec_at_qps;
2131
2132 for (const Point & xyz_qp : xyz)
2133 {
2134 std::vector<Point> xyz_perturb_vec;
2135 if (elem->dim() == 3)
2136 {
2137 Point xyz_perturb = xyz_qp;
2138
2139 xyz_perturb(0) += fd_delta;
2140 xyz_perturb_vec.emplace_back(xyz_perturb);
2141 xyz_perturb(0) -= fd_delta;
2142
2143 xyz_perturb(1) += fd_delta;
2144 xyz_perturb_vec.emplace_back(xyz_perturb);
2145 xyz_perturb(1) -= fd_delta;
2146
2147 xyz_perturb(2) += fd_delta;
2148 xyz_perturb_vec.emplace_back(xyz_perturb);
2149 xyz_perturb(2) -= fd_delta;
2150 }
2151 else if (elem->dim() == 2)
2152 {
2153 // In this case we assume that we have a 2D element
2154 // embedded in 3D space. In this case we have to use
2155 // the following approach to perturb xyz:
2156 // 1) inverse map xyz to the reference element
2157 // 2) perturb on the reference element in the (xi,eta) "directions"
2158 // 3) map the perturbed points back to the physical element
2159 // This approach is necessary to ensure that the perturbed points
2160 // are still in the element.
2161
2162 Point xi_eta =
2163 FEMap::inverse_map(elem->dim(),
2164 elem,
2165 xyz_qp,
2166 /*Newton iteration tolerance*/ TOLERANCE,
2167 /*secure*/ true);
2168
2169 // Inverse map should map back to a 2D reference domain
2170 libmesh_assert(std::abs(xi_eta(2)) < TOLERANCE);
2171
2172 Point xi_eta_perturb = xi_eta;
2173
2174 xi_eta_perturb(0) += fd_delta;
2175 Point xyz_perturb_0 =
2176 FEMap::map(elem->dim(),
2177 elem,
2178 xi_eta_perturb);
2179 xi_eta_perturb(0) -= fd_delta;
2180
2181 xi_eta_perturb(1) += fd_delta;
2182 Point xyz_perturb_1 =
2183 FEMap::map(elem->dim(),
2184 elem,
2185 xi_eta_perturb);
2186 xi_eta_perturb(1) -= fd_delta;
2187
2188 // Finally, we rescale xyz_perturb_0 and xyz_perturb_1 so that
2189 // (xyz_perturb - xyz_qp).norm() == fd_delta, since this is
2190 // required in order to compute finite differences correctly.
2191 Point unit_0 = (xyz_perturb_0-xyz_qp).unit();
2192 Point unit_1 = (xyz_perturb_1-xyz_qp).unit();
2193
2194 xyz_perturb_vec.emplace_back(xyz_qp + fd_delta*unit_0);
2195 xyz_perturb_vec.emplace_back(xyz_qp + fd_delta*unit_1);
2196 }
2197 else
2198 {
2199 // We current do nothing in the dim=1 case since
2200 // we have no need for this capability so far.
2201 // Support for this case could be added if it is
2202 // needed.
2203 }
2204
2205 xyz_perturb_vec_at_qps.emplace_back(xyz_perturb_vec);
2206 }
2207
2208 _local_quad_point_locations_perturbations[elem_id] = xyz_perturb_vec_at_qps;
2209 }
2210 }
2211 }
2212}
static const boundary_id_type invalid_id
Number used for internal use.
static Point map(const unsigned int dim, const Elem *elem, const Point &reference_point)
Definition fe_map.C:1954
static Point inverse_map(const unsigned int dim, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true, const bool extra_checks=true)
Definition fe_map.C:1512
RBParametrizedFunction & get_parametrized_function()
Get a reference to the parametrized function.
Real fd_delta
The finite difference step size in the case that this function in the case that this function uses fi...
const std::set< boundary_id_type > & get_parametrized_function_boundary_ids() const
For RBParametrizedFunctions defined on element sides or nodes, we get/set the boundary IDs that this ...
const boundary_id_type node_boundary_id

References libMesh::RBEIMConstruction::_local_node_boundary_ids, libMesh::RBEIMConstruction::_local_node_locations, libMesh::RBEIMConstruction::_local_quad_point_JxW, libMesh::RBEIMConstruction::_local_quad_point_locations, libMesh::RBEIMConstruction::_local_quad_point_locations_perturbations, libMesh::RBEIMConstruction::_local_quad_point_subdomain_ids, libMesh::RBEIMConstruction::_local_side_quad_point_boundary_ids, libMesh::RBEIMConstruction::_local_side_quad_point_JxW, libMesh::RBEIMConstruction::_local_side_quad_point_locations, libMesh::RBEIMConstruction::_local_side_quad_point_locations_perturbations, libMesh::RBEIMConstruction::_local_side_quad_point_side_types, libMesh::RBEIMConstruction::_local_side_quad_point_subdomain_ids, libMesh::FEMContext::elem_fe_reinit(), libMesh::RBParametrizedFunction::fd_delta, libMesh::FEMContext::get_elem(), libMesh::FEMContext::get_element_fe(), libMesh::System::get_mesh(), libMesh::RBEIMEvaluation::get_parametrized_function(), libMesh::RBParametrizedFunction::get_parametrized_function_boundary_ids(), libMesh::RBEIMConstruction::get_rb_eim_evaluation(), libMesh::FEMContext::get_side_fe(), libMesh::RBEIMConstruction::init_context(), libMesh::BoundaryInfo::invalid_id, libMesh::FEMap::inverse_map(), libMesh::libmesh_assert(), libMesh::FEMap::map(), mesh, libMesh::Elem::n_sides(), libMesh::Elem::neighbor_ptr(), node_boundary_id, libMesh::RBParametrizedFunction::on_mesh_nodes(), libMesh::out, libMesh::FEMContext::pre_fe_reinit(), libMesh::DofObject::processor_id(), libMesh::Real, libMesh::System::reinit(), libMesh::RBParametrizedFunction::requires_xyz_perturbations, libMesh::FEMContext::side, and libMesh::TOLERANCE.

Referenced by libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set().

◆ initialize_training_parameters()

void libMesh::RBConstructionBase< System >::initialize_training_parameters ( const RBParameters mu_min,
const RBParameters mu_max,
const unsigned int  n_global_training_samples,
const std::map< std::string, bool > &  log_param_scale,
const bool  deterministic = true 
)
virtualinherited

Initialize the parameter ranges and indicate whether deterministic or random training parameters should be used and whether or not we want the parameters to be scaled logarithmically.

n_global_training_samples is the total number of samples to generate, which will be distributed across all the processors.

Definition at line 142 of file rb_construction_base.C.

297{
298 if (!is_quiet())
299 {
300 // Print out some info about the training set initialization
301 libMesh::out << "Initializing training parameters with "
302 << (deterministic ? "deterministic " : "random " )
303 << "training set..." << std::endl;
304
305 for (const auto & pr : log_param_scale)
306 libMesh::out << "Parameter "
307 << pr.first
308 << ": log scaling = "
309 << pr.second
310 << std::endl;
311
312 libMesh::out << std::endl;
313 }
314
315 if (deterministic)
316 {
317 const auto [first_local_index, last_local_index] =
319 log_param_scale,
320 _training_parameters,
321 n_global_training_samples,
322 mu_min,
323 mu_max,
324 serial_training_set);
325 _first_local_index = first_local_index;
326 _n_local_training_samples = last_local_index-first_local_index;
327 }
328 else
329 {
330 // Generate random training samples for all parameters
331 const auto [first_local_index, last_local_index] =
333 log_param_scale,
334 _training_parameters,
335 n_global_training_samples,
336 mu_min,
337 mu_max,
338 this->_training_parameters_random_seed,
339 serial_training_set);
340 _first_local_index = first_local_index;
341 _n_local_training_samples = last_local_index-first_local_index;
342 }
344
345 if (!serial_training_set)
346 this->comm().sum(_n_global_training_samples);
347
348 // For each parameter that only allows discrete values, we "snap" to the nearest
349 // allowable discrete value
350 if (get_n_discrete_params() > 0)
351 {
352 for (auto & [param_name, sample_vector] : _training_parameters)
353 {
354 if (is_discrete_parameter(param_name))
355 {
356 const std::vector<Real> & discrete_values =
357 libmesh_map_find(get_discrete_parameter_values(), param_name);
358
359 for (const auto sample_idx : index_range(sample_vector))
360 {
361 // Round all values to the closest discrete value.
362 std::vector<Real> discretized_vector(sample_vector[sample_idx].size());
363 std::transform(sample_vector[sample_idx].cbegin(),
364 sample_vector[sample_idx].cend(),
365 discretized_vector.begin(),
366 [&discrete_values](const Real & val) {
367 return get_closest_value(val, discrete_values);
368 });
369 sample_vector[sample_idx] = discretized_vector;
370 }
371 }
372 }
373 }
374
376}
bool _training_parameters_initialized
Boolean flag to indicate whether or not the parameter ranges have been initialized.
static std::pair< std::size_t, std::size_t > generate_training_parameters_random(const Parallel::Communicator &communicator, const std::map< std::string, bool > &log_param_scale, std::map< std::string, std::vector< RBParameter > > &local_training_parameters_in, const unsigned int n_global_training_samples_in, const RBParameters &min_parameters, const RBParameters &max_parameters, const int training_parameters_random_seed=-1, const bool serial_training_set=false)
Static helper function for generating a randomized set of parameters.
static std::pair< std::size_t, std::size_t > generate_training_parameters_deterministic(const Parallel::Communicator &communicator, const std::map< std::string, bool > &log_param_scale, std::map< std::string, std::vector< RBParameter > > &local_training_parameters_in, const unsigned int n_global_training_samples_in, const RBParameters &min_parameters, const RBParameters &max_parameters, const bool serial_training_set=false)
Static helper function for generating a deterministic set of parameters.
bool is_quiet() const
Is the system in quiet mode?
bool is_discrete_parameter(const std::string &mu_name) const
Is parameter mu_name discrete?
The libMesh namespace provides an interface to certain functionality in the library.

◆ inner_product()

Number libMesh::RBEIMConstruction::inner_product ( const QpDataMap v,
const QpDataMap w,
bool  apply_comp_scaling 
)
privateinherited

Evaluate the inner product of vec1 and vec2 which specify values at quadrature points.

The inner product includes the JxW contributions stored in _local_quad_point_JxW, so that this is equivalent to computing w^t M v, where M is the mass matrix.

If apply_comp_scaling then we will incorporate the scaling from _component_scaling_in_training_set in the inner product.

Definition at line 2215 of file rb_eim_construction.C.

2216{
2217 LOG_SCOPE("inner_product()", "RBEIMConstruction");
2218
2219 Number val = 0.;
2220
2221 for (const auto & [elem_id, v_comp_and_qp] : v)
2222 {
2223 const auto & w_comp_and_qp = libmesh_map_find(w, elem_id);
2224 const auto & JxW = libmesh_map_find(_local_quad_point_JxW, elem_id);
2225
2226 for (const auto & comp : index_range(v_comp_and_qp))
2227 {
2228 const std::vector<Number> & v_qp = v_comp_and_qp[comp];
2229 const std::vector<Number> & w_qp = w_comp_and_qp[comp];
2230
2231 Real comp_scaling = 1.;
2232 if (apply_comp_scaling)
2233 {
2234 // We square the component scaling here because it occurs twice in
2235 // the inner product calculation below.
2236 comp_scaling = std::pow(_component_scaling_in_training_set[comp], 2.);
2237 }
2238
2239 for (unsigned int qp : index_range(JxW))
2240 val += JxW[qp] * comp_scaling * v_qp[qp] * libmesh_conj(w_qp[qp]);
2241 }
2242 }
2243
2244 comm().sum(val);
2245 return val;
2246}
T libmesh_conj(T a)

References libMesh::RBEIMConstruction::_component_scaling_in_training_set, libMesh::RBEIMConstruction::_local_quad_point_JxW, libMesh::ParallelObject::comm(), libMesh::index_range(), libMesh::libmesh_conj(), libMesh::Real, and libMesh::Parallel::Communicator::sum().

Referenced by libMesh::RBEIMConstruction::apply_normalization_to_solution_snapshots(), libMesh::RBEIMConstruction::compute_max_eim_error(), libMesh::RBEIMConstruction::train_eim_approximation_with_POD(), and libMesh::RBEIMConstruction::update_eim_matrices().

◆ is_adjoint_already_solved()

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

Accessor for the adjoint_already_solved boolean.

Definition at line 411 of file system.h.

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

References libMesh::System::adjoint_already_solved.

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

◆ is_discrete_parameter()

bool libMesh::RBParametrized::is_discrete_parameter ( const std::string &  mu_name) const
inherited

Is parameter mu_name discrete?

Definition at line 351 of file rb_parametrized.C.

352{
353 libmesh_error_msg_if(!parameters_initialized,
354 "Error: parameters not initialized in RBParametrized::is_discrete_parameter");
355
356 return _discrete_parameter_values.count(mu_name);
357}

References libMesh::RBParametrized::_discrete_parameter_values, and libMesh::RBParametrized::parameters_initialized.

Referenced by libMesh::RBDataSerialization::add_parameter_ranges_to_builder(), libMesh::RBEIMConstruction::print_info(), libMesh::RBConstruction::print_info(), and libMesh::RBParametrized::write_parameter_ranges_to_file().

◆ is_initialized()

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

Definition at line 2457 of file system.h.

2458{
2459 return _is_initialized;
2460}

References libMesh::System::_is_initialized.

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

◆ is_quiet()

bool libMesh::RBConstructionBase< System >::is_quiet ( ) const
inlineinherited

Is the system in quiet mode?

Definition at line 106 of file rb_construction_base.h.

107 { return this->quiet_mode; }
bool quiet_mode
Flag to indicate whether we print out extra information during the Offline stage.

◆ is_value_in_list()

bool libMesh::RBParametrized::is_value_in_list ( Real  value,
const std::vector< Real > &  list_of_values,
Real  tol 
)
staticprivateinherited

Helper function to check if the specified value is in the list of values (within a tolerance given by tol).

Definition at line 451 of file rb_parametrized.C.

452{
453 Real closest_value = get_closest_value(value, list_of_values);
454
455 // Check if relative tolerance is satisfied
456 Real rel_error = std::abs(value - closest_value) / std::abs(value);
457 if (rel_error <= tol)
458 {
459 return true;
460 }
461
462 // If relative tolerance isn't satisfied, we should still check an absolute
463 // error, since relative tolerance can be misleading if value is close to zero
464 Real abs_error = std::abs(value - closest_value);
465 return (abs_error <= tol);
466}
static Real get_closest_value(Real value, const std::vector< Real > &list_of_values)

References libMesh::RBParametrized::get_closest_value(), libMesh::Real, and value.

Referenced by libMesh::RBParametrized::check_if_valid_params().

◆ late_matrix_init()

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

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

Definition at line 1063 of file system.C.

1065{
1067 {
1068 this->get_dof_map().attach_matrix(mat);
1069 mat.init(type);
1070 }
1071}
virtual void init(const numeric_index_type m, const numeric_index_type n, const numeric_index_type m_l, const numeric_index_type n_l, const numeric_index_type nnz=30, const numeric_index_type noz=10, const numeric_index_type blocksize=1)=0
Initialize SparseMatrix with the specified sizes.

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

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

◆ load_training_set()

void libMesh::RBConstructionBase< System >::load_training_set ( const std::map< std::string, std::vector< RBParameter > > &  new_training_set)
virtualinherited

Overwrite the training parameters with new_training_set.

This training set is assumed to contain only the samples local to this processor.

Definition at line 152 of file rb_construction_base.C.

380{
381 // Make sure we're running this on all processors at the same time
382 libmesh_parallel_only(this->comm());
383
384 // First, make sure that an initial training set has already been generated
385 libmesh_error_msg_if(!_training_parameters_initialized,
386 "Error: load_training_set cannot be used to initialize parameters");
387
388 // Make sure that the training set has the correct number of parameters
389 const unsigned int n_params = get_n_params();
390 libmesh_error_msg_if(new_training_set.size() > n_params,
391 "Error: new_training_set should not have more than get_n_params() parameters.");
392
393 // Check that (new_training_set.size() == get_n_params()) is the same on all processes so that
394 // we go into the same branch of the "if" statement below on all processes.
395 const bool size_matches = (new_training_set.size() == n_params);
396 libmesh_assert(this->comm().verify(size_matches));
397
398 if (size_matches)
399 {
400 // If new_training_set stores values for all parameters, then we overwrite
401 // _training_parameters with new_training_set.
402
403 // Get the number of local and global training parameters
406 cast_int<numeric_index_type>(new_training_set.begin()->second.size());
408
409 if (!serial_training_set)
410 {
411 this->comm().sum(_n_global_training_samples);
412
413 // Set the first/last indices.
414 std::vector<numeric_index_type> local_sizes (this->n_processors(), 0);
415 local_sizes[this->processor_id()] = _n_local_training_samples;
416 this->comm().sum(local_sizes);
417
418 // first_local_index is the sum of local_sizes
419 // for all processor ids less than ours
420 for (auto p : make_range(this->processor_id()))
421 _first_local_index += local_sizes[p];
422 }
423
424 // Ensure that the parameters are the same.
425 for (const auto & pr : _training_parameters)
426 libmesh_error_msg_if(!new_training_set.count(pr.first),
427 "Parameters must be identical in order to overwrite dataset.");
428
429 // Copy the values from the new_training_set to the internal training_parameters.
430 _training_parameters = new_training_set;
431 }
432 else
433 {
434 // If new_training_set stores values for a subset of the parameters, then we keep the
435 // length of training_parameters unchanged and overwrite the entries of the specified
436 // parameters from new_training_set. Note that we repeatedly loop over new_training_set
437 // to fill up the entire length of the sample_vector.
438 for (auto & [param_name, sample_vector]: _training_parameters)
439 {
440 if (new_training_set.count(param_name))
441 {
442 for (const auto i : make_range(get_local_n_training_samples()))
443 {
444 const unsigned int num_new_samples = libmesh_map_find(new_training_set,param_name).size();
445 libmesh_error_msg_if (num_new_samples==0, "new_training_set set should not be empty");
446
447 const unsigned int new_training_set_index = i % num_new_samples;
448 sample_vector[i] = libmesh_map_find(new_training_set,param_name)[new_training_set_index];
449 }
450 }
451 }
452 }
453}
processor_id_type processor_id() const

◆ local_dof_indices()

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

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

Definition at line 1409 of file system.C.

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

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

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

◆ matrices_begin() [1/2]

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

Beginning of matrices container.

Definition at line 2529 of file system.h.

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

References libMesh::System::_matrices.

◆ matrices_begin() [2/2]

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

Beginning of matrices container.

Definition at line 2535 of file system.h.

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

References libMesh::System::_matrices.

◆ matrices_end() [1/2]

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

End of matrices container.

Definition at line 2541 of file system.h.

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

References libMesh::System::_matrices.

◆ matrices_end() [2/2]

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

End of matrices container.

Definition at line 2547 of file system.h.

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

References libMesh::System::_matrices.

◆ n_active_dofs()

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

Definition at line 2483 of file system.h.

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

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

◆ n_components()

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

Definition at line 2694 of file system.C.

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

Referenced by ElasticityRBConstruction::init_data().

◆ n_constrained_dofs()

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

Definition at line 125 of file system.C.

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

References libMesh::System::_dof_map.

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

◆ n_dofs()

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

Definition at line 118 of file system.C.

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

References libMesh::System::_dof_map.

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

◆ n_local_constrained_dofs()

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

Definition at line 140 of file system.C.

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

References libMesh::System::_dof_map.

◆ n_local_dofs()

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

Definition at line 155 of file system.C.

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

References libMesh::System::_dof_map.

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

◆ n_matrices()

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

Definition at line 2638 of file system.h.

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

References libMesh::System::_matrices.

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

◆ n_objects() [1/2]

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

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

Definition at line 85 of file reference_counter.h.

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

References libMesh::ReferenceCounter::_n_objects.

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

◆ n_objects() [2/2]

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

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

Definition at line 85 of file reference_counter.h.

86 { return _n_objects; }

References libMesh::ReferenceCounter::_n_objects.

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

◆ n_processors()

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

Definition at line 103 of file parallel_object.h.

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

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

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

◆ n_qois()

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

Number of currently active quantities of interest.

Definition at line 2562 of file system.h.

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

References libMesh::System::_qoi.

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

◆ n_variable_groups()

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

Definition at line 2699 of file system.C.

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

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

◆ n_vars()

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

Definition at line 2674 of file system.C.

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

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

◆ n_vectors()

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

Definition at line 2499 of file system.h.

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

References libMesh::System::_vectors.

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

◆ name()

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

◆ node_inner_product()

Number libMesh::RBEIMConstruction::node_inner_product ( const NodeDataMap v,
const NodeDataMap w,
bool  apply_comp_scaling 
)
privateinherited

Same as inner_product() except for node data.

Definition at line 2283 of file rb_eim_construction.C.

2284{
2285 LOG_SCOPE("node_inner_product()", "RBEIMConstruction");
2286
2287 Number val = 0.;
2288
2289 for (const auto & [node_id, v_comps] : v)
2290 {
2291 const auto & w_comps = libmesh_map_find(w, node_id);
2292
2293 for (const auto & comp : index_range(v_comps))
2294 {
2295 // There is no quadrature rule on nodes, so we just multiply the values directly.
2296 // Hence we effectively work with the Euclidean inner product in this case.
2297
2298 Real comp_scaling = 1.;
2299 if (apply_comp_scaling)
2300 {
2301 // We square the component scaling here because it occurs twice in
2302 // the inner product calculation below.
2303 comp_scaling = std::pow(_component_scaling_in_training_set[comp], 2.);
2304 }
2305
2306 val += comp_scaling * v_comps[comp] * libmesh_conj(w_comps[comp]);
2307 }
2308 }
2309
2310 comm().sum(val);
2311 return val;
2312}

References libMesh::RBEIMConstruction::_component_scaling_in_training_set, libMesh::ParallelObject::comm(), libMesh::index_range(), libMesh::libmesh_conj(), libMesh::Real, and libMesh::Parallel::Communicator::sum().

Referenced by libMesh::RBEIMConstruction::apply_normalization_to_solution_snapshots(), libMesh::RBEIMConstruction::compute_max_eim_error(), libMesh::RBEIMConstruction::train_eim_approximation_with_POD(), and libMesh::RBEIMConstruction::update_eim_matrices().

◆ number()

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

Definition at line 2393 of file system.h.

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

References libMesh::System::_sys_number.

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

◆ point_gradient() [1/4]

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

Definition at line 2348 of file system.C.

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

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

Referenced by line_print().

◆ point_gradient() [2/4]

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

Definition at line 2410 of file system.C.

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

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

◆ point_gradient() [3/4]

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

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

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

Definition at line 2475 of file system.C.

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

References libMesh::libmesh_assert().

◆ point_gradient() [4/4]

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

Calls the parallel version of point_gradient().

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

Definition at line 2483 of file system.C.

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

◆ point_hessian() [1/4]

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

Definition at line 2492 of file system.C.

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

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

◆ point_hessian() [2/4]

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

Definition at line 2553 of file system.C.

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

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

◆ point_hessian() [3/4]

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

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

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

Definition at line 2613 of file system.C.

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

References libMesh::libmesh_assert().

◆ point_hessian() [4/4]

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

Calls the parallel version of point_hessian().

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

Definition at line 2621 of file system.C.

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

◆ point_value() [1/4]

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

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

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

Definition at line 2219 of file system.C.

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

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

Referenced by line_print(), main(), NavierSystem::postprocess(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testCopyNodalSolutionImpl(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), PeriodicBCTest::testPeriodicBC(), SystemsTest::testProjectCubeWithMeshFunction(), EquationSystemsTest::testRepartitionThenReinit(), DisjointNeighborTest::testTempJump(), and DisjointNeighborTest::testTempJumpRefine().

◆ point_value() [2/4]

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

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

Definition at line 2280 of file system.C.

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

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

◆ point_value() [3/4]

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

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

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

Definition at line 2332 of file system.C.

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

References libMesh::libmesh_assert().

◆ point_value() [4/4]

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

Calls the parallel version of point_value().

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

Definition at line 2340 of file system.C.

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

◆ prefer_hash_table_matrix_assembly()

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

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

Definition at line 2667 of file system.h.

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

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

Referenced by main().

◆ prefix()

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

Definition at line 1980 of file system.h.

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

References libMesh::System::name().

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

◆ prefix_with_name() [1/2]

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

Definition at line 1974 of file system.h.

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

References libMesh::System::_prefix_with_name.

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

◆ prefix_with_name() [2/2]

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

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

Definition at line 1969 of file system.h.

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

◆ print_discrete_parameter_values()

void libMesh::RBParametrized::print_discrete_parameter_values ( ) const
inherited

Print out all the discrete parameter values.

Definition at line 366 of file rb_parametrized.C.

367{
368 for (const auto & [name, values] : get_discrete_parameter_values())
369 {
370 libMesh::out << "Discrete parameter " << name << ", values: ";
371
372 for (const auto & value : values)
373 libMesh::out << value << " ";
374 libMesh::out << std::endl;
375 }
376}

References libMesh::RBParametrized::get_discrete_parameter_values(), libMesh::out, and value.

Referenced by libMesh::RBEIMConstruction::print_info(), libMesh::RBSCMConstruction::print_info(), and libMesh::RBConstruction::print_info().

◆ print_info() [1/3]

void libMesh::RBEIMConstruction::print_info ( )
virtualinherited

Print out info that describes the current setup of this RBConstruction.

Definition at line 187 of file rb_eim_construction.C.

188{
189 // Print out info that describes the current setup
190 libMesh::out << std::endl << "RBEIMConstruction parameters:" << std::endl;
191 libMesh::out << "system name: " << this->name() << std::endl;
192 libMesh::out << "Nmax: " << get_Nmax() << std::endl;
194 {
195 libMesh::out << "Overruling Nmax based on number of snapshots, with increment set to "
197 << std::endl;
198 }
199 libMesh::out << "Greedy relative error tolerance: " << get_rel_training_tolerance() << std::endl;
200 libMesh::out << "Greedy absolute error tolerance: " << get_abs_training_tolerance() << std::endl;
201 libMesh::out << "Number of parameters: " << get_n_params() << std::endl;
202 for (const auto & pr : get_parameters())
203 if (!is_discrete_parameter(pr.first))
204 {
205 libMesh::out << "Parameter " << pr.first
206 << ": Min = " << get_parameter_min(pr.first)
207 << ", Max = " << get_parameter_max(pr.first) << std::endl;
208 }
209
211 libMesh::out << "n_training_samples: " << get_n_training_samples() << std::endl;
212 libMesh::out << "quiet mode? " << is_quiet() << std::endl;
213
215 {
216 libMesh::out << "EIM best fit type: projection" << std::endl;
217 }
218 else
220 {
221 libMesh::out << "EIM best fit type: eim" << std::endl;
222 }
223 libMesh::out << std::endl;
224}
unsigned int get_Nmax() const
Get/set Nmax, the maximum number of RB functions we are willing to compute.
void print_discrete_parameter_values() const
Print out all the discrete parameter values.

References libMesh::RBEIMConstruction::_Nmax_from_n_snapshots_increment, libMesh::RBEIMConstruction::_set_Nmax_from_n_snapshots, libMesh::RBEIMConstruction::best_fit_type_flag, libMesh::RBEIMConstruction::EIM_BEST_FIT, libMesh::RBEIMConstruction::get_abs_training_tolerance(), libMesh::RBParametrized::get_n_params(), libMesh::RBConstructionBase< System >::get_n_training_samples(), libMesh::RBEIMConstruction::get_Nmax(), libMesh::RBParametrized::get_parameter_max(), libMesh::RBParametrized::get_parameter_min(), libMesh::RBParametrized::get_parameters(), libMesh::RBEIMConstruction::get_rel_training_tolerance(), libMesh::RBParametrized::is_discrete_parameter(), libMesh::RBConstructionBase< System >::is_quiet(), libMesh::System::name(), libMesh::out, libMesh::RBParametrized::print_discrete_parameter_values(), and libMesh::RBEIMConstruction::PROJECTION_BEST_FIT.

Referenced by main().

◆ print_info() [2/3]

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

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

Definition at line 81 of file reference_counter.C.

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

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

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

◆ print_info() [3/3]

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

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

Definition at line 81 of file reference_counter.C.

82{
84 out_stream << ReferenceCounter::get_info();
85}

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

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

◆ print_parameters()

void libMesh::RBParametrized::print_parameters ( ) const
inherited

Print the current parameters.

Definition at line 178 of file rb_parametrized.C.

179{
180 libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::print_current_parameters");
181
183}
void print(unsigned precision=6, int max_values=5) const
Print the parameters.

References libMesh::RBParametrized::get_parameters(), libMesh::RBParametrized::parameters_initialized, and libMesh::RBParameters::print().

Referenced by main(), libMesh::RBEIMConstruction::train_eim_approximation_with_greedy(), and libMesh::RBConstruction::train_reduced_basis_with_greedy().

◆ process_parameters_file()

void libMesh::RBEIMConstruction::process_parameters_file ( const std::string &  parameters_filename)
virtualinherited

Read parameters in from file and set up this system accordingly.

Definition at line 231 of file rb_eim_construction.C.

232{
233 // First read in data from input_filename
234 GetPot infile(parameters_filename);
235
236 std::string best_fit_type_string = infile("best_fit_type","projection");
237 set_best_fit_type_flag(best_fit_type_string);
238
239 const unsigned int n_training_samples = infile("n_training_samples",0);
240 const bool deterministic_training = infile("deterministic_training",false);
241 unsigned int training_parameters_random_seed_in =
242 static_cast<unsigned int>(-1);
243 training_parameters_random_seed_in = infile("training_parameters_random_seed",
244 training_parameters_random_seed_in);
245 const bool quiet_mode_in = infile("quiet_mode", quiet_mode);
246 const unsigned int Nmax_in = infile("Nmax", _Nmax);
247 const Real rel_training_tolerance_in = infile("rel_training_tolerance",
249 const Real abs_training_tolerance_in = infile("abs_training_tolerance",
251
252 // Read in the parameters from the input file too
253 unsigned int n_continuous_parameters = infile.vector_variable_size("parameter_names");
254 RBParameters mu_min_in;
255 RBParameters mu_max_in;
256 for (unsigned int i=0; i<n_continuous_parameters; i++)
257 {
258 // Read in the parameter names
259 std::string param_name = infile("parameter_names", "NONE", i);
260
261 {
262 Real min_val = infile(param_name, 0., 0);
263 mu_min_in.set_value(param_name, min_val);
264 }
265
266 {
267 Real max_val = infile(param_name, 0., 1);
268 mu_max_in.set_value(param_name, max_val);
269 }
270 }
271
272 std::map<std::string, std::vector<Real>> discrete_parameter_values_in;
273
274 unsigned int n_discrete_parameters = infile.vector_variable_size("discrete_parameter_names");
275 for (unsigned int i=0; i<n_discrete_parameters; i++)
276 {
277 std::string param_name = infile("discrete_parameter_names", "NONE", i);
278
279 unsigned int n_vals_for_param = infile.vector_variable_size(param_name);
280 std::vector<Real> vals_for_param(n_vals_for_param);
281 for (auto j : make_range(vals_for_param.size()))
282 vals_for_param[j] = infile(param_name, 0., j);
283
284 discrete_parameter_values_in[param_name] = vals_for_param;
285 }
286
287 std::map<std::string,bool> log_scaling_in;
288 // For now, just set all entries to false.
289 // TODO: Implement a decent way to specify log-scaling true/false
290 // in the input text file
291 for (const auto & pr : mu_min_in)
292 log_scaling_in[pr.first] = false;
293
294 // Set the parameters that have been read in
295 set_rb_construction_parameters(n_training_samples,
296 deterministic_training,
297 training_parameters_random_seed_in,
298 quiet_mode_in,
299 Nmax_in,
300 rel_training_tolerance_in,
301 abs_training_tolerance_in,
302 mu_min_in,
303 mu_max_in,
304 discrete_parameter_values_in,
305 log_scaling_in);
306}
void set_rb_construction_parameters(unsigned int n_training_samples_in, bool deterministic_training_in, int training_parameters_random_seed_in, bool quiet_mode_in, unsigned int Nmax_in, Real rel_training_tolerance_in, Real abs_training_tolerance_in, const RBParameters &mu_min_in, const RBParameters &mu_max_in, const std::map< std::string, std::vector< Real > > &discrete_parameter_values_in, const std::map< std::string, bool > &log_scaling, std::map< std::string, std::vector< RBParameter > > *training_sample_list=nullptr)
Set the state of this RBConstruction object based on the arguments to this function.
virtual void set_best_fit_type_flag(const std::string &best_fit_type_string)
Specify which type of "best fit" we use to guide the EIM greedy algorithm.

References libMesh::RBEIMConstruction::_abs_training_tolerance, libMesh::RBEIMConstruction::_Nmax, libMesh::RBEIMConstruction::_rel_training_tolerance, libMesh::make_range(), libMesh::RBConstructionBase< System >::quiet_mode, libMesh::Real, libMesh::RBEIMConstruction::set_best_fit_type_flag(), libMesh::RBEIMConstruction::set_rb_construction_parameters(), and libMesh::RBParameters::set_value().

Referenced by main().

◆ processor_id()

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

Definition at line 114 of file parallel_object.h.

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

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

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

◆ project_solution() [1/3]

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

Projects arbitrary functions onto the current solution.

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

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

Definition at line 1080 of file system_projection.C.

1084{
1085 this->project_vector(*solution, f, g, /*is_adjoint=*/-1, active_local_range, variable_numbers);
1086
1087 solution->localize(*current_local_solution, _dof_map->get_send_list());
1088}
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1, std::optional< ConstElemRange > active_local_range=std::nullopt, std::optional< std::vector< unsigned int > > variable_numbers=std::nullopt) const
Projects arbitrary functions onto a vector of degree of freedom values for the current system.

◆ project_solution() [2/3]

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

Projects arbitrary functions onto the current solution.

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

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

Definition at line 1065 of file system_projection.C.

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

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

◆ project_solution() [3/3]

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

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

Definition at line 1049 of file system_projection.C.

1054{
1055 WrappedFunction<Number> f(*this, fptr, &function_parameters);
1056 WrappedFunction<Gradient> g(*this, gptr, &function_parameters);
1057 this->project_solution(&f, &g, active_local_range, variable_numbers);
1058}
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, std::optional< ConstElemRange > active_local_range=std::nullopt, std::optional< std::vector< unsigned int > > variable_numbers=std::nullopt) const
Projects arbitrary functions onto the current solution.

References fptr(), and gptr().

◆ project_solution_on_reinit()

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

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

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

Definition at line 884 of file system.h.

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

References libMesh::System::_solution_projection.

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

◆ project_vector() [1/5]

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

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

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

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

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

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

Definition at line 267 of file system_projection.C.

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

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

◆ project_vector() [2/5]

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

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

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

Definition at line 247 of file system_projection.C.

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

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

◆ project_vector() [3/5]

void libMesh::System::project_vector ( NumericVector< Number > &  new_vector,
FEMFunctionBase< Number > *  f,
FEMFunctionBase< Gradient > *  g = nullptr,
int  is_adjoint = -1,
std::optional< ConstElemRange active_local_range = std::nullopt,
std::optional< std::vector< unsigned int > >  variable_numbers = std::nullopt 
) const
inherited

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

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

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

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

Definition at line 1140 of file system_projection.C.

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

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

◆ project_vector() [4/5]

void libMesh::System::project_vector ( NumericVector< Number > &  new_vector,
FunctionBase< Number > *  f,
FunctionBase< Gradient > *  g = nullptr,
int  is_adjoint = -1,
std::optional< ConstElemRange active_local_range = std::nullopt,
std::optional< std::vector< unsigned int > >  variable_numbers = std::nullopt 
) const
inherited

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

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

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

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

Definition at line 1112 of file system_projection.C.

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

References libMesh::libmesh_assert().

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

◆ project_vector() [5/5]

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

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

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

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

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

Definition at line 1095 of file system_projection.C.

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

References fptr(), and gptr().

◆ projection_matrix()

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

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

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

Definition at line 983 of file system_projection.C.

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

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

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

◆ prolong_vectors()

void libMesh::System::prolong_vectors ( )
virtualinherited

Prolong vectors after the mesh has refined.

Definition at line 432 of file system.C.

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

References libMesh::System::restrict_vectors().

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

◆ qoi_parameter_hessian()

void libMesh::System::qoi_parameter_hessian ( const QoISet qoi_indices,
const ParameterVector parameters,
SensitivityData hessian 
)
inlinevirtualinherited

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

This method is only implemented in some derived classes.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2620 of file system.h.

2623{
2624 libmesh_not_implemented();
2625}

◆ qoi_parameter_hessian_vector_product()

void libMesh::System::qoi_parameter_hessian_vector_product ( const QoISet qoi_indices,
const ParameterVector parameters,
const ParameterVector vector,
SensitivityData product 
)
inlinevirtualinherited

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

This method is only implemented in some derived classes.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2629 of file system.h.

2633{
2634 libmesh_not_implemented();
2635}

◆ qoi_parameter_sensitivity()

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

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

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

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

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

Definition at line 590 of file system.C.

593{
594 // Forward sensitivities are more efficient for Nq > Np
595 if (qoi_indices.size(*this) > parameters_vec.size())
596 forward_qoi_parameter_sensitivity(qoi_indices, parameters_vec, sensitivities);
597 // Adjoint sensitivities are more efficient for Np > Nq,
598 // and an adjoint may be more reusable than a forward
599 // solution sensitivity in the Np == Nq case.
600 else
601 adjoint_qoi_parameter_sensitivity(qoi_indices, parameters_vec, sensitivities);
602}
virtual void adjoint_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Solves for parameter sensitivities using the adjoint method.
Definition system.h:2602
virtual void forward_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Solves for parameter sensitivities using the forward method.
Definition system.h:2611

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

◆ re_update()

void libMesh::System::re_update ( )
virtualinherited

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

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

Reimplemented in libMesh::TransientSystem< RBConstruction >.

Definition at line 521 of file system.C.

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

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

◆ read_discrete_parameter_values_from_file()

void libMesh::RBParametrized::read_discrete_parameter_values_from_file ( const std::string &  file_name,
const bool  read_binary_data,
std::map< std::string, std::vector< Real > > &  discrete_parameter_values_in 
)
privateinherited

Read in the discrete parameter values from file, if we have any.

Definition at line 318 of file rb_parametrized.C.

321{
322 // read in the discrete parameters, if we have any
323 std::ifstream check_if_file_exists(file_name.c_str());
324 if (check_if_file_exists.good())
325 {
326 // The reading mode: DECODE for binary, READ for ASCII
327 XdrMODE mode = read_binary_data ? DECODE : READ;
328
329 // Read in the parameter ranges
330 Xdr discrete_parameter_values_in(file_name, mode);
331 unsigned int n_discrete_params;
332 discrete_parameter_values_in >> n_discrete_params;
333
334 for (unsigned int i=0; i<n_discrete_params; i++)
335 {
336 std::string param_name;
337 discrete_parameter_values_in >> param_name;
338
339 unsigned int n_discrete_values;
340 discrete_parameter_values_in >> n_discrete_values;
341
342 std::vector<Real> discrete_values(n_discrete_values);
343 for (auto & val : discrete_values)
344 discrete_parameter_values_in >> val;
345
346 discrete_parameter_values[param_name] = discrete_values;
347 }
348 }
349}
XdrMODE
Defines an enum for read/write mode in Xdr format.

References libMesh::DECODE, and libMesh::READ.

Referenced by libMesh::RBParametrized::read_parameter_data_from_files().

◆ read_header()

void libMesh::System::read_header ( Xdr io,
std::string_view  version,
const bool  read_header = true,
const bool  read_additional_data = true,
const bool  read_legacy_format = false 
)
inherited

Reads the basic data header for this System.

Definition at line 97 of file system_io.C.

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

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

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

◆ read_parallel_data() [1/2]

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

Reads additional data, namely vectors, for this System.

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

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

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

for each additional vector in the object

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

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

Definition at line 302 of file system_io.C.

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

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

◆ read_parallel_data() [2/2]

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

Non-templated version for backward compatibility.

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

Definition at line 1412 of file system.h.

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

◆ read_parameter_data_from_files()

void libMesh::RBParametrized::read_parameter_data_from_files ( const std::string &  continuous_param_file_name,
const std::string &  discrete_param_file_name,
const bool  read_binary_data 
)
inherited

Read in the parameter ranges from files.

Definition at line 262 of file rb_parametrized.C.

265{
266 RBParameters param_min;
267 RBParameters param_max;
268 read_parameter_ranges_from_file(continuous_param_file_name,
269 read_binary_data,
270 param_min,
271 param_max);
272
273 std::map<std::string, std::vector<Real>> discrete_parameter_values_in;
274 read_discrete_parameter_values_from_file(discrete_param_file_name,
275 read_binary_data,
276 discrete_parameter_values_in);
277
278 initialize_parameters(param_min, param_max, discrete_parameter_values_in);
279}
void read_discrete_parameter_values_from_file(const std::string &file_name, const bool read_binary_data, std::map< std::string, std::vector< Real > > &discrete_parameter_values_in)
Read in the discrete parameter values from file, if we have any.
void read_parameter_ranges_from_file(const std::string &file_name, const bool read_binary, RBParameters &param_min, RBParameters &param_max)
Read in the parameter ranges from file.

References libMesh::RBParametrized::initialize_parameters(), libMesh::RBParametrized::read_discrete_parameter_values_from_file(), and libMesh::RBParametrized::read_parameter_ranges_from_file().

Referenced by libMesh::RBEvaluation::legacy_read_offline_data_from_files(), and libMesh::RBSCMEvaluation::legacy_read_offline_data_from_files().

◆ read_parameter_ranges_from_file()

void libMesh::RBParametrized::read_parameter_ranges_from_file ( const std::string &  file_name,
const bool  read_binary,
RBParameters param_min,
RBParameters param_max 
)
privateinherited

Read in the parameter ranges from file.

Initialize parameters to the "minimum" parameter values.

Definition at line 281 of file rb_parametrized.C.

285{
286 // The reading mode: DECODE for binary, READ for ASCII
287 XdrMODE mode = read_binary_data ? DECODE : READ;
288
289 // Read in the parameter ranges
290 Xdr parameter_ranges_in(file_name, mode);
291 unsigned int n_continuous_params;
292 parameter_ranges_in >> n_continuous_params;
293
294 for (unsigned int i=0; i<n_continuous_params; i++)
295 {
296 std::string param_name;
297 Real param_value;
298
299 parameter_ranges_in >> param_name;
300 parameter_ranges_in >> param_value;
301
302 param_min.set_value(param_name, param_value);
303 }
304 for (unsigned int i=0; i<n_continuous_params; i++)
305 {
306 std::string param_name;
307 Real param_value;
308
309 parameter_ranges_in >> param_name;
310 parameter_ranges_in >> param_value;
311
312 param_max.set_value(param_name, param_value);
313 }
314
315 parameter_ranges_in.close();
316}

References libMesh::Xdr::close(), libMesh::DECODE, libMesh::READ, libMesh::Real, and libMesh::RBParameters::set_value().

Referenced by libMesh::RBParametrized::read_parameter_data_from_files().

◆ read_SCALAR_dofs()

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

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

Returns
The number of dofs read.

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

Definition at line 939 of file system_io.C.

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

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

Referenced by libMesh::System::read_serialized_vector(), and libMesh::System::read_serialized_vectors().

◆ read_serialized_blocked_dof_objects()

template<typename iterator_type , typename InValType >
std::size_t libMesh::System::read_serialized_blocked_dof_objects ( const dof_id_type  n_objects,
const iterator_type  begin,
const iterator_type  end,
const InValType  dummy,
Xdr io,
const std::vector< NumericVector< Number > * > &  vecs,
const unsigned int  var_to_read = libMesh::invalid_uint 
) const
privateinherited

Reads an input vector from the stream io and assigns the values to a set of DofObjects.

This method uses blocked input and is safe to call on a distributed memory-mesh. Unless otherwise specified, all variables are read.

If an entry in vecs is a null pointer, the corresponding data is read (incrementing the file read location) but discarded.

Definition at line 618 of file system_io.C.

625{
626 //-------------------------------------------------------
627 // General order: (IO format 0.7.4 & greater)
628 //
629 // for (objects ...)
630 // for (vecs ....)
631 // for (vars ....)
632 // for (comps ...)
633 //
634 // where objects are nodes or elements, sorted to be
635 // partition independent,
636 // vecs are one or more *identically distributed* solution
637 // coefficient vectors, vars are one or more variables
638 // to write, and comps are all the components for said
639 // vars on the object.
640
641 // variables to read. Unless specified otherwise, defaults to _written_var_indices.
642 std::vector<unsigned int> vars_to_read (_written_var_indices);
643
644 if (var_to_read != libMesh::invalid_uint)
645 vars_to_read.assign({var_to_read});
646
647 const unsigned int
648 sys_num = this->number(),
649 num_vecs = cast_int<unsigned int>(vecs.size());
650 const dof_id_type
651 io_blksize = cast_int<dof_id_type>(std::min(max_io_blksize, static_cast<std::size_t>(n_objs))),
652 num_blks = cast_int<unsigned int>(std::ceil(static_cast<double>(n_objs)/
653 static_cast<double>(io_blksize)));
654
655 libmesh_assert_less_equal (_written_var_indices.size(), this->n_vars());
656
657 std::size_t n_read_values=0;
658
659 std::vector<std::vector<dof_id_type>> xfer_ids(num_blks); // The global IDs and # of components for the local objects in all blocks
660 std::vector<std::vector<Number>> recv_vals(num_blks); // The raw values for the local objects in all blocks
661 std::vector<Parallel::Request>
662 id_requests(num_blks), val_requests(num_blks);
663 std::vector<Parallel::MessageTag>
664 id_tags(num_blks), val_tags(num_blks);
665
666 // ------------------------------------------------------
667 // First pass - count the number of objects in each block
668 // traverse all the objects and figure out which block they
669 // will ultimately live in.
670 std::vector<std::size_t>
671 xfer_ids_size (num_blks,0),
672 recv_vals_size (num_blks,0);
673
674
675 for (iterator_type it=begin; it!=end; ++it)
676 {
677 const dof_id_type
678 id = (*it)->id(),
679 block = id/io_blksize;
680
681 libmesh_assert_less (block, num_blks);
682
683 xfer_ids_size[block] += 2; // for each object, we send its id, as well as the total number of components for all variables
684
685 dof_id_type n_comp_tot=0;
686 for (const auto & var : vars_to_read)
687 n_comp_tot += (*it)->n_comp(sys_num, var); // for each variable, we will receive the nonzero components
688
689 recv_vals_size[block] += n_comp_tot*num_vecs;
690 }
691
692 // knowing the recv_vals_size[block] for each processor allows
693 // us to sum them and find the global size for each block.
694 std::vector<std::size_t> tot_vals_size(recv_vals_size);
695 this->comm().sum (tot_vals_size);
696
697
698 //------------------------------------------
699 // Collect the ids & number of values needed
700 // for all local objects, binning them into
701 // 'blocks' that will be sent to processor 0
702 for (dof_id_type blk=0; blk<num_blks; blk++)
703 {
704 // Each processor should build up its transfer buffers for its
705 // local objects in [first_object,last_object).
706 const dof_id_type
707 first_object = blk*io_blksize,
708 last_object = std::min(cast_int<dof_id_type>((blk+1)*io_blksize), n_objs);
709
710 // convenience
711 std::vector<dof_id_type> & ids (xfer_ids[blk]);
712 std::vector<Number> & vals (recv_vals[blk]);
713
714 // we now know the number of values we will store for each block,
715 // so we can do efficient preallocation
716 ids.clear(); ids.reserve (xfer_ids_size[blk]);
717 vals.resize(recv_vals_size[blk]);
718
719#ifdef DEBUG
720 std::unordered_set<dof_id_type> seen_ids;
721#endif
722
723 if (recv_vals_size[blk] != 0) // only if there are nonzero values to receive
724 for (iterator_type it=begin; it!=end; ++it)
725 {
726 dof_id_type id = (*it)->id();
727#ifdef DEBUG
728 // Any renumbering tricks should not have given us any
729 // duplicate ids.
730 libmesh_assert(!seen_ids.count(id));
731 seen_ids.insert(id);
732#endif
733
734 if ((id >= first_object) && // object in [first_object,last_object)
735 (id < last_object))
736 {
737 ids.push_back(id);
738
739 unsigned int n_comp_tot=0;
740
741 for (const auto & var : vars_to_read)
742 n_comp_tot += (*it)->n_comp(sys_num, var);
743
744 ids.push_back (n_comp_tot*num_vecs);
745 }
746 }
747
748#ifdef LIBMESH_HAVE_MPI
749 id_tags[blk] = this->comm().get_unique_tag(100*num_blks + blk);
750 val_tags[blk] = this->comm().get_unique_tag(200*num_blks + blk);
751
752 // nonblocking send the data for this block
753 this->comm().send (0, ids, id_requests[blk], id_tags[blk]);
754
755 // Go ahead and post the receive too
756 this->comm().receive (0, vals, val_requests[blk], val_tags[blk]);
757#endif
758 }
759
760 //---------------------------------------------------
761 // Here processor 0 will read and distribute the data.
762 // We have to do this block-wise to ensure that we
763 // do not exhaust memory on processor 0.
764
765 // give these variables scope outside the block to avoid reallocation
766 std::vector<std::vector<dof_id_type>> recv_ids (this->n_processors());
767 std::vector<std::vector<Number>> send_vals (this->n_processors());
768 std::vector<Parallel::Request> reply_requests (this->n_processors());
769 std::vector<unsigned int> obj_val_offsets; // map to traverse entry-wise rather than processor-wise
770 std::vector<Number> input_vals; // The input buffer for the current block
771 std::vector<InValType> input_vals_tmp; // The input buffer for the current block
772
773 for (dof_id_type blk=0; blk<num_blks; blk++)
774 {
775 // Each processor should build up its transfer buffers for its
776 // local objects in [first_object,last_object).
777 const dof_id_type
778 first_object = blk*io_blksize,
779 last_object = std::min(cast_int<dof_id_type>((blk+1)*io_blksize), n_objs),
780 n_objects_blk = last_object - first_object;
781
782 // Processor 0 has a special job. It needs to gather the requested indices
783 // in [first_object,last_object) from all processors, read the data from
784 // disk, and reply
785 if (this->processor_id() == 0)
786 {
787 // we know the input buffer size for this block and can begin reading it now
788 input_vals.resize(tot_vals_size[blk]);
789 input_vals_tmp.resize(tot_vals_size[blk]);
790
791 // a ThreadedIO object to perform asynchronous file IO
792 ThreadedIO<InValType> threaded_io(io, input_vals_tmp);
793 Threads::Thread async_io(threaded_io);
794
795 // offset array. this will define where each object's values
796 // map into the actual input_vals buffer. this must get
797 // 0-initialized because 0-component objects are not actually sent
798 obj_val_offsets.resize (n_objects_blk); std::fill (obj_val_offsets.begin(), obj_val_offsets.end(), 0);
799 recv_vals_size.resize(this->n_processors()); // reuse this to count how many values are going to each processor
800
801#ifndef NDEBUG
802 std::size_t n_vals_blk = 0;
803#endif
804
805 // loop over all processors and process their index request
806 for (processor_id_type comm_step=0, tnp=this->n_processors(); comm_step != tnp; ++comm_step)
807 {
808#ifdef LIBMESH_HAVE_MPI
809 // blocking receive indices for this block, imposing no particular order on processor
810 Parallel::Status id_status (this->comm().probe (Parallel::any_source, id_tags[blk]));
811 std::vector<dof_id_type> & ids (recv_ids[id_status.source()]);
812 std::size_t & n_vals_proc (recv_vals_size[id_status.source()]);
813 this->comm().receive (id_status.source(), ids, id_tags[blk]);
814#else
815 // straight copy without MPI
816 std::vector<dof_id_type> & ids (recv_ids[0]);
817 std::size_t & n_vals_proc (recv_vals_size[0]);
818 ids = xfer_ids[blk];
819#endif
820
821 n_vals_proc = 0;
822
823 // note its possible we didn't receive values for objects in
824 // this block if they have no components allocated.
825 for (std::size_t idx=0, sz=ids.size(); idx<sz; idx+=2)
826 {
827 const dof_id_type
828 local_idx = ids[idx+0]-first_object,
829 n_vals_tot_allvecs = ids[idx+1];
830
831 libmesh_assert_less (local_idx, n_objects_blk);
832
833 obj_val_offsets[local_idx] = n_vals_tot_allvecs;
834 n_vals_proc += n_vals_tot_allvecs;
835 }
836
837#ifndef NDEBUG
838 n_vals_blk += n_vals_proc;
839#endif
840 }
841
842 // We need the offsets into the input_vals vector for each object.
843 // fortunately, this is simply the partial sum of the total number
844 // of components for each object
845 std::partial_sum(obj_val_offsets.begin(), obj_val_offsets.end(),
846 obj_val_offsets.begin());
847
848 libmesh_assert_equal_to (n_vals_blk, obj_val_offsets.back());
849 libmesh_assert_equal_to (n_vals_blk, tot_vals_size[blk]);
850
851 // Wait for read completion
852 async_io.join();
853 // now copy the values back to the main vector for transfer
854 for (auto i_val : index_range(input_vals))
855 input_vals[i_val] = input_vals_tmp[i_val];
856
857 n_read_values += input_vals.size();
858
859 // pack data replies for each processor
860 for (auto proc : make_range(this->n_processors()))
861 {
862 const std::vector<dof_id_type> & ids (recv_ids[proc]);
863 std::vector<Number> & vals (send_vals[proc]);
864 const std::size_t & n_vals_proc (recv_vals_size[proc]);
865
866 vals.clear(); vals.reserve(n_vals_proc);
867
868 for (std::size_t idx=0, sz=ids.size(); idx<sz; idx+=2)
869 {
870 const dof_id_type
871 local_idx = ids[idx+0]-first_object,
872 n_vals_tot_allvecs = ids[idx+1];
873
874 std::vector<Number>::const_iterator in_vals(input_vals.begin());
875 if (local_idx != 0)
876 std::advance (in_vals, obj_val_offsets[local_idx-1]);
877
878 for (unsigned int val=0; val<n_vals_tot_allvecs; val++, ++in_vals)
879 {
880 libmesh_assert (in_vals != input_vals.end());
881 //libMesh::out << "*in_vals=" << *in_vals << '\n';
882 vals.push_back(*in_vals);
883 }
884 }
885
886#ifdef LIBMESH_HAVE_MPI
887 // send the relevant values to this processor
888 this->comm().send (proc, vals, reply_requests[proc], val_tags[blk]);
889#else
890 recv_vals[blk] = vals;
891#endif
892 }
893 } // end processor 0 read/reply
894
895 // all processors complete the (already posted) read for this block
896 {
897 Parallel::wait (val_requests[blk]);
898
899 const std::vector<Number> & vals (recv_vals[blk]);
900 std::vector<Number>::const_iterator val_it(vals.begin());
901
902 if (!recv_vals[blk].empty()) // nonzero values to receive
903 for (iterator_type it=begin; it!=end; ++it)
904 if (((*it)->id() >= first_object) && // object in [first_object,last_object)
905 ((*it)->id() < last_object))
906 // unpack & set the values
907 for (auto & vec : vecs)
908 for (const auto & var : vars_to_read)
909 {
910 const unsigned int n_comp = (*it)->n_comp(sys_num, var);
911
912 for (unsigned int comp=0; comp<n_comp; comp++, ++val_it)
913 {
914 const dof_id_type dof_index = (*it)->dof_number (sys_num, var, comp);
915 libmesh_assert (val_it != vals.end());
916 if (vec)
917 {
918 libmesh_assert_greater_equal (dof_index, vec->first_local_index());
919 libmesh_assert_less (dof_index, vec->last_local_index());
920 //libMesh::out << "dof_index, *val_it = \t" << dof_index << ", " << *val_it << '\n';
921 vec->set (dof_index, *val_it);
922 }
923 }
924 }
925 }
926
927 // processor 0 needs to make sure all replies have been handed off
928 if (this->processor_id () == 0)
929 Parallel::wait(reply_requests);
930 }
931
932 Parallel::wait(id_requests);
933
934 return n_read_values;
935}
Status wait(Request &r)
const unsigned int any_source
NonConcurrentThread Thread
Use the non-concurrent placeholder.
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
Definition libmesh.h:303

References libMesh::System::_written_var_indices, TIMPI::any_source, libMesh::ParallelObject::comm(), libMesh::Parallel::Communicator::get_unique_tag(), libMesh::index_range(), libMesh::invalid_uint, libMesh::Threads::NonConcurrentThread::join(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::ParallelObject::n_processors(), libMesh::System::number(), libMesh::ParallelObject::processor_id(), libMesh::Parallel::Communicator::receive(), libMesh::Parallel::Communicator::send(), TIMPI::Status::source(), libMesh::Parallel::Communicator::sum(), and TIMPI::wait().

Referenced by libMesh::System::read_serialized_vector(), and libMesh::System::read_serialized_vectors().

◆ read_serialized_data() [1/2]

template<typename InValType >
void libMesh::System::read_serialized_data ( Xdr io,
const bool  read_additional_data = true 
)
inherited

Reads additional data, namely vectors, for this System.

This method may safely be called on a distributed-memory mesh.

Definition at line 533 of file system_io.C.

535{
536 // This method implements the input of the vectors
537 // contained in this System object, embedded in the
538 // output of an EquationSystems<T_sys>.
539 //
540 // 10.) The global solution vector, re-ordered to be node-major
541 // (More on this later.)
542 //
543 // for each additional vector in the object
544 //
545 // 11.) The global additional vector, re-ordered to be
546 // node-major (More on this later.)
547 parallel_object_only();
548 std::string comment;
549
550 // PerfLog pl("IO Performance",false);
551 // pl.push("read_serialized_data");
552 // std::size_t total_read_size = 0;
553
554 // 10.)
555 // Read the global solution vector
556 {
557 // total_read_size +=
558 this->read_serialized_vector<InValType>(io, this->solution.get());
559
560 // get the comment
561 if (this->processor_id() == 0)
562 io.comment (comment);
563 }
564
565 // 11.)
566 // Only read additional vectors if data is available, and only use
567 // that data to fill our vectors if the user requested it.
568 if (this->_additional_data_written)
569 {
570 const std::size_t nvecs = this->_vectors.size();
571
572 // If the number of additional vectors written is non-zero, and
573 // the number of additional vectors we have is non-zero, and
574 // they don't match, then we can't read additional vectors
575 // and be sure we're reading data into the correct places.
576 if (read_additional_data && nvecs &&
577 nvecs != this->_additional_data_written)
578 libmesh_error_msg
579 ("Additional vectors in file do not match system");
580
581 auto pos = _vectors.begin();
582
583 for (std::size_t i = 0; i != this->_additional_data_written; ++i)
584 {
585 // Read data, but only put it into a vector if we've been
586 // asked to and if we have a corresponding vector to read.
587
588 // total_read_size +=
589 this->read_serialized_vector<InValType>
590 (io, (read_additional_data && nvecs) ? pos->second.get() : nullptr);
591
592 // get the comment
593 if (this->processor_id() == 0)
594 io.comment (comment);
595
596
597 // If we've got vectors then we need to be iterating through
598 // those too
599 if (pos != this->_vectors.end())
600 ++pos;
601 }
602 }
603
604 // const Real
605 // dt = pl.get_elapsed_time(),
606 // rate = total_read_size*sizeof(Number)/dt;
607
608 // libMesh::out << "Read " << total_read_size << " \"Number\" values\n"
609 // << " Elapsed time = " << dt << '\n'
610 // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
611
612 // pl.pop("read_serialized_data");
613}

References libMesh::System::_additional_data_written, libMesh::System::_vectors, libMesh::Xdr::comment(), libMesh::ParallelObject::processor_id(), and libMesh::System::solution.

Referenced by libMesh::TransientRBConstruction::initialize_truth(), libMesh::RBConstruction::read_riesz_representors_from_files(), and libMesh::TransientRBConstruction::read_riesz_representors_from_files().

◆ read_serialized_data() [2/2]

template LIBMESH_EXPORT void libMesh::System::read_serialized_data< Real > ( Xdr io,
const bool  read_additional_data = true 
)
inlineinherited

Non-templated version for backward compatibility.

Reads additional data, namely vectors, for this System. This method may safely be called on a distributed-memory mesh.

Definition at line 1370 of file system.h.

1372 { read_serialized_data<Number>(io, read_additional_data); }

◆ read_serialized_vector() [1/2]

numeric_index_type libMesh::System::read_serialized_vector ( Xdr io,
NumericVector< Number > &  vec 
)
inlineprivateinherited

Non-templated version for backward compatibility.

Reads a vector for this System. This method may safely be called on a distributed-memory mesh.

Returns
The length of the vector read.

Definition at line 2126 of file system.h.

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

◆ read_serialized_vector() [2/2]

template<typename InValType >
template LIBMESH_EXPORT numeric_index_type libMesh::System::read_serialized_vector< Real > ( Xdr io,
NumericVector< Number > *  vec 
)
privateinherited

Reads a vector for this System.

This method may safely be called on a distributed-memory mesh.

Returns
The length of the vector read.

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

Definition at line 986 of file system_io.C.

988{
989 parallel_object_only();
990
991#ifndef NDEBUG
992 // In parallel we better be reading a parallel vector -- if not
993 // we will not set all of its components below!!
994 if (this->n_processors() > 1 && vec)
995 {
996 libmesh_assert (vec->type() == PARALLEL ||
997 vec->type() == GHOSTED);
998 }
999#endif
1000
1001 libmesh_assert (io.reading());
1002
1003 // vector length
1004 unsigned int vector_length=0; // FIXME? size_t would break binary compatibility...
1005#ifndef NDEBUG
1006 std::size_t n_assigned_vals=0;
1007#endif
1008
1009 // Get the buffer size
1010 if (this->processor_id() == 0)
1011 io.data(vector_length, "# vector length");
1012 this->comm().broadcast(vector_length);
1013
1014 const unsigned int nv = cast_int<unsigned int>
1015 (this->_written_var_indices.size());
1016 const dof_id_type
1017 n_nodes = this->get_mesh().n_nodes(),
1018 n_elem = this->get_mesh().n_elem();
1019
1020 libmesh_assert_less_equal (nv, this->n_vars());
1021
1022 // for newer versions, read variables node/elem major
1023 if (io.version() >= LIBMESH_VERSION_ID(0,7,4))
1024 {
1025 //---------------------------------
1026 // Collect the values for all nodes
1027#ifndef NDEBUG
1028 n_assigned_vals +=
1029#endif
1031 this->get_mesh().local_nodes_begin(),
1032 this->get_mesh().local_nodes_end(),
1033 InValType(),
1034 io,
1035 std::vector<NumericVector<Number> *> (1,vec));
1036
1037
1038 //------------------------------------
1039 // Collect the values for all elements
1040#ifndef NDEBUG
1041 n_assigned_vals +=
1042#endif
1044 this->get_mesh().local_elements_begin(),
1045 this->get_mesh().local_elements_end(),
1046 InValType(),
1047 io,
1048 std::vector<NumericVector<Number> *> (1,vec));
1049 }
1050
1051 // for older versions, read variables var-major
1052 else
1053 {
1054 // Loop over each variable in the system, and then each node/element in the mesh.
1055 for (unsigned int data_var=0; data_var<nv; data_var++)
1056 {
1057 const unsigned int var = _written_var_indices[data_var];
1058 if (this->variable(var).type().family != SCALAR)
1059 {
1060 //---------------------------------
1061 // Collect the values for all nodes
1062#ifndef NDEBUG
1063 n_assigned_vals +=
1064#endif
1066 this->get_mesh().local_nodes_begin(),
1067 this->get_mesh().local_nodes_end(),
1068 InValType(),
1069 io,
1070 std::vector<NumericVector<Number> *> (1,vec),
1071 var);
1072
1073
1074 //------------------------------------
1075 // Collect the values for all elements
1076#ifndef NDEBUG
1077 n_assigned_vals +=
1078#endif
1080 this->get_mesh().local_elements_begin(),
1081 this->get_mesh().local_elements_end(),
1082 InValType(),
1083 io,
1084 std::vector<NumericVector<Number> *> (1,vec),
1085 var);
1086 } // end variable loop
1087 }
1088 }
1089
1090 //-------------------------------------------
1091 // Finally loop over all the SCALAR variables
1092 for (unsigned int data_var=0; data_var<nv; data_var++)
1093 {
1094 const unsigned int var = _written_var_indices[data_var];
1095 if (this->variable(var).type().family == SCALAR)
1096 {
1097#ifndef NDEBUG
1098 n_assigned_vals +=
1099#endif
1100 this->read_SCALAR_dofs (var, io, vec);
1101 }
1102 }
1103
1104 if (vec)
1105 vec->close();
1106
1107#ifndef NDEBUG
1108 this->comm().sum (n_assigned_vals);
1109 libmesh_assert_equal_to (n_assigned_vals, vector_length);
1110#endif
1111
1112 return vector_length;
1113}
virtual dof_id_type n_elem() const =0
virtual dof_id_type n_nodes() const =0
std::size_t read_serialized_blocked_dof_objects(const dof_id_type n_objects, const iterator_type begin, const iterator_type end, const InValType dummy, Xdr &io, const std::vector< NumericVector< Number > * > &vecs, const unsigned int var_to_read=libMesh::invalid_uint) const
Reads an input vector from the stream io and assigns the values to a set of DofObjects.
Definition system_io.C:618
unsigned int read_SCALAR_dofs(const unsigned int var, Xdr &io, NumericVector< Number > *vec) const
Reads the SCALAR dofs from the stream io and assigns the values to the appropriate entries of vec.
Definition system_io.C:939
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Count up the number of elements of a specific type (as defined by an iterator range).
const dof_id_type n_nodes
Definition tecplot_io.C:67

References libMesh::System::_written_var_indices, libMesh::Parallel::Communicator::broadcast(), libMesh::NumericVector< T >::close(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::System::get_mesh(), libMesh::GHOSTED, libMesh::libmesh_assert(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), n_nodes, libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMesh::PARALLEL, libMesh::ParallelObject::processor_id(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::Xdr::reading(), libMesh::SCALAR, libMesh::Parallel::Communicator::sum(), libMesh::NumericVector< T >::type(), libMesh::System::variable(), and libMesh::Xdr::version().

◆ read_serialized_vectors() [1/2]

template<typename InValType >
std::size_t libMesh::System::read_serialized_vectors ( Xdr io,
const std::vector< NumericVector< Number > * > &  vectors 
) const
inherited

Read a number of identically distributed vectors.

This method allows for optimization for the multiple vector case by only communicating the metadata once.

Definition at line 2015 of file system_io.C.

2017{
2018 parallel_object_only();
2019
2020 // Error checking
2021 // #ifndef NDEBUG
2022 // // In parallel we better be reading a parallel vector -- if not
2023 // // we will not set all of its components below!!
2024 // if (this->n_processors() > 1)
2025 // {
2026 // libmesh_assert (vec.type() == PARALLEL ||
2027 // vec.type() == GHOSTED);
2028 // }
2029 // #endif
2030
2031 libmesh_assert (io.reading());
2032
2033 if (this->processor_id() == 0)
2034 {
2035 // sizes
2036 unsigned int num_vecs=0;
2037 dof_id_type vector_length=0;
2038
2039 // Get the number of vectors
2040 io.data(num_vecs);
2041 // Get the buffer size
2042 io.data(vector_length);
2043
2044 libmesh_error_msg_if
2045 (num_vecs != vectors.size(),
2046 "Xdr file header declares " << num_vecs << " vectors, but we were asked to read " << vectors.size());
2047
2048 if (num_vecs != 0)
2049 {
2050 libmesh_error_msg_if (vectors[0] == nullptr, "vectors[0] should not be null");
2051 libmesh_error_msg_if (vectors[0]->size() != vector_length, "Inconsistent vector sizes");
2052 }
2053 }
2054
2055 // no need to actually communicate these.
2056 // this->comm().broadcast(num_vecs);
2057 // this->comm().broadcast(vector_length);
2058
2059 // Cache these - they are not free!
2060 const dof_id_type
2061 n_nodes = this->get_mesh().n_nodes(),
2062 n_elem = this->get_mesh().n_elem();
2063
2064 std::size_t read_length = 0;
2065
2066 //---------------------------------
2067 // Collect the values for all nodes
2068 read_length +=
2070 this->get_mesh().local_nodes_begin(),
2071 this->get_mesh().local_nodes_end(),
2072 InValType(),
2073 io,
2074 vectors);
2075
2076 //------------------------------------
2077 // Collect the values for all elements
2078 read_length +=
2080 this->get_mesh().local_elements_begin(),
2081 this->get_mesh().local_elements_end(),
2082 InValType(),
2083 io,
2084 vectors);
2085
2086 //-------------------------------------------
2087 // Finally loop over all the SCALAR variables
2088 for (NumericVector<Number> * vec : vectors)
2089 for (auto var : make_range(this->n_vars()))
2090 if (this->variable(var).type().family == SCALAR)
2091 {
2092 libmesh_assert_not_equal_to (vec, 0);
2093
2094 read_length +=
2095 this->read_SCALAR_dofs (var, io, vec);
2096 }
2097
2098 //---------------------------------------
2099 // last step - must close all the vectors
2100 for (NumericVector<Number> * vec : vectors)
2101 {
2102 libmesh_assert_not_equal_to (vec, 0);
2103 vec->close();
2104 }
2105
2106 return read_length;
2107}

References libMesh::Xdr::data(), libMesh::FEType::family, libMesh::System::get_mesh(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), n_nodes, libMesh::System::n_vars(), libMesh::ParallelObject::processor_id(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::Xdr::reading(), libMesh::SCALAR, libMesh::Variable::type(), and libMesh::System::variable().

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

◆ read_serialized_vectors() [2/2]

template LIBMESH_EXPORT std::size_t libMesh::System::read_serialized_vectors< Real > ( Xdr io,
const std::vector< NumericVector< Number > * > &  vectors 
) const
inlineinherited

Non-templated version for backward compatibility.

Read a number of identically distributed vectors. This method allows for optimization for the multiple vector case by only communicating the metadata once.

Definition at line 1390 of file system.h.

1392 { return read_serialized_vectors<Number>(io, vectors); }

◆ reinit()

void libMesh::System::reinit ( )
virtualinherited

Reinitializes degrees of freedom and other required data on the current mesh.

Note
The matrix is not initialized at this time since it may not be required for all applications. Should be overridden in derived classes.

Reimplemented in libMesh::CondensedEigenSystem, libMesh::DifferentiableSystem, libMesh::EigenSystem, libMesh::LinearImplicitSystem, libMesh::NewmarkSystem, libMesh::NonlinearImplicitSystem, and libMesh::OptimizationSystem.

Definition at line 442 of file system.C.

443{
444 parallel_object_only();
445
446 // project_vector handles vector initialization now
447 libmesh_assert_equal_to (solution->size(), current_local_solution->size());
448
449 // Make sure our static condensation dof map is up-to-date before we init any
450 // static condensation matrices
452
453 if (!_matrices.empty() && !_basic_system_only)
454 {
455 // Clear the matrices
456 for (auto & pr : _matrices)
457 {
458 pr.second->clear();
459 pr.second->attach_dof_map(this->get_dof_map());
460 }
461
463 {
464 // Clear the sparsity pattern
465 this->get_dof_map().clear_sparsity();
466
467 // Compute the sparsity pattern for the current
468 // mesh and DOF distribution. This also updates
469 // additional matrices, \p DofMap now knows them
470 this->get_dof_map().compute_sparsity (this->get_mesh());
471 }
472
473 // Initialize matrices and set to zero
474 for (auto & pr : _matrices)
475 {
476 pr.second->init();
477 pr.second->zero();
478 }
479 }
480}
void reinit_static_condensation()
Calls reinit on the static condensation map if it exists.
Definition dof_map.C:3140
void clear_sparsity()
Clears the sparsity pattern.
Definition dof_map.C:1981
bool _basic_system_only
Holds true if the components of more advanced system types (e.g.
Definition system.h:2300

References libMesh::System::_basic_system_only, libMesh::System::_matrices, libMesh::System::_require_sparsity_pattern, libMesh::DofMap::clear_sparsity(), libMesh::DofMap::compute_sparsity(), libMesh::System::current_local_solution, libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::DofMap::reinit_static_condensation(), and libMesh::System::solution.

Referenced by alternative_fe_assembly(), libMesh::RBEIMConstruction::initialize_qp_data(), libMesh::DifferentiableSystem::reinit(), libMesh::EigenSystem::reinit(), libMesh::LinearImplicitSystem::reinit(), libMesh::NonlinearImplicitSystem::reinit(), and libMesh::OptimizationSystem::reinit().

◆ reinit_constraints()

void libMesh::System::reinit_constraints ( )
virtualinherited

Reinitializes the constraints for this system.

Also prepares the send_list, whether or not constraints have changed.

Definition at line 483 of file system.C.

484{
485 parallel_object_only();
486
487#ifdef LIBMESH_ENABLE_CONSTRAINTS
491 if (libMesh::on_command_line ("--print-constraints"))
493#endif
495}
void prepare_send_list()
Takes the _send_list vector (which may have duplicate entries) and sorts it.
Definition dof_map.C:1835
void print_dof_constraints(std::ostream &os=libMesh::out, bool print_nonlocal=false) const
Prints (from processor 0) all DoF and Node constraints.
void create_dof_constraints(const MeshBase &, Real time=0)
Rebuilds the raw degree of freedom and DofObject constraints, based on attached DirichletBoundary obj...
void process_constraints(MeshBase &)
Postprocesses any constrained degrees of freedom to be constrained only in terms of unconstrained dof...
virtual void user_constrain()
Calls user's attached constraint function, or is overridden by the user in derived classes.
Definition system.C:2123

References libMesh::System::_mesh, libMesh::DofMap::create_dof_constraints(), libMesh::System::get_dof_map(), libMesh::on_command_line(), libMesh::out, libMesh::DofMap::prepare_send_list(), libMesh::DofMap::print_dof_constraints(), libMesh::DofMap::process_constraints(), libMesh::System::time, and libMesh::System::user_constrain().

Referenced by libMesh::EquationSystems::allgather(), libMesh::System::init_data(), libMesh::PetscDMWrapper::init_petscdm(), and libMesh::EquationSystems::reinit_solutions().

◆ reinit_eim_projection_matrix()

void libMesh::RBEIMConstruction::reinit_eim_projection_matrix ( )
inherited

Zero the _eim_projection_matrix and resize it to be get_Nmax() x get_Nmax().

Definition at line 1361 of file rb_eim_construction.C.

1362{
1363 RBEIMEvaluation & rbe = get_rb_eim_evaluation();
1364
1365 // We need space for one extra interpolation point if we're using the
1366 // EIM error indicator.
1367 unsigned int max_matrix_size = rbe.use_eim_error_indicator() ? get_Nmax()+1 : get_Nmax();
1368 _eim_projection_matrix.resize(max_matrix_size,max_matrix_size);
1369}

References libMesh::RBEIMConstruction::_eim_projection_matrix, libMesh::RBEIMConstruction::get_Nmax(), libMesh::RBEIMConstruction::get_rb_eim_evaluation(), libMesh::DenseMatrix< T >::resize(), and libMesh::RBEIMEvaluation::use_eim_error_indicator().

◆ reinit_mesh()

void libMesh::System::reinit_mesh ( )
virtualinherited

Reinitializes the system with a new mesh.

Definition at line 289 of file system.C.

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

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

Referenced by libMesh::System::init(), libMesh::PetscPreconditioner< T >::set_hypre_ads_data(), and libMesh::PetscPreconditioner< T >::set_hypre_ams_data().

◆ remove_matrix()

void libMesh::System::remove_matrix ( std::string_view  mat_name)
inherited

Removes the additional matrix mat_name from this system.

Definition at line 1076 of file system.C.

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

References libMesh::System::_matrices.

◆ remove_vector()

void libMesh::System::remove_vector ( std::string_view  vec_name)
inherited

Removes the additional vector vec_name from this system.

Definition at line 861 of file system.C.

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

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

Referenced by libMesh::AdjointRefinementEstimator::estimate_error(), and libMesh::UnsteadySolver::integrate_adjoint_sensitivity().

◆ request_matrix() [1/2]

SparseMatrix< Number > * libMesh::System::request_matrix ( std::string_view  mat_name)
inherited
Returns
A writable pointer to this system's additional matrix named mat_name, or nullptr if no matrix by that name exists.

Definition at line 1099 of file system.C.

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

References libMesh::System::_matrices.

◆ request_matrix() [2/2]

const SparseMatrix< Number > * libMesh::System::request_matrix ( std::string_view  mat_name) const
inherited
Returns
A const pointer to this system's additional matrix named mat_name, or nullptr if no matrix by that name exists.

Definition at line 1087 of file system.C.

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

References libMesh::System::_matrices.

Referenced by libMesh::EigenSystem::has_matrix_A(), libMesh::EigenSystem::has_matrix_B(), libMesh::EigenSystem::has_precond_matrix(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::NewtonSolver::solve(), and libMesh::LinearImplicitSystem::solve().

◆ request_vector() [1/4]

NumericVector< Number > * libMesh::System::request_vector ( const unsigned int  vec_num)
inherited
Returns
A writable pointer to this system's additional vector number vec_num (where the vectors are counted starting with 0), or nullptr if the system has no such vector.

Definition at line 917 of file system.C.

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

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

◆ request_vector() [2/4]

const NumericVector< Number > * libMesh::System::request_vector ( const unsigned int  vec_num) const
inherited
Returns
A const pointer to this system's additional vector number vec_num (where the vectors are counted starting with 0), or nullptr if the system has no such vector.

Definition at line 903 of file system.C.

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

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

◆ request_vector() [3/4]

NumericVector< Number > * libMesh::System::request_vector ( std::string_view  vec_name)
inherited
Returns
A pointer to the vector if this System has a vector associated with the given name, nullptr otherwise.

Definition at line 891 of file system.C.

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

References libMesh::System::_vectors, and libMesh::NumericVector< T >::get().

◆ request_vector() [4/4]

const NumericVector< Number > * libMesh::System::request_vector ( std::string_view  vec_name) const
inherited
Returns
A const pointer to the vector if this System has a vector associated with the given name, nullptr otherwise.

Definition at line 879 of file system.C.

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

References libMesh::System::_vectors, and libMesh::NumericVector< T >::get().

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

◆ restrict_solve_to()

void libMesh::System::restrict_solve_to ( const SystemSubset subset,
const SubsetSolveMode  subset_solve_mode = SUBSET_ZERO 
)
virtualinherited

After calling this method, any solve will be restricted to the given subdomain.

To disable this mode, call this method with subset being a nullptr.

Reimplemented in libMesh::LinearImplicitSystem.

Definition at line 545 of file system.C.

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

◆ restrict_vectors()

void libMesh::System::restrict_vectors ( )
virtualinherited

Restrict vectors after the mesh has coarsened.

Definition at line 374 of file system.C.

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

References libMesh::System::_dof_map, libMesh::System::_solution_projection, libMesh::System::_vector_projections, libMesh::System::_vectors, libMesh::System::current_local_solution, libMesh::NumericVector< T >::get(), libMesh::GHOSTED, libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::PARALLEL, libMesh::System::project_vector(), libMesh::System::solution, and libMesh::System::vector_is_adjoint().

Referenced by libMesh::System::prolong_vectors(), and libMesh::EquationSystems::reinit_solutions().

◆ scale_node_parametrized_function()

void libMesh::RBEIMConstruction::scale_node_parametrized_function ( NodeDataMap local_pf,
Number  scaling_factor 
)
staticprivateinherited

Scale all values in pf by scaling_factor The templated function above handles the elem and side cases, and this separate case handles the node case.

Definition at line 3080 of file rb_eim_construction.C.

3082{
3083 for (auto & pr : local_pf)
3084 {
3085 auto & values = pr.second;
3086 for ( auto & value : values)
3087 value *= scaling_factor;
3088 }
3089}

References value.

Referenced by libMesh::RBEIMConstruction::apply_normalization_to_solution_snapshots(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_nodes(), and libMesh::RBEIMConstruction::train_eim_approximation_with_POD().

◆ scale_parametrized_function()

template<class DataMap >
static void libMesh::RBEIMConstruction::scale_parametrized_function ( DataMap &  local_pf,
Number  scaling_factor 
)
inlinestaticprivateinherited

Scale all values in pf by scaling_factor.

Definition at line 440 of file rb_eim_construction.h.

442 {
443 for (auto & pr : local_pf)
444 {
445 auto & comp_and_qp = pr.second;
446
447 for (unsigned int comp : index_range(comp_and_qp))
448 {
449 std::vector<Number> & qp_values = comp_and_qp[comp];
450
451 for (unsigned int qp : index_range(qp_values))
452 {
453 qp_values[qp] *= scaling_factor;
454 }
455 }
456 }
457 }

References libMesh::index_range().

Referenced by libMesh::RBEIMConstruction::apply_normalization_to_solution_snapshots(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), and libMesh::RBEIMConstruction::train_eim_approximation_with_POD().

◆ sensitivity_solve()

std::pair< unsigned int, Real > libMesh::System::sensitivity_solve ( const ParameterVector parameters)
inlinevirtualinherited

Solves the sensitivity system, for the provided parameters.

Must be overridden in derived systems.

Returns
A pair with the total number of linear iterations performed and the (sum of the) final residual norms

This method is only implemented in some derived classes.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2571 of file system.h.

2572{
2573 libmesh_not_implemented();
2574}

◆ set_abs_training_tolerance()

void libMesh::RBEIMConstruction::set_abs_training_tolerance ( Real  new_training_tolerance)
inherited

Get/set the absolute tolerance for the basis training.

Definition at line 1200 of file rb_eim_construction.C.

1201{
1202 _abs_training_tolerance = new_training_tolerance;
1203}

References libMesh::RBEIMConstruction::_abs_training_tolerance.

Referenced by libMesh::RBEIMConstruction::set_rb_construction_parameters().

◆ set_adjoint_already_solved()

void libMesh::System::set_adjoint_already_solved ( bool  setting)
inlineinherited

Setter for the adjoint_already_solved boolean.

Definition at line 417 of file system.h.

418 { adjoint_already_solved = setting;}

References libMesh::System::adjoint_already_solved.

Referenced by main().

◆ set_basic_system_only()

void libMesh::System::set_basic_system_only ( )
inlineinherited

Sets the system to be "basic only": i.e.

advanced system components such as ImplicitSystem matrices may not be initialized. This is useful for efficiency in certain utility programs that never use System::solve(). This method must be called after the System or derived class is created but before it is initialized; e.g. from within EquationSystems::read()

Definition at line 2465 of file system.h.

2466{
2467 _basic_system_only = true;
2468}

References libMesh::System::_basic_system_only.

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

◆ set_best_fit_type_flag()

void libMesh::RBEIMConstruction::set_best_fit_type_flag ( const std::string &  best_fit_type_string)
virtualinherited

Specify which type of "best fit" we use to guide the EIM greedy algorithm.

Definition at line 169 of file rb_eim_construction.C.

170{
171 if (best_fit_type_string == "projection")
172 {
174 }
175 else if (best_fit_type_string == "eim")
176 {
178 }
179 else if (best_fit_type_string == "pod")
180 {
182 }
183 else
184 libmesh_error_msg("Error: invalid best_fit_type in input file");
185}

References libMesh::RBEIMConstruction::best_fit_type_flag, libMesh::RBEIMConstruction::EIM_BEST_FIT, libMesh::RBEIMConstruction::POD_BEST_FIT, and libMesh::RBEIMConstruction::PROJECTION_BEST_FIT.

Referenced by libMesh::RBEIMConstruction::process_parameters_file().

◆ set_deterministic_training_parameter_name()

void libMesh::RBConstructionBase< System >::set_deterministic_training_parameter_name ( const std::string &  name)
inherited

In some cases we only want to allow discrete parameter values, instead of parameters that may take any value in a specified interval.

Here we provide a method to set the d Set the discrete values for parameter mu that are allowed in the training set. This must be called before the training set is generated. Set the name of the parameter that we will generate deterministic training parameters for. Defaults to "NONE".

◆ set_Nmax()

void libMesh::RBEIMConstruction::set_Nmax ( unsigned int  Nmax)
virtualinherited

Definition at line 1215 of file rb_eim_construction.C.

1216{
1217 _Nmax = Nmax;
1218}

References libMesh::RBEIMConstruction::_Nmax.

Referenced by libMesh::RBEIMConstruction::set_rb_construction_parameters().

◆ set_normalize_solution_snapshots()

void libMesh::RBConstructionBase< System >::set_normalize_solution_snapshots ( bool  value)
inherited

Set the boolean option that indicates if we normalization solution snapshots or not.

Definition at line 113 of file rb_construction_base.C.

148{
150}
bool _normalize_solution_snapshots
Set this boolean to true if we want to normalize solution snapshots used in training to have norm of ...

◆ set_parameters()

bool libMesh::RBParametrized::set_parameters ( const RBParameters params)
inherited

Set the current parameters to params The parameters are checked for validity; an error is thrown if the number of parameters or samples is different than expected.

We

Returns
a boolean true if the new parameters are within the min/max range, and false otherwise (but the parameters are set regardless). Enabling the "verbose_mode" flag will also print more details.

Definition at line 129 of file rb_parametrized.C.

130{
131 libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::set_parameters");
132
133 // Terminate if params has the wrong number of parameters or samples.
134 // If the parameters are outside the min/max range, return false.
135 const bool valid_params = check_if_valid_params(params);
136
137 // Make a copy of params (default assignment operator just does memberwise copy, which is sufficient here)
138 this->parameters = params;
139
140 return valid_params;
141}
bool check_if_valid_params(const RBParameters &params) const
Helper function to check that params is valid:

References libMesh::RBParametrized::check_if_valid_params(), libMesh::RBParametrized::parameters, and libMesh::RBParametrized::parameters_initialized.

Referenced by libMesh::RBSCMConstruction::compute_SCM_bounds_on_training_set(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_nodes(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), libMesh::RBConstruction::get_RB_error_bound(), SimpleRBEvaluation::get_stability_lower_bound(), libMesh::RBParametrized::initialize_parameters(), main(), libMesh::RBSCMEvaluation::reload_current_parameters(), libMesh::RBSCMEvaluation::set_current_parameters_from_C_J(), and RBParametersTest::testRBParametrized().

◆ set_params_from_training_set()

void libMesh::RBConstructionBase< System >::set_params_from_training_set ( unsigned int  global_index)
protectedinherited

Set parameters to the RBParameters stored in index global_index of the global training set.

Definition at line 243 of file rb_construction_base.C.

226{
228}

◆ set_params_from_training_set_and_broadcast()

void libMesh::RBConstructionBase< System >::set_params_from_training_set_and_broadcast ( unsigned int  global_index)
protectedvirtualinherited

Load the specified training parameter and then broadcast to all processors.

Definition at line 248 of file rb_construction_base.C.

271{
272 libmesh_error_msg_if(!_training_parameters_initialized,
273 "Error: training parameters must first be initialized.");
274
275 processor_id_type root_id = 0;
276 if ((this->get_first_local_training_index() <= global_index) &&
277 (global_index < this->get_last_local_training_index()))
278 {
279 // Set parameters on only one processor
280 set_params_from_training_set(global_index);
281
282 // set root_id, only non-zero on one processor
283 root_id = this->processor_id();
284 }
285
286 // broadcast
287 this->comm().max(root_id);
288 broadcast_parameters(root_id);
289}
void broadcast_parameters(const unsigned int proc_id)
Broadcasts parameters from processor proc_id to all processors.
uint8_t processor_id_type

◆ set_project_with_constraints()

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

Definition at line 1842 of file system.h.

1843 {
1844 project_with_constraints = _project_with_constraints;
1845 }

References libMesh::System::project_with_constraints.

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

◆ set_qoi() [1/2]

void libMesh::System::set_qoi ( std::vector< Number new_qoi)
inherited

Definition at line 2197 of file system.C.

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

◆ set_qoi() [2/2]

void libMesh::System::set_qoi ( unsigned int  qoi_index,
Number  qoi_value 
)
inherited

◆ set_qoi_error_estimate()

void libMesh::System::set_qoi_error_estimate ( unsigned int  qoi_index,
Number  qoi_error_estimate 
)
inherited

◆ set_quiet_mode()

void libMesh::RBConstructionBase< System >::set_quiet_mode ( bool  quiet_mode_in)
inlineinherited

Set the quiet_mode flag.

If quiet == false then we print out a lot of extra information during the Offline stage.

Definition at line 100 of file rb_construction_base.h.

101 { this->quiet_mode = quiet_mode_in; }

◆ set_rb_construction_parameters()

void libMesh::RBEIMConstruction::set_rb_construction_parameters ( unsigned int  n_training_samples_in,
bool  deterministic_training_in,
int  training_parameters_random_seed_in,
bool  quiet_mode_in,
unsigned int  Nmax_in,
Real  rel_training_tolerance_in,
Real  abs_training_tolerance_in,
const RBParameters mu_min_in,
const RBParameters mu_max_in,
const std::map< std::string, std::vector< Real > > &  discrete_parameter_values_in,
const std::map< std::string, bool > &  log_scaling,
std::map< std::string, std::vector< RBParameter > > *  training_sample_list = nullptr 
)
inherited

Set the state of this RBConstruction object based on the arguments to this function.

Definition at line 308 of file rb_eim_construction.C.

320{
321 // Read in training_parameters_random_seed value. This is used to
322 // seed the RNG when picking the training parameters. By default the
323 // value is -1, which means use std::time to seed the RNG.
324 set_training_random_seed(training_parameters_random_seed_in);
325
326 // Set quiet mode
327 set_quiet_mode(quiet_mode_in);
328
329 // Initialize RB parameters
330 set_Nmax(Nmax_in);
331
332 set_rel_training_tolerance(rel_training_tolerance_in);
333 set_abs_training_tolerance(abs_training_tolerance_in);
334
335 if (get_rb_eim_evaluation().get_parametrized_function().is_lookup_table)
336 {
337 const std::string & lookup_table_param_name =
339
340 libmesh_error_msg_if(!discrete_parameter_values_in.count(lookup_table_param_name),
341 "Lookup table parameter should be discrete");
342
343 // Make an editable copy of discrete_parameters_values_in.
344 std::map<std::string, std::vector<Real>> discrete_parameter_values_final(
345 discrete_parameter_values_in);
346
347 std::vector<Real> & lookup_table_param_values =
348 libmesh_map_find(discrete_parameter_values_final, lookup_table_param_name);
349
350 // Overwrite the discrete values for lookup_table_param to make sure that
351 // it is: 0, 1, 2, ..., size-1.
352 std::iota(lookup_table_param_values.begin(), lookup_table_param_values.end(), 0);
353
354 // Also, overwrite n_training_samples_in to make sure it matches
355 // lookup_table_size so that we will get full coverage of the
356 // lookup table in our training set.
357 n_training_samples_in = lookup_table_param_values.size();
358
359 // Initialize the parameter ranges and the parameters themselves
360 initialize_parameters(mu_min_in, mu_max_in, discrete_parameter_values_final);
361 }
362 else
363 {
364 // Initialize the parameter ranges and the parameters themselves
365 initialize_parameters(mu_min_in, mu_max_in, discrete_parameter_values_in);
366 }
367
368 bool updated_deterministic_training = deterministic_training_in;
369 if (training_sample_list && (this->get_parameters_min().n_parameters() > 3))
370 {
371 // In this case we force deterministic_training to be false because
372 // a) deterministic training samples are not currrently supported with
373 // more than 3 parameters, and
374 // b) we will overwrite the training samples anyway in the call to
375 // load_training_set() below, so we do not want to generate an
376 // error due to deterministic training sample generation when
377 // the samples will be overwritten anyway.
378 updated_deterministic_training = false;
379 }
380
382 this->get_parameters_max(),
383 n_training_samples_in,
384 log_scaling_in,
385 updated_deterministic_training);
386
387 if (training_sample_list)
388 {
389 // Note that we must call initialize_training_parameters() before
390 // load_training_set() in order to initialize the parameter vectors.
391 load_training_set(*training_sample_list);
392 }
393
394
395 if (get_rb_eim_evaluation().get_parametrized_function().is_lookup_table)
396 {
397 // Also, now that we've initialized the training set, overwrite the training
398 // samples to ensure that we have full coverage of the lookup tbale.
399 const std::string & lookup_table_param_name =
401
402 // Fill the lookup_table_training_samples with sequential single-entry vectors,
403 // i.e. {{0.0}, {1.0}, {2.0}, ...}
404 Real val = 0.0;
405 std::vector<RBParameter> lookup_table_training_samples(n_training_samples_in, {val});
406 for (auto & vec : lookup_table_training_samples)
407 {
408 vec[0] = val;
409 val += 1.0; // Could use val++, but better to be explicit for doubles.
410 }
411
412 set_training_parameter_values(lookup_table_param_name, lookup_table_training_samples);
413 }
414}
void set_training_random_seed(int seed)
Set the seed that is used to randomly generate training parameters.
void set_quiet_mode(bool quiet_mode_in)
Set the quiet_mode flag.
void set_training_parameter_values(const std::string &param_name, const std::vector< RBParameter > &values)
Overwrite the local training samples for param_name using values.
virtual void initialize_training_parameters(const RBParameters &mu_min, const RBParameters &mu_max, const unsigned int n_global_training_samples, const std::map< std::string, bool > &log_param_scale, const bool deterministic=true)
Initialize the parameter ranges and indicate whether deterministic or random training parameters shou...
virtual void load_training_set(const std::map< std::string, std::vector< RBParameter > > &new_training_set)
Overwrite the training parameters with new_training_set.
void set_rel_training_tolerance(Real new_training_tolerance)
Get/set the relative tolerance for the basis training.
void set_abs_training_tolerance(Real new_training_tolerance)
Get/set the absolute tolerance for the basis training.
virtual void set_Nmax(unsigned int Nmax)
std::string lookup_table_param_name
If this is a lookup table, then lookup_table_param_name specifies the parameter that is used to index...
const RBParameters & get_parameters_max() const
Get an RBParameters object that specifies the maximum allowable value for each parameter.
const RBParameters & get_parameters_min() const
Get an RBParameters object that specifies the minimum allowable value for each parameter.

References libMesh::RBParametrized::get_parameters_max(), libMesh::RBParametrized::get_parameters_min(), libMesh::RBEIMEvaluation::get_parametrized_function(), libMesh::RBEIMConstruction::get_rb_eim_evaluation(), libMesh::RBParametrized::initialize_parameters(), libMesh::RBConstructionBase< System >::initialize_training_parameters(), libMesh::RBConstructionBase< System >::load_training_set(), libMesh::RBParametrizedFunction::lookup_table_param_name, libMesh::Real, libMesh::RBEIMConstruction::set_abs_training_tolerance(), libMesh::RBEIMConstruction::set_Nmax(), libMesh::RBConstructionBase< System >::set_quiet_mode(), libMesh::RBEIMConstruction::set_rel_training_tolerance(), libMesh::RBConstructionBase< System >::set_training_parameter_values(), and libMesh::RBConstructionBase< System >::set_training_random_seed().

Referenced by libMesh::RBEIMConstruction::process_parameters_file().

◆ set_rb_eim_evaluation()

void libMesh::RBEIMConstruction::set_rb_eim_evaluation ( RBEIMEvaluation rb_eim_eval_in)
inherited

Set the RBEIMEvaluation object.

Definition at line 152 of file rb_eim_construction.C.

153{
154 _rb_eim_eval = &rb_eim_eval_in;
155}

References libMesh::RBEIMConstruction::_rb_eim_eval.

Referenced by main().

◆ set_rel_training_tolerance()

void libMesh::RBEIMConstruction::set_rel_training_tolerance ( Real  new_training_tolerance)
inherited

Get/set the relative tolerance for the basis training.

Definition at line 1190 of file rb_eim_construction.C.

1191{
1192 _rel_training_tolerance = new_training_tolerance;
1193}

References libMesh::RBEIMConstruction::_rel_training_tolerance.

Referenced by libMesh::RBEIMConstruction::set_rb_construction_parameters().

◆ set_training_parameter_values()

void libMesh::RBConstructionBase< System >::set_training_parameter_values ( const std::string &  param_name,
const std::vector< RBParameter > &  values 
)
inherited

Overwrite the local training samples for param_name using values.

This assumes that values.size() matches get_local_n_training_samples().

Definition at line 158 of file rb_construction_base.C.

458{
459 libmesh_error_msg_if(!_training_parameters_initialized,
460 "Training parameters must be initialized before calling set_training_parameter_values");
461 libmesh_error_msg_if(values.size() != get_local_n_training_samples(),
462 "Inconsistent sizes");
463
464 // Copy the new data, overwriting the old data.
465 auto & training_vector = libmesh_map_find(_training_parameters, param_name);
466 training_vector = values;
467}

◆ set_training_random_seed()

void libMesh::RBConstructionBase< System >::set_training_random_seed ( int  seed)
inherited

Set the seed that is used to randomly generate training parameters.

Definition at line 170 of file rb_construction_base.C.

781{
783}
int _training_parameters_random_seed
If < 0, use std::time() * processor_id() to seed the random number generator for the training paramet...

◆ set_vector_as_adjoint()

void libMesh::System::set_vector_as_adjoint ( const std::string &  vec_name,
int  qoi_num 
)
inherited

Allows one to set the QoI index controlling whether the vector identified by vec_name represents a solution from the adjoint (qoi_num >= 0) or primal (qoi_num == -1) space.

This becomes significant if those spaces have differing heterogeneous Dirichlet constraints.

qoi_num == -2 can be used to indicate a vector which should not be affected by constraints during projection operations.

Definition at line 1147 of file system.C.

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

References libMesh::System::_vector_is_adjoint.

Referenced by libMesh::System::add_adjoint_solution(), and libMesh::System::add_weighted_sensitivity_adjoint_solution().

◆ set_vector_preservation()

void libMesh::System::set_vector_preservation ( const std::string &  vec_name,
bool  preserve 
)
inherited

Allows one to set the boolean controlling whether the vector identified by vec_name should be "preserved": projected to new meshes, saved, etc.

Definition at line 1125 of file system.C.

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

References libMesh::System::_vector_projections.

Referenced by libMesh::AdjointRefinementEstimator::estimate_error(), and main().

◆ side_inner_product()

Number libMesh::RBEIMConstruction::side_inner_product ( const SideQpDataMap v,
const SideQpDataMap w,
bool  apply_comp_scaling 
)
privateinherited

Same as inner_product() except for side data.

Definition at line 2249 of file rb_eim_construction.C.

2250{
2251 LOG_SCOPE("side_inner_product()", "RBEIMConstruction");
2252
2253 Number val = 0.;
2254
2255 for (const auto & [elem_and_side, v_comp_and_qp] : v)
2256 {
2257 const auto & w_comp_and_qp = libmesh_map_find(w, elem_and_side);
2258 const auto & JxW = libmesh_map_find(_local_side_quad_point_JxW, elem_and_side);
2259
2260 for (const auto & comp : index_range(v_comp_and_qp))
2261 {
2262 const std::vector<Number> & v_qp = v_comp_and_qp[comp];
2263 const std::vector<Number> & w_qp = w_comp_and_qp[comp];
2264
2265 Real comp_scaling = 1.;
2266 if (apply_comp_scaling)
2267 {
2268 // We square the component scaling here because it occurs twice in
2269 // the inner product calculation below.
2270 comp_scaling = std::pow(_component_scaling_in_training_set[comp], 2.);
2271 }
2272
2273 for (unsigned int qp : index_range(JxW))
2274 val += JxW[qp] * comp_scaling * v_qp[qp] * libmesh_conj(w_qp[qp]);
2275 }
2276 }
2277
2278 comm().sum(val);
2279 return val;
2280}

References libMesh::RBEIMConstruction::_component_scaling_in_training_set, libMesh::RBEIMConstruction::_local_side_quad_point_JxW, libMesh::ParallelObject::comm(), libMesh::index_range(), libMesh::libmesh_conj(), libMesh::Real, and libMesh::Parallel::Communicator::sum().

Referenced by libMesh::RBEIMConstruction::apply_normalization_to_solution_snapshots(), libMesh::RBEIMConstruction::compute_max_eim_error(), libMesh::RBEIMConstruction::train_eim_approximation_with_POD(), and libMesh::RBEIMConstruction::update_eim_matrices().

◆ solve()

virtual void libMesh::System::solve ( )
inlinevirtualinherited

◆ solve_for_unconstrained_dofs()

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

Definition at line 2103 of file system_projection.C.

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

References libMesh::DofMap::build_sparsity(), libMesh::DofMap::computed_sparsity_already(), libMesh::DofMapBase::end_dof(), libMesh::DofMapBase::first_dof(), libMesh::NumericVector< T >::get(), libMesh::DofMap::heterogenously_constrain_element_matrix_and_vector(), libMesh::DofMap::is_constrained_dof(), libMesh::NumericVector< T >::local_size(), libMesh::DofMap::n_dofs(), libMesh::DofMap::n_local_dofs(), libMesh::PARALLEL, libMesh::Real, libMesh::NumericVector< T >::size(), and libMesh::DofMap::update_sparsity_pattern().

◆ store_eim_solutions_for_training_set()

void libMesh::RBEIMConstruction::store_eim_solutions_for_training_set ( )
inherited

Get the EIM solution vector at all parametrized functions in the training set.

In some cases we want to store this data for future use. For example this is useful in the case that the parametrized function is defined based on a look-up table rather than an analytical function, since if we store the EIM solution data, we can do Online solves without initializing the look-up table data.

Definition at line 1237 of file rb_eim_construction.C.

1238{
1239 LOG_SCOPE("store_eim_solutions_for_training_set()", "RBEIMConstruction");
1240
1241 RBEIMEvaluation & eim_eval = get_rb_eim_evaluation();
1242
1243 std::vector<DenseVector<Number>> & eim_solutions = get_rb_eim_evaluation().get_eim_solutions_for_training_set();
1244 eim_solutions.clear();
1245 eim_solutions.resize(get_n_training_samples());
1246
1247 unsigned int RB_size = get_rb_eim_evaluation().get_n_basis_functions();
1248
1249 for (auto i : make_range(get_n_training_samples()))
1250 {
1251 if (eim_eval.get_parametrized_function().on_mesh_sides())
1252 {
1253 const auto & local_side_pf = _local_side_parametrized_functions_for_training[i];
1254
1255 if (RB_size > 0)
1256 {
1257 // Get the right-hand side vector for the EIM approximation
1258 // by sampling the parametrized function (stored in solution)
1259 // at the interpolation points.
1260 DenseVector<Number> EIM_rhs(RB_size);
1261 for (unsigned int j=0; j<RB_size; j++)
1262 {
1263 EIM_rhs(j) =
1265 local_side_pf,
1266 eim_eval.get_interpolation_points_elem_id(j),
1267 eim_eval.get_interpolation_points_side_index(j),
1268 eim_eval.get_interpolation_points_comp(j),
1269 eim_eval.get_interpolation_points_qp(j));
1270 }
1271 eim_solutions[i] = eim_eval.rb_eim_solve(EIM_rhs);
1272 }
1273 }
1274 else if (eim_eval.get_parametrized_function().on_mesh_nodes())
1275 {
1276 const auto & local_node_pf = _local_node_parametrized_functions_for_training[i];
1277
1278 if (RB_size > 0)
1279 {
1280 // Get the right-hand side vector for the EIM approximation
1281 // by sampling the parametrized function (stored in solution)
1282 // at the interpolation points.
1283 DenseVector<Number> EIM_rhs(RB_size);
1284 for (unsigned int j=0; j<RB_size; j++)
1285 {
1286 EIM_rhs(j) =
1288 local_node_pf,
1289 eim_eval.get_interpolation_points_node_id(j),
1290 eim_eval.get_interpolation_points_comp(j));
1291 }
1292 eim_solutions[i] = eim_eval.rb_eim_solve(EIM_rhs);
1293 }
1294 }
1295 else
1296 {
1297 const auto & local_pf = _local_parametrized_functions_for_training[i];
1298
1299 if (RB_size > 0)
1300 {
1301 // Get the right-hand side vector for the EIM approximation
1302 // by sampling the parametrized function (stored in solution)
1303 // at the interpolation points.
1304 DenseVector<Number> EIM_rhs(RB_size);
1305 for (unsigned int j=0; j<RB_size; j++)
1306 {
1307 EIM_rhs(j) =
1309 local_pf,
1310 eim_eval.get_interpolation_points_elem_id(j),
1311 eim_eval.get_interpolation_points_comp(j),
1312 eim_eval.get_interpolation_points_qp(j));
1313 }
1314 eim_solutions[i] = eim_eval.rb_eim_solve(EIM_rhs);
1315 }
1316 }
1317 }
1318}
const std::vector< DenseVector< Number > > & get_eim_solutions_for_training_set() const
Return a const reference to the EIM solutions for the parameters in the training set.

References libMesh::RBEIMConstruction::_local_node_parametrized_functions_for_training, libMesh::RBEIMConstruction::_local_parametrized_functions_for_training, libMesh::RBEIMConstruction::_local_side_parametrized_functions_for_training, libMesh::ParallelObject::comm(), libMesh::RBEIMEvaluation::get_eim_solutions_for_training_set(), libMesh::RBEIMEvaluation::get_interpolation_points_comp(), libMesh::RBEIMEvaluation::get_interpolation_points_elem_id(), libMesh::RBEIMEvaluation::get_interpolation_points_node_id(), libMesh::RBEIMEvaluation::get_interpolation_points_qp(), libMesh::RBEIMEvaluation::get_interpolation_points_side_index(), libMesh::RBEIMEvaluation::get_n_basis_functions(), libMesh::RBConstructionBase< System >::get_n_training_samples(), libMesh::RBEIMEvaluation::get_parametrized_function(), libMesh::RBEIMEvaluation::get_parametrized_function_node_value(), libMesh::RBEIMEvaluation::get_parametrized_function_side_value(), libMesh::RBEIMEvaluation::get_parametrized_function_value(), libMesh::RBEIMConstruction::get_rb_eim_evaluation(), libMesh::make_range(), libMesh::RBParametrizedFunction::on_mesh_nodes(), libMesh::RBParametrizedFunction::on_mesh_sides(), and libMesh::RBEIMEvaluation::rb_eim_solve().

Referenced by libMesh::RBEIMConstruction::train_eim_approximation_with_greedy().

◆ system()

sys_type & libMesh::RBConstructionBase< System >::system ( )
inlineinherited
Returns
A reference to *this.

Definition at line 87 of file rb_construction_base.h.

87{ return *this; }

◆ system_type()

virtual std::string libMesh::System::system_type ( ) const
inlinevirtualinherited
Returns
The type of system, helpful in identifying which system type to use when reading equation system data from file. Should be overridden in derived classes.

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

Definition at line 510 of file system.h.

510{ return "Basic"; }

Referenced by main().

◆ train_eim_approximation()

Real libMesh::RBEIMConstruction::train_eim_approximation ( )
virtualinherited

Generate the EIM approximation for the specified parametrized function using either POD or the Greedy Algorithm.

Return the final tolerance.

Definition at line 416 of file rb_eim_construction.C.

417{
420
422 {
424 return 0.;
425 }
426 else
427 {
429 }
430}
virtual Real train_eim_approximation_with_greedy()
Generate the EIM approximation for the specified parametrized function using the Greedy Algorithm.
void apply_normalization_to_solution_snapshots()
Rescale solution snapshots so that they all have unity norm.
virtual Real train_eim_approximation_with_POD()
Generate the EIM approximation for the specified parametrized function using Proper Orthogonal Decomp...

References libMesh::RBConstructionBase< System >::_normalize_solution_snapshots, libMesh::RBEIMConstruction::apply_normalization_to_solution_snapshots(), libMesh::RBEIMConstruction::best_fit_type_flag, libMesh::RBEIMConstruction::POD_BEST_FIT, libMesh::RBEIMConstruction::train_eim_approximation_with_greedy(), and libMesh::RBEIMConstruction::train_eim_approximation_with_POD().

Referenced by main().

◆ train_eim_approximation_with_greedy()

Real libMesh::RBEIMConstruction::train_eim_approximation_with_greedy ( )
virtualinherited

Generate the EIM approximation for the specified parametrized function using the Greedy Algorithm.

Return the final tolerance. Method is virtual so that behavior can be specialized further in subclasses, if needed.

Definition at line 432 of file rb_eim_construction.C.

433{
434 LOG_SCOPE("train_eim_approximation_with_greedy()", "RBEIMConstruction");
435
436 RBEIMEvaluation & rbe = get_rb_eim_evaluation();
437
438 // We need space for one extra interpolation point if we're using the
439 // EIM error indicator.
440 unsigned int max_matrix_size = rbe.use_eim_error_indicator() ? get_Nmax()+1 : get_Nmax();
441 _eim_projection_matrix.resize(max_matrix_size,max_matrix_size);
442
443 rbe.initialize_parameters(*this);
444 rbe.resize_data_structures(max_matrix_size);
445
446 // If we are continuing from a previous training run,
447 // we might already be at the max number of basis functions.
448 // If so, we can just return.
449 libmesh_error_msg_if(rbe.get_n_basis_functions() > 0,
450 "Error: We currently only support EIM training starting from an empty basis");
451
452 libMesh::out << std::endl << "---- Performing Greedy EIM basis enrichment ----" << std::endl;
453
455 {
456 std::cout << "Maximum absolute value in the training set is "
457 << _max_abs_value_in_training_set << ", which is less than or equal to the abs. training tolerance of "
458 << get_abs_training_tolerance() << ", hence exiting Greedy basis enrichment with empty basis" << std::endl;
459 return 0.0;
460 }
461
462 // Initialize greedy_error so that we do not incorrectly set is_zero_bf=true on
463 // the first iteration.
464 Real greedy_error = -1.;
465 std::vector<RBParameters> greedy_param_list;
466
467 // Initialize the current training index to the index that corresponds
468 // to the largest (in terms of infinity norm) function in the training set.
469 // We do this to ensure that the first EIM basis function is not zero.
470 unsigned int current_training_index = _max_abs_value_in_training_set_index;
471 set_params_from_training_set(current_training_index);
472
473 // We use this boolean to indicate if we will run one more iteration
474 // before exiting the loop below. We use this when computing the EIM
475 // error indicator, which requires one extra EIM iteration.
476 bool exit_on_next_iteration = false;
477
478 // We also initialize a boolean to keep track of whether we have
479 // reached "n_samples" EIM basis functions, since we need to
480 // handle the EIM error indicator in a special way in this case.
481 bool bfs_equals_n_samples = false;
482
483 while (true)
484 {
485 if (rbe.get_n_basis_functions() >= get_n_training_samples())
486 {
487 libMesh::out << "Number of basis functions (" << rbe.get_n_basis_functions()
488 << ") equals number of training samples." << std::endl;
489
490 bfs_equals_n_samples = true;
491
492 // If exit_on_next_iteration==true then we don't exit yet, since
493 // we still need to add data for the error indicator before exiting.
494 if (!exit_on_next_iteration)
495 break;
496 }
497
498 libMesh::out << "Greedily selected parameter vector:" << std::endl;
500 greedy_param_list.emplace_back(get_parameters());
501
502 libMesh::out << "Enriching the EIM approximation" << std::endl;
503 libmesh_try
504 {
505 bool is_zero_bf = bfs_equals_n_samples || (greedy_error == 0.);
506
507 // If is_zero_bf==true then we add an "extra point" because we
508 // cannot add a usual EIM interpolation point in that case since
509 // the full EIM space is already covered. This is necessary when we
510 // want to add an extra point for error indicator purposes in the
511 // is_zero_bf==true case, for example.
512 std::unique_ptr<EimPointData> eim_point_data;
513 if (is_zero_bf)
514 eim_point_data = std::make_unique<EimPointData>(get_random_point_from_training_sample());
515
516 // If exit_on_next_iteration==true then we do not add a basis function in
517 // that case since in that case we only need to add data for the EIM error
518 // indicator.
519 enrich_eim_approximation(current_training_index,
520 /*add_basis_function*/ !exit_on_next_iteration,
521 eim_point_data.get());
522 update_eim_matrices(/*set_error_indicator*/ exit_on_next_iteration);
523
524 libMesh::out << std::endl << "---- Basis dimension: "
525 << rbe.get_n_basis_functions() << " ----" << std::endl;
526
527 if (get_rb_eim_evaluation().get_parametrized_function().is_lookup_table &&
529 {
530 // If this is a lookup table and we're using "EIM best fit" then we
531 // need to update the eim_solutions after each EIM enrichment so that
532 // we can call rb_eim_eval.rb_eim_solve() from within compute_max_eim_error().
534 }
535
536 libMesh::out << "Computing EIM error on training set" << std::endl;
537 std::tie(greedy_error, current_training_index) = compute_max_eim_error();
538 set_params_from_training_set(current_training_index);
539
540 libMesh::out << "Maximum EIM error is " << greedy_error << std::endl << std::endl;
541 }
542#ifdef LIBMESH_ENABLE_EXCEPTIONS
543 catch (const std::exception & e)
544 {
545 // If we hit an exception when performing the enrichment for the error indicator, then
546 // we just continue and skip the error indicator. Otherwise we rethrow the exception.
547 if (exit_on_next_iteration)
548 {
549 std::cout << "Exception occurred when enriching basis for error indicator hence we skip the error indicator in this case" << std::endl;
550 break;
551 }
552 else
553 throw;
554 }
555#endif
556
557 if (exit_on_next_iteration)
558 {
559 libMesh::out << "Extra EIM iteration for error indicator is complete, hence exiting EIM training now" << std::endl;
560 break;
561 }
562
563 // Convergence and/or termination tests
564 {
565 bool exit_condition_satisfied = false;
566
567 if (rbe.get_n_basis_functions() >= this->get_Nmax())
568 {
569 libMesh::out << "Maximum number of basis functions reached: Nmax = "
570 << get_Nmax() << std::endl;
571 exit_condition_satisfied = true;
572 }
573
574 // We consider the relative tolerance as relative to the maximum value in the training
575 // set, since we assume that this maximum value provides a relevant scaling.
576 if (!exit_condition_satisfied)
578 {
579 libMesh::out << "Relative error tolerance reached." << std::endl;
580 exit_condition_satisfied = true;
581 }
582
583 if (!exit_condition_satisfied)
584 if (greedy_error < get_abs_training_tolerance())
585 {
586 libMesh::out << "Absolute error tolerance reached." << std::endl;
587 exit_condition_satisfied = true;
588 }
589
590 bool has_parameters = (get_parameters().n_parameters() > 0);
591 if (!exit_condition_satisfied)
592 {
593 bool do_exit = false;
594 // In the check for repeated parameters we have to make sure this isn't a case
595 // with no parameters, since in that case we would always report repeated
596 // parameters.
597 for (auto & param : greedy_param_list)
598 if (param == get_parameters() && has_parameters)
599 {
600 libMesh::out << "Exiting greedy because the same parameters were selected twice"
601 << std::endl;
602 do_exit = true;
603 break;
604 }
605
606 if (do_exit)
607 exit_condition_satisfied = true;
608 }
609
610 if (exit_condition_satisfied)
611 {
612 // If we're using the EIM error indicator then we need to run
613 // one extra EIM iteration since we use the extra EIM point
614 // to obtain our error indicator. If we're not using the EIM
615 // error indicator, then we just exit now.
616 if (get_rb_eim_evaluation().use_eim_error_indicator() && has_parameters)
617 {
618 exit_on_next_iteration = true;
619 libMesh::out << "EIM error indicator is active, hence we will run one extra EIM iteration before exiting"
620 << std::endl;
621 }
622 else
623 break;
624 }
625 }
626 } // end while(true)
627
628 if (rbe.get_parametrized_function().is_lookup_table &&
630 {
631 // We only enter here if best_fit_type_flag != EIM_BEST_FIT because we
632 // already called this above in the EIM_BEST_FIT case.
634 }
635
636 return greedy_error;
637}
void store_eim_solutions_for_training_set()
Get the EIM solution vector at all parametrized functions in the training set.
void update_eim_matrices(bool set_eim_error_indicator)
Update the matrices used in training the EIM approximation.
EimPointData get_random_point_from_training_sample()
Get a random point using the 0^th training sample as input to get_random_point().
std::pair< Real, unsigned int > compute_max_eim_error()
Find the training sample that has the largest EIM approximation error based on the current EIM approx...
Real get_max_abs_value_in_training_set() const
Get the maximum value (across all processors) from the parametrized functions in the training set.
void enrich_eim_approximation(unsigned int training_index, bool add_basis_function, EimPointData *eim_point_data)
Add a new basis function to the EIM approximation.
void print_parameters() const
Print the current parameters.

References libMesh::RBEIMConstruction::_eim_projection_matrix, libMesh::RBEIMConstruction::_max_abs_value_in_training_set, libMesh::RBEIMConstruction::_max_abs_value_in_training_set_index, libMesh::RBEIMConstruction::best_fit_type_flag, libMesh::RBEIMConstruction::compute_max_eim_error(), libMesh::RBEIMConstruction::EIM_BEST_FIT, libMesh::RBEIMConstruction::enrich_eim_approximation(), libMesh::RBEIMConstruction::get_abs_training_tolerance(), libMesh::RBEIMConstruction::get_max_abs_value_in_training_set(), libMesh::RBEIMEvaluation::get_n_basis_functions(), libMesh::RBConstructionBase< System >::get_n_training_samples(), libMesh::RBEIMConstruction::get_Nmax(), libMesh::RBParametrized::get_parameters(), libMesh::RBEIMEvaluation::get_parametrized_function(), libMesh::RBEIMConstruction::get_random_point_from_training_sample(), libMesh::RBEIMConstruction::get_rb_eim_evaluation(), libMesh::RBEIMConstruction::get_rel_training_tolerance(), libMesh::RBParametrized::initialize_parameters(), libMesh::RBParametrizedFunction::is_lookup_table, libMesh::RBParameters::n_parameters(), libMesh::out, libMesh::RBParametrized::print_parameters(), libMesh::Real, libMesh::DenseMatrix< T >::resize(), libMesh::RBEIMEvaluation::resize_data_structures(), libMesh::RBConstructionBase< System >::set_params_from_training_set(), libMesh::RBEIMConstruction::store_eim_solutions_for_training_set(), libMesh::RBEIMConstruction::update_eim_matrices(), and libMesh::RBEIMEvaluation::use_eim_error_indicator().

Referenced by libMesh::RBEIMConstruction::train_eim_approximation().

◆ train_eim_approximation_with_POD()

Real libMesh::RBEIMConstruction::train_eim_approximation_with_POD ( )
virtualinherited

Generate the EIM approximation for the specified parametrized function using Proper Orthogonal Decomposition (POD).

Return the final tolerance. Method is virtual so that behavior can be specialized further in subclasses, if needed.

Definition at line 703 of file rb_eim_construction.C.

704{
705 LOG_SCOPE("train_eim_approximation_with_POD()", "RBEIMConstruction");
706
707 RBEIMEvaluation & rbe = get_rb_eim_evaluation();
708
709 unsigned int n_snapshots = get_n_training_samples();
710
711 // If _set_Nmax_from_n_snapshots=true, then we overrule Nmax.
713 {
714 int updated_Nmax = (static_cast<int>(n_snapshots) + _Nmax_from_n_snapshots_increment);
715
716 // We only overrule _Nmax if updated_Nmax is positive, since if Nmax=0 then we'll skip
717 // training here entirely, which is typically not what we want.
718 if (updated_Nmax > 0)
719 _Nmax = static_cast<unsigned int>(updated_Nmax);
720 }
721
722 // _eim_projection_matrix is not used in the POD case, but we resize it here in any case
723 // to be consistent with what we do in train_eim_approximation_with_greedy().
724 // We need space for one extra interpolation point if we're using the
725 // EIM error indicator.
726 unsigned int max_matrix_size = rbe.use_eim_error_indicator() ? get_Nmax()+1 : get_Nmax();
727 _eim_projection_matrix.resize(max_matrix_size,max_matrix_size);
728
729 rbe.initialize_parameters(*this);
730 rbe.resize_data_structures(get_Nmax());
731
732 libmesh_error_msg_if(rbe.get_n_basis_functions() > 0,
733 "Error: We currently only support EIM training starting from an empty basis");
734
735 libMesh::out << std::endl << "---- Performing POD EIM basis enrichment ----" << std::endl;
736
737 // Set up the POD "correlation matrix". This enables us to compute the POD via the
738 // "method of snapshots", in which we compute a low rank representation of the
739 // n_snapshots x n_snapshots matrix.
740 DenseMatrix<Number> correlation_matrix(n_snapshots,n_snapshots);
741
742 std::cout << "Start computing correlation matrix" << std::endl;
743
744 bool apply_comp_scaling = !get_rb_eim_evaluation().scale_components_in_enrichment().empty();
745 for (unsigned int i=0; i<n_snapshots; i++)
746 {
747 for (unsigned int j=0; j<=i; j++)
748 {
749 Number inner_prod = 0.;
750 if (rbe.get_parametrized_function().on_mesh_sides())
751 {
752 inner_prod = side_inner_product(
755 apply_comp_scaling);
756 }
757 else if (rbe.get_parametrized_function().on_mesh_nodes())
758 {
759 inner_prod = node_inner_product(
762 apply_comp_scaling);
763 }
764 else
765 {
766 inner_prod = inner_product(
769 apply_comp_scaling);
770 }
771
772
773 correlation_matrix(i,j) = inner_prod;
774 if(i != j)
775 {
776 correlation_matrix(j,i) = libmesh_conj(inner_prod);
777 }
778 }
779
780 // Print out every 10th row so that we can see the progress
781 if ( (i+1) % 10 == 0)
782 std::cout << "Finished row " << (i+1) << " of " << n_snapshots << std::endl;
783 }
784 std::cout << "Finished computing correlation matrix" << std::endl;
785
786 // Compute SVD of correlation matrix.
787 // Let Y = U S V^T, then the SVD below corresponds
788 // to Y^T Y = V S U^T U S V^T = V S^2 V^T.
789 // The POD basis we use is then given by U, which
790 // we can compute via U = Y V S^{-1}, which is what
791 // we compute below.
792 //
793 // Note that the formulation remains the same in the
794 // case that we use a weighted inner product (as
795 // in the case that we used apply_comp_scaling=true
796 // when computing the correlation matrix), see (1.28)
797 // from the lecture notes from Volkwein on POD for more
798 // details.
799 DenseVector<Real> sigma( n_snapshots );
800 DenseMatrix<Number> U( n_snapshots, n_snapshots );
801 DenseMatrix<Number> VT( n_snapshots, n_snapshots );
802 correlation_matrix.svd(sigma, U, VT );
803
804 // We use this boolean to indicate if we will run one more iteration
805 // before exiting the loop below. We use this when computing the EIM
806 // error indicator, which requires one extra EIM iteration.
807 bool exit_on_next_iteration = false;
808
809 // Add dominant vectors from the POD as basis functions.
810 unsigned int j = 0;
811 Real rel_err = 0.;
812
813 // We also initialize a boolean to keep track of whether we have
814 // reached "n_snapshots" EIM basis functions, since we need to
815 // handle the EIM error indicator in a special way in this case.
816 bool j_equals_n_snapshots = false;
817 while (true)
818 {
819 bool exit_condition_satisfied = false;
820
821 if ((j == 0) && (sigma(0) == 0.))
822 {
823 libMesh::out << "Terminating EIM POD with empty basis because first singular value is zero" << std::endl;
824 exit_condition_satisfied = true;
825 rel_err = 0.;
826 }
827 else if (j >= n_snapshots)
828 {
829 libMesh::out << "Number of basis functions equals number of training samples." << std::endl;
830 exit_condition_satisfied = true;
831 j_equals_n_snapshots = true;
832
833 // In this case we set the rel. error to be zero since we've filled up the
834 // entire space. We cannot use the formula below for rel_err since
835 // sigma(n_snapshots) is not defined.
836 rel_err = 0.;
837 }
838 else
839 {
840 // The "energy" error in the POD approximation is determined by the first omitted
841 // singular value, i.e. sigma(j). We normalize by sigma(0), which gives the total
842 // "energy", in order to obtain a relative error.
843 rel_err = std::sqrt(sigma(j)) / std::sqrt(sigma(0));
844 }
845
846 if (exit_on_next_iteration)
847 {
848 libMesh::out << "Extra EIM iteration for error indicator is complete, POD error norm for extra iteration: " << rel_err << std::endl;
849 break;
850 }
851
852 libMesh::out << "Number of basis functions: " << j
853 << ", POD error norm: " << rel_err << std::endl;
854
855 if (!exit_condition_satisfied)
856 if (j >= get_Nmax())
857 {
858 libMesh::out << "Maximum number of basis functions (" << j << ") reached." << std::endl;
859 exit_condition_satisfied = true;
860 }
861
862 if (!exit_condition_satisfied)
863 if (rel_err < get_rel_training_tolerance())
864 {
865 libMesh::out << "Training tolerance reached." << std::endl;
866 exit_condition_satisfied = true;
867 }
868
869 if (exit_condition_satisfied)
870 {
871 // If we're using the EIM error indicator then we need to run
872 // one extra EIM iteration since we use the extra EIM point
873 // to obtain our error indicator. If we're not using the EIM
874 // error indicator, then we just exit now.
875 bool has_parameters = (get_parameters().n_parameters() > 0);
876 if (get_rb_eim_evaluation().use_eim_error_indicator() && has_parameters)
877 {
878 exit_on_next_iteration = true;
879 libMesh::out << "EIM error indicator is active, hence we will run one extra EIM iteration before exiting"
880 << std::endl;
881 }
882 else
883 break;
884 }
885
886 bool is_zero_bf = j_equals_n_snapshots || (rel_err == 0.);
887 if (rbe.get_parametrized_function().on_mesh_sides())
888 {
889 // Make a "zero clone" by copying to get the same data layout, and then scaling by zero
891
892 if (!is_zero_bf)
893 {
895
896 for ( unsigned int i=0; i<n_snapshots; ++i )
898
899 Real norm_v = std::sqrt(sigma(j));
900 scale_parametrized_function(v, 1./norm_v);
901 }
902
903 libmesh_try
904 {
905 // If is_zero_bf==true then we add an "extra point" because we cannot
906 // add a usual EIM interpolation point in that case since the full EIM
907 // space is already covered. This is necessary when we want to add an
908 // extra point for error indicator purposes in the is_zero_bf==true
909 // case, for example.
910 std::unique_ptr<EimPointData> eim_point_data;
911 if (is_zero_bf)
912 eim_point_data = std::make_unique<EimPointData>(get_random_point(v));
913
914 // If exit_on_next_iteration==true then we do not add a basis function in
915 // that case since in that case we only need to add data for the EIM error
916 // indicator.
917 bool is_linearly_dependent = enrich_eim_approximation_on_sides(v,
918 /*add_basis_function*/ !exit_on_next_iteration,
919 eim_point_data.get());
920
921 // If we encountered linearly dependent data, then we treat this the same as
922 // when we have exit_condition_satisfied==true because the EIM training cannot
923 // proceed any further. As a result, we set exit_on_next_iteration=true here,
924 // as we do above in the case that exit_condition_satisfied==true.
925 if (is_linearly_dependent)
926 {
927 bool has_parameters = (get_parameters().n_parameters() > 0);
928 if (get_rb_eim_evaluation().use_eim_error_indicator() && has_parameters)
929 {
930 exit_on_next_iteration = true;
931 libMesh::out << "Linearly dependent data detected, finalizing iteration for the EIM error indicator before exiting"
932 << std::endl;
933 }
934 else
935 break;
936 }
937
938 if (is_linearly_dependent && !is_zero_bf)
939 {
940 // In this case we detected that v is actually linearly dependent and that is_zero_bf
941 // was previously not correct --- it should have been true. We typically
942 // catch this earlier (e.g. by checking rel_err) but in some cases we do not catch
943 // this until we call the enrichment method. In this situation we update is_zero_bf
944 // to true and call the enrichment again.
945 is_zero_bf = true;
946 eim_point_data = std::make_unique<EimPointData>(get_random_point(v));
947
949 /*add_basis_function*/ !exit_on_next_iteration,
950 eim_point_data.get());
951 }
952
953 update_eim_matrices(/*set_error_indicator*/ exit_on_next_iteration);
954 }
955#ifdef LIBMESH_ENABLE_EXCEPTIONS
956 catch (const std::exception & e)
957 {
958 // If we hit an exception when performing the enrichment for the error indicator, then
959 // we just continue and skip the error indicator. Otherwise we rethrow the exception.
960 if (exit_on_next_iteration)
961 {
962 std::cout << "Exception occurred when enriching basis for error indicator hence we skip the error indicator in this case" << std::endl;
963 break;
964 }
965 else
966 throw;
967 }
968#endif
969 }
970 else if (rbe.get_parametrized_function().on_mesh_nodes())
971 {
972 // Make a "zero clone" by copying to get the same data layout, and then scaling by zero
974
975 if (!is_zero_bf)
976 {
978
979 for ( unsigned int i=0; i<n_snapshots; ++i )
980 add_node_data_map(v, U.el(i, j), _local_node_parametrized_functions_for_training[i] );
981
982 Real norm_v = std::sqrt(sigma(j));
984 }
985
986 libmesh_try
987 {
988 // If is_zero_bf==true then we add an "extra point" because we cannot
989 // add a usual EIM interpolation point in that case since the full EIM
990 // space is already covered. This is necessary when we want to add an
991 // extra point for error indicator purposes in the is_zero_bf==true
992 // case, for example.
993 std::unique_ptr<EimPointData> eim_point_data;
994 if (is_zero_bf)
995 eim_point_data = std::make_unique<EimPointData>(get_random_point(v));
996
997 // If exit_on_next_iteration==true then we do not add a basis function in
998 // that case since in that case we only need to add data for the EIM error
999 // indicator.
1000 bool is_linearly_dependent = enrich_eim_approximation_on_nodes(v,
1001 /*add_basis_function*/ !exit_on_next_iteration,
1002 eim_point_data.get());
1003
1004 // If we encountered linearly dependent data, then we treat this the same as
1005 // when we have exit_condition_satisfied==true because the EIM training cannot
1006 // proceed any further. As a result, we set exit_on_next_iteration=true here,
1007 // as we do above in the case that exit_condition_satisfied==true.
1008 if (is_linearly_dependent)
1009 {
1010 bool has_parameters = (get_parameters().n_parameters() > 0);
1011 if (get_rb_eim_evaluation().use_eim_error_indicator() && has_parameters)
1012 {
1013 exit_on_next_iteration = true;
1014 libMesh::out << "Linearly dependent data detected, finalizing iteration for the EIM error indicator before exiting"
1015 << std::endl;
1016 }
1017 else
1018 break;
1019 }
1020
1021 if (is_linearly_dependent && !is_zero_bf)
1022 {
1023 // In this case we detected that v is actually linearly dependent and that is_zero_bf
1024 // was previously not correct --- it should have been true. We typically
1025 // catch this earlier (e.g. by checking rel_err) but in some cases we do not catch
1026 // this until we call the enrichment method. In this situation we update is_zero_bf
1027 // to true and call the enrichment again.
1028 is_zero_bf = true;
1029 eim_point_data = std::make_unique<EimPointData>(get_random_point(v));
1030
1032 /*add_basis_function*/ !exit_on_next_iteration,
1033 eim_point_data.get());
1034 }
1035
1036 update_eim_matrices(/*set_error_indicator*/ exit_on_next_iteration);
1037 }
1038#ifdef LIBMESH_ENABLE_EXCEPTIONS
1039 catch (const std::exception & e)
1040 {
1041 // If we hit an exception when performing the enrichment for the error indicator, then
1042 // we just continue and skip the error indicator. Otherwise we rethrow the exception.
1043 if (exit_on_next_iteration)
1044 {
1045 std::cout << "Exception occurred when enriching basis for error indicator hence we skip the error indicator in this case" << std::endl;
1046 break;
1047 }
1048 else
1049 throw;
1050 }
1051#endif
1052 }
1053 else
1054 {
1055 // Make a "zero clone" by copying to get the same data layout, and then scaling by zero
1057
1058 if (!is_zero_bf)
1059 {
1061
1062 for ( unsigned int i=0; i<n_snapshots; ++i )
1063 add(v, U.el(i, j), _local_parametrized_functions_for_training[i] );
1064
1065 Real norm_v = std::sqrt(sigma(j));
1066 scale_parametrized_function(v, 1./norm_v);
1067 }
1068
1069 libmesh_try
1070 {
1071 // If is_zero_bf==true then we add an "extra point" because we cannot
1072 // add a usual EIM interpolation point in that case since the full EIM
1073 // space is already covered. This is necessary when we want to add an
1074 // extra point for error indicator purposes in the is_zero_bf==true
1075 // case, for example.
1076 std::unique_ptr<EimPointData> eim_point_data;
1077 if (is_zero_bf)
1078 eim_point_data = std::make_unique<EimPointData>(get_random_point(v));
1079
1080 // If exit_on_next_iteration==true then we do not add a basis function in
1081 // that case since in that case we only need to add data for the EIM error
1082 // indicator.
1083 bool is_linearly_dependent = enrich_eim_approximation_on_interiors(v,
1084 /*add_basis_function*/ !exit_on_next_iteration,
1085 eim_point_data.get());
1086
1087 // If we encountered linearly dependent data, then we treat this the same as
1088 // when we have exit_condition_satisfied==true because the EIM training cannot
1089 // proceed any further. As a result, we set exit_on_next_iteration=true here,
1090 // as we do above in the case that exit_condition_satisfied==true.
1091 if (is_linearly_dependent)
1092 {
1093 bool has_parameters = (get_parameters().n_parameters() > 0);
1094 if (get_rb_eim_evaluation().use_eim_error_indicator() && has_parameters)
1095 {
1096 exit_on_next_iteration = true;
1097 libMesh::out << "Linearly dependent data detected, finalizing iteration for the EIM error indicator before exiting"
1098 << std::endl;
1099 }
1100 else
1101 break;
1102 }
1103
1104 if (is_linearly_dependent && !is_zero_bf)
1105 {
1106 // In this case we detected that v is actually linearly dependent and that is_zero_bf
1107 // was previously not correct --- it should have been true. We typically
1108 // catch this earlier (e.g. by checking rel_err) but in some cases we do not catch
1109 // this until we call the enrichment method. In this situation we update is_zero_bf
1110 // to true and call the enrichment again.
1111 is_zero_bf = true;
1112 eim_point_data = std::make_unique<EimPointData>(get_random_point(v));
1113
1115 /*add_basis_function*/ !exit_on_next_iteration,
1116 eim_point_data.get());
1117 }
1118
1119 update_eim_matrices(/*set_error_indicator*/ exit_on_next_iteration);
1120 }
1121#ifdef LIBMESH_ENABLE_EXCEPTIONS
1122 catch (const std::exception & e)
1123 {
1124 // If we hit an exception when performing the enrichment for the error indicator, then
1125 // we just continue and skip the error indicator. Otherwise we rethrow the exception.
1126 if (exit_on_next_iteration)
1127 {
1128 std::cout << "Exception occurred when enriching basis for error indicator hence we skip the error indicator in this case" << std::endl;
1129 break;
1130 }
1131 else
1132 throw;
1133 }
1134#endif
1135 }
1136
1137 if (is_zero_bf)
1138 {
1139 // In this case we exit here instead of increment j and continuing because
1140 // if we've encountered a zero EIM basis function then we must not have
1141 // any more valid data to add.
1142 std::cout << "Zero basis function encountered, hence exiting." << std::endl;
1143 break;
1144 }
1145
1146 j++;
1147 }
1148 libMesh::out << std::endl;
1149
1150 return rel_err;
1151}
virtual bool use_eim_error_indicator() const
Virtual function to indicate if we use the EIM error indicator in this case.
template class LIBMESH_EXPORT DenseVector< Real >

References libMesh::RBEIMConstruction::_eim_projection_matrix, libMesh::RBEIMConstruction::_local_node_parametrized_functions_for_training, libMesh::RBEIMConstruction::_local_parametrized_functions_for_training, libMesh::RBEIMConstruction::_local_side_parametrized_functions_for_training, libMesh::RBEIMConstruction::_Nmax, libMesh::RBEIMConstruction::_Nmax_from_n_snapshots_increment, libMesh::RBEIMConstruction::_set_Nmax_from_n_snapshots, libMesh::DenseMatrix< T >::el(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_nodes(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), libMesh::RBEIMEvaluation::get_n_basis_functions(), libMesh::RBConstructionBase< System >::get_n_training_samples(), libMesh::RBEIMConstruction::get_Nmax(), libMesh::RBParametrized::get_parameters(), libMesh::RBEIMEvaluation::get_parametrized_function(), libMesh::RBEIMConstruction::get_random_point(), libMesh::RBEIMConstruction::get_rb_eim_evaluation(), libMesh::RBEIMConstruction::get_rel_training_tolerance(), libMesh::RBParametrized::initialize_parameters(), libMesh::RBEIMConstruction::inner_product(), libMesh::libmesh_conj(), libMesh::RBParameters::n_parameters(), libMesh::RBEIMConstruction::node_inner_product(), libMesh::RBParametrizedFunction::on_mesh_nodes(), libMesh::RBParametrizedFunction::on_mesh_sides(), libMesh::out, libMesh::Real, libMesh::DenseMatrix< T >::resize(), libMesh::RBEIMEvaluation::resize_data_structures(), libMesh::RBEIMEvaluation::scale_components_in_enrichment(), libMesh::RBEIMConstruction::scale_node_parametrized_function(), libMesh::RBEIMConstruction::scale_parametrized_function(), libMesh::RBEIMConstruction::side_inner_product(), libMesh::DenseMatrix< T >::svd(), libMesh::RBEIMConstruction::update_eim_matrices(), and libMesh::RBEIMEvaluation::use_eim_error_indicator().

Referenced by libMesh::RBEIMConstruction::train_eim_approximation().

◆ update()

void libMesh::System::update ( )
virtualinherited

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

Reimplemented in SolidSystem.

Definition at line 498 of file system.C.

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

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

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

◆ update_eim_matrices()

void libMesh::RBEIMConstruction::update_eim_matrices ( bool  set_eim_error_indicator)
protectedinherited

Update the matrices used in training the EIM approximation.

If set_eim_error_indicator is true then we add data corresponding to the EIM error indicator.

Definition at line 2909 of file rb_eim_construction.C.

2910{
2911 LOG_SCOPE("update_eim_matrices()", "RBEIMConstruction");
2912
2913 RBEIMEvaluation & eim_eval = get_rb_eim_evaluation();
2914 unsigned int RB_size = eim_eval.get_n_basis_functions();
2915
2916 libmesh_assert_msg(RB_size >= 1, "Must have at least 1 basis function.");
2917
2918 if (set_eim_error_indicator)
2919 {
2920 // Here we have RB_size EIM basis functions, and RB_size+1 interpolation points,
2921 // since we should have added one extra interpolation point for the EIM error
2922 // indicator. As a result, we use RB_size as the index to access the (RB_size+1)^th
2923 // interpolation point in the calls to eim_eval.get_interpolation_points_*.
2924 DenseVector<Number> extra_point_row(RB_size);
2925
2926 if (eim_eval.get_parametrized_function().on_mesh_sides())
2927 {
2928 // update the EIM interpolation matrix
2929 for (unsigned int j=0; j<RB_size; j++)
2930 {
2931 // Evaluate the basis functions at the new interpolation point in order
2932 // to update the interpolation matrix
2933 Number value =
2934 eim_eval.get_eim_basis_function_side_value(j,
2935 eim_eval.get_interpolation_points_elem_id(RB_size),
2936 eim_eval.get_interpolation_points_side_index(RB_size),
2937 eim_eval.get_interpolation_points_comp(RB_size),
2938 eim_eval.get_interpolation_points_qp(RB_size));
2939 extra_point_row(j) = value;
2940 }
2941 }
2942 else if (eim_eval.get_parametrized_function().on_mesh_nodes())
2943 {
2944 // update the EIM interpolation matrix
2945 for (unsigned int j=0; j<RB_size; j++)
2946 {
2947 // Evaluate the basis functions at the new interpolation point in order
2948 // to update the interpolation matrix
2949 Number value =
2950 eim_eval.get_eim_basis_function_node_value(j,
2951 eim_eval.get_interpolation_points_node_id(RB_size),
2952 eim_eval.get_interpolation_points_comp(RB_size));
2953 extra_point_row(j) = value;
2954 }
2955 }
2956 else
2957 {
2958 // update the EIM interpolation matrix
2959 for (unsigned int j=0; j<RB_size; j++)
2960 {
2961 // Evaluate the basis functions at the new interpolation point in order
2962 // to update the interpolation matrix
2963 Number value =
2964 eim_eval.get_eim_basis_function_value(j,
2965 eim_eval.get_interpolation_points_elem_id(RB_size),
2966 eim_eval.get_interpolation_points_comp(RB_size),
2967 eim_eval.get_interpolation_points_qp(RB_size));
2968 extra_point_row(j) = value;
2969 }
2970 }
2971
2972 eim_eval.set_error_indicator_interpolation_row(extra_point_row);
2973 return;
2974 }
2975
2976 if (eim_eval.get_parametrized_function().on_mesh_sides())
2977 {
2978 // update the matrix that is used to evaluate L2 projections
2979 // into the EIM approximation space
2980 for (unsigned int i=(RB_size-1); i<RB_size; i++)
2981 {
2982 for (unsigned int j=0; j<RB_size; j++)
2983 {
2984 Number value = side_inner_product(eim_eval.get_side_basis_function(j),
2985 eim_eval.get_side_basis_function(i),
2986 /*apply_comp_scaling*/ false);
2987
2989 if (i!=j)
2990 {
2991 // The inner product matrix is assumed to be hermitian
2993 }
2994 }
2995 }
2996
2997 // update the EIM interpolation matrix
2998 for (unsigned int j=0; j<RB_size; j++)
2999 {
3000 // Evaluate the basis functions at the new interpolation point in order
3001 // to update the interpolation matrix
3002 Number value =
3003 eim_eval.get_eim_basis_function_side_value(j,
3004 eim_eval.get_interpolation_points_elem_id(RB_size-1),
3005 eim_eval.get_interpolation_points_side_index(RB_size-1),
3006 eim_eval.get_interpolation_points_comp(RB_size-1),
3007 eim_eval.get_interpolation_points_qp(RB_size-1));
3008 eim_eval.set_interpolation_matrix_entry(RB_size-1, j, value);
3009 }
3010 }
3011 else if (eim_eval.get_parametrized_function().on_mesh_nodes())
3012 {
3013 // update the matrix that is used to evaluate L2 projections
3014 // into the EIM approximation space
3015 for (unsigned int i=(RB_size-1); i<RB_size; i++)
3016 {
3017 for (unsigned int j=0; j<RB_size; j++)
3018 {
3019 Number value = node_inner_product(eim_eval.get_node_basis_function(j),
3020 eim_eval.get_node_basis_function(i),
3021 /*apply_comp_scaling*/ false);
3022
3024 if (i!=j)
3025 {
3026 // The inner product matrix is assumed to be hermitian
3028 }
3029 }
3030 }
3031
3032 // update the EIM interpolation matrix
3033 for (unsigned int j=0; j<RB_size; j++)
3034 {
3035 // Evaluate the basis functions at the new interpolation point in order
3036 // to update the interpolation matrix
3037 Number value =
3038 eim_eval.get_eim_basis_function_node_value(j,
3039 eim_eval.get_interpolation_points_node_id(RB_size-1),
3040 eim_eval.get_interpolation_points_comp(RB_size-1));
3041 eim_eval.set_interpolation_matrix_entry(RB_size-1, j, value);
3042 }
3043 }
3044 else
3045 {
3046 // update the matrix that is used to evaluate L2 projections
3047 // into the EIM approximation space
3048 for (unsigned int i=(RB_size-1); i<RB_size; i++)
3049 {
3050 for (unsigned int j=0; j<RB_size; j++)
3051 {
3052 Number value = inner_product(eim_eval.get_basis_function(j),
3053 eim_eval.get_basis_function(i),
3054 /*apply_comp_scaling*/ false);
3055
3057 if (i!=j)
3058 {
3059 // The inner product matrix is assumed to be hermitian
3061 }
3062 }
3063 }
3064
3065 // update the EIM interpolation matrix
3066 for (unsigned int j=0; j<RB_size; j++)
3067 {
3068 // Evaluate the basis functions at the new interpolation point in order
3069 // to update the interpolation matrix
3070 Number value =
3071 eim_eval.get_eim_basis_function_value(j,
3072 eim_eval.get_interpolation_points_elem_id(RB_size-1),
3073 eim_eval.get_interpolation_points_comp(RB_size-1),
3074 eim_eval.get_interpolation_points_qp(RB_size-1));
3075 eim_eval.set_interpolation_matrix_entry(RB_size-1, j, value);
3076 }
3077 }
3078}

References libMesh::RBEIMConstruction::_eim_projection_matrix, libMesh::RBEIMEvaluation::get_basis_function(), libMesh::RBEIMEvaluation::get_eim_basis_function_node_value(), libMesh::RBEIMEvaluation::get_eim_basis_function_side_value(), libMesh::RBEIMEvaluation::get_eim_basis_function_value(), libMesh::RBEIMEvaluation::get_interpolation_points_comp(), libMesh::RBEIMEvaluation::get_interpolation_points_elem_id(), libMesh::RBEIMEvaluation::get_interpolation_points_node_id(), libMesh::RBEIMEvaluation::get_interpolation_points_qp(), libMesh::RBEIMEvaluation::get_interpolation_points_side_index(), libMesh::RBEIMEvaluation::get_n_basis_functions(), libMesh::RBEIMEvaluation::get_node_basis_function(), libMesh::RBEIMEvaluation::get_parametrized_function(), libMesh::RBEIMConstruction::get_rb_eim_evaluation(), libMesh::RBEIMEvaluation::get_side_basis_function(), libMesh::RBEIMConstruction::inner_product(), libMesh::libmesh_conj(), libMesh::RBEIMConstruction::node_inner_product(), libMesh::RBParametrizedFunction::on_mesh_nodes(), libMesh::RBParametrizedFunction::on_mesh_sides(), libMesh::RBEIMEvaluation::set_error_indicator_interpolation_row(), libMesh::RBEIMEvaluation::set_interpolation_matrix_entry(), libMesh::RBEIMConstruction::side_inner_product(), and value.

Referenced by libMesh::RBEIMConstruction::train_eim_approximation_with_greedy(), and libMesh::RBEIMConstruction::train_eim_approximation_with_POD().

◆ update_global_solution() [1/2]

void libMesh::System::update_global_solution ( std::vector< Number > &  global_soln) const
inherited

Fill the input vector global_soln so that it contains the global solution on all processors.

Requires communication with all other processors.

Definition at line 733 of file system.C.

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

References libMesh::System::solution.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::ExactErrorEstimator::estimate_error(), main(), and libMesh::InterMeshProjection::project_system_vectors().

◆ update_global_solution() [2/2]

void libMesh::System::update_global_solution ( std::vector< Number > &  global_soln,
const processor_id_type  dest_proc 
) const
inherited

Fill the input vector global_soln so that it contains the global solution on processor dest_proc.

Requires communication with all other processors.

Definition at line 744 of file system.C.

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

References libMesh::System::solution.

◆ user_assembly()

void libMesh::System::user_assembly ( )
virtualinherited

Calls user's attached assembly function, or is overridden by the user in derived classes.

Definition at line 2109 of file system.C.

2110{
2111 // Call the user-provided assembly function,
2112 // if it was provided
2113 if (_assemble_system_function != nullptr)
2115
2116 // ...or the user-provided assembly object.
2117 else if (_assemble_system_object != nullptr)
2119}
virtual void assemble()=0
Assembly function.

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

◆ user_constrain()

void libMesh::System::user_constrain ( )
virtualinherited

Calls user's attached constraint function, or is overridden by the user in derived classes.

Definition at line 2123 of file system.C.

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

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

◆ user_initialization()

void libMesh::System::user_initialization ( )
virtualinherited

Calls user's attached initialization function, or is overridden by the user in derived classes.

Definition at line 2095 of file system.C.

2096{
2097 // Call the user-provided initialization function,
2098 // if it was provided
2099 if (_init_system_function != nullptr)
2101
2102 // ...or the user-provided initialization object.
2103 else if (_init_system_object != nullptr)
2105}
virtual void initialize()=0
Initialization function.

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

◆ user_QOI()

void libMesh::System::user_QOI ( const QoISet qoi_indices)
virtualinherited

Calls user's attached quantity of interest function, or is overridden by the user in derived classes.

Definition at line 2137 of file system.C.

2138{
2139 // Call the user-provided quantity of interest function,
2140 // if it was provided
2141 if (_qoi_evaluate_function != nullptr)
2142 this->_qoi_evaluate_function(_equation_systems, this->name(), qoi_indices);
2143
2144 // ...or the user-provided QOI function object.
2145 else if (_qoi_evaluate_object != nullptr)
2146 this->_qoi_evaluate_object->qoi(qoi_indices);
2147}
virtual void qoi(const QoISet &qoi_indices)=0
Quantity of interest function.

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

◆ user_QOI_derivative()

void libMesh::System::user_QOI_derivative ( const QoISet qoi_indices = QoISet(),
bool  include_liftfunc = true,
bool  apply_constraints = true 
)
virtualinherited

Calls user's attached quantity of interest derivative function, or is overridden by the user in derived classes.

Definition at line 2151 of file system.C.

2154{
2155 // Call the user-provided quantity of interest derivative,
2156 // if it was provided
2157 if (_qoi_evaluate_derivative_function != nullptr)
2159 (_equation_systems, this->name(), qoi_indices, include_liftfunc,
2160 apply_constraints);
2161
2162 // ...or the user-provided QOI derivative function object.
2163 else if (_qoi_evaluate_derivative_object != nullptr)
2165 (qoi_indices, include_liftfunc, apply_constraints);
2166}
virtual void qoi_derivative(const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)=0
Quantity of interest derivative function.

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

◆ variable()

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

Return a constant reference to Variable var.

Definition at line 2704 of file system.C.

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

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DifferentiableSystem::add_second_order_dot_vars(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::FirstOrderUnsteadySolver::compute_second_order_eqns(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::DifferentiableSystem::have_first_order_scalar_vars(), libMesh::DifferentiableSystem::have_second_order_scalar_vars(), main(), main(), libMesh::DifferentiablePhysics::nonlocal_mass_residual(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SortAndCopy::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectInteriors::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectEdges::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectSides::operator()(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::PetscPreconditioner< T >::set_petsc_aux_data(), libMesh::PetscDMWrapper::set_point_range_in_section(), SystemsTest::testFirstScalarNumber(), libMesh::System::write_header(), libMesh::Nemesis_IO_Helper::write_nodal_solution(), libMesh::System::write_parallel_data(), libMesh::System::write_serialized_vector(), and libMesh::System::write_serialized_vectors().

◆ variable_group()

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

Return a constant reference to VariableGroup vg.

Definition at line 2709 of file system.C.

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

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

◆ variable_name()

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

◆ variable_number()

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

Definition at line 1398 of file system.C.

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

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

Referenced by libMesh::ExactSolution::_compute_error(), alternative_fe_assembly(), LinearElasticity::assemble(), AssembleOptimization::assemble_A_and_F(), assemble_divgrad(), assemble_elasticity(), assemble_graddiv(), assemble_matrix_and_rhs(), assemble_shell(), assemble_stokes(), compute_enriched_soln(), LinearElasticity::compute_stresses(), LargeDeformationElasticity::compute_stresses(), LinearElasticityWithContact::compute_stresses(), compute_stresses(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_elemental_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::Nemesis_IO::copy_nodal_solution(), libMesh::ExactErrorEstimator::estimate_error(), fe_assembly(), libMesh::ExactErrorEstimator::find_squared_element_error(), AssemblyPointLoadX::get_nodal_rhs_values(), AssemblyPointLoadY::get_nodal_rhs_values(), AssemblyPointLoadZ::get_nodal_rhs_values(), CoupledSystemQoI::init_context(), LargeDeformationElasticity::jacobian(), libMesh::HDGProblem::jacobian(), line_print(), main(), LinearElasticityWithContact::move_mesh(), OverlappingCouplingFunctor::operator()(), libMesh::System::read_header(), LargeDeformationElasticity::residual(), libMesh::HDGProblem::residual(), LinearElasticityWithContact::residual_and_jacobian(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), OverlappingTestBase::setup_coupling_matrix(), libMesh::DTKAdapter::update_variable_values(), libMesh::System::variable_scalar_number(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().

◆ variable_scalar_number() [1/2]

unsigned int libMesh::System::variable_scalar_number ( std::string_view  var,
unsigned int  component 
) const
inlineinherited
Returns
An index, starting from 0 for the first component of the first variable, and incrementing for each component of each (potentially vector-valued) variable in the system in order. For systems with only scalar-valued variables, this will be the same as variable_number(var)

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

Definition at line 2474 of file system.h.

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

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

Referenced by libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectInteriors::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectEdges::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectSides::operator()(), and libMesh::System::variable_scalar_number().

◆ variable_scalar_number() [2/2]

unsigned int libMesh::System::variable_scalar_number ( unsigned int  var_num,
unsigned int  component 
) const
inherited
Returns
An index, starting from 0 for the first component of the first variable, and incrementing for each component of each (potentially vector-valued) variable in the system in order. For systems with only scalar-valued variables, this will be the same as var_num

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

Definition at line 2715 of file system.C.

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

◆ variable_type() [1/2]

const FEType & libMesh::System::variable_type ( const unsigned int  i) const
inherited
Returns
The finite element type variable number i.

Definition at line 2721 of file system.C.

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

Referenced by libMesh::ExactSolution::_compute_error(), alternative_fe_assembly(), assemble(), libMesh::ClawSystem::assemble_advection_matrices(), libMesh::ClawSystem::assemble_avg_coupling_matrices(), libMesh::ClawSystem::assemble_boundary_condition_matrices(), assemble_ellipticdg(), libMesh::ClawSystem::assemble_jump_coupling_matrix(), libMesh::ClawSystem::assemble_mass_matrix(), assemble_shell(), assemble_shell(), assemble_stokes(), libMesh::FEMContext::attach_quadrature_rules(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::ExactSolution::compute_error(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_elemental_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::DGFEMContext::DGFEMContext(), libMesh::JumpErrorEstimator::estimate_error(), fe_assembly(), libMesh::FEMContext::find_hardest_fe_type(), libMesh::EquationSystems::find_variable_numbers_by_predicate(), form_functionA(), form_functionB(), form_matrixA(), libMesh::FEMSystem::init_context(), libMesh::FEMContext::init_internal_data(), OverlappingCouplingFunctor::operator()(), RationalMapTest< elem_type >::setUp(), FETestBase< order, family, elem_type, build_nx, CaseName >::setUp(), EquationSystemsTest::testBadVarNames(), FETest< order, family, elem_type, CaseName >::testCustomReinit(), FETest< order, family, elem_type, CaseName >::testFEInterface(), libMesh::Nemesis_IO_Helper::write_element_values(), libMesh::System::write_header(), libMesh::Nemesis_IO_Helper::write_nodal_solution(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().

◆ variable_type() [2/2]

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

Definition at line 2726 of file system.C.

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

◆ vector_is_adjoint()

int libMesh::System::vector_is_adjoint ( std::string_view  vec_name) const
inherited
Returns
The integer describing whether the vector identified by vec_name represents a solution from an adjoint (non-negative) or the primal (-1) space.

Definition at line 1160 of file system.C.

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

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

Referenced by libMesh::InterMeshProjection::project_system_vectors(), and libMesh::System::restrict_vectors().

◆ vector_name() [1/2]

const std::string & libMesh::System::vector_name ( const NumericVector< Number > &  vec_reference) const
inherited
Returns
The name of a system vector, given a reference to that vector

Definition at line 982 of file system.C.

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

References libMesh::System::_vectors, libMesh::NumericVector< T >::get(), libMesh::libmesh_assert(), libMesh::System::vectors_begin(), and libMesh::System::vectors_end().

◆ vector_name() [2/2]

const std::string & libMesh::System::vector_name ( const unsigned int  vec_num) const
inherited
Returns
The name of this system's additional vector number vec_num (where the vectors are counted starting with 0).

Definition at line 971 of file system.C.

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

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

Referenced by libMesh::AdjointRefinementEstimator::estimate_error(), and main().

◆ vector_preservation()

bool libMesh::System::vector_preservation ( std::string_view  vec_name) const
inherited
Returns
The boolean describing whether the vector identified by vec_name should be "preserved": projected to new meshes, saved, etc.

Definition at line 1135 of file system.C.

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

References libMesh::System::_vector_projections.

Referenced by libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::MemoryHistoryData::store_vectors(), SystemsTest::testAddVectorProjChange(), SystemsTest::testAddVectorTypeChange(), and SystemsTest::testPostInitAddVectorTypeChange().

◆ vectors_begin() [1/2]

System::vectors_iterator libMesh::System::vectors_begin ( )
inlineinherited

◆ vectors_begin() [2/2]

System::const_vectors_iterator libMesh::System::vectors_begin ( ) const
inlineinherited

Beginning of vectors container.

Definition at line 2511 of file system.h.

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

References libMesh::System::_vectors.

◆ vectors_end() [1/2]

System::vectors_iterator libMesh::System::vectors_end ( )
inlineinherited

◆ vectors_end() [2/2]

System::const_vectors_iterator libMesh::System::vectors_end ( ) const
inlineinherited

End of vectors container.

Definition at line 2523 of file system.h.

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

References libMesh::System::_vectors.

◆ weighted_sensitivity_adjoint_solve()

std::pair< unsigned int, Real > libMesh::System::weighted_sensitivity_adjoint_solve ( const ParameterVector parameters,
const ParameterVector weights,
const QoISet qoi_indices = QoISet() 
)
inlinevirtualinherited

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

This method is only implemented in some derived classes.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2593 of file system.h.

2596{
2597 libmesh_not_implemented();
2598}

◆ weighted_sensitivity_solve()

std::pair< unsigned int, Real > libMesh::System::weighted_sensitivity_solve ( const ParameterVector parameters,
const ParameterVector weights 
)
inlinevirtualinherited

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

This method is only implemented in some derived classes.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2578 of file system.h.

2580{
2581 libmesh_not_implemented();
2582}

◆ write_discrete_parameter_values_to_file()

void libMesh::RBParametrized::write_discrete_parameter_values_to_file ( const std::string &  file_name,
const bool  write_binary_data 
)
privateinherited

Write out the discrete parameter values to file.

Definition at line 230 of file rb_parametrized.C.

232{
233 // write out the discrete parameters, if we have any
234 if (get_n_discrete_params() > 0)
235 {
236 // The writing mode: ENCODE for binary, WRITE for ASCII
237 XdrMODE mode = write_binary_data ? ENCODE : WRITE;
238
239 Xdr discrete_parameters_out(file_name, mode);
240 unsigned int n_discrete_params = get_n_discrete_params();
241 discrete_parameters_out << n_discrete_params;
242
243 // Note: the following loops are not candidates for structured
244 // bindings syntax because the Xdr APIs which they call are not
245 // defined for const references. We must therefore make copies
246 // to call these functions.
247 for (const auto & pr : get_discrete_parameter_values())
248 {
249 std::string param_name = pr.first;
250 auto n_discrete_values = cast_int<unsigned int>(pr.second.size());
251 discrete_parameters_out << param_name << n_discrete_values;
252
253 for (unsigned int i=0; i<n_discrete_values; i++)
254 {
255 Real discrete_value = pr.second[i];
256 discrete_parameters_out << discrete_value;
257 }
258 }
259 }
260}

References libMesh::ENCODE, libMesh::RBParametrized::get_discrete_parameter_values(), libMesh::RBParametrized::get_n_discrete_params(), libMesh::Real, and libMesh::WRITE.

Referenced by libMesh::RBParametrized::write_parameter_data_to_files().

◆ write_header()

void libMesh::System::write_header ( Xdr io,
std::string_view  version,
const bool  write_additional_data 
) const
inherited

Writes the basic data header for this System.

This method implements the output of a System object, embedded in the output of an EquationSystems<T_sys>. This warrants some documentation. The output of this part consists of 5 sections:

for this system

5.) The number of variables in the system (unsigned int)

for each variable in the system

6.) The name of the variable (string)

6.1.) subdomain where the variable lives

7.) Combined in an FEType:

  • The approximation order(s) of the variable (Order Enum, cast to int/s)
  • The finite element family/ies of the variable (FEFamily Enum, cast to int/s)

end variable loop

8.) The number of additional vectors (unsigned int),

for each additional vector in the system object

9.) the name of the additional vector (string)

end system

Definition at line 1117 of file system_io.C.

1120{
1154 libmesh_assert (io.writing());
1155
1156
1157 // Only write the header information
1158 // if we are processor 0.
1159 if (this->get_mesh().processor_id() != 0)
1160 return;
1161
1162 std::string comment;
1163
1164 // 5.)
1165 // Write the number of variables in the system
1166
1167 {
1168 // set up the comment
1169 comment = "# No. of Variables in System \"";
1170 comment += this->name();
1171 comment += "\"";
1172
1173 unsigned int nv = this->n_vars();
1174 io.data (nv, comment);
1175 }
1176
1177
1178 for (auto var : make_range(this->n_vars()))
1179 {
1180 // 6.)
1181 // Write the name of the var-th variable
1182 {
1183 // set up the comment
1184 comment = "# Name, Variable No. ";
1185 comment += std::to_string(var);
1186 comment += ", System \"";
1187 comment += this->name();
1188 comment += "\"";
1189
1190 std::string var_name = this->variable_name(var);
1191 io.data (var_name, comment);
1192 }
1193
1194 // 6.1.) Variable subdomains
1195 {
1196 // set up the comment
1197 comment = "# Subdomains, Variable \"";
1198 comment += this->variable_name(var);
1199 comment += "\", System \"";
1200 comment += this->name();
1201 comment += "\"";
1202
1203 const std::set<subdomain_id_type> & domains = this->variable(var).active_subdomains();
1204 std::vector<subdomain_id_type> domain_array;
1205 domain_array.assign(domains.begin(), domains.end());
1206 io.data (domain_array, comment);
1207 }
1208
1209 // 7.)
1210 // Write the approximation order of the var-th variable
1211 // in this system
1212 {
1213 // set up the comment
1214 comment = "# Approximation Order, Variable \"";
1215 comment += this->variable_name(var);
1216 comment += "\", System \"";
1217 comment += this->name();
1218 comment += "\"";
1219
1220 int order = static_cast<int>(this->variable_type(var).order);
1221 io.data (order, comment);
1222 }
1223
1224
1225#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1226
1227 // do the same for radial_order
1228 {
1229 comment = "# Radial Approximation Order, Variable \"";
1230 comment += this->variable_name(var);
1231 comment += "\", System \"";
1232 comment += this->name();
1233 comment += "\"";
1234
1235 int rad_order = static_cast<int>(this->variable_type(var).radial_order);
1236 io.data (rad_order, comment);
1237 }
1238
1239#endif
1240
1241 // Write the Finite Element type of the var-th variable
1242 // in this System
1243 {
1244 // set up the comment
1245 comment = "# FE Family, Variable \"";
1246 comment += this->variable_name(var);
1247 comment += "\", System \"";
1248 comment += this->name();
1249 comment += "\"";
1250
1251 const FEType & type = this->variable_type(var);
1252 int fam = static_cast<int>(type.family);
1253 io.data (fam, comment);
1254
1255#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1256
1257 comment = "# Radial FE Family, Variable \"";
1258 comment += this->variable_name(var);
1259 comment += "\", System \"";
1260 comment += this->name();
1261 comment += "\"";
1262
1263 int radial_fam = static_cast<int>(type.radial_family);
1264 io.data (radial_fam, comment);
1265
1266 comment = "# Infinite Mapping Type, Variable \"";
1267 comment += this->variable_name(var);
1268 comment += "\", System \"";
1269 comment += this->name();
1270 comment += "\"";
1271
1272 int i_map = static_cast<int>(type.inf_map);
1273 io.data (i_map, comment);
1274#endif
1275 }
1276 } // end of the variable loop
1277
1278 // 8.)
1279 // Write the number of additional vectors in the System.
1280 // If write_additional_data==false, then write zero for
1281 // the number of additional vectors.
1282 {
1283 {
1284 // set up the comment
1285 comment = "# No. of Additional Vectors, System \"";
1286 comment += this->name();
1287 comment += "\"";
1288
1289 unsigned int nvecs = write_additional_data ? this->n_vectors () : 0;
1290 io.data (nvecs, comment);
1291 }
1292
1293 if (write_additional_data)
1294 {
1295 unsigned int cnt=0;
1296 for (const auto & [vec_name, vec] : _vectors)
1297 {
1298 // 9.)
1299 // write the name of the cnt-th additional vector
1300 const std::string dth_vector = std::to_string(cnt++)+"th vector";
1301 comment = "# Name of " + dth_vector;
1302 std::string nonconst_vec_name = vec_name; // Stupid XDR API
1303
1304 io.data (nonconst_vec_name, comment);
1305 int vec_projection = _vector_projections.at(vec_name);
1306 comment = "# Whether to do projections for " + dth_vector;
1307 io.data (vec_projection, comment);
1308 int vec_type = vec->type();
1309 comment = "# Parallel type of " + dth_vector;
1310 io.data (vec_type, comment);
1311 }
1312 }
1313 }
1314}
OrderWrapper radial_order
The approximation order in radial direction of the infinite element.
Definition fe_type.h:263
const std::string & variable_name(const unsigned int i) const
Definition system.C:2679

References libMesh::System::_vector_projections, libMesh::System::_vectors, libMesh::Variable::active_subdomains(), libMesh::Xdr::data(), libMesh::FEType::family, libMesh::System::get_mesh(), libMesh::FEType::inf_map, libMesh::libmesh_assert(), libMesh::make_range(), libMesh::System::n_vars(), libMesh::System::n_vectors(), libMesh::System::name(), libMesh::FEType::order, libMesh::ParallelObject::processor_id(), libMesh::FEType::radial_family, libMesh::FEType::radial_order, libMesh::System::variable(), libMesh::System::variable_name(), libMesh::System::variable_type(), and libMesh::Xdr::writing().

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

◆ write_parallel_data()

void libMesh::System::write_parallel_data ( Xdr io,
const bool  write_additional_data 
) const
inherited

Writes additional data, namely vectors, for this System.

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

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

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

for each additional vector in the object

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

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

Definition at line 1318 of file system_io.C.

1320{
1340 // PerfLog pl("IO Performance",false);
1341 // pl.push("write_parallel_data");
1342 // std::size_t total_written_size = 0;
1343
1344 std::string comment;
1345
1346 libmesh_assert (io.writing());
1347
1348 std::vector<Number> io_buffer; io_buffer.reserve(this->solution->local_size());
1349
1350 // build the ordered nodes and element maps.
1351 // when writing/reading parallel files we need to iterate
1352 // over our nodes/elements in order of increasing global id().
1353 // however, this is not guaranteed to be ordering we obtain
1354 // by using the node_iterators/element_iterators directly.
1355 // so build a set, sorted by id(), that provides the ordering.
1356 // further, for memory economy build the set but then transfer
1357 // its contents to vectors, which will be sorted.
1358 std::vector<const DofObject *> ordered_nodes, ordered_elements;
1359 {
1360 std::set<const DofObject *, CompareDofObjectsByID>
1361 ordered_nodes_set (this->get_mesh().local_nodes_begin(),
1362 this->get_mesh().local_nodes_end());
1363
1364 ordered_nodes.insert(ordered_nodes.end(),
1365 ordered_nodes_set.begin(),
1366 ordered_nodes_set.end());
1367 }
1368 {
1369 std::set<const DofObject *, CompareDofObjectsByID>
1370 ordered_elements_set (this->get_mesh().local_elements_begin(),
1371 this->get_mesh().local_elements_end());
1372
1373 ordered_elements.insert(ordered_elements.end(),
1374 ordered_elements_set.begin(),
1375 ordered_elements_set.end());
1376 }
1377
1378 const unsigned int sys_num = this->number();
1379 const unsigned int nv = this->n_vars();
1380
1381 // Loop over each non-SCALAR variable and each node, and write out the value.
1382 for (unsigned int var=0; var<nv; var++)
1383 if (this->variable(var).type().family != SCALAR)
1384 {
1385 // First write the node DOF values
1386 for (const auto & node : ordered_nodes)
1387 for (auto comp : make_range(node->n_comp(sys_num,var)))
1388 {
1389 libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
1391
1392 io_buffer.push_back((*this->solution)(node->dof_number(sys_num, var, comp)));
1393 }
1394
1395 // Then write the element DOF values
1396 for (const auto & elem : ordered_elements)
1397 for (auto comp : make_range(elem->n_comp(sys_num,var)))
1398 {
1399 libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
1401
1402 io_buffer.push_back((*this->solution)(elem->dof_number(sys_num, var, comp)));
1403 }
1404 }
1405
1406 // Finally, write the SCALAR data on the last processor
1407 for (auto var : make_range(this->n_vars()))
1408 if (this->variable(var).type().family == SCALAR)
1409 {
1410 if (this->processor_id() == (this->n_processors()-1))
1411 {
1412 const DofMap & dof_map = this->get_dof_map();
1413 std::vector<dof_id_type> SCALAR_dofs;
1414 dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
1415
1416 for (auto dof : SCALAR_dofs)
1417 io_buffer.push_back((*this->solution)(dof));
1418 }
1419 }
1420
1421 // 9.)
1422 //
1423 // Actually write the reordered solution vector
1424 // for the ith system to disk
1425
1426 // set up the comment
1427 {
1428 comment = "# System \"";
1429 comment += this->name();
1430 comment += "\" Solution Vector";
1431 }
1432
1433 io.data (io_buffer, comment);
1434
1435 // total_written_size += io_buffer.size();
1436
1437 // Only write additional vectors if wanted
1438 if (write_additional_data)
1439 {
1440 for (auto & [vec_name, vec] : _vectors)
1441 {
1442 io_buffer.clear();
1443 io_buffer.reserve(vec->local_size());
1444
1445 // Loop over each non-SCALAR variable and each node, and write out the value.
1446 for (unsigned int var=0; var<nv; var++)
1447 if (this->variable(var).type().family != SCALAR)
1448 {
1449 // First write the node DOF values
1450 for (const auto & node : ordered_nodes)
1451 for (auto comp : make_range(node->n_comp(sys_num,var)))
1452 {
1453 libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
1455
1456 io_buffer.push_back((*vec)(node->dof_number(sys_num, var, comp)));
1457 }
1458
1459 // Then write the element DOF values
1460 for (const auto & elem : ordered_elements)
1461 for (auto comp : make_range(elem->n_comp(sys_num,var)))
1462 {
1463 libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
1465
1466 io_buffer.push_back((*vec)(elem->dof_number(sys_num, var, comp)));
1467 }
1468 }
1469
1470 // Finally, write the SCALAR data on the last processor
1471 for (auto var : make_range(this->n_vars()))
1472 if (this->variable(var).type().family == SCALAR)
1473 {
1474 if (this->processor_id() == (this->n_processors()-1))
1475 {
1476 const DofMap & dof_map = this->get_dof_map();
1477 std::vector<dof_id_type> SCALAR_dofs;
1478 dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
1479
1480 for (auto dof : SCALAR_dofs)
1481 io_buffer.push_back((*vec)(dof));
1482 }
1483 }
1484
1485 // 10.)
1486 //
1487 // Actually write the reordered additional vector
1488 // for this system to disk
1489
1490 // set up the comment
1491 {
1492 comment = "# System \"";
1493 comment += this->name();
1494 comment += "\" Additional Vector \"";
1495 comment += vec_name;
1496 comment += "\"";
1497 }
1498
1499 io.data (io_buffer, comment);
1500
1501 // total_written_size += io_buffer.size();
1502 }
1503 }
1504
1505 // const Real
1506 // dt = pl.get_elapsed_time(),
1507 // rate = total_written_size*sizeof(Number)/dt;
1508
1509 // libMesh::err << "Write " << total_written_size << " \"Number\" values\n"
1510 // << " Elapsed time = " << dt << '\n'
1511 // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
1512
1513 // pl.pop("write_parallel_data");
1514}

References libMesh::System::_vectors, libMesh::Xdr::data(), libMesh::FEType::family, libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::DofObject::invalid_id, libMesh::libmesh_assert(), libMesh::make_range(), libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMesh::System::name(), libMesh::System::number(), libMesh::ParallelObject::processor_id(), libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::System::solution, libMesh::Variable::type(), libMesh::System::variable(), and libMesh::Xdr::writing().

◆ write_parameter_data_to_files()

void libMesh::RBParametrized::write_parameter_data_to_files ( const std::string &  continuous_param_file_name,
const std::string &  discrete_param_file_name,
const bool  write_binary_data 
)
inherited

Write out the parameter ranges to files.

Definition at line 185 of file rb_parametrized.C.

188{
189 write_parameter_ranges_to_file(continuous_param_file_name, write_binary_data);
190 write_discrete_parameter_values_to_file(discrete_param_file_name, write_binary_data);
191}
void write_parameter_ranges_to_file(const std::string &file_name, const bool write_binary)
Write out the parameter ranges to file.
void write_discrete_parameter_values_to_file(const std::string &file_name, const bool write_binary_data)
Write out the discrete parameter values to file.

References libMesh::RBParametrized::write_discrete_parameter_values_to_file(), and libMesh::RBParametrized::write_parameter_ranges_to_file().

Referenced by libMesh::RBEvaluation::legacy_write_offline_data_to_files(), and libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files().

◆ write_parameter_ranges_to_file()

void libMesh::RBParametrized::write_parameter_ranges_to_file ( const std::string &  file_name,
const bool  write_binary 
)
privateinherited

Write out the parameter ranges to file.

Definition at line 193 of file rb_parametrized.C.

195{
196 // The writing mode: ENCODE for binary, WRITE for ASCII
197 XdrMODE mode = write_binary_data ? ENCODE : WRITE;
198
199 // Write out the parameter ranges
200 Xdr parameter_ranges_out(file_name, mode);
201 unsigned int n_continuous_params = get_n_continuous_params();
202 parameter_ranges_out << n_continuous_params;
203
204 // Note: the following loops are not candidates for structured
205 // bindings syntax because the Xdr APIs which they call are not
206 // defined for const references. We must therefore make copies to
207 // call these functions.
208 for (const auto & pr : get_parameters_min())
209 {
210 std::string param_name = pr.first;
211 if (!is_discrete_parameter(param_name))
212 {
213 Real param_value = get_parameters_min().get_value(param_name);
214 parameter_ranges_out << param_name << param_value;
215 }
216 }
217 for (const auto & pr : get_parameters_max())
218 {
219 std::string param_name = pr.first;
220 if (!is_discrete_parameter(param_name))
221 {
222 Real param_value = get_parameters_max().get_value(param_name);
223 parameter_ranges_out << param_name << param_value;
224 }
225 }
226
227 parameter_ranges_out.close();
228}
unsigned int get_n_continuous_params() const
Get the number of continuous parameters.

References libMesh::Xdr::close(), libMesh::ENCODE, libMesh::RBParametrized::get_n_continuous_params(), libMesh::RBParametrized::get_parameters_max(), libMesh::RBParametrized::get_parameters_min(), libMesh::RBParameters::get_value(), libMesh::RBParametrized::is_discrete_parameter(), libMesh::Real, and libMesh::WRITE.

Referenced by libMesh::RBParametrized::write_parameter_data_to_files().

◆ write_SCALAR_dofs()

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

Writes the SCALAR dofs associated with var to the stream io.

Returns
The number of values written.

Definition at line 1912 of file system_io.C.

1915{
1916 unsigned int written_length=0;
1917 std::vector<Number> vals; // The raw values for the local objects in the current block
1918 // Collect the SCALARs for the current variable
1919 if (this->processor_id() == (this->n_processors()-1))
1920 {
1921 const DofMap & dof_map = this->get_dof_map();
1922 std::vector<dof_id_type> SCALAR_dofs;
1923 dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
1924 const unsigned int n_scalar_dofs = cast_int<unsigned int>
1925 (SCALAR_dofs.size());
1926
1927 for (unsigned int i=0; i<n_scalar_dofs; i++)
1928 {
1929 vals.push_back( vec(SCALAR_dofs[i]) );
1930 }
1931 }
1932
1933#ifdef LIBMESH_HAVE_MPI
1934 if (this->n_processors() > 1)
1935 {
1936 const Parallel::MessageTag val_tag =
1937 this->comm().get_unique_tag(1);
1938
1939 // Post the receive on processor 0
1940 if (this->processor_id() == 0)
1941 {
1942 this->comm().receive(this->n_processors()-1, vals, val_tag);
1943 }
1944
1945 // Send the data to processor 0
1946 if (this->processor_id() == (this->n_processors()-1))
1947 {
1948 this->comm().send(0, vals, val_tag);
1949 }
1950 }
1951#endif
1952
1953 // -------------------------------------------------------
1954 // Write the output on processor 0.
1955 if (this->processor_id() == 0)
1956 {
1957 const unsigned int vals_size =
1958 cast_int<unsigned int>(vals.size());
1959 io.data_stream (vals.data(), vals_size);
1960 written_length += vals_size;
1961 }
1962
1963 return written_length;
1964}

References libMesh::ParallelObject::comm(), libMesh::Xdr::data_stream(), libMesh::System::get_dof_map(), libMesh::Parallel::Communicator::get_unique_tag(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::Parallel::Communicator::receive(), libMesh::DofMap::SCALAR_dof_indices(), and libMesh::Parallel::Communicator::send().

Referenced by libMesh::System::write_serialized_vector(), and libMesh::System::write_serialized_vectors().

◆ write_serialized_blocked_dof_objects()

template<typename iterator_type >
std::size_t libMesh::System::write_serialized_blocked_dof_objects ( const std::vector< const NumericVector< Number > * > &  vecs,
const dof_id_type  n_objects,
const iterator_type  begin,
const iterator_type  end,
Xdr io,
const unsigned int  var_to_write = libMesh::invalid_uint 
) const
privateinherited

Writes an output vector to the stream io for a set of DofObjects.

This method uses blocked output and is safe to call on a distributed memory-mesh.

Returns
The number of values written

Definition at line 1626 of file system_io.C.

1632{
1633 parallel_object_only();
1634
1635 //-------------------------------------------------------
1636 // General order: (IO format 0.7.4 & greater)
1637 //
1638 // for (objects ...)
1639 // for (vecs ....)
1640 // for (vars ....)
1641 // for (comps ...)
1642 //
1643 // where objects are nodes or elements, sorted to be
1644 // partition independent,
1645 // vecs are one or more *identically distributed* solution
1646 // coefficient vectors, vars are one or more variables
1647 // to write, and comps are all the components for said
1648 // vars on the object.
1649
1650 // We will write all variables unless requested otherwise.
1651 std::vector<unsigned int> vars_to_write(1, var_to_write);
1652
1653 if (var_to_write == libMesh::invalid_uint)
1654 {
1655 vars_to_write.clear(); vars_to_write.reserve(this->n_vars());
1656 for (auto var : make_range(this->n_vars()))
1657 vars_to_write.push_back(var);
1658 }
1659
1660 const dof_id_type io_blksize = cast_int<dof_id_type>
1661 (std::min(max_io_blksize, static_cast<std::size_t>(n_objs)));
1662
1663 const unsigned int
1664 sys_num = this->number(),
1665 num_vecs = cast_int<unsigned int>(vecs.size()),
1666 num_blks = cast_int<unsigned int>(std::ceil(static_cast<double>(n_objs)/
1667 static_cast<double>(io_blksize)));
1668
1669 // libMesh::out << "io_blksize = " << io_blksize
1670 // << ", num_objects = " << n_objs
1671 // << ", num_blks = " << num_blks
1672 // << std::endl;
1673
1674 std::size_t written_length=0; // The numer of values written. This will be returned
1675 std::vector<std::vector<dof_id_type>> xfer_ids(num_blks); // The global IDs and # of components for the local objects in all blocks
1676 std::vector<std::vector<Number>> send_vals(num_blks); // The raw values for the local objects in all blocks
1677 std::vector<Parallel::Request>
1678 id_requests(num_blks), val_requests(num_blks); // send request handle for each block
1679 std::vector<Parallel::MessageTag>
1680 id_tags(num_blks), val_tags(num_blks); // tag number for each block
1681
1682 // ------------------------------------------------------
1683 // First pass - count the number of objects in each block
1684 // traverse all the objects and figure out which block they
1685 // will ultimately live in.
1686 std::vector<unsigned int>
1687 xfer_ids_size (num_blks,0),
1688 send_vals_size (num_blks,0);
1689
1690 for (iterator_type it=begin; it!=end; ++it)
1691 {
1692 const dof_id_type
1693 id = (*it)->id(),
1694 block = id/io_blksize;
1695
1696 libmesh_assert_less (block, num_blks);
1697
1698 xfer_ids_size[block] += 2; // for each object, we store its id, as well as the total number of components for all variables
1699
1700 unsigned int n_comp_tot=0;
1701
1702 for (const auto & var : vars_to_write)
1703 n_comp_tot += (*it)->n_comp(sys_num, var); // for each variable, we will store the nonzero components
1704
1705 send_vals_size[block] += n_comp_tot*num_vecs;
1706 }
1707
1708 //-----------------------------------------
1709 // Collect the values for all local objects,
1710 // binning them into 'blocks' that will be
1711 // sent to processor 0
1712 for (unsigned int blk=0; blk<num_blks; blk++)
1713 {
1714 // libMesh::out << "Writing object block " << blk << std::endl;
1715
1716 // Each processor should build up its transfer buffers for its
1717 // local objects in [first_object,last_object).
1718 const dof_id_type
1719 first_object = blk*io_blksize,
1720 last_object = std::min(cast_int<dof_id_type>((blk+1)*io_blksize), n_objs);
1721
1722 // convenience
1723 std::vector<dof_id_type> & ids (xfer_ids[blk]);
1724 std::vector<Number> & vals (send_vals[blk]);
1725
1726 // we now know the number of values we will store for each block,
1727 // so we can do efficient preallocation
1728 ids.clear(); ids.reserve (xfer_ids_size[blk]);
1729 vals.clear(); vals.reserve (send_vals_size[blk]);
1730
1731 if (send_vals_size[blk] != 0) // only send if we have nonzero components to write
1732 for (iterator_type it=begin; it!=end; ++it)
1733 if (((*it)->id() >= first_object) && // object in [first_object,last_object)
1734 ((*it)->id() < last_object))
1735 {
1736 ids.push_back((*it)->id());
1737
1738 // count the total number of nonzeros transferred for this object
1739 {
1740 unsigned int n_comp_tot=0;
1741
1742 for (const auto & var : vars_to_write)
1743 n_comp_tot += (*it)->n_comp(sys_num, var);
1744
1745 ids.push_back (n_comp_tot*num_vecs); // even if 0 - processor 0 has no way of knowing otherwise...
1746 }
1747
1748 // pack the values to send
1749 for (const auto & vec : vecs)
1750 for (const auto & var : vars_to_write)
1751 {
1752 const unsigned int n_comp = (*it)->n_comp(sys_num, var);
1753
1754 for (unsigned int comp=0; comp<n_comp; comp++)
1755 {
1756 libmesh_assert_greater_equal ((*it)->dof_number(sys_num, var, comp), vec->first_local_index());
1757 libmesh_assert_less ((*it)->dof_number(sys_num, var, comp), vec->last_local_index());
1758 vals.push_back((*vec)((*it)->dof_number(sys_num, var, comp)));
1759 }
1760 }
1761 }
1762
1763#ifdef LIBMESH_HAVE_MPI
1764 id_tags[blk] = this->comm().get_unique_tag(100*num_blks + blk);
1765 val_tags[blk] = this->comm().get_unique_tag(200*num_blks + blk);
1766
1767 // nonblocking send the data for this block
1768 this->comm().send (0, ids, id_requests[blk], id_tags[blk]);
1769 this->comm().send (0, vals, val_requests[blk], val_tags[blk]);
1770#endif
1771 }
1772
1773
1774 if (this->processor_id() == 0)
1775 {
1776 std::vector<std::vector<dof_id_type>> recv_ids (this->n_processors());
1777 std::vector<std::vector<Number>> recv_vals (this->n_processors());
1778 std::vector<unsigned int> obj_val_offsets; // map to traverse entry-wise rather than processor-wise
1779 std::vector<Number> output_vals; // The output buffer for the current block
1780
1781 // a ThreadedIO object to perform asynchronous file IO
1782 ThreadedIO<Number> threaded_io(io, output_vals);
1783 std::unique_ptr<Threads::Thread> async_io;
1784
1785 for (unsigned int blk=0; blk<num_blks; blk++)
1786 {
1787 // Each processor should build up its transfer buffers for its
1788 // local objects in [first_object,last_object).
1789 const dof_id_type
1790 first_object = cast_int<dof_id_type>(blk*io_blksize),
1791 last_object = std::min(cast_int<dof_id_type>((blk+1)*io_blksize), n_objs),
1792 n_objects_blk = last_object - first_object;
1793
1794 // offset array. this will define where each object's values
1795 // map into the actual output_vals buffer. this must get
1796 // 0-initialized because 0-component objects are not actually sent
1797 obj_val_offsets.resize (n_objects_blk); std::fill (obj_val_offsets.begin(), obj_val_offsets.end(), 0);
1798
1799 std::size_t n_val_recvd_blk=0;
1800
1801 // receive this block of data from all processors.
1802 for (processor_id_type comm_step=0, tnp=this->n_processors(); comm_step != tnp; ++comm_step)
1803 {
1804#ifdef LIBMESH_HAVE_MPI
1805 // blocking receive indices for this block, imposing no particular order on processor
1806 Parallel::Status id_status (this->comm().probe (Parallel::any_source, id_tags[blk]));
1807 std::vector<dof_id_type> & ids (recv_ids[id_status.source()]);
1808 this->comm().receive (id_status.source(), ids, id_tags[blk]);
1809#else
1810 std::vector<dof_id_type> & ids (recv_ids[0]);
1811 ids = xfer_ids[blk];
1812#endif
1813
1814 // note its possible we didn't receive values for objects in
1815 // this block if they have no components allocated.
1816 for (std::size_t idx=0, sz=ids.size(); idx<sz; idx+=2)
1817 {
1818 const dof_id_type
1819 local_idx = ids[idx+0]-first_object,
1820 n_vals_tot_allvecs = ids[idx+1];
1821
1822 libmesh_assert_less (local_idx, n_objects_blk);
1823 libmesh_assert_less (local_idx, obj_val_offsets.size());
1824
1825 obj_val_offsets[local_idx] = n_vals_tot_allvecs;
1826 }
1827
1828#ifdef LIBMESH_HAVE_MPI
1829 // blocking receive values for this block, imposing no particular order on processor
1830 Parallel::Status val_status (this->comm().probe (Parallel::any_source, val_tags[blk]));
1831 std::vector<Number> & vals (recv_vals[val_status.source()]);
1832 this->comm().receive (val_status.source(), vals, val_tags[blk]);
1833#else
1834 // straight copy without MPI
1835 std::vector<Number> & vals (recv_vals[0]);
1836 vals = send_vals[blk];
1837#endif
1838
1839 n_val_recvd_blk += vals.size();
1840 }
1841
1842 // We need the offsets into the output_vals vector for each object.
1843 // fortunately, this is simply the partial sum of the total number
1844 // of components for each object
1845 std::partial_sum(obj_val_offsets.begin(), obj_val_offsets.end(),
1846 obj_val_offsets.begin());
1847
1848 // wait on any previous asynchronous IO - this *must* complete before
1849 // we start messing with the output_vals buffer!
1850 if (async_io.get()) async_io->join();
1851
1852 // this is the actual output buffer that will be written to disk.
1853 // at ths point we finally know wha size it will be.
1854 output_vals.resize(n_val_recvd_blk);
1855
1856 // pack data from all processors into output values
1857 for (auto proc : make_range(this->n_processors()))
1858 {
1859 const std::vector<dof_id_type> & ids (recv_ids [proc]);
1860 const std::vector<Number> & vals(recv_vals[proc]);
1861 std::vector<Number>::const_iterator proc_vals(vals.begin());
1862
1863 for (std::size_t idx=0, sz=ids.size(); idx<sz; idx+=2)
1864 {
1865 const dof_id_type
1866 local_idx = ids[idx+0]-first_object,
1867 n_vals_tot_allvecs = ids[idx+1];
1868
1869 // put this object's data into the proper location
1870 // in the output buffer
1871 std::vector<Number>::iterator out_vals(output_vals.begin());
1872 if (local_idx != 0)
1873 std::advance (out_vals, obj_val_offsets[local_idx-1]);
1874
1875 for (unsigned int val=0; val<n_vals_tot_allvecs; val++, ++out_vals, ++proc_vals)
1876 {
1877 libmesh_assert (out_vals != output_vals.end());
1878 libmesh_assert (proc_vals != vals.end());
1879 *out_vals = *proc_vals;
1880 }
1881 }
1882 }
1883
1884 // output_vals buffer is now filled for this block.
1885 // write it to disk
1886 async_io = std::make_unique<Threads::Thread>(threaded_io);
1887 written_length += output_vals.size();
1888 }
1889
1890 // wait on any previous asynchronous IO - this *must* complete before
1891 // our stuff goes out of scope
1892 async_io->join();
1893 }
1894
1895 Parallel::wait(id_requests);
1896 Parallel::wait(val_requests);
1897
1898 // we need some synchronization here. Because this method
1899 // can be called for a range of nodes, then a range of elements,
1900 // we need some mechanism to prevent processors from racing past
1901 // to the next range and overtaking ongoing communication. one
1902 // approach would be to figure out unique tags for each range,
1903 // but for now we just impose a barrier here. And might as
1904 // well have it do some useful work.
1905 this->comm().broadcast(written_length);
1906
1907 return written_length;
1908}

References TIMPI::any_source, libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::Parallel::Communicator::get_unique_tag(), libMesh::invalid_uint, libMesh::libmesh_assert(), libMesh::make_range(), libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMesh::System::number(), libMesh::ParallelObject::processor_id(), libMesh::Parallel::Communicator::receive(), libMesh::Parallel::Communicator::send(), TIMPI::Status::source(), and TIMPI::wait().

Referenced by libMesh::System::write_serialized_vector(), and libMesh::System::write_serialized_vectors().

◆ write_serialized_data()

void libMesh::System::write_serialized_data ( Xdr io,
const bool  write_additional_data = true 
) const
inherited

Writes additional data, namely vectors, for this System.

This method may safely be called on a distributed-memory mesh.

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

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

for each additional vector in the object

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

Definition at line 1518 of file system_io.C.

1520{
1534 parallel_object_only();
1535 std::string comment;
1536
1537 // PerfLog pl("IO Performance",false);
1538 // pl.push("write_serialized_data");
1539 // std::size_t total_written_size = 0;
1540
1541 // total_written_size +=
1542 this->write_serialized_vector(io, *this->solution);
1543
1544 // set up the comment
1545 if (this->processor_id() == 0)
1546 {
1547 comment = "# System \"";
1548 comment += this->name();
1549 comment += "\" Solution Vector";
1550
1551 io.comment (comment);
1552 }
1553
1554 // Only write additional vectors if wanted
1555 if (write_additional_data)
1556 {
1557 for (auto & pair : this->_vectors)
1558 {
1559 // total_written_size +=
1560 this->write_serialized_vector(io, *pair.second);
1561
1562 // set up the comment
1563 if (this->processor_id() == 0)
1564 {
1565 comment = "# System \"";
1566 comment += this->name();
1567 comment += "\" Additional Vector \"";
1568 comment += pair.first;
1569 comment += "\"";
1570 io.comment (comment);
1571 }
1572 }
1573 }
1574
1575 // const Real
1576 // dt = pl.get_elapsed_time(),
1577 // rate = total_written_size*sizeof(Number)/dt;
1578
1579 // libMesh::out << "Write " << total_written_size << " \"Number\" values\n"
1580 // << " Elapsed time = " << dt << '\n'
1581 // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
1582
1583 // pl.pop("write_serialized_data");
1584
1585
1586
1587
1588 // // test the new method
1589 // {
1590 // std::vector<std::string> names;
1591 // std::vector<NumericVector<Number> *> vectors_to_write;
1592
1593 // names.push_back("Solution Vector");
1594 // vectors_to_write.push_back(this->solution.get());
1595
1596 // // Only write additional vectors if wanted
1597 // if (write_additional_data)
1598 // {
1599 // std::map<std::string, NumericVector<Number> *>::const_iterator
1600 // pos = _vectors.begin();
1601
1602 // for (; pos != this->_vectors.end(); ++pos)
1603 // {
1604 // names.push_back("Additional Vector " + pos->first);
1605 // vectors_to_write.push_back(pos->second);
1606 // }
1607 // }
1608
1609 // total_written_size =
1610 // this->write_serialized_vectors (io, names, vectors_to_write);
1611
1612 // const Real
1613 // dt2 = pl.get_elapsed_time(),
1614 // rate2 = total_written_size*sizeof(Number)/(dt2-dt);
1615
1616 // libMesh::out << "Write (new) " << total_written_size << " \"Number\" values\n"
1617 // << " Elapsed time = " << (dt2-dt) << '\n'
1618 // << " Rate = " << rate2/1.e6 << "(MB/sec)\n\n";
1619
1620 // }
1621}
dof_id_type write_serialized_vector(Xdr &io, const NumericVector< Number > &vec) const
Writes a vector for this System.
Definition system_io.C:1968

References libMesh::System::_vectors, libMesh::Xdr::comment(), libMesh::System::name(), libMesh::ParallelObject::processor_id(), libMesh::System::solution, and libMesh::System::write_serialized_vector().

Referenced by libMesh::RBConstruction::write_riesz_representors_to_files(), and libMesh::TransientRBConstruction::write_riesz_representors_to_files().

◆ write_serialized_vector()

dof_id_type libMesh::System::write_serialized_vector ( Xdr io,
const NumericVector< Number > &  vec 
) const
privateinherited

Writes a vector for this System.

This method may safely be called on a distributed-memory mesh.

Returns
The number of values written.

Definition at line 1968 of file system_io.C.

1970{
1971 parallel_object_only();
1972
1973 libmesh_assert (io.writing());
1974
1975 dof_id_type vec_length = vec.size();
1976 if (this->processor_id() == 0) io.data (vec_length, "# vector length");
1977
1978 dof_id_type written_length = 0;
1979
1980 //---------------------------------
1981 // Collect the values for all nodes
1982 written_length += cast_int<dof_id_type>
1983 (this->write_serialized_blocked_dof_objects (std::vector<const NumericVector<Number> *>(1,&vec),
1984 this->get_mesh().n_nodes(),
1985 this->get_mesh().local_nodes_begin(),
1986 this->get_mesh().local_nodes_end(),
1987 io));
1988
1989 //------------------------------------
1990 // Collect the values for all elements
1991 written_length += cast_int<dof_id_type>
1992 (this->write_serialized_blocked_dof_objects (std::vector<const NumericVector<Number> *>(1,&vec),
1993 this->get_mesh().n_elem(),
1994 this->get_mesh().local_elements_begin(),
1995 this->get_mesh().local_elements_end(),
1996 io));
1997
1998 //-------------------------------------------
1999 // Finally loop over all the SCALAR variables
2000 for (auto var : make_range(this->n_vars()))
2001 if (this->variable(var).type().family == SCALAR)
2002 {
2003 written_length +=
2004 this->write_SCALAR_dofs (vec, var, io);
2005 }
2006
2007 if (this->processor_id() == 0)
2008 libmesh_assert_equal_to (written_length, vec_length);
2009
2010 return written_length;
2011}
std::size_t write_serialized_blocked_dof_objects(const std::vector< const NumericVector< Number > * > &vecs, const dof_id_type n_objects, const iterator_type begin, const iterator_type end, Xdr &io, const unsigned int var_to_write=libMesh::invalid_uint) const
Writes an output vector to the stream io for a set of DofObjects.
Definition system_io.C:1626
unsigned int write_SCALAR_dofs(const NumericVector< Number > &vec, const unsigned int var, Xdr &io) const
Writes the SCALAR dofs associated with var to the stream io.
Definition system_io.C:1912

References libMesh::Xdr::data(), libMesh::FEType::family, libMesh::System::get_mesh(), libMesh::libmesh_assert(), libMesh::make_range(), n_nodes, libMesh::System::n_vars(), libMesh::ParallelObject::processor_id(), libMesh::SCALAR, libMesh::NumericVector< T >::size(), libMesh::Variable::type(), libMesh::System::variable(), libMesh::System::write_SCALAR_dofs(), libMesh::System::write_serialized_blocked_dof_objects(), and libMesh::Xdr::writing().

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

◆ write_serialized_vectors()

std::size_t libMesh::System::write_serialized_vectors ( Xdr io,
const std::vector< const NumericVector< Number > * > &  vectors 
) const
inherited

Serialize & write a number of identically distributed vectors.

This method allows for optimization for the multiple vector case by only communicating the metadata once.

Definition at line 2111 of file system_io.C.

2113{
2114 parallel_object_only();
2115
2116 libmesh_assert (io.writing());
2117
2118 // Cache these - they are not free!
2119 const dof_id_type
2120 n_nodes = this->get_mesh().n_nodes(),
2121 n_elem = this->get_mesh().n_elem();
2122
2123 std::size_t written_length = 0;
2124
2125 if (this->processor_id() == 0)
2126 {
2127 unsigned int
2128 n_vec = cast_int<unsigned int>(vectors.size());
2130 vec_size = vectors.empty() ? 0 : vectors[0]->size();
2131 // Set the number of vectors
2132 io.data(n_vec, "# number of vectors");
2133 // Set the buffer size
2134 io.data(vec_size, "# vector length");
2135 }
2136
2137 //---------------------------------
2138 // Collect the values for all nodes
2139 written_length +=
2141 n_nodes,
2142 this->get_mesh().local_nodes_begin(),
2143 this->get_mesh().local_nodes_end(),
2144 io);
2145
2146 //------------------------------------
2147 // Collect the values for all elements
2148 written_length +=
2150 n_elem,
2151 this->get_mesh().local_elements_begin(),
2152 this->get_mesh().local_elements_end(),
2153 io);
2154
2155 //-------------------------------------------
2156 // Finally loop over all the SCALAR variables
2157 for (const NumericVector<Number> * vec : vectors)
2158 for (auto var : make_range(this->n_vars()))
2159 if (this->variable(var).type().family == SCALAR)
2160 {
2161 libmesh_assert_not_equal_to (vec, 0);
2162
2163 written_length +=
2164 this->write_SCALAR_dofs (*vec, var, io);
2165 }
2166
2167 return written_length;
2168}

References libMesh::Xdr::data(), libMesh::FEType::family, libMesh::System::get_mesh(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), n_nodes, libMesh::System::n_vars(), libMesh::ParallelObject::processor_id(), libMesh::SCALAR, libMesh::Variable::type(), libMesh::System::variable(), libMesh::System::write_SCALAR_dofs(), libMesh::System::write_serialized_blocked_dof_objects(), and libMesh::Xdr::writing().

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

◆ zero_variable()

void libMesh::System::zero_variable ( NumericVector< Number > &  v,
unsigned int  var_num 
) const
inherited

Zeroes all dofs in v that correspond to variable number var_num.

Definition at line 1450 of file system.C.

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

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

Member Data Documentation

◆ _abs_training_tolerance

Real libMesh::RBEIMConstruction::_abs_training_tolerance
privateinherited

◆ _active

bool libMesh::System::_active
privateinherited

Flag stating if the system is active or not.

Definition at line 2252 of file system.h.

Referenced by libMesh::System::activate(), libMesh::System::active(), and libMesh::System::deactivate().

◆ _additional_data_written

unsigned int libMesh::System::_additional_data_written
privateinherited

This flag is used only when reading in a system from file.

Based on the system header, it keeps track of how many additional vectors were actually written for this file.

Definition at line 2313 of file system.h.

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

◆ _assemble_system_function

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

Function that assembles the system.

Definition at line 2176 of file system.h.

◆ _assemble_system_object

Assembly* libMesh::System::_assemble_system_object
privateinherited

Object that assembles the system.

Definition at line 2182 of file system.h.

◆ _basic_system_only

bool libMesh::System::_basic_system_only
privateinherited

Holds true if the components of more advanced system types (e.g.

system matrices) should not be initialized.

Definition at line 2300 of file system.h.

Referenced by libMesh::System::init_data(), libMesh::System::reinit(), libMesh::System::reinit_mesh(), and libMesh::System::set_basic_system_only().

◆ _communicator

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

◆ _component_scaling_in_training_set

std::vector<Real> libMesh::RBEIMConstruction::_component_scaling_in_training_set
privateinherited

Keep track of a scaling factor for each component of the parametrized functions in the training set which "scales up" each component to have a similar magnitude as the largest component encountered in the training set.

This can give more uniform scaling across all components and is helpful in cases where components have widely varying magnitudes.

Definition at line 570 of file rb_eim_construction.h.

Referenced by libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::get_max_abs_value(), libMesh::RBEIMConstruction::get_node_max_abs_value(), libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set(), libMesh::RBEIMConstruction::inner_product(), libMesh::RBEIMConstruction::node_inner_product(), and libMesh::RBEIMConstruction::side_inner_product().

◆ _constrain_system_function

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

Function to impose constraints.

Definition at line 2187 of file system.h.

◆ _constrain_system_object

Constraint* libMesh::System::_constrain_system_object
privateinherited

Object that constrains the system.

Definition at line 2193 of file system.h.

◆ _counts [1/2]

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

Actually holds the data.

Definition at line 124 of file reference_counter.h.

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

◆ _counts [2/2]

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

Actually holds the data.

Definition at line 124 of file reference_counter.h.

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

◆ _discrete_parameter_values

std::map<std::string, std::vector<Real> > libMesh::RBParametrized::_discrete_parameter_values
privateinherited

Map that defines the allowable values of any discrete parameters.

Definition at line 250 of file rb_parametrized.h.

Referenced by libMesh::RBParametrized::get_discrete_parameter_values(), libMesh::RBParametrized::initialize_parameters(), and libMesh::RBParametrized::is_discrete_parameter().

◆ _dof_map

std::unique_ptr<DofMap> libMesh::System::_dof_map
privateinherited

◆ _eim_projection_matrix

DenseMatrix<Number> libMesh::RBEIMConstruction::_eim_projection_matrix
privateinherited

◆ _enable_print_counter [1/2]

bool libMesh::ReferenceCounter::_enable_print_counter = true
staticprotectedinherited

Flag to control whether reference count information is printed when print_info is called.

Definition at line 143 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().

◆ _enable_print_counter [2/2]

bool libMesh::ReferenceCounter::_enable_print_counter = true
staticprotectedinherited

Flag to control whether reference count information is printed when print_info is called.

Definition at line 143 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().

◆ _equation_systems

EquationSystems& libMesh::System::_equation_systems
privateinherited

Constant reference to the EquationSystems object used for the simulation.

Definition at line 2231 of file system.h.

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

◆ _first_local_index

numeric_index_type libMesh::RBConstructionBase< System >::_first_local_index
privateinherited

The first sample-vector index from the global vector which is stored in the _training_parameters on this processor.

_n_local_training_samples is equivalent to the .size() of any vector in _training_parameters.

Definition at line 313 of file rb_construction_base.h.

◆ _hide_output

bool libMesh::System::_hide_output
privateinherited

Are we allowed to write this system to file? If _hide_output is true, then EquationSystems::write will ignore this system.

Definition at line 2338 of file system.h.

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

◆ _init_system_function

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

Function that initializes the system.

Definition at line 2165 of file system.h.

◆ _init_system_object

Initialization* libMesh::System::_init_system_object
privateinherited

Object that initializes the system.

Definition at line 2171 of file system.h.

◆ _is_initialized

bool libMesh::System::_is_initialized
privateinherited

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

Definition at line 2306 of file system.h.

Referenced by libMesh::System::add_vector(), libMesh::System::clear(), libMesh::System::compare(), libMesh::System::init_data(), and libMesh::System::is_initialized().

◆ _local_node_boundary_ids

std::unordered_map<dof_id_type, boundary_id_type > libMesh::RBEIMConstruction::_local_node_boundary_ids
privateinherited

◆ _local_node_locations

std::unordered_map<dof_id_type, Point > libMesh::RBEIMConstruction::_local_node_locations
privateinherited

◆ _local_node_parametrized_functions_for_training

std::vector<NodeDataMap> libMesh::RBEIMConstruction::_local_node_parametrized_functions_for_training
privateinherited

◆ _local_parametrized_functions_for_training

std::vector<QpDataMap> libMesh::RBEIMConstruction::_local_parametrized_functions_for_training
privateinherited

The parametrized functions that are used for training.

We pre-compute and store all of these functions, rather than recompute them at each iteration of the training.

We store values at quadrature points on elements that are local to this processor. The indexing is as follows: basis function index --> element ID --> variable --> quadrature point --> value We use a map to index the element ID, since the IDs on this processor in generally will not start at zero.

Definition at line 536 of file rb_eim_construction.h.

Referenced by libMesh::RBEIMConstruction::apply_normalization_to_solution_snapshots(), libMesh::RBEIMConstruction::clear(), libMesh::RBEIMConstruction::compute_max_eim_error(), libMesh::RBEIMConstruction::enrich_eim_approximation(), libMesh::RBEIMConstruction::get_n_parametrized_functions_for_training(), libMesh::RBEIMConstruction::get_parametrized_function_from_training_set(), libMesh::RBEIMConstruction::get_random_point_from_training_sample(), libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set(), libMesh::RBEIMConstruction::store_eim_solutions_for_training_set(), and libMesh::RBEIMConstruction::train_eim_approximation_with_POD().

◆ _local_quad_point_JxW

std::unordered_map<dof_id_type, std::vector<Real> > libMesh::RBEIMConstruction::_local_quad_point_JxW
privateinherited

◆ _local_quad_point_locations

std::unordered_map<dof_id_type, std::vector<Point> > libMesh::RBEIMConstruction::_local_quad_point_locations
privateinherited

The quadrature point locations, quadrature point weights (JxW), and subdomain IDs on every element local to this processor.

The indexing is as follows: element ID --> quadrature point --> xyz element ID --> quadrature point --> JxW element ID --> subdomain_id We use a map to index the element ID, since the IDs on this processor in generally will not start at zero.

Definition at line 583 of file rb_eim_construction.h.

Referenced by libMesh::RBEIMConstruction::clear(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set(), and libMesh::RBEIMConstruction::initialize_qp_data().

◆ _local_quad_point_locations_perturbations

std::unordered_map<dof_id_type, std::vector<std::vector<Point> > > libMesh::RBEIMConstruction::_local_quad_point_locations_perturbations
privateinherited

EIM approximations often arise when applying a geometric mapping to a Reduced Basis formulation.

In this context, we often need to approximate derivates of the mapping function via EIM. In order to enable this, we also optionally store perturbations about each point in _local_quad_point_locations to enable finite difference approximation to the mapping function derivatives.

Definition at line 594 of file rb_eim_construction.h.

Referenced by libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set(), and libMesh::RBEIMConstruction::initialize_qp_data().

◆ _local_quad_point_subdomain_ids

std::unordered_map<dof_id_type, subdomain_id_type > libMesh::RBEIMConstruction::_local_quad_point_subdomain_ids
privateinherited

◆ _local_side_parametrized_functions_for_training

std::vector<SideQpDataMap> libMesh::RBEIMConstruction::_local_side_parametrized_functions_for_training
privateinherited

◆ _local_side_quad_point_boundary_ids

std::map<std::pair<dof_id_type,unsigned int>, boundary_id_type > libMesh::RBEIMConstruction::_local_side_quad_point_boundary_ids
privateinherited

◆ _local_side_quad_point_JxW

std::map<std::pair<dof_id_type,unsigned int>, std::vector<Real> > libMesh::RBEIMConstruction::_local_side_quad_point_JxW
privateinherited

◆ _local_side_quad_point_locations

std::map<std::pair<dof_id_type,unsigned int>, std::vector<Point> > libMesh::RBEIMConstruction::_local_side_quad_point_locations
privateinherited

◆ _local_side_quad_point_locations_perturbations

std::map<std::pair<dof_id_type,unsigned int>, std::vector<std::vector<Point> > > libMesh::RBEIMConstruction::_local_side_quad_point_locations_perturbations
privateinherited

◆ _local_side_quad_point_side_types

std::map<std::pair<dof_id_type,unsigned int>, unsigned int > libMesh::RBEIMConstruction::_local_side_quad_point_side_types
privateinherited

For side data, we also store "side type" info.

This is used to distinguish between data that is stored on a "shellface" vs. a "standard side". The convention we use here is: 0 --> standard side 1 --> shellface

Definition at line 618 of file rb_eim_construction.h.

Referenced by libMesh::RBEIMConstruction::clear(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set(), and libMesh::RBEIMConstruction::initialize_qp_data().

◆ _local_side_quad_point_subdomain_ids

std::map<std::pair<dof_id_type,unsigned int>, subdomain_id_type > libMesh::RBEIMConstruction::_local_side_quad_point_subdomain_ids
privateinherited

◆ _matrices

std::map<std::string, std::unique_ptr<SparseMatrix<Number> >, std::less<> > libMesh::System::_matrices
privateinherited

◆ _matrices_initialized

bool libMesh::System::_matrices_initialized
privateinherited

false when additional matrices being added require initialization, true otherwise.

Definition at line 2287 of file system.h.

Referenced by libMesh::System::can_add_matrices(), libMesh::System::clear(), libMesh::System::init_matrices(), libMesh::System::late_matrix_init(), and libMesh::System::prefer_hash_table_matrix_assembly().

◆ _matrix_types

std::map<std::string, ParallelType, std::less<> > libMesh::System::_matrix_types
privateinherited

Holds the types of the matrices.

Definition at line 2282 of file system.h.

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

◆ _max_abs_value_in_training_set

Real libMesh::RBEIMConstruction::_max_abs_value_in_training_set
privateinherited

◆ _max_abs_value_in_training_set_index

unsigned int libMesh::RBEIMConstruction::_max_abs_value_in_training_set_index
privateinherited

◆ _mesh

MeshBase& libMesh::System::_mesh
privateinherited

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

Definition at line 2237 of file system.h.

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

◆ _mutex [1/2]

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 137 of file reference_counter.h.

◆ _mutex [2/2]

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 137 of file reference_counter.h.

◆ _n_global_training_samples

numeric_index_type libMesh::RBConstructionBase< System >::_n_global_training_samples
privateinherited

Definition at line 315 of file rb_construction_base.h.

◆ _n_local_training_samples

numeric_index_type libMesh::RBConstructionBase< System >::_n_local_training_samples
privateinherited

Definition at line 314 of file rb_construction_base.h.

◆ _n_objects [1/2]

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

◆ _n_objects [2/2]

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

◆ _Nmax

unsigned int libMesh::RBEIMConstruction::_Nmax
privateinherited

◆ _Nmax_from_n_snapshots_increment

int libMesh::RBEIMConstruction::_Nmax_from_n_snapshots_increment
privateinherited

◆ _normalize_solution_snapshots

bool libMesh::RBConstructionBase< System >::_normalize_solution_snapshots
protectedinherited

Set this boolean to true if we want to normalize solution snapshots used in training to have norm of 1.

This is relevant if snapshots have differing magnitudes and we want to approximate them all with equal accuracy.

Definition at line 281 of file rb_construction_base.h.

◆ _prefer_hash_table_matrix_assembly

bool libMesh::System::_prefer_hash_table_matrix_assembly
privateinherited

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

Definition at line 2348 of file system.h.

Referenced by libMesh::System::init_matrices(), and libMesh::System::prefer_hash_table_matrix_assembly().

◆ _prefix_with_name

bool libMesh::System::_prefix_with_name
privateinherited

Whether we are name prefixing solver options.

Definition at line 2358 of file system.h.

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

◆ _qoi

std::vector<Number> libMesh::System::_qoi
privateinherited

Values of the quantities of interest.

This vector needs to be both resized and filled by the user before any quantity of interest assembly is done and before any sensitivities are calculated. Use the get_qoi_values() accessor to get these values.

Definition at line 2367 of file system.h.

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

◆ _qoi_error_estimates

std::vector<Number> libMesh::System::_qoi_error_estimates
privateinherited

Vector to hold error estimates for qois, either from a steady state calculation, or from a single unsteady solver timestep.

Used by the library after resizing to match the size of the qoi vector. User code can use this for accumulating error estimates for example. Use the set_qoi_error_estimate()/get_qoi_error_estimate_value() accessors to set/get these values.

Definition at line 2377 of file system.h.

◆ _qoi_evaluate_derivative_function

void(* libMesh::System::_qoi_evaluate_derivative_function) (EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
privateinherited

Function to evaluate quantity of interest derivative.

Definition at line 2210 of file system.h.

◆ _qoi_evaluate_derivative_object

QOIDerivative* libMesh::System::_qoi_evaluate_derivative_object
privateinherited

Object to compute derivatives of quantities of interest.

Definition at line 2219 of file system.h.

◆ _qoi_evaluate_function

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

Function to evaluate quantity of interest.

Definition at line 2198 of file system.h.

◆ _qoi_evaluate_object

QOI* libMesh::System::_qoi_evaluate_object
privateinherited

Object to compute quantities of interest.

Definition at line 2205 of file system.h.

◆ _rb_eim_assembly_objects

std::vector<std::unique_ptr<ElemAssembly> > libMesh::RBEIMConstruction::_rb_eim_assembly_objects
privateinherited

The vector of assembly objects that are created to point to this RBEIMConstruction.

Definition at line 523 of file rb_eim_construction.h.

Referenced by libMesh::RBEIMConstruction::clear(), libMesh::RBEIMConstruction::get_eim_assembly_objects(), and libMesh::RBEIMConstruction::initialize_eim_assembly_objects().

◆ _rb_eim_eval

RBEIMEvaluation* libMesh::RBEIMConstruction::_rb_eim_eval
privateinherited

The RBEIMEvaluation object that we use to perform the EIM training.

Definition at line 517 of file rb_eim_construction.h.

Referenced by libMesh::RBEIMConstruction::get_rb_eim_evaluation(), libMesh::RBEIMConstruction::get_rb_eim_evaluation(), and libMesh::RBEIMConstruction::set_rb_eim_evaluation().

◆ _rel_training_tolerance

Real libMesh::RBEIMConstruction::_rel_training_tolerance
privateinherited

◆ _require_sparsity_pattern

bool libMesh::System::_require_sparsity_pattern
privateinherited

Whether any of our matrices require an initial sparsity pattern computation in order to determine preallocation.

Definition at line 2353 of file system.h.

Referenced by libMesh::System::init_matrices(), and libMesh::System::reinit().

◆ _set_Nmax_from_n_snapshots

bool libMesh::RBEIMConstruction::_set_Nmax_from_n_snapshots
privateinherited

If _set_Nmax_from_n_snapshots=true, then we overrule Nmax to be Nmax += _Nmax_from_n_snapshots_increment.

Note that the "increment can be positive or negative. Typically we would want to set the increment to be negative or 0 to limit Nmax based on the number of available snapshots, but in some rare cases it could make sense to set it to a positive value, e.g. if we are appending to a basis that has already been generated via a previous training.

Definition at line 499 of file rb_eim_construction.h.

Referenced by libMesh::RBEIMConstruction::disable_set_Nmax_from_n_snapshots(), libMesh::RBEIMConstruction::enable_set_Nmax_from_n_snapshots(), libMesh::RBEIMConstruction::print_info(), and libMesh::RBEIMConstruction::train_eim_approximation_with_POD().

◆ _solution_projection

bool libMesh::System::_solution_projection
privateinherited

Holds true if the solution vector should be projected onto a changed grid, false if it should be zeroed.

This is true by default.

Definition at line 2294 of file system.h.

Referenced by libMesh::System::project_solution_on_reinit(), and libMesh::System::restrict_vectors().

◆ _sys_name

const std::string libMesh::System::_sys_name
privateinherited

A name associated with this system.

Definition at line 2242 of file system.h.

Referenced by libMesh::System::clear(), libMesh::System::compare(), and libMesh::System::name().

◆ _sys_number

const unsigned int libMesh::System::_sys_number
privateinherited

The number associated with this system.

Definition at line 2247 of file system.h.

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

◆ _training_parameters

std::map<std::string, std::vector<RBParameter> > libMesh::RBConstructionBase< System >::_training_parameters
privateinherited

The training samples for each parameter.

When serial_training_set is true, the map contains all samples of all parameters. Otherwise, the sample vectors will only contain the values for the local samples as defined by _first_local_index and _n_local_training_samples. Mapped from parameter_name -> sample_vector -> value_vector.

Definition at line 306 of file rb_construction_base.h.

◆ _training_parameters_initialized

bool libMesh::RBConstructionBase< System >::_training_parameters_initialized
privateinherited

Boolean flag to indicate whether or not the parameter ranges have been initialized.

Definition at line 297 of file rb_construction_base.h.

◆ _training_parameters_random_seed

int libMesh::RBConstructionBase< System >::_training_parameters_random_seed
privateinherited

If < 0, use std::time() * processor_id() to seed the random number generator for the training parameters (default).

If >= 0, use the provided value * processor_id() as the random number generator seed.

Definition at line 323 of file rb_construction_base.h.

◆ _vector_is_adjoint

std::map<std::string, int, std::less<> > libMesh::System::_vector_is_adjoint
privateinherited

Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs, -1 if primal.

Definition at line 2272 of file system.h.

Referenced by libMesh::System::add_vector(), libMesh::System::clear(), libMesh::System::remove_vector(), libMesh::System::set_vector_as_adjoint(), and libMesh::System::vector_is_adjoint().

◆ _vector_projections

std::map<std::string, bool, std::less<> > libMesh::System::_vector_projections
privateinherited

Holds true if a vector by that name should be projected onto a changed grid, false if it should be zeroed.

Definition at line 2266 of file system.h.

Referenced by libMesh::System::add_vector(), libMesh::System::clear(), libMesh::System::remove_vector(), libMesh::System::restrict_vectors(), libMesh::System::set_vector_preservation(), libMesh::System::vector_preservation(), and libMesh::System::write_header().

◆ _vectors

std::map<std::string, std::unique_ptr<NumericVector<Number> >, std::less<> > libMesh::System::_vectors
privateinherited

◆ _written_var_indices

std::vector<unsigned int> libMesh::System::_written_var_indices
privateinherited

This vector is used only when reading in a system from file.

Based on the system header, it keeps track of any index remapping between variable names in the data file and variable names in the already-constructed system. I.e. if we have a system with variables "A1", "A2", "B1", and "B2", but we read in a data file with only "A1" and "B1" defined, then we don't want to try and read in A2 or B2, and we don't want to assign A1 and B1 values to different dof indices.

Definition at line 2325 of file system.h.

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

◆ adjoint_already_solved

bool libMesh::System::adjoint_already_solved
privateinherited

Has the adjoint problem already been solved? If the user sets adjoint_already_solved to true, we won't waste time solving it again.

Definition at line 2332 of file system.h.

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

◆ assemble_before_solve

bool libMesh::System::assemble_before_solve
inherited

Flag which tells the system to whether or not to call the user assembly function during each call to solve().

By default, every call to solve() begins with a call to the user assemble, so this flag is true. (For explicit systems, "solving" the system occurs during the assembly step, so this flag is always true for explicit systems.)

You will only want to set this to false if you need direct control over when the system is assembled, and are willing to track the state of its assembly yourself. An example of such a case is an implicit system with multiple right hand sides. In this instance, a single assembly would likely be followed with multiple calls to solve.

The frequency system and Newmark system have their own versions of this flag, called _finished_assemble, which might be able to be replaced with this more general concept.

Definition at line 1609 of file system.h.

Referenced by libMesh::ImplicitSystem::adjoint_solve(), libMesh::ClawSystem::ClawSystem(), libMesh::System::disable_cache(), libMesh::ImplicitSystem::disable_cache(), main(), libMesh::RBConstruction::RBConstruction(), libMesh::RBSCMConstruction::RBSCMConstruction(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::CondensedEigenSystem::solve(), libMesh::EigenSystem::solve(), and libMesh::LinearImplicitSystem::solve().

◆ best_fit_type_flag

BEST_FIT_TYPE libMesh::RBEIMConstruction::best_fit_type_flag
inherited

Enum that indicates which type of "best fit" algorithm we should use.

a) projection: Find the best fit in the inner product b) eim: Use empirical interpolation to find a "best fit"

Definition at line 302 of file rb_eim_construction.h.

Referenced by libMesh::RBEIMConstruction::compute_max_eim_error(), libMesh::RBEIMConstruction::print_info(), libMesh::RBEIMConstruction::set_best_fit_type_flag(), libMesh::RBEIMConstruction::train_eim_approximation(), and libMesh::RBEIMConstruction::train_eim_approximation_with_greedy().

◆ current_local_solution

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

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

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

Definition at line 1667 of file system.h.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::UniformRefinementEstimator::_estimate_error(), alternative_fe_assembly(), libMesh::NonlinearImplicitSystem::assembly(), libMesh::VariationalSmootherSystem::assembly(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::System::clear(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::System::current_solution(), DMlibMeshFunction(), DMlibMeshJacobian(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), fe_assembly(), libMesh::PetscNonlinearSolver< Number >::force_new_preconditioner(), libMesh::StaticCondensation::init(), libMesh::System::init_data(), libMesh::FEMContext::pre_fe_reinit(), libMesh::System::re_update(), libMesh::System::reinit(), libMesh::System::restrict_vectors(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), SolidSystem::save_initial_mesh(), libMesh::RBConstruction::set_context_solution_vec(), setup(), MeshFunctionTest::test_bad_gradient_var_with_out_of_mesh_value(), MeshFunctionTest::test_bad_hessian_var_with_out_of_mesh_value(), MeshFunctionTest::test_subdomain_id_sets(), MeshInputTest::testCopyElementVectorImpl(), FETest< order, family, elem_type, CaseName >::testGradU(), FETest< order, family, elem_type, CaseName >::testGradUComp(), FETest< order, family, elem_type, CaseName >::testHessU(), FETest< order, family, elem_type, CaseName >::testHessUComp(), FETest< order, family, elem_type, CaseName >::testU(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::TransientRBConstruction::truth_solve(), libMesh::System::update(), libMesh::Nemesis_IO_Helper::write_element_values(), and libMesh::Nemesis_IO_Helper::write_nodal_solution().

◆ extra_quadrature_order

int libMesh::System::extra_quadrature_order
inherited

A member int that can be employed to indicate increased or reduced quadrature order.

Note
For FEMSystem users, by default, when calling the user-defined residual functions, the FEMSystem will first set up an appropriate FEType::default_quadrature_rule() object for performing the integration. This rule will integrate elements of order up to 2*p+1 exactly (where p is the sum of the base FEType and local p refinement levels), but if additional (or reduced) quadrature accuracy is desired then this extra_quadrature_order (default 0) will be added.

Definition at line 1640 of file system.h.

Referenced by libMesh::JumpErrorEstimator::estimate_error(), CurlCurlSystem::init_data(), and set_system_parameters().

◆ inner_product_storage_vector

std::unique_ptr<NumericVector<Number> > libMesh::RBConstructionBase< System >::inner_product_storage_vector
protectedinherited

We keep an extra temporary vector that is useful for performing inner products (avoids unnecessary memory allocation/deallocation).

Definition at line 288 of file rb_construction_base.h.

◆ parameters

Parameters libMesh::System::parameters
inherited

◆ parameters_initialized

bool libMesh::RBParametrized::parameters_initialized
privateinherited

◆ parameters_max

RBParameters libMesh::RBParametrized::parameters_max
privateinherited

◆ parameters_min

RBParameters libMesh::RBParametrized::parameters_min
privateinherited

◆ project_with_constraints

bool libMesh::System::project_with_constraints
privateinherited

Do we want to apply constraints while projecting vectors ?

Definition at line 2343 of file system.h.

Referenced by libMesh::System::get_project_with_constraints(), and libMesh::System::set_project_with_constraints().

◆ quiet_mode

bool libMesh::RBConstructionBase< System >::quiet_mode
protectedinherited

Flag to indicate whether we print out extra information during the Offline stage.

Definition at line 265 of file rb_construction_base.h.

◆ serial_training_set

bool libMesh::RBConstructionBase< System >::serial_training_set
protectedinherited

This boolean flag indicates whether or not the training set should be the same on all processors.

By default it is false, but in the case of the Empirical Interpolation Method (RBEIMConstruction), for example, we need the training set to be identical on all processors.

Definition at line 273 of file rb_construction_base.h.

◆ solution

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

Data structure to hold solution values.

Definition at line 1655 of file system.h.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::NewmarkSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::ContinuationSystem::apply_predictor(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::FEMSystem::assembly(), libMesh::LinearImplicitSystem::assembly(), libMesh::VariationalSmootherSystem::assembly(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::RBConstruction::check_if_zero_truth_solve(), libMesh::System::clear(), libMesh::System::compare(), compute_enriched_soln(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::NewmarkSolver::compute_initial_accel(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), LinearElasticity::compute_stresses(), LargeDeformationElasticity::compute_stresses(), LinearElasticityWithContact::compute_stresses(), compute_stresses(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ContinuationSystem::continuation_solve(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_elemental_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::Nemesis_IO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), create_wrapped_function(), DMCreateGlobalVector_libMesh(), DMlibMeshFunction(), DMlibMeshJacobian(), libMesh::UnsteadySolver::du(), libMesh::RBConstruction::enrich_RB_space(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::SmoothnessEstimator::estimate_smoothness(), libMesh::RBSCMConstruction::evaluate_stability_constant(), libMesh::EigenSystem::get_eigenpair(), libMesh::CondensedEigenSystem::get_eigenpair(), LinearElasticityWithContact::get_least_and_max_gap_function(), libMesh::System::init_data(), libMesh::VariationalSmootherSystem::init_data(), libMesh::ContinuationSystem::initialize_tangent(), libMesh::TransientRBConstruction::initialize_truth(), libMesh::RBConstruction::load_basis_function(), libMesh::RBConstruction::load_rb_solution(), libMesh::TransientRBConstruction::load_rb_solution(), main(), libMesh::DofMap::max_constraint_error(), libMesh::FEMSystem::mesh_position_get(), libMesh::ErrorVector::plot_error(), libMesh::RBConstruction::print_basis_function_orthogonality(), libMesh::InterMeshProjection::project_system_vectors(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), libMesh::System::re_update(), libMesh::System::read_parallel_data(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::System::read_serialized_data(), MeshFunctionTest::read_variable_info_from_output_data(), libMesh::System::reinit(), libMesh::System::restrict_vectors(), libMesh::MemoryHistoryData::retrieve_vectors(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), libMesh::ContinuationSystem::save_current_solution(), libMesh::TransientRBConstruction::set_error_temporal_data(), ParsedFEMFunctionTest::setUp(), setup(), WriteVecAndScalar::setupTests(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::TwostepTimeSolver::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::NonlinearImplicitSystem::solve(), libMesh::FrequencySystem::solve(), libMesh::ClawSystem::solve_conservation_law(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), libMesh::ContinuationSystem::solve_tangent(), libMesh::MemoryHistoryData::store_vectors(), ConstraintOperatorTest::test1DCoarseningOperator(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), ProjectSolutionTest::test_partial_project_solution(), SystemsTest::testBoundaryProjectCube(), ConstraintOperatorTest::testCoreform(), SystemsTest::testDofCouplingWithVarGroups(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), SystemsTest::testPostInitAddVector(), SystemsTest::testProjectCubeWithMeshFunction(), MeshInputTest::testProjectionRegression(), SystemsTest::testProjectScalarCoarsening(), WriteVecAndScalar::testSolution(), libMesh::RBConstruction::train_reduced_basis_with_POD(), libMesh::DirectSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::BoundaryVolumeSolutionTransfer::transfer_volume_boundary(), libMesh::RBConstruction::truth_solve(), libMesh::TransientRBConstruction::truth_solve(), libMesh::System::update(), update_current_local_solution(), libMesh::System::update_global_solution(), libMesh::System::update_global_solution(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::ContinuationSystem::update_solution(), libMesh::NewmarkSystem::update_u_v_a(), libMesh::DTKAdapter::update_variable_values(), libMesh::System::write_parallel_data(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::TransientRBConstruction::write_riesz_representors_to_files(), and libMesh::System::write_serialized_data().

◆ time

Real libMesh::System::time
inherited

For time-dependent problems, this is the time t at the beginning of the current timestep.

Note
For DifferentiableSystem users: do not access this time during an assembly! Use the DiffContext::time value instead to get correct results.

Definition at line 1677 of file system.h.

Referenced by libMesh::AdaptiveTimeSolver::adjoint_advance_timestep(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::TwostepTimeSolver::adjoint_solve(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubProjector::construct_projection(), HeatSystem::element_qoi(), fill_dirichlet_bc(), libMesh::ExactErrorEstimator::find_squared_element_error(), initialize(), libMesh::Euler2Solver::integrate_adjoint_refinement_error_estimate(), libMesh::EulerSolver::integrate_adjoint_refinement_error_estimate(), libMesh::UnsteadySolver::integrate_adjoint_sensitivity(), libMesh::Euler2Solver::integrate_qoi_timestep(), libMesh::EulerSolver::integrate_qoi_timestep(), main(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectInteriors::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectEdges::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectSides::operator()(), libMesh::System::reinit_constraints(), libMesh::UnsteadySolver::retrieve_timestep(), and libMesh::TwostepTimeSolver::solve().

◆ use_fixed_solution

bool libMesh::System::use_fixed_solution
inherited

A boolean to be set to true by systems using elem_fixed_solution, for optional use by e.g.

stabilized methods. False by default.

Note
For FEMSystem users, if this variable is set to true, it must be before init_data() is called.

Definition at line 1625 of file system.h.

Referenced by libMesh::NewmarkSolver::_general_residual(), libMesh::Euler2Solver::_general_residual(), libMesh::EulerSolver::_general_residual(), libMesh::SteadySolver::_general_residual(), libMesh::DifferentiableSystem::clear(), libMesh::DiffContext::DiffContext(), and libMesh::FEMContext::pre_fe_reinit().

◆ verbose_mode

bool libMesh::RBParametrized::verbose_mode
inherited

Public boolean to toggle verbose mode.

Definition at line 181 of file rb_parametrized.h.

Referenced by libMesh::RBParametrized::check_if_valid_params().


The documentation for this class was generated from the following files: