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

This class enables evaluation of an Empirical Interpolation Method (EIM) approximation. More...

#include <rb_eim_evaluation.h>

Inheritance diagram for libMesh::RBEIMEvaluation:
[legend]

Public Types

enum  EimErrorIndicatorNormalization { RESIDUAL_SUM , RESIDUAL_RHS , MAX_RHS }
 Here we store an enum that defines the type of EIM error indicator normalization that we use in get_eim_error_indicator(). More...
 
typedef std::map< dof_id_type, std::vector< std::vector< Number > > > QpDataMap
 Type of the data structure used to map from (elem id) -> [n_vars][n_qp] data.
 
typedef std::map< std::pair< dof_id_type, unsigned int >, std::vector< std::vector< Number > > > SideQpDataMap
 Type of the data structure used to map from (elem id, side index) -> [n_vars][n_qp] data.
 
typedef std::map< dof_id_type, std::vector< Number > > NodeDataMap
 Type of the data structure used to map from (node id) -> [n_vars] data.
 

Public Member Functions

 RBEIMEvaluation (const Parallel::Communicator &comm)
 Constructor.
 
 RBEIMEvaluation (RBEIMEvaluation &&)=default
 Special functions.
 
 RBEIMEvaluation (const RBEIMEvaluation &)=delete
 
RBEIMEvaluationoperator= (const RBEIMEvaluation &)=delete
 
RBEIMEvaluationoperator= (RBEIMEvaluation &&)=default
 
virtual ~RBEIMEvaluation ()
 
virtual void clear () override
 Clear this object.
 
void resize_data_structures (const unsigned int Nmax)
 Resize the data structures for storing data associated with this object.
 
void set_parametrized_function (std::unique_ptr< RBParametrizedFunction > pf)
 Set the parametrized function that we will approximate using the Empirical Interpolation Method.
 
RBParametrizedFunctionget_parametrized_function ()
 Get a reference to the parametrized function.
 
const RBParametrizedFunctionget_parametrized_function () const
 Get a const reference to the parametrized function.
 
DenseVector< Numberrb_eim_solve (DenseVector< Number > &EIM_rhs)
 Calculate the EIM approximation for the given right-hand side vector EIM_rhs.
 
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 initialize_interpolation_points_spatial_indices ()
 Initialize _interpolation_points_spatial_indices.
 
void initialize_param_fn_spatial_indices ()
 The Online counterpart of initialize_interpolation_points_spatial_indices().
 
unsigned int get_n_basis_functions () const
 Return the current number of EIM basis functions.
 
unsigned int get_n_interpolation_points () const
 Return the number of interpolation points.
 
unsigned int get_n_elems () const
 Return the number of unique elements containing interpolation points.
 
unsigned int get_n_properties () const
 Return the number of properties stored in the rb_property_map.
 
void set_n_basis_functions (unsigned int n_bfs)
 Set the number of basis functions.
 
void decrement_vector (QpDataMap &v, const DenseVector< Number > &coeffs)
 Subtract coeffs[i]*basis_function[i] from v.
 
void side_decrement_vector (SideQpDataMap &v, const DenseVector< Number > &coeffs)
 Same as decrement_vector() except for Side data.
 
void node_decrement_vector (NodeDataMap &v, const DenseVector< Number > &coeffs)
 Same as decrement_vector() except for node data.
 
void initialize_eim_theta_objects ()
 Build a vector of RBTheta objects that accesses the components of the RB_solution member variable of this RBEvaluation.
 
std::vector< std::unique_ptr< RBTheta > > & get_eim_theta_objects ()
 
virtual std::unique_ptr< RBThetabuild_eim_theta (unsigned int index)
 Build a theta object corresponding to EIM index index.
 
void get_eim_basis_function_values_at_qps (unsigned int basis_function_index, dof_id_type elem_id, unsigned int var, std::vector< Number > &values) const
 Fill up values with the basis function values for basis function basis_function_index and variable var, at all quadrature points on element elem_id.
 
void get_eim_basis_function_side_values_at_qps (unsigned int basis_function_index, dof_id_type elem_id, unsigned int side_index, unsigned int var, std::vector< Number > &values) const
 Same as get_eim_basis_function_values_at_qps() except for side data.
 
Number get_eim_basis_function_node_local_value (unsigned int basis_function_index, dof_id_type node_id, unsigned int var) const
 Same as get_eim_basis_function_values_at_qps() except for node data.
 
Number get_eim_basis_function_value (unsigned int basis_function_index, dof_id_type elem_id, unsigned int comp, unsigned int qp) const
 Same as above, except that we just return the value at the qp^th quadrature point.
 
Number get_eim_basis_function_side_value (unsigned int basis_function_index, dof_id_type elem_id, unsigned int side_index, unsigned int comp, unsigned int qp) const
 Same as get_eim_basis_function_value() except for side data.
 
Number get_eim_basis_function_node_value (unsigned int basis_function_index, dof_id_type node_id, unsigned int var) const
 Same as get_eim_basis_function_value() except for node data.
 
const QpDataMapget_basis_function (unsigned int i) const
 Get a reference to the i^th basis function.
 
const SideQpDataMapget_side_basis_function (unsigned int i) const
 Get a reference to the i^th side basis function.
 
const NodeDataMapget_node_basis_function (unsigned int i) const
 Get a reference to the i^th node basis function.
 
void set_rb_eim_solutions (const std::vector< DenseVector< Number > > &rb_eim_solutions)
 Set _rb_eim_solutions.
 
const std::vector< DenseVector< Number > > & get_rb_eim_solutions () const
 Return the EIM solution coefficients from the most recent call to rb_eim_solves().
 
std::vector< Numberget_rb_eim_solutions_entries (unsigned int index) const
 Return entry index for each solution in _rb_eim_solutions.
 
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.
 
std::vector< DenseVector< Number > > & get_eim_solutions_for_training_set ()
 Return a writeable reference to the EIM solutions for the parameters in the training set.
 
const std::vector< std::pair< Real, Real > > & get_rb_eim_error_indicators () const
 Return the EIM error indicator values from the most recent call to rb_eim_solves().
 
void add_interpolation_points_xyz (Point p)
 Set the data associated with EIM interpolation points.
 
void add_interpolation_points_comp (unsigned int comp)
 
void add_interpolation_points_subdomain_id (subdomain_id_type sbd_id)
 
void add_interpolation_points_boundary_id (boundary_id_type b_id)
 
void add_interpolation_points_xyz_perturbations (const std::vector< Point > &perturbs)
 
void add_interpolation_points_elem_id (dof_id_type elem_id)
 
void add_interpolation_points_side_index (unsigned int side_index)
 
void add_interpolation_points_node_id (dof_id_type node_id)
 
void add_interpolation_points_qp (unsigned int qp)
 
void add_interpolation_points_elem_type (ElemType elem_type)
 
void add_interpolation_points_phi_i_qp (const std::vector< Real > &phi_i_qp)
 
void add_interpolation_points_JxW_all_qp (const std::vector< Real > &JxW_all_qp)
 
void add_interpolation_points_phi_i_all_qp (const std::vector< std::vector< Real > > &phi_i_all_qp)
 
void add_interpolation_points_qrule_order (Order qrule_order)
 
void add_elem_center_dxyzdxi (const Point &dxyzdxi)
 
void add_elem_center_dxyzdeta (const Point &dxyzdxi)
 
void add_interpolation_points_spatial_indices (const std::vector< unsigned int > &spatial_indices)
 
void add_elem_id_local_index_map_entry (dof_id_type elem_id, unsigned int local_index)
 
void add_rb_property_map_entry (std::string &property_name, std::set< dof_id_type > &entity_ids)
 
Point get_interpolation_points_xyz (unsigned int index) const
 Get the data associated with EIM interpolation points.
 
unsigned int get_interpolation_points_comp (unsigned int index) const
 
subdomain_id_type get_interpolation_points_subdomain_id (unsigned int index) const
 
boundary_id_type get_interpolation_points_boundary_id (unsigned int index) const
 
const std::vector< Point > & get_interpolation_points_xyz_perturbations (unsigned int index) const
 
dof_id_type get_interpolation_points_elem_id (unsigned int index) const
 
unsigned int get_interpolation_points_side_index (unsigned int index) const
 
dof_id_type get_interpolation_points_node_id (unsigned int index) const
 
unsigned int get_interpolation_points_qp (unsigned int index) const
 
ElemType get_interpolation_points_elem_type (unsigned int index) const
 
const std::vector< Real > & get_interpolation_points_phi_i_qp (unsigned int index) const
 
const std::vector< Real > & get_interpolation_points_JxW_all_qp (unsigned int index) const
 
const std::vector< std::vector< Real > > & get_interpolation_points_phi_i_all_qp (unsigned int index) const
 
Order get_interpolation_points_qrule_order (unsigned int index) const
 
const Pointget_elem_center_dxyzdxi (unsigned int index) const
 
const Pointget_elem_center_dxyzdeta (unsigned int index) const
 
const std::vector< unsigned int > & get_interpolation_points_spatial_indices (unsigned int index) const
 
const std::map< dof_id_type, unsigned int > & get_elem_id_to_local_index_map () const
 
const std::unordered_map< std::string, std::set< dof_id_type > > & get_rb_property_map () const
 
unsigned int get_n_interpolation_points_spatial_indices () const
 _interpolation_points_spatial_indices is optional data, so we need to be able to check how many _interpolation_points_spatial_indices values have actually been set since it may not match the number of interpolation points.
 
void set_interpolation_matrix_entry (unsigned int i, unsigned int j, Number value)
 Set entry of the EIM interpolation matrix.
 
const DenseMatrix< Number > & get_interpolation_matrix () const
 Get the EIM interpolation matrix.
 
void add_basis_function (const QpDataMap &bf)
 Add bf to our EIM basis.
 
void add_interpolation_data (Point p, unsigned int comp, dof_id_type elem_id, subdomain_id_type subdomain_id, unsigned int qp, const std::vector< Point > &perturbs, const std::vector< Real > &phi_i_qp, ElemType elem_type, const std::vector< Real > &JxW_all_qp, const std::vector< std::vector< Real > > &phi_i_all_qp, Order qrule_order, const Point &dxyz_dxi_elem_center, const Point &dxyz_deta_elem_center)
 Add interpolation data associated with a new basis function.
 
void add_side_basis_function (const SideQpDataMap &side_bf)
 Add side_bf to our EIM basis.
 
void add_side_interpolation_data (Point p, unsigned int comp, dof_id_type elem_id, unsigned int side_index, subdomain_id_type subdomain_id, boundary_id_type boundary_id, unsigned int qp, const std::vector< Point > &perturbs, const std::vector< Real > &phi_i_qp)
 Add interpolation data associated with a new basis function.
 
void add_node_basis_function (const NodeDataMap &node_bf)
 Add node_bf to our EIM basis.
 
void add_node_interpolation_data (Point p, unsigned int comp, dof_id_type node_id, boundary_id_type boundary_id)
 Add interpolation data associated with a new basis function.
 
void set_preserve_rb_eim_solutions (bool preserve_rb_eim_solutions)
 Set _preserve_rb_eim_solutions.
 
bool get_preserve_rb_eim_solutions () const
 Get _preserve_rb_eim_solutions.
 
void write_out_basis_functions (const std::string &directory_name="offline_data", bool write_binary_basis_functions=true)
 Write out all the basis functions to file.
 
void read_in_basis_functions (const System &sys, const std::string &directory_name="offline_data", bool read_binary_basis_functions=true)
 Read in all the basis functions from file.
 
virtual void project_qp_data_vector_onto_system (System &sys, const std::vector< Number > &bf_data, const EIMVarGroupPlottingInfo &eim_vargroup, const std::map< std::string, std::string > &extra_options)
 Project the EIM basis function data stored in bf_data onto sys.solution.
 
const std::vector< EIMVarGroupPlottingInfo > & get_eim_vars_to_project_and_write () const
 Get _eim_vars_to_project_and_write.
 
const std::set< unsigned int > & scale_components_in_enrichment () const
 Get _scale_components_in_enrichment.
 
virtual bool use_eim_error_indicator () const
 Virtual function to indicate if we use the EIM error indicator in this case.
 
void set_eim_error_indicator_active (bool is_active)
 Activate/decative the error indicator in EIM solves.
 
const DenseVector< Number > & get_error_indicator_interpolation_row () const
 Get/set _extra_points_interpolation_matrix.
 
void set_error_indicator_interpolation_row (const DenseVector< Number > &error_indicator_row)
 
std::pair< Real, Realget_eim_error_indicator (Number error_indicator_rhs, const DenseVector< Number > &eim_solution, const DenseVector< Number > &eim_rhs)
 Evaluates the EIM error indicator based on error_indicator_rhs, eim_solution, and _error_indicator_interpolation_row.
 
const VectorizedEvalInputget_vec_eval_input () const
 Get the VectorizedEvalInput data.
 
void initialize_rb_property_map ()
 Initialize the rb_property_map of RBEIMEvaluation (this) from the rb_property_map stored in RBParametrizedFunction with empty entries but identical keys.
 
std::vector< std::vector< std::vector< Number > > > get_interior_basis_functions_as_vecs ()
 Get all interior basis functions in the form of std::vectors.
 
std::map< std::string, std::size_t > get_interior_basis_function_sizes (std::vector< unsigned int > &n_qp_per_elem)
 Get data that defines the sizes of interior EIM basis functions.
 
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 RBParametersget_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 RBParametersget_parameters_min () const
 Get an RBParameters object that specifies the minimum allowable value for each parameter.
 
const RBParametersget_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.
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static void get_parametrized_function_values_at_qps (const QpDataMap &pf, dof_id_type elem_id, unsigned int comp, std::vector< Number > &values)
 Fill up values by evaluating the parametrized function pf for all quadrature points on element elem_id and component comp.
 
static void get_parametrized_function_side_values_at_qps (const SideQpDataMap &pf, dof_id_type elem_id, unsigned int side_index, unsigned int comp, std::vector< Number > &values)
 Same as get_parametrized_function_values_at_qps() except for side data.
 
static Number get_parametrized_function_node_local_value (const NodeDataMap &pf, dof_id_type node_id, unsigned int comp)
 Same as get_parametrized_function_values_at_qps() except for node data.
 
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.
 
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.
 
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.
 
static Real get_closest_value (Real value, const std::vector< Real > &list_of_values)
 
static std::string get_info ()
 Gets a string containing the reference information.
 
static void print_info (std::ostream &out_stream=libMesh::out)
 Prints the reference information, by default to libMesh::out.
 
static unsigned int n_objects ()
 Prints the number of outstanding (created, but not yet destroyed) objects.
 
static void enable_print_counter_info ()
 Methods to enable/disable the reference counter output from print_info().
 
static void disable_print_counter_info ()
 

Public Attributes

EimErrorIndicatorNormalization eim_error_indicator_normalization
 
bool limit_eim_error_indicator_to_one
 If this boolean is true then we clamp EIM error indicator values to be at most 1.
 
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.
 

Protected Member Functions

void increment_constructor_count (const std::string &name) noexcept
 Increments the construction counter.
 
void increment_destructor_count (const std::string &name) noexcept
 Increments the destruction counter.
 

Protected Attributes

std::vector< EIMVarGroupPlottingInfo_eim_vars_to_project_and_write
 This vector specifies which EIM variables we want to write to disk and/or project to nodes for plotting purposes.
 
std::set< unsigned int_scale_components_in_enrichment
 This set that specifies which EIM variables will be scaled during EIM enrichment so that their maximum value matches the maximum value across all variables.
 
const Parallel::Communicator_communicator
 

Static Protected Attributes

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

Private Member Functions

void write_out_interior_basis_functions (const std::string &directory_name, bool write_binary_basis_functions)
 Method that writes out element interior EIM basis functions.
 
void write_out_side_basis_functions (const std::string &directory_name, bool write_binary_basis_functions)
 Method that writes out element side EIM basis functions.
 
void write_out_node_basis_functions (const std::string &directory_name, bool write_binary_basis_functions)
 Method that writes out element node EIM basis functions.
 
void read_in_interior_basis_functions (const System &sys, const std::string &directory_name, bool read_binary_basis_functions)
 Method that reads in element interior EIM basis functions.
 
void read_in_side_basis_functions (const System &sys, const std::string &directory_name, bool read_binary_basis_functions)
 Method that reads in element side EIM basis functions.
 
void read_in_node_basis_functions (const System &sys, const std::string &directory_name, bool read_binary_basis_functions)
 Method that reads in element node EIM basis functions.
 
std::vector< std::vector< Number > > get_interior_basis_function_as_vec_helper (unsigned int n_vars, unsigned int n_qp_data, unsigned int bf_index)
 Helper function called by write_out_interior_basis_functions() to get basis function bf_index stored as a std::vector per variable.
 
void print_local_eim_basis_functions () const
 Print the contents of _local_eim_basis_functions to libMesh::out.
 
void gather_bfs ()
 Helper function that gathers the contents of _local_eim_basis_functions to processor 0 in preparation for printing to file.
 
void side_gather_bfs ()
 Same as gather_bfs() except for side data.
 
void node_gather_bfs ()
 Same as gather_bfs() except for node data.
 
void distribute_bfs (const System &sys)
 Helper function that distributes the entries of _local_eim_basis_functions to their respective processors after they are read in on processor 0.
 
void side_distribute_bfs (const System &sys)
 Same as distribute_bfs() except for side data.
 
void node_distribute_bfs (const System &sys)
 Same as distribute_bfs() except for node data.
 
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

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

std::vector< DenseVector< Number > > _rb_eim_solutions
 The EIM solution coefficients from the most recent call to rb_eim_solves().
 
std::vector< std::pair< Real, Real > > _rb_eim_error_indicators
 If we're using the EIM error indicator, then we store the error indicator values corresponding to _rb_eim_solutions here.
 
std::vector< DenseVector< Number > > _eim_solutions_for_training_set
 Storage for EIM solutions from the training set.
 
std::vector< RBParameters_rb_eim_solves_mus
 The parameters and the number of basis functions that were used in the most recent call to rb_eim_solves().
 
unsigned int _rb_eim_solves_N
 
DenseMatrix< Number_interpolation_matrix
 Dense matrix that stores the lower triangular interpolation matrix that can be used.
 
VectorizedEvalInput _vec_eval_input
 We store the EIM interpolation point data in this object.
 
std::vector< unsigned int_interpolation_points_comp
 In the case of a "vector-valued" EIM, this vector determines which component of the parameterized function we sample at each EIM point.
 
std::vector< std::vector< unsigned int > > _interpolation_points_spatial_indices
 Here we store the spatial indices that were initialized by initialize_spatial_indices_at_interp_pts().
 
std::unique_ptr< RBParametrizedFunction_parametrized_function
 Store the parametrized function that will be approximated by this EIM system.
 
std::vector< std::unique_ptr< RBTheta > > _rb_eim_theta_objects
 The vector of RBTheta objects that are created to point to this RBEIMEvaluation.
 
std::vector< QpDataMap_local_eim_basis_functions
 The EIM basis functions.
 
std::vector< SideQpDataMap_local_side_eim_basis_functions
 The EIM basis functions on element sides.
 
