libMesh
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Private Attributes | List of all members
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

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. More...
 
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. More...
 
typedef std::map< dof_id_type, std::vector< Number > > NodeDataMap
 Type of the data structure used to map from (node id) -> [n_vars] data. More...
 

Public Member Functions

 RBEIMEvaluation (const Parallel::Communicator &comm)
 Constructor. More...
 
 RBEIMEvaluation (RBEIMEvaluation &&)=default
 Special functions. More...
 
 RBEIMEvaluation (const RBEIMEvaluation &)=delete
 
RBEIMEvaluationoperator= (const RBEIMEvaluation &)=delete
 
RBEIMEvaluationoperator= (RBEIMEvaluation &&)=default
 
virtual ~RBEIMEvaluation ()
 
virtual void clear () override
 Clear this object. More...
 
void resize_data_structures (const unsigned int Nmax)
 Resize the data structures for storing data associated with this object. More...
 
void set_parametrized_function (std::unique_ptr< RBParametrizedFunction > pf)
 Set the parametrized function that we will approximate using the Empirical Interpolation Method. More...
 
RBParametrizedFunctionget_parametrized_function ()
 Get a reference to the parametrized function. More...
 
const RBParametrizedFunctionget_parametrized_function () const
 Get a const reference to the parametrized function. More...
 
DenseVector< Numberrb_eim_solve (DenseVector< Number > &EIM_rhs)
 Calculate the EIM approximation for the given right-hand side vector EIM_rhs. More...
 
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. More...
 
void initialize_interpolation_points_spatial_indices ()
 Initialize _interpolation_points_spatial_indices. More...
 
void initialize_param_fn_spatial_indices ()
 The Online counterpart of initialize_interpolation_points_spatial_indices(). More...
 
unsigned int get_n_basis_functions () const
 Return the current number of EIM basis functions. More...
 
unsigned int get_n_interpolation_points () const
 Return the number of interpolation points. More...
 
void set_n_basis_functions (unsigned int n_bfs)
 Set the number of basis functions. More...
 
void decrement_vector (QpDataMap &v, const DenseVector< Number > &coeffs)
 Subtract coeffs[i]*basis_function[i] from v. More...
 
void side_decrement_vector (SideQpDataMap &v, const DenseVector< Number > &coeffs)
 Same as decrement_vector() except for Side data. More...
 
void node_decrement_vector (NodeDataMap &v, const DenseVector< Number > &coeffs)
 Same as decrement_vector() except for node data. More...
 
void initialize_eim_theta_objects ()
 Build a vector of RBTheta objects that accesses the components of the RB_solution member variable of this RBEvaluation. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
const QpDataMapget_basis_function (unsigned int i) const
 Get a reference to the i^th basis function. More...
 
const SideQpDataMapget_side_basis_function (unsigned int i) const
 Get a reference to the i^th side basis function. More...
 
const NodeDataMapget_node_basis_function (unsigned int i) const
 Get a reference to the i^th node basis function. More...
 
void set_rb_eim_solutions (const std::vector< DenseVector< Number >> &rb_eim_solutions)
 Set _rb_eim_solutions. More...
 
const std::vector< DenseVector< Number > > & get_rb_eim_solutions () const
 Return the EIM solution coefficients from the most recent call to rb_eim_solves(). More...
 
std::vector< Numberget_rb_eim_solutions_entries (unsigned int index) const
 Return entry index for each solution in _rb_eim_solutions. More...
 
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. More...
 
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. More...
 
const std::vector< Real > & get_rb_eim_error_indicators () const
 Return the EIM error indicator values from the most recent call to rb_eim_solves(). More...
 
void add_interpolation_points_xyz (Point p)
 Set the data associated with EIM interpolation points. More...
 
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_spatial_indices (const std::vector< unsigned int > &spatial_indices)
 
Point get_interpolation_points_xyz (unsigned int index) const
 Get the data associated with EIM interpolation points. More...
 
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
 
const std::vector< unsigned int > & get_interpolation_points_spatial_indices (unsigned int index) 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. More...
 
void set_interpolation_matrix_entry (unsigned int i, unsigned int j, Number value)
 Set entry of the EIM interpolation matrix. More...
 
const DenseMatrix< Number > & get_interpolation_matrix () const
 Get the EIM interpolation matrix. More...
 
void add_basis_function (const QpDataMap &bf)
 Add bf to our EIM basis. More...
 
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)
 Add interpolation data associated with a new basis function. More...
 
void add_side_basis_function (const SideQpDataMap &side_bf)
 Add side_bf to our EIM basis. More...
 
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. More...
 
void add_node_basis_function (const NodeDataMap &node_bf)
 Add node_bf to our EIM basis. More...
 
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. More...
 
void set_preserve_rb_eim_solutions (bool preserve_rb_eim_solutions)
 Set _preserve_rb_eim_solutions. More...
 
bool get_preserve_rb_eim_solutions () const
 Get _preserve_rb_eim_solutions. More...
 
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. More...
 
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. More...
 
void project_qp_data_map_onto_system (System &sys, const QpDataMap &bf_data, unsigned int var)
 Project variable var of bf_data into the solution vector of System. More...
 
const std::set< unsigned int > & get_eim_vars_to_project_and_write () const
 Get _eim_vars_to_project_and_write. More...
 
void write_out_projected_basis_functions (System &sys, const std::string &directory_name="offline_data")
 Project all basis functions using project_qp_data_map_onto_system() and then write out the resulting vectors. More...
 
const std::set< unsigned int > & scale_components_in_enrichment () const
 Get _scale_components_in_enrichment. More...
 
virtual bool use_eim_error_indicator () const
 Virtual function to indicate if we use the EIM error indicator in this case. More...
 
void set_eim_error_indicator_active (bool is_active)
 Activate/decative the error indicator in EIM solves. More...
 
const DenseVector< Number > & get_error_indicator_interpolation_row () const
 Get/set _extra_points_interpolation_matrix. More...
 
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. More...
 
const VectorizedEvalInputget_vec_eval_input () const
 Get the VectorizedEvalInput data. More...
 
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. More...
 
void initialize_parameters (const RBParametrized &rb_parametrized)
 Initialize the parameter ranges and set current_parameters. More...
 
unsigned int get_n_params () const
 Get the number of parameters. More...
 
unsigned int get_n_continuous_params () const
 Get the number of continuous parameters. More...
 
unsigned int get_n_discrete_params () const
 Get the number of discrete parameters. More...
 
std::set< std::string > get_parameter_names () const
 Get a set that stores the parameter names. More...
 
const RBParametersget_parameters () const
 Get the current parameters. More...
 
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. More...
 
const RBParametersget_parameters_min () const
 Get an RBParameters object that specifies the minimum allowable value for each parameter. More...
 
const RBParametersget_parameters_max () const
 Get an RBParameters object that specifies the maximum allowable value for each parameter. More...
 
Real get_parameter_min (const std::string &param_name) const
 Get minimum allowable value of parameter param_name. More...
 
Real get_parameter_max (const std::string &param_name) const
 Get maximum allowable value of parameter param_name. More...
 
void print_parameters () const
 Print the current parameters. More...
 
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. More...
 
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. More...
 
bool is_discrete_parameter (const std::string &mu_name) const
 Is parameter mu_name discrete? More...
 
const std::map< std::string, std::vector< Real > > & get_discrete_parameter_values () const
 Get a const reference to the discrete parameter values. More...
 
void print_discrete_parameter_values () const
 Print out all the discrete parameter values. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
static void print_info (std::ostream &out_stream=libMesh::out)
 Prints the reference information, by default to libMesh::out. More...
 
static unsigned int n_objects ()
 Prints the number of outstanding (created, but not yet destroyed) objects. More...
 
static void enable_print_counter_info ()
 Methods to enable/disable the reference counter output from print_info() More...
 
static void disable_print_counter_info ()
 

Public Attributes

bool verbose_mode
 Public boolean to toggle verbose mode. More...
 

Protected Types

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

Protected Member Functions

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

Protected Attributes

std::set< unsigned int_eim_vars_to_project_and_write
 This set specifies which EIM variables will be projected and written out in write_out_projected_basis_functions(). More...
 
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. More...
 
const Parallel::Communicator_communicator
 

Static Protected Attributes

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

Private Member Functions

void write_out_interior_basis_functions (const std::string &directory_name, bool write_binary_basis_functions)
 Method that writes out element interior EIM basis functions. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
void print_local_eim_basis_functions () const
 Print the contents of _local_eim_basis_functions to libMesh::out. More...
 
void gather_bfs ()
 Helper function that gathers the contents of _local_eim_basis_functions to processor 0 in preparation for printing to file. More...
 
void side_gather_bfs ()
 Same as gather_bfs() except for side data. More...
 
void node_gather_bfs ()
 Same as gather_bfs() except for node data. More...
 
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. More...
 
void side_distribute_bfs (const System &sys)
 Same as distribute_bfs() except for side data. More...
 
void node_distribute_bfs (const System &sys)
 Same as distribute_bfs() except for node data. More...
 

Private Attributes

std::vector< DenseVector< Number > > _rb_eim_solutions
 The EIM solution coefficients from the most recent call to rb_eim_solves(). More...
 
std::vector< 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. More...
 
std::vector< DenseVector< Number > > _eim_solutions_for_training_set
 Storage for EIM solutions from the training set. More...
 
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(). More...
 
unsigned int _rb_eim_solves_N
 
DenseMatrix< Number_interpolation_matrix
 Dense matrix that stores the lower triangular interpolation matrix that can be used. More...
 
VectorizedEvalInput _vec_eval_input
 We store the EIM interpolation point data in this object. More...
 
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. More...
 
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(). More...
 
std::unique_ptr< RBParametrizedFunction_parametrized_function
 Store the parametrized function that will be approximated by this EIM system. More...
 
std::vector< std::unique_ptr< RBTheta > > _rb_eim_theta_objects
 The vector of RBTheta objects that are created to point to this RBEIMEvaluation. More...
 
std::vector< QpDataMap_local_eim_basis_functions
 The EIM basis functions. More...
 
std::vector< SideQpDataMap_local_side_eim_basis_functions
 The EIM basis functions on element sides. More...
 
