Line data Source code
1 : // rbOOmit: An implementation of the Certified Reduced Basis method. 2 : // Copyright (C) 2009, 2010 David J. Knezevic 3 : 4 : // This file is part of rbOOmit. 5 : 6 : // rbOOmit is free software; you can redistribute it and/or 7 : // modify it under the terms of the GNU Lesser General Public 8 : // License as published by the Free Software Foundation; either 9 : // version 2.1 of the License, or (at your option) any later version. 10 : 11 : // rbOOmit is distributed in the hope that it will be useful, 12 : // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 : // Lesser General Public License for more details. 15 : 16 : // You should have received a copy of the GNU Lesser General Public 17 : // License along with this library; if not, write to the Free Software 18 : // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 : 20 : #ifndef LIBMESH_RB_SCM_EVALUATION_H 21 : #define LIBMESH_RB_SCM_EVALUATION_H 22 : 23 : // RBSCMEvaluation should only be available 24 : // if SLEPc and GLPK support is enabled. 25 : #include "libmesh/libmesh_config.h" 26 : #if defined(LIBMESH_HAVE_SLEPC) && (LIBMESH_HAVE_GLPK) 27 : 28 : // rbOOmit includes 29 : #include "libmesh/rb_parametrized.h" 30 : 31 : // libMesh includes 32 : #include "libmesh/parallel_object.h" 33 : 34 : // C++ includes 35 : 36 : namespace libMesh 37 : { 38 : 39 : // Forward declarations 40 : class RBThetaExpansion; 41 : 42 : /** 43 : * This class is part of the rbOOmit framework. 44 : * 45 : * RBSCMEvaluation encapsulates the functionality required 46 : * to _evaluate_ the Successive Constraint Method for 47 : * associated with a reduced basis model. 48 : * 49 : * \author David J. Knezevic 50 : * \date 2011 51 : */ 52 0 : class RBSCMEvaluation : public RBParametrized, 53 : public ParallelObject 54 : { 55 : public: 56 : 57 : /** 58 : * Constructor. 59 : */ 60 : RBSCMEvaluation (const Parallel::Communicator & comm); 61 : 62 : /** 63 : * Destructor. 64 : */ 65 : virtual ~RBSCMEvaluation (); 66 : 67 : /** 68 : * Set the RBThetaExpansion object. 69 : */ 70 : void set_rb_theta_expansion(RBThetaExpansion & rb_theta_expansion_in); 71 : 72 : /** 73 : * Get a reference to the rb_theta_expansion. 74 : */ 75 : RBThetaExpansion & get_rb_theta_expansion(); 76 : 77 : /** 78 : * Evaluate single SCM lower bound. 79 : */ 80 : virtual Real get_SCM_LB(); 81 : 82 : /** 83 : * Evaluate single SCM upper bound. 84 : */ 85 : virtual Real get_SCM_UB(); 86 : 87 : /** 88 : * Get stability constraints (i.e. the values of coercivity/ 89 : * inf-sup/stability constants at the parameter values chosen 90 : * during the greedy); we store one constraint for each element 91 : * of C_J. 92 : */ 93 : Real get_C_J_stability_constraint(unsigned int j) const; 94 : 95 : /** 96 : * Set stability constraints (i.e. the values of coercivity/ 97 : * inf-sup/stability constants at the parameter values chosen 98 : * during the greedy); we store one constraint for each element 99 : * of C_J. 100 : */ 101 : void set_C_J_stability_constraint(unsigned int j, Real stability_constraint_in); 102 : 103 : /** 104 : * Get entries of SCM_UB_vector, which stores the 105 : * vector y, corresponding to the minimizing eigenvectors 106 : * for the elements of C_J. 107 : */ 108 : Real get_SCM_UB_vector(unsigned int j, unsigned int q); 109 : 110 : /** 111 : * Set entries of SCM_UB_vector, which stores the 112 : * vector y, corresponding to the minimizing eigenvectors 113 : * for the elements of C_J. 114 : */ 115 : void set_SCM_UB_vector(unsigned int j, unsigned int q, Real y_q); 116 : 117 : /** 118 : * Get size of the set C_J. 119 : */ 120 : unsigned int get_C_J_size() 121 : { return cast_int<unsigned int>(C_J.size()); } 122 : 123 : /** 124 : * Get entry of C_J. 125 : */ 126 : const RBParameters & get_C_J_entry(unsigned int j); 127 : 128 : /** 129 : * Get entry of C_J_stability_vector. 130 : */ 131 : Real get_C_J_stability_value(unsigned int j) { return C_J_stability_vector[j]; } 132 : 133 : /** 134 : * Get B_min and B_max. 135 : */ 136 : Real get_B_min(unsigned int i) const; 137 : Real get_B_max(unsigned int i) const; 138 : 139 : /** 140 : * Set B_min and B_max. 141 : */ 142 : void set_B_min(unsigned int i, Real B_min_val); 143 : void set_B_max(unsigned int i, Real B_max_val); 144 : 145 : /** 146 : * Helper function to save current_parameters in 147 : * saved_parameters. 148 : */ 149 : virtual void save_current_parameters(); 150 : 151 : /** 152 : * Helper function to (re)load current_parameters 153 : * from saved_parameters. 154 : */ 155 : virtual void reload_current_parameters(); 156 : 157 : /** 158 : * Set parameters based on values saved in "C_J" 159 : */ 160 : virtual void set_current_parameters_from_C_J(unsigned int C_J_index); 161 : 162 : /** 163 : * Write out all the data to text files in order to segregate the 164 : * Offline stage from the Online stage. 165 : * 166 : * \note This is a legacy method, use RBDataSerialization instead. 167 : */ 168 : virtual void legacy_write_offline_data_to_files(const std::string & directory_name = "offline_data", 169 : const bool write_binary_data = true); 170 : 171 : /** 172 : * Read in the saved Offline reduced basis data 173 : * to initialize the system for Online solves. 174 : * 175 : * \note This is a legacy method, use RBDataSerialization instead. 176 : */ 177 : virtual void legacy_read_offline_data_from_files(const std::string & directory_name = "offline_data", 178 : const bool read_binary_data = true); 179 : 180 : //----------- PUBLIC DATA MEMBERS -----------// 181 : 182 : /** 183 : * B_min, B_max define the bounding box. 184 : */ 185 : std::vector<Real> B_min; 186 : std::vector<Real> B_max; 187 : 188 : /** 189 : * Vector storing the greedily selected parameters 190 : * during SCM training. 191 : */ 192 : std::vector<RBParameters > C_J; 193 : 194 : /** 195 : * Vector storing the (truth) stability values 196 : * at the parameters in C_J. 197 : */ 198 : std::vector<Real> C_J_stability_vector; 199 : 200 : /** 201 : * This matrix stores the infimizing vectors 202 : * y_1(\f$ \mu \f$),...,y_Q_a(\f$ \mu \f$), for each \f$ \mu \f$ in 203 : * C_J, which are used in computing the SCM 204 : * upper bounds. 205 : */ 206 : std::vector<std::vector<Real>> SCM_UB_vectors; 207 : 208 : private: 209 : 210 : /** 211 : * Vector in which to save a parameter set. Useful 212 : * in get_SCM_LB, for example. 213 : */ 214 : RBParameters saved_parameters; 215 : 216 : /** 217 : * A pointer to to the object that stores the theta expansion. 218 : * This is not a std::unique_ptr since we may want to share it. 219 : * 220 : * \note A \p shared_ptr would be a good option here. 221 : */ 222 : RBThetaExpansion * rb_theta_expansion; 223 : 224 : }; 225 : 226 : } 227 : 228 : #endif // LIBMESH_HAVE_SLEPC && LIBMESH_HAVE_GLPK 229 : 230 : #endif // LIBMESH_RB_SCM_EVALUATION_H