std::vector< NodeDataMap_local_node_eim_basis_functions
 The EIM basis functions on element nodes (e.g.
 
bool _preserve_rb_eim_solutions
 Boolean to indicate if we skip updating _rb_eim_solutions in rb_eim_solves().
 
bool _is_eim_error_indicator_active
 Indicate if the EIM error indicator is active in RB EIM solves.
 
DenseVector< Number_error_indicator_interpolation_row
 Here we store an extra row of the interpolation matrix which is used to compute the EIM error indicator.
 
bool parameters_initialized
 Flag indicating whether the parameters have been initialized.
 
RBParameters parameters
 Vector storing the current parameters.
 
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

This class enables evaluation of an Empirical Interpolation Method (EIM) approximation.

RBEvaluation plays an analogous role in the context of the regular reduced basis method.

Definition at line 111 of file rb_eim_evaluation.h.

Member Typedef Documentation

◆ Counts

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

Data structure to log the information.

The log is identified by the class name.

Definition at line 119 of file reference_counter.h.

◆ NodeDataMap

typedef std::map<dof_id_type, std::vector<Number> > libMesh::RBEIMEvaluation::NodeDataMap

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

Definition at line 146 of file rb_eim_evaluation.h.

◆ QpDataMap

typedef std::map<dof_id_type, std::vector<std::vector<Number> > > libMesh::RBEIMEvaluation::QpDataMap

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

Definition at line 136 of file rb_eim_evaluation.h.

◆ SideQpDataMap

typedef std::map<std::pair<dof_id_type,unsigned int>, std::vector<std::vector<Number> > > libMesh::RBEIMEvaluation::SideQpDataMap

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

Definition at line 141 of file rb_eim_evaluation.h.

Member Enumeration Documentation

◆ EimErrorIndicatorNormalization

Here we store an enum that defines the type of EIM error indicator normalization that we use in get_eim_error_indicator().

The enum is public so that it can be set in user code.

RESIDUAL_SUM: Use the sum of the terms in the EIM residual to determine the error indicator normalization. This ensures that the error indicator value will be at most 1.0, which may be a desirable property of the indicator.

RHS: Use only the right-hand side value for the EIM residual to determine the error indicator normalization.

MAX_RHS: Use the maximum value in the EIM RHS vector to determine the error indicator normalization (default). This is helpful when the values at some EIM points are much larger than others, since in this scenario we typically want to normalize the error indicator based on the largest values in order to avoid overestimating the error.

Enumerator
RESIDUAL_SUM 
RESIDUAL_RHS 
MAX_RHS 

Definition at line 715 of file rb_eim_evaluation.h.

Constructor & Destructor Documentation

◆ RBEIMEvaluation() [1/3]

RBEIMEvaluation::RBEIMEvaluation ( const Parallel::Communicator comm)

Constructor.

Definition at line 48 of file rb_eim_evaluation.C.

49:
56{
57}
ParallelObject(const Parallel::Communicator &comm_in)
Constructor.
const Parallel::Communicator & comm() const
bool _preserve_rb_eim_solutions
Boolean to indicate if we skip updating _rb_eim_solutions in rb_eim_solves().
EimErrorIndicatorNormalization eim_error_indicator_normalization
bool _is_eim_error_indicator_active
Indicate if the EIM error indicator is active in RB EIM solves.
bool limit_eim_error_indicator_to_one
If this boolean is true then we clamp EIM error indicator values to be at most 1.

◆ RBEIMEvaluation() [2/3]

libMesh::RBEIMEvaluation::RBEIMEvaluation ( RBEIMEvaluation &&  )
default

Special functions.

  • This class contains unique_ptrs, so it can't be default copy constructed/assigned.
  • The destructor is defaulted out of line.

◆ RBEIMEvaluation() [3/3]

libMesh::RBEIMEvaluation::RBEIMEvaluation ( const RBEIMEvaluation )
delete

◆ ~RBEIMEvaluation()

RBEIMEvaluation::~RBEIMEvaluation ( )
virtualdefault

Member Function Documentation

◆ add_basis_function()

void RBEIMEvaluation::add_basis_function ( const QpDataMap bf)

Add bf to our EIM basis.

Definition at line 963 of file rb_eim_evaluation.C.

965{
966 _local_eim_basis_functions.emplace_back(bf);
967}
std::vector< QpDataMap > _local_eim_basis_functions
The EIM basis functions.

References _local_eim_basis_functions.

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

◆ add_elem_center_dxyzdeta()

void RBEIMEvaluation::add_elem_center_dxyzdeta ( const Point dxyzdxi)

Definition at line 778 of file rb_eim_evaluation.C.

779{
780 _vec_eval_input.dxyzdeta_elem_center.emplace_back(dxyzdeta);
781}
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.

References _vec_eval_input, and libMesh::VectorizedEvalInput::dxyzdeta_elem_center.

Referenced by libMesh::RBDataDeserialization::load_rb_eim_evaluation_data().

◆ add_elem_center_dxyzdxi()

void RBEIMEvaluation::add_elem_center_dxyzdxi ( const Point dxyzdxi)

◆ add_elem_id_local_index_map_entry()

void RBEIMEvaluation::add_elem_id_local_index_map_entry ( dof_id_type  elem_id,
unsigned int  local_index 
)

Definition at line 793 of file rb_eim_evaluation.C.

794{
795 // Try to insert object and return an error if object already inserted as duplicated should not happen.
796 bool insert_succeed = _vec_eval_input.elem_id_to_local_index.insert({elem_id, local_index}).second;
797 libmesh_error_msg_if(!insert_succeed, "Entry already added, duplicate detected.");
798}
std::map< dof_id_type, unsigned int > elem_id_to_local_index
The following containers are indexed by element id to avoid duplicated data.

References _vec_eval_input, and libMesh::VectorizedEvalInput::elem_id_to_local_index.

Referenced by libMesh::RBDataDeserialization::load_rb_eim_evaluation_data().

◆ add_interpolation_data()

void RBEIMEvaluation::add_interpolation_data ( Point  p,
unsigned int  comp,
dof_id_type  elem_id,
subdomain_id_type  subdomain_id,
unsigned int  qp,
const std::vector< Point > &  perturbs,
const std::vector< Real > &  phi_i_qp,
ElemType  elem_type,
const std::vector< Real > &  JxW_all_qp,
const std::vector< std::vector< Real > > &  phi_i_all_qp,
Order  qrule_order,
const Point dxyz_dxi_elem_center,
const Point dxyz_deta_elem_center 
)

Add interpolation data associated with a new basis function.

Definition at line 969 of file rb_eim_evaluation.C.

983{
984 _vec_eval_input.all_xyz.emplace_back(p);
985 _interpolation_points_comp.emplace_back(comp);
986 _vec_eval_input.elem_ids.emplace_back(elem_id);
987 _vec_eval_input.sbd_ids.emplace_back(subdomain_id);
988 _vec_eval_input.qps.emplace_back(qp);
989 _vec_eval_input.all_xyz_perturb.emplace_back(perturbs);
990 _vec_eval_input.phi_i_qp.emplace_back(phi_i_qp);
991 _vec_eval_input.elem_types.emplace_back(elem_type);
992
993 // The following quantities are indexed by elem id to prevent duplicated data
994 // If an entry is already present then we should not need to add that data again as it is element
995 // based so it should be identical between 2 points if they refer to the same element id.
996 if (_vec_eval_input.elem_id_to_local_index.count(elem_id) == 0)
997 {
998 unsigned int local_index = _vec_eval_input.JxW_all_qp.size();
999 // Maybe check that getting local index from a a different source is still ok.
1000 _vec_eval_input.elem_id_to_local_index[elem_id] = local_index;
1001 _vec_eval_input.JxW_all_qp.emplace_back(JxW_all_qp);
1002 _vec_eval_input.phi_i_all_qp.emplace_back(phi_i_all_qp);
1003 _vec_eval_input.qrule_orders.emplace_back(qrule_order);
1004 _vec_eval_input.dxyzdxi_elem_center.emplace_back(dxyzdxi_elem_center);
1005 _vec_eval_input.dxyzdeta_elem_center.emplace_back(dxyzdeta_elem_center);
1006 }
1007
1008 // add_interpolation_data_to_property_map is a virtual function that aims to add only the property data
1009 // required by the corresponding rb_parametrized_function.
1010 // Right now, only elem_ids are supported but if subdomain_ids need to be stored for a property
1011 // it can be added to the list of arguments and used in the overridden subclass function, the map type
1012 // might also required an update to support various id types.
1015 elem_id);
1016}
std::vector< unsigned int > _interpolation_points_comp
In the case of a "vector-valued" EIM, this vector determines which component of the parameterized fun...
RBParametrizedFunction & get_parametrized_function()
Get a reference to the parametrized function.
virtual void add_interpolation_data_to_rb_property_map(const Parallel::Communicator &comm, std::unordered_map< std::string, std::set< dof_id_type > > &rb_property_map, dof_id_type elem_id)
Virtual function that can be overridden in RBParametrizedFunction subclasses to store properties in t...
std::vector< std::vector< Point > > all_xyz_perturb
std::unordered_map< std::string, std::set< dof_id_type > > rb_property_map
Generic map that can be used to store any list of ids (elements, nodes, elemsets, subdomains....
std::vector< unsigned int > qps
std::vector< std::vector< std::vector< Real > > > phi_i_all_qp
std::vector< dof_id_type > elem_ids
std::vector< Point > all_xyz
The members that define the inputs to the vectorized evaluate functions.
std::vector< subdomain_id_type > sbd_ids
std::vector< std::vector< Real > > JxW_all_qp
std::vector< std::vector< Real > > phi_i_qp

References _interpolation_points_comp, _vec_eval_input, libMesh::RBParametrizedFunction::add_interpolation_data_to_rb_property_map(), libMesh::VectorizedEvalInput::all_xyz, libMesh::VectorizedEvalInput::all_xyz_perturb, libMesh::ParallelObject::comm(), libMesh::VectorizedEvalInput::dxyzdeta_elem_center, libMesh::VectorizedEvalInput::dxyzdxi_elem_center, libMesh::VectorizedEvalInput::elem_id_to_local_index, libMesh::VectorizedEvalInput::elem_ids, libMesh::VectorizedEvalInput::elem_types, get_parametrized_function(), libMesh::VectorizedEvalInput::JxW_all_qp, libMesh::VectorizedEvalInput::phi_i_all_qp, libMesh::VectorizedEvalInput::phi_i_qp, libMesh::VectorizedEvalInput::qps, libMesh::VectorizedEvalInput::qrule_orders, libMesh::VectorizedEvalInput::rb_property_map, and libMesh::VectorizedEvalInput::sbd_ids.

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

◆ add_interpolation_points_boundary_id()

void RBEIMEvaluation::add_interpolation_points_boundary_id ( boundary_id_type  b_id)

◆ add_interpolation_points_comp()

void RBEIMEvaluation::add_interpolation_points_comp ( unsigned int  comp)

Definition at line 713 of file rb_eim_evaluation.C.

714{
715 _interpolation_points_comp.emplace_back(comp);
716}

References _interpolation_points_comp.

Referenced by libMesh::RBDataDeserialization::load_rb_eim_evaluation_data().

◆ add_interpolation_points_elem_id()

void RBEIMEvaluation::add_interpolation_points_elem_id ( dof_id_type  elem_id)

◆ add_interpolation_points_elem_type()

void RBEIMEvaluation::add_interpolation_points_elem_type ( ElemType  elem_type)

◆ add_interpolation_points_JxW_all_qp()

void RBEIMEvaluation::add_interpolation_points_JxW_all_qp ( const std::vector< Real > &  JxW_all_qp)

◆ add_interpolation_points_node_id()

void RBEIMEvaluation::add_interpolation_points_node_id ( dof_id_type  node_id)

Definition at line 743 of file rb_eim_evaluation.C.

744{
745 _vec_eval_input.node_ids.emplace_back(node_id);
746}
std::vector< dof_id_type > node_ids

References _vec_eval_input, and libMesh::VectorizedEvalInput::node_ids.

Referenced by libMesh::RBDataDeserialization::load_rb_eim_evaluation_data().

◆ add_interpolation_points_phi_i_all_qp()

void RBEIMEvaluation::add_interpolation_points_phi_i_all_qp ( const std::vector< std::vector< Real > > &  phi_i_all_qp)

◆ add_interpolation_points_phi_i_qp()

void RBEIMEvaluation::add_interpolation_points_phi_i_qp ( const std::vector< Real > &  phi_i_qp)

Definition at line 768 of file rb_eim_evaluation.C.

769{
770 _vec_eval_input.phi_i_qp.emplace_back(phi_i_qp);
771}

References _vec_eval_input, and libMesh::VectorizedEvalInput::phi_i_qp.

Referenced by libMesh::RBDataDeserialization::load_rb_eim_evaluation_data().

◆ add_interpolation_points_qp()

void RBEIMEvaluation::add_interpolation_points_qp ( unsigned int  qp)

Definition at line 748 of file rb_eim_evaluation.C.

749{
750 _vec_eval_input.qps.emplace_back(qp);
751}

References _vec_eval_input, and libMesh::VectorizedEvalInput::qps.

Referenced by libMesh::RBDataDeserialization::load_rb_eim_evaluation_data().

◆ add_interpolation_points_qrule_order()

void RBEIMEvaluation::add_interpolation_points_qrule_order ( Order  qrule_order)

◆ add_interpolation_points_side_index()

void RBEIMEvaluation::add_interpolation_points_side_index ( unsigned int  side_index)

Definition at line 738 of file rb_eim_evaluation.C.

739{
740 _vec_eval_input.side_indices.emplace_back(side_index);
741}
std::vector< unsigned int > side_indices

References _vec_eval_input, and libMesh::VectorizedEvalInput::side_indices.

Referenced by libMesh::RBDataDeserialization::load_rb_eim_evaluation_data().

◆ add_interpolation_points_spatial_indices()

void RBEIMEvaluation::add_interpolation_points_spatial_indices ( const std::vector< unsigned int > &  spatial_indices)

Definition at line 788 of file rb_eim_evaluation.C.

789{
790 _interpolation_points_spatial_indices.emplace_back(spatial_indices);
791}
std::vector< std::vector< unsigned int > > _interpolation_points_spatial_indices
Here we store the spatial indices that were initialized by initialize_spatial_indices_at_interp_pts()...

References _interpolation_points_spatial_indices.

Referenced by libMesh::RBDataDeserialization::load_rb_eim_evaluation_data().

◆ add_interpolation_points_subdomain_id()

void RBEIMEvaluation::add_interpolation_points_subdomain_id ( subdomain_id_type  sbd_id)

◆ add_interpolation_points_xyz()

void RBEIMEvaluation::add_interpolation_points_xyz ( Point  p)

Set the data associated with EIM interpolation points.

Definition at line 708 of file rb_eim_evaluation.C.

709{
710 _vec_eval_input.all_xyz.emplace_back(p);
711}

References _vec_eval_input, and libMesh::VectorizedEvalInput::all_xyz.

Referenced by libMesh::RBDataDeserialization::load_rb_eim_evaluation_data().

◆ add_interpolation_points_xyz_perturbations()

void RBEIMEvaluation::add_interpolation_points_xyz_perturbations ( const std::vector< Point > &  perturbs)

◆ add_node_basis_function()

void RBEIMEvaluation::add_node_basis_function ( const NodeDataMap node_bf)

Add node_bf to our EIM basis.

Definition at line 1055 of file rb_eim_evaluation.C.

1057{
1058 _local_node_eim_basis_functions.emplace_back(node_bf);
1059}
std::vector< NodeDataMap > _local_node_eim_basis_functions
The EIM basis functions on element nodes (e.g.

References _local_node_eim_basis_functions.

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

◆ add_node_interpolation_data()

void RBEIMEvaluation::add_node_interpolation_data ( Point  p,
unsigned int  comp,
dof_id_type  node_id,
boundary_id_type  boundary_id 
)

Add interpolation data associated with a new basis function.

Definition at line 1061 of file rb_eim_evaluation.C.

1066{
1067 _vec_eval_input.all_xyz.emplace_back(p);
1068 _interpolation_points_comp.emplace_back(comp);
1069 _vec_eval_input.node_ids.emplace_back(node_id);
1070 _vec_eval_input.boundary_ids.emplace_back(boundary_id);
1071
1072 // Add dummy values for the other properties, which are unused in the
1073 // node case.
1074 _vec_eval_input.elem_ids.emplace_back(0);
1075 _vec_eval_input.side_indices.emplace_back(0);
1076 _vec_eval_input.sbd_ids.emplace_back(0);
1077 _vec_eval_input.qps.emplace_back(0);
1078 _vec_eval_input.all_xyz_perturb.emplace_back();
1079 _vec_eval_input.phi_i_qp.emplace_back();
1081 _vec_eval_input.JxW_all_qp.emplace_back();
1082 _vec_eval_input.phi_i_all_qp.emplace_back();
1084 _vec_eval_input.dxyzdxi_elem_center.emplace_back();
1086}
@ INVALID_ORDER
Definition enum_order.h:88

References _interpolation_points_comp, _vec_eval_input, libMesh::VectorizedEvalInput::all_xyz, libMesh::VectorizedEvalInput::all_xyz_perturb, libMesh::VectorizedEvalInput::boundary_ids, libMesh::VectorizedEvalInput::dxyzdeta_elem_center, libMesh::VectorizedEvalInput::dxyzdxi_elem_center, libMesh::VectorizedEvalInput::elem_ids, libMesh::VectorizedEvalInput::elem_types, libMesh::INVALID_ELEM, libMesh::INVALID_ORDER, libMesh::VectorizedEvalInput::JxW_all_qp, libMesh::VectorizedEvalInput::node_ids, libMesh::VectorizedEvalInput::phi_i_all_qp, libMesh::VectorizedEvalInput::phi_i_qp, libMesh::VectorizedEvalInput::qps, libMesh::VectorizedEvalInput::qrule_orders, libMesh::VectorizedEvalInput::sbd_ids, and libMesh::VectorizedEvalInput::side_indices.

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

◆ add_rb_property_map_entry()

void RBEIMEvaluation::add_rb_property_map_entry ( std::string &  property_name,
std::set< dof_id_type > &  entity_ids 
)

Definition at line 800 of file rb_eim_evaluation.C.

801{
802 bool insert_succeed = _vec_eval_input.rb_property_map.insert({property_name, entity_ids}).second;
803 libmesh_error_msg_if(!insert_succeed, "Entry already added, duplicate detected.");
804}

References _vec_eval_input, and libMesh::VectorizedEvalInput::rb_property_map.

Referenced by libMesh::RBDataDeserialization::load_rb_eim_evaluation_data().

◆ add_side_basis_function()

void RBEIMEvaluation::add_side_basis_function ( const SideQpDataMap side_bf)

Add side_bf to our EIM basis.

Definition at line 1018 of file rb_eim_evaluation.C.

1020{
1021 _local_side_eim_basis_functions.emplace_back(side_bf);
1022}
std::vector< SideQpDataMap > _local_side_eim_basis_functions
The EIM basis functions on element sides.

References _local_side_eim_basis_functions.

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

◆ add_side_interpolation_data()

void RBEIMEvaluation::add_side_interpolation_data ( Point  p,
unsigned int  comp,
dof_id_type  elem_id,
unsigned int  side_index,
subdomain_id_type  subdomain_id,
boundary_id_type  boundary_id,
unsigned int  qp,
const std::vector< Point > &  perturbs,
const std::vector< Real > &  phi_i_qp 
)

Add interpolation data associated with a new basis function.

Definition at line 1024 of file rb_eim_evaluation.C.

1034{
1035 _vec_eval_input.all_xyz.emplace_back(p);
1036 _interpolation_points_comp.emplace_back(comp);
1037 _vec_eval_input.elem_ids.emplace_back(elem_id);
1038 _vec_eval_input.side_indices.emplace_back(side_index);
1039 _vec_eval_input.sbd_ids.emplace_back(subdomain_id);
1040 _vec_eval_input.boundary_ids.emplace_back(boundary_id);
1041 _vec_eval_input.qps.emplace_back(qp);
1042 _vec_eval_input.all_xyz_perturb.emplace_back(perturbs);
1043 _vec_eval_input.phi_i_qp.emplace_back(phi_i_qp);
1044
1045 // Add dummy values for the other properties, which are unused in the
1046 // node case.
1048 _vec_eval_input.JxW_all_qp.emplace_back();
1049 _vec_eval_input.phi_i_all_qp.emplace_back();
1051 _vec_eval_input.dxyzdxi_elem_center.emplace_back();
1053}

References _interpolation_points_comp, _vec_eval_input, libMesh::VectorizedEvalInput::all_xyz, libMesh::VectorizedEvalInput::all_xyz_perturb, libMesh::VectorizedEvalInput::boundary_ids, libMesh::VectorizedEvalInput::dxyzdeta_elem_center, libMesh::VectorizedEvalInput::dxyzdxi_elem_center, libMesh::VectorizedEvalInput::elem_ids, libMesh::VectorizedEvalInput::elem_types, libMesh::INVALID_ELEM, libMesh::INVALID_ORDER, libMesh::VectorizedEvalInput::JxW_all_qp, libMesh::VectorizedEvalInput::phi_i_all_qp, libMesh::VectorizedEvalInput::phi_i_qp, libMesh::VectorizedEvalInput::qps, libMesh::VectorizedEvalInput::qrule_orders, libMesh::VectorizedEvalInput::sbd_ids, and libMesh::VectorizedEvalInput::side_indices.

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

◆ build_eim_theta()

std::unique_ptr< RBTheta > RBEIMEvaluation::build_eim_theta ( unsigned int  index)
virtual

Build a theta object corresponding to EIM index index.

The default implementation builds an RBEIMTheta object, possibly override in subclasses if we need more specialized behavior.

Definition at line 429 of file rb_eim_evaluation.C.

430{
431 return std::make_unique<RBEIMTheta>(*this, index);
432}

Referenced by initialize_eim_theta_objects().

◆ 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.
OStreamProxy out
static constexpr Real TOLERANCE
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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 RBEIMEvaluation::clear ( )
overridevirtual

Clear this object.

Reimplemented from libMesh::RBParametrized.

Definition at line 61 of file rb_eim_evaluation.C.

62{
64
67
68
70
71 // Delete any RBTheta objects that were created
73}
void resize(const unsigned int new_m, const unsigned int new_n)
Resizes the matrix to the specified size and calls zero().
DenseMatrix< Number > _interpolation_matrix
Dense matrix that stores the lower triangular interpolation matrix that can be used.
std::vector< std::unique_ptr< RBTheta > > _rb_eim_theta_objects
The vector of RBTheta objects that are created to point to this RBEIMEvaluation.
void clear()
Clear all the members.

References _interpolation_matrix, _interpolation_points_comp, _interpolation_points_spatial_indices, _rb_eim_theta_objects, _vec_eval_input, libMesh::VectorizedEvalInput::clear(), and libMesh::DenseMatrix< T >::resize().

Referenced by distribute_bfs(), gather_bfs(), node_distribute_bfs(), side_distribute_bfs(), side_gather_bfs(), and write_out_side_basis_functions().

◆ 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(), 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(), 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(), gather_bfs(), libMesh::DofMap::gather_constraints(), libMesh::MeshfreeInterpolation::gather_remote_data(), libMesh::CondensedEigenSystem::get_eigenpair(), get_eim_basis_function_node_value(), get_eim_basis_function_side_value(), get_eim_basis_function_value(), libMesh::MeshBase::get_info(), get_interior_basis_functions_as_vecs(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::RBEIMConstruction::get_max_abs_value(), libMesh::RBEIMConstruction::get_node_max_abs_value(), get_parametrized_function_node_value(), get_parametrized_function_side_value(), 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(), node_distribute_bfs(), 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(), read_in_interior_basis_functions(), read_in_node_basis_functions(), 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(), side_distribute_bfs(), 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(), write_out_interior_basis_functions(), write_out_node_basis_functions(), 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().

◆ decrement_vector()

void RBEIMEvaluation::decrement_vector ( QpDataMap v,
const DenseVector< Number > &  coeffs 
)

Subtract coeffs[i]*basis_function[i] from v.

Definition at line 340 of file rb_eim_evaluation.C.

342{
343 LOG_SCOPE("decrement_vector()", "RBEIMEvaluation");
344
345 libmesh_error_msg_if(get_n_basis_functions() != coeffs.size(),
346 "Error: Number of coefficients should match number of basis functions");
347
348 for (auto & [elem_id, v_comp_and_qp] : v)
349 {
350 for (const auto & comp : index_range(v_comp_and_qp))
351 for (unsigned int qp : index_range(v_comp_and_qp[comp]))
352 for (unsigned int i : index_range(_local_eim_basis_functions))
353 {
354 // Check that entry (elem_id,comp,qp) exists in _local_eim_basis_functions so that
355 // we get a clear error message if there is any missing data
356 const auto & basis_comp_and_qp = libmesh_map_find(_local_eim_basis_functions[i], elem_id);
357
358 libmesh_error_msg_if(comp >= basis_comp_and_qp.size(), "Error: Invalid comp");
359 libmesh_error_msg_if(qp >= basis_comp_and_qp[comp].size(), "Error: Invalid qp");
360
361 v_comp_and_qp[comp][qp] -= coeffs(i) * basis_comp_and_qp[comp][qp];
362 }
363 }
364}
void ErrorVector unsigned int
virtual unsigned int size() const override final
unsigned int get_n_basis_functions() const
Return the current number of EIM basis functions.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition int_range.h:153

References _local_eim_basis_functions, get_n_basis_functions(), libMesh::index_range(), and libMesh::DenseVector< T >::size().

Referenced by libMesh::RBEIMConstruction::compute_max_eim_error(), and libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors().

◆ disable_print_counter_info()

void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 100 of file reference_counter.C.

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

References libMesh::ReferenceCounter::_enable_print_counter.

◆ distribute_bfs()

void RBEIMEvaluation::distribute_bfs ( const System sys)
private

Helper function that distributes the entries of _local_eim_basis_functions to their respective processors after they are read in on processor 0.

Definition at line 2297 of file rb_eim_evaluation.C.

2298{
2299 // So we can avoid calling these many times below
2300 auto n_procs = sys.comm().size();
2301 auto rank = sys.comm().rank();
2302
2303 // In serial there's nothing to distribute
2304 if (n_procs == 1)
2305 return;
2306
2307 // Broadcast the number of basis functions from proc 0. After
2308 // distributing, all procs should have the same number of basis
2309 // functions.
2310 auto n_bf = _local_eim_basis_functions.size();
2311 sys.comm().broadcast(n_bf);
2312
2313 // Allocate enough space to store n_bf basis functions on non-zero ranks
2314 if (rank != 0)
2315 _local_eim_basis_functions.resize(n_bf);
2316
2317 // Broadcast the number of variables from proc 0. After
2318 // distributing, all procs should have the same number of variables.
2319 auto n_vars = _local_eim_basis_functions[0].begin()->second.size();
2320 sys.comm().broadcast(n_vars);
2321
2322 // Construct lists of elem ids owned by different processors
2323 const MeshBase & mesh = sys.get_mesh();
2324
2325 std::vector<dof_id_type> gathered_local_elem_ids;
2326 gathered_local_elem_ids.reserve(mesh.n_elem());
2327 for (const auto & elem : mesh.active_local_element_ptr_range())
2328 gathered_local_elem_ids.push_back(elem->id());
2329
2330 // I _think_ the local elem ids are likely to already be sorted in
2331 // ascending order, since that is how they are stored on the Mesh,
2332 // but we can always just guarantee this to be on the safe side as
2333 // well.
2334 std::sort(gathered_local_elem_ids.begin(), gathered_local_elem_ids.end());
2335
2336 // Gather the number of local elems from all procs to proc 0
2337 auto n_local_elems = gathered_local_elem_ids.size();
2338 std::vector<std::size_t> gathered_n_local_elems = {n_local_elems};
2339 sys.comm().gather(/*root_id=*/0, gathered_n_local_elems);
2340
2341 // Gather the elem ids owned by each processor onto processor 0.
2342 sys.comm().gather(/*root_id=*/0, gathered_local_elem_ids);
2343
2344 // Construct vectors of "start" and "one-past-the-end" indices into
2345 // the gathered_local_elem_ids vector for each proc. Only valid on
2346 // processor 0.
2347 std::vector<std::size_t> start_elem_ids_index, end_elem_ids_index;
2348
2349 if (rank == 0)
2350 {
2351 start_elem_ids_index.resize(n_procs);
2352 start_elem_ids_index[0] = 0;
2353 for (processor_id_type p=1; p<n_procs; ++p)
2354 start_elem_ids_index[p] = start_elem_ids_index[p-1] + gathered_n_local_elems[p-1];
2355
2356 end_elem_ids_index.resize(n_procs);
2357 end_elem_ids_index[n_procs - 1] = gathered_local_elem_ids.size();
2358 for (processor_id_type p=0; p<n_procs - 1; ++p)
2359 end_elem_ids_index[p] = start_elem_ids_index[p+1];
2360 }
2361
2362 // On processor 0, using basis function 0 and variable 0, prepare a
2363 // vector with the number of qps per Elem. Then scatter this vector
2364 // out to the processors that require it. The order of this vector
2365 // matches the gathered_local_elem_ids ordering. The counts will be
2366 // gathered_n_local_elems, since there will be one qp count per Elem.
2367 std::vector<unsigned int> n_qp_per_elem_data;
2368
2369 // On rank 0, the "counts" vector holds the number of floating point values that
2370 // are to be scattered to each proc. It is only required on proc 0.
2371 std::vector<int> counts;
2372
2373 if (rank == 0)
2374 {
2375 n_qp_per_elem_data.reserve(gathered_local_elem_ids.size());
2376 counts.resize(n_procs);
2377
2378 auto & bf_map = _local_eim_basis_functions[0];
2379
2380 for (processor_id_type p=0; p<n_procs; ++p)
2381 {
2382 for (auto e : make_range(start_elem_ids_index[p], end_elem_ids_index[p]))
2383 {
2384 auto elem_id = gathered_local_elem_ids[e];
2385
2386 // Get reference to array[n_vars][n_qp] for current Elem.
2387 // Throws an error if the required elem_id is not found.
2388 const auto & array = libmesh_map_find(bf_map, elem_id);
2389
2390 auto n_qps = array[0].size();
2391
2392 // We use var==0 to set the number of qps for all vars
2393 n_qp_per_elem_data.push_back(n_qps);
2394
2395 // Accumulate the count for this proc
2396 counts[p] += n_qps;
2397 } // end for (e)
2398 } // end for proc_id
2399 } // if (rank == 0)
2400
2401 // Now scatter the n_qp_per_elem_data to all procs (must call the
2402 // scatter on all procs, it is a collective).
2403 {
2404 std::vector<unsigned int> recv;
2405 std::vector<int> tmp(gathered_n_local_elems.begin(), gathered_n_local_elems.end());
2406 sys.comm().scatter(n_qp_per_elem_data, tmp, recv, /*root_id=*/0);
2407
2408 // Now swap n_qp_per_elem_data and recv. All processors now have a
2409 // vector of length n_local_elems containing the number of
2410 // quadarature points per Elem.
2411 n_qp_per_elem_data.swap(recv);
2412 }
2413
2414 // For each basis function and each variable, build a vector
2415 // of qp data in the Elem ordering given by the
2416 // gathered_local_elem_ids, then call
2417 //
2418 // sys.comm().scatter(data, counts, recv, /*root_id=*/0);
2419 std::vector<std::vector<Number>> qp_data(n_vars);
2420 if (rank == 0)
2421 {
2422 // The total amount of qp data is given by summing the entries
2423 // of the "counts" vector.
2424 auto n_qp_data =
2425 std::accumulate(counts.begin(), counts.end(), 0u);
2426
2427 // On processor 0, reserve enough space to hold all the qp
2428 // data for a single basis function for each var.
2429 for (auto var : index_range(qp_data))
2430 qp_data[var].reserve(n_qp_data);
2431 }
2432
2433 // The recv_qp_data vector will be used on the receiving end of all
2434 // the scatters below.
2435 std::vector<Number> recv_qp_data;
2436
2437 // Loop from 0..n_bf on _all_ procs, since the scatters inside this
2438 // loop are collective.
2439 for (auto bf : make_range(n_bf))
2440 {
2441 // Prepare data for scattering (only on proc 0)
2442 if (rank == 0)
2443 {
2444 // Reference to the data map for the current basis function.
2445 auto & bf_map = _local_eim_basis_functions[bf];
2446
2447 // Clear any data from previous bf
2448 for (auto var : index_range(qp_data))
2449 qp_data[var].clear();
2450
2451 for (processor_id_type p=0; p<n_procs; ++p)
2452 {
2453 for (auto e : make_range(start_elem_ids_index[p], end_elem_ids_index[p]))
2454 {
2455 auto elem_id = gathered_local_elem_ids[e];
2456
2457 // Get reference to array[n_vars][n_qp] for current Elem.
2458 // Throws an error if the required elem_id is not found.
2459 const auto & array = libmesh_map_find(bf_map, elem_id);
2460
2461 for (auto var : index_range(array))
2462 {
2463 // Insert all qp values for this var
2464 qp_data[var].insert(/*insert at*/qp_data[var].end(),
2465 /*data start*/array[var].begin(),
2466 /*data end*/array[var].end());
2467 } // end for (var)
2468 } // end for (e)
2469 } // end for proc_id
2470 } // end if rank==0
2471
2472 // Perform the scatters (all procs)
2473 for (auto var : make_range(n_vars))
2474 {
2475 // Do the scatter for the current var
2476 sys.comm().scatter(qp_data[var], counts, recv_qp_data, /*root_id=*/0);
2477
2478 if (rank != 0)
2479 {
2480 // Store the scattered data we received in _local_eim_basis_functions[bf]
2481 auto & bf_map = _local_eim_basis_functions[bf];
2482 auto cursor = recv_qp_data.begin();
2483
2484 for (auto i : index_range(gathered_local_elem_ids))
2485 {
2486 auto elem_id = gathered_local_elem_ids[i];
2487 auto n_qp_this_elem = n_qp_per_elem_data[i];
2488 auto & array = bf_map[elem_id];
2489
2490 // Create space to store the data if it doesn't already exist.
2491 if (array.empty())
2492 array.resize(n_vars);
2493
2494 array[var].assign(cursor, cursor + n_qp_this_elem);
2495 std::advance(cursor, n_qp_this_elem);
2496 }
2497 } // if (rank != 0)
2498 } // end for (var)
2499 } // end for (bf)
2500
2501 // Now that the scattering is done, delete non-local Elem
2502 // information from processor 0's _local_eim_basis_functions data
2503 // structure.
2504 if (rank == 0)
2505 {
2506 for (processor_id_type p=1; p<n_procs; ++p)
2507 {
2508 for (auto e : make_range(start_elem_ids_index[p], end_elem_ids_index[p]))
2509 {
2510 auto elem_id = gathered_local_elem_ids[e];
2511
2512 // Delete this Elem's information from every basis function.
2513 for (auto & bf_map : _local_eim_basis_functions)
2514 bf_map.erase(elem_id);
2515 } // end for (e)
2516 } // end for proc_id
2517 } // if (rank == 0)
2518}
unsigned int n_vars
virtual void clear() override
Clear this object.
MeshBase & mesh
uint8_t processor_id_type
Definition id_types.h:104
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition int_range.h:176

References _local_eim_basis_functions, libMesh::Parallel::Communicator::broadcast(), clear(), libMesh::ParallelObject::comm(), libMesh::Parallel::Communicator::gather(), libMesh::System::get_mesh(), libMesh::index_range(), libMesh::make_range(), mesh, n_vars, libMesh::Parallel::Communicator::rank(), libMesh::Parallel::Communicator::scatter(), and libMesh::Parallel::Communicator::size().

Referenced by read_in_interior_basis_functions().

◆ enable_print_counter_info()

void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

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

Enabled by default.

Definition at line 94 of file reference_counter.C.

95{
97 return;
98}

References libMesh::ReferenceCounter::_enable_print_counter.

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

◆ gather_bfs()

void RBEIMEvaluation::gather_bfs ( )
private

Helper function that gathers the contents of _local_eim_basis_functions to processor 0 in preparation for printing to file.

Definition at line 1878 of file rb_eim_evaluation.C.

1879{
1880 // We need to gather _local_eim_basis_functions data from other
1881 // procs for printing.
1882 //
1883 // Ideally, this could be accomplished by simply calling:
1884 // this->comm().gather(/*root_id=*/0, _local_eim_basis_functions);
1885 //
1886 // but the data structure seems to be too complicated for this to
1887 // work automatically. (I get some error about the function called
1888 // being "private within this context".) Therefore, we have to
1889 // gather the information manually.
1890
1891 // So we can avoid calling this many times below
1892 auto n_procs = this->n_processors();
1893
1894 // In serial there's nothing to gather
1895 if (n_procs == 1)
1896 return;
1897
1898 // Current assumption is that the number of basis functions stored on
1899 // each processor is the same, the only thing that differs is the number
1900 // of elements, so make sure that is the case now.
1901 auto n_bf = _local_eim_basis_functions.size();
1902 libmesh_assert(this->comm().verify(n_bf));
1903
1904 // This function should never be called if there are no basis
1905 // functions, so if it was, something went wrong.
1906 libmesh_error_msg_if(!n_bf, "RBEIMEvaluation::gather_bfs() should not be called with 0 basis functions.");
1907
1908 // The number of variables should be the same on all processors
1909 // and we can get this from _local_eim_basis_functions. However,
1910 // it may be that some processors have no local elements, so on
1911 // those processors we cannot look up the size from
1912 // _local_eim_basis_functions. As a result we use comm().max(n_vars)
1913 // to make sure all processors agree on the final value.
1914 std::size_t n_vars =
1915 _local_eim_basis_functions[0].empty() ? 0 : _local_eim_basis_functions[0].begin()->second.size();
1916 this->comm().max(n_vars);
1917
1918 // Gather list of Elem ids stored on each processor to proc 0. We
1919 // use basis function 0 as an example and assume all the basis
1920 // functions are distributed similarly.
1921 std::vector<dof_id_type> elem_ids;
1922 elem_ids.reserve(_local_eim_basis_functions[0].size());
1923 for (const auto & pr : _local_eim_basis_functions[0])
1924 elem_ids.push_back(pr.first);
1925 this->comm().gather(/*root_id=*/0, elem_ids);
1926
1927 // Store the number of qps per Elem on this processor. Again, use
1928 // basis function 0 (and variable 0) to get this information, then
1929 // apply it to all basis functions.
1930 std::vector<unsigned int> n_qp_per_elem;
1931 n_qp_per_elem.reserve(_local_eim_basis_functions[0].size());
1932 for (const auto & pr : _local_eim_basis_functions[0])
1933 {
1934 // array[n_vars][n_qp] per Elem. We get the number of QPs
1935 // for variable 0, assuming they are all the same.
1936 const auto & array = pr.second;
1937 n_qp_per_elem.push_back(array[0].size());
1938 }
1939
1940 // Before gathering, compute the total amount of local qp data for
1941 // each var, which is the sum of the entries in the "n_qp_per_elem" array.
1942 // This will be used to reserve space in a vector below.
1943 auto n_local_qp_data =
1944 std::accumulate(n_qp_per_elem.begin(),
1945 n_qp_per_elem.end(),
1946 0u);
1947
1948 // Gather the number of qps per Elem for each processor onto processor 0.
1949 this->comm().gather(/*root_id=*/0, n_qp_per_elem);
1950
1951 // Sanity check: On processor 0, this checks that we have gathered the same number
1952 // of elem ids and qp counts.
1953 libmesh_error_msg_if(elem_ids.size() != n_qp_per_elem.size(),
1954 "Must gather same number of Elem ids as qps per Elem.");
1955
1956 // Reserve space to store contiguous vectors of qp data for each var
1957 std::vector<std::vector<Number>> gathered_qp_data(n_vars);
1958 for (auto var : index_range(gathered_qp_data))
1959 gathered_qp_data[var].reserve(n_local_qp_data);
1960
1961 // Now we construct a vector for each basis function, for each
1962 // variable, which is ordered according to:
1963 // [ [qp vals for Elem 0], [qp vals for Elem 1], ... [qp vals for Elem N] ]
1964 // and gather it to processor 0.
1966 {
1967 // Clear any data from previous bf
1968 for (auto var : index_range(gathered_qp_data))
1969 gathered_qp_data[var].clear();
1970
1971 for (const auto & pr : _local_eim_basis_functions[bf])
1972 {
1973 // array[n_vars][n_qp] per Elem
1974 const auto & array = pr.second;
1975 for (auto var : index_range(array))
1976 {
1977 // Insert all qp values for this var
1978 gathered_qp_data[var].insert(/*insert at*/gathered_qp_data[var].end(),
1979 /*data start*/array[var].begin(),
1980 /*data end*/array[var].end());
1981 }
1982 }
1983
1984 // Reference to the data map for the current basis function.
1985 auto & bf_map = _local_eim_basis_functions[bf];
1986
1987 for (auto var : index_range(gathered_qp_data))
1988 {
1989 // For each var, gather gathered_qp_data[var] onto processor
1990 // 0. There apparently is not a gather overload for
1991 // vector-of-vectors...
1992 this->comm().gather(/*root_id=*/0, gathered_qp_data[var]);
1993
1994 // On processor 0, iterate over the gathered_qp_data[var]
1995 // vector we just gathered, filling in the "small" vectors
1996 // for each Elem. Note: here we ignore the fact that we
1997 // already have the data on processor 0 and just overwrite
1998 // it, this makes the indexing logic a bit simpler.
1999 if (this->processor_id() == 0)
2000 {
2001 auto cursor = gathered_qp_data[var].begin();
2002 for (auto i : index_range(elem_ids))
2003 {
2004 auto elem_id = elem_ids[i];
2005 auto n_qp_this_elem = n_qp_per_elem[i];
2006
2007 // Get reference to the [n_vars][n_qp] array for
2008 // this Elem. We assign() into the vector of
2009 // quadrature point values, which allocates space if
2010 // it doesn't already exist.
2011 auto & array = bf_map[elem_id];
2012
2013 // Possibly allocate space if this is data for a new
2014 // element we haven't seen before.
2015 if (array.empty())
2016 array.resize(n_vars);
2017
2018 array[var].assign(cursor, cursor + n_qp_this_elem);
2019 std::advance(cursor, n_qp_this_elem);
2020 }
2021 }
2022 }
2023 } // end loop over basis functions
2024}
void max(const T &r, T &o, Request &req) const
void gather(const unsigned int root_id, const T &send_data, std::vector< T, A > &recv) const
processor_id_type processor_id() const
processor_id_type n_processors() const
libmesh_assert(ctx)

References _local_eim_basis_functions, clear(), libMesh::ParallelObject::comm(), libMesh::Parallel::Communicator::gather(), libMesh::index_range(), libMesh::libmesh_assert(), libMesh::Parallel::Communicator::max(), libMesh::ParallelObject::n_processors(), n_vars, and libMesh::ParallelObject::processor_id().

Referenced by get_interior_basis_functions_as_vecs(), and write_out_interior_basis_functions().

◆ get_basis_function()

const RBEIMEvaluation::QpDataMap & RBEIMEvaluation::get_basis_function ( unsigned int  i) const

Get a reference to the i^th basis function.

Definition at line 650 of file rb_eim_evaluation.C.

651{
653}

References _local_eim_basis_functions.

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

◆ 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_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_eim_basis_function_node_local_value()

Number RBEIMEvaluation::get_eim_basis_function_node_local_value ( unsigned int  basis_function_index,
dof_id_type  node_id,
unsigned int  var 
) const

Same as get_eim_basis_function_values_at_qps() except for node data.

Note that this does not do any parallel communication, it just looks up the value from _local_node_eim_basis_functions.

Definition at line 588 of file rb_eim_evaluation.C.

591{
592 libmesh_error_msg_if(basis_function_index >= _local_node_eim_basis_functions.size(),
593 "Invalid basis function index: " << basis_function_index);
594
596 _local_node_eim_basis_functions[basis_function_index],
597 node_id,
598 comp);
599}
static Number get_parametrized_function_node_local_value(const NodeDataMap &pf, dof_id_type node_id, unsigned int comp)
Same as get_parametrized_function_values_at_qps() except for node data.

References _local_node_eim_basis_functions, and get_parametrized_function_node_local_value().

Referenced by libMesh::RBEIMAssembly::evaluate_node_basis_function().

◆ get_eim_basis_function_node_value()

Number RBEIMEvaluation::get_eim_basis_function_node_value ( unsigned int  basis_function_index,
dof_id_type  node_id,
unsigned int  var 
) const

Same as get_eim_basis_function_value() except for node data.

Note that unlike get_eim_basis_function_node_local_value(), this does do parallel communication so that it can be called on any processor regardless of whether node_id is local or not.

Definition at line 601 of file rb_eim_evaluation.C.

604{
605 libmesh_error_msg_if(basis_function_index >= _local_node_eim_basis_functions.size(),
606 "Invalid basis function index: " << basis_function_index);
607
609 comm(),
610 _local_node_eim_basis_functions[basis_function_index],
611 node_id,
612 comp);
613}
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.

References _local_node_eim_basis_functions, libMesh::ParallelObject::comm(), and get_parametrized_function_node_value().

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

◆ get_eim_basis_function_side_value()

Number RBEIMEvaluation::get_eim_basis_function_side_value ( unsigned int  basis_function_index,
dof_id_type  elem_id,
unsigned int  side_index,
unsigned int  comp,
unsigned int  qp 
) const

Same as get_eim_basis_function_value() except for side data.

Definition at line 631 of file rb_eim_evaluation.C.

636{
637 libmesh_error_msg_if(basis_function_index >= _local_side_eim_basis_functions.size(),
638 "Invalid side basis function index: " << basis_function_index);
639
641 comm(),
642 _local_side_eim_basis_functions[basis_function_index],
643 elem_id,
644 side_index,
645 comp,
646 qp);
647}
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 _local_side_eim_basis_functions, libMesh::ParallelObject::comm(), and get_parametrized_function_side_value().

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