std::vector< NodeDataMap_local_node_eim_basis_functions
 The EIM basis functions on element nodes (e.g. More...
 
bool _preserve_rb_eim_solutions
 Boolean to indicate if we skip updating _rb_eim_solutions in rb_eim_solves(). More...
 
bool _is_eim_error_indicator_active
 Indicate if the EIM error indicator is active in RB EIM solves. More...
 
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. More...
 

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 52 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 87 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 77 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 82 of file rb_eim_evaluation.h.

Constructor & Destructor Documentation

◆ RBEIMEvaluation() [1/3]

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

Constructor.

Definition at line 47 of file rb_eim_evaluation.C.

48 :
53 {
54 }
ParallelObject(const Parallel::Communicator &comm_in)
Constructor.
const Parallel::Communicator & comm() const
bool _is_eim_error_indicator_active
Indicate if the EIM error indicator is active in RB EIM solves.
bool _preserve_rb_eim_solutions
Boolean to indicate if we skip updating _rb_eim_solutions in rb_eim_solves().

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

References _local_eim_basis_functions.

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

893 {
894  _local_eim_basis_functions.emplace_back(bf);
895 }
std::vector< QpDataMap > _local_eim_basis_functions
The EIM basis functions.

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

Add interpolation data associated with a new basis function.

Definition at line 897 of file rb_eim_evaluation.C.

References _interpolation_points_comp, _vec_eval_input, libMesh::VectorizedEvalInput::all_xyz, libMesh::VectorizedEvalInput::all_xyz_perturb, libMesh::VectorizedEvalInput::elem_ids, libMesh::VectorizedEvalInput::elem_types, libMesh::VectorizedEvalInput::JxW_all_qp, libMesh::VectorizedEvalInput::phi_i_all_qp, libMesh::VectorizedEvalInput::phi_i_qp, libMesh::VectorizedEvalInput::qps, and libMesh::VectorizedEvalInput::sbd_ids.

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

908 {
909  _vec_eval_input.all_xyz.emplace_back(p);
910  _interpolation_points_comp.emplace_back(comp);
911  _vec_eval_input.elem_ids.emplace_back(elem_id);
912  _vec_eval_input.sbd_ids.emplace_back(subdomain_id);
913  _vec_eval_input.qps.emplace_back(qp);
914  _vec_eval_input.all_xyz_perturb.emplace_back(perturbs);
915  _vec_eval_input.phi_i_qp.emplace_back(phi_i_qp);
916  _vec_eval_input.elem_types.emplace_back(elem_type);
917  _vec_eval_input.JxW_all_qp.emplace_back(JxW_all_qp);
918  _vec_eval_input.phi_i_all_qp.emplace_back(phi_i_all_qp);
919 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< ElemType > elem_types
std::vector< std::vector< Real > > JxW_all_qp
std::vector< unsigned int > qps
std::vector< std::vector< Real > > phi_i_qp
std::vector< dof_id_type > elem_ids
std::vector< subdomain_id_type > sbd_ids
std::vector< Point > all_xyz
The members that define the inputs to the vectorized evaluate functions.
std::vector< std::vector< std::vector< Real > > > phi_i_all_qp
std::vector< unsigned int > _interpolation_points_comp
In the case of a "vector-valued" EIM, this vector determines which component of the parameterized fun...
std::vector< std::vector< Point > > all_xyz_perturb

◆ add_interpolation_points_boundary_id()

void RBEIMEvaluation::add_interpolation_points_boundary_id ( boundary_id_type  b_id)

Definition at line 710 of file rb_eim_evaluation.C.

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

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

711 {
712  _vec_eval_input.boundary_ids.emplace_back(b_id);
713 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< boundary_id_type > boundary_ids

◆ add_interpolation_points_comp()

void RBEIMEvaluation::add_interpolation_points_comp ( unsigned int  comp)

Definition at line 700 of file rb_eim_evaluation.C.

References _interpolation_points_comp.

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

701 {
702  _interpolation_points_comp.emplace_back(comp);
703 }
std::vector< unsigned int > _interpolation_points_comp
In the case of a "vector-valued" EIM, this vector determines which component of the parameterized fun...

◆ add_interpolation_points_elem_id()

void RBEIMEvaluation::add_interpolation_points_elem_id ( dof_id_type  elem_id)

Definition at line 720 of file rb_eim_evaluation.C.

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

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

721 {
722  _vec_eval_input.elem_ids.emplace_back(elem_id);
723 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< dof_id_type > elem_ids

◆ add_interpolation_points_elem_type()

void RBEIMEvaluation::add_interpolation_points_elem_type ( ElemType  elem_type)

Definition at line 740 of file rb_eim_evaluation.C.

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

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

741 {
742  _vec_eval_input.elem_types.emplace_back(elem_type);
743 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< ElemType > elem_types

◆ add_interpolation_points_JxW_all_qp()

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

Definition at line 745 of file rb_eim_evaluation.C.

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

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

746 {
747  _vec_eval_input.JxW_all_qp.emplace_back(JxW_all_qp);
748 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< 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 730 of file rb_eim_evaluation.C.

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

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

731 {
732  _vec_eval_input.node_ids.emplace_back(node_id);
733 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< dof_id_type > node_ids

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

Definition at line 750 of file rb_eim_evaluation.C.

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

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

751 {
752  _vec_eval_input.phi_i_all_qp.emplace_back(phi_i_all_qp);
753 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< 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 755 of file rb_eim_evaluation.C.

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

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

756 {
757  _vec_eval_input.phi_i_qp.emplace_back(phi_i_qp);
758 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< std::vector< Real > > phi_i_qp

◆ add_interpolation_points_qp()

void RBEIMEvaluation::add_interpolation_points_qp ( unsigned int  qp)

Definition at line 735 of file rb_eim_evaluation.C.

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

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

736 {
737  _vec_eval_input.qps.emplace_back(qp);
738 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< unsigned int > qps

◆ add_interpolation_points_side_index()

void RBEIMEvaluation::add_interpolation_points_side_index ( unsigned int  side_index)

Definition at line 725 of file rb_eim_evaluation.C.

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

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

726 {
727  _vec_eval_input.side_indices.emplace_back(side_index);
728 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< unsigned int > side_indices

◆ add_interpolation_points_spatial_indices()

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

Definition at line 760 of file rb_eim_evaluation.C.

References _interpolation_points_spatial_indices.

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

761 {
762  _interpolation_points_spatial_indices.emplace_back(spatial_indices);
763 }
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()...

◆ add_interpolation_points_subdomain_id()

void RBEIMEvaluation::add_interpolation_points_subdomain_id ( subdomain_id_type  sbd_id)

Definition at line 705 of file rb_eim_evaluation.C.

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

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

706 {
707  _vec_eval_input.sbd_ids.emplace_back(sbd_id);
708 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< subdomain_id_type > sbd_ids

◆ add_interpolation_points_xyz()

void RBEIMEvaluation::add_interpolation_points_xyz ( Point  p)

Set the data associated with EIM interpolation points.

Definition at line 695 of file rb_eim_evaluation.C.

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

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

696 {
697  _vec_eval_input.all_xyz.emplace_back(p);
698 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< Point > all_xyz
The members that define the inputs to the vectorized evaluate functions.

◆ add_interpolation_points_xyz_perturbations()

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

Definition at line 715 of file rb_eim_evaluation.C.

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

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

716 {
717  _vec_eval_input.all_xyz_perturb.emplace_back(perturbs);
718 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< std::vector< Point > > all_xyz_perturb

◆ add_node_basis_function()

void RBEIMEvaluation::add_node_basis_function ( const NodeDataMap node_bf)

Add node_bf to our EIM basis.

Definition at line 955 of file rb_eim_evaluation.C.

References _local_node_eim_basis_functions.

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

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

◆ 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 961 of file rb_eim_evaluation.C.

References _interpolation_points_comp, _vec_eval_input, libMesh::VectorizedEvalInput::all_xyz, libMesh::VectorizedEvalInput::all_xyz_perturb, libMesh::VectorizedEvalInput::boundary_ids, libMesh::VectorizedEvalInput::elem_ids, libMesh::VectorizedEvalInput::elem_types, libMesh::INVALID_ELEM, 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::sbd_ids, and libMesh::VectorizedEvalInput::side_indices.

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

966 {
967  _vec_eval_input.all_xyz.emplace_back(p);
968  _interpolation_points_comp.emplace_back(comp);
969  _vec_eval_input.node_ids.emplace_back(node_id);
970  _vec_eval_input.boundary_ids.emplace_back(boundary_id);
971 
972  // Add dummy values for the other properties, which are unused in the
973  // node case.
974  _vec_eval_input.elem_ids.emplace_back(0);
975  _vec_eval_input.side_indices.emplace_back(0);
976  _vec_eval_input.sbd_ids.emplace_back(0);
977  _vec_eval_input.qps.emplace_back(0);
978  _vec_eval_input.all_xyz_perturb.emplace_back();
979  _vec_eval_input.phi_i_qp.emplace_back();
981  _vec_eval_input.JxW_all_qp.emplace_back();
982  _vec_eval_input.phi_i_all_qp.emplace_back();
983 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< ElemType > elem_types
std::vector< std::vector< Real > > JxW_all_qp
std::vector< unsigned int > qps
std::vector< std::vector< Real > > phi_i_qp
std::vector< dof_id_type > elem_ids
std::vector< subdomain_id_type > sbd_ids
std::vector< unsigned int > side_indices
std::vector< Point > all_xyz
The members that define the inputs to the vectorized evaluate functions.
std::vector< std::vector< std::vector< Real > > > phi_i_all_qp
std::vector< boundary_id_type > boundary_ids
std::vector< unsigned int > _interpolation_points_comp
In the case of a "vector-valued" EIM, this vector determines which component of the parameterized fun...
std::vector< std::vector< Point > > all_xyz_perturb
std::vector< dof_id_type > node_ids

◆ add_side_basis_function()

void RBEIMEvaluation::add_side_basis_function ( const SideQpDataMap side_bf)

Add side_bf to our EIM basis.

Definition at line 921 of file rb_eim_evaluation.C.

References _local_side_eim_basis_functions.

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

923 {
924  _local_side_eim_basis_functions.emplace_back(side_bf);
925 }
std::vector< SideQpDataMap > _local_side_eim_basis_functions
The EIM basis functions on element 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 927 of file rb_eim_evaluation.C.

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

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

937 {
938  _vec_eval_input.all_xyz.emplace_back(p);
939  _interpolation_points_comp.emplace_back(comp);
940  _vec_eval_input.elem_ids.emplace_back(elem_id);
941  _vec_eval_input.side_indices.emplace_back(side_index);
942  _vec_eval_input.sbd_ids.emplace_back(subdomain_id);
943  _vec_eval_input.boundary_ids.emplace_back(boundary_id);
944  _vec_eval_input.qps.emplace_back(qp);
945  _vec_eval_input.all_xyz_perturb.emplace_back(perturbs);
946  _vec_eval_input.phi_i_qp.emplace_back(phi_i_qp);
947 
948  // Add dummy values for the other properties, which are unused in the
949  // node case.
951  _vec_eval_input.JxW_all_qp.emplace_back();
952  _vec_eval_input.phi_i_all_qp.emplace_back();
953 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< ElemType > elem_types
std::vector< std::vector< Real > > JxW_all_qp
std::vector< unsigned int > qps
std::vector< std::vector< Real > > phi_i_qp
std::vector< dof_id_type > elem_ids
std::vector< subdomain_id_type > sbd_ids
std::vector< unsigned int > side_indices
std::vector< Point > all_xyz
The members that define the inputs to the vectorized evaluate functions.
std::vector< std::vector< std::vector< Real > > > phi_i_all_qp
std::vector< boundary_id_type > boundary_ids
std::vector< unsigned int > _interpolation_points_comp
In the case of a "vector-valued" EIM, this vector determines which component of the parameterized fun...
std::vector< std::vector< Point > > all_xyz_perturb

◆ 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 416 of file rb_eim_evaluation.C.

Referenced by initialize_eim_theta_objects().

417 {
418  return std::make_unique<RBEIMTheta>(*this, index);
419 }

◆ clear()

void RBEIMEvaluation::clear ( )
overridevirtual

Clear this object.

Reimplemented from libMesh::RBParametrized.

Definition at line 58 of file rb_eim_evaluation.C.

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

59 {
61 
64 
65 
67 
68  // Delete any RBTheta objects that were created
69  _rb_eim_theta_objects.clear();
70 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
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< std::vector< unsigned int > > _interpolation_points_spatial_indices
Here we store the spatial indices that were initialized by initialize_spatial_indices_at_interp_pts()...
void clear()
Clear all the members.
std::vector< unsigned int > _interpolation_points_comp
In the case of a "vector-valued" EIM, this vector determines which component of the parameterized fun...
void resize(const unsigned int new_m, const unsigned int new_n)
Resizes the matrix to the specified size and calls zero().
Definition: dense_matrix.h:895
DenseMatrix< Number > _interpolation_matrix
Dense matrix that stores the lower triangular interpolation matrix that can be used.

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

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_tao_equality_constraints(), libMesh::__libmesh_tao_equality_constraints_jacobian(), libMesh::__libmesh_tao_gradient(), libMesh::__libmesh_tao_hessian(), libMesh::__libmesh_tao_inequality_constraints(), libMesh::__libmesh_tao_inequality_constraints_jacobian(), libMesh::__libmesh_tao_objective(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult_add(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), libMesh::DofMap::add_constraints_to_send_list(), add_cube_convex_hull_to_mesh(), libMesh::PetscDMWrapper::add_dofs_helper(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::EigenSystem::add_matrices(), libMesh::System::add_matrix(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::System::add_variable(), libMesh::System::add_variables(), libMesh::System::add_vector(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::FEMSystem::assemble_qoi(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::MeshCommunication::assign_global_indices(), libMesh::Partitioner::assign_partitioning(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_section(), libMesh::PetscDMWrapper::build_sf(), libMesh::MeshBase::cache_elem_data(), libMesh::System::calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::RBSCMConstruction::compute_SCM_bounds_on_training_set(), libMesh::DofMap::computed_sparsity_already(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), 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::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< libMesh::Number >::create_submatrix_nosort(), libMesh::MeshCommunication::delete_remote_elements(), distribute_bfs(), libMesh::DofMap::distribute_dofs(), 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::PatchRecoveryErrorEstimator::estimate_error(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), 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(), libMesh::System::get_info(), libMesh::DofMap::get_info(), 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(), AssembleOptimization::inequality_constraints(), AssembleOptimization::inequality_constraints_jacobian(), libMesh::LocationMap< T >::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_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::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_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_recalculate_monitor(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_interface(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_postcheck(), libMesh::libmesh_petsc_snes_precheck(), libMesh::libmesh_petsc_snes_residual(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), libMesh::LinearImplicitSystem::LinearImplicitSystem(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_new_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_new_nodes_parallel_consistent(), libMesh::MeshCommunication::make_node_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::MeshRefinement::make_refinement_compatible(), 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::DofMap::n_constrained_dofs(), 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::MeshBase::operator==(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::ReplicatedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_n_elem(), libMesh::DistributedMesh::parallel_n_nodes(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::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(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::DofMap::print_dof_constraints(), libMesh::DofMap::process_mesh_constraint_rows(), libMesh::Partitioner::processor_pairs_to_interface_nodes(), libMesh::InterMeshProjection::project_system_vectors(), FEMParameters::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::EquationSystems::read(), libMesh::ExodusII_IO::read_header(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::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::System::read_legacy_data(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::Nemesis_IO_Helper::read_var_names_impl(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshRefinement::refine_and_coarsen_elements(), 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::split_mesh(), libMesh::RBEIMConstruction::store_eim_solutions_for_training_set(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), libMesh::MeshRefinement::test_level_one(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), libMesh::MeshRefinement::test_unflagged(), DofMapTest::testBadElemFECombo(), SystemsTest::testBlockRestrictedVarNDofs(), BoundaryInfoTest::testBoundaryOnChildrenErrors(), MeshInputTest::testExodusIGASidesets(), MeshTriangulationTest::testFoundCenters(), PointLocatorTest::testLocator(), BoundaryInfoTest::testMesh(), PointLocatorTest::testPlanar(), MeshTriangulationTest::testPoly2TriRefinementBase(), SystemsTest::testProjectCubeWithMeshFunction(), BoundaryInfoTest::testRenumber(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), MeshTriangulationTest::testTriangulatorInterp(), MeshTriangulationTest::testTriangulatorMeshedHoles(), libMesh::MeshTools::total_weight(), libMesh::RBConstruction::train_reduced_basis_with_POD(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::Poly2TriTriangulator::triangulate(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::NameBasedIO::write(), libMesh::XdrIO::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::TransientRBConstruction::write_riesz_representors_to_files(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::RBDataSerialization::RBEvaluationSerialization::write_to_file(), libMesh::RBDataSerialization::TransientRBEvaluationSerialization::write_to_file(), libMesh::RBDataSerialization::RBEIMEvaluationSerialization::write_to_file(), and libMesh::RBDataSerialization::RBSCMEvaluationSerialization::write_to_file().

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

◆ decrement_vector()

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

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

Definition at line 327 of file rb_eim_evaluation.C.

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

329 {
330  LOG_SCOPE("decrement_vector()", "RBEIMEvaluation");
331 
332  libmesh_error_msg_if(get_n_basis_functions() != coeffs.size(),
333  "Error: Number of coefficients should match number of basis functions");
334 
335  for (auto & [elem_id, v_comp_and_qp] : v)
336  {
337  for (const auto & comp : index_range(v_comp_and_qp))
338  for (unsigned int qp : index_range(v_comp_and_qp[comp]))
339  for (unsigned int i : index_range(_local_eim_basis_functions))
340  {
341  // Check that entry (elem_id,comp,qp) exists in _local_eim_basis_functions so that
342  // we get a clear error message if there is any missing data
343  const auto & basis_comp_and_qp = libmesh_map_find(_local_eim_basis_functions[i], elem_id);
344 
345  libmesh_error_msg_if(comp >= basis_comp_and_qp.size(), "Error: Invalid comp");
346  libmesh_error_msg_if(qp >= basis_comp_and_qp[comp].size(), "Error: Invalid qp");
347 
348  v_comp_and_qp[comp][qp] -= coeffs(i) * basis_comp_and_qp[comp][qp];
349  }
350  }
351 }
unsigned int get_n_basis_functions() const
Return the current number of EIM basis functions.
virtual unsigned int size() const override final
Definition: dense_vector.h:104
std::vector< QpDataMap > _local_eim_basis_functions
The 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:111

◆ disable_print_counter_info()

void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 100 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

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

◆ 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 2101 of file rb_eim_evaluation.C.

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

Referenced by read_in_interior_basis_functions().

2102 {
2103  // So we can avoid calling these many times below
2104  auto n_procs = sys.comm().size();
2105  auto rank = sys.comm().rank();
2106 
2107  // In serial there's nothing to distribute
2108  if (n_procs == 1)
2109  return;
2110 
2111  // Broadcast the number of basis functions from proc 0. After
2112  // distributing, all procs should have the same number of basis
2113  // functions.
2114  auto n_bf = _local_eim_basis_functions.size();
2115  sys.comm().broadcast(n_bf);
2116 
2117  // Allocate enough space to store n_bf basis functions on non-zero ranks
2118  if (rank != 0)
2119  _local_eim_basis_functions.resize(n_bf);
2120 
2121  // Broadcast the number of variables from proc 0. After
2122  // distributing, all procs should have the same number of variables.
2123  auto n_vars = _local_eim_basis_functions[0].begin()->second.size();
2124  sys.comm().broadcast(n_vars);
2125 
2126  // Construct lists of elem ids owned by different processors
2127  const MeshBase & mesh = sys.get_mesh();
2128 
2129  std::vector<dof_id_type> gathered_local_elem_ids;
2130  gathered_local_elem_ids.reserve(mesh.n_elem());
2131  for (const auto & elem : mesh.active_local_element_ptr_range())
2132  gathered_local_elem_ids.push_back(elem->id());
2133 
2134  // I _think_ the local elem ids are likely to already be sorted in
2135  // ascending order, since that is how they are stored on the Mesh,
2136  // but we can always just guarantee this to be on the safe side as
2137  // well.
2138  std::sort(gathered_local_elem_ids.begin(), gathered_local_elem_ids.end());
2139 
2140  // Gather the number of local elems from all procs to proc 0
2141  auto n_local_elems = gathered_local_elem_ids.size();
2142  std::vector<std::size_t> gathered_n_local_elems = {n_local_elems};
2143  sys.comm().gather(/*root_id=*/0, gathered_n_local_elems);
2144 
2145  // Gather the elem ids owned by each processor onto processor 0.
2146  sys.comm().gather(/*root_id=*/0, gathered_local_elem_ids);
2147 
2148  // Construct vectors of "start" and "one-past-the-end" indices into
2149  // the gathered_local_elem_ids vector for each proc. Only valid on
2150  // processor 0.
2151  std::vector<std::size_t> start_elem_ids_index, end_elem_ids_index;
2152 
2153  if (rank == 0)
2154  {
2155  start_elem_ids_index.resize(n_procs);
2156  start_elem_ids_index[0] = 0;
2157  for (processor_id_type p=1; p<n_procs; ++p)
2158  start_elem_ids_index[p] = start_elem_ids_index[p-1] + gathered_n_local_elems[p-1];
2159 
2160  end_elem_ids_index.resize(n_procs);
2161  end_elem_ids_index[n_procs - 1] = gathered_local_elem_ids.size();
2162  for (processor_id_type p=0; p<n_procs - 1; ++p)
2163  end_elem_ids_index[p] = start_elem_ids_index[p+1];
2164  }
2165 
2166  // On processor 0, using basis function 0 and variable 0, prepare a
2167  // vector with the number of qps per Elem. Then scatter this vector
2168  // out to the processors that require it. The order of this vector
2169  // matches the gathered_local_elem_ids ordering. The counts will be
2170  // gathered_n_local_elems, since there will be one qp count per Elem.
2171  std::vector<unsigned int> n_qp_per_elem_data;
2172 
2173  // On rank 0, the "counts" vector holds the number of floating point values that
2174  // are to be scattered to each proc. It is only required on proc 0.
2175  std::vector<int> counts;
2176 
2177  if (rank == 0)
2178  {
2179  n_qp_per_elem_data.reserve(gathered_local_elem_ids.size());
2180  counts.resize(n_procs);
2181 
2182  auto & bf_map = _local_eim_basis_functions[0];
2183 
2184  for (processor_id_type p=0; p<n_procs; ++p)
2185  {
2186  for (auto e : make_range(start_elem_ids_index[p], end_elem_ids_index[p]))
2187  {
2188  auto elem_id = gathered_local_elem_ids[e];
2189 
2190  // Get reference to array[n_vars][n_qp] for current Elem.
2191  // Throws an error if the required elem_id is not found.
2192  const auto & array = libmesh_map_find(bf_map, elem_id);
2193 
2194  auto n_qps = array[0].size();
2195 
2196  // We use var==0 to set the number of qps for all vars
2197  n_qp_per_elem_data.push_back(n_qps);
2198 
2199  // Accumulate the count for this proc
2200  counts[p] += n_qps;
2201  } // end for (e)
2202  } // end for proc_id
2203  } // if (rank == 0)
2204 
2205  // Now scatter the n_qp_per_elem_data to all procs (must call the
2206  // scatter on all procs, it is a collective).
2207  {
2208  std::vector<unsigned int> recv;
2209  std::vector<int> tmp(gathered_n_local_elems.begin(), gathered_n_local_elems.end());
2210  sys.comm().scatter(n_qp_per_elem_data, tmp, recv, /*root_id=*/0);
2211 
2212  // Now swap n_qp_per_elem_data and recv. All processors now have a
2213  // vector of length n_local_elems containing the number of
2214  // quadarature points per Elem.
2215  n_qp_per_elem_data.swap(recv);
2216  }
2217 
2218  // For each basis function and each variable, build a vector
2219  // of qp data in the Elem ordering given by the
2220  // gathered_local_elem_ids, then call
2221  //
2222  // sys.comm().scatter(data, counts, recv, /*root_id=*/0);
2223  std::vector<std::vector<Number>> qp_data(n_vars);
2224  if (rank == 0)
2225  {
2226  // The total amount of qp data is given by summing the entries
2227  // of the "counts" vector.
2228  auto n_qp_data =
2229  std::accumulate(counts.begin(), counts.end(), 0u);
2230 
2231  // On processor 0, reserve enough space to hold all the qp
2232  // data for a single basis function for each var.
2233  for (auto var : index_range(qp_data))
2234  qp_data[var].reserve(n_qp_data);
2235  }
2236 
2237  // The recv_qp_data vector will be used on the receiving end of all
2238  // the scatters below.
2239  std::vector<Number> recv_qp_data;
2240 
2241  // Loop from 0..n_bf on _all_ procs, since the scatters inside this
2242  // loop are collective.
2243  for (auto bf : make_range(n_bf))
2244  {
2245  // Prepare data for scattering (only on proc 0)
2246  if (rank == 0)
2247  {
2248  // Reference to the data map for the current basis function.
2249  auto & bf_map = _local_eim_basis_functions[bf];
2250 
2251  // Clear any data from previous bf
2252  for (auto var : index_range(qp_data))
2253  qp_data[var].clear();
2254 
2255  for (processor_id_type p=0; p<n_procs; ++p)
2256  {
2257  for (auto e : make_range(start_elem_ids_index[p], end_elem_ids_index[p]))
2258  {
2259  auto elem_id = gathered_local_elem_ids[e];
2260 
2261  // Get reference to array[n_vars][n_qp] for current Elem.
2262  // Throws an error if the required elem_id is not found.
2263  const auto & array = libmesh_map_find(bf_map, elem_id);
2264 
2265  for (auto var : index_range(array))
2266  {
2267  // Insert all qp values for this var
2268  qp_data[var].insert(/*insert at*/qp_data[var].end(),
2269  /*data start*/array[var].begin(),
2270  /*data end*/array[var].end());
2271  } // end for (var)
2272  } // end for (e)
2273  } // end for proc_id
2274  } // end if rank==0
2275 
2276  // Perform the scatters (all procs)
2277  for (auto var : make_range(n_vars))
2278  {
2279  // Do the scatter for the current var
2280  sys.comm().scatter(qp_data[var], counts, recv_qp_data, /*root_id=*/0);
2281 
2282  if (rank != 0)
2283  {
2284  // Store the scattered data we received in _local_eim_basis_functions[bf]
2285  auto & bf_map = _local_eim_basis_functions[bf];
2286  auto cursor = recv_qp_data.begin();
2287 
2288  for (auto i : index_range(gathered_local_elem_ids))
2289  {
2290  auto elem_id = gathered_local_elem_ids[i];
2291  auto n_qp_this_elem = n_qp_per_elem_data[i];
2292  auto & array = bf_map[elem_id];
2293 
2294  // Create space to store the data if it doesn't already exist.
2295  if (array.empty())
2296  array.resize(n_vars);
2297 
2298  array[var].assign(cursor, cursor + n_qp_this_elem);
2299  std::advance(cursor, n_qp_this_elem);
2300  }
2301  } // if (rank != 0)
2302  } // end for (var)
2303  } // end for (bf)
2304 
2305  // Now that the scattering is done, delete non-local Elem
2306  // information from processor 0's _local_eim_basis_functions data
2307  // structure.
2308  if (rank == 0)
2309  {
2310  for (processor_id_type p=1; p<n_procs; ++p)
2311  {
2312  for (auto e : make_range(start_elem_ids_index[p], end_elem_ids_index[p]))
2313  {
2314  auto elem_id = gathered_local_elem_ids[e];
2315 
2316  // Delete this Elem's information from every basis function.
2317  for (auto & bf_map : _local_eim_basis_functions)
2318  bf_map.erase(elem_id);
2319  } // end for (e)
2320  } // end for proc_id
2321  } // if (rank == 0)
2322 }
virtual void clear() override
Clear this object.
MeshBase & mesh
uint8_t processor_id_type
unsigned int n_vars
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:134
std::vector< QpDataMap > _local_eim_basis_functions
The 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:111

◆ enable_print_counter_info()

void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

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

Definition at line 94 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

95 {
96  _enable_print_counter = true;
97  return;
98 }
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...

◆ 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 1682 of file rb_eim_evaluation.C.

References _local_eim_basis_functions, libMesh::ParallelObject::comm(), TIMPI::Communicator::gather(), libMesh::index_range(), TIMPI::Communicator::max(), libMesh::ParallelObject::n_processors(), n_vars, libMesh::ParallelObject::processor_id(), and TIMPI::Communicator::verify().

Referenced by write_out_interior_basis_functions().

1683 {
1684  // We need to gather _local_eim_basis_functions data from other
1685  // procs for printing.
1686  //
1687  // Ideally, this could be accomplished by simply calling:
1688  // this->comm().gather(/*root_id=*/0, _local_eim_basis_functions);
1689  //
1690  // but the data structure seems to be too complicated for this to
1691  // work automatically. (I get some error about the function called
1692  // being "private within this context".) Therefore, we have to
1693  // gather the information manually.
1694 
1695  // So we can avoid calling this many times below
1696  auto n_procs = this->n_processors();
1697 
1698  // In serial there's nothing to gather
1699  if (n_procs == 1)
1700  return;
1701 
1702  // Current assumption is that the number of basis functions stored on
1703  // each processor is the same, the only thing that differs is the number
1704  // of elements, so make sure that is the case now.
1705  auto n_bf = _local_eim_basis_functions.size();
1706  this->comm().verify(n_bf);
1707 
1708  // This function should never be called if there are no basis
1709  // functions, so if it was, something went wrong.
1710  libmesh_error_msg_if(!n_bf, "RBEIMEvaluation::gather_bfs() should not be called with 0 basis functions.");
1711 
1712  // The number of variables should be the same on all processors
1713  // and we can get this from _local_eim_basis_functions. However,
1714  // it may be that some processors have no local elements, so on
1715  // those processors we cannot look up the size from
1716  // _local_eim_basis_functions. As a result we use comm().max(n_vars)
1717  // to make sure all processors agree on the final value.
1718  std::size_t n_vars =
1719  _local_eim_basis_functions[0].empty() ? 0 : _local_eim_basis_functions[0].begin()->second.size();
1720  this->comm().max(n_vars);
1721 
1722  // Gather list of Elem ids stored on each processor to proc 0. We
1723  // use basis function 0 as an example and assume all the basis
1724  // functions are distributed similarly.
1725  std::vector<dof_id_type> elem_ids;
1726  elem_ids.reserve(_local_eim_basis_functions[0].size());
1727  for (const auto & pr : _local_eim_basis_functions[0])
1728  elem_ids.push_back(pr.first);
1729  this->comm().gather(/*root_id=*/0, elem_ids);
1730 
1731  // Store the number of qps per Elem on this processor. Again, use
1732  // basis function 0 (and variable 0) to get this information, then
1733  // apply it to all basis functions.
1734  std::vector<unsigned int> n_qp_per_elem;
1735  n_qp_per_elem.reserve(_local_eim_basis_functions[0].size());
1736  for (const auto & pr : _local_eim_basis_functions[0])
1737  {
1738  // array[n_vars][n_qp] per Elem. We get the number of QPs
1739  // for variable 0, assuming they are all the same.
1740  const auto & array = pr.second;
1741  n_qp_per_elem.push_back(array[0].size());
1742  }
1743 
1744  // Before gathering, compute the total amount of local qp data for
1745  // each var, which is the sum of the entries in the "n_qp_per_elem" array.
1746  // This will be used to reserve space in a vector below.
1747  auto n_local_qp_data =
1748  std::accumulate(n_qp_per_elem.begin(),
1749  n_qp_per_elem.end(),
1750  0u);
1751 
1752  // Gather the number of qps per Elem for each processor onto processor 0.
1753  this->comm().gather(/*root_id=*/0, n_qp_per_elem);
1754 
1755  // Sanity check: On processor 0, this checks that we have gathered the same number
1756  // of elem ids and qp counts.
1757  libmesh_error_msg_if(elem_ids.size() != n_qp_per_elem.size(),
1758  "Must gather same number of Elem ids as qps per Elem.");
1759 
1760  // Reserve space to store contiguous vectors of qp data for each var
1761  std::vector<std::vector<Number>> gathered_qp_data(n_vars);
1762  for (auto var : index_range(gathered_qp_data))
1763  gathered_qp_data[var].reserve(n_local_qp_data);
1764 
1765  // Now we construct a vector for each basis function, for each
1766  // variable, which is ordered according to:
1767  // [ [qp vals for Elem 0], [qp vals for Elem 1], ... [qp vals for Elem N] ]
1768  // and gather it to processor 0.
1769  for (auto bf : index_range(_local_eim_basis_functions))
1770  {
1771  // Clear any data from previous bf
1772  for (auto var : index_range(gathered_qp_data))
1773  gathered_qp_data[var].clear();
1774 
1775  for (const auto & pr : _local_eim_basis_functions[bf])
1776  {
1777  // array[n_vars][n_qp] per Elem
1778  const auto & array = pr.second;
1779  for (auto var : index_range(array))
1780  {
1781  // Insert all qp values for this var
1782  gathered_qp_data[var].insert(/*insert at*/gathered_qp_data[var].end(),
1783  /*data start*/array[var].begin(),
1784  /*data end*/array[var].end());
1785  }
1786  }
1787 
1788  // Reference to the data map for the current basis function.
1789  auto & bf_map = _local_eim_basis_functions[bf];
1790 
1791  for (auto var : index_range(gathered_qp_data))
1792  {
1793  // For each var, gather gathered_qp_data[var] onto processor
1794  // 0. There apparently is not a gather overload for
1795  // vector-of-vectors...
1796  this->comm().gather(/*root_id=*/0, gathered_qp_data[var]);
1797 
1798  // On processor 0, iterate over the gathered_qp_data[var]
1799  // vector we just gathered, filling in the "small" vectors
1800  // for each Elem. Note: here we ignore the fact that we
1801  // already have the data on processor 0 and just overwrite
1802  // it, this makes the indexing logic a bit simpler.
1803  if (this->processor_id() == 0)
1804  {
1805  auto cursor = gathered_qp_data[var].begin();
1806  for (auto i : index_range(elem_ids))
1807  {
1808  auto elem_id = elem_ids[i];
1809  auto n_qp_this_elem = n_qp_per_elem[i];
1810 
1811  // Get reference to the [n_vars][n_qp] array for
1812  // this Elem. We assign() into the vector of
1813  // quadrature point values, which allocates space if
1814  // it doesn't already exist.
1815  auto & array = bf_map[elem_id];
1816 
1817  // Possibly allocate space if this is data for a new
1818  // element we haven't seen before.
1819  if (array.empty())
1820  array.resize(n_vars);
1821 
1822  array[var].assign(cursor, cursor + n_qp_this_elem);
1823  std::advance(cursor, n_qp_this_elem);
1824  }
1825  }
1826  }
1827  } // end loop over basis functions
1828 }
bool verify(const T &r) const
void gather(const unsigned int root_id, const T &send_data, std::vector< T, A > &recv) const
const Parallel::Communicator & comm() const
processor_id_type n_processors() const
unsigned int n_vars
void max(const T &r, T &o, Request &req) const
std::vector< QpDataMap > _local_eim_basis_functions
The EIM basis functions.
processor_id_type processor_id() const
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:111

◆ 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 637 of file rb_eim_evaluation.C.

References _local_eim_basis_functions.

Referenced by libMesh::RBEIMConstruction::update_eim_matrices(), and write_out_projected_basis_functions().

638 {
639  return _local_eim_basis_functions[i];
640 }
std::vector< QpDataMap > _local_eim_basis_functions
The EIM basis functions.

◆ 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 443 of file rb_parametrized.C.

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

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

444 {
445  libmesh_error_msg_if(list_of_values.empty(), "Error: list_of_values is empty.");
446 
447  Real min_distance = std::numeric_limits<Real>::max();
448  Real closest_val = 0.;
449  for (const auto & current_value : list_of_values)
450  {
451  Real distance = std::abs(value - current_value);
452  if (distance < min_distance)
453  {
454  min_distance = distance;
455  closest_val = current_value;
456  }
457  }
458 
459  return closest_val;
460 }
Real distance(const Point &p)
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
Definition: type_vector.h:57
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const bool value
Definition: xdr_io.C:54

◆ 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 370 of file rb_parametrized.C.

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

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

◆ 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 575 of file rb_eim_evaluation.C.

References _local_node_eim_basis_functions, and get_parametrized_function_node_local_value().

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

578 {
579  libmesh_error_msg_if(basis_function_index >= _local_node_eim_basis_functions.size(),
580  "Invalid basis function index: " << basis_function_index);
581 
583  _local_node_eim_basis_functions[basis_function_index],
584  node_id,
585  comp);
586 }
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.
std::vector< NodeDataMap > _local_node_eim_basis_functions
The EIM basis functions on element nodes (e.g.

◆ 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 588 of file rb_eim_evaluation.C.

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

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

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  comm(),
597  _local_node_eim_basis_functions[basis_function_index],
598  node_id,
599  comp);
600 }
const Parallel::Communicator & comm() const
std::vector< NodeDataMap > _local_node_eim_basis_functions
The EIM basis functions on element nodes (e.g.
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.

◆ 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 618 of file rb_eim_evaluation.C.

References _local_side_eim_basis_functions, libMesh::ParallelObject::comm(), and get_parametrized_function_side_value().

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

623 {
624  libmesh_error_msg_if(basis_function_index >= _local_side_eim_basis_functions.size(),
625  "Invalid side basis function index: " << basis_function_index);
626 
628  comm(),
629  _local_side_eim_basis_functions[basis_function_index],
630  elem_id,
631  side_index,
632  comp,
633  qp);
634 }
const Parallel::Communicator & comm() const
std::vector< SideQpDataMap > _local_side_eim_basis_functions
The EIM basis functions on element sides.
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.

◆ 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 558 of file rb_eim_evaluation.C.

References _local_side_eim_basis_functions, and get_parametrized_function_side_values_at_qps().

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

563 {
564  libmesh_error_msg_if(basis_function_index >= _local_side_eim_basis_functions.size(),
565  "Invalid basis function index: " << basis_function_index);
566 
568  _local_side_eim_basis_functions[basis_function_index],
569  elem_id,
570  side_index,
571  comp,
572  values);
573 }
std::vector< SideQpDataMap > _local_side_eim_basis_functions
The EIM basis functions on element sides.
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.

◆ 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 602 of file rb_eim_evaluation.C.

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

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

606 {
607  libmesh_error_msg_if(basis_function_index >= _local_eim_basis_functions.size(),
608  "Invalid basis function index: " << basis_function_index);
609 
611  comm(),
612  _local_eim_basis_functions[basis_function_index],
613  elem_id,
614  comp,
615  qp);
616 }
const Parallel::Communicator & comm() const
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.
std::vector< QpDataMap > _local_eim_basis_functions
The EIM basis functions.

◆ 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 543 of file rb_eim_evaluation.C.

References _local_eim_basis_functions, and get_parametrized_function_values_at_qps().

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

547 {
548  libmesh_error_msg_if(basis_function_index >= _local_eim_basis_functions.size(),
549  "Invalid basis function index: " << basis_function_index);
550 
552  _local_eim_basis_functions[basis_function_index],
553  elem_id,
554  comp,
555  values);
556 }
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...
std::vector< QpDataMap > _local_eim_basis_functions
The EIM basis functions.

◆ 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 2977 of file rb_eim_evaluation.C.

References _error_indicator_interpolation_row, std::abs(), libMesh::DenseVector< T >::dot(), libMesh::DenseVector< T >::get_principal_subvector(), libMesh::DenseVector< T >::linfty_norm(), std::real(), libMesh::Real, and libMesh::DenseVector< T >::size().

Referenced by rb_eim_solves().

2981 {
2982  DenseVector<Number> coeffs;
2984 
2985  Real error_indicator_val =
2986  std::real(error_indicator_rhs - (coeffs.dot(eim_solution)));
2987 
2988  // Normalize the error indicator based on the norm of the EIM RHS vector.
2989  // Other normalizations are possible (e.g. see the commented-out option
2990  // below), but we prefer the RHS norm approach since it helps to handle
2991  // the case where different EIM variables have different magnitudes in
2992  // a more sensible manner, i.e. if error_indicator_val is based on a
2993  // "small magnitude" variable, then by normalizing based on the entire
2994  // RHS vector (which will typically include values from multiple different
2995  // EIM variables) we will effectively scale down the error indicator
2996  // corresponding to small variables, which is typically what we want.
2997  Real normalization = std::max(eim_rhs.linfty_norm(), std::abs(error_indicator_rhs));
2998 
2999  // Commented-out alternative normalization
3000  // Real normalization =
3001  // std::abs(error_indicator_rhs) + std::abs(coeffs.dot(eim_solution));
3002 
3003  // We avoid NaNs by setting normalization to 1 in the case that it is exactly 0.
3004  if (normalization == 0.)
3005  normalization = 1.;
3006 
3007  // Return the relative error indicator, and the normalization that we used. By returning
3008  // the normalization, we can subsequently recover the absolute error indicator if
3009  // desired.
3010  return std::make_pair(std::abs(error_indicator_val) / normalization, normalization);
3011 }
boost::multiprecision::float128 real(const boost::multiprecision::float128 in)
void get_principal_subvector(unsigned int sub_n, DenseVector< T > &dest) const
Puts the principal subvector of size sub_n (i.e.
Definition: dense_vector.h:691
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
Definition: type_vector.h:57
Real linfty_norm() const
Definition: dense_vector.h:667
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual unsigned int size() const override final
Definition: dense_vector.h:104
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...

◆ get_eim_solutions_for_training_set() [1/2]

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

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

Definition at line 680 of file rb_eim_evaluation.C.

References _eim_solutions_for_training_set.

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder(), libMesh::RBDataDeserialization::load_rb_eim_evaluation_data(), and libMesh::RBEIMConstruction::store_eim_solutions_for_training_set().

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

◆ get_eim_solutions_for_training_set() [2/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 685 of file rb_eim_evaluation.C.

References _eim_solutions_for_training_set.

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

◆ 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 411 of file rb_eim_evaluation.C.

References _rb_eim_theta_objects.

412 {
413  return _rb_eim_theta_objects;
414 }
std::vector< std::unique_ptr< RBTheta > > _rb_eim_theta_objects
The vector of RBTheta objects that are created to point to this RBEIMEvaluation.

◆ get_eim_vars_to_project_and_write()

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

Get _eim_vars_to_project_and_write.

Definition at line 2916 of file rb_eim_evaluation.C.

References _eim_vars_to_project_and_write.

Referenced by write_out_projected_basis_functions().

2917 {
2919 }
std::set< unsigned int > _eim_vars_to_project_and_write
This set specifies which EIM variables will be projected and written out in write_out_projected_basis...

◆ get_error_indicator_interpolation_row()

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

Get/set _extra_points_interpolation_matrix.

Definition at line 3018 of file rb_eim_evaluation.C.

References _error_indicator_interpolation_row.

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

3019 {
3021 }
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...

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

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

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

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 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
static Counts _counts
Actually holds the data.

◆ get_interpolation_matrix()

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

Get the EIM interpolation matrix.

Definition at line 876 of file rb_eim_evaluation.C.

References _interpolation_matrix.

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

877 {
878  return _interpolation_matrix;
879 }
DenseMatrix< Number > _interpolation_matrix
Dense matrix that stores the lower triangular interpolation matrix that can be used.

◆ get_interpolation_points_boundary_id()

boundary_id_type RBEIMEvaluation::get_interpolation_points_boundary_id ( unsigned int  index) const

Definition at line 786 of file rb_eim_evaluation.C.

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

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

787 {
788  libmesh_error_msg_if(index >= _vec_eval_input.boundary_ids.size(), "Error: Invalid index");
789 
790  return _vec_eval_input.boundary_ids[index];
791 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< boundary_id_type > boundary_ids

◆ 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 828 of file rb_eim_evaluation.C.

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

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

829 {
830  libmesh_error_msg_if(index >= _vec_eval_input.elem_types.size(), "Error: Invalid index");
831 
832  return _vec_eval_input.elem_types[index];
833 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< ElemType > elem_types

◆ get_interpolation_points_JxW_all_qp()

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

Definition at line 835 of file rb_eim_evaluation.C.

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

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

836 {
837  libmesh_error_msg_if(index >= _vec_eval_input.JxW_all_qp.size(), "Error: Invalid index");
838 
839  return _vec_eval_input.JxW_all_qp[index];
840 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< std::vector< Real > > JxW_all_qp

◆ get_interpolation_points_node_id()

dof_id_type RBEIMEvaluation::get_interpolation_points_node_id ( unsigned int  index) const

Definition at line 814 of file rb_eim_evaluation.C.

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

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_nodes(), libMesh::RBEIMConstruction::store_eim_solutions_for_training_set(), and libMesh::RBEIMConstruction::update_eim_matrices().

815 {
816  libmesh_error_msg_if(index >= _vec_eval_input.node_ids.size(), "Error: Invalid index");
817 
818  return _vec_eval_input.node_ids[index];
819 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< dof_id_type > node_ids

◆ 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 842 of file rb_eim_evaluation.C.

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

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

843 {
844  libmesh_error_msg_if(index >= _vec_eval_input.phi_i_all_qp.size(), "Error: Invalid index");
845 
846  return _vec_eval_input.phi_i_all_qp[index];
847 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< std::vector< std::vector< Real > > > phi_i_all_qp

◆ get_interpolation_points_phi_i_qp()

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

Definition at line 849 of file rb_eim_evaluation.C.

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

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

850 {
851  libmesh_error_msg_if(index >= _vec_eval_input.phi_i_qp.size(), "Error: Invalid index");
852 
853  return _vec_eval_input.phi_i_qp[index];
854 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< std::vector< Real > > phi_i_qp

◆ get_interpolation_points_qp()

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

◆ get_interpolation_points_side_index()

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

Definition at line 807 of file rb_eim_evaluation.C.

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

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), libMesh::RBEIMConstruction::store_eim_solutions_for_training_set(), and libMesh::RBEIMConstruction::update_eim_matrices().

808 {
809  libmesh_error_msg_if(index >= _vec_eval_input.side_indices.size(), "Error: Invalid index");
810 
811  return _vec_eval_input.side_indices[index];
812 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< unsigned int > side_indices

◆ get_interpolation_points_spatial_indices()

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

Definition at line 856 of file rb_eim_evaluation.C.

References _interpolation_points_spatial_indices.

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

857 {
858  libmesh_error_msg_if(index >= _interpolation_points_spatial_indices.size(), "Error: Invalid index");
859 
861 }
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()...

◆ get_interpolation_points_subdomain_id()

subdomain_id_type RBEIMEvaluation::get_interpolation_points_subdomain_id ( unsigned int  index) const

Definition at line 779 of file rb_eim_evaluation.C.

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

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

780 {
781  libmesh_error_msg_if(index >= _vec_eval_input.sbd_ids.size(), "Error: Invalid index");
782 
783  return _vec_eval_input.sbd_ids[index];
784 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< subdomain_id_type > sbd_ids

◆ 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 765 of file rb_eim_evaluation.C.

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

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

766 {
767  libmesh_error_msg_if(index >= _vec_eval_input.all_xyz.size(), "Error: Invalid index");
768 
769  return _vec_eval_input.all_xyz[index];
770 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< Point > all_xyz
The members that define the inputs to the vectorized evaluate functions.

◆ get_interpolation_points_xyz_perturbations()

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

Definition at line 793 of file rb_eim_evaluation.C.

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

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

794 {
795  libmesh_error_msg_if(index >= _vec_eval_input.all_xyz_perturb.size(), "Error: Invalid index");
796 
797  return _vec_eval_input.all_xyz_perturb[index];
798 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< std::vector< Point > > all_xyz_perturb

◆ get_n_basis_functions()

unsigned int RBEIMEvaluation::get_n_basis_functions ( ) const

Return the current number of EIM basis functions.

Definition at line 302 of file rb_eim_evaluation.C.

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

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder(), libMesh::RBEIMConstruction::compute_max_eim_error(), decrement_vector(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_nodes(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), libMesh::RBEIMTheta::evaluate_vec(), initialize_eim_theta_objects(), node_decrement_vector(), rb_eim_solve(), rb_eim_solves(), read_in_basis_functions(), set_eim_error_indicator_active(), side_decrement_vector(), 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_projected_basis_functions().

303 {
304  if (get_parametrized_function().on_mesh_sides())
305  return _local_side_eim_basis_functions.size();
306  else if (get_parametrized_function().on_mesh_nodes())
307  return _local_node_eim_basis_functions.size();
308  else
309  return _local_eim_basis_functions.size();
310 }
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.
std::vector< QpDataMap > _local_eim_basis_functions
The EIM basis functions.
RBParametrizedFunction & get_parametrized_function()
Get a reference to the parametrized function.

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

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

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 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
unsigned int get_n_discrete_params() const
Get the number of discrete parameters.
libmesh_assert(ctx)
unsigned int get_n_params() const
Get the number of parameters.

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

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

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 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
const std::map< std::string, std::vector< Real > > & get_discrete_parameter_values() const
Get a const reference to the discrete parameter values.

◆ 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 312 of file rb_eim_evaluation.C.

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

313 {
314  return _vec_eval_input.all_xyz.size();
315 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
std::vector< Point > all_xyz
The members that define the inputs to the vectorized evaluate functions.

◆ 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 863 of file rb_eim_evaluation.C.

References _interpolation_points_spatial_indices.

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

864 {
866 }
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()...

◆ get_n_params()

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

Get the number of parameters.

Definition at line 103 of file rb_parametrized.C.

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

Referenced by libMesh::RBParametrized::check_if_valid_params(), libMesh::RBEIMConstruction::compute_max_eim_error(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::RBParametrized::get_n_continuous_params(), libMesh::RBSCMConstruction::print_info(), libMesh::RBEIMConstruction::print_info(), libMesh::RBConstruction::print_info(), set_eim_error_indicator_active(), and libMesh::RBConstruction::train_reduced_basis_with_POD().

104 {
105  libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::get_n_params");
106 
107  libmesh_assert_equal_to ( parameters_min.n_parameters(), parameters_max.n_parameters() );
108 
109  return parameters_min.n_parameters();
110 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
RBParameters parameters_min
Vectors that define the ranges (min and max) for the parameters.
unsigned int n_parameters() const
Get the number of parameters that have been added.

◆ 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 649 of file rb_eim_evaluation.C.

References _local_node_eim_basis_functions.

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

650 {
652 }
std::vector< NodeDataMap > _local_node_eim_basis_functions
The EIM basis functions on element nodes (e.g.

◆ 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 183 of file rb_parametrized.C.

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

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

184 {
185  libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::get_parameter_max");
186 
187  return parameters_max.get_value(param_name);
188 }
Real get_value(const std::string &param_name) const
Get the value of the specified parameter, throw an error if it does not exist.
Definition: rb_parameters.C:64
bool parameters_initialized
Flag indicating whether the parameters have been initialized.

◆ 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 176 of file rb_parametrized.C.

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

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

177 {
178  libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::get_parameter_min");
179 
180  return parameters_min.get_value(param_name);
181 }
Real get_value(const std::string &param_name) const
Get the value of the specified parameter, throw an error if it does not exist.
Definition: rb_parameters.C:64
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
RBParameters parameters_min
Vectors that define the ranges (min and max) for the parameters.

◆ get_parameter_names()

std::set< std::string > libMesh::RBParametrized::get_parameter_names ( ) const
inherited

Get a set that stores the parameter names.

Definition at line 129 of file rb_parametrized.C.

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

130 {
131  libmesh_deprecated();
132  libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::get_parameter_names");
133 
134  std::set<std::string> parameter_names;
135  for (const auto & pr : parameters_min)
136  parameter_names.insert(pr.first);
137 
138  return parameter_names;
139 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
RBParameters parameters_min
Vectors that define the ranges (min and max) for the parameters.

◆ get_parameters()

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

Get the current parameters.

Definition at line 155 of file rb_parametrized.C.

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(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::RBConstruction::preevaluate_thetas(), libMesh::RBSCMConstruction::print_info(), libMesh::RBEIMConstruction::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::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::truth_solve(), libMesh::RBConstruction::truth_solve(), libMesh::TransientRBEvaluation::uncached_compute_residual_dual_norm(), and libMesh::RBConstruction::update_greedy_param_list().

156 {
157  libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::get_parameters");
158 
159  return parameters;
160 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
RBParameters parameters
Vector storing the current parameters.

◆ get_parameters_max()

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

Get an RBParameters object that specifies the maximum allowable value for each parameter.

Definition at line 169 of file rb_parametrized.C.

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

Referenced by libMesh::RBDataSerialization::add_parameter_ranges_to_builder(), libMesh::RBParametrized::initialize_parameters(), libMesh::RBSCMConstruction::process_parameters_file(), libMesh::RBEIMConstruction::set_rb_construction_parameters(), libMesh::RBConstruction::set_rb_construction_parameters(), and libMesh::RBParametrized::write_parameter_ranges_to_file().

170 {
171  libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::get_parameters_max");
172 
173  return parameters_max;
174 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.

◆ get_parameters_min()

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

Get an RBParameters object that specifies the minimum allowable value for each parameter.

Definition at line 162 of file rb_parametrized.C.

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

Referenced by libMesh::RBDataSerialization::add_parameter_ranges_to_builder(), libMesh::RBParametrized::initialize_parameters(), libMesh::RBSCMConstruction::process_parameters_file(), libMesh::RBEIMConstruction::set_rb_construction_parameters(), libMesh::RBConstruction::set_rb_construction_parameters(), and libMesh::RBParametrized::write_parameter_ranges_to_file().

163 {
164  libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::get_parameters_min");
165 
166  return parameters_min;
167 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
RBParameters parameters_min
Vectors that define the ranges (min and max) for the parameters.

◆ get_parametrized_function() [1/2]

RBParametrizedFunction & RBEIMEvaluation::get_parametrized_function ( )

Get a reference to the parametrized function.

Definition at line 89 of file rb_eim_evaluation.C.

References _parametrized_function.

Referenced by libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder(), libMesh::RBEIMConstruction::enrich_eim_approximation(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), 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(), 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().

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

◆ get_parametrized_function() [2/2]

const RBParametrizedFunction & RBEIMEvaluation::get_parametrized_function ( ) const

Get a const reference to the parametrized function.

Definition at line 96 of file rb_eim_evaluation.C.

References _parametrized_function.

97 {
98  libmesh_error_msg_if(!_parametrized_function, "Parametrized function not initialized yet");
99 
100  return *_parametrized_function;
101 }
std::unique_ptr< RBParametrizedFunction > _parametrized_function
Store the parametrized function that will be approximated by this EIM system.

◆ 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 464 of file rb_eim_evaluation.C.

Referenced by get_eim_basis_function_node_local_value(), and get_parametrized_function_node_value().

468 {
469  LOG_SCOPE("get_parametrized_function_node_local_value()", "RBEIMConstruction");
470 
471  auto it = pf.find(node_id);
472  if (it != pf.end())
473  {
474  const std::vector<Number> & vec = it->second;
475  libmesh_error_msg_if (comp >= vec.size(), "Error: Invalid comp index");
476  return vec[comp];
477  }
478  else
479  return 0.;
480 }

◆ 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 529 of file rb_eim_evaluation.C.

References libMesh::ParallelObject::comm(), get_parametrized_function_node_local_value(), TIMPI::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().

534 {
535  LOG_SCOPE("get_parametrized_function_node_value()", "RBEIMConstruction");
536 
538  comm.sum(value);
539 
540  return value;
541 }
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.
void sum(T &r) const
const Parallel::Communicator & comm() const
static const bool value
Definition: xdr_io.C:54

◆ 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 505 of file rb_eim_evaluation.C.

References libMesh::ParallelObject::comm(), get_parametrized_function_side_values_at_qps(), TIMPI::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().

512 {
513  std::vector<Number> values;
514  get_parametrized_function_side_values_at_qps(pf, elem_id, side_index, comp, values);
515 
516  // In parallel, values should only be non-empty on one processor
517  Number value = 0.;
518  if (!values.empty())
519  {
520  libmesh_error_msg_if(qp >= values.size(), "Error: Invalid qp index");
521 
522  value = values[qp];
523  }
524  comm.sum(value);
525 
526  return value;
527 }
void sum(T &r) const
const Parallel::Communicator & comm() const
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 const bool value
Definition: xdr_io.C:54

◆ 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 442 of file rb_eim_evaluation.C.

Referenced by get_eim_basis_function_side_values_at_qps(), and get_parametrized_function_side_value().

448 {
449  LOG_SCOPE("get_parametrized_function_side_values_at_qps()", "RBEIMConstruction");
450 
451  values.clear();
452 
453  const auto it = pf.find(std::make_pair(elem_id,side_index));
454  if (it != pf.end())
455  {
456  const auto & comps_and_qps_on_elem = it->second;
457  libmesh_error_msg_if(comp >= comps_and_qps_on_elem.size(),
458  "Invalid comp index: " << comp);
459 
460  values = comps_and_qps_on_elem[comp];
461  }
462 }

◆ 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 482 of file rb_eim_evaluation.C.

References libMesh::ParallelObject::comm(), get_parametrized_function_values_at_qps(), TIMPI::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().

488 {
489  std::vector<Number> values;
490  get_parametrized_function_values_at_qps(pf, elem_id, comp, values);
491 
492  // In parallel, values should only be non-empty on one processor
493  Number value = 0.;
494  if (!values.empty())
495  {
496  libmesh_error_msg_if(qp >= values.size(), "Error: Invalid qp index");
497 
498  value = values[qp];
499  }
500  comm.sum(value);
501 
502  return value;
503 }
void sum(T &r) const
const Parallel::Communicator & comm() const
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...
static const bool value
Definition: xdr_io.C:54

◆ 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 421 of file rb_eim_evaluation.C.

Referenced by get_eim_basis_function_values_at_qps(), and get_parametrized_function_value().

426 {
427  LOG_SCOPE("get_parametrized_function_values_at_qps()", "RBEIMConstruction");
428 
429  values.clear();
430 
431  const auto it = pf.find(elem_id);
432  if (it != pf.end())
433  {
434  const auto & comps_and_qps_on_elem = it->second;
435  libmesh_error_msg_if(comp >= comps_and_qps_on_elem.size(),
436  "Invalid comp index: " << comp);
437 
438  values = comps_and_qps_on_elem[comp];
439  }
440 }

◆ get_preserve_rb_eim_solutions()

bool RBEIMEvaluation::get_preserve_rb_eim_solutions ( ) const

Get _preserve_rb_eim_solutions.

Definition at line 886 of file rb_eim_evaluation.C.

References _preserve_rb_eim_solutions.

887 {
889 }
bool _preserve_rb_eim_solutions
Boolean to indicate if we skip updating _rb_eim_solutions in rb_eim_solves().

◆ get_rb_eim_error_indicators()

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

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

Definition at line 690 of file rb_eim_evaluation.C.

References _rb_eim_error_indicators.

691 {
693 }
std::vector< Real > _rb_eim_error_indicators
If we&#39;re using the EIM error indicator, then we store the error indicator values corresponding to _rb...

◆ 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 659 of file rb_eim_evaluation.C.

References _rb_eim_solutions.

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

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

◆ 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 664 of file rb_eim_evaluation.C.

References _rb_eim_solutions, and libMesh::index_range().

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

665 {
666  LOG_SCOPE("get_rb_eim_solutions_entries()", "RBEIMEvaluation");
667 
668  std::vector<Number> rb_eim_solutions_entries(_rb_eim_solutions.size());
669  for (unsigned int mu_index : index_range(_rb_eim_solutions))
670  {
671  libmesh_error_msg_if(index >= _rb_eim_solutions[mu_index].size(),
672  "Error: Requested solution index " << index <<
673  ", but only have " << _rb_eim_solutions[mu_index].size() << " entries.");
674  rb_eim_solutions_entries[mu_index] = _rb_eim_solutions[mu_index](index);
675  }
676 
677  return rb_eim_solutions_entries;
678 }
std::vector< DenseVector< Number > > _rb_eim_solutions
The EIM solution coefficients from the most recent call to rb_eim_solves().
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:111

◆ 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 643 of file rb_eim_evaluation.C.

References _local_side_eim_basis_functions.

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

644 {
646 }
std::vector< SideQpDataMap > _local_side_eim_basis_functions
The EIM basis functions on element sides.

◆ get_vec_eval_input()

const VectorizedEvalInput & RBEIMEvaluation::get_vec_eval_input ( ) const

Get the VectorizedEvalInput data.

Definition at line 3013 of file rb_eim_evaluation.C.

References _vec_eval_input.

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

3014 {
3015  return _vec_eval_input;
3016 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.

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

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

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

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 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
OStreamProxy err
static Counts _counts
Actually holds the data.
streamT * get()
Rather than implement every ostream/ios/ios_base function, we&#39;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

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

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

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

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 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
OStreamProxy err
static Counts _counts
Actually holds the data.
streamT * get()
Rather than implement every ostream/ios/ios_base function, we&#39;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

◆ 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 403 of file rb_eim_evaluation.C.

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

404 {
405  // Initialize the rb_theta objects that access the solution from this rb_eim_evaluation
406  _rb_eim_theta_objects.clear();
407  for (auto i : make_range(get_n_basis_functions()))
408  _rb_eim_theta_objects.emplace_back(build_eim_theta(i));
409 }
unsigned int get_n_basis_functions() const
Return the current number of EIM basis functions.
std::vector< std::unique_ptr< RBTheta > > _rb_eim_theta_objects
The vector of RBTheta objects that are created to point to this RBEIMEvaluation.
virtual std::unique_ptr< RBTheta > build_eim_theta(unsigned int index)
Build a theta object corresponding to EIM index index.
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:134

◆ 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 288 of file rb_eim_evaluation.C.

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

289 {
291 
294 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
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 ...
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()...
RBParametrizedFunction & get_parametrized_function()
Get a reference to the parametrized function.

◆ 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 296 of file rb_eim_evaluation.C.

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

297 {
300 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
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().
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()...
RBParametrizedFunction & get_parametrized_function()
Get a reference to the parametrized function.

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

References libMesh::RBParametrized::_discrete_parameter_values, libMesh::RBParameters::begin_serialized(), libMesh::RBParameters::end_serialized(), libMesh::RBParameters::n_parameters(), libMesh::RBParameters::n_samples(), libMesh::Quality::name(), 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::RBEIMConstruction::set_rb_construction_parameters(), libMesh::RBConstruction::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().

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 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
RBParameters parameters_min
Vectors that define the ranges (min and max) for the parameters.
std::map< std::string, std::vector< Real > > _discrete_parameter_values
Map that defines the allowable values of any discrete parameters.
bool set_parameters(const RBParameters &params)
Set the current parameters to params The parameters are checked for validity; an error is thrown if t...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void set_value(const std::string &param_name, Real value)
Set the value of the specified parameter.

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

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

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.

◆ is_discrete_parameter()

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

Is parameter mu_name discrete?

Definition at line 363 of file rb_parametrized.C.

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

364 {
365  libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::is_discrete_parameter");
366 
367  return (_discrete_parameter_values.find(mu_name) != _discrete_parameter_values.end());
368 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
std::map< std::string, std::vector< Real > > _discrete_parameter_values
Map that defines the allowable values of any discrete parameters.

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

References libMesh::ReferenceCounter::_n_objects.

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

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

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

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

Referenced by libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::DofMap::add_constraints_to_send_list(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::System::add_vector(), libMesh::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::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::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_scalar_dofs(), libMesh::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), gather_bfs(), libMesh::MeshBase::get_info(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), node_gather_bfs(), libMesh::Partitioner::partition(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::prepare_send_list(), libMesh::DofMap::print_dof_constraints(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::XdrIO::read_header(), libMesh::CheckpointIO::read_nodes(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::DistributedMesh::renumber_dof_objects(), 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::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::VTKIO::write_nodal_data(), libMesh::ExodusII_IO::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().

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  }
const Parallel::Communicator & _communicator
processor_id_type size() const
uint8_t processor_id_type
libmesh_assert(ctx)

◆ 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 379 of file rb_eim_evaluation.C.

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

381 {
382  LOG_SCOPE("node_decrement_vector()", "RBEIMEvaluation");
383 
384  libmesh_error_msg_if(get_n_basis_functions() != coeffs.size(),
385  "Error: Number of coefficients should match number of basis functions");
386 
387  for (auto & [node_id, v_comps] : v)
388  {
389  for (const auto & comp : index_range(v_comps))
390  for (unsigned int i : index_range(_local_node_eim_basis_functions))
391  {
392  // Check that entry (node_id,comp) exists in _local_node_eim_basis_functions so that
393  // we get a clear error message if there is any missing data
394  const auto & basis_comp = libmesh_map_find(_local_node_eim_basis_functions[i], node_id);
395 
396  libmesh_error_msg_if(comp >= basis_comp.size(), "Error: Invalid comp");
397 
398  v_comps[comp] -= coeffs(i) * basis_comp[comp];
399  }
400  }
401 }
unsigned int get_n_basis_functions() const
Return the current number of EIM basis functions.
std::vector< NodeDataMap > _local_node_eim_basis_functions
The EIM basis functions on element nodes (e.g.
virtual unsigned int size() const override final
Definition: dense_vector.h:104
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:111

◆ node_distribute_bfs()

void RBEIMEvaluation::node_distribute_bfs ( const System sys)
private

Same as distribute_bfs() except for node data.

Definition at line 2599 of file rb_eim_evaluation.C.

References _local_node_eim_basis_functions, TIMPI::Communicator::broadcast(), clear(), libMesh::ParallelObject::comm(), TIMPI::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(), TIMPI::Communicator::rank(), TIMPI::Communicator::scatter(), and TIMPI::Communicator::size().

Referenced by read_in_node_basis_functions().

2600 {
2601  // So we can avoid calling these many times below
2602  auto n_procs = sys.comm().size();
2603  auto rank = sys.comm().rank();
2604 
2605  // In serial there's nothing to distribute
2606  if (n_procs == 1)
2607  return;
2608 
2609  // Broadcast the number of basis functions from proc 0. After
2610  // distributing, all procs should have the same number of basis
2611  // functions.
2612  auto n_bf = _local_node_eim_basis_functions.size();
2613  sys.comm().broadcast(n_bf);
2614 
2615  // Allocate enough space to store n_bf basis functions on non-zero ranks
2616  if (rank != 0)
2617  _local_node_eim_basis_functions.resize(n_bf);
2618 
2619  // Broadcast the number of variables from proc 0. After
2620  // distributing, all procs should have the same number of variables.
2621  auto n_vars = _local_node_eim_basis_functions[0].begin()->second.size();
2622  sys.comm().broadcast(n_vars);
2623 
2624  // Construct lists of elem ids owned by different processors
2625  const MeshBase & mesh = sys.get_mesh();
2626 
2627  std::vector<dof_id_type> gathered_local_node_ids;
2628  {
2629  const std::set<boundary_id_type> & parametrized_function_boundary_ids =
2631 
2632  const auto & binfo = mesh.get_boundary_info();
2633 
2634  // Make a set with all the nodes that have nodesets. Use
2635  // a set so that we don't have any duplicate entries. We
2636  // deal with duplicate entries below by getting all boundary
2637  // IDs on each node.
2638  std::set<dof_id_type> nodes_with_nodesets;
2639  for (const auto & t : binfo.build_node_list())
2640  nodes_with_nodesets.insert(std::get<0>(t));
2641 
2642  // To be filled in by BoundaryInfo calls in loop below
2643  std::vector<boundary_id_type> node_boundary_ids;
2644 
2645  for(dof_id_type node_id : nodes_with_nodesets)
2646  {
2647  const Node * node = mesh.node_ptr(node_id);
2648 
2649  if (node->processor_id() != mesh.comm().rank())
2650  continue;
2651 
2652  binfo.boundary_ids(node, node_boundary_ids);
2653 
2654  bool has_node_boundary_id = false;
2655  for(boundary_id_type node_boundary_id : node_boundary_ids)
2656  if(parametrized_function_boundary_ids.count(node_boundary_id))
2657  {
2658  has_node_boundary_id = true;
2659  break;
2660  }
2661 
2662  if(has_node_boundary_id)
2663  {
2664  gathered_local_node_ids.push_back(node_id);
2665  }
2666  }
2667  }
2668 
2669  // I _think_ the local node ids are likely to already be sorted in
2670  // ascending order, since that is how they are stored on the Mesh,
2671  // but we can always just guarantee this to be on the safe side as
2672  // well.
2673  std::sort(gathered_local_node_ids.begin(), gathered_local_node_ids.end());
2674 
2675  // Gather the number of local nodes from all procs to proc 0
2676  auto n_local_nodes = gathered_local_node_ids.size();
2677  std::vector<std::size_t> gathered_n_local_nodes = {n_local_nodes};
2678  sys.comm().gather(/*root_id=*/0, gathered_n_local_nodes);
2679 
2680  // Gather the node ids owned by each processor onto processor 0.
2681  sys.comm().gather(/*root_id=*/0, gathered_local_node_ids);
2682 
2683  // Construct vectors of "start" and "one-past-the-end" indices into
2684  // the gathered_local_node_ids vector for each proc. Only valid on
2685  // processor 0.
2686  std::vector<std::size_t> start_node_ids_index, end_node_ids_index;
2687 
2688  if (rank == 0)
2689  {
2690  start_node_ids_index.resize(n_procs);
2691  start_node_ids_index[0] = 0;
2692  for (processor_id_type p=1; p<n_procs; ++p)
2693  start_node_ids_index[p] = start_node_ids_index[p-1] + gathered_n_local_nodes[p-1];
2694 
2695  end_node_ids_index.resize(n_procs);
2696  end_node_ids_index[n_procs - 1] = gathered_local_node_ids.size();
2697  for (processor_id_type p=0; p<n_procs - 1; ++p)
2698  end_node_ids_index[p] = start_node_ids_index[p+1];
2699  }
2700 
2701  // On processor 0, using basis function 0 and variable 0, prepare a
2702  // vector with the nodes. Then scatter this vector
2703  // out to the processors that require it. The order of this vector
2704  // matches the gathered_local_node_ids ordering. The counts will be
2705  // gathered_n_local_nodes.
2706 
2707  // On rank 0, the "counts" vector holds the number of floating point values that
2708  // are to be scattered to each proc. It is only required on proc 0.
2709  std::vector<int> counts;
2710 
2711  if (rank == 0)
2712  {
2713  counts.resize(n_procs);
2714 
2715  for (processor_id_type p=0; p<n_procs; ++p)
2716  {
2717  auto node_ids_range = (end_node_ids_index[p] - start_node_ids_index[p]);
2718 
2719  // Accumulate the count for this proc
2720  counts[p] += node_ids_range;
2721  } // end for proc_id
2722  } // if (rank == 0)
2723 
2724  // The recv_node_data vector will be used on the receiving end of all
2725  // the scatters below.
2726  std::vector<Number> recv_node_data;
2727 
2728  // For each basis function and each variable, build a vector
2729  // data in the Node ordering given by the
2730  // gathered_local_node_ids, then call
2731  //
2732  // sys.comm().scatter(data, counts, recv, /*root_id=*/0);
2733  std::vector<std::vector<Number>> node_data(n_vars);
2734 
2735  // We also reserve space in node_data, since we will push_back into it below.
2736  int count_sum = std::accumulate(counts.begin(), counts.end(), 0);
2737  for (auto var : index_range(node_data))
2738  node_data[var].reserve(count_sum);
2739 
2740  // Loop from 0..n_bf on _all_ procs, since the scatters inside this
2741  // loop are collective.
2742  for (auto bf : make_range(n_bf))
2743  {
2744  // Prepare data for scattering (only on proc 0)
2745  if (rank == 0)
2746  {
2747  // Reference to the data map for the current basis function.
2748  auto & bf_map = _local_node_eim_basis_functions[bf];
2749 
2750  // Clear any data from previous bf (this does not change the capacity
2751  // that was reserved above).
2752  for (auto var : index_range(node_data))
2753  node_data[var].clear();
2754 
2755  for (processor_id_type p=0; p<n_procs; ++p)
2756  {
2757  for (auto n : make_range(start_node_ids_index[p], end_node_ids_index[p]))
2758  {
2759  auto node_id = gathered_local_node_ids[n];
2760 
2761  // Get reference to array[n_vars] for current Node.
2762  // Throws an error if the required node_id is not found.
2763  const auto & array = libmesh_map_find(bf_map, node_id);
2764 
2765  for (auto var : index_range(array))
2766  node_data[var].push_back(array[var]);
2767  } // end for (n)
2768  } // end for proc_id
2769  } // end if rank==0
2770 
2771  // Perform the scatters (all procs)
2772  for (auto var : make_range(n_vars))
2773  {
2774  // Do the scatter for the current var
2775  sys.comm().scatter(node_data[var], counts, recv_node_data, /*root_id=*/0);
2776 
2777  if (rank != 0)
2778  {
2779  // Store the scattered data we received in _local_eim_basis_functions[bf]
2780  auto & bf_map = _local_node_eim_basis_functions[bf];
2781  auto cursor = recv_node_data.begin();
2782 
2783  for (auto i : index_range(gathered_local_node_ids))
2784  {
2785  auto node_id = gathered_local_node_ids[i];
2786  auto & array = bf_map[node_id];
2787 
2788  // Create space to store the data if it doesn't already exist.
2789  if (array.empty())
2790  array.resize(n_vars);
2791 
2792  // There is only one value per variable per node, so
2793  // we set the value by de-referencing cursor, and
2794  // then advance the cursor by 1.
2795  array[var] = *cursor;
2796  std::advance(cursor, 1);
2797  }
2798  } // if (rank != 0)
2799  } // end for (var)
2800  } // end for (bf)
2801 
2802  // Now that the scattering is done, delete non-local Elem
2803  // information from processor 0's _local_eim_basis_functions data
2804  // structure.
2805  if (rank == 0)
2806  {
2807  for (processor_id_type p=1; p<n_procs; ++p)
2808  {
2809  for (auto n : make_range(start_node_ids_index[p], end_node_ids_index[p]))
2810  {
2811  auto node_id = gathered_local_node_ids[n];
2812 
2813  // Delete this Node's information from every basis function.
2814  for (auto & bf_map : _local_node_eim_basis_functions)
2815  bf_map.erase(node_id);
2816  } // end for (n)
2817  } // end for proc_id
2818  } // if (rank == 0)
2819 }
virtual void clear() override
Clear this object.
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 ...
MeshBase & mesh
uint8_t processor_id_type
std::vector< NodeDataMap > _local_node_eim_basis_functions
The EIM basis functions on element nodes (e.g.
int8_t boundary_id_type
Definition: id_types.h:51
unsigned int n_vars
const boundary_id_type node_boundary_id
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:134
RBParametrizedFunction & get_parametrized_function()
Get a reference to the parametrized function.
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:111
uint8_t dof_id_type
Definition: id_types.h:67

◆ node_gather_bfs()

void RBEIMEvaluation::node_gather_bfs ( )
private

Same as gather_bfs() except for node data.

Definition at line 1978 of file rb_eim_evaluation.C.

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

Referenced by write_out_node_basis_functions().

1979 {
1980  // We need to gather _local_node_eim_basis_functions data from other
1981  // procs for printing.
1982  //
1983  // Ideally, this could be accomplished by simply calling:
1984  // this->comm().gather(/*root_id=*/0, _local_node_eim_basis_functions);
1985  //
1986  // but the data structure seems to be too complicated for this to
1987  // work automatically. (I get some error about the function called
1988  // being "private within this context".) Therefore, we have to
1989  // gather the information manually.
1990 
1991  // So we can avoid calling this many times below
1992  auto n_procs = this->n_processors();
1993 
1994  // In serial there's nothing to gather
1995  if (n_procs == 1)
1996  return;
1997 
1998  // Current assumption is that the number of basis functions stored on
1999  // each processor is the same, the only thing that differs is the number
2000  // of elements, so make sure that is the case now.
2001  auto n_bf = _local_node_eim_basis_functions.size();
2002  this->comm().verify(n_bf);
2003 
2004  // This function should never be called if there are no basis
2005  // functions, so if it was, something went wrong.
2006  libmesh_error_msg_if(!n_bf, "RBEIMEvaluation::gather_bfs() should not be called with 0 basis functions.");
2007 
2008  // The number of variables should be the same on all processors
2009  // and we can get this from _local_eim_basis_functions. However,
2010  // it may be that some processors have no local elements, so on
2011  // those processors we cannot look up the size from
2012  // _local_eim_basis_functions. As a result we use comm().max(n_vars)
2013  // to make sure all processors agree on the final value.
2014  std::size_t n_vars =
2015  _local_node_eim_basis_functions[0].empty() ? 0 : _local_node_eim_basis_functions[0].begin()->second.size();
2016  this->comm().max(n_vars);
2017 
2018  // Gather list of Node ids stored on each processor to proc 0. We
2019  // use basis function 0 as an example and assume all the basis
2020  // functions are distributed similarly.
2021  unsigned int n_local_nodes = _local_node_eim_basis_functions[0].size();
2022  std::vector<dof_id_type> node_ids;
2023  node_ids.reserve(n_local_nodes);
2024  for (const auto & pr : _local_node_eim_basis_functions[0])
2025  node_ids.push_back(pr.first);
2026  this->comm().gather(/*root_id=*/0, node_ids);
2027 
2028  // Now we construct a vector for each basis function, for each
2029  // variable, which is ordered according to:
2030  // [ [val for Node 0], [val for Node 1], ... [val for Node N] ]
2031  // and gather it to processor 0.
2032  std::vector<std::vector<Number>> gathered_node_data(n_vars);
2034  {
2035  // Clear any data from previous bf
2036  for (auto var : index_range(gathered_node_data))
2037  {
2038  gathered_node_data[var].clear();
2039  gathered_node_data[var].resize(n_local_nodes);
2040  }
2041 
2042  unsigned int local_node_idx = 0;
2043  for (const auto & pr : _local_node_eim_basis_functions[bf])
2044  {
2045  // array[n_vars] per Node
2046  const auto & array = pr.second;
2047  for (auto var : index_range(array))
2048  {
2049  gathered_node_data[var][local_node_idx] = array[var];
2050  }
2051 
2052  local_node_idx++;
2053  }
2054 
2055  // Reference to the data map for the current basis function.
2056  auto & bf_map = _local_node_eim_basis_functions[bf];
2057 
2058  for (auto var : index_range(gathered_node_data))
2059  {
2060  // For each var, gather gathered_qp_data[var] onto processor
2061  // 0. There apparently is not a gather overload for
2062  // vector-of-vectors...
2063  this->comm().gather(/*root_id=*/0, gathered_node_data[var]);
2064 
2065  // On processor 0, iterate over the gathered_qp_data[var]
2066  // vector we just gathered, filling in the "small" vectors
2067  // for each Elem. Note: here we ignore the fact that we
2068  // already have the data on processor 0 and just overwrite
2069  // it, this makes the indexing logic a bit simpler.
2070  if (this->processor_id() == 0)
2071  {
2072  auto cursor = gathered_node_data[var].begin();
2073  for (auto i : index_range(node_ids))
2074  {
2075  auto node_id = node_ids[i];
2076 
2077  // Get reference to the [n_vars] array for
2078  // this Node. We assign() into the vector of
2079  // node values, which allocates space if
2080  // it doesn't already exist.
2081  auto & array = bf_map[node_id];
2082 
2083  // Possibly allocate space if this is data for a new
2084  // node we haven't seen before.
2085  if (array.empty())
2086  array.resize(n_vars);
2087 
2088  // There is only one value per variable per node, so
2089  // we set the value by de-referencing cursor, and
2090  // then advance the cursor by 1.
2091  array[var] = *cursor;
2092  std::advance(cursor, 1);
2093  }
2094  }
2095  }
2096  } // end loop over basis functions
2097 }
bool verify(const T &r) const
void gather(const unsigned int root_id, const T &send_data, std::vector< T, A > &recv) const
const Parallel::Communicator & comm() const
std::vector< NodeDataMap > _local_node_eim_basis_functions
The EIM basis functions on element nodes (e.g.
processor_id_type n_processors() const
unsigned int n_vars
void max(const T &r, T &o, Request &req) const
processor_id_type processor_id() const
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:111

◆ 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 377 of file rb_parametrized.C.

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

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

378 {
379  for (const auto & [name, values] : get_discrete_parameter_values())
380  {
381  libMesh::out << "Discrete parameter " << name << ", values: ";
382 
383  for (const auto & value : values)
384  libMesh::out << value << " ";
385  libMesh::out << std::endl;
386  }
387 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
const std::map< std::string, std::vector< Real > > & get_discrete_parameter_values() const
Get a const reference to the discrete parameter values.
OStreamProxy out
static const bool value
Definition: xdr_io.C:54

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

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

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

82 {
84  out_stream << ReferenceCounter::get_info();
85 }
static std::string get_info()
Gets a string containing the reference information.
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...

◆ 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 1631 of file rb_eim_evaluation.C.

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

1632 {
1633  for (auto bf : index_range(_local_eim_basis_functions))
1634  {
1635  libMesh::out << "Interior basis function " << bf << std::endl;
1636  for (const auto & [elem_id, array] : _local_eim_basis_functions[bf])
1637  {
1638  libMesh::out << "Elem " << elem_id << std::endl;
1639  for (auto var : index_range(array))
1640  {
1641  libMesh::out << "Variable " << var << std::endl;
1642  for (auto qp : index_range(array[var]))
1643  libMesh::out << array[var][qp] << " ";
1644  libMesh::out << std::endl;
1645  }
1646  }
1647  }
1648 
1650  {
1651  libMesh::out << "Side basis function " << bf << std::endl;
1652  for (const auto & [pr, array] : _local_side_eim_basis_functions[bf])
1653  {
1654  const auto & elem_id = pr.first;
1655  const auto & side_index = pr.second;
1656  libMesh::out << "Elem " << elem_id << ", Side " << side_index << std::endl;
1657  for (auto var : index_range(array))
1658  {
1659  libMesh::out << "Variable " << var << std::endl;
1660  for (auto qp : index_range(array[var]))
1661  libMesh::out << array[var][qp] << " ";
1662  libMesh::out << std::endl;
1663  }
1664  }
1665  }
1666 
1668  {
1669  libMesh::out << "Node basis function " << bf << std::endl;
1670  for (const auto & [node_id, array] : _local_node_eim_basis_functions[bf])
1671  {
1672  libMesh::out << "Node " << node_id << std::endl;
1673  for (auto var : index_range(array))
1674  {
1675  libMesh::out << "Variable " << var << ": " << array[var] << std::endl;
1676  }
1677  libMesh::out << std::endl;
1678  }
1679  }
1680 }
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.
OStreamProxy out
std::vector< QpDataMap > _local_eim_basis_functions
The 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:111

◆ print_parameters()

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

Print the current parameters.

Definition at line 190 of file rb_parametrized.C.

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

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

191 {
192  libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::print_current_parameters");
193 
194  get_parameters().print();
195 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
void print() const
Print the parameters.
const RBParameters & get_parameters() const
Get the current parameters.

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

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

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::MeshTools::Modification::all_tri(), libMesh::DofMap::allgather_recursive_constraints(), 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::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::DistributedMesh::delete_elem(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DofMap::distribute_scalar_dofs(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::MeshFunction::find_element(), libMesh::MeshFunction::find_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMap::first_dof(), libMesh::DofMap::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::DofMap::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::DofMap::get_local_constraints(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::LaplaceMeshSmoother::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), HeatSystem::init_data(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::DistributedMesh::insert_elem(), libMesh::DofMap::is_evaluable(), libMesh::SparsityPattern::Build::join(), libMesh::TransientRBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEvaluation::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(), libMesh::DofMap::local_variable_indices(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), AugmentSparsityOnInterface::mesh_reinit(), libMesh::TriangulatorInterface::MeshedHole::MeshedHole(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMap::n_local_dofs(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), node_gather_bfs(), libMesh::SparsityPattern::Build::operator()(), libMesh::DistributedMesh::own_node(), libMesh::BoundaryInfo::parallel_sync_node_ids(), libMesh::BoundaryInfo::parallel_sync_side_ids(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), 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::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read(), libMesh::EquationSystems::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), libMesh::ExodusII_IO::read_header(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::DynaIO::read_mesh(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::System::read_serialized_data(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::Nemesis_IO_Helper::read_var_names_impl(), 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(), ExodusTest< elem_type >::test_read_gold(), ExodusTest< elem_type >::test_write(), MeshInputTest::testAbaqusRead(), 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::testLowOrderEdgeBlocks(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), BoundaryInfoTest::testShellFaceConstraints(), MeshInputTest::testSingleElementImpl(), WriteVecAndScalar::testSolution(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::DTKAdapter::update_variable_values(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::CheckpointIO::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_element_values_element_major(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO_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::UCDIO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), libMesh::ExodusII_IO::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::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_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::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), libMesh::ExodusII_IO_Helper::write_timestep(), and libMesh::ExodusII_IO::write_timestep_discontinuous().

115  { return cast_int<processor_id_type>(_communicator.rank()); }
processor_id_type rank() const
const Parallel::Communicator & _communicator

◆ project_qp_data_map_onto_system()

void RBEIMEvaluation::project_qp_data_map_onto_system ( System sys,
const QpDataMap bf_data,
unsigned int  var 
)

Project variable var of bf_data into the solution vector of System.

Definition at line 2821 of file rb_eim_evaluation.C.

References libMesh::DenseMatrix< T >::cholesky_solve(), libMesh::System::current_local_solution, dim, libMesh::MeshBase::elem_dimensions(), libMesh::FEAbstract::get_JxW(), libMesh::System::get_mesh(), libMesh::FEGenericBase< OutputType >::get_phi(), libMesh::make_range(), libMesh::System::n_vars(), and libMesh::System::solution.

Referenced by write_out_projected_basis_functions().

2824 {
2825  LOG_SCOPE("project_basis_function_onto_system()", "RBEIMEvaluation");
2826 
2827  libmesh_error_msg_if(sys.n_vars() == 0, "System must have at least one variable");
2828 
2829  FEMContext context(sys);
2830  {
2831  // Pre-request relevant data for all dimensions
2832  for (unsigned int dim=1; dim<=3; ++dim)
2833  if (sys.get_mesh().elem_dimensions().count(dim))
2834  for (auto init_var : make_range(sys.n_vars()))
2835  {
2836  auto fe = context.get_element_fe(init_var, dim);
2837  fe->get_JxW();
2838  fe->get_phi();
2839  }
2840  }
2841 
2842  FEBase * elem_fe = nullptr;
2843  context.get_element_fe( 0, elem_fe );
2844  const std::vector<Real> & JxW = elem_fe->get_JxW();
2845  const std::vector<std::vector<Real>> & phi = elem_fe->get_phi();
2846 
2847  // Get a reference to the current_local_solution vector, which has
2848  // GHOSTED DOFs. Make sure it is initially zeroed, since we will now
2849  // accumulate values into it.
2850  auto & current_local_soln = *(sys.current_local_solution);
2851  current_local_soln.zero();
2852 
2853  // The repeat_count vector will store the number of times a
2854  // projected value has been assigned to a node. We get a reference
2855  // to it for convenience in the code below.
2856  std::unique_ptr<NumericVector<Number>> repeat_count_ptr = current_local_soln.zero_clone();
2857  auto & repeat_count = *repeat_count_ptr;
2858 
2859  for (const auto & elem : sys.get_mesh().active_local_element_ptr_range())
2860  {
2861  context.pre_fe_reinit(sys, elem);
2862  context.elem_fe_reinit();
2863 
2864  const std::vector<dof_id_type> & dof_indices = context.get_dof_indices(/*var=*/0);
2865  unsigned int n_proj_dofs = dof_indices.size();
2866  unsigned int n_qpoints = context.get_element_qrule().n_points();
2867 
2868  const std::vector<std::vector<Number>> & var_and_qp_data = libmesh_map_find(qp_data_map, elem->id());
2869  libmesh_error_msg_if(var >= var_and_qp_data.size(), "Invalid EIM variable number: " << var);
2870  const std::vector<Number> & qp_data = var_and_qp_data[var];
2871 
2872  // If qp_data doesn't match n_qpoints then we skip this element since this means
2873  // that the EIM basis function is not applicable on this element. This can happen,
2874  // for example, if we have 1D and 3D elements in the same mesh and the EIM basis
2875  // functions have been set up for the 3D elements only. Note that the EIM is
2876  // necessarily dependent on the element dimension since it is based on the number
2877  // of quad. points per element. If multiple dimensions need to be supported then
2878  // one can add a separate EIM for each dimension.
2879  if (qp_data.size() != n_qpoints)
2880  continue;
2881 
2882  DenseMatrix<Number> Me(n_proj_dofs, n_proj_dofs);
2883  DenseVector<Number> Fe(n_proj_dofs);
2884  for (auto qp : make_range(n_qpoints))
2885  for (auto i : make_range(n_proj_dofs))
2886  {
2887  Fe(i) += JxW[qp] * qp_data[qp] * phi[i][qp];
2888 
2889  for (auto j : make_range(n_proj_dofs))
2890  Me(i,j) += JxW[qp] * phi[i][qp] * phi[j][qp];
2891  }
2892 
2893  DenseVector<Number> projected_data;
2894  Me.cholesky_solve(Fe, projected_data);
2895 
2896  for (auto i : make_range(n_proj_dofs))
2897  {
2898  current_local_soln.add(dof_indices[i], projected_data(i));
2899  repeat_count.add(dof_indices[i], 1.);
2900  }
2901  }
2902 
2903  current_local_soln.close();
2904  repeat_count.close();
2905 
2906  // Average the projected QP values to get nodal values
2907  current_local_soln /= repeat_count;
2908  current_local_soln.close();
2909 
2910  // Copy values from the GHOSTED current_local_solution vector into
2911  // sys.solution, since that is what will ultimately be plotted/used
2912  // by other parts of the code.
2913  (*sys.solution) = current_local_soln;
2914 }
unsigned int dim
FEGenericBase< Real > FEBase
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:134

◆ 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 103 of file rb_eim_evaluation.C.

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

104 {
105  LOG_SCOPE("rb_eim_solve()", "RBEIMEvaluation");
106 
107  libmesh_error_msg_if(EIM_rhs.size() > get_n_basis_functions(),
108  "Error: N cannot be larger than the number of basis functions in rb_solve");
109 
110  libmesh_error_msg_if(EIM_rhs.size()==0, "Error: N must be greater than 0 in rb_solve");
111 
112  const unsigned int N = EIM_rhs.size();
113  DenseVector<Number> rb_eim_solution(N);
114  DenseMatrix<Number> interpolation_matrix_N;
115  _interpolation_matrix.get_principal_submatrix(N, interpolation_matrix_N);
116 
117  interpolation_matrix_N.lu_solve(EIM_rhs, rb_eim_solution);
118 
119  return rb_eim_solution;
120 }
unsigned int get_n_basis_functions() const
Return the current number of EIM basis functions.
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.
virtual unsigned int size() const override final
Definition: dense_vector.h:104
DenseMatrix< Number > _interpolation_matrix
Dense matrix that stores the lower triangular interpolation matrix that can be used.

◆ 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 122 of file rb_eim_evaluation.C.

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::index_range(), libMesh::libmesh_ignore(), 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().

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

◆ 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 1325 of file rb_eim_evaluation.C.

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

1328 {
1329  LOG_SCOPE("read_in_basis_functions()", "RBEIMEvaluation");
1330 
1331  // Return early without reading in anything if there are no basis functions
1332  if (get_n_basis_functions() == 0)
1333  return;
1334 
1335  if (get_parametrized_function().on_mesh_sides())
1336  read_in_side_basis_functions(sys, directory_name, read_binary_basis_functions);
1337  else if (get_parametrized_function().on_mesh_nodes())
1338  read_in_node_basis_functions(sys, directory_name, read_binary_basis_functions);
1339  else
1340  read_in_interior_basis_functions(sys, directory_name, read_binary_basis_functions);
1341 }
unsigned int get_n_basis_functions() const
Return the current number of 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_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.
RBParametrizedFunction & get_parametrized_function()
Get a reference to the parametrized function.

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

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

Referenced by read_in_basis_functions().

1347 {
1348  LOG_SCOPE("read_in_interior_basis_functions()", "RBEIMEvaluation");
1349 
1350  // Read values on processor 0 only.
1351  if (sys.comm().rank() == 0)
1352  {
1353  // Create filename
1354  std::ostringstream file_name;
1355  const std::string basis_function_suffix = (read_binary_basis_functions ? ".xdr" : ".dat");
1356  file_name << directory_name << "/" << "bf_data" << basis_function_suffix;
1357 
1358  // Create XDR reader object
1359  Xdr xdr(file_name.str(), read_binary_basis_functions ? DECODE : READ);
1360 
1361  // Read in the number of basis functions. The comment parameter
1362  // is ignored when reading.
1363  std::size_t n_bf;
1364  xdr.data(n_bf);
1365 
1366  // Read in the number of elements
1367  std::size_t n_elem;
1368  xdr.data(n_elem);
1369 
1370  // Read in the number of variables.
1371  std::size_t n_vars;
1372  xdr.data(n_vars);
1373 
1374  // Read in vector containing the number of QPs per elem. We can
1375  // create this vector with the required size or let it be read
1376  // from the file and sized for us.
1377  std::vector<unsigned int> n_qp_per_elem(n_elem);
1378  xdr.data(n_qp_per_elem);
1379 
1380  // The total amount of qp data for each var is the sum of the
1381  // entries in the "n_qp_per_elem" array.
1382  auto n_qp_data =
1383  std::accumulate(n_qp_per_elem.begin(),
1384  n_qp_per_elem.end(),
1385  0u);
1386 
1387  // Allocate space to store all required basis functions,
1388  // clearing any data that may have been there previously.
1389  //
1390  // TODO: Do we need to also write out/read in Elem ids?
1391  // Or can we assume they will always be contiguously
1392  // numbered (at least on proc 0)?
1394  _local_eim_basis_functions.resize(n_bf);
1395  for (auto i : index_range(_local_eim_basis_functions))
1396  for (std::size_t elem_id=0; elem_id<n_elem; ++elem_id)
1397  {
1398  auto & array = _local_eim_basis_functions[i][elem_id];
1399  array.resize(n_vars);
1400  }
1401 
1402  // Allocate temporary storage for one var's worth of qp data.
1403  std::vector<Number> qp_data;
1404 
1405  // Read in data for each basis function
1406  for (auto i : index_range(_local_eim_basis_functions))
1407  {
1408  // Reference to the data map for the current basis function.
1409  auto & bf_map = _local_eim_basis_functions[i];
1410 
1411  for (std::size_t var=0; var<n_vars; ++var)
1412  {
1413  qp_data.clear();
1414  qp_data.resize(n_qp_data);
1415 
1416  // Read data using data_stream() since that is
1417  // (currently) how we write it out. The "line_break"
1418  // parameter of data_stream() is ignored while reading.
1419  xdr.data_stream(qp_data.data(), qp_data.size());
1420 
1421  // Iterate over the qp_data vector, filling in the
1422  // "small" vectors for each Elem.
1423  auto cursor = qp_data.begin();
1424  for (std::size_t elem_id=0; elem_id<n_elem; ++elem_id)
1425  {
1426  // Get reference to the [n_vars][n_qp] array for
1427  // this Elem. We assign() into the vector of
1428  // quadrature point values, which allocates space if
1429  // it doesn't already exist.
1430  auto & array = bf_map[elem_id];
1431  array[var].assign(cursor, cursor + n_qp_per_elem[elem_id]);
1432  std::advance(cursor, n_qp_per_elem[elem_id]);
1433  }
1434  } // end for (var)
1435  } // end for (i)
1436  } // end if processor 0
1437 
1438  // Distribute the basis function information to the processors that require it
1439  this->distribute_bfs(sys);
1440 }
void distribute_bfs(const System &sys)
Helper function that distributes the entries of _local_eim_basis_functions to their respective proces...
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Count up the number of elements of a specific type (as defined by an iterator range).
Definition: mesh_tools.C:850
unsigned int n_vars
std::vector< QpDataMap > _local_eim_basis_functions
The 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:111

◆ 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 1551 of file rb_eim_evaluation.C.

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

Referenced by read_in_basis_functions().

1554 {
1555  LOG_SCOPE("read_in_node_basis_functions()", "RBEIMEvaluation");
1556 
1557  // Read values on processor 0 only.
1558  if (sys.comm().rank() == 0)
1559  {
1560  // Create filename
1561  std::ostringstream file_name;
1562  const std::string basis_function_suffix = (read_binary_basis_functions ? ".xdr" : ".dat");
1563  file_name << directory_name << "/" << "bf_data" << basis_function_suffix;
1564 
1565  // Create XDR reader object
1566  Xdr xdr(file_name.str(), read_binary_basis_functions ? DECODE : READ);
1567 
1568  // Read in the number of basis functions. The comment parameter
1569  // is ignored when reading.
1570  std::size_t n_bf;
1571  xdr.data(n_bf);
1572 
1573  // Read in the number of nodes
1574  std::size_t n_node;
1575  xdr.data(n_node);
1576 
1577  // Read in the number of variables.
1578  std::size_t n_vars;
1579  xdr.data(n_vars);
1580 
1581  std::vector<unsigned int> node_ids(n_node);
1582  xdr.data(node_ids);
1583 
1584  // Allocate space to store all required basis functions,
1585  // clearing any data that may have been there previously.
1586  //
1587  // TODO: Do we need to also write out/read in Node ids?
1588  // Or can we assume they will always be contiguously
1589  // numbered (at least on proc 0)?
1591  _local_node_eim_basis_functions.resize(n_bf);
1593  for (auto node_id : node_ids)
1594  {
1595  auto & array = _local_node_eim_basis_functions[i][node_id];
1596  array.resize(n_vars);
1597  }
1598 
1599  // Read data into node_value from xdr
1600  std::vector<Number> node_value;
1601 
1602  // Read in data for each basis function
1604  {
1605  // Reference to the data map for the current basis function.
1606  auto & bf_map = _local_node_eim_basis_functions[i];
1607 
1608  for (std::size_t var=0; var<n_vars; ++var)
1609  {
1610  node_value.clear();
1611  node_value.resize(n_node);
1612 
1613  // Read data using data_stream() since that is
1614  // (currently) how we write it out. The "line_break"
1615  // parameter of data_stream() is ignored while reading.
1616  xdr.data_stream(node_value.data(), node_value.size());
1617 
1618  for (unsigned int node_counter=0; node_counter<n_node; node_counter++)
1619  {
1620  auto & array = bf_map[node_ids[node_counter]];
1621  array[var] = node_value[node_counter];
1622  }
1623  } // end for (var)
1624  } // end for (i)
1625  } // end if processor 0
1626 
1627  // Distribute the basis function information to the processors that require it
1628  this->node_distribute_bfs(sys);
1629 }
std::vector< NodeDataMap > _local_node_eim_basis_functions
The EIM basis functions on element nodes (e.g.
unsigned int n_vars
void node_distribute_bfs(const System &sys)
Same as distribute_bfs() except for node data.
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:111

◆ 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 1443 of file rb_eim_evaluation.C.

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

Referenced by read_in_basis_functions().

1446 {
1447  LOG_SCOPE("read_in_basis_functions()", "RBEIMEvaluation");
1448 
1449  // Read values on processor 0 only.
1450  if (sys.comm().rank() == 0)
1451  {
1452  // Create filename
1453  std::ostringstream file_name;
1454  const std::string basis_function_suffix = (read_binary_basis_functions ? ".xdr" : ".dat");
1455  file_name << directory_name << "/" << "bf_data" << basis_function_suffix;
1456 
1457  // Create XDR reader object
1458  Xdr xdr(file_name.str(), read_binary_basis_functions ? DECODE : READ);
1459 
1460  // Read in the number of basis functions. The comment parameter
1461  // is ignored when reading.
1462  std::size_t n_bf;
1463  xdr.data(n_bf);
1464 
1465  // Read in the number of elements
1466  std::size_t n_elem_side;
1467  xdr.data(n_elem_side);
1468 
1469  // Read in the number of variables.
1470  std::size_t n_vars;
1471  xdr.data(n_vars);
1472 
1473  std::vector<unsigned int> elem_ids(n_elem_side);
1474  xdr.data(elem_ids);
1475  std::vector<unsigned int> side_indices(n_elem_side);
1476  xdr.data(side_indices);
1477 
1478  // Read in vector containing the number of QPs per elem. We can
1479  // create this vector with the required size or let it be read
1480  // from the file and sized for us.
1481  std::vector<unsigned int> n_qp_per_elem_side(n_elem_side);
1482  xdr.data(n_qp_per_elem_side);
1483 
1484  // The total amount of qp data for each var is the sum of the
1485  // entries in the "n_qp_per_elem" array.
1486  auto n_qp_data =
1487  std::accumulate(n_qp_per_elem_side.begin(),
1488  n_qp_per_elem_side.end(),
1489  0u);
1490 
1491  // Allocate space to store all required basis functions,
1492  // clearing any data that may have been there previously.
1494  _local_side_eim_basis_functions.resize(n_bf);
1496  for (std::size_t elem_side_idx=0; elem_side_idx<n_elem_side; ++elem_side_idx)
1497  {
1498  unsigned int elem_id = elem_ids[elem_side_idx];
1499  unsigned int side_index = side_indices[elem_side_idx];
1500  auto elem_side_pair = std::make_pair(elem_id, side_index);
1501 
1502  auto & array = _local_side_eim_basis_functions[i][elem_side_pair];
1503  array.resize(n_vars);
1504  }
1505 
1506  // Allocate temporary storage for one var's worth of qp data.
1507  std::vector<Number> qp_data;
1508 
1509  // Read in data for each basis function
1511  {
1512  // Reference to the data map for the current basis function.
1513  auto & bf_map = _local_side_eim_basis_functions[i];
1514 
1515  for (std::size_t var=0; var<n_vars; ++var)
1516  {
1517  qp_data.clear();
1518  qp_data.resize(n_qp_data);
1519 
1520  // Read data using data_stream() since that is
1521  // (currently) how we write it out. The "line_break"
1522  // parameter of data_stream() is ignored while reading.
1523  xdr.data_stream(qp_data.data(), qp_data.size());
1524 
1525  // Iterate over the qp_data vector, filling in the
1526  // "small" vectors for each Elem.
1527  auto cursor = qp_data.begin();
1528  for (std::size_t elem_side_idx=0; elem_side_idx<n_elem_side; ++elem_side_idx)
1529  {
1530  unsigned int elem_id = elem_ids[elem_side_idx];
1531  unsigned int side_index = side_indices[elem_side_idx];
1532  auto elem_side_pair = std::make_pair(elem_id, side_index);
1533 
1534  // Get reference to the [n_vars][n_qp] array for
1535  // this Elem. We assign() into the vector of
1536  // quadrature point values, which allocates space if
1537  // it doesn't already exist.
1538  auto & array = bf_map[elem_side_pair];
1539  array[var].assign(cursor, cursor + n_qp_per_elem_side[elem_side_idx]);
1540  std::advance(cursor, n_qp_per_elem_side[elem_side_idx]);
1541  }
1542  } // end for (var)
1543  } // end for (i)
1544  } // end if processor 0
1545 
1546  // Distribute the basis function information to the processors that require it
1547  this->side_distribute_bfs(sys);
1548 }
std::vector< SideQpDataMap > _local_side_eim_basis_functions
The EIM basis functions on element sides.
void side_distribute_bfs(const System &sys)
Same as distribute_bfs() except for side data.
unsigned int n_vars
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:111

◆ 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 274 of file rb_parametrized.C.

References libMesh::RBParametrized::initialize_parameters(), libMesh::RBParametrized::read_discrete_parameter_values_from_file(), and libMesh::RBParametrized::read_parameter_ranges_from_file().

Referenced by libMesh::RBSCMEvaluation::legacy_read_offline_data_from_files(), and libMesh::RBEvaluation::legacy_read_offline_data_from_files().

277 {
278  RBParameters param_min;
279  RBParameters param_max;
280  read_parameter_ranges_from_file(continuous_param_file_name,
281  read_binary_data,
282  param_min,
283  param_max);
284 
285  std::map<std::string, std::vector<Real>> discrete_parameter_values_in;
286  read_discrete_parameter_values_from_file(discrete_param_file_name,
287  read_binary_data,
288  discrete_parameter_values_in);
289 
290  initialize_parameters(param_min, param_max, discrete_parameter_values_in);
291 }
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.
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.

◆ resize_data_structures()

void RBEIMEvaluation::resize_data_structures ( const unsigned int  Nmax)

Resize the data structures for storing data associated with this object.

Definition at line 72 of file rb_eim_evaluation.C.

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

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

73 {
74  // Resize the data structures relevant to the EIM system
76  _vec_eval_input.all_xyz.clear();
77 
80 
81  _interpolation_matrix.resize(Nmax,Nmax);
82 }
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
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::vector< Point > all_xyz
The members that define the inputs to the vectorized evaluate functions.
void clear()
Clear all the members.
std::vector< unsigned int > _interpolation_points_comp
In the case of a "vector-valued" EIM, this vector determines which component of the parameterized fun...
void resize(const unsigned int new_m, const unsigned int new_n)
Resizes the matrix to the specified size and calls zero().
Definition: dense_matrix.h:895
DenseMatrix< Number > _interpolation_matrix
Dense matrix that stores the lower triangular interpolation matrix that can be used.

◆ scale_components_in_enrichment()

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

Get _scale_components_in_enrichment.

Definition at line 2954 of file rb_eim_evaluation.C.

References _scale_components_in_enrichment.

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

2955 {
2957 }
std::set< unsigned int > _scale_components_in_enrichment
This set that specifies which EIM variables will be scaled during EIM enrichment so that their maximu...

◆ 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 2966 of file rb_eim_evaluation.C.

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

2967 {
2968  // We skip setting _is_eim_error_indicator_active in the case that
2969  // we have no parameters, since we do not use the EIM error indicator
2970  // in that case. We also check if the number of interpolation points
2971  // is larger than the number of EIM basis functions, since that is
2972  // also always the case when the error indicator is active.
2975 }
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.
bool _is_eim_error_indicator_active
Indicate if the EIM error indicator is active in RB EIM solves.
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_params() const
Get the number of parameters.

◆ set_error_indicator_interpolation_row()

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

Definition at line 3023 of file rb_eim_evaluation.C.

References _error_indicator_interpolation_row.

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

3024 {
3025  _error_indicator_interpolation_row = extra_point_row;
3026 }
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...

◆ 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 868 of file rb_eim_evaluation.C.

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

869 {
870  libmesh_error_msg_if((i >= _interpolation_matrix.m()) || (j >= _interpolation_matrix.n()),
871  "Error: Invalid matrix indices");
872 
874 }
unsigned int m() const
static const bool value
Definition: xdr_io.C:54
unsigned int n() const
DenseMatrix< Number > _interpolation_matrix
Dense matrix that stores the lower triangular interpolation matrix that can be used.

◆ 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 317 of file rb_eim_evaluation.C.

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

318 {
319  if (get_parametrized_function().on_mesh_sides())
320  _local_side_eim_basis_functions.resize(n_bfs);
321  else if (get_parametrized_function().on_mesh_nodes())
322  _local_node_eim_basis_functions.resize(n_bfs);
323  else
324  _local_eim_basis_functions.resize(n_bfs);
325 }
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.
std::vector< QpDataMap > _local_eim_basis_functions
The EIM basis functions.
RBParametrizedFunction & get_parametrized_function()
Get a reference to the parametrized function.

◆ 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 141 of file rb_parametrized.C.

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(), libMesh::RBSCMEvaluation::reload_current_parameters(), libMesh::RBSCMEvaluation::set_current_parameters_from_C_J(), and RBParametersTest::testRBParametrized().

142 {
143  libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::set_parameters");
144 
145  // Terminate if params has the wrong number of parameters or samples.
146  // If the parameters are outside the min/max range, return false.
147  const bool valid_params = check_if_valid_params(params);
148 
149  // Make a copy of params (default assignment operator just does memberwise copy, which is sufficient here)
150  this->parameters = params;
151 
152  return valid_params;
153 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
bool check_if_valid_params(const RBParameters &params) const
Helper function to check that params is valid:
RBParameters parameters
Vector storing the current parameters.

◆ 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 84 of file rb_eim_evaluation.C.

References _parametrized_function.

85 {
86  _parametrized_function = std::move(pf);
87 }
std::unique_ptr< RBParametrizedFunction > _parametrized_function
Store the parametrized function that will be approximated by this EIM system.

◆ 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 881 of file rb_eim_evaluation.C.

References _preserve_rb_eim_solutions.

882 {
883  _preserve_rb_eim_solutions = preserve_rb_eim_solutions;
884 }
bool _preserve_rb_eim_solutions
Boolean to indicate if we skip updating _rb_eim_solutions in rb_eim_solves().

◆ 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 654 of file rb_eim_evaluation.C.

References _rb_eim_solutions.

655 {
656  _rb_eim_solutions = rb_eim_solutions;
657 }
std::vector< DenseVector< Number > > _rb_eim_solutions
The EIM solution coefficients from the most recent call to rb_eim_solves().

◆ 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 353 of file rb_eim_evaluation.C.

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

355 {
356  LOG_SCOPE("side_decrement_vector()", "RBEIMEvaluation");
357 
358  libmesh_error_msg_if(get_n_basis_functions() != coeffs.size(),
359  "Error: Number of coefficients should match number of basis functions");
360 
361  for (auto & [elem_and_side, v_comp_and_qp] : v)
362  {
363  for (const auto & comp : index_range(v_comp_and_qp))
364  for (unsigned int qp : index_range(v_comp_and_qp[comp]))
365  for (unsigned int i : index_range(_local_side_eim_basis_functions))
366  {
367  // Check that entry (elem_and_side,comp,qp) exists in _local_side_eim_basis_functions so that
368  // we get a clear error message if there is any missing data
369  const auto & basis_comp_and_qp = libmesh_map_find(_local_side_eim_basis_functions[i], elem_and_side);
370 
371  libmesh_error_msg_if(comp >= basis_comp_and_qp.size(), "Error: Invalid comp");
372  libmesh_error_msg_if(qp >= basis_comp_and_qp[comp].size(), "Error: Invalid qp");
373 
374  v_comp_and_qp[comp][qp] -= coeffs(i) * basis_comp_and_qp[comp][qp];
375  }
376  }
377 }
unsigned int get_n_basis_functions() const
Return the current number of EIM basis functions.
std::vector< SideQpDataMap > _local_side_eim_basis_functions
The EIM basis functions on element sides.
virtual unsigned int size() const override final
Definition: dense_vector.h:104
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:111

◆ side_distribute_bfs()

void RBEIMEvaluation::side_distribute_bfs ( const System sys)
private

Same as distribute_bfs() except for side data.

Definition at line 2324 of file rb_eim_evaluation.C.

References _local_side_eim_basis_functions, TIMPI::Communicator::broadcast(), clear(), libMesh::ParallelObject::comm(), TIMPI::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, TIMPI::Communicator::rank(), TIMPI::Communicator::scatter(), and TIMPI::Communicator::size().

Referenced by read_in_side_basis_functions().

2325 {
2326  // So we can avoid calling these many times below
2327  auto n_procs = sys.comm().size();
2328  auto rank = sys.comm().rank();
2329 
2330  // In serial there's nothing to distribute
2331  if (n_procs == 1)
2332  return;
2333 
2334  // Broadcast the number of basis functions from proc 0. After
2335  // distributing, all procs should have the same number of basis
2336  // functions.
2337  auto n_bf = _local_side_eim_basis_functions.size();
2338  sys.comm().broadcast(n_bf);
2339 
2340  // Allocate enough space to store n_bf basis functions on non-zero ranks
2341  if (rank != 0)
2342  _local_side_eim_basis_functions.resize(n_bf);
2343 
2344  // Broadcast the number of variables from proc 0. After
2345  // distributing, all procs should have the same number of variables.
2346  auto n_vars = _local_side_eim_basis_functions[0].begin()->second.size();
2347  sys.comm().broadcast(n_vars);
2348 
2349  const std::set<boundary_id_type> & parametrized_function_boundary_ids =
2351 
2352  // Construct lists of elem ids owned by different processors
2353  const MeshBase & mesh = sys.get_mesh();
2354 
2355  // BoundaryInfo and related data structures
2356  const auto & binfo = mesh.get_boundary_info();
2357  std::vector<boundary_id_type> side_boundary_ids;
2358 
2359  std::vector<dof_id_type> gathered_local_elem_ids;
2360  std::vector<dof_id_type> gathered_local_side_indices;
2361  for (const auto & elem : mesh.active_local_element_ptr_range())
2362  {
2363  for (unsigned int side = 0; side != elem->n_sides(); ++side)
2364  {
2365  // skip non-boundary elements
2366  if (!elem->neighbor_ptr(side))
2367  {
2368  binfo.boundary_ids(elem, side, side_boundary_ids);
2369 
2370  bool has_side_boundary_id = false;
2371  for (boundary_id_type side_boundary_id : side_boundary_ids)
2372  if (parametrized_function_boundary_ids.count(side_boundary_id))
2373  {
2374  has_side_boundary_id = true;
2375  break;
2376  }
2377 
2378  if (has_side_boundary_id)
2379  {
2380  gathered_local_elem_ids.push_back(elem->id());
2381  gathered_local_side_indices.push_back(side);
2382  }
2383  }
2384  }
2385 
2386  // In the case of 2D elements, we also check the shellfaces
2387  if (elem->dim() == 2)
2388  for (unsigned int shellface_index=0; shellface_index<2; shellface_index++)
2389  {
2390  binfo.shellface_boundary_ids(elem, shellface_index, side_boundary_ids);
2391 
2392  bool has_side_boundary_id = false;
2393  for (boundary_id_type side_boundary_id : side_boundary_ids)
2394  if (parametrized_function_boundary_ids.count(side_boundary_id))
2395  {
2396  has_side_boundary_id = true;
2397  break;
2398  }
2399 
2400  if (has_side_boundary_id)
2401  {
2402  // We use shellface_index as the side_index since shellface boundary conditions
2403  // are stored separately from side boundary conditions in BoundaryInfo.
2404  gathered_local_elem_ids.push_back(elem->id());
2405  gathered_local_side_indices.push_back(shellface_index);
2406  }
2407  }
2408  }
2409 
2410  // Gather the number of local elems from all procs to proc 0
2411  auto n_local_elems = gathered_local_elem_ids.size();
2412  std::vector<std::size_t> gathered_n_local_elems = {n_local_elems};
2413  sys.comm().gather(/*root_id=*/0, gathered_n_local_elems);
2414 
2415  // Gather the (elem,side) owned by each processor onto processor 0.
2416  sys.comm().gather(/*root_id=*/0, gathered_local_elem_ids);
2417  sys.comm().gather(/*root_id=*/0, gathered_local_side_indices);
2418 
2419  // Construct vectors of "start" and "one-past-the-end" indices into
2420  // the gathered_local_elem_ids vector for each proc. Only valid on
2421  // processor 0.
2422  std::vector<std::size_t> start_elem_ids_index, end_elem_ids_index;
2423 
2424  if (rank == 0)
2425  {
2426  start_elem_ids_index.resize(n_procs);
2427  start_elem_ids_index[0] = 0;
2428  for (processor_id_type p=1; p<n_procs; ++p)
2429  start_elem_ids_index[p] = start_elem_ids_index[p-1] + gathered_n_local_elems[p-1];
2430 
2431  end_elem_ids_index.resize(n_procs);
2432  end_elem_ids_index[n_procs - 1] = gathered_local_elem_ids.size();
2433  for (processor_id_type p=0; p<n_procs - 1; ++p)
2434  end_elem_ids_index[p] = start_elem_ids_index[p+1];
2435  }
2436 
2437  // On processor 0, using basis function 0 and variable 0, prepare a
2438  // vector with the number of qps per Elem. Then scatter this vector
2439  // out to the processors that require it. The order of this vector
2440  // matches the gathered_local_elem_ids ordering. The counts will be
2441  // gathered_n_local_elems, since there will be one qp count per Elem.
2442  std::vector<unsigned int> n_qp_per_elem_data;
2443 
2444  // On rank 0, the "counts" vector holds the number of floating point values that
2445  // are to be scattered to each proc. It is only required on proc 0.
2446  std::vector<int> counts;
2447 
2448  if (rank == 0)
2449  {
2450  n_qp_per_elem_data.reserve(gathered_local_elem_ids.size());
2451  counts.resize(n_procs);
2452 
2453  auto & bf_map = _local_side_eim_basis_functions[0];
2454 
2455  for (processor_id_type p=0; p<n_procs; ++p)
2456  {
2457  for (auto e : make_range(start_elem_ids_index[p], end_elem_ids_index[p]))
2458  {
2459  auto elem_id = gathered_local_elem_ids[e];
2460  auto side_index = gathered_local_side_indices[e];
2461 
2462  // Get reference to array[n_vars][n_qp] for current Elem.
2463  // Throws an error if the required elem_id is not found.
2464  const auto & array = libmesh_map_find(bf_map, std::make_pair(elem_id, side_index));
2465 
2466  auto n_qps = array[0].size();
2467 
2468  // We use var==0 to set the number of qps for all vars
2469  n_qp_per_elem_data.push_back(n_qps);
2470 
2471  // Accumulate the count for this proc
2472  counts[p] += n_qps;
2473  } // end for (e)
2474  } // end for proc_id
2475  } // if (rank == 0)
2476 
2477  // Now scatter the n_qp_per_elem_data to all procs (must call the
2478  // scatter on all procs, it is a collective).
2479  {
2480  std::vector<unsigned int> recv;
2481  std::vector<int> tmp(gathered_n_local_elems.begin(), gathered_n_local_elems.end());
2482  sys.comm().scatter(n_qp_per_elem_data, tmp, recv, /*root_id=*/0);
2483 
2484  // Now swap n_qp_per_elem_data and recv. All processors now have a
2485  // vector of length n_local_elems containing the number of
2486  // quadarature points per Elem.
2487  n_qp_per_elem_data.swap(recv);
2488  }
2489 
2490  // For each basis function and each variable, build a vector
2491  // of qp data in the Elem ordering given by the
2492  // gathered_local_elem_ids, then call
2493  //
2494  // sys.comm().scatter(data, counts, recv, /*root_id=*/0);
2495  std::vector<std::vector<Number>> qp_data(n_vars);
2496  if (rank == 0)
2497  {
2498  // The total amount of qp data is given by summing the entries
2499  // of the "counts" vector.
2500  auto n_qp_data =
2501  std::accumulate(counts.begin(), counts.end(), 0u);
2502 
2503  // On processor 0, reserve enough space to hold all the qp
2504  // data for a single basis function for each var.
2505  for (auto var : index_range(qp_data))
2506  qp_data[var].reserve(n_qp_data);
2507  }
2508 
2509  // The recv_qp_data vector will be used on the receiving end of all
2510  // the scatters below.
2511  std::vector<Number> recv_qp_data;
2512 
2513  // Loop from 0..n_bf on _all_ procs, since the scatters inside this
2514  // loop are collective.
2515  for (auto bf : make_range(n_bf))
2516  {
2517  // Prepare data for scattering (only on proc 0)
2518  if (rank == 0)
2519  {
2520  // Reference to the data map for the current basis function.
2521  auto & bf_map = _local_side_eim_basis_functions[bf];
2522 
2523  // Clear any data from previous bf
2524  for (auto var : index_range(qp_data))
2525  qp_data[var].clear();
2526 
2527  for (processor_id_type p=0; p<n_procs; ++p)
2528  {
2529  for (auto e : make_range(start_elem_ids_index[p], end_elem_ids_index[p]))
2530  {
2531  auto elem_id = gathered_local_elem_ids[e];
2532  auto side_index = gathered_local_side_indices[e];
2533 
2534  // Get reference to array[n_vars][n_qp] for current Elem.
2535  // Throws an error if the required (elem,side) is not found.
2536  const auto & array = libmesh_map_find(bf_map, std::make_pair(elem_id, side_index));
2537 
2538  for (auto var : index_range(array))
2539  {
2540  // Insert all qp values for this var
2541  qp_data[var].insert(/*insert at*/qp_data[var].end(),
2542  /*data start*/array[var].begin(),
2543  /*data end*/array[var].end());
2544  } // end for (var)
2545  } // end for (e)
2546  } // end for proc_id
2547  } // end if rank==0
2548 
2549  // Perform the scatters (all procs)
2550  for (auto var : make_range(n_vars))
2551  {
2552  // Do the scatter for the current var
2553  sys.comm().scatter(qp_data[var], counts, recv_qp_data, /*root_id=*/0);
2554 
2555  if (rank != 0)
2556  {
2557  // Store the scattered data we received in _local_side_eim_basis_functions[bf]
2558  auto & bf_map = _local_side_eim_basis_functions[bf];
2559  auto cursor = recv_qp_data.begin();
2560 
2561  for (auto i : index_range(gathered_local_elem_ids))
2562  {
2563  auto elem_id = gathered_local_elem_ids[i];
2564  auto side_index = gathered_local_side_indices[i];
2565  auto n_qp_this_elem = n_qp_per_elem_data[i];
2566  auto & array = bf_map[std::make_pair(elem_id, side_index)];
2567 
2568  // Create space to store the data if it doesn't already exist.
2569  if (array.empty())
2570  array.resize(n_vars);
2571 
2572  array[var].assign(cursor, cursor + n_qp_this_elem);
2573  std::advance(cursor, n_qp_this_elem);
2574  }
2575  } // if (rank != 0)
2576  } // end for (var)
2577  } // end for (bf)
2578 
2579  // Now that the scattering is done, delete non-local Elem
2580  // information from processor 0's _local_side_eim_basis_functions data
2581  // structure.
2582  if (rank == 0)
2583  {
2584  for (processor_id_type p=1; p<n_procs; ++p)
2585  {
2586  for (auto e : make_range(start_elem_ids_index[p], end_elem_ids_index[p]))
2587  {
2588  auto elem_id = gathered_local_elem_ids[e];
2589  auto side_index = gathered_local_side_indices[e];
2590 
2591  // Delete this Elem's information from every basis function.
2592  for (auto & bf_map : _local_side_eim_basis_functions)
2593  bf_map.erase(std::make_pair(elem_id, side_index));
2594  } // end for (e)
2595  } // end for proc_id
2596  } // if (rank == 0)
2597 }
virtual void clear() override
Clear this object.
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 ...
MeshBase & mesh
std::vector< SideQpDataMap > _local_side_eim_basis_functions
The EIM basis functions on element sides.
uint8_t processor_id_type
int8_t boundary_id_type
Definition: id_types.h:51
unsigned int n_vars
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:134
RBParametrizedFunction & get_parametrized_function()
Get a reference to the parametrized function.
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:111

◆ side_gather_bfs()

void RBEIMEvaluation::side_gather_bfs ( )
private

Same as gather_bfs() except for side data.

Definition at line 1830 of file rb_eim_evaluation.C.

References _local_side_eim_basis_functions, libMesh::ParallelObject::comm(), TIMPI::Communicator::gather(), libMesh::index_range(), TIMPI::Communicator::max(), libMesh::ParallelObject::n_processors(), n_vars, libMesh::ParallelObject::processor_id(), and TIMPI::Communicator::verify().

Referenced by write_out_side_basis_functions().

1831 {
1832  // We need to gather _local_side_eim_basis_functions data from other
1833  // procs for printing.
1834  //
1835  // Ideally, this could be accomplished by simply calling:
1836  // this->comm().gather(/*root_id=*/0, _local_side_eim_basis_functions);
1837  //
1838  // but the data structure seems to be too complicated for this to
1839  // work automatically. (I get some error about the function called
1840  // being "private within this context".) Therefore, we have to
1841  // gather the information manually.
1842 
1843  // So we can avoid calling this many times below
1844  auto n_procs = this->n_processors();
1845 
1846  // In serial there's nothing to gather
1847  if (n_procs == 1)
1848  return;
1849 
1850  // Current assumption is that the number of basis functions stored on
1851  // each processor is the same, the only thing that differs is the number
1852  // of elements, so make sure that is the case now.
1853  auto n_bf = _local_side_eim_basis_functions.size();
1854  this->comm().verify(n_bf);
1855 
1856  // This function should never be called if there are no basis
1857  // functions, so if it was, something went wrong.
1858  libmesh_error_msg_if(!n_bf, "SideRBEIMEvaluation::gather_bfs() should not be called with 0 basis functions.");
1859 
1860  // The number of variables should be the same on all processors
1861  // and we can get this from _local_side_eim_basis_functions. However,
1862  // it may be that some processors have no local elements, so on
1863  // those processors we cannot look up the size from
1864  // _local_side_eim_basis_functions. As a result we use comm().max(n_vars)
1865  // to make sure all processors agree on the final value.
1866  std::size_t n_vars =
1867  _local_side_eim_basis_functions[0].empty() ? 0 : _local_side_eim_basis_functions[0].begin()->second.size();
1868  this->comm().max(n_vars);
1869 
1870  // Gather list of (elem,side) pairs stored on each processor to proc 0. We
1871  // use basis function 0 as an example and assume all the basis
1872  // functions are distributed similarly.
1873  std::vector<std::pair<dof_id_type,unsigned int>> elem_side_pairs;
1874  elem_side_pairs.reserve(_local_side_eim_basis_functions[0].size());
1875  for (const auto & pr : _local_side_eim_basis_functions[0])
1876  elem_side_pairs.push_back(pr.first);
1877  this->comm().gather(/*root_id=*/0, elem_side_pairs);
1878 
1879  // Store the number of qps per Elem on this processor. Again, use
1880  // basis function 0 (and variable 0) to get this information, then
1881  // apply it to all basis functions.
1882  std::vector<unsigned int> n_qp_per_elem_side;
1883  n_qp_per_elem_side.reserve(_local_side_eim_basis_functions[0].size());
1884  for (const auto & pr : _local_side_eim_basis_functions[0])
1885  {
1886  // array[n_vars][n_qp] per (elem,side). We get the number of QPs
1887  // for variable 0, assuming they are all the same.
1888  const auto & array = pr.second;
1889  n_qp_per_elem_side.push_back(array[0].size());
1890  }
1891 
1892  // Before gathering, compute the total amount of local qp data for
1893  // each var, which is the sum of the entries in the "n_qp_per_elem_side" array.
1894  // This will be used to reserve space in a vector below.
1895  auto n_local_qp_data =
1896  std::accumulate(n_qp_per_elem_side.begin(),
1897  n_qp_per_elem_side.end(),
1898  0u);
1899 
1900  // Gather the number of qps per Elem for each processor onto processor 0.
1901  this->comm().gather(/*root_id=*/0, n_qp_per_elem_side);
1902 
1903  // Sanity check: On processor 0, this checks that we have gathered the same number
1904  // of (elem,side) pairs and qp counts.
1905  libmesh_error_msg_if(elem_side_pairs.size() != n_qp_per_elem_side.size(),
1906  "Must gather same number of Elem ids as qps per Elem.");
1907 
1908  // Reserve space to store contiguous vectors of qp data for each var
1909  std::vector<std::vector<Number>> gathered_qp_data(n_vars);
1910  for (auto var : index_range(gathered_qp_data))
1911  gathered_qp_data[var].reserve(n_local_qp_data);
1912 
1913  // Now we construct a vector for each basis function, for each
1914  // variable, which is ordered according to:
1915  // [ [qp vals for Elem 0], [qp vals for Elem 1], ... [qp vals for Elem N] ]
1916  // and gather it to processor 0.
1918  {
1919  // Clear any data from previous bf
1920  for (auto var : index_range(gathered_qp_data))
1921  gathered_qp_data[var].clear();
1922 
1923  for (const auto & pr : _local_side_eim_basis_functions[bf])
1924  {
1925  // array[n_vars][n_qp] per (elem,side) pair
1926  const auto & array = pr.second;
1927  for (auto var : index_range(array))
1928  {
1929  // Insert all qp values for this var
1930  gathered_qp_data[var].insert(/*insert at*/gathered_qp_data[var].end(),
1931  /*data start*/array[var].begin(),
1932  /*data end*/array[var].end());
1933  }
1934  }
1935 
1936  // Reference to the data map for the current basis function.
1937  auto & bf_map = _local_side_eim_basis_functions[bf];
1938 
1939  for (auto var : index_range(gathered_qp_data))
1940  {
1941  // For each var, gather gathered_qp_data[var] onto processor
1942  // 0. There apparently is not a gather overload for
1943  // vector-of-vectors...
1944  this->comm().gather(/*root_id=*/0, gathered_qp_data[var]);
1945 
1946  // On processor 0, iterate over the gathered_qp_data[var]
1947  // vector we just gathered, filling in the "small" vectors
1948  // for each Elem. Note: here we ignore the fact that we
1949  // already have the data on processor 0 and just overwrite
1950  // it, this makes the indexing logic a bit simpler.
1951  if (this->processor_id() == 0)
1952  {
1953  auto cursor = gathered_qp_data[var].begin();
1954  for (auto i : index_range(elem_side_pairs))
1955  {
1956  auto elem_side_pair = elem_side_pairs[i];
1957  auto n_qp_this_elem_side = n_qp_per_elem_side[i];
1958 
1959  // Get reference to the [n_vars][n_qp] array for
1960  // this Elem. We assign() into the vector of
1961  // quadrature point values, which allocates space if
1962  // it doesn't already exist.
1963  auto & array = bf_map[elem_side_pair];
1964 
1965  // Possibly allocate space if this is data for a new
1966  // element we haven't seen before.
1967  if (array.empty())
1968  array.resize(n_vars);
1969 
1970  array[var].assign(cursor, cursor + n_qp_this_elem_side);
1971  std::advance(cursor, n_qp_this_elem_side);
1972  }
1973  }
1974  }
1975  } // end loop over basis functions
1976 }
bool verify(const T &r) const
void gather(const unsigned int root_id, const T &send_data, std::vector< T, A > &recv) const
const Parallel::Communicator & comm() const
std::vector< SideQpDataMap > _local_side_eim_basis_functions
The EIM basis functions on element sides.
processor_id_type n_processors() const
unsigned int n_vars
void max(const T &r, T &o, Request &req) const
processor_id_type processor_id() const
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:111

◆ 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 2959 of file rb_eim_evaluation.C.

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

2960 {
2961  // Return false by default, but we override this in subclasses
2962  // for cases where we want to use the error indicator.
2963  return false;
2964 }

◆ 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 986 of file rb_eim_evaluation.C.

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

988 {
989  LOG_SCOPE("write_out_basis_functions()", "RBEIMEvaluation");
990 
991  if (get_parametrized_function().on_mesh_sides())
992  write_out_side_basis_functions(directory_name, write_binary_basis_functions);
993  else if (get_parametrized_function().on_mesh_nodes())
994  write_out_node_basis_functions(directory_name, write_binary_basis_functions);
995  else
996  write_out_interior_basis_functions(directory_name, write_binary_basis_functions);
997 }
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_interior_basis_functions(const std::string &directory_name, bool write_binary_basis_functions)
Method that writes out element interior EIM basis functions.
RBParametrizedFunction & get_parametrized_function()
Get a reference to the parametrized function.
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.

◆ 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 1000 of file rb_eim_evaluation.C.

References _local_eim_basis_functions, libMesh::ParallelObject::comm(), libMesh::ENCODE, gather_bfs(), libMesh::index_range(), libMesh::Utility::mkdir(), libMesh::MeshTools::n_elem(), n_vars, libMesh::ParallelObject::processor_id(), TIMPI::Communicator::verify(), and libMesh::WRITE.

Referenced by write_out_basis_functions().

1002 {
1003  LOG_SCOPE("write_out_interior_basis_functions()", "RBEIMEvaluation");
1004 
1005  // Quick return if there is no work to do. Note: make sure all procs
1006  // agree there is no work to do.
1007  bool is_empty = _local_eim_basis_functions.empty();
1008  this->comm().verify(is_empty);
1009 
1010  if (is_empty)
1011  return;
1012 
1013  // Gather basis function data from other procs, storing it in
1014  // _local_eim_basis_functions, so that we can then print everything
1015  // from processor 0.
1016  this->gather_bfs();
1017 
1018  // Write values from processor 0 only.
1019  if (this->processor_id() == 0)
1020  {
1021  // Make a directory to store all the data files
1022  Utility::mkdir(directory_name.c_str());
1023 
1024  // Create filename
1025  std::ostringstream file_name;
1026  const std::string basis_function_suffix = (write_binary_basis_functions ? ".xdr" : ".dat");
1027  file_name << directory_name << "/" << "bf_data" << basis_function_suffix;
1028 
1029  // Create XDR writer object
1030  Xdr xdr(file_name.str(), write_binary_basis_functions ? ENCODE : WRITE);
1031 
1032  // Write number of basis functions to file. Note: the
1033  // Xdr::data() function takes non-const references, so you can't
1034  // pass e.g. vec.size() to that interface.
1035  auto n_bf = _local_eim_basis_functions.size();
1036  xdr.data(n_bf, "# Number of basis functions");
1037 
1038  // We assume that each basis function has data for the same
1039  // number of elements as basis function 0, which is equal to the
1040  // size of the map.
1041  auto n_elem = _local_eim_basis_functions[0].size();
1042  xdr.data(n_elem, "# Number of elements");
1043 
1044  // We assume that each element has the same number of variables,
1045  // and we get the number of vars from the first element of the
1046  // first basis function.
1047  auto n_vars = _local_eim_basis_functions[0].begin()->second.size();
1048  xdr.data(n_vars, "# Number of variables");
1049 
1050  // We assume that the list of elements for each basis function
1051  // is the same as basis function 0. We also assume that all vars
1052  // have the same number of qps.
1053  std::vector<unsigned int> n_qp_per_elem;
1054  n_qp_per_elem.reserve(n_elem);
1055  dof_id_type expected_elem_id = 0;
1056  for (const auto & [actual_elem_id, array] : _local_eim_basis_functions[0])
1057  {
1058  // Note: Currently we require that the Elems are numbered
1059  // contiguously from [0..n_elem). This allows us to avoid
1060  // writing the Elem ids to the Xdr file, but if we need to
1061  // generalize this assumption later, we can.
1062  libmesh_error_msg_if(actual_elem_id != expected_elem_id++,
1063  "RBEIMEvaluation currently assumes a contiguous Elem numbering starting from 0.");
1064 
1065  // array[n_vars][n_qp] per Elem. We get the number of QPs
1066  // for variable 0, assuming they are all the same.
1067  n_qp_per_elem.push_back(array[0].size());
1068  }
1069  xdr.data(n_qp_per_elem, "# Number of QPs per Elem");
1070 
1071  // The total amount of qp data for each var is the sum of the
1072  // entries in the "n_qp_per_elem" array.
1073  auto n_qp_data =
1074  std::accumulate(n_qp_per_elem.begin(),
1075  n_qp_per_elem.end(),
1076  0u);
1077 
1078  // Reserve space to store contiguous vectors of qp data for each var
1079  std::vector<std::vector<Number>> qp_data(n_vars);
1080  for (auto var : index_range(qp_data))
1081  qp_data[var].reserve(n_qp_data);
1082 
1083  // Now we construct a vector for each basis function, for each
1084  // variable which is ordered according to:
1085  // [ [qp vals for Elem 0], [qp vals for Elem 1], ... [qp vals for Elem N] ]
1086  // and write it to file.
1087  for (auto bf : index_range(_local_eim_basis_functions))
1088  {
1089  // Clear any data from previous bf
1090  for (auto var : index_range(qp_data))
1091  qp_data[var].clear();
1092 
1093  for (const auto & pr : _local_eim_basis_functions[bf])
1094  {
1095  // array[n_vars][n_qp] per Elem
1096  const auto & array = pr.second;
1097  for (auto var : index_range(array))
1098  {
1099  // Insert all qp values for this var
1100  qp_data[var].insert(/*insert at*/qp_data[var].end(),
1101  /*data start*/array[var].begin(),
1102  /*data end*/array[var].end());
1103  }
1104  }
1105 
1106  // Write all the var values for this bf
1107  for (auto var : index_range(qp_data))
1108  xdr.data_stream(qp_data[var].data(), qp_data[var].size(), /*line_break=*/qp_data[var].size());
1109  }
1110  }
1111 }
bool verify(const T &r) const
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Count up the number of elements of a specific type (as defined by an iterator range).
Definition: mesh_tools.C:850
const Parallel::Communicator & comm() const
int mkdir(const char *pathname)
Create a directory.
Definition: utility.C:144
unsigned int n_vars
std::vector< QpDataMap > _local_eim_basis_functions
The EIM basis functions.
processor_id_type processor_id() const
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:111
uint8_t dof_id_type
Definition: id_types.h:67
void gather_bfs()
Helper function that gathers the contents of _local_eim_basis_functions to processor 0 in preparation...

◆ 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 1230 of file rb_eim_evaluation.C.

References _local_node_eim_basis_functions, libMesh::ParallelObject::comm(), libMesh::ENCODE, libMesh::index_range(), libMesh::Utility::mkdir(), n_vars, node_gather_bfs(), libMesh::ParallelObject::processor_id(), TIMPI::Communicator::verify(), and libMesh::WRITE.

Referenced by write_out_basis_functions().

1232 {
1233  LOG_SCOPE("write_out_node_basis_functions()", "RBEIMEvaluation");
1234 
1235  // Quick return if there is no work to do. Note: make sure all procs
1236  // agree there is no work to do.
1237  bool is_empty = _local_node_eim_basis_functions.empty();
1238  this->comm().verify(is_empty);
1239 
1240  if (is_empty)
1241  return;
1242 
1243  // Gather basis function data from other procs, storing it in
1244  // _local_node_eim_basis_functions, so that we can then print everything
1245  // from processor 0.
1246  this->node_gather_bfs();
1247 
1248  // Write values from processor 0 only.
1249  if (this->processor_id() == 0)
1250  {
1251  // Make a directory to store all the data files
1252  Utility::mkdir(directory_name.c_str());
1253 
1254  // Create filename
1255  std::ostringstream file_name;
1256  const std::string basis_function_suffix = (write_binary_basis_functions ? ".xdr" : ".dat");
1257  file_name << directory_name << "/" << "bf_data" << basis_function_suffix;
1258 
1259  // Create XDR writer object
1260  Xdr xdr(file_name.str(), write_binary_basis_functions ? ENCODE : WRITE);
1261 
1262  // Write number of basis functions to file. Note: the
1263  // Xdr::data() function takes non-const references, so you can't
1264  // pass e.g. vec.size() to that interface.
1265  auto n_bf = _local_node_eim_basis_functions.size();
1266  xdr.data(n_bf, "# Number of basis functions");
1267 
1268  // We assume that each basis function has data for the same
1269  // number of elements as basis function 0, which is equal to the
1270  // size of the map.
1271  auto n_node = _local_node_eim_basis_functions[0].size();
1272  xdr.data(n_node, "# Number of nodes");
1273 
1274  // We assume that each element has the same number of variables,
1275  // and we get the number of vars from the first element of the
1276  // first basis function.
1277  auto n_vars = _local_node_eim_basis_functions[0].begin()->second.size();
1278  xdr.data(n_vars, "# Number of variables");
1279 
1280  // We write out the following arrays:
1281  // - node IDs
1282  std::vector<unsigned int> node_ids;
1283  node_ids.reserve(n_node);
1284  for (const auto & pr : _local_node_eim_basis_functions[0])
1285  {
1286  node_ids.push_back(pr.first);
1287  }
1288  xdr.data(node_ids, "# Node IDs");
1289 
1290  // Now we construct a vector for each basis function, for each
1291  // variable which is ordered according to:
1292  // [ [val for Node 0], [val for Node 1], ... [val for Node N] ]
1293  // and write it to file.
1294 
1295  std::vector<std::vector<Number>> var_data(n_vars);
1296  for (unsigned int var=0; var<n_vars; var++)
1297  var_data[var].resize(n_node);
1298 
1300  {
1301  unsigned int node_counter = 0;
1302  for (const auto & pr : _local_node_eim_basis_functions[bf])
1303  {
1304  // array[n_vars] per Node
1305  const auto & array = pr.second;
1306  for (auto var : index_range(array))
1307  {
1308  // Based on the error check above, we know that node_id is numbered
1309  // contiguously from [0..nodes], so we can use it as the vector
1310  // index here.
1311  var_data[var][node_counter] = array[var];
1312  }
1313 
1314  node_counter++;
1315  }
1316 
1317  // Write all the var values for this bf
1318  for (auto var : index_range(var_data))
1319  xdr.data_stream(var_data[var].data(), var_data[var].size(), /*line_break=*/var_data[var].size());
1320  }
1321  }
1322 }
bool verify(const T &r) const
const Parallel::Communicator & comm() const
int mkdir(const char *pathname)
Create a directory.
Definition: utility.C:144
std::vector< NodeDataMap > _local_node_eim_basis_functions
The EIM basis functions on element nodes (e.g.
unsigned int n_vars
void node_gather_bfs()
Same as gather_bfs() except for node data.
processor_id_type processor_id() const
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:111

◆ write_out_projected_basis_functions()

void RBEIMEvaluation::write_out_projected_basis_functions ( System sys,
const std::string &  directory_name = "offline_data" 
)

Project all basis functions using project_qp_data_map_onto_system() and then write out the resulting vectors.

Definition at line 2921 of file rb_eim_evaluation.C.

References get_basis_function(), get_eim_vars_to_project_and_write(), get_n_basis_functions(), libMesh::index_range(), libMesh::make_range(), project_qp_data_map_onto_system(), libMesh::System::solution, and libMesh::RBEvaluation::write_out_vectors().

2923 {
2924  if (get_eim_vars_to_project_and_write().empty())
2925  return;
2926 
2927  for (unsigned int eim_var : get_eim_vars_to_project_and_write())
2928  {
2929  std::vector<std::unique_ptr<NumericVector<Number>>> projected_bfs;
2930  for (unsigned int bf_index : make_range(get_n_basis_functions()))
2931  {
2933  sys,
2934  get_basis_function(bf_index),
2935  eim_var);
2936 
2937  projected_bfs.emplace_back(sys.solution->clone());
2938  }
2939 
2940  // Create projected_bfs_ptrs so that we can call RBEvaluation::write_out_vectors()
2941  std::vector<NumericVector<Number>*> projected_bfs_ptrs(projected_bfs.size());
2942  for (unsigned int i : index_range(projected_bfs))
2943  {
2944  projected_bfs_ptrs[i] = projected_bfs[i].get();
2945  }
2946 
2948  projected_bfs_ptrs,
2949  directory_name,
2950  "projected_bf_var_" + std::to_string(eim_var));
2951  }
2952 }
unsigned int get_n_basis_functions() const
Return the current number of EIM basis functions.
static void write_out_vectors(System &sys, std::vector< NumericVector< Number > *> &vectors, const std::string &directory_name="offline_data", const std::string &data_name="bf", const bool write_binary_basis_functions=true)
Same as write_out_basis_functions, except in this case we pass in the vectors to be written...
const QpDataMap & get_basis_function(unsigned int i) const
Get a reference to the i^th basis function.
const std::set< unsigned int > & get_eim_vars_to_project_and_write() const
Get _eim_vars_to_project_and_write.
void project_qp_data_map_onto_system(System &sys, const QpDataMap &bf_data, unsigned int var)
Project variable var of bf_data into the solution vector of System.
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:134
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:111

◆ 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 1114 of file rb_eim_evaluation.C.

References _local_side_eim_basis_functions, libMesh::ParallelObject::comm(), libMesh::ENCODE, libMesh::index_range(), libMesh::Utility::mkdir(), libMesh::MeshTools::n_elem(), n_vars, libMesh::ParallelObject::processor_id(), side_gather_bfs(), TIMPI::Communicator::verify(), and libMesh::WRITE.

Referenced by write_out_basis_functions().

1116 {
1117  LOG_SCOPE("write_out_side_basis_functions()", "RBEIMEvaluation");
1118 
1119  // Quick return if there is no work to do. Note: make sure all procs
1120  // agree there is no work to do.
1121  bool is_empty = _local_side_eim_basis_functions.empty();
1122  this->comm().verify(is_empty);
1123 
1124  if (is_empty)
1125  return;
1126 
1127  // Gather basis function data from other procs, storing it in
1128  // _local_side_eim_basis_functions, so that we can then print everything
1129  // from processor 0.
1130  this->side_gather_bfs();
1131 
1132  // Write values from processor 0 only.
1133  if (this->processor_id() == 0)
1134  {
1135  // Make a directory to store all the data files
1136  Utility::mkdir(directory_name.c_str());
1137 
1138  // Create filename
1139  std::ostringstream file_name;
1140  const std::string basis_function_suffix = (write_binary_basis_functions ? ".xdr" : ".dat");
1141  file_name << directory_name << "/" << "bf_data" << basis_function_suffix;
1142 
1143  // Create XDR writer object
1144  Xdr xdr(file_name.str(), write_binary_basis_functions ? ENCODE : WRITE);
1145 
1146  // Write number of basis functions to file. Note: the
1147  // Xdr::data() function takes non-const references, so you can't
1148  // pass e.g. vec.size() to that interface.
1149  auto n_bf = _local_side_eim_basis_functions.size();
1150  xdr.data(n_bf, "# Number of basis functions");
1151 
1152  // We assume that each basis function has data for the same
1153  // number of (elem,side) pairs as basis function 0, which is equal to the
1154  // size of the map.
1155  auto n_elem = _local_side_eim_basis_functions[0].size();
1156  xdr.data(n_elem, "# Number of (elem,side) pairs");
1157 
1158  // We assume that each element has the same number of variables,
1159  // and we get the number of vars from the first element of the
1160  // first basis function.
1161  auto n_vars = _local_side_eim_basis_functions[0].begin()->second.size();
1162  xdr.data(n_vars, "# Number of variables");
1163 
1164  // We write out the following arrays:
1165  // - element IDs
1166  // - side indices
1167  // - n_qp_per_elem_side
1168  std::vector<unsigned int> n_qp_per_elem_side;
1169  std::vector<unsigned int> elem_ids;
1170  std::vector<unsigned int> side_indices;
1171  elem_ids.reserve(n_elem);
1172  side_indices.reserve(n_elem);
1173  n_qp_per_elem_side.reserve(n_elem);
1174  for (const auto & [elem_side_pair, array] : _local_side_eim_basis_functions[0])
1175  {
1176  elem_ids.push_back(elem_side_pair.first);
1177  side_indices.push_back(elem_side_pair.second);
1178 
1179  // array[n_vars][n_qp] per Elem. We get the number of QPs
1180  // for variable 0, assuming they are all the same.
1181  n_qp_per_elem_side.push_back(array[0].size());
1182  }
1183  xdr.data(elem_ids, "# Elem IDs");
1184  xdr.data(side_indices, "# Side indices");
1185  xdr.data(n_qp_per_elem_side, "# Number of QPs per Elem");
1186 
1187  // The total amount of qp data for each var is the sum of the
1188  // entries in the "n_qp_per_elem" array.
1189  auto n_qp_data =
1190  std::accumulate(n_qp_per_elem_side.begin(),
1191  n_qp_per_elem_side.end(),
1192  0u);
1193 
1194  // Reserve space to store contiguous vectors of qp data for each var
1195  std::vector<std::vector<Number>> qp_data(n_vars);
1196  for (auto var : index_range(qp_data))
1197  qp_data[var].reserve(n_qp_data);
1198 
1199  // Now we construct a vector for each basis function, for each
1200  // variable which is ordered according to:
1201  // [ [qp vals for Elem 0], [qp vals for Elem 1], ... [qp vals for Elem N] ]
1202  // and write it to file.
1204  {
1205  // Clear any data from previous bf
1206  for (auto var : index_range(qp_data))
1207  qp_data[var].clear();
1208 
1209  for (const auto & pr : _local_side_eim_basis_functions[bf])
1210  {
1211  // array[n_vars][n_qp] per Elem
1212  const auto & array = pr.second;
1213  for (auto var : index_range(array))
1214  {
1215  // Insert all qp values for this var
1216  qp_data[var].insert(/*insert at*/qp_data[var].end(),
1217  /*data start*/array[var].begin(),
1218  /*data end*/array[var].end());
1219  }
1220  }
1221 
1222  // Write all the var values for this bf
1223  for (auto var : index_range(qp_data))
1224  xdr.data_stream(qp_data[var].data(), qp_data[var].size(), /*line_break=*/qp_data[var].size());
1225  }
1226  }
1227 }
bool verify(const T &r) const
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Count up the number of elements of a specific type (as defined by an iterator range).
Definition: mesh_tools.C:850
const Parallel::Communicator & comm() const
int mkdir(const char *pathname)
Create a directory.
Definition: utility.C:144
std::vector< SideQpDataMap > _local_side_eim_basis_functions
The EIM basis functions on element sides.
void side_gather_bfs()
Same as gather_bfs() except for side data.
unsigned int n_vars
processor_id_type processor_id() const
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:111

◆ 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 197 of file rb_parametrized.C.

References libMesh::RBParametrized::write_discrete_parameter_values_to_file(), and libMesh::RBParametrized::write_parameter_ranges_to_file().

Referenced by libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), and libMesh::RBEvaluation::legacy_write_offline_data_to_files().

200 {
201  write_parameter_ranges_to_file(continuous_param_file_name, write_binary_data);
202  write_discrete_parameter_values_to_file(discrete_param_file_name, write_binary_data);
203 }
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 write_parameter_ranges_to_file(const std::string &file_name, const bool write_binary)
Write out the parameter ranges to file.

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

◆ _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 670 of file rb_eim_evaluation.h.

Referenced by get_eim_solutions_for_training_set(), and rb_eim_solves().

◆ _eim_vars_to_project_and_write

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

This set specifies which EIM variables will be projected and written out in write_out_projected_basis_functions().

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

Definition at line 591 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 813 of file rb_eim_evaluation.h.

Referenced by get_eim_error_indicator(), get_error_indicator_interpolation_row(), and set_error_indicator_interpolation_row().

◆ _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 685 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 696 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 704 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 806 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 728 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_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 748 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 738 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

The number of objects.

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

Definition at line 132 of file reference_counter.h.

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

◆ _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 712 of file rb_eim_evaluation.h.

Referenced by 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 795 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<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 660 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 654 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 678 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 679 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 718 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 602 of file rb_eim_evaluation.h.

Referenced by scale_components_in_enrichment().

◆ _vec_eval_input

VectorizedEvalInput libMesh::RBEIMEvaluation::_vec_eval_input
private

◆ verbose_mode

bool libMesh::RBParametrized::verbose_mode
inherited

Public boolean to toggle verbose mode.

Definition at line 191 of file rb_parametrized.h.

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


The documentation for this class was generated from the following files: