Go to the documentation of this file.
   21 #include "libmesh/libmesh_config.h" 
   25 #if defined(LIBMESH_HAVE_SLEPC) && (LIBMESH_HAVE_GLPK) 
   27 #include "libmesh/rb_scm_construction.h" 
   28 #include "libmesh/rb_construction.h" 
   29 #include "libmesh/rb_scm_evaluation.h" 
   31 #include "libmesh/libmesh_logging.h" 
   32 #include "libmesh/numeric_vector.h" 
   33 #include "libmesh/sparse_matrix.h" 
   34 #include "libmesh/equation_systems.h" 
   35 #include "libmesh/getpot.h" 
   36 #include "libmesh/dof_map.h" 
   37 #include "libmesh/enum_eigen_solver_type.h" 
   40 #include <sys/types.h> 
   48                                       const std::string & name_in,
 
   49                                       const unsigned int number_in)
 
   50   : 
Parent(es, name_in, number_in),
 
   51     SCM_training_tolerance(0.5),
 
   84     libmesh_error_msg(
"Error: RBSCMEvaluation object hasn't been initialized yet");
 
   97   GetPot infile(parameters_filename);
 
   98   const unsigned int n_training_samples = infile(
"n_training_samples",1);
 
   99   const bool deterministic_training     = infile(
"deterministic_training",
false);
 
  104   unsigned int training_parameters_random_seed_in = static_cast<int>(-1);
 
  105   training_parameters_random_seed_in = infile(
"training_parameters_random_seed",
 
  106                                               training_parameters_random_seed_in);
 
  114   unsigned int n_continuous_parameters = infile.vector_variable_size(
"parameter_names");
 
  117   for (
unsigned int i=0; i<n_continuous_parameters; i++)
 
  120       std::string param_name = infile(
"parameter_names", 
"NONE", i);
 
  123         Real min_val = infile(param_name, 0., 0);
 
  124         mu_min_in.
set_value(param_name, min_val);
 
  128         Real max_val = infile(param_name, 0., 1);
 
  129         mu_max_in.
set_value(param_name, max_val);
 
  133   std::map<std::string, std::vector<Real>> discrete_parameter_values_in;
 
  135   unsigned int n_discrete_parameters = infile.vector_variable_size(
"discrete_parameter_names");
 
  136   for (
unsigned int i=0; i<n_discrete_parameters; i++)
 
  138       std::string param_name = infile(
"discrete_parameter_names", 
"NONE", i);
 
  140       unsigned int n_vals_for_param = infile.vector_variable_size(param_name);
 
  141       std::vector<Real> vals_for_param(n_vals_for_param);
 
  142       for (
unsigned int j=0; j != n_vals_for_param; j++)
 
  143         vals_for_param[j] = infile(param_name, 0., j);
 
  145       discrete_parameter_values_in[param_name] = vals_for_param;
 
  150   std::map<std::string,bool> log_scaling;
 
  153   for (
const auto & pr : mu)
 
  155       const std::string & param_name = pr.first;
 
  156       log_scaling[param_name] = static_cast<bool>(infile(
"log_scaling", 0, i++));
 
  163                                  deterministic_training);   
 
  169   libMesh::out << std::endl << 
"RBSCMConstruction parameters:" << std::endl;
 
  178       libMesh::out << 
"RBThetaExpansion member is not set yet" << std::endl;
 
  183       const std::string & param_name = pr.first;
 
  211   LOG_SCOPE(
"add_scaled_symm_Aq()", 
"RBSCMConstruction");
 
  231   LOG_SCOPE(
"perform_SCM_greedy()", 
"RBSCMConstruction");
 
  236 #ifdef LIBMESH_ENABLE_CONSTRAINTS 
  238   std::set<dof_id_type> constrained_dofs_set;
 
  246           constrained_dofs_set.insert(i);
 
  253 #endif // LIBMESH_ENABLE_CONSTRAINTS 
  264   unsigned int SCM_iter=0;
 
  274                    << 
", max_SCM_error = " << SCM_error_pair.second << std::endl;
 
  279                        << std::endl << std::endl;
 
  286       libMesh::out << std::endl << 
"-----------------------------------" << std::endl << std::endl;
 
  294   LOG_SCOPE(
"compute_SCM_bounding_box()", 
"RBSCMConstruction");
 
  318           libmesh_assert_less (eval.second, 
TOLERANCE);
 
  324         libmesh_error_msg(
"Eigen solver for computing B_min did not converge");
 
  339           libmesh_assert_less (eval.second, 
TOLERANCE);
 
  345         libmesh_error_msg(
"Eigen solver for computing B_max did not converge");
 
  351   LOG_SCOPE(
"evaluate_stability_constant()", 
"RBSCMConstruction");
 
  354   const unsigned int j = cast_int<unsigned int>(
rb_scm_eval->
C_J.size()-1);
 
  379       libmesh_assert_less (eval.second, 
TOLERANCE);
 
  383       libMesh::out << std::endl << 
"Stability constant for C_J("<<j<<
") = " 
  399     libmesh_error_msg(
"Error: Eigensolver did not converge in evaluate_stability_constant");
 
  415     libmesh_error_msg(
"Error: We must have q < Q_a in Aq_inner_product.");
 
  426   LOG_SCOPE(
"compute_SCM_bounds_on_training_set()", 
"RBSCMConstruction");
 
  429   unsigned int new_C_J_index = 0;
 
  430   Real max_SCM_error = 0.;
 
  442       if (error_i > max_SCM_error)
 
  444           max_SCM_error = error_i;
 
  450   std::pair<numeric_index_type,Real> error_pair(global_index, max_SCM_error);
 
  458   LOG_SCOPE(
"enrich_C_J()", 
"RBSCMConstruction");
 
  471       const std::string & param_name = pr.first;
 
  488 #endif // LIBMESH_HAVE_SLEPC && LIBMESH_HAVE_GLPK 
  
virtual void perform_SCM_greedy()
Perform the SCM greedy algorithm to develop a lower bound over the training set.
 
void print_discrete_parameter_values() const
Print out all the discrete parameter values.
 
virtual std::pair< unsigned int, Real > compute_SCM_bounds_on_training_set()
Compute upper and lower bounds for each SCM training point.
 
const RBParameters & get_parameters_min() const
Get an RBParameters object that specifies the minimum allowable value for each parameter.
 
virtual void clear()
Clear all the data structures associated with the system.
 
const EquationSystems & get_equation_systems() const
 
virtual void resize_SCM_vectors()
Clear and resize the SCM data vectors.
 
virtual void load_matrix_B()
Copy over the matrix to store in matrix_B, usually this is the mass or inner-product matrix,...
 
std::unique_ptr< SparseMatrix< Number > > matrix_A
The system matrix for standard eigenvalue problems.
 
std::vector< RBParameters > C_J
Vector storing the greedily selected parameters during SCM training.
 
void set_B_min(unsigned int i, Real B_min_val)
Set B_min and B_max.
 
Number B_inner_product(const NumericVector< Number > &v, const NumericVector< Number > &w) const
Compute the inner product between two vectors using the system's matrix_B.
 
numeric_index_type get_first_local_training_index() const
Get the first local index of the training parameters.
 
std::unique_ptr< NumericVector< Number > > inner_product_storage_vector
We keep an extra temporary vector that is useful for performing inner products (avoids unnecessary me...
 
std::vector< Real > B_max
 
virtual void solve() override
Override to solve the condensed eigenproblem with the dofs in local_non_condensed_dofs_vector strippe...
 
void set_rb_scm_evaluation(RBSCMEvaluation &rb_scm_eval_in)
Set the RBSCMEvaluation object.
 
Real SCM_training_tolerance
Tolerance which controls when to terminate the SCM Greedy.
 
void set_training_random_seed(unsigned int seed)
Set the seed that is used to randomly generate training parameters.
 
unsigned int get_n_params() const
Get the number of parameters.
 
The libMesh namespace provides an interface to certain functionality in the library.
 
const T_sys & get_system(const std::string &name) const
 
virtual void clear() override
Clear all the data structures associated with the system.
 
virtual void set_params_from_training_set_and_broadcast(unsigned int index)
Load the specified training parameter and then broadcast to all processors.
 
static const Real TOLERANCE
 
const Parallel::Communicator & comm() const
 
virtual void set_eigensolver_properties(int)
This function is called before truth eigensolves in compute_SCM_bounding_box and evaluate_stability_c...
 
This class is part of the rbOOmit framework.
 
std::unique_ptr< EigenSolver< Number > > eigen_solver
The EigenSolver, defining which interface, i.e solver package to use.
 
std::vector< std::vector< Real > > SCM_UB_vectors
This matrix stores the infimizing vectors y_1( ),...,y_Q_a( ), for each  in C_J, which are used in co...
 
virtual std::pair< Real, Real > get_eigenpair(dof_id_type i) override
Override get_eigenpair() to retrieve the eigenpair for the condensed eigensolve.
 
void set_eigenproblem_type(EigenProblemType ept)
Sets the type of the current eigen problem.
 
RBSCMConstruction(EquationSystems &es, const std::string &name_in, const unsigned int number_in)
Constructor.
 
bool is_constrained_dof(const dof_id_type dof) const
 
void set_parameters(const RBParameters ¶ms)
Set the current parameters to params.
 
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object.
 
static void get_global_max_error_pair(const Parallel::Communicator &communicator, std::pair< numeric_index_type, Real > &error_pair)
Static function to return the error pair (index,error) that is corresponds to the largest error on al...
 
virtual Real get_SCM_UB()
Evaluate single SCM upper bound.
 
const RBParameters & get_parameters_max() const
Get an RBParameters object that specifies the maximum allowable value for each parameter.
 
const RBParameters & get_parameters() const
Get the current parameters.
 
void set_SCM_training_tolerance(Real SCM_training_tolerance_in)
 
Number Aq_inner_product(unsigned int q, const NumericVector< Number > &v, const NumericVector< Number > &w)
Compute the inner product between two vectors using matrix Aq.
 
unsigned int get_n_converged() const
 
std::unique_ptr< SparseMatrix< Number > > matrix_B
A second system matrix for generalized eigenvalue problems.
 
bool assemble_before_solve
Flag which tells the system to whether or not to call the user assembly function during each call to ...
 
std::vector< Real > C_J_stability_vector
Vector storing the (truth) stability values at the parameters in C_J.
 
virtual void process_parameters_file(const std::string ¶meters_filename)
Read in the parameters from file specified by parameters_filename and set the this system's member va...
 
SparseMatrix< Number > * get_inner_product_matrix()
Get a pointer to inner_product_matrix.
 
RBSCMEvaluation & get_rb_scm_evaluation()
Get a reference to the RBSCMEvaluation object.
 
Real get_parameter_max(const std::string ¶m_name) const
Get maximum allowable value of parameter param_name.
 
virtual void compute_SCM_bounding_box()
Compute the SCM bounding box.
 
numeric_index_type get_n_training_samples() const
Get the total number of training samples.
 
void set_params_from_training_set(unsigned int index)
Set parameters to the RBParameters stored in index index of the training set.
 
void set_SCM_UB_vector(unsigned int j, unsigned int q, Real y_q)
Set entries of SCM_UB_vector, which stores the vector y, corresponding to the minimizing eigenvectors...
 
Real get_SCM_training_tolerance() const
Get/set SCM_training_tolerance: tolerance for SCM greedy.
 
std::vector< Real > B_min
B_min, B_max define the bounding box.
 
void set_value(const std::string ¶m_name, Real value)
Set the value of the specified parameter.
 
This class is part of the rbOOmit framework.
 
virtual void enrich_C_J(unsigned int new_C_J_index)
Enrich C_J by adding the element of SCM_training_samples that has the largest gap between alpha_LB an...
 
Real get_B_max(unsigned int i) const
 
void add_scaled_Aq(Number scalar, unsigned int q_a, SparseMatrix< Number > *input_matrix, bool symmetrize)
Add the scaled q^th affine matrix to input_matrix.
 
virtual ~RBSCMConstruction()
Destructor.
 
void initialize_condensed_dofs(const std::set< dof_id_type > &global_condensed_dofs_set=std::set< dof_id_type >())
Loop over the dofs on each processor to initialize the list of non-condensed dofs.
 
dof_id_type numeric_index_type
 
This is the EquationSystems class.
 
virtual void evaluate_stability_constant()
Compute the stability constant for current_parameters by solving a generalized eigenvalue problem ove...
 
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.
 
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
 
virtual Real SCM_greedy_error_indicator(Real LB, Real UB)
Helper function which provides an error indicator to be used in the SCM greedy.
 
RBSCMEvaluation * rb_scm_eval
The current RBSCMEvaluation object we are using to perform the Evaluation stage of the SCM.
 
const std::string & name() const
 
std::string RB_system_name
The name of the associated RB system.
 
virtual void print_info()
Print out info that describes the current setup of this RBSCMConstruction.
 
This class is part of the rbOOmit framework.
 
unsigned int get_n_A_terms() const
Get Q_a, the number of terms in the affine expansion for the bilinear form.
 
virtual void attach_deflation_space()
Attach the deflation space defined by the specified vector, can be useful in solving constrained eige...
 
virtual Real get_SCM_LB()
Evaluate single SCM lower bound.
 
Real get_B_min(unsigned int i) const
Get B_min and B_max.
 
void set_C_J_stability_constraint(unsigned int j, Real stability_constraint_in)
Set stability constraints (i.e.
 
void set_B_max(unsigned int i, Real B_max_val)
 
const DofMap & get_dof_map() const
 
dof_id_type n_dofs() const
 
numeric_index_type get_local_n_training_samples() const
Get the total number of training samples local to this processor.
 
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
 
This class stores the set of RBTheta functor objects that define the "parameter-dependent expansion" ...
 
virtual void add_scaled_symm_Aq(unsigned int q_a, Number scalar)
Add the scaled symmetrized affine matrix from the associated RBSystem to matrix_A.
 
virtual void initialize_training_parameters(const RBParameters &mu_min, const RBParameters &mu_max, unsigned int n_training_parameters, std::map< std::string, bool > log_param_scale, bool deterministic=true)
Initialize the parameter ranges and indicate whether deterministic or random training parameters shou...
 
virtual T dot(const NumericVector< T > &v) const =0
 
Real get_C_J_stability_constraint(unsigned int j) const
Get stability constraints (i.e.
 
Real get_value(const std::string ¶m_name) const
Get the value of the specific parameter.
 
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the rb_theta_expansion.
 
Real get_parameter_min(const std::string ¶m_name) const
Get minimum allowable value of parameter param_name.