◆ get_eim_basis_function_side_values_at_qps()

void RBEIMEvaluation::get_eim_basis_function_side_values_at_qps ( unsigned int  basis_function_index,
dof_id_type  elem_id,
unsigned int  side_index,
unsigned int  var,
std::vector< Number > &  values 
) const

Same as get_eim_basis_function_values_at_qps() except for side data.

Definition at line 571 of file rb_eim_evaluation.C.

576{
577 libmesh_error_msg_if(basis_function_index >= _local_side_eim_basis_functions.size(),
578 "Invalid basis function index: " << basis_function_index);
579
581 _local_side_eim_basis_functions[basis_function_index],
582 elem_id,
583 side_index,
584 comp,
585 values);
586}
static void get_parametrized_function_side_values_at_qps(const SideQpDataMap &pf, dof_id_type elem_id, unsigned int side_index, unsigned int comp, std::vector< Number > &values)
Same as get_parametrized_function_values_at_qps() except for side data.

References _local_side_eim_basis_functions, and get_parametrized_function_side_values_at_qps().

Referenced by libMesh::RBEIMAssembly::evaluate_side_basis_function().

◆ get_eim_basis_function_value()

Number RBEIMEvaluation::get_eim_basis_function_value ( unsigned int  basis_function_index,
dof_id_type  elem_id,
unsigned int  comp,
unsigned int  qp 
) const

Same as above, except that we just return the value at the qp^th quadrature point.

Definition at line 615 of file rb_eim_evaluation.C.

619{
620 libmesh_error_msg_if(basis_function_index >= _local_eim_basis_functions.size(),
621 "Invalid basis function index: " << basis_function_index);
622
624 comm(),
625 _local_eim_basis_functions[basis_function_index],
626 elem_id,
627 comp,
628 qp);
629}
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.

References _local_eim_basis_functions, libMesh::ParallelObject::comm(), and get_parametrized_function_value().

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

◆ get_eim_basis_function_values_at_qps()

void RBEIMEvaluation::get_eim_basis_function_values_at_qps ( unsigned int  basis_function_index,
dof_id_type  elem_id,
unsigned int  var,
std::vector< Number > &  values 
) const

Fill up values with the basis function values for basis function basis_function_index and variable var, at all quadrature points on element elem_id.

Each processor stores data for only the elements local to that processor, so if elem_id is not on this processor then values will be empty.

Definition at line 556 of file rb_eim_evaluation.C.

560{
561 libmesh_error_msg_if(basis_function_index >= _local_eim_basis_functions.size(),
562 "Invalid basis function index: " << basis_function_index);
563
565 _local_eim_basis_functions[basis_function_index],
566 elem_id,
567 comp,
568 values);
569}
static void get_parametrized_function_values_at_qps(const QpDataMap &pf, dof_id_type elem_id, unsigned int comp, std::vector< Number > &values)
Fill up values by evaluating the parametrized function pf for all quadrature points on element elem_i...

References _local_eim_basis_functions, and get_parametrized_function_values_at_qps().

Referenced by libMesh::RBEIMAssembly::evaluate_basis_function().

◆ get_eim_error_indicator()

std::pair< Real, Real > RBEIMEvaluation::get_eim_error_indicator ( Number  error_indicator_rhs,
const DenseVector< Number > &  eim_solution,
const DenseVector< Number > &  eim_rhs 
)

Evaluates the EIM error indicator based on error_indicator_rhs, eim_solution, and _error_indicator_interpolation_row.

We also pass in eim_rhs since this is used to normalize the error indicator.

We return a pair that specifies the relative error indicator, and the normalization that was used to compute the relative error indicator. We can then recover the absolute error indicator via rel. indicator x normalization.

Definition at line 3053 of file rb_eim_evaluation.C.

3057{
3058 DenseVector<Number> coeffs;
3060
3061 Number EIM_val_at_error_indicator_pt = coeffs.dot(eim_solution);
3062 Real error_indicator_val =
3063 std::real(error_indicator_rhs - EIM_val_at_error_indicator_pt);
3064
3065 Real normalization = 0.;
3067 {
3068 // This normalization is based on the sum of terms from the "EIM residual" calculation
3069 // used in the calculation of error_indicator_val. This ensures that the error indicator
3070 // will always be less than or equal to one, which is a useful property for an error
3071 // indicator.
3072 normalization =
3073 std::abs(error_indicator_rhs) + std::abs(EIM_val_at_error_indicator_pt);
3074 }
3076 {
3077 // Normalize with respect to the right-hand side from the "EIM residual" calculation.
3078 normalization = std::abs(error_indicator_rhs);
3079 }
3081 {
3082 // Normalize the error indicator based on the max-norm of the EIM RHS vector.
3083 // This approach handles the case where different EIM variables have different
3084 // magnitudes well, i.e. if error_indicator_val is based on a
3085 // "small magnitude" variable, then by normalizing based on the entire
3086 // RHS vector (which will typically include values from multiple different
3087 // EIM variables) we will effectively scale down the error indicator
3088 // corresponding to small variables, which is typically what we want.
3089 normalization = std::max(eim_rhs.linfty_norm(), std::abs(error_indicator_rhs));
3090 }
3091 else
3092 {
3093 libmesh_error_msg("unsupported eim_error_indicator_normalization");
3094 }
3095
3096 // We avoid NaNs by setting normalization to 1 in the case that it is exactly 0.
3097 // But we return the "original normalization" as well (as opposed to the modified
3098 // normalization) since that can be useful information since it can indicate that
3099 // the EIM approximation was identically zero, for example.
3100 Real orig_normalization = normalization;
3101 if (normalization == 0.)
3102 normalization = 1.;
3103
3104 // Return the relative error indicator, and the normalization that we used. By returning
3105 // the normalization, we can subsequently recover the absolute error indicator if
3106 // desired.
3107 //
3108 // We also optionally clamp the relative error indicator to 1.0 since this typically
3109 // indicators 100% error and hence it may be the maximum value that we want to see.
3110 Real rel_error_indicator = std::abs(error_indicator_val) / normalization;
3111 if (limit_eim_error_indicator_to_one && (rel_error_indicator > 1.0))
3112 rel_error_indicator = 1.0;
3113
3114 return std::make_pair(rel_error_indicator, orig_normalization);
3115}
Real linfty_norm() const
void get_principal_subvector(unsigned int sub_n, DenseVector< T > &dest) const
Puts the principal subvector of size sub_n (i.e.
DenseVector< Number > _error_indicator_interpolation_row
Here we store an extra row of the interpolation matrix which is used to compute the EIM error indicat...
boost::multiprecision::float128 real(const boost::multiprecision::float128 in)

References _error_indicator_interpolation_row, libMesh::DenseVector< T >::dot(), eim_error_indicator_normalization, libMesh::DenseVector< T >::get_principal_subvector(), limit_eim_error_indicator_to_one, libMesh::DenseVector< T >::linfty_norm(), MAX_RHS, std::real(), libMesh::Real, RESIDUAL_RHS, RESIDUAL_SUM, and libMesh::DenseVector< T >::size().

Referenced by rb_eim_solves().

◆ get_eim_solutions_for_training_set() [1/2]

std::vector< DenseVector< Number > > & RBEIMEvaluation::get_eim_solutions_for_training_set ( )

Return a writeable reference to the EIM solutions for the parameters in the training set.

Definition at line 698 of file rb_eim_evaluation.C.

699{
701}
std::vector< DenseVector< Number > > _eim_solutions_for_training_set
Storage for EIM solutions from the training set.

References _eim_solutions_for_training_set.

◆ get_eim_solutions_for_training_set() [2/2]

const std::vector< DenseVector< Number > > & RBEIMEvaluation::get_eim_solutions_for_training_set ( ) const

◆ get_eim_theta_objects()

std::vector< std::unique_ptr< RBTheta > > & RBEIMEvaluation::get_eim_theta_objects ( )
Returns
The vector of theta objects that point to this RBEIMEvaluation.

Definition at line 424 of file rb_eim_evaluation.C.

425{
427}

References _rb_eim_theta_objects.

◆ get_eim_vars_to_project_and_write()

const std::vector< EIMVarGroupPlottingInfo > & RBEIMEvaluation::get_eim_vars_to_project_and_write ( ) const

Get _eim_vars_to_project_and_write.

Definition at line 3025 of file rb_eim_evaluation.C.

3026{
3028}
std::vector< EIMVarGroupPlottingInfo > _eim_vars_to_project_and_write
This vector specifies which EIM variables we want to write to disk and/or project to nodes for plotti...

References _eim_vars_to_project_and_write.

◆ get_elem_center_dxyzdeta()

const Point & RBEIMEvaluation::get_elem_center_dxyzdeta ( unsigned int  index) const

Definition at line 914 of file rb_eim_evaluation.C.

915{
916 libmesh_error_msg_if(index >= _vec_eval_input.dxyzdeta_elem_center.size(), "Error: Invalid index");
917
919}

References _vec_eval_input, and libMesh::VectorizedEvalInput::dxyzdeta_elem_center.

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder().

◆ get_elem_center_dxyzdxi()

const Point & RBEIMEvaluation::get_elem_center_dxyzdxi ( unsigned int  index) const

Definition at line 907 of file rb_eim_evaluation.C.

908{
909 libmesh_error_msg_if(index >= _vec_eval_input.dxyzdxi_elem_center.size(), "Error: Invalid index");
910
912}

References _vec_eval_input, and libMesh::VectorizedEvalInput::dxyzdxi_elem_center.

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder().

◆ get_elem_id_to_local_index_map()

const std::map< dof_id_type, unsigned int > & RBEIMEvaluation::get_elem_id_to_local_index_map ( ) const

◆ get_error_indicator_interpolation_row()

const DenseVector< Number > & RBEIMEvaluation::get_error_indicator_interpolation_row ( ) const

Get/set _extra_points_interpolation_matrix.

Definition at line 3131 of file rb_eim_evaluation.C.

3132{
3134}

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder().

◆ get_info()

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

std::vector< std::vector< Number > > RBEIMEvaluation::get_interior_basis_function_as_vec_helper ( unsigned int  n_vars,
unsigned int  n_qp_data,
unsigned int  bf_index 
)
private

Helper function called by write_out_interior_basis_functions() to get basis function bf_index stored as a std::vector per variable.

Definition at line 1235 of file rb_eim_evaluation.C.

1240{
1241 LOG_SCOPE("get_interior_basis_function_as_vec_helper()", "RBEIMEvaluation");
1242
1243 std::vector<std::vector<Number>> qp_data(n_vars);
1244
1245 // Reserve enough capacity in qp_data in order to do the insertions below
1246 // without further memory allocation.
1247 for (auto var : index_range(qp_data))
1248 qp_data[var].reserve(n_qp_data);
1249
1250 // Now we construct a vector for each basis function, for each
1251 // variable which is ordered according to:
1252 // [ [qp vals for Elem 0], [qp vals for Elem 1], ... [qp vals for Elem N] ]
1253 // and write it to file.
1254
1255 libmesh_error_msg_if(bf_index >= _local_eim_basis_functions.size(), "bf_index not valid");
1256 for (const auto & pr : _local_eim_basis_functions[bf_index])
1257 {
1258 // array[n_vars][n_qp] per Elem
1259 const auto & array = pr.second;
1260 for (auto var : index_range(array))
1261 {
1262 // Insert all qp values for this var
1263 qp_data[var].insert(/*insert at*/qp_data[var].end(),
1264 /*data start*/array[var].begin(),
1265 /*data end*/array[var].end());
1266 }
1267 }
1268
1269 return qp_data;
1270}

References _local_eim_basis_functions, libMesh::index_range(), and n_vars.

Referenced by get_interior_basis_functions_as_vecs(), and write_out_interior_basis_functions().

◆ get_interior_basis_function_sizes()

std::map< std::string, std::size_t > RBEIMEvaluation::get_interior_basis_function_sizes ( std::vector< unsigned int > &  n_qp_per_elem)

Get data that defines the sizes of interior EIM basis functions.

Definition at line 1181 of file rb_eim_evaluation.C.

1183{
1184 std::map<std::string,std::size_t> interior_basis_function_sizes;
1185
1186 // Write number of basis functions to file. Note: the
1187 // Xdr::data() function takes non-const references, so you can't
1188 // pass e.g. vec.size() to that interface.
1189 auto n_bf = _local_eim_basis_functions.size();
1190 interior_basis_function_sizes["n_bf"] = n_bf;
1191
1192 // We assume that each basis function has data for the same
1193 // number of elements as basis function 0, which is equal to the
1194 // size of the map.
1195 auto n_elem = _local_eim_basis_functions[0].size();
1196 interior_basis_function_sizes["n_elem"] = n_elem;
1197
1198 // We assume that each element has the same number of variables,
1199 // and we get the number of vars from the first element of the
1200 // first basis function.
1201 auto n_vars = _local_eim_basis_functions[0].begin()->second.size();
1202 interior_basis_function_sizes["n_vars"] = n_vars;
1203
1204 // We assume that the list of elements for each basis function
1205 // is the same as basis function 0. We also assume that all vars
1206 // have the same number of qps.
1207 n_qp_per_elem.clear();
1208 n_qp_per_elem.reserve(n_elem);
1209 dof_id_type expected_elem_id = 0;
1210 for (const auto & [actual_elem_id, array] : _local_eim_basis_functions[0])
1211 {
1212 // Note: Currently we require that the Elems are numbered
1213 // contiguously from [0..n_elem). This allows us to avoid
1214 // writing the Elem ids to the Xdr file, but if we need to
1215 // generalize this assumption later, we can.
1216 libmesh_error_msg_if(actual_elem_id != expected_elem_id++,
1217 "RBEIMEvaluation currently assumes a contiguous Elem numbering starting from 0.");
1218
1219 // array[n_vars][n_qp] per Elem. We get the number of QPs
1220 // for variable 0, assuming they are all the same.
1221 n_qp_per_elem.push_back(array[0].size());
1222 }
1223
1224 // The total amount of qp data for each var is the sum of the
1225 // entries in the "n_qp_per_elem" array.
1226 auto n_qp_data =
1227 std::accumulate(n_qp_per_elem.begin(),
1228 n_qp_per_elem.end(),
1229 0u);
1230 interior_basis_function_sizes["n_qp_data"] = n_qp_data;
1231
1232 return interior_basis_function_sizes;
1233}
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).
uint8_t dof_id_type
Definition id_types.h:67

