20#ifndef LIBMESH_RB_EIM_EVALUATION_H
21#define LIBMESH_RB_EIM_EVALUATION_H
24#include "libmesh/point.h"
25#include "libmesh/rb_theta_expansion.h"
26#include "libmesh/rb_parametrized.h"
27#include "libmesh/parallel_object.h"
28#include "libmesh/dense_matrix.h"
29#include "libmesh/dense_vector.h"
30#include "libmesh/rb_parametrized_function.h"
31#include "libmesh/fe_type.h"
43class RBParametrizedFunction;
136 typedef std::map<dof_id_type, std::vector<std::vector<Number>>>
QpDataMap;
141 typedef std::map<std::pair<dof_id_type,unsigned int>, std::vector<std::vector<Number>>>
SideQpDataMap;
151 virtual void clear()
override;
187 void rb_eim_solves(
const std::vector<RBParameters> & mus,
unsigned int N);
277 std::vector<Number> & values);
285 unsigned int side_index,
287 std::vector<Number> & values);
317 unsigned int side_index,
343 std::vector<Number> & values)
const;
350 unsigned int side_index,
352 std::vector<Number> & values)
const;
361 unsigned int var)
const;
370 unsigned int qp)
const;
377 unsigned int side_index,
379 unsigned int qp)
const;
389 unsigned int var)
const;
484 const std::unordered_map<std::string, std::set<dof_id_type>> &
get_rb_property_map()
const;
518 const std::vector<Point> & perturbs,
519 const std::vector<Real> & phi_i_qp,
521 const std::vector<Real> & JxW_all_qp,
522 const std::vector<std::vector<Real>> & phi_i_all_qp,
524 const Point & dxyz_dxi_elem_center,
525 const Point & dxyz_deta_elem_center);
540 unsigned int side_index,
544 const std::vector<Point> & perturbs,
545 const std::vector<Real> & phi_i_qp);
583 bool write_binary_basis_functions =
true);
596 const std::string & directory_name =
"offline_data",
597 bool read_binary_basis_functions =
true);
613 const std::vector<Number> & bf_data,
615 const std::map<std::string,std::string> & extra_options);
661 Number error_indicator_rhs,
692 std::map<std::string,std::size_t>
760 bool write_binary_basis_functions);
767 bool write_binary_basis_functions);
774 bool write_binary_basis_functions);
781 const std::string & directory_name,
782 bool read_binary_basis_functions);
789 const std::string & directory_name,
790 bool read_binary_basis_functions);
797 const std::string & directory_name,
798 bool read_binary_basis_functions);
806 unsigned int n_qp_data,
807 unsigned int bf_index);
Defines a dense matrix for use in Finite Element-type computations.
Defines a dense vector for use in Finite Element-type computations.
An object whose state is distributed along a set of processors.
const Parallel::Communicator & comm() const
A Point defines a location in LIBMESH_DIM dimensional Real space.
This class enables evaluation of an Empirical Interpolation Method (EIM) approximation.
const SideQpDataMap & get_side_basis_function(unsigned int i) const
Get a reference to the i^th side basis function.
void distribute_bfs(const System &sys)
Helper function that distributes the entries of _local_eim_basis_functions to their respective proces...
Point get_interpolation_points_xyz(unsigned int index) const
Get the data associated with EIM interpolation points.
virtual void project_qp_data_vector_onto_system(System &sys, const std::vector< Number > &bf_data, const EIMVarGroupPlottingInfo &eim_vargroup, const std::map< std::string, std::string > &extra_options)
Project the EIM basis function data stored in bf_data onto sys.solution.
void add_interpolation_data(Point p, unsigned int comp, dof_id_type elem_id, subdomain_id_type subdomain_id, unsigned int qp, const std::vector< Point > &perturbs, const std::vector< Real > &phi_i_qp, ElemType elem_type, const std::vector< Real > &JxW_all_qp, const std::vector< std::vector< Real > > &phi_i_all_qp, Order qrule_order, const Point &dxyz_dxi_elem_center, const Point &dxyz_deta_elem_center)
Add interpolation data associated with a new basis function.
void add_interpolation_points_subdomain_id(subdomain_id_type sbd_id)
void add_interpolation_points_comp(unsigned int comp)
void add_basis_function(const QpDataMap &bf)
Add bf to our EIM basis.
virtual bool use_eim_error_indicator() const
Virtual function to indicate if we use the EIM error indicator in this case.
bool _preserve_rb_eim_solutions
Boolean to indicate if we skip updating _rb_eim_solutions in rb_eim_solves().
void add_interpolation_points_phi_i_all_qp(const std::vector< std::vector< Real > > &phi_i_all_qp)
void add_node_interpolation_data(Point p, unsigned int comp, dof_id_type node_id, boundary_id_type boundary_id)
Add interpolation data associated with a new basis function.
void read_in_interior_basis_functions(const System &sys, const std::string &directory_name, bool read_binary_basis_functions)
Method that reads in element interior EIM basis functions.
void read_in_node_basis_functions(const System &sys, const std::string &directory_name, bool read_binary_basis_functions)
Method that reads in element node EIM basis functions.
void add_rb_property_map_entry(std::string &property_name, std::set< dof_id_type > &entity_ids)
const DenseVector< Number > & get_error_indicator_interpolation_row() const
Get/set _extra_points_interpolation_matrix.
DenseMatrix< Number > _interpolation_matrix
Dense matrix that stores the lower triangular interpolation matrix that can be used.
std::vector< std::vector< std::vector< Number > > > get_interior_basis_functions_as_vecs()
Get all interior basis functions in the form of std::vectors.
std::vector< DenseVector< Number > > _eim_solutions_for_training_set
Storage for EIM solutions from the training set.
void add_interpolation_points_xyz_perturbations(const std::vector< Point > &perturbs)
const std::unordered_map< std::string, std::set< dof_id_type > > & get_rb_property_map() const
void decrement_vector(QpDataMap &v, const DenseVector< Number > &coeffs)
Subtract coeffs[i]*basis_function[i] from v.
void print_local_eim_basis_functions() const
Print the contents of _local_eim_basis_functions to libMesh::out.
unsigned int get_interpolation_points_side_index(unsigned int index) const
const std::map< dof_id_type, unsigned int > & get_elem_id_to_local_index_map() const
std::vector< QpDataMap > _local_eim_basis_functions
The EIM basis functions.
unsigned int get_n_elems() const
Return the number of unique elements containing interpolation points.
std::vector< unsigned int > _interpolation_points_comp
In the case of a "vector-valued" EIM, this vector determines which component of the parameterized fun...
EimErrorIndicatorNormalization eim_error_indicator_normalization
std::vector< std::pair< Real, Real > > _rb_eim_error_indicators
If we're using the EIM error indicator, then we store the error indicator values corresponding to _rb...
const DenseMatrix< Number > & get_interpolation_matrix() const
Get the EIM interpolation matrix.
void add_interpolation_points_side_index(unsigned int side_index)
void side_gather_bfs()
Same as gather_bfs() except for side data.
const std::set< unsigned int > & scale_components_in_enrichment() const
Get _scale_components_in_enrichment.
Order get_interpolation_points_qrule_order(unsigned int index) const
virtual std::unique_ptr< RBTheta > build_eim_theta(unsigned int index)
Build a theta object corresponding to EIM index index.
virtual ~RBEIMEvaluation()
void add_interpolation_points_elem_type(ElemType elem_type)
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.
void add_interpolation_points_boundary_id(boundary_id_type b_id)
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.
void set_preserve_rb_eim_solutions(bool preserve_rb_eim_solutions)
Set _preserve_rb_eim_solutions.
std::pair< Real, Real > get_eim_error_indicator(Number error_indicator_rhs, const DenseVector< Number > &eim_solution, const DenseVector< Number > &eim_rhs)
Evaluates the EIM error indicator based on error_indicator_rhs, eim_solution, and _error_indicator_in...
std::vector< 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 set_rb_eim_solutions(const std::vector< DenseVector< Number > > &rb_eim_solutions)
Set _rb_eim_solutions.
unsigned int get_n_basis_functions() const
Return the current number of EIM basis functions.
void add_interpolation_points_qp(unsigned int qp)
void write_out_interior_basis_functions(const std::string &directory_name, bool write_binary_basis_functions)
Method that writes out element interior EIM basis functions.
void add_interpolation_points_elem_id(dof_id_type elem_id)
RBEIMEvaluation & operator=(const RBEIMEvaluation &)=delete
subdomain_id_type get_interpolation_points_subdomain_id(unsigned int index) const
unsigned int get_n_interpolation_points() const
Return the number of interpolation points.
std::vector< NodeDataMap > _local_node_eim_basis_functions
The EIM basis functions on element nodes (e.g.
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.
unsigned int get_interpolation_points_comp(unsigned int index) const
unsigned int get_n_properties() const
Return the number of properties stored in the rb_property_map.
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 side_distribute_bfs(const System &sys)
Same as distribute_bfs() except for side data.
void initialize_eim_theta_objects()
Build a vector of RBTheta objects that accesses the components of the RB_solution member variable of ...
void set_error_indicator_interpolation_row(const DenseVector< Number > &error_indicator_row)
const std::vector< Real > & get_interpolation_points_JxW_all_qp(unsigned int index) const
void set_n_basis_functions(unsigned int n_bfs)
Set the number of 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.
const std::vector< std::vector< Real > > & get_interpolation_points_phi_i_all_qp(unsigned int index) const
std::vector< SideQpDataMap > _local_side_eim_basis_functions
The EIM basis functions on element sides.
const QpDataMap & get_basis_function(unsigned int i) const
Get a reference to the i^th basis function.
void node_distribute_bfs(const System &sys)
Same as distribute_bfs() except for node data.
void add_interpolation_points_xyz(Point p)
Set the data associated with EIM interpolation points.
bool _is_eim_error_indicator_active
Indicate if the EIM error indicator is active in RB EIM solves.
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.
void add_interpolation_points_phi_i_qp(const std::vector< Real > &phi_i_qp)
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.
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.
virtual void clear() override
Clear this object.
void add_node_basis_function(const NodeDataMap &node_bf)
Add node_bf to our EIM basis.
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...
std::vector< Number > get_rb_eim_solutions_entries(unsigned int index) const
Return entry index for each solution in _rb_eim_solutions.
void resize_data_structures(const unsigned int Nmax)
Resize the data structures for storing data associated with this object.
void set_parametrized_function(std::unique_ptr< RBParametrizedFunction > pf)
Set the parametrized function that we will approximate using the Empirical Interpolation Method.
dof_id_type get_interpolation_points_elem_id(unsigned int index) const
RBEIMEvaluation(const RBEIMEvaluation &)=delete
void add_interpolation_points_spatial_indices(const std::vector< unsigned int > &spatial_indices)
void side_decrement_vector(SideQpDataMap &v, const DenseVector< Number > &coeffs)
Same as decrement_vector() except for Side data.
const NodeDataMap & get_node_basis_function(unsigned int i) const
Get a reference to the i^th node basis function.
void read_in_side_basis_functions(const System &sys, const std::string &directory_name, bool read_binary_basis_functions)
Method that reads in element side EIM basis functions.
void set_eim_error_indicator_active(bool is_active)
Activate/decative the error indicator in EIM solves.
void initialize_rb_property_map()
Initialize the rb_property_map of RBEIMEvaluation (this) from the rb_property_map stored in RBParamet...
const std::vector< Real > & get_interpolation_points_phi_i_qp(unsigned int index) const
void add_side_basis_function(const SideQpDataMap &side_bf)
Add side_bf to our EIM basis.
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.
const std::vector< EIMVarGroupPlottingInfo > & get_eim_vars_to_project_and_write() const
Get _eim_vars_to_project_and_write.
void initialize_interpolation_points_spatial_indices()
Initialize _interpolation_points_spatial_indices.
dof_id_type get_interpolation_points_node_id(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 _inte...
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.
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.
std::vector< std::vector< Number > > get_interior_basis_function_as_vec_helper(unsigned int n_vars, unsigned int n_qp_data, unsigned int bf_index)
Helper function called by write_out_interior_basis_functions() to get basis function bf_index stored ...
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.
const std::vector< DenseVector< Number > > & get_rb_eim_solutions() const
Return the EIM solution coefficients from the most recent call to rb_eim_solves().
void add_elem_id_local_index_map_entry(dof_id_type elem_id, unsigned int local_index)
void set_interpolation_matrix_entry(unsigned int i, unsigned int j, Number value)
Set entry of the EIM interpolation matrix.
std::map< std::string, std::size_t > get_interior_basis_function_sizes(std::vector< unsigned int > &n_qp_per_elem)
Get data that defines the sizes of interior EIM basis functions.
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.
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...
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...
VectorizedEvalInput _vec_eval_input
We store the EIM interpolation point data in this object.
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.
void node_decrement_vector(NodeDataMap &v, const DenseVector< Number > &coeffs)
Same as decrement_vector() except for node data.
EimErrorIndicatorNormalization
Here we store an enum that defines the type of EIM error indicator normalization that we use in get_e...
void add_interpolation_points_qrule_order(Order qrule_order)
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...
void add_elem_center_dxyzdxi(const Point &dxyzdxi)
void node_gather_bfs()
Same as gather_bfs() except for node data.
bool limit_eim_error_indicator_to_one
If this boolean is true then we clamp EIM error indicator values to be at most 1.
void add_elem_center_dxyzdeta(const Point &dxyzdxi)
unsigned int _rb_eim_solves_N
void add_interpolation_points_node_id(dof_id_type node_id)
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.
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.
DenseVector< Number > rb_eim_solve(DenseVector< Number > &EIM_rhs)
Calculate the EIM approximation for the given right-hand side vector EIM_rhs.
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.
void initialize_param_fn_spatial_indices()
The Online counterpart of initialize_interpolation_points_spatial_indices().
std::vector< EIMVarGroupPlottingInfo > _eim_vars_to_project_and_write
This vector specifies which EIM variables we want to write to disk and/or project to nodes for plotti...
std::unique_ptr< RBParametrizedFunction > _parametrized_function
Store the parametrized function that will be approximated by this EIM system.
const std::vector< std::pair< Real, Real > > & get_rb_eim_error_indicators() const
Return the EIM error indicator values from the most recent call to rb_eim_solves().
RBEIMEvaluation(RBEIMEvaluation &&)=default
Special functions.
RBParametrizedFunction & get_parametrized_function()
Get a reference to the parametrized function.
boundary_id_type get_interpolation_points_boundary_id(unsigned int index) const
ElemType get_interpolation_points_elem_type(unsigned int index) const
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.
bool get_preserve_rb_eim_solutions() const
Get _preserve_rb_eim_solutions.
std::vector< std::unique_ptr< RBTheta > > & get_eim_theta_objects()
const Point & get_elem_center_dxyzdeta(unsigned int index) const
std::vector< DenseVector< Number > > _rb_eim_solutions
The EIM solution coefficients from the most recent call to rb_eim_solves().
const Point & get_elem_center_dxyzdxi(unsigned int index) 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.
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 va...
unsigned int get_interpolation_points_qp(unsigned int index) const
const VectorizedEvalInput & get_vec_eval_input() const
Get the VectorizedEvalInput data.
void add_interpolation_points_JxW_all_qp(const std::vector< Real > &JxW_all_qp)
void gather_bfs()
Helper function that gathers the contents of _local_eim_basis_functions to processor 0 in preparation...
const std::vector< Point > & get_interpolation_points_xyz_perturbations(unsigned int index) const
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.
std::map< dof_id_type, std::vector< Number > > NodeDataMap
Type of the data structure used to map from (node id) -> [n_vars] data.
A simple functor class that provides a RBParameter-dependent function.
This class is part of the rbOOmit framework.
Manages consistently variables, degrees of freedom, and coefficient vectors.
The libMesh namespace provides an interface to certain functionality in the library.
ElemType
Defines an enum for geometric element types.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
This struct encapsulates data that specifies how we will perform plotting for EIM variable groups.
Real min_value
The min (resp.
bool enforce_min_value
These booleans indicate if we should clamp the resulting output to be above a min value or below a ma...
unsigned int n_eim_vars
The number of EIM variables in the group.
unsigned int first_eim_var_index
The index for the first EIM variable in this variable group.
std::string eim_sys_name
The name of the System we use for plotting this EIM variable group.
EIMVarGroupPlottingInfo()
Default constructor.