References _local_eim_basis_functions, and n_vars.

Referenced by get_interior_basis_functions_as_vecs(), and write_out_interior_basis_functions().

◆ get_interior_basis_functions_as_vecs()

std::vector< std::vector< std::vector< Number > > > RBEIMEvaluation::get_interior_basis_functions_as_vecs ( )

Get all interior basis functions in the form of std::vectors.

This can provide a convenient format for processing the basis function data, or writing it to disk.

Indexing is as follows: basis function index --> variable index --> data at qps per elems

In parallel we gather basis functions to processor 0 and hence we only return non-empty data on processor 0.

Definition at line 1272 of file rb_eim_evaluation.C.

1274{
1275 LOG_SCOPE("get_interior_basis_function_as_vec()", "RBEIMEvaluation");
1276
1277 std::vector<std::vector<std::vector<Number>>> interior_basis_functions;
1278
1279 // Quick return if there is no work to do. Note: make sure all procs
1280 // agree there is no work to do.
1281 bool is_empty = _local_eim_basis_functions.empty();
1282 libmesh_assert(this->comm().verify(is_empty));
1283
1284 if (is_empty)
1285 return interior_basis_functions;
1286
1287 // Gather basis function data from other procs, storing it in
1288 // _local_eim_basis_functions, so that we can then print everything
1289 // from processor 0.
1290 this->gather_bfs();
1291
1292 if (this->processor_id() == 0)
1293 {
1294 std::vector<unsigned int> n_qp_per_elem;
1295 std::map<std::string,std::size_t> interior_basis_function_sizes =
1296 get_interior_basis_function_sizes(n_qp_per_elem);
1297
1298 for (auto bf_index : index_range(_local_eim_basis_functions))
1299 interior_basis_functions.emplace_back(
1301 libmesh_map_find(interior_basis_function_sizes,"n_vars"),
1302 libmesh_map_find(interior_basis_function_sizes,"n_qp_data"),
1303 bf_index));
1304 }
1305
1306 return interior_basis_functions;
1307}
std::vector< std::vector< Number > > get_interior_basis_function_as_vec_helper(unsigned int n_vars, unsigned int n_qp_data, unsigned int bf_index)
Helper function called by write_out_interior_basis_functions() to get basis function bf_index stored ...
std::map< std::string, std::size_t > get_interior_basis_function_sizes(std::vector< unsigned int > &n_qp_per_elem)
Get data that defines the sizes of interior EIM basis functions.
void gather_bfs()
Helper function that gathers the contents of _local_eim_basis_functions to processor 0 in preparation...

References _local_eim_basis_functions, libMesh::ParallelObject::comm(), gather_bfs(), get_interior_basis_function_as_vec_helper(), get_interior_basis_function_sizes(), libMesh::index_range(), libMesh::libmesh_assert(), and libMesh::ParallelObject::processor_id().

◆ get_interpolation_matrix()

const DenseMatrix< Number > & RBEIMEvaluation::get_interpolation_matrix ( ) const

Get the EIM interpolation matrix.

Definition at line 948 of file rb_eim_evaluation.C.

949{
951}

References _interpolation_matrix.

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder().

◆ get_interpolation_points_boundary_id()

boundary_id_type RBEIMEvaluation::get_interpolation_points_boundary_id ( unsigned int  index) const

Definition at line 827 of file rb_eim_evaluation.C.

828{
829 libmesh_error_msg_if(index >= _vec_eval_input.boundary_ids.size(), "Error: Invalid index");
830
831 return _vec_eval_input.boundary_ids[index];
832}

References _vec_eval_input, and libMesh::VectorizedEvalInput::boundary_ids.

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder().

◆ get_interpolation_points_comp()

unsigned int RBEIMEvaluation::get_interpolation_points_comp ( unsigned int  index) const

◆ get_interpolation_points_elem_id()

dof_id_type RBEIMEvaluation::get_interpolation_points_elem_id ( unsigned int  index) const

◆ get_interpolation_points_elem_type()

ElemType RBEIMEvaluation::get_interpolation_points_elem_type ( unsigned int  index) const

Definition at line 869 of file rb_eim_evaluation.C.

870{
871 libmesh_error_msg_if(index >= _vec_eval_input.elem_types.size(), "Error: Invalid index");
872
873 return _vec_eval_input.elem_types[index];
874}

References _vec_eval_input, and libMesh::VectorizedEvalInput::elem_types.

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder().

◆ get_interpolation_points_JxW_all_qp()

const std::vector< Real > & RBEIMEvaluation::get_interpolation_points_JxW_all_qp ( unsigned int  index) const

Definition at line 876 of file rb_eim_evaluation.C.

877{
878 libmesh_error_msg_if(index >= _vec_eval_input.JxW_all_qp.size(), "Error: Invalid index");
879
880 return _vec_eval_input.JxW_all_qp[index];
881}

References _vec_eval_input, and libMesh::VectorizedEvalInput::JxW_all_qp.

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder().

◆ get_interpolation_points_node_id()

dof_id_type RBEIMEvaluation::get_interpolation_points_node_id ( unsigned int  index) const

◆ get_interpolation_points_phi_i_all_qp()

const std::vector< std::vector< Real > > & RBEIMEvaluation::get_interpolation_points_phi_i_all_qp ( unsigned int  index) const

Definition at line 893 of file rb_eim_evaluation.C.

894{
895 libmesh_error_msg_if(index >= _vec_eval_input.phi_i_all_qp.size(), "Error: Invalid index");
896
897 return _vec_eval_input.phi_i_all_qp[index];
898}

References _vec_eval_input, and libMesh::VectorizedEvalInput::phi_i_all_qp.

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder().

◆ get_interpolation_points_phi_i_qp()

const std::vector< Real > & RBEIMEvaluation::get_interpolation_points_phi_i_qp ( unsigned int  index) const

Definition at line 900 of file rb_eim_evaluation.C.

901{
902 libmesh_error_msg_if(index >= _vec_eval_input.phi_i_qp.size(), "Error: Invalid index");
903
904 return _vec_eval_input.phi_i_qp[index];
905}

References _vec_eval_input, and libMesh::VectorizedEvalInput::phi_i_qp.

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder().

◆ get_interpolation_points_qp()

unsigned int RBEIMEvaluation::get_interpolation_points_qp ( unsigned int  index) const

◆ get_interpolation_points_qrule_order()

Order RBEIMEvaluation::get_interpolation_points_qrule_order ( unsigned int  index) const

Definition at line 921 of file rb_eim_evaluation.C.

922{
923 libmesh_error_msg_if(index >= _vec_eval_input.qrule_orders.size(), "Error: Invalid index");
924
925 return _vec_eval_input.qrule_orders[index];
926}

References _vec_eval_input, and libMesh::VectorizedEvalInput::qrule_orders.

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder().

◆ get_interpolation_points_side_index()

unsigned int RBEIMEvaluation::get_interpolation_points_side_index ( unsigned int  index) const

◆ get_interpolation_points_spatial_indices()

const std::vector< unsigned int > & RBEIMEvaluation::get_interpolation_points_spatial_indices ( unsigned int  index) const

Definition at line 928 of file rb_eim_evaluation.C.

929{
930 libmesh_error_msg_if(index >= _interpolation_points_spatial_indices.size(), "Error: Invalid index");
931
933}

References _interpolation_points_spatial_indices.

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder().

◆ get_interpolation_points_subdomain_id()

subdomain_id_type RBEIMEvaluation::get_interpolation_points_subdomain_id ( unsigned int  index) const

Definition at line 820 of file rb_eim_evaluation.C.

821{
822 libmesh_error_msg_if(index >= _vec_eval_input.sbd_ids.size(), "Error: Invalid index");
823
824 return _vec_eval_input.sbd_ids[index];
825}

References _vec_eval_input, and libMesh::VectorizedEvalInput::sbd_ids.

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder().

◆ get_interpolation_points_xyz()

Point RBEIMEvaluation::get_interpolation_points_xyz ( unsigned int  index) const

Get the data associated with EIM interpolation points.

Definition at line 806 of file rb_eim_evaluation.C.

807{
808 libmesh_error_msg_if(index >= _vec_eval_input.all_xyz.size(), "Error: Invalid index");
809
810 return _vec_eval_input.all_xyz[index];
811}

References _vec_eval_input, and libMesh::VectorizedEvalInput::all_xyz.

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder().

◆ get_interpolation_points_xyz_perturbations()

const std::vector< Point > & RBEIMEvaluation::get_interpolation_points_xyz_perturbations ( unsigned int  index) const

Definition at line 834 of file rb_eim_evaluation.C.

835{
836 libmesh_error_msg_if(index >= _vec_eval_input.all_xyz_perturb.size(), "Error: Invalid index");
837
838 return _vec_eval_input.all_xyz_perturb[index];
839}

References _vec_eval_input, and libMesh::VectorizedEvalInput::all_xyz_perturb.

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder().

◆ get_n_basis_functions()

unsigned int RBEIMEvaluation::get_n_basis_functions ( ) const

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

unsigned int RBEIMEvaluation::get_n_elems ( ) const

Return the number of unique elements containing interpolation points.

Definition at line 320 of file rb_eim_evaluation.C.

321{
323}

References _vec_eval_input, and libMesh::VectorizedEvalInput::elem_id_to_local_index.

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder().

◆ get_n_interpolation_points()

unsigned int RBEIMEvaluation::get_n_interpolation_points ( ) const

Return the number of interpolation points.

If we're not using the EIM error indicator, then this matches get_n_basis_functions(), but if we are using the EIM error indicator then we should have one extra interpolation point.

Definition at line 315 of file rb_eim_evaluation.C.

316{
317 return _vec_eval_input.all_xyz.size();
318}

References _vec_eval_input, and libMesh::VectorizedEvalInput::all_xyz.

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder(), and set_eim_error_indicator_active().

◆ get_n_interpolation_points_spatial_indices()

unsigned int RBEIMEvaluation::get_n_interpolation_points_spatial_indices ( ) const

_interpolation_points_spatial_indices is optional data, so we need to be able to check how many _interpolation_points_spatial_indices values have actually been set since it may not match the number of interpolation points.

Definition at line 935 of file rb_eim_evaluation.C.

936{
938}

References _interpolation_points_spatial_indices.

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder().

◆ get_n_params()

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

◆ get_n_properties()

unsigned int RBEIMEvaluation::get_n_properties ( ) const

Return the number of properties stored in the rb_property_map.

Definition at line 325 of file rb_eim_evaluation.C.

326{
327 return _vec_eval_input.rb_property_map.size();
328}

References _vec_eval_input, and libMesh::VectorizedEvalInput::rb_property_map.

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder().

◆ get_node_basis_function()

const RBEIMEvaluation::NodeDataMap & RBEIMEvaluation::get_node_basis_function ( unsigned int  i) const

Get a reference to the i^th node basis function.

Definition at line 662 of file rb_eim_evaluation.C.

663{
665}

References _local_node_eim_basis_functions.

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

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

RBParametrizedFunction & RBEIMEvaluation::get_parametrized_function ( )

Get a reference to the parametrized function.

Definition at line 92 of file rb_eim_evaluation.C.

93{
94 libmesh_error_msg_if(!_parametrized_function, "Parametrized function not initialized yet");
95
97}
std::unique_ptr< RBParametrizedFunction > _parametrized_function
Store the parametrized function that will be approximated by this EIM system.

References _parametrized_function.

Referenced by add_interpolation_data(), libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder(), libMesh::RBEIMConstruction::apply_normalization_to_solution_snapshots(), libMesh::RBEIMConstruction::compute_max_eim_error(), libMesh::RBEIMConstruction::enrich_eim_approximation(), get_n_basis_functions(), libMesh::RBEIMConstruction::get_random_point_from_training_sample(), initialize_interpolation_points_spatial_indices(), initialize_param_fn_spatial_indices(), libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set(), libMesh::RBEIMConstruction::initialize_qp_data(), initialize_rb_property_map(), libMesh::RBDataDeserialization::load_rb_eim_evaluation_data(), node_distribute_bfs(), rb_eim_solves(), read_in_basis_functions(), set_n_basis_functions(), libMesh::RBEIMConstruction::set_rb_construction_parameters(), side_distribute_bfs(), libMesh::RBEIMConstruction::store_eim_solutions_for_training_set(), libMesh::RBEIMConstruction::train_eim_approximation_with_greedy(), libMesh::RBEIMConstruction::train_eim_approximation_with_POD(), libMesh::RBEIMConstruction::update_eim_matrices(), and write_out_basis_functions().

◆ get_parametrized_function() [2/2]

const RBParametrizedFunction & RBEIMEvaluation::get_parametrized_function ( ) const

Get a const reference to the parametrized function.

Definition at line 99 of file rb_eim_evaluation.C.

100{
101 libmesh_error_msg_if(!_parametrized_function, "Parametrized function not initialized yet");
102
104}

References _parametrized_function.

◆ get_parametrized_function_node_local_value()

Number RBEIMEvaluation::get_parametrized_function_node_local_value ( const NodeDataMap pf,
dof_id_type  node_id,
unsigned int  comp 
)
static

Same as get_parametrized_function_values_at_qps() except for node data.

Note that this does not do any parallel communication, so it is only applicable to looking up local values.

Definition at line 477 of file rb_eim_evaluation.C.

481{
482 LOG_SCOPE("get_parametrized_function_node_local_value()", "RBEIMConstruction");
483
484 if (const auto it = pf.find(node_id);
485 it != pf.end())
486 {
487 const std::vector<Number> & vec = it->second;
488 libmesh_error_msg_if (comp >= vec.size(), "Error: Invalid comp index");
489 return vec[comp];
490 }
491 else
492 return 0.;
493}

Referenced by get_eim_basis_function_node_local_value(), and get_parametrized_function_node_value().

◆ get_parametrized_function_node_value()

Number RBEIMEvaluation::get_parametrized_function_node_value ( const Parallel::Communicator comm,
const NodeDataMap pf,
dof_id_type  node_id,
unsigned int  comp 
)
static

Same as get_parametrized_function_value() except for node data.

Unlike get_parametrized_function_node_local_value(), this does parallel communication, and therefore if can be used to look up values regardless of whether or not node_id is local.

Definition at line 542 of file rb_eim_evaluation.C.

547{
548 LOG_SCOPE("get_parametrized_function_node_value()", "RBEIMConstruction");
549
551 comm.sum(value);
552
553 return value;
554}

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

Referenced by libMesh::RBEIMConstruction::enrich_eim_approximation_on_nodes(), get_eim_basis_function_node_value(), and libMesh::RBEIMConstruction::store_eim_solutions_for_training_set().

◆ get_parametrized_function_side_value()

Number RBEIMEvaluation::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 
)
static

Same as get_parametrized_function_value() except for side data.

Definition at line 518 of file rb_eim_evaluation.C.

525{
526 std::vector<Number> values;
527 get_parametrized_function_side_values_at_qps(pf, elem_id, side_index, comp, values);
528
529 // In parallel, values should only be non-empty on one processor
530 Number value = 0.;
531 if (!values.empty())
532 {
533 libmesh_error_msg_if(qp >= values.size(), "Error: Invalid qp index");
534
535 value = values[qp];
536 }
537 comm.sum(value);
538
539 return value;
540}

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

Referenced by libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), get_eim_basis_function_side_value(), and libMesh::RBEIMConstruction::store_eim_solutions_for_training_set().

◆ get_parametrized_function_side_values_at_qps()

void RBEIMEvaluation::get_parametrized_function_side_values_at_qps ( const SideQpDataMap pf,
dof_id_type  elem_id,
unsigned int  side_index,
unsigned int  comp,
std::vector< Number > &  values 
)
static

Same as get_parametrized_function_values_at_qps() except for side data.

Definition at line 455 of file rb_eim_evaluation.C.

461{
462 LOG_SCOPE("get_parametrized_function_side_values_at_qps()", "RBEIMConstruction");
463
464 values.clear();
465
466 if (const auto it = pf.find(std::make_pair(elem_id, side_index));
467 it != pf.end())
468 {
469 const auto & comps_and_qps_on_elem = it->second;
470 libmesh_error_msg_if(comp >= comps_and_qps_on_elem.size(),
471 "Invalid comp index: " << comp);
472
473 values = comps_and_qps_on_elem[comp];
474 }
475}

Referenced by get_eim_basis_function_side_values_at_qps(), and get_parametrized_function_side_value().

◆ get_parametrized_function_value()

Number RBEIMEvaluation::get_parametrized_function_value ( const Parallel::Communicator comm,
const QpDataMap pf,
dof_id_type  elem_id,
unsigned int  comp,
unsigned int  qp 
)
static

Same as above, except that we just return the value at the qp^th quadrature point.

Definition at line 495 of file rb_eim_evaluation.C.

501{
502 std::vector<Number> values;
503 get_parametrized_function_values_at_qps(pf, elem_id, comp, values);
504
505 // In parallel, values should only be non-empty on one processor
506 Number value = 0.;
507 if (!values.empty())
508 {
509 libmesh_error_msg_if(qp >= values.size(), "Error: Invalid qp index");
510
511 value = values[qp];
512 }
513 comm.sum(value);
514
515 return value;
516}

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

Referenced by libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), get_eim_basis_function_value(), and libMesh::RBEIMConstruction::store_eim_solutions_for_training_set().

◆ get_parametrized_function_values_at_qps()

void RBEIMEvaluation::get_parametrized_function_values_at_qps ( const QpDataMap pf,
dof_id_type  elem_id,
unsigned int  comp,
std::vector< Number > &  values 
)
static

Fill up values by evaluating the parametrized function pf for all quadrature points on element elem_id and component comp.

Definition at line 434 of file rb_eim_evaluation.C.

439{
440 LOG_SCOPE("get_parametrized_function_values_at_qps()", "RBEIMConstruction");
441
442 values.clear();
443
444 if (const auto it = pf.find(elem_id);
445 it != pf.end())
446 {
447 const auto & comps_and_qps_on_elem = it->second;
448 libmesh_error_msg_if(comp >= comps_and_qps_on_elem.size(),
449 "Invalid comp index: " << comp);
450
451 values = comps_and_qps_on_elem[comp];
452 }
453}

Referenced by get_eim_basis_function_values_at_qps(), and get_parametrized_function_value().

◆ get_preserve_rb_eim_solutions()

bool RBEIMEvaluation::get_preserve_rb_eim_solutions ( ) const

Get _preserve_rb_eim_solutions.

Definition at line 958 of file rb_eim_evaluation.C.

959{
961}

References _preserve_rb_eim_solutions.

◆ get_rb_eim_error_indicators()

const std::vector< std::pair< Real, Real > > & RBEIMEvaluation::get_rb_eim_error_indicators ( ) const

Return the EIM error indicator values from the most recent call to rb_eim_solves().

The first entry of each pair is the normalized error indicator, and the second entry is the normalization factor.

Definition at line 703 of file rb_eim_evaluation.C.

704{
706}
std::vector< std::pair< Real, Real > > _rb_eim_error_indicators
If we're using the EIM error indicator, then we store the error indicator values corresponding to _rb...

References _rb_eim_error_indicators.

◆ get_rb_eim_solutions()

const std::vector< DenseVector< Number > > & RBEIMEvaluation::get_rb_eim_solutions ( ) const

Return the EIM solution coefficients from the most recent call to rb_eim_solves().

Definition at line 672 of file rb_eim_evaluation.C.

673{
674 return _rb_eim_solutions;
675}
std::vector< DenseVector< Number > > _rb_eim_solutions
The EIM solution coefficients from the most recent call to rb_eim_solves().

References _rb_eim_solutions.

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

◆ get_rb_eim_solutions_entries()

std::vector< Number > RBEIMEvaluation::get_rb_eim_solutions_entries ( unsigned int  index) const

Return entry index for each solution in _rb_eim_solutions.

Definition at line 677 of file rb_eim_evaluation.C.

678{
679 LOG_SCOPE("get_rb_eim_solutions_entries()", "RBEIMEvaluation");
680
681 std::vector<Number> rb_eim_solutions_entries(_rb_eim_solutions.size());
682 for (unsigned int mu_index : index_range(_rb_eim_solutions))
683 {
684 libmesh_error_msg_if(index >= _rb_eim_solutions[mu_index].size(),
685 "Error: Requested solution index " << index <<
686 ", but only have " << _rb_eim_solutions[mu_index].size() << " entries.");
687 rb_eim_solutions_entries[mu_index] = _rb_eim_solutions[mu_index](index);
688 }
689
690 return rb_eim_solutions_entries;
691}

References _rb_eim_solutions, and libMesh::index_range().

Referenced by libMesh::RBEIMTheta::evaluate_vec().

◆ get_rb_property_map()

const std::unordered_map< std::string, std::set< dof_id_type > > & RBEIMEvaluation::get_rb_property_map ( ) const

◆ get_side_basis_function()

const RBEIMEvaluation::SideQpDataMap & RBEIMEvaluation::get_side_basis_function ( unsigned int  i) const

Get a reference to the i^th side basis function.

Definition at line 656 of file rb_eim_evaluation.C.

657{
659}

References _local_side_eim_basis_functions.

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

◆ get_vec_eval_input()

const VectorizedEvalInput & RBEIMEvaluation::get_vec_eval_input ( ) const

◆ increment_constructor_count()

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

Increments the construction counter.

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

Definition at line 183 of file reference_counter.h.

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

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

Increments the destruction counter.

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

Definition at line 207 of file reference_counter.h.

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

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

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

◆ initialize_eim_theta_objects()

void RBEIMEvaluation::initialize_eim_theta_objects ( )

Build a vector of RBTheta objects that accesses the components of the RB_solution member variable of this RBEvaluation.

Store these objects in the member vector rb_theta_objects.

Definition at line 416 of file rb_eim_evaluation.C.

417{
418 // Initialize the rb_theta objects that access the solution from this rb_eim_evaluation
419 _rb_eim_theta_objects.clear();
420 for (auto i : make_range(get_n_basis_functions()))
421 _rb_eim_theta_objects.emplace_back(build_eim_theta(i));
422}
virtual std::unique_ptr< RBTheta > build_eim_theta(unsigned int index)
Build a theta object corresponding to EIM index index.

References _rb_eim_theta_objects, build_eim_theta(), get_n_basis_functions(), and libMesh::make_range().

◆ initialize_interpolation_points_spatial_indices()

void RBEIMEvaluation::initialize_interpolation_points_spatial_indices ( )

Initialize _interpolation_points_spatial_indices.

Once this data is initialized, we can store it in the training data, and read it back in during the Online stage to be used in solves.

Definition at line 291 of file rb_eim_evaluation.C.

292{
294
297}
virtual void get_spatial_indices(std::vector< std::vector< unsigned int > > &spatial_indices, const VectorizedEvalInput &v)
In some cases a parametrized function is defined based on array data that we index into based on the ...

References _interpolation_points_spatial_indices, _vec_eval_input, get_parametrized_function(), and libMesh::RBParametrizedFunction::get_spatial_indices().

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder().

◆ initialize_param_fn_spatial_indices()

void RBEIMEvaluation::initialize_param_fn_spatial_indices ( )

The Online counterpart of initialize_interpolation_points_spatial_indices().

This is used to initialize the spatial indices data in _parametrized_function so that the _parametrized_function can be used in the Online stage without reconstructing the spatial indices on every element or node in the mesh.

Definition at line 299 of file rb_eim_evaluation.C.

300{
303}
virtual void initialize_spatial_indices(const std::vector< std::vector< unsigned int > > &spatial_indices, const VectorizedEvalInput &v)
The Online stage counterpart of get_spatial_indices().

References _interpolation_points_spatial_indices, _vec_eval_input, get_parametrized_function(), and libMesh::RBParametrizedFunction::initialize_spatial_indices().

Referenced by libMesh::RBDataDeserialization::load_rb_eim_evaluation_data().

◆ 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.
bool set_parameters(const RBParameters &params)
Set the current parameters to params The parameters are checked for validity; an error is thrown if t...

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

void RBEIMEvaluation::initialize_rb_property_map ( )

Initialize the rb_property_map of RBEIMEvaluation (this) from the rb_property_map stored in RBParametrizedFunction with empty entries but identical keys.

Definition at line 3122 of file rb_eim_evaluation.C.

3123{
3124 const auto & rb_property_map = get_parametrized_function().get_rb_property_map();
3125 // Initialize rb_eim_eval VectorizedEvaluateInput from the one in rb_parametrized_function with
3126 // empty sets as it will be filled by subclasses virtual functions.
3127 for (const auto & [key, val] : rb_property_map)
3128 _vec_eval_input.rb_property_map[key] = {};
3129}
const std::unordered_map< std::string, std::set< dof_id_type > > & get_rb_property_map() const
Function that returns a reference to the rb_property_map stored in the RBParametrizedFunction.

References _vec_eval_input, get_parametrized_function(), libMesh::RBParametrizedFunction::get_rb_property_map(), and libMesh::VectorizedEvalInput::rb_property_map.

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

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

◆ n_objects()

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

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

Definition at line 85 of file reference_counter.h.

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

References libMesh::ReferenceCounter::_n_objects.

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

◆ n_processors()

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

Definition at line 103 of file parallel_object.h.

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

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

◆ node_decrement_vector()

void RBEIMEvaluation::node_decrement_vector ( NodeDataMap v,
const DenseVector< Number > &  coeffs 
)

Same as decrement_vector() except for node data.

Definition at line 392 of file rb_eim_evaluation.C.

394{
395 LOG_SCOPE("node_decrement_vector()", "RBEIMEvaluation");
396
397 libmesh_error_msg_if(get_n_basis_functions() != coeffs.size(),
398 "Error: Number of coefficients should match number of basis functions");
399
400 for (auto & [node_id, v_comps] : v)
401 {
402 for (const auto & comp : index_range(v_comps))
404 {
405 // Check that entry (node_id,comp) exists in _local_node_eim_basis_functions so that
406 // we get a clear error message if there is any missing data
407 const auto & basis_comp = libmesh_map_find(_local_node_eim_basis_functions[i], node_id);
408
409 libmesh_error_msg_if(comp >= basis_comp.size(), "Error: Invalid comp");
410
411 v_comps[comp] -= coeffs(i) * basis_comp[comp];
412 }
413 }
414}

References _local_node_eim_basis_functions, get_n_basis_functions(), libMesh::index_range(), and libMesh::DenseVector< T >::size().

Referenced by libMesh::RBEIMConstruction::compute_max_eim_error(), and libMesh::RBEIMConstruction::enrich_eim_approximation_on_nodes().

◆ node_distribute_bfs()

void RBEIMEvaluation::node_distribute_bfs ( const System sys)
private

Same as distribute_bfs() except for node data.

Definition at line 2795 of file rb_eim_evaluation.C.

2796{
2797 // So we can avoid calling these many times below
2798 auto n_procs = sys.comm().size();
2799 auto rank = sys.comm().rank();
2800
2801 // In serial there's nothing to distribute
2802 if (n_procs == 1)
2803 return;
2804
2805 // Broadcast the number of basis functions from proc 0. After
2806 // distributing, all procs should have the same number of basis
2807 // functions.
2808 auto n_bf = _local_node_eim_basis_functions.size();
2809 sys.comm().broadcast(n_bf);
2810
2811 // Allocate enough space to store n_bf basis functions on non-zero ranks
2812 if (rank != 0)
2814
2815 // Broadcast the number of variables from proc 0. After
2816 // distributing, all procs should have the same number of variables.
2817 auto n_vars = _local_node_eim_basis_functions[0].begin()->second.size();
2818 sys.comm().broadcast(n_vars);
2819
2820 // Construct lists of elem ids owned by different processors
2821 const MeshBase & mesh = sys.get_mesh();
2822
2823 std::vector<dof_id_type> gathered_local_node_ids;
2824 {
2825 const std::set<boundary_id_type> & parametrized_function_boundary_ids =
2827
2828 const auto & binfo = mesh.get_boundary_info();
2829
2830 // Make a set with all the nodes that have nodesets. Use
2831 // a set so that we don't have any duplicate entries. We
2832 // deal with duplicate entries below by getting all boundary
2833 // IDs on each node.
2834 std::set<dof_id_type> nodes_with_nodesets;
2835 for (const auto & t : binfo.build_node_list())
2836 nodes_with_nodesets.insert(std::get<0>(t));
2837
2838 // To be filled in by BoundaryInfo calls in loop below
2839 std::vector<boundary_id_type> node_boundary_ids;
2840
2841 for(dof_id_type node_id : nodes_with_nodesets)
2842 {
2843 const Node * node = mesh.node_ptr(node_id);
2844
2845 if (node->processor_id() != mesh.comm().rank())
2846 continue;
2847
2848 binfo.boundary_ids(node, node_boundary_ids);
2849
2850 bool has_node_boundary_id = false;
2851 for(boundary_id_type node_boundary_id : node_boundary_ids)
2852 if(parametrized_function_boundary_ids.count(node_boundary_id))
2853 {
2854 has_node_boundary_id = true;
2855 break;
2856 }
2857
2858 if(has_node_boundary_id)
2859 {
2860 gathered_local_node_ids.push_back(node_id);
2861 }
2862 }
2863 }
2864
2865 // I _think_ the local node ids are likely to already be sorted in
2866 // ascending order, since that is how they are stored on the Mesh,
2867 // but we can always just guarantee this to be on the safe side as
2868 // well.
2869 std::sort(gathered_local_node_ids.begin(), gathered_local_node_ids.end());
2870
2871 // Gather the number of local nodes from all procs to proc 0
2872 auto n_local_nodes = gathered_local_node_ids.size();
2873 std::vector<std::size_t> gathered_n_local_nodes = {n_local_nodes};
2874 sys.comm().gather(/*root_id=*/0, gathered_n_local_nodes);
2875
2876 // Gather the node ids owned by each processor onto processor 0.
2877 sys.comm().gather(/*root_id=*/0, gathered_local_node_ids);
2878
2879 // Construct vectors of "start" and "one-past-the-end" indices into
2880 // the gathered_local_node_ids vector for each proc. Only valid on
2881 // processor 0.
2882 std::vector<std::size_t> start_node_ids_index, end_node_ids_index;
2883
2884 if (rank == 0)
2885 {
2886 start_node_ids_index.resize(n_procs);
2887 start_node_ids_index[0] = 0;
2888 for (processor_id_type p=1; p<n_procs; ++p)
2889 start_node_ids_index[p] = start_node_ids_index[p-1] + gathered_n_local_nodes[p-1];
2890
2891 end_node_ids_index.resize(n_procs);
2892 end_node_ids_index[n_procs - 1] = gathered_local_node_ids.size();
2893 for (processor_id_type p=0; p<n_procs - 1; ++p)
2894 end_node_ids_index[p] = start_node_ids_index[p+1];
2895 }
2896
2897 // On processor 0, using basis function 0 and variable 0, prepare a
2898 // vector with the nodes. Then scatter this vector
2899 // out to the processors that require it. The order of this vector
2900 // matches the gathered_local_node_ids ordering. The counts will be
2901 // gathered_n_local_nodes.
2902
2903 // On rank 0, the "counts" vector holds the number of floating point values that
2904 // are to be scattered to each proc. It is only required on proc 0.
2905 std::vector<int> counts;
2906
2907 if (rank == 0)
2908 {
2909 counts.resize(n_procs);
2910
2911 for (processor_id_type p=0; p<n_procs; ++p)
2912 {
2913 auto node_ids_range = (end_node_ids_index[p] - start_node_ids_index[p]);
2914
2915 // Accumulate the count for this proc
2916 counts[p] += node_ids_range;
2917 } // end for proc_id
2918 } // if (rank == 0)
2919
2920 // The recv_node_data vector will be used on the receiving end of all
2921 // the scatters below.
2922 std::vector<Number> recv_node_data;
2923
2924 // For each basis function and each variable, build a vector
2925 // data in the Node ordering given by the
2926 // gathered_local_node_ids, then call
2927 //
2928 // sys.comm().scatter(data, counts, recv, /*root_id=*/0);
2929 std::vector<std::vector<Number>> node_data(n_vars);
2930
2931 // We also reserve space in node_data, since we will push_back into it below.
2932 int count_sum = std::accumulate(counts.begin(), counts.end(), 0);
2933 for (auto var : index_range(node_data))
2934 node_data[var].reserve(count_sum);
2935
2936 // Loop from 0..n_bf on _all_ procs, since the scatters inside this
2937 // loop are collective.
2938 for (auto bf : make_range(n_bf))
2939 {
2940 // Prepare data for scattering (only on proc 0)
2941 if (rank == 0)
2942 {
2943 // Reference to the data map for the current basis function.
2944 auto & bf_map = _local_node_eim_basis_functions[bf];
2945
2946 // Clear any data from previous bf (this does not change the capacity
2947 // that was reserved above).
2948 for (auto var : index_range(node_data))
2949 node_data[var].clear();
2950
2951 for (processor_id_type p=0; p<n_procs; ++p)
2952 {
2953 for (auto n : make_range(start_node_ids_index[p], end_node_ids_index[p]))
2954 {
2955 auto node_id = gathered_local_node_ids[n];
2956
2957 // Get reference to array[n_vars] for current Node.
2958 // Throws an error if the required node_id is not found.
2959 const auto & array = libmesh_map_find(bf_map, node_id);
2960
2961 for (auto var : index_range(array))
2962 node_data[var].push_back(array[var]);
2963 } // end for (n)
2964 } // end for proc_id
2965 } // end if rank==0
2966
2967 // Perform the scatters (all procs)
2968 for (auto var : make_range(n_vars))
2969 {
2970 // Do the scatter for the current var
2971 sys.comm().scatter(node_data[var], counts, recv_node_data, /*root_id=*/0);
2972
2973 if (rank != 0)
2974 {
2975 // Store the scattered data we received in _local_eim_basis_functions[bf]
2976 auto & bf_map = _local_node_eim_basis_functions[bf];
2977 auto cursor = recv_node_data.begin();
2978
2979 for (auto i : index_range(gathered_local_node_ids))
2980 {
2981 auto node_id = gathered_local_node_ids[i];
2982 auto & array = bf_map[node_id];
2983
2984 // Create space to store the data if it doesn't already exist.
2985 if (array.empty())
2986 array.resize(n_vars);
2987
2988 // There is only one value per variable per node, so
2989 // we set the value by de-referencing cursor, and
2990 // then advance the cursor by 1.
2991 array[var] = *cursor;
2992 std::advance(cursor, 1);
2993 }
2994 } // if (rank != 0)
2995 } // end for (var)
2996 } // end for (bf)
2997
2998 // Now that the scattering is done, delete non-local Elem
2999 // information from processor 0's _local_eim_basis_functions data
3000 // structure.
3001 if (rank == 0)
3002 {
3003 for (processor_id_type p=1; p<n_procs; ++p)
3004 {
3005 for (auto n : make_range(start_node_ids_index[p], end_node_ids_index[p]))
3006 {
3007 auto node_id = gathered_local_node_ids[n];
3008
3009 // Delete this Node's information from every basis function.
3010 for (auto & bf_map : _local_node_eim_basis_functions)
3011 bf_map.erase(node_id);
3012 } // end for (n)
3013 } // end for proc_id
3014 } // if (rank == 0)
3015}
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
const Elem & get(const ElemType type_in)
int8_t boundary_id_type
Definition id_types.h:51

References _local_node_eim_basis_functions, libMesh::Parallel::Communicator::broadcast(), clear(), libMesh::ParallelObject::comm(), libMesh::Parallel::Communicator::gather(), libMesh::System::get_mesh(), get_parametrized_function(), libMesh::RBParametrizedFunction::get_parametrized_function_boundary_ids(), libMesh::index_range(), libMesh::make_range(), mesh, n_vars, node_boundary_id, libMesh::DofObject::processor_id(), libMesh::Parallel::Communicator::rank(), libMesh::Parallel::Communicator::scatter(), and libMesh::Parallel::Communicator::size().

Referenced by read_in_node_basis_functions().

◆ node_gather_bfs()

void RBEIMEvaluation::node_gather_bfs ( )
private

Same as gather_bfs() except for node data.

Definition at line 2174 of file rb_eim_evaluation.C.

2175{
2176 // We need to gather _local_node_eim_basis_functions data from other
2177 // procs for printing.
2178 //
2179 // Ideally, this could be accomplished by simply calling:
2180 // this->comm().gather(/*root_id=*/0, _local_node_eim_basis_functions);
2181 //
2182 // but the data structure seems to be too complicated for this to
2183 // work automatically. (I get some error about the function called
2184 // being "private within this context".) Therefore, we have to
2185 // gather the information manually.
2186
2187 // So we can avoid calling this many times below
2188 auto n_procs = this->n_processors();
2189
2190 // In serial there's nothing to gather
2191 if (n_procs == 1)
2192 return;
2193
2194 // Current assumption is that the number of basis functions stored on
2195 // each processor is the same, the only thing that differs is the number
2196 // of elements, so make sure that is the case now.
2197 auto n_bf = _local_node_eim_basis_functions.size();
2198 libmesh_assert(this->comm().verify(n_bf));
2199
2200 // This function should never be called if there are no basis
2201 // functions, so if it was, something went wrong.
2202 libmesh_error_msg_if(!n_bf, "RBEIMEvaluation::gather_bfs() should not be called with 0 basis functions.");
2203
2204 // The number of variables should be the same on all processors
2205 // and we can get this from _local_eim_basis_functions. However,
2206 // it may be that some processors have no local elements, so on
2207 // those processors we cannot look up the size from
2208 // _local_eim_basis_functions. As a result we use comm().max(n_vars)
2209 // to make sure all processors agree on the final value.
2210 std::size_t n_vars =
2211 _local_node_eim_basis_functions[0].empty() ? 0 : _local_node_eim_basis_functions[0].begin()->second.size();
2212 this->comm().max(n_vars);
2213
2214 // Gather list of Node ids stored on each processor to proc 0. We
2215 // use basis function 0 as an example and assume all the basis
2216 // functions are distributed similarly.
2217 unsigned int n_local_nodes = _local_node_eim_basis_functions[0].size();
2218 std::vector<dof_id_type> node_ids;
2219 node_ids.reserve(n_local_nodes);
2220 for (const auto & pr : _local_node_eim_basis_functions[0])
2221 node_ids.push_back(pr.first);
2222 this->comm().gather(/*root_id=*/0, node_ids);
2223
2224 // Now we construct a vector for each basis function, for each
2225 // variable, which is ordered according to:
2226 // [ [val for Node 0], [val for Node 1], ... [val for Node N] ]
2227 // and gather it to processor 0.
2228 std::vector<std::vector<Number>> gathered_node_data(n_vars);
2230 {
2231 // Clear any data from previous bf
2232 for (auto var : index_range(gathered_node_data))
2233 {
2234 gathered_node_data[var].clear();
2235 gathered_node_data[var].resize(n_local_nodes);
2236 }
2237
2238 unsigned int local_node_idx = 0;
2239 for (const auto & pr : _local_node_eim_basis_functions[bf])
2240 {
2241 // array[n_vars] per Node
2242 const auto & array = pr.second;
2243 for (auto var : index_range(array))
2244 {
2245 gathered_node_data[var][local_node_idx] = array[var];
2246 }
2247
2248 local_node_idx++;
2249 }
2250
2251 // Reference to the data map for the current basis function.
2252 auto & bf_map = _local_node_eim_basis_functions[bf];
2253
2254 for (auto var : index_range(gathered_node_data))
2255 {
2256 // For each var, gather gathered_qp_data[var] onto processor
2257 // 0. There apparently is not a gather overload for
2258 // vector-of-vectors...
2259 this->comm().gather(/*root_id=*/0, gathered_node_data[var]);
2260
2261 // On processor 0, iterate over the gathered_qp_data[var]
2262 // vector we just gathered, filling in the "small" vectors
2263 // for each Elem. Note: here we ignore the fact that we
2264 // already have the data on processor 0 and just overwrite
2265 // it, this makes the indexing logic a bit simpler.
2266 if (this->processor_id() == 0)
2267 {
2268 auto cursor = gathered_node_data[var].begin();
2269 for (auto i : index_range(node_ids))
2270 {
2271 auto node_id = node_ids[i];
2272
2273 // Get reference to the [n_vars] array for
2274 // this Node. We assign() into the vector of
2275 // node values, which allocates space if
2276 // it doesn't already exist.
2277 auto & array = bf_map[node_id];
2278
2279 // Possibly allocate space if this is data for a new
2280 // node we haven't seen before.
2281 if (array.empty())
2282 array.resize(n_vars);
2283
2284 // There is only one value per variable per node, so
2285 // we set the value by de-referencing cursor, and
2286 // then advance the cursor by 1.
2287 array[var] = *cursor;
2288 std::advance(cursor, 1);
2289 }
2290 }
2291 }
2292 } // end loop over basis functions
2293}

References _local_node_eim_basis_functions, libMesh::ParallelObject::comm(), libMesh::Parallel::Communicator::gather(), libMesh::index_range(), libMesh::libmesh_assert(), libMesh::Parallel::Communicator::max(), libMesh::ParallelObject::n_processors(), n_vars, and libMesh::ParallelObject::processor_id().

Referenced by write_out_node_basis_functions().

◆ operator=() [1/2]

RBEIMEvaluation & libMesh::RBEIMEvaluation::operator= ( const RBEIMEvaluation )
delete

◆ operator=() [2/2]

RBEIMEvaluation & libMesh::RBEIMEvaluation::operator= ( RBEIMEvaluation &&  )
default

◆ 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}
The libMesh namespace provides an interface to certain functionality in the library.

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

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

void RBEIMEvaluation::print_local_eim_basis_functions ( ) const
private

Print the contents of _local_eim_basis_functions to libMesh::out.

Helper function mainly useful for debugging.

Definition at line 1827 of file rb_eim_evaluation.C.

1828{
1830 {
1831 libMesh::out << "Interior basis function " << bf << std::endl;
1832 for (const auto & [elem_id, array] : _local_eim_basis_functions[bf])
1833 {
1834 libMesh::out << "Elem " << elem_id << std::endl;
1835 for (auto var : index_range(array))
1836 {
1837 libMesh::out << "Variable " << var << std::endl;
1838 for (auto qp : index_range(array[var]))
1839 libMesh::out << array[var][qp] << " ";
1840 libMesh::out << std::endl;
1841 }
1842 }
1843 }
1844
1846 {
1847 libMesh::out << "Side basis function " << bf << std::endl;
1848 for (const auto & [pr, array] : _local_side_eim_basis_functions[bf])
1849 {
1850 const auto & elem_id = pr.first;
1851 const auto & side_index = pr.second;
1852 libMesh::out << "Elem " << elem_id << ", Side " << side_index << std::endl;
1853 for (auto var : index_range(array))
1854 {
1855 libMesh::out << "Variable " << var << std::endl;
1856 for (auto qp : index_range(array[var]))
1857 libMesh::out << array[var][qp] << " ";
1858 libMesh::out << std::endl;
1859 }
1860 }
1861 }
1862
1864 {
1865 libMesh::out << "Node basis function " << bf << std::endl;
1866 for (const auto & [node_id, array] : _local_node_eim_basis_functions[bf])
1867 {
1868 libMesh::out << "Node " << node_id << std::endl;
1869 for (auto var : index_range(array))
1870 {
1871 libMesh::out << "Variable " << var << ": " << array[var] << std::endl;
1872 }
1873 libMesh::out << std::endl;
1874 }
1875 }
1876}

References _local_eim_basis_functions, _local_node_eim_basis_functions, _local_side_eim_basis_functions, libMesh::index_range(), and libMesh::out.

◆ 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.
const RBParameters & get_parameters() const
Get the current 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().

◆ processor_id()

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

Definition at line 114 of file parallel_object.h.

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

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

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DistributedMesh::add_node(), libMesh::MeshTools::Modification::all_tri(), libMesh::FEMSystem::assembly(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::Partitioner::assign_partitioning(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::Partitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::MeshFunction::check_found_elem(), libMesh::DistributedMesh::clear(), libMesh::DistributedMesh::clear_elems(), libMesh::ExodusII_IO_Helper::close(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::compute_communication_map_parameters(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_node_communication_maps(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::ExodusII_IO_Helper::create(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DofMapBase::end_dof(), libMesh::DofMapBase::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMapBase::first_dof(), libMesh::DofMapBase::first_old_dof(), 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(), 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(), 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(), 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(), write_out_interior_basis_functions(), write_out_node_basis_functions(), 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_qp_data_vector_onto_system()

void RBEIMEvaluation::project_qp_data_vector_onto_system ( System sys,
const std::vector< Number > &  bf_data,
const EIMVarGroupPlottingInfo eim_vargroup,
const std::map< std::string, std::string > &  extra_options 
)
virtual

Project the EIM basis function data stored in bf_data onto sys.solution.

The intent of this function is to work with the data format provided by get_interior_basis_functions_as_vecs(). That format can be easily serialized, if needed, and hence can be used to provide bf_data after reading in data from disk, for example.

extra_options can be used to pass extra information to this method, e.g. options related to how to perform the projection.

This is a no-op by default, implement in sub-classes if needed.

Definition at line 3017 of file rb_eim_evaluation.C.

3021{
3022 // No-op by default, implement in subclasses if needed
3023}

◆ rb_eim_solve()

DenseVector< Number > RBEIMEvaluation::rb_eim_solve ( DenseVector< Number > &  EIM_rhs)

Calculate the EIM approximation for the given right-hand side vector EIM_rhs.

Store the solution coefficients in the member _eim_solution.

Definition at line 106 of file rb_eim_evaluation.C.

107{
108 LOG_SCOPE("rb_eim_solve()", "RBEIMEvaluation");
109
110 libmesh_error_msg_if(EIM_rhs.size() > get_n_basis_functions(),
111 "Error: N cannot be larger than the number of basis functions in rb_solve");
112
113 libmesh_error_msg_if(EIM_rhs.size()==0, "Error: N must be greater than 0 in rb_solve");
114
115 const unsigned int N = EIM_rhs.size();
116 DenseVector<Number> rb_eim_solution(N);
117 DenseMatrix<Number> interpolation_matrix_N;
118 _interpolation_matrix.get_principal_submatrix(N, interpolation_matrix_N);
119
120 interpolation_matrix_N.lu_solve(EIM_rhs, rb_eim_solution);
121
122 return rb_eim_solution;
123}
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.

References _interpolation_matrix, get_n_basis_functions(), libMesh::DenseMatrix< T >::get_principal_submatrix(), libMesh::DenseMatrix< T >::lu_solve(), and libMesh::DenseVector< T >::size().

Referenced by libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_nodes(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), and libMesh::RBEIMConstruction::store_eim_solutions_for_training_set().

◆ rb_eim_solves()

void RBEIMEvaluation::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.

Definition at line 125 of file rb_eim_evaluation.C.

127{
129 {
130 // In this case we preserve _rb_eim_solutions and hence we
131 // just return immediately so that we skip updating
132 // _rb_eim_solutions below. This is relevant in cases where
133 // we set up _rb_eim_solutions elsewhere and we don't want
134 // to override it.
135 return;
136 }
137
138 libmesh_error_msg_if(N > get_n_basis_functions(),
139 "Error: N cannot be larger than the number of basis functions in rb_eim_solves");
140 libmesh_error_msg_if(N==0, "Error: N must be greater than 0 in rb_eim_solves");
141
142 // If mus and N are the same as before, then we return early
143 if ((_rb_eim_solves_mus == mus) && (_rb_eim_solves_N == N))
144 return;
145
146 LOG_SCOPE("rb_eim_solves()", "RBEIMEvaluation");
147
148 _rb_eim_solves_mus = mus;
150
151 if (get_parametrized_function().is_lookup_table)
152 {
153 _rb_eim_solutions.resize(mus.size());
154 for (auto mu_index : index_range(mus))
155 {
156 Real lookup_table_param =
157 mus[mu_index].get_value(get_parametrized_function().lookup_table_param_name);
158
159 // Cast lookup_table_param to an unsigned integer so that we can use
160 // it as an index into the EIM rhs values obtained from the lookup table.
161 unsigned int lookup_table_index =
162 cast_int<unsigned int>(std::round(lookup_table_param));
163
164 DenseVector<Number> values;
165 _eim_solutions_for_training_set[lookup_table_index].get_principal_subvector(N, values);
166 _rb_eim_solutions[mu_index] = values;
167 }
168
169 return;
170 }
171
172 // output all comps indexing is as follows:
173 // mu index --> interpolation point index --> component index --> value.
174 std::vector<std::vector<std::vector<Number>>> output_all_comps;
175 if (get_parametrized_function().on_mesh_sides())
177 else if (get_parametrized_function().on_mesh_nodes())
179 else
181
182 // Previously we did one RB-EIM solve per input mu, but now we do
183 // one RB-EIM solve per input mu, per sample. In order for this to
184 // work, we require that all the input mu objects have the same
185 // number of samples.
186 auto n_samples_0 = mus[0].n_samples();
187 for (const auto & mu : mus)
188 libmesh_error_msg_if(mu.n_samples() != n_samples_0, "All RBParameters objects must have same n_samples()");
189
190 // After we verified that all mus have the same number of samples,
191 // the total number of RB-EIM solves is simply the number of mus
192 // times the number of samples.
193 unsigned int num_rb_eim_solves = mus.size() * n_samples_0;
194
195 // A special case is when we are passed a single RBParameters object
196 // with no parameters stored on it. In this case, we effectively
197 // have Theta(mu) == const, and therefore we still need to do at
198 // least one RB-EIM solve. In this case, we require that there is
199 // only one entry in "mus" for simplicity.
200 if (num_rb_eim_solves == 0 && mus[0].n_parameters() == 0)
201 {
202 libmesh_error_msg_if(mus.size() != 1, "Must pass in only a single RBParameters object when solving with no parameters.");
203 num_rb_eim_solves = 1;
204 }
205
206 std::vector<std::vector<Number>> evaluated_values_at_interp_points(num_rb_eim_solves);
207
208 std::vector<Number> evaluated_values_at_err_indicator_point;
210 evaluated_values_at_err_indicator_point.resize(num_rb_eim_solves);
211
212 // In this loop, counter goes from 0 to num_rb_eim_solves. The
213 // purpose of this loop is to strip out the "columns" of the
214 // output_all_comps array into rows.
215 {
216 unsigned int counter = 0;
217 for (auto mu_index : index_range(mus))
218 for (auto sample_index : make_range(mus[mu_index].n_samples()))
219 {
220 // Ignore compiler warnings about unused loop index
221 libmesh_ignore(sample_index);
222
223 evaluated_values_at_interp_points[counter].resize(N);
224
225 for (unsigned int interp_pt_index=0; interp_pt_index<N; interp_pt_index++)
226 {
227 unsigned int comp = _interpolation_points_comp[interp_pt_index];
228
229 // This line of code previously used "mu_index", now we use
230 // "counter" handle the multi-sample RBParameters case.
231 evaluated_values_at_interp_points[counter][interp_pt_index] =
232 output_all_comps[counter][interp_pt_index][comp];
233 }
234
236 {
237 unsigned int comp = _interpolation_points_comp[N];
238
239 evaluated_values_at_err_indicator_point[counter] =
240 output_all_comps[counter][N][comp];
241 }
242
243 counter++;
244 }
245
246 // Throw an error if we didn't do the required number of solves for
247 // some reason
248 libmesh_error_msg_if(counter != num_rb_eim_solves,
249 "We should have done " << num_rb_eim_solves <<
250 " solves, instead we did " << counter);
251 }
252
253 DenseMatrix<Number> interpolation_matrix_N;
254 _interpolation_matrix.get_principal_submatrix(N, interpolation_matrix_N);
255
256 // The number of RB EIM solutions is equal to the size of the
257 // "evaluated_values_at_interp_points" vector which we determined
258 // earlier.
259 _rb_eim_solutions.resize(num_rb_eim_solves);
261 _rb_eim_error_indicators.resize(num_rb_eim_solves);
262
263 {
264 unsigned int counter = 0;
265 for (auto mu_index : index_range(mus))
266 for (auto sample_index : make_range(mus[mu_index].n_samples()))
267 {
268 // Ignore compiler warnings about unused loop index
269 libmesh_ignore(sample_index);
270
271 DenseVector<Number> EIM_rhs = evaluated_values_at_interp_points[counter];
272 interpolation_matrix_N.lu_solve(EIM_rhs, _rb_eim_solutions[counter]);
273
274 // If we're using the EIM error indicator, then we compute it via the approach
275 // proposed in Proposition 3.3 of "An empirical interpolation method: application
276 // to efficient reduced-basis discretization of partial differential equations",
277 // Barrault et al.
279 {
280 Number error_indicator_rhs = evaluated_values_at_err_indicator_point[counter];
281 _rb_eim_error_indicators[counter] =
283 error_indicator_rhs, _rb_eim_solutions[counter], EIM_rhs);
284 }
285
286 counter++;
287 }
288 }
289}
std::pair< Real, Real > get_eim_error_indicator(Number error_indicator_rhs, const DenseVector< Number > &eim_solution, const DenseVector< Number > &eim_rhs)
Evaluates the EIM error indicator based on error_indicator_rhs, eim_solution, and _error_indicator_in...
std::vector< RBParameters > _rb_eim_solves_mus
The parameters and the number of basis functions that were used in the most recent call to rb_eim_sol...
virtual void node_vectorized_evaluate(const std::vector< RBParameters > &mus, const VectorizedEvalInput &v, std::vector< std::vector< std::vector< Number > > > &output)
Same as vectorized_evaluate() but on element nodes.
virtual void side_vectorized_evaluate(const std::vector< RBParameters > &mus, const VectorizedEvalInput &v, std::vector< std::vector< std::vector< Number > > > &output)
Same as vectorized_evaluate() but on element sides.
virtual void vectorized_evaluate(const std::vector< RBParameters > &mus, const VectorizedEvalInput &v, std::vector< std::vector< std::vector< Number > > > &output)
Vectorized version of evaluate.
void libmesh_ignore(const Args &...)

References _eim_solutions_for_training_set, _interpolation_matrix, _interpolation_points_comp, _is_eim_error_indicator_active, _preserve_rb_eim_solutions, _rb_eim_error_indicators, _rb_eim_solutions, _rb_eim_solves_mus, _rb_eim_solves_N, _vec_eval_input, get_eim_error_indicator(), get_n_basis_functions(), get_parametrized_function(), libMesh::DenseMatrix< T >::get_principal_submatrix(), libMesh::DenseVector< T >::get_principal_subvector(), libMesh::index_range(), libMesh::libmesh_ignore(), libMesh::RBParametrizedFunction::lookup_table_param_name, libMesh::DenseMatrix< T >::lu_solve(), libMesh::make_range(), libMesh::RBParametrizedFunction::node_vectorized_evaluate(), libMesh::Real, libMesh::RBParametrizedFunction::side_vectorized_evaluate(), and libMesh::RBParametrizedFunction::vectorized_evaluate().

Referenced by libMesh::RBEIMConstruction::compute_max_eim_error(), and libMesh::RBEIMTheta::evaluate_vec().

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

void RBEIMEvaluation::read_in_basis_functions ( const System sys,
const std::string &  directory_name = "offline_data",
bool  read_binary_basis_functions = true 
)

Read in all the basis functions from file.

Parameters
sysThe Mesh in this System determines the parallel distribution of the basis functions.
directory_nameSpecifies which directory to write files to.
read_binary_basis_functionsIndicates whether to expect binary or ASCII data.

Note: this is not a virtual function and is not related to the RBEvaluation function of the same name.

Definition at line 1520 of file rb_eim_evaluation.C.

1524{
1525 LOG_SCOPE("read_in_basis_functions()", "RBEIMEvaluation");
1526
1527 // Return early without reading in anything if there are no basis functions
1528 if (get_n_basis_functions() == 0)
1529 return;
1530
1531 if (get_parametrized_function().on_mesh_sides())
1532 read_in_side_basis_functions(sys, directory_name, read_binary_basis_functions);
1533 else if (get_parametrized_function().on_mesh_nodes())
1534 read_in_node_basis_functions(sys, directory_name, read_binary_basis_functions);
1535 else
1536 read_in_interior_basis_functions(sys, directory_name, read_binary_basis_functions);
1537}
void read_in_interior_basis_functions(const System &sys, const std::string &directory_name, bool read_binary_basis_functions)
Method that reads in element interior EIM basis functions.
void read_in_node_basis_functions(const System &sys, const std::string &directory_name, bool read_binary_basis_functions)
Method that reads in element node EIM basis functions.
void read_in_side_basis_functions(const System &sys, const std::string &directory_name, bool read_binary_basis_functions)
Method that reads in element side EIM basis functions.

References get_n_basis_functions(), get_parametrized_function(), read_in_interior_basis_functions(), read_in_node_basis_functions(), and read_in_side_basis_functions().

◆ read_in_interior_basis_functions()

void RBEIMEvaluation::read_in_interior_basis_functions ( const System sys,
const std::string &  directory_name,
bool  read_binary_basis_functions 
)
private

Method that reads in element interior EIM basis functions.

This may be called by read_in_basis_functions().

Definition at line 1539 of file rb_eim_evaluation.C.

1543{
1544 LOG_SCOPE("read_in_interior_basis_functions()", "RBEIMEvaluation");
1545
1546 // Read values on processor 0 only.
1547 if (sys.comm().rank() == 0)
1548 {
1549 // Create filename
1550 std::ostringstream file_name;
1551 const std::string basis_function_suffix = (read_binary_basis_functions ? ".xdr" : ".dat");
1552 file_name << directory_name << "/" << "bf_data" << basis_function_suffix;
1553
1554 // Create XDR reader object
1555 Xdr xdr(file_name.str(), read_binary_basis_functions ? DECODE : READ);
1556
1557 // Read in the number of basis functions. The comment parameter
1558 // is ignored when reading.
1559 std::size_t n_bf;
1560 xdr.data(n_bf);
1561
1562 // Read in the number of elements
1563 std::size_t n_elem;
1564 xdr.data(n_elem);
1565
1566 // Read in the number of variables.
1567 std::size_t n_vars;
1568 xdr.data(n_vars);
1569
1570 // Read in vector containing the number of QPs per elem. We can
1571 // create this vector with the required size or let it be read
1572 // from the file and sized for us.
1573 std::vector<unsigned int> n_qp_per_elem(n_elem);
1574 xdr.data(n_qp_per_elem);
1575
1576 // The total amount of qp data for each var is the sum of the
1577 // entries in the "n_qp_per_elem" array.
1578 auto n_qp_data =
1579 std::accumulate(n_qp_per_elem.begin(),
1580 n_qp_per_elem.end(),
1581 0u);
1582
1583 // Allocate space to store all required basis functions,
1584 // clearing any data that may have been there previously.
1585 //
1586 // TODO: Do we need to also write out/read in Elem ids?
1587 // Or can we assume they will always be contiguously
1588 // numbered (at least on proc 0)?
1590 _local_eim_basis_functions.resize(n_bf);
1592 for (std::size_t elem_id=0; elem_id<n_elem; ++elem_id)
1593 {
1594 auto & array = _local_eim_basis_functions[i][elem_id];
1595 array.resize(n_vars);
1596 }
1597
1598 // Allocate temporary storage for one var's worth of qp data.
1599 std::vector<Number> qp_data;
1600
1601 // Read in data for each basis function
1603 {
1604 // Reference to the data map for the current basis function.
1605 auto & bf_map = _local_eim_basis_functions[i];
1606
1607 for (std::size_t var=0; var<n_vars; ++var)
1608 {
1609 qp_data.clear();
1610 qp_data.resize(n_qp_data);
1611
1612 // Read data using data_stream() since that is
1613 // (currently) how we write it out. The "line_break"
1614 // parameter of data_stream() is ignored while reading.
1615 xdr.data_stream(qp_data.data(), qp_data.size());
1616
1617 // Iterate over the qp_data vector, filling in the
1618 // "small" vectors for each Elem.
1619 auto cursor = qp_data.begin();
1620 for (std::size_t elem_id=0; elem_id<n_elem; ++elem_id)
1621 {
1622 // Get reference to the [n_vars][n_qp] array for
1623 // this Elem. We assign() into the vector of
1624 // quadrature point values, which allocates space if
1625 // it doesn't already exist.
1626 auto & array = bf_map[elem_id];
1627 array[var].assign(cursor, cursor + n_qp_per_elem[elem_id]);
1628 std::advance(cursor, n_qp_per_elem[elem_id]);
1629 }
1630 } // end for (var)
1631 } // end for (i)
1632 } // end if processor 0
1633
1634 // Distribute the basis function information to the processors that require it
1635 this->distribute_bfs(sys);
1636}
void distribute_bfs(const System &sys)
Helper function that distributes the entries of _local_eim_basis_functions to their respective proces...

References _local_eim_basis_functions, libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::DECODE, distribute_bfs(), libMesh::index_range(), n_vars, libMesh::Parallel::Communicator::rank(), and libMesh::READ.

Referenced by read_in_basis_functions().

◆ read_in_node_basis_functions()

void RBEIMEvaluation::read_in_node_basis_functions ( const System sys,
const std::string &  directory_name,
bool  read_binary_basis_functions 
)
private

Method that reads in element node EIM basis functions.

This may be called by read_in_basis_functions().

Definition at line 1746 of file rb_eim_evaluation.C.

1750{
1751 LOG_SCOPE("read_in_node_basis_functions()", "RBEIMEvaluation");
1752
1753 // Read values on processor 0 only.
1754 if (sys.comm().rank() == 0)
1755 {
1756 // Create filename
1757 std::ostringstream file_name;
1758 const std::string basis_function_suffix = (read_binary_basis_functions ? ".xdr" : ".dat");
1759 file_name << directory_name << "/" << "bf_data" << basis_function_suffix;
1760
1761 // Create XDR reader object
1762 Xdr xdr(file_name.str(), read_binary_basis_functions ? DECODE : READ);
1763
1764 // Read in the number of basis functions. The comment parameter
1765 // is ignored when reading.
1766 std::size_t n_bf;
1767 xdr.data(n_bf);
1768
1769 // Read in the number of nodes
1770 std::size_t n_node;
1771 xdr.data(n_node);
1772
1773 // Read in the number of variables.
1774 std::size_t n_vars;
1775 xdr.data(n_vars);
1776
1777 std::vector<unsigned int> node_ids(n_node);
1778 xdr.data(node_ids);
1779
1780 // Allocate space to store all required basis functions,
1781 // clearing any data that may have been there previously.
1782 //
1783 // TODO: Do we need to also write out/read in Node ids?
1784 // Or can we assume they will always be contiguously
1785 // numbered (at least on proc 0)?
1789 for (auto node_id : node_ids)
1790 {
1791 auto & array = _local_node_eim_basis_functions[i][node_id];
1792 array.resize(n_vars);
1793 }
1794
1795 // Read data into node_value from xdr
1796 std::vector<Number> node_value;
1797
1798 // Read in data for each basis function
1800 {
1801 // Reference to the data map for the current basis function.
1802 auto & bf_map = _local_node_eim_basis_functions[i];
1803
1804 for (std::size_t var=0; var<n_vars; ++var)
1805 {
1806 node_value.clear();
1807 node_value.resize(n_node);
1808
1809 // Read data using data_stream() since that is
1810 // (currently) how we write it out. The "line_break"
1811 // parameter of data_stream() is ignored while reading.
1812 xdr.data_stream(node_value.data(), node_value.size());
1813
1814 for (unsigned int node_counter=0; node_counter<n_node; node_counter++)
1815 {
1816 auto & array = bf_map[node_ids[node_counter]];
1817 array[var] = node_value[node_counter];
1818 }
1819 } // end for (var)
1820 } // end for (i)
1821 } // end if processor 0
1822
1823 // Distribute the basis function information to the processors that require it
1824 this->node_distribute_bfs(sys);
1825}
void node_distribute_bfs(const System &sys)
Same as distribute_bfs() except for node data.

References _local_node_eim_basis_functions, libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::DECODE, libMesh::index_range(), n_vars, node_distribute_bfs(), libMesh::Parallel::Communicator::rank(), and libMesh::READ.

Referenced by read_in_basis_functions().

◆ read_in_side_basis_functions()

void RBEIMEvaluation::read_in_side_basis_functions ( const System sys,
const std::string &  directory_name,
bool  read_binary_basis_functions 
)
private

Method that reads in element side EIM basis functions.

This may be called by read_in_basis_functions().

Definition at line 1638 of file rb_eim_evaluation.C.

1642{
1643 LOG_SCOPE("read_in_basis_functions()", "RBEIMEvaluation");
1644
1645 // Read values on processor 0 only.
1646 if (sys.comm().rank() == 0)
1647 {
1648 // Create filename
1649 std::ostringstream file_name;
1650 const std::string basis_function_suffix = (read_binary_basis_functions ? ".xdr" : ".dat");
1651 file_name << directory_name << "/" << "bf_data" << basis_function_suffix;
1652
1653 // Create XDR reader object
1654 Xdr xdr(file_name.str(), read_binary_basis_functions ? DECODE : READ);
1655
1656 // Read in the number of basis functions. The comment parameter
1657 // is ignored when reading.
1658 std::size_t n_bf;
1659 xdr.data(n_bf);
1660
1661 // Read in the number of elements
1662 std::size_t n_elem_side;
1663 xdr.data(n_elem_side);
1664
1665 // Read in the number of variables.
1666 std::size_t n_vars;
1667 xdr.data(n_vars);
1668
1669 std::vector<unsigned int> elem_ids(n_elem_side);
1670 xdr.data(elem_ids);
1671 std::vector<unsigned int> side_indices(n_elem_side);
1672 xdr.data(side_indices);
1673
1674 // Read in vector containing the number of QPs per elem. We can
1675 // create this vector with the required size or let it be read
1676 // from the file and sized for us.
1677 std::vector<unsigned int> n_qp_per_elem_side(n_elem_side);
1678 xdr.data(n_qp_per_elem_side);
1679
1680 // The total amount of qp data for each var is the sum of the
1681 // entries in the "n_qp_per_elem" array.
1682 auto n_qp_data =
1683 std::accumulate(n_qp_per_elem_side.begin(),
1684 n_qp_per_elem_side.end(),
1685 0u);
1686
1687 // Allocate space to store all required basis functions,
1688 // clearing any data that may have been there previously.
1692 for (std::size_t elem_side_idx=0; elem_side_idx<n_elem_side; ++elem_side_idx)
1693 {
1694 unsigned int elem_id = elem_ids[elem_side_idx];
1695 unsigned int side_index = side_indices[elem_side_idx];
1696 auto elem_side_pair = std::make_pair(elem_id, side_index);
1697
1698 auto & array = _local_side_eim_basis_functions[i][elem_side_pair];
1699 array.resize(n_vars);
1700 }
1701
1702 // Allocate temporary storage for one var's worth of qp data.
1703 std::vector<Number> qp_data;
1704
1705 // Read in data for each basis function
1707 {
1708 // Reference to the data map for the current basis function.
1709 auto & bf_map = _local_side_eim_basis_functions[i];
1710
1711 for (std::size_t var=0; var<n_vars; ++var)
1712 {
1713 qp_data.clear();
1714 qp_data.resize(n_qp_data);
1715
1716 // Read data using data_stream() since that is
1717 // (currently) how we write it out. The "line_break"
1718 // parameter of data_stream() is ignored while reading.
1719 xdr.data_stream(qp_data.data(), qp_data.size());
1720
1721 // Iterate over the qp_data vector, filling in the
1722 // "small" vectors for each Elem.
1723 auto cursor = qp_data.begin();
1724 for (std::size_t elem_side_idx=0; elem_side_idx<n_elem_side; ++elem_side_idx)
1725 {
1726 unsigned int elem_id = elem_ids[elem_side_idx];
1727 unsigned int side_index = side_indices[elem_side_idx];
1728 auto elem_side_pair = std::make_pair(elem_id, side_index);
1729
1730 // Get reference to the [n_vars][n_qp] array for
1731 // this Elem. We assign() into the vector of
1732 // quadrature point values, which allocates space if
1733 // it doesn't already exist.
1734 auto & array = bf_map[elem_side_pair];
1735 array[var].assign(cursor, cursor + n_qp_per_elem_side[elem_side_idx]);
1736 std::advance(cursor, n_qp_per_elem_side[elem_side_idx]);
1737 }
1738 } // end for (var)
1739 } // end for (i)
1740 } // end if processor 0
1741
1742 // Distribute the basis function information to the processors that require it
1743 this->side_distribute_bfs(sys);
1744}
void side_distribute_bfs(const System &sys)
Same as distribute_bfs() except for side data.

References _local_side_eim_basis_functions, libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::DECODE, libMesh::index_range(), n_vars, libMesh::Parallel::Communicator::rank(), libMesh::READ, and side_distribute_bfs().

Referenced by read_in_basis_functions().

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

◆ resize_data_structures()

void RBEIMEvaluation::resize_data_structures ( const unsigned int  Nmax)

◆ scale_components_in_enrichment()

const std::set< unsigned int > & RBEIMEvaluation::scale_components_in_enrichment ( ) const

◆ set_eim_error_indicator_active()

void RBEIMEvaluation::set_eim_error_indicator_active ( bool  is_active)

Activate/decative the error indicator in EIM solves.

We need this option since in some cases (e.g. during EIM training) we do not want to activate the EIM error indicator, whereas in "online solves" we do want to activate it.

Definition at line 3042 of file rb_eim_evaluation.C.

3043{
3044 // We skip setting _is_eim_error_indicator_active in the case that
3045 // we have no parameters, since we do not use the EIM error indicator
3046 // in that case. We also check if the number of interpolation points
3047 // is larger than the number of EIM basis functions, since that is
3048 // also always the case when the error indicator is active.
3051}
virtual bool use_eim_error_indicator() const
Virtual function to indicate if we use the EIM error indicator in this case.
unsigned int get_n_interpolation_points() const
Return the number of interpolation points.

References _is_eim_error_indicator_active, get_n_basis_functions(), get_n_interpolation_points(), libMesh::RBParametrized::get_n_params(), and use_eim_error_indicator().

Referenced by libMesh::RBEIMTheta::evaluate_vec().

◆ set_error_indicator_interpolation_row()

void RBEIMEvaluation::set_error_indicator_interpolation_row ( const DenseVector< Number > &  error_indicator_row)

◆ set_interpolation_matrix_entry()

void RBEIMEvaluation::set_interpolation_matrix_entry ( unsigned int  i,
unsigned int  j,
Number  value 
)

Set entry of the EIM interpolation matrix.

Definition at line 940 of file rb_eim_evaluation.C.

941{
942 libmesh_error_msg_if((i >= _interpolation_matrix.m()) || (j >= _interpolation_matrix.n()),
943 "Error: Invalid matrix indices");
944
946}

References _interpolation_matrix, libMesh::DenseMatrixBase< T >::m(), libMesh::DenseMatrixBase< T >::n(), and value.

Referenced by libMesh::RBDataDeserialization::load_rb_eim_evaluation_data(), and libMesh::RBEIMConstruction::update_eim_matrices().

◆ set_n_basis_functions()

void RBEIMEvaluation::set_n_basis_functions ( unsigned int  n_bfs)

Set the number of basis functions.

Useful when reading in stored data.

Definition at line 330 of file rb_eim_evaluation.C.

331{
332 if (get_parametrized_function().on_mesh_sides())
334 else if (get_parametrized_function().on_mesh_nodes())
336 else
337 _local_eim_basis_functions.resize(n_bfs);
338}

References _local_eim_basis_functions, _local_node_eim_basis_functions, _local_side_eim_basis_functions, and get_parametrized_function().

Referenced by libMesh::RBDataDeserialization::load_rb_eim_evaluation_data().

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

void RBEIMEvaluation::set_parametrized_function ( std::unique_ptr< RBParametrizedFunction pf)

Set the parametrized function that we will approximate using the Empirical Interpolation Method.

This object will take ownership of the unique pointer.

Definition at line 87 of file rb_eim_evaluation.C.

88{
89 _parametrized_function = std::move(pf);
90}

References _parametrized_function.

◆ set_preserve_rb_eim_solutions()

void RBEIMEvaluation::set_preserve_rb_eim_solutions ( bool  preserve_rb_eim_solutions)

Set _preserve_rb_eim_solutions.

Definition at line 953 of file rb_eim_evaluation.C.

954{
955 _preserve_rb_eim_solutions = preserve_rb_eim_solutions;
956}

References _preserve_rb_eim_solutions.

◆ set_rb_eim_solutions()

void RBEIMEvaluation::set_rb_eim_solutions ( const std::vector< DenseVector< Number > > &  rb_eim_solutions)

Set _rb_eim_solutions.

Normally we update _rb_eim_solutions by performing and EIM solve, but in some cases we want to set the EIM solution coefficients elsewhere, so this setter enables us to do that.

Definition at line 667 of file rb_eim_evaluation.C.

668{
669 _rb_eim_solutions = rb_eim_solutions;
670}

References _rb_eim_solutions.

◆ side_decrement_vector()

void RBEIMEvaluation::side_decrement_vector ( SideQpDataMap v,
const DenseVector< Number > &  coeffs 
)

Same as decrement_vector() except for Side data.

Definition at line 366 of file rb_eim_evaluation.C.

368{
369 LOG_SCOPE("side_decrement_vector()", "RBEIMEvaluation");
370
371 libmesh_error_msg_if(get_n_basis_functions() != coeffs.size(),
372 "Error: Number of coefficients should match number of basis functions");
373
374 for (auto & [elem_and_side, v_comp_and_qp] : v)
375 {
376 for (const auto & comp : index_range(v_comp_and_qp))
377 for (unsigned int qp : index_range(v_comp_and_qp[comp]))
379 {
380 // Check that entry (elem_and_side,comp,qp) exists in _local_side_eim_basis_functions so that
381 // we get a clear error message if there is any missing data
382 const auto & basis_comp_and_qp = libmesh_map_find(_local_side_eim_basis_functions[i], elem_and_side);
383
384 libmesh_error_msg_if(comp >= basis_comp_and_qp.size(), "Error: Invalid comp");
385 libmesh_error_msg_if(qp >= basis_comp_and_qp[comp].size(), "Error: Invalid qp");
386
387 v_comp_and_qp[comp][qp] -= coeffs(i) * basis_comp_and_qp[comp][qp];
388 }
389 }
390}

References _local_side_eim_basis_functions, get_n_basis_functions(), libMesh::index_range(), and libMesh::DenseVector< T >::size().

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

◆ side_distribute_bfs()

void RBEIMEvaluation::side_distribute_bfs ( const System sys)
private

Same as distribute_bfs() except for side data.

Definition at line 2520 of file rb_eim_evaluation.C.

2521{
2522 // So we can avoid calling these many times below
2523 auto n_procs = sys.comm().size();
2524 auto rank = sys.comm().rank();
2525
2526 // In serial there's nothing to distribute
2527 if (n_procs == 1)
2528 return;
2529
2530 // Broadcast the number of basis functions from proc 0. After
2531 // distributing, all procs should have the same number of basis
2532 // functions.
2533 auto n_bf = _local_side_eim_basis_functions.size();
2534 sys.comm().broadcast(n_bf);
2535
2536 // Allocate enough space to store n_bf basis functions on non-zero ranks
2537 if (rank != 0)
2539
2540 // Broadcast the number of variables from proc 0. After
2541 // distributing, all procs should have the same number of variables.
2542 auto n_vars = _local_side_eim_basis_functions[0].begin()->second.size();
2543 sys.comm().broadcast(n_vars);
2544
2545 const std::set<boundary_id_type> & parametrized_function_boundary_ids =
2547
2548 // Construct lists of elem ids owned by different processors
2549 const MeshBase & mesh = sys.get_mesh();
2550
2551 // BoundaryInfo and related data structures
2552 const auto & binfo = mesh.get_boundary_info();
2553 std::vector<boundary_id_type> side_boundary_ids;
2554
2555 std::vector<dof_id_type> gathered_local_elem_ids;
2556 std::vector<dof_id_type> gathered_local_side_indices;
2557 for (const auto & elem : mesh.active_local_element_ptr_range())
2558 {
2559 for (unsigned int side = 0; side != elem->n_sides(); ++side)
2560 {
2561 // skip non-boundary elements
2562 if (!elem->neighbor_ptr(side))
2563 {
2564 binfo.boundary_ids(elem, side, side_boundary_ids);
2565
2566 bool has_side_boundary_id = false;
2567 for (boundary_id_type side_boundary_id : side_boundary_ids)
2568 if (parametrized_function_boundary_ids.count(side_boundary_id))
2569 {
2570 has_side_boundary_id = true;
2571 break;
2572 }
2573
2574 if (has_side_boundary_id)
2575 {
2576 gathered_local_elem_ids.push_back(elem->id());
2577 gathered_local_side_indices.push_back(side);
2578 }
2579 }
2580 }
2581
2582 // In the case of 2D elements, we also check the shellfaces
2583 if (elem->dim() == 2)
2584 for (unsigned int shellface_index=0; shellface_index<2; shellface_index++)
2585 {
2586 binfo.shellface_boundary_ids(elem, shellface_index, side_boundary_ids);
2587
2588 bool has_side_boundary_id = false;
2589 for (boundary_id_type side_boundary_id : side_boundary_ids)
2590 if (parametrized_function_boundary_ids.count(side_boundary_id))
2591 {
2592 has_side_boundary_id = true;
2593 break;
2594 }
2595
2596 if (has_side_boundary_id)
2597 {
2598 // We use shellface_index as the side_index since shellface boundary conditions
2599 // are stored separately from side boundary conditions in BoundaryInfo.
2600 gathered_local_elem_ids.push_back(elem->id());
2601 gathered_local_side_indices.push_back(shellface_index);
2602 }
2603 }
2604 }
2605
2606 // Gather the number of local elems from all procs to proc 0
2607 auto n_local_elems = gathered_local_elem_ids.size();
2608 std::vector<std::size_t> gathered_n_local_elems = {n_local_elems};
2609 sys.comm().gather(/*root_id=*/0, gathered_n_local_elems);
2610
2611 // Gather the (elem,side) owned by each processor onto processor 0.
2612 sys.comm().gather(/*root_id=*/0, gathered_local_elem_ids);
2613 sys.comm().gather(/*root_id=*/0, gathered_local_side_indices);
2614
2615 // Construct vectors of "start" and "one-past-the-end" indices into
2616 // the gathered_local_elem_ids vector for each proc. Only valid on
2617 // processor 0.
2618 std::vector<std::size_t> start_elem_ids_index, end_elem_ids_index;
2619
2620 if (rank == 0)
2621 {
2622 start_elem_ids_index.resize(n_procs);
2623 start_elem_ids_index[0] = 0;
2624 for (processor_id_type p=1; p<n_procs; ++p)
2625 start_elem_ids_index[p] = start_elem_ids_index[p-1] + gathered_n_local_elems[p-1];
2626
2627 end_elem_ids_index.resize(n_procs);
2628 end_elem_ids_index[n_procs - 1] = gathered_local_elem_ids.size();
2629 for (processor_id_type p=0; p<n_procs - 1; ++p)
2630 end_elem_ids_index[p] = start_elem_ids_index[p+1];
2631 }
2632
2633 // On processor 0, using basis function 0 and variable 0, prepare a
2634 // vector with the number of qps per Elem. Then scatter this vector
2635 // out to the processors that require it. The order of this vector
2636 // matches the gathered_local_elem_ids ordering. The counts will be
2637 // gathered_n_local_elems, since there will be one qp count per Elem.
2638 std::vector<unsigned int> n_qp_per_elem_data;
2639
2640 // On rank 0, the "counts" vector holds the number of floating point values that
2641 // are to be scattered to each proc. It is only required on proc 0.
2642 std::vector<int> counts;
2643
2644 if (rank == 0)
2645 {
2646 n_qp_per_elem_data.reserve(gathered_local_elem_ids.size());
2647 counts.resize(n_procs);
2648
2649 auto & bf_map = _local_side_eim_basis_functions[0];
2650
2651 for (processor_id_type p=0; p<n_procs; ++p)
2652 {
2653 for (auto e : make_range(start_elem_ids_index[p], end_elem_ids_index[p]))
2654 {
2655 auto elem_id = gathered_local_elem_ids[e];
2656 auto side_index = gathered_local_side_indices[e];
2657
2658 // Get reference to array[n_vars][n_qp] for current Elem.
2659 // Throws an error if the required elem_id is not found.
2660 const auto & array = libmesh_map_find(bf_map, std::make_pair(elem_id, side_index));
2661
2662 auto n_qps = array[0].size();
2663
2664 // We use var==0 to set the number of qps for all vars
2665 n_qp_per_elem_data.push_back(n_qps);
2666
2667 // Accumulate the count for this proc
2668 counts[p] += n_qps;
2669 } // end for (e)
2670 } // end for proc_id
2671 } // if (rank == 0)
2672
2673 // Now scatter the n_qp_per_elem_data to all procs (must call the
2674 // scatter on all procs, it is a collective).
2675 {
2676 std::vector<unsigned int> recv;
2677 std::vector<int> tmp(gathered_n_local_elems.begin(), gathered_n_local_elems.end());
2678 sys.comm().scatter(n_qp_per_elem_data, tmp, recv, /*root_id=*/0);
2679
2680 // Now swap n_qp_per_elem_data and recv. All processors now have a
2681 // vector of length n_local_elems containing the number of
2682 // quadarature points per Elem.
2683 n_qp_per_elem_data.swap(recv);
2684 }
2685
2686 // For each basis function and each variable, build a vector
2687 // of qp data in the Elem ordering given by the
2688 // gathered_local_elem_ids, then call
2689 //
2690 // sys.comm().scatter(data, counts, recv, /*root_id=*/0);
2691 std::vector<std::vector<Number>> qp_data(n_vars);
2692 if (rank == 0)
2693 {
2694 // The total amount of qp data is given by summing the entries
2695 // of the "counts" vector.
2696 auto n_qp_data =
2697 std::accumulate(counts.begin(), counts.end(), 0u);
2698
2699 // On processor 0, reserve enough space to hold all the qp
2700 // data for a single basis function for each var.
2701 for (auto var : index_range(qp_data))
2702 qp_data[var].reserve(n_qp_data);
2703 }
2704
2705 // The recv_qp_data vector will be used on the receiving end of all
2706 // the scatters below.
2707 std::vector<Number> recv_qp_data;
2708
2709 // Loop from 0..n_bf on _all_ procs, since the scatters inside this
2710 // loop are collective.
2711 for (auto bf : make_range(n_bf))
2712 {
2713 // Prepare data for scattering (only on proc 0)
2714 if (rank == 0)
2715 {
2716 // Reference to the data map for the current basis function.
2717 auto & bf_map = _local_side_eim_basis_functions[bf];
2718
2719 // Clear any data from previous bf
2720 for (auto var : index_range(qp_data))
2721 qp_data[var].clear();
2722
2723 for (processor_id_type p=0; p<n_procs; ++p)
2724 {
2725 for (auto e : make_range(start_elem_ids_index[p], end_elem_ids_index[p]))
2726 {
2727 auto elem_id = gathered_local_elem_ids[e];
2728 auto side_index = gathered_local_side_indices[e];
2729
2730 // Get reference to array[n_vars][n_qp] for current Elem.
2731 // Throws an error if the required (elem,side) is not found.
2732 const auto & array = libmesh_map_find(bf_map, std::make_pair(elem_id, side_index));
2733
2734 for (auto var : index_range(array))
2735 {
2736 // Insert all qp values for this var
2737 qp_data[var].insert(/*insert at*/qp_data[var].end(),
2738 /*data start*/array[var].begin(),
2739 /*data end*/array[var].end());
2740 } // end for (var)
2741 } // end for (e)
2742 } // end for proc_id
2743 } // end if rank==0
2744
2745 // Perform the scatters (all procs)
2746 for (auto var : make_range(n_vars))
2747 {
2748 // Do the scatter for the current var
2749 sys.comm().scatter(qp_data[var], counts, recv_qp_data, /*root_id=*/0);
2750
2751 if (rank != 0)
2752 {
2753 // Store the scattered data we received in _local_side_eim_basis_functions[bf]
2754 auto & bf_map = _local_side_eim_basis_functions[bf];
2755 auto cursor = recv_qp_data.begin();
2756
2757 for (auto i : index_range(gathered_local_elem_ids))
2758 {
2759 auto elem_id = gathered_local_elem_ids[i];
2760 auto side_index = gathered_local_side_indices[i];
2761 auto n_qp_this_elem = n_qp_per_elem_data[i];
2762 auto & array = bf_map[std::make_pair(elem_id, side_index)];
2763
2764 // Create space to store the data if it doesn't already exist.
2765 if (array.empty())
2766 array.resize(n_vars);
2767
2768 array[var].assign(cursor, cursor + n_qp_this_elem);
2769 std::advance(cursor, n_qp_this_elem);
2770 }
2771 } // if (rank != 0)
2772 } // end for (var)
2773 } // end for (bf)
2774
2775 // Now that the scattering is done, delete non-local Elem
2776 // information from processor 0's _local_side_eim_basis_functions data
2777 // structure.
2778 if (rank == 0)
2779 {
2780 for (processor_id_type p=1; p<n_procs; ++p)
2781 {
2782 for (auto e : make_range(start_elem_ids_index[p], end_elem_ids_index[p]))
2783 {
2784 auto elem_id = gathered_local_elem_ids[e];
2785 auto side_index = gathered_local_side_indices[e];
2786
2787 // Delete this Elem's information from every basis function.
2788 for (auto & bf_map : _local_side_eim_basis_functions)
2789 bf_map.erase(std::make_pair(elem_id, side_index));
2790 } // end for (e)
2791 } // end for proc_id
2792 } // if (rank == 0)
2793}

References _local_side_eim_basis_functions, libMesh::BoundaryInfo::boundary_ids(), libMesh::Parallel::Communicator::broadcast(), clear(), libMesh::ParallelObject::comm(), libMesh::Parallel::Communicator::gather(), libMesh::MeshBase::get_boundary_info(), libMesh::System::get_mesh(), get_parametrized_function(), libMesh::RBParametrizedFunction::get_parametrized_function_boundary_ids(), libMesh::index_range(), libMesh::make_range(), mesh, n_vars, libMesh::Parallel::Communicator::rank(), libMesh::Parallel::Communicator::scatter(), and libMesh::Parallel::Communicator::size().

Referenced by read_in_side_basis_functions().

◆ side_gather_bfs()

void RBEIMEvaluation::side_gather_bfs ( )
private

Same as gather_bfs() except for side data.

Definition at line 2026 of file rb_eim_evaluation.C.

2027{
2028 // We need to gather _local_side_eim_basis_functions data from other
2029 // procs for printing.
2030 //
2031 // Ideally, this could be accomplished by simply calling:
2032 // this->comm().gather(/*root_id=*/0, _local_side_eim_basis_functions);
2033 //
2034 // but the data structure seems to be too complicated for this to
2035 // work automatically. (I get some error about the function called
2036 // being "private within this context".) Therefore, we have to
2037 // gather the information manually.
2038
2039 // So we can avoid calling this many times below
2040 auto n_procs = this->n_processors();
2041
2042 // In serial there's nothing to gather
2043 if (n_procs == 1)
2044 return;
2045
2046 // Current assumption is that the number of basis functions stored on
2047 // each processor is the same, the only thing that differs is the number
2048 // of elements, so make sure that is the case now.
2049 auto n_bf = _local_side_eim_basis_functions.size();
2050 libmesh_assert(this->comm().verify(n_bf));
2051
2052 // This function should never be called if there are no basis
2053 // functions, so if it was, something went wrong.
2054 libmesh_error_msg_if(!n_bf, "SideRBEIMEvaluation::gather_bfs() should not be called with 0 basis functions.");
2055
2056 // The number of variables should be the same on all processors
2057 // and we can get this from _local_side_eim_basis_functions. However,
2058 // it may be that some processors have no local elements, so on
2059 // those processors we cannot look up the size from
2060 // _local_side_eim_basis_functions. As a result we use comm().max(n_vars)
2061 // to make sure all processors agree on the final value.
2062 std::size_t n_vars =
2063 _local_side_eim_basis_functions[0].empty() ? 0 : _local_side_eim_basis_functions[0].begin()->second.size();
2064 this->comm().max(n_vars);
2065
2066 // Gather list of (elem,side) pairs stored on each processor to proc 0. We
2067 // use basis function 0 as an example and assume all the basis
2068 // functions are distributed similarly.
2069 std::vector<std::pair<dof_id_type,unsigned int>> elem_side_pairs;
2070 elem_side_pairs.reserve(_local_side_eim_basis_functions[0].size());
2071 for (const auto & pr : _local_side_eim_basis_functions[0])
2072 elem_side_pairs.push_back(pr.first);
2073 this->comm().gather(/*root_id=*/0, elem_side_pairs);
2074
2075 // Store the number of qps per Elem on this processor. Again, use
2076 // basis function 0 (and variable 0) to get this information, then
2077 // apply it to all basis functions.
2078 std::vector<unsigned int> n_qp_per_elem_side;
2079 n_qp_per_elem_side.reserve(_local_side_eim_basis_functions[0].size());
2080 for (const auto & pr : _local_side_eim_basis_functions[0])
2081 {
2082 // array[n_vars][n_qp] per (elem,side). We get the number of QPs
2083 // for variable 0, assuming they are all the same.
2084 const auto & array = pr.second;
2085 n_qp_per_elem_side.push_back(array[0].size());
2086 }
2087
2088 // Before gathering, compute the total amount of local qp data for
2089 // each var, which is the sum of the entries in the "n_qp_per_elem_side" array.
2090 // This will be used to reserve space in a vector below.
2091 auto n_local_qp_data =
2092 std::accumulate(n_qp_per_elem_side.begin(),
2093 n_qp_per_elem_side.end(),
2094 0u);
2095
2096 // Gather the number of qps per Elem for each processor onto processor 0.
2097 this->comm().gather(/*root_id=*/0, n_qp_per_elem_side);
2098
2099 // Sanity check: On processor 0, this checks that we have gathered the same number
2100 // of (elem,side) pairs and qp counts.
2101 libmesh_error_msg_if(elem_side_pairs.size() != n_qp_per_elem_side.size(),
2102 "Must gather same number of Elem ids as qps per Elem.");
2103
2104 // Reserve space to store contiguous vectors of qp data for each var
2105 std::vector<std::vector<Number>> gathered_qp_data(n_vars);
2106 for (auto var : index_range(gathered_qp_data))
2107 gathered_qp_data[var].reserve(n_local_qp_data);
2108
2109 // Now we construct a vector for each basis function, for each
2110 // variable, which is ordered according to:
2111 // [ [qp vals for Elem 0], [qp vals for Elem 1], ... [qp vals for Elem N] ]
2112 // and gather it to processor 0.
2114 {
2115 // Clear any data from previous bf
2116 for (auto var : index_range(gathered_qp_data))
2117 gathered_qp_data[var].clear();
2118
2119 for (const auto & pr : _local_side_eim_basis_functions[bf])
2120 {
2121 // array[n_vars][n_qp] per (elem,side) pair
2122 const auto & array = pr.second;
2123 for (auto var : index_range(array))
2124 {
2125 // Insert all qp values for this var
2126 gathered_qp_data[var].insert(/*insert at*/gathered_qp_data[var].end(),
2127 /*data start*/array[var].begin(),
2128 /*data end*/array[var].end());
2129 }
2130 }
2131
2132 // Reference to the data map for the current basis function.
2133 auto & bf_map = _local_side_eim_basis_functions[bf];
2134
2135 for (auto var : index_range(gathered_qp_data))
2136 {
2137 // For each var, gather gathered_qp_data[var] onto processor
2138 // 0. There apparently is not a gather overload for
2139 // vector-of-vectors...
2140 this->comm().gather(/*root_id=*/0, gathered_qp_data[var]);
2141
2142 // On processor 0, iterate over the gathered_qp_data[var]
2143 // vector we just gathered, filling in the "small" vectors
2144 // for each Elem. Note: here we ignore the fact that we
2145 // already have the data on processor 0 and just overwrite
2146 // it, this makes the indexing logic a bit simpler.
2147 if (this->processor_id() == 0)
2148 {
2149 auto cursor = gathered_qp_data[var].begin();
2150 for (auto i : index_range(elem_side_pairs))
2151 {
2152 auto elem_side_pair = elem_side_pairs[i];
2153 auto n_qp_this_elem_side = n_qp_per_elem_side[i];
2154
2155 // Get reference to the [n_vars][n_qp] array for
2156 // this Elem. We assign() into the vector of
2157 // quadrature point values, which allocates space if
2158 // it doesn't already exist.
2159 auto & array = bf_map[elem_side_pair];
2160
2161 // Possibly allocate space if this is data for a new
2162 // element we haven't seen before.
2163 if (array.empty())
2164 array.resize(n_vars);
2165
2166 array[var].assign(cursor, cursor + n_qp_this_elem_side);
2167 std::advance(cursor, n_qp_this_elem_side);
2168 }
2169 }
2170 }
2171 } // end loop over basis functions
2172}

References _local_side_eim_basis_functions, clear(), libMesh::ParallelObject::comm(), libMesh::Parallel::Communicator::gather(), libMesh::index_range(), libMesh::libmesh_assert(), libMesh::Parallel::Communicator::max(), libMesh::ParallelObject::n_processors(), n_vars, and libMesh::ParallelObject::processor_id().

Referenced by write_out_side_basis_functions().

◆ use_eim_error_indicator()

bool RBEIMEvaluation::use_eim_error_indicator ( ) const
virtual

Virtual function to indicate if we use the EIM error indicator in this case.

This indicates if we will generate the data during the Offline training for the EIM error indicator. In EIM solves, the error indicator will only be used if set_eim_error_indicator_active() is set to true, since we want to be able to enable or disable the error indicator depending on the type of solve we are doing (e.g. EIM solves during training do not need the error indicator).

Definition at line 3035 of file rb_eim_evaluation.C.

3036{
3037 // Return false by default, but we override this in subclasses
3038 // for cases where we want to use the error indicator.
3039 return false;
3040}

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder(), libMesh::RBEIMConstruction::reinit_eim_projection_matrix(), set_eim_error_indicator_active(), libMesh::RBEIMConstruction::train_eim_approximation_with_greedy(), and libMesh::RBEIMConstruction::train_eim_approximation_with_POD().

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

void RBEIMEvaluation::write_out_basis_functions ( const std::string &  directory_name = "offline_data",
bool  write_binary_basis_functions = true 
)

Write out all the basis functions to file.

sys is used for file IO directory_name specifies which directory to write files to read_binary_basis_functions indicates whether to write binary or ASCII data

Note: this is not currently a virtual function and is not related to the RBEvaluation function of the same name.

Definition at line 1088 of file rb_eim_evaluation.C.

1091{
1092 LOG_SCOPE("write_out_basis_functions()", "RBEIMEvaluation");
1093
1094 if (get_parametrized_function().on_mesh_sides())
1095 write_out_side_basis_functions(directory_name, write_binary_basis_functions);
1096 else if (get_parametrized_function().on_mesh_nodes())
1097 write_out_node_basis_functions(directory_name, write_binary_basis_functions);
1098 else
1099 write_out_interior_basis_functions(directory_name, write_binary_basis_functions);
1100}
void write_out_interior_basis_functions(const std::string &directory_name, bool write_binary_basis_functions)
Method that writes out element interior EIM basis functions.
void write_out_node_basis_functions(const std::string &directory_name, bool write_binary_basis_functions)
Method that writes out element node EIM basis functions.
void write_out_side_basis_functions(const std::string &directory_name, bool write_binary_basis_functions)
Method that writes out element side EIM basis functions.

References get_parametrized_function(), write_out_interior_basis_functions(), write_out_node_basis_functions(), and write_out_side_basis_functions().

◆ write_out_interior_basis_functions()

void RBEIMEvaluation::write_out_interior_basis_functions ( const std::string &  directory_name,
bool  write_binary_basis_functions 
)
private

Method that writes out element interior EIM basis functions.

This may be called by write_out_basis_functions().

Definition at line 1102 of file rb_eim_evaluation.C.

1105{
1106 LOG_SCOPE("write_out_interior_basis_functions()", "RBEIMEvaluation");
1107
1108 // Quick return if there is no work to do. Note: make sure all procs
1109 // agree there is no work to do.
1110 bool is_empty = _local_eim_basis_functions.empty();
1111 libmesh_assert(this->comm().verify(is_empty));
1112
1113 if (is_empty)
1114 return;
1115
1116 // Gather basis function data from other procs, storing it in
1117 // _local_eim_basis_functions, so that we can then print everything
1118 // from processor 0.
1119 this->gather_bfs();
1120
1121 // Write values from processor 0 only.
1122 if (this->processor_id() == 0)
1123 {
1124 std::vector<unsigned int> n_qp_per_elem;
1125 auto interior_basis_function_sizes =
1126 get_interior_basis_function_sizes(n_qp_per_elem);
1127
1128 // Make a directory to store all the data files
1129 Utility::mkdir(directory_name.c_str());
1130
1131 // Create filename
1132 std::ostringstream file_name;
1133 const std::string basis_function_suffix = (write_binary_basis_functions ? ".xdr" : ".dat");
1134 file_name << directory_name << "/" << "bf_data" << basis_function_suffix;
1135
1136 // Create XDR writer object
1137 Xdr xdr(file_name.str(), write_binary_basis_functions ? ENCODE : WRITE);
1138
1139 // Write number of basis functions to file. Note: the
1140 // Xdr::data() function takes non-const references, so you can't
1141 // pass e.g. vec.size() to that interface.
1142 auto n_bf = libmesh_map_find(interior_basis_function_sizes,"n_bf");
1143 xdr.data(n_bf, "# Number of basis functions");
1144
1145 // We assume that each basis function has data for the same
1146 // number of elements as basis function 0, which is equal to the
1147 // size of the map.
1148 auto n_elem = libmesh_map_find(interior_basis_function_sizes,"n_elem");
1149 xdr.data(n_elem, "# Number of elements");
1150
1151 // We assume that each element has the same number of variables,
1152 // and we get the number of vars from the first element of the
1153 // first basis function.
1154 auto n_vars = libmesh_map_find(interior_basis_function_sizes,"n_vars");
1155 xdr.data(n_vars, "# Number of variables");
1156
1157 // We assume that the list of elements for each basis function
1158 // is the same as basis function 0. We also assume that all vars
1159 // have the same number of qps.
1160 xdr.data(n_qp_per_elem, "# Number of QPs per Elem");
1161
1162 // The total amount of qp data for each var is the sum of the
1163 // entries in the "n_qp_per_elem" array.
1164 auto n_qp_data = libmesh_map_find(interior_basis_function_sizes,"n_qp_data");
1165
1166 // Now we construct a vector for each basis function, for each
1167 // variable which is ordered according to:
1168 // [ [qp vals for Elem 0], [qp vals for Elem 1], ... [qp vals for Elem N] ]
1169 // and write it to file.
1170 for (auto bf_index : index_range(_local_eim_basis_functions))
1171 {
1172 auto qp_data = get_interior_basis_function_as_vec_helper(n_vars, n_qp_data, bf_index);
1173
1174 // Write all the var values for this bf
1175 for (auto var : index_range(qp_data))
1176 xdr.data_stream(qp_data[var].data(), qp_data[var].size(), /*line_break=*/qp_data[var].size());
1177 }
1178 }
1179}
int mkdir(const char *pathname)
Create a directory.
Definition utility.C:152

References _local_eim_basis_functions, libMesh::ParallelObject::comm(), libMesh::ENCODE, gather_bfs(), get_interior_basis_function_as_vec_helper(), get_interior_basis_function_sizes(), libMesh::index_range(), libMesh::libmesh_assert(), libMesh::Utility::mkdir(), n_vars, libMesh::ParallelObject::processor_id(), and libMesh::WRITE.

Referenced by write_out_basis_functions().

◆ write_out_node_basis_functions()

void RBEIMEvaluation::write_out_node_basis_functions ( const std::string &  directory_name,
bool  write_binary_basis_functions 
)
private

Method that writes out element node EIM basis functions.

This may be called by write_out_basis_functions().

Definition at line 1425 of file rb_eim_evaluation.C.

1428{
1429 LOG_SCOPE("write_out_node_basis_functions()", "RBEIMEvaluation");
1430
1431 // Quick return if there is no work to do. Note: make sure all procs
1432 // agree there is no work to do.
1433 bool is_empty = _local_node_eim_basis_functions.empty();
1434 libmesh_assert(this->comm().verify(is_empty));
1435
1436 if (is_empty)
1437 return;
1438
1439 // Gather basis function data from other procs, storing it in
1440 // _local_node_eim_basis_functions, so that we can then print everything
1441 // from processor 0.
1442 this->node_gather_bfs();
1443
1444 // Write values from processor 0 only.
1445 if (this->processor_id() == 0)
1446 {
1447 // Make a directory to store all the data files
1448 Utility::mkdir(directory_name.c_str());
1449
1450 // Create filename
1451 std::ostringstream file_name;
1452 const std::string basis_function_suffix = (write_binary_basis_functions ? ".xdr" : ".dat");
1453 file_name << directory_name << "/" << "bf_data" << basis_function_suffix;
1454
1455 // Create XDR writer object
1456 Xdr xdr(file_name.str(), write_binary_basis_functions ? ENCODE : WRITE);
1457
1458 // Write number of basis functions to file. Note: the
1459 // Xdr::data() function takes non-const references, so you can't
1460 // pass e.g. vec.size() to that interface.
1461 auto n_bf = _local_node_eim_basis_functions.size();
1462 xdr.data(n_bf, "# Number of basis functions");
1463
1464 // We assume that each basis function has data for the same
1465 // number of elements as basis function 0, which is equal to the
1466 // size of the map.
1467 auto n_node = _local_node_eim_basis_functions[0].size();
1468 xdr.data(n_node, "# Number of nodes");
1469
1470 // We assume that each element has the same number of variables,
1471 // and we get the number of vars from the first element of the
1472 // first basis function.
1473 auto n_vars = _local_node_eim_basis_functions[0].begin()->second.size();
1474 xdr.data(n_vars, "# Number of variables");
1475
1476 // We write out the following arrays:
1477 // - node IDs
1478 std::vector<unsigned int> node_ids;
1479 node_ids.reserve(n_node);
1480 for (const auto & pr : _local_node_eim_basis_functions[0])
1481 {
1482 node_ids.push_back(pr.first);
1483 }
1484 xdr.data(node_ids, "# Node IDs");
1485
1486 // Now we construct a vector for each basis function, for each
1487 // variable which is ordered according to:
1488 // [ [val for Node 0], [val for Node 1], ... [val for Node N] ]
1489 // and write it to file.
1490
1491 std::vector<std::vector<Number>> var_data(n_vars);
1492 for (unsigned int var=0; var<n_vars; var++)
1493 var_data[var].resize(n_node);
1494
1496 {
1497 unsigned int node_counter = 0;
1498 for (const auto & pr : _local_node_eim_basis_functions[bf])
1499 {
1500 // array[n_vars] per Node
1501 const auto & array = pr.second;
1502 for (auto var : index_range(array))
1503 {
1504 // Based on the error check above, we know that node_id is numbered
1505 // contiguously from [0..nodes], so we can use it as the vector
1506 // index here.
1507 var_data[var][node_counter] = array[var];
1508 }
1509
1510 node_counter++;
1511 }
1512
1513 // Write all the var values for this bf
1514 for (auto var : index_range(var_data))
1515 xdr.data_stream(var_data[var].data(), var_data[var].size(), /*line_break=*/var_data[var].size());
1516 }
1517 }
1518}
void node_gather_bfs()
Same as gather_bfs() except for node data.

References _local_node_eim_basis_functions, libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::ENCODE, libMesh::index_range(), libMesh::libmesh_assert(), libMesh::Utility::mkdir(), n_vars, node_gather_bfs(), libMesh::ParallelObject::processor_id(), and libMesh::WRITE.

Referenced by write_out_basis_functions().

◆ write_out_side_basis_functions()

void RBEIMEvaluation::write_out_side_basis_functions ( const std::string &  directory_name,
bool  write_binary_basis_functions 
)
private

Method that writes out element side EIM basis functions.

This may be called by write_out_basis_functions().

Definition at line 1309 of file rb_eim_evaluation.C.

1312{
1313 LOG_SCOPE("write_out_side_basis_functions()", "RBEIMEvaluation");
1314
1315 // Quick return if there is no work to do. Note: make sure all procs
1316 // agree there is no work to do.
1317 bool is_empty = _local_side_eim_basis_functions.empty();
1318 libmesh_assert(this->comm().verify(is_empty));
1319
1320 if (is_empty)
1321 return;
1322
1323 // Gather basis function data from other procs, storing it in
1324 // _local_side_eim_basis_functions, so that we can then print everything
1325 // from processor 0.
1326 this->side_gather_bfs();
1327
1328 // Write values from processor 0 only.
1329 if (this->processor_id() == 0)
1330 {
1331 // Make a directory to store all the data files
1332 Utility::mkdir(directory_name.c_str());
1333
1334 // Create filename
1335 std::ostringstream file_name;
1336 const std::string basis_function_suffix = (write_binary_basis_functions ? ".xdr" : ".dat");
1337 file_name << directory_name << "/" << "bf_data" << basis_function_suffix;
1338
1339 // Create XDR writer object
1340 Xdr xdr(file_name.str(), write_binary_basis_functions ? ENCODE : WRITE);
1341
1342 // Write number of basis functions to file. Note: the
1343 // Xdr::data() function takes non-const references, so you can't
1344 // pass e.g. vec.size() to that interface.
1345 auto n_bf = _local_side_eim_basis_functions.size();
1346 xdr.data(n_bf, "# Number of basis functions");
1347
1348 // We assume that each basis function has data for the same
1349 // number of (elem,side) pairs as basis function 0, which is equal to the
1350 // size of the map.
1351 auto n_elem = _local_side_eim_basis_functions[0].size();
1352 xdr.data(n_elem, "# Number of (elem,side) pairs");
1353
1354 // We assume that each element has the same number of variables,
1355 // and we get the number of vars from the first element of the
1356 // first basis function.
1357 auto n_vars = _local_side_eim_basis_functions[0].begin()->second.size();
1358 xdr.data(n_vars, "# Number of variables");
1359
1360 // We write out the following arrays:
1361 // - element IDs
1362 // - side indices
1363 // - n_qp_per_elem_side
1364 std::vector<unsigned int> n_qp_per_elem_side;
1365 std::vector<unsigned int> elem_ids;
1366 std::vector<unsigned int> side_indices;
1367 elem_ids.reserve(n_elem);
1368 side_indices.reserve(n_elem);
1369 n_qp_per_elem_side.reserve(n_elem);
1370 for (const auto & [elem_side_pair, array] : _local_side_eim_basis_functions[0])
1371 {
1372 elem_ids.push_back(elem_side_pair.first);
1373 side_indices.push_back(elem_side_pair.second);
1374
1375 // array[n_vars][n_qp] per Elem. We get the number of QPs
1376 // for variable 0, assuming they are all the same.
1377 n_qp_per_elem_side.push_back(array[0].size());
1378 }
1379 xdr.data(elem_ids, "# Elem IDs");
1380 xdr.data(side_indices, "# Side indices");
1381 xdr.data(n_qp_per_elem_side, "# Number of QPs per Elem");
1382
1383 // The total amount of qp data for each var is the sum of the
1384 // entries in the "n_qp_per_elem" array.
1385 auto n_qp_data =
1386 std::accumulate(n_qp_per_elem_side.begin(),
1387 n_qp_per_elem_side.end(),
1388 0u);
1389
1390 // Reserve space to store contiguous vectors of qp data for each var
1391 std::vector<std::vector<Number>> qp_data(n_vars);
1392 for (auto var : index_range(qp_data))
1393 qp_data[var].reserve(n_qp_data);
1394
1395 // Now we construct a vector for each basis function, for each
1396 // variable which is ordered according to:
1397 // [ [qp vals for Elem 0], [qp vals for Elem 1], ... [qp vals for Elem N] ]
1398 // and write it to file.
1400 {
1401 // Clear any data from previous bf
1402 for (auto var : index_range(qp_data))
1403 qp_data[var].clear();
1404
1405 for (const auto & pr : _local_side_eim_basis_functions[bf])
1406 {
1407 // array[n_vars][n_qp] per Elem
1408 const auto & array = pr.second;
1409 for (auto var : index_range(array))
1410 {
1411 // Insert all qp values for this var
1412 qp_data[var].insert(/*insert at*/qp_data[var].end(),
1413 /*data start*/array[var].begin(),
1414 /*data end*/array[var].end());
1415 }
1416 }
1417
1418 // Write all the var values for this bf
1419 for (auto var : index_range(qp_data))
1420 xdr.data_stream(qp_data[var].data(), qp_data[var].size(), /*line_break=*/qp_data[var].size());
1421 }
1422 }
1423}
void side_gather_bfs()
Same as gather_bfs() except for side data.

References _local_side_eim_basis_functions, clear(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::ENCODE, libMesh::index_range(), libMesh::libmesh_assert(), libMesh::Utility::mkdir(), n_vars, libMesh::ParallelObject::processor_id(), side_gather_bfs(), and libMesh::WRITE.

Referenced by write_out_basis_functions().

◆ 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}
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.
unsigned int get_n_continuous_params() const
Get the number of continuous parameters.
bool is_discrete_parameter(const std::string &mu_name) const
Is parameter mu_name discrete?

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

Member Data Documentation

◆ _communicator

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

◆ _counts

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

Actually holds the data.

Definition at line 124 of file reference_counter.h.

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

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

◆ _eim_solutions_for_training_set

std::vector<DenseVector<Number> > libMesh::RBEIMEvaluation::_eim_solutions_for_training_set
private

Storage for EIM solutions from the training set.

This is typically used in the case that we have is_lookup_table==true in our RBParametrizedFunction, since in that case we need to store all the EIM solutions on the training set so that we do not always need to refer to the lookup table itself (since in some cases, like in the Online stage, the lookup table is not available).

Definition at line 828 of file rb_eim_evaluation.h.

Referenced by get_eim_solutions_for_training_set(), get_eim_solutions_for_training_set(), and rb_eim_solves().

◆ _eim_vars_to_project_and_write

std::vector<EIMVarGroupPlottingInfo> libMesh::RBEIMEvaluation::_eim_vars_to_project_and_write
protected

This vector specifies which EIM variables we want to write to disk and/or project to nodes for plotting purposes.

By default this is an empty set, but can be updated in subclasses to specify the EIM variables that are relevant for visualization.

We identify groups of variables with one or more variables in a group. The purpose of using a group is often we plot multiple components of a tensor-valued or vector-valued quantity, so it makes sense to refer to the entire group of variables together in those cases.

Definition at line 740 of file rb_eim_evaluation.h.

Referenced by get_eim_vars_to_project_and_write().

◆ _enable_print_counter

bool libMesh::ReferenceCounter::_enable_print_counter = true
staticprotectedinherited

Flag to control whether reference count information is printed when print_info is called.

Definition at line 143 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().

◆ _error_indicator_interpolation_row

DenseVector<Number> libMesh::RBEIMEvaluation::_error_indicator_interpolation_row
private

Here we store an extra row of the interpolation matrix which is used to compute the EIM error indicator.

This stores the EIM basis function values at the extra point associated with the error indicator.

Definition at line 971 of file rb_eim_evaluation.h.

Referenced by get_eim_error_indicator().

◆ _interpolation_matrix

DenseMatrix<Number> libMesh::RBEIMEvaluation::_interpolation_matrix
private

Dense matrix that stores the lower triangular interpolation matrix that can be used.

Definition at line 843 of file rb_eim_evaluation.h.

Referenced by clear(), get_interpolation_matrix(), rb_eim_solve(), rb_eim_solves(), resize_data_structures(), and set_interpolation_matrix_entry().

◆ _interpolation_points_comp

std::vector<unsigned int> libMesh::RBEIMEvaluation::_interpolation_points_comp
private

In the case of a "vector-valued" EIM, this vector determines which component of the parameterized function we sample at each EIM point.

Definition at line 854 of file rb_eim_evaluation.h.

Referenced by add_interpolation_data(), add_interpolation_points_comp(), add_node_interpolation_data(), add_side_interpolation_data(), clear(), get_interpolation_points_comp(), rb_eim_solves(), and resize_data_structures().

◆ _interpolation_points_spatial_indices

std::vector<std::vector<unsigned int> > libMesh::RBEIMEvaluation::_interpolation_points_spatial_indices
private

Here we store the spatial indices that were initialized by initialize_spatial_indices_at_interp_pts().

These are relevant in the case that _parametrized_function is defined by indexing into separate data based on the mesh-based data.

Definition at line 862 of file rb_eim_evaluation.h.

Referenced by add_interpolation_points_spatial_indices(), clear(), get_interpolation_points_spatial_indices(), get_n_interpolation_points_spatial_indices(), initialize_interpolation_points_spatial_indices(), initialize_param_fn_spatial_indices(), and resize_data_structures().

◆ _is_eim_error_indicator_active

bool libMesh::RBEIMEvaluation::_is_eim_error_indicator_active
private

Indicate if the EIM error indicator is active in RB EIM solves.

Note that this is distinct from use_eim_error_indicator(), since use_eim_error_indicator() indicates if this RBEIMEvaluation has an EIM error indicator defined, whereas _is_eim_error_indicator_active is used to turn on or off the error indicator. This primary purpose of _is_eim_error_indicator_active is to turn the error indicator off during EIM training (when it is not relevant) and to turn it on during "online solves".

Definition at line 964 of file rb_eim_evaluation.h.

Referenced by rb_eim_solves(), and set_eim_error_indicator_active().

◆ _local_eim_basis_functions

std::vector<QpDataMap> libMesh::RBEIMEvaluation::_local_eim_basis_functions
private

The EIM basis functions.

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 general will not start at zero.

Definition at line 886 of file rb_eim_evaluation.h.

Referenced by add_basis_function(), decrement_vector(), distribute_bfs(), gather_bfs(), get_basis_function(), get_eim_basis_function_value(), get_eim_basis_function_values_at_qps(), get_interior_basis_function_as_vec_helper(), get_interior_basis_function_sizes(), get_interior_basis_functions_as_vecs(), get_n_basis_functions(), print_local_eim_basis_functions(), read_in_interior_basis_functions(), set_n_basis_functions(), and write_out_interior_basis_functions().

◆ _local_node_eim_basis_functions

std::vector<NodeDataMap> libMesh::RBEIMEvaluation::_local_node_eim_basis_functions
private

The EIM basis functions on element nodes (e.g.

on a nodeset). We store values at nodes that are local to this processor. The indexing is as follows: basis function index --> node ID --> variable --> value We use a map to index the node ID, since the IDs on this processor in general will not start at zero.

Definition at line 906 of file rb_eim_evaluation.h.

Referenced by add_node_basis_function(), get_eim_basis_function_node_local_value(), get_eim_basis_function_node_value(), get_n_basis_functions(), get_node_basis_function(), node_decrement_vector(), node_distribute_bfs(), node_gather_bfs(), print_local_eim_basis_functions(), read_in_node_basis_functions(), set_n_basis_functions(), and write_out_node_basis_functions().

◆ _local_side_eim_basis_functions

std::vector<SideQpDataMap> libMesh::RBEIMEvaluation::_local_side_eim_basis_functions
private

The EIM basis functions on element sides.

We store values at quadrature points on elements that are local to this processor. The indexing is as follows: basis function index --> (element ID,side index) --> variable --> quadrature point --> value We use a map to index the element ID, since the IDs on this processor in general will not start at zero.

Definition at line 896 of file rb_eim_evaluation.h.

Referenced by add_side_basis_function(), get_eim_basis_function_side_value(), get_eim_basis_function_side_values_at_qps(), get_n_basis_functions(), get_side_basis_function(), print_local_eim_basis_functions(), read_in_side_basis_functions(), set_n_basis_functions(), side_decrement_vector(), side_distribute_bfs(), side_gather_bfs(), and write_out_side_basis_functions().

◆ _mutex

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 137 of file reference_counter.h.

◆ _n_objects

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

◆ _parametrized_function

std::unique_ptr<RBParametrizedFunction> libMesh::RBEIMEvaluation::_parametrized_function
private

Store the parametrized function that will be approximated by this EIM system.

Note that the parametrized function may have more than one component, and each component is approximated by a separate variable in the EIM system.

Definition at line 870 of file rb_eim_evaluation.h.

Referenced by get_parametrized_function(), get_parametrized_function(), and set_parametrized_function().

◆ _preserve_rb_eim_solutions

bool libMesh::RBEIMEvaluation::_preserve_rb_eim_solutions
private

Boolean to indicate if we skip updating _rb_eim_solutions in rb_eim_solves().

This is relevant for cases when we set up _rb_eim_solutions elsewhere and we want to avoid changing it.

Definition at line 953 of file rb_eim_evaluation.h.

Referenced by get_preserve_rb_eim_solutions(), rb_eim_solves(), and set_preserve_rb_eim_solutions().

◆ _rb_eim_error_indicators

std::vector<std::pair<Real,Real> > libMesh::RBEIMEvaluation::_rb_eim_error_indicators
private

If we're using the EIM error indicator, then we store the error indicator values corresponding to _rb_eim_solutions here.

Definition at line 818 of file rb_eim_evaluation.h.

Referenced by get_rb_eim_error_indicators(), and rb_eim_solves().

◆ _rb_eim_solutions

std::vector<DenseVector<Number> > libMesh::RBEIMEvaluation::_rb_eim_solutions
private

The EIM solution coefficients from the most recent call to rb_eim_solves().

Definition at line 812 of file rb_eim_evaluation.h.

Referenced by get_rb_eim_solutions(), get_rb_eim_solutions_entries(), rb_eim_solves(), and set_rb_eim_solutions().

◆ _rb_eim_solves_mus

std::vector<RBParameters> libMesh::RBEIMEvaluation::_rb_eim_solves_mus
private

The parameters and the number of basis functions that were used in the most recent call to rb_eim_solves().

We store this so that we can check if we can skip calling rb_eim_solves() again if the inputs haven't changed.

Definition at line 836 of file rb_eim_evaluation.h.

Referenced by rb_eim_solves().

◆ _rb_eim_solves_N

unsigned int libMesh::RBEIMEvaluation::_rb_eim_solves_N
private

Definition at line 837 of file rb_eim_evaluation.h.

Referenced by rb_eim_solves().

◆ _rb_eim_theta_objects

std::vector<std::unique_ptr<RBTheta> > libMesh::RBEIMEvaluation::_rb_eim_theta_objects
private

The vector of RBTheta objects that are created to point to this RBEIMEvaluation.

Definition at line 876 of file rb_eim_evaluation.h.

Referenced by clear(), get_eim_theta_objects(), and initialize_eim_theta_objects().

◆ _scale_components_in_enrichment

std::set<unsigned int> libMesh::RBEIMEvaluation::_scale_components_in_enrichment
protected

This set that specifies which EIM variables will be scaled during EIM enrichment so that their maximum value matches the maximum value across all variables.

This is helpful in cases where some components are much smaller in magnitude than others, since in those cases if we do not apply component scaling to the small components then the accuracy of the EIM approximation for those components will not be controlled well by the EIM enrichment process.

Definition at line 751 of file rb_eim_evaluation.h.

Referenced by scale_components_in_enrichment().

◆ _vec_eval_input

VectorizedEvalInput libMesh::RBEIMEvaluation::_vec_eval_input
private

We store the EIM interpolation point data in this object.

Definition at line 848 of file rb_eim_evaluation.h.

Referenced by add_elem_center_dxyzdeta(), add_elem_center_dxyzdxi(), add_elem_id_local_index_map_entry(), add_interpolation_data(), add_interpolation_points_boundary_id(), add_interpolation_points_elem_id(), add_interpolation_points_elem_type(), add_interpolation_points_JxW_all_qp(), add_interpolation_points_node_id(), add_interpolation_points_phi_i_all_qp(), add_interpolation_points_phi_i_qp(), add_interpolation_points_qp(), add_interpolation_points_qrule_order(), add_interpolation_points_side_index(), add_interpolation_points_subdomain_id(), add_interpolation_points_xyz(), add_interpolation_points_xyz_perturbations(), add_node_interpolation_data(), add_rb_property_map_entry(), add_side_interpolation_data(), clear(), get_elem_center_dxyzdeta(), get_elem_center_dxyzdxi(), get_elem_id_to_local_index_map(), get_interpolation_points_boundary_id(), get_interpolation_points_elem_id(), get_interpolation_points_elem_type(), get_interpolation_points_JxW_all_qp(), get_interpolation_points_node_id(), get_interpolation_points_phi_i_all_qp(), get_interpolation_points_phi_i_qp(), get_interpolation_points_qp(), get_interpolation_points_qrule_order(), get_interpolation_points_side_index(), get_interpolation_points_subdomain_id(), get_interpolation_points_xyz(), get_interpolation_points_xyz_perturbations(), get_n_elems(), get_n_interpolation_points(), get_n_properties(), get_rb_property_map(), get_vec_eval_input(), initialize_interpolation_points_spatial_indices(), initialize_param_fn_spatial_indices(), initialize_rb_property_map(), rb_eim_solves(), and resize_data_structures().

◆ eim_error_indicator_normalization

EimErrorIndicatorNormalization libMesh::RBEIMEvaluation::eim_error_indicator_normalization

Definition at line 717 of file rb_eim_evaluation.h.

Referenced by get_eim_error_indicator().

◆ limit_eim_error_indicator_to_one

bool libMesh::RBEIMEvaluation::limit_eim_error_indicator_to_one

If this boolean is true then we clamp EIM error indicator values to be at most 1.

This is often desirable since we typically think of the error indicator as a percentage, and a value of 1 means 100% error. We set this to true by default.

Definition at line 725 of file rb_eim_evaluation.h.

Referenced by get_eim_error_indicator().

◆ parameters

RBParameters libMesh::RBParametrized::parameters
privateinherited

Vector storing the current parameters.

Definition at line 239 of file rb_parametrized.h.

Referenced by libMesh::RBParametrized::clear(), libMesh::RBParametrized::get_parameters(), and libMesh::RBParametrized::set_parameters().

◆ parameters_initialized

bool libMesh::RBParametrized::parameters_initialized
privateinherited

◆ parameters_max

RBParameters libMesh::RBParametrized::parameters_max
privateinherited

◆ parameters_min

RBParameters libMesh::RBParametrized::parameters_min
privateinherited

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