$extrastylesheet
rb_construction_base.h
Go to the documentation of this file.
00001 // rbOOmit: An implementation of the Certified Reduced Basis method.
00002 // Copyright (C) 2009, 2010 David J. Knezevic
00003 
00004 // This file is part of rbOOmit.
00005 
00006 // rbOOmit is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License, or (at your option) any later version.
00010 
00011 // rbOOmit is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 #ifndef LIBMESH_RB_CONSTRUCTION_BASE_H
00021 #define LIBMESH_RB_CONSTRUCTION_BASE_H
00022 
00023 // rbOOmit includes
00024 #include "libmesh/rb_parametrized.h"
00025 #include "libmesh/rb_theta_expansion.h"
00026 #include "libmesh/rb_theta.h"
00027 
00028 // libMesh includes
00029 #include "libmesh/system.h"
00030 #include "libmesh/numeric_vector.h"
00031 #include "libmesh/linear_solver.h"
00032 #include "libmesh/perf_log.h"
00033 
00034 // C++ includes
00035 #include <set>
00036 
00037 namespace libMesh
00038 {
00039 
00054 // ------------------------------------------------------------
00055 // RBConstructionBase class definition
00056 template<class Base>
00057 class RBConstructionBase : public Base, public RBParametrized
00058 {
00059 public:
00060 
00065   RBConstructionBase (EquationSystems& es,
00066                       const std::string& name,
00067                       const unsigned int number);
00068 
00072   virtual ~RBConstructionBase ();
00073 
00077   typedef RBConstructionBase<Base> sys_type;
00078 
00082   sys_type & system () { return *this; }
00083 
00088   virtual void clear ();
00089 
00093   numeric_index_type get_n_training_samples() const;
00094 
00098   numeric_index_type get_local_n_training_samples() const;
00099 
00103   numeric_index_type get_first_local_training_index() const;
00104 
00108   numeric_index_type get_last_local_training_index() const;
00109 
00115   virtual void initialize_training_parameters(const RBParameters& mu_min,
00116                                               const RBParameters& mu_max,
00117                                               unsigned int n_training_parameters,
00118                                               std::map<std::string, bool> log_param_scale,
00119                                               bool deterministic=true);
00120 
00124   virtual void load_training_set(std::map< std::string, std::vector<Number> >& new_training_set);
00125 
00135   std::pair<std::string,std::string> set_alternative_solver(UniquePtr<LinearSolver<Number> >& ls);
00136 
00143   void reset_alternative_solver(UniquePtr<LinearSolver<Number> >& ls,
00144                                 const std::pair<std::string,std::string>& orig);
00145 
00150   void broadcast_parameters(unsigned int proc_id);
00151 
00155   void set_training_random_seed(unsigned int seed);
00156 
00169   void set_deterministic_training_parameter_name(const std::string& name);
00170 
00174   const std::string& get_deterministic_training_parameter_name() const;
00175 
00179   void set_deterministic_training_parameter_repeats(unsigned int repeats);
00180 
00184   unsigned int get_deterministic_training_parameter_repeats() const;
00185 
00186 protected:
00187 
00192   virtual void init_data ();
00193 
00197   RBParameters get_params_from_training_set(unsigned int index);
00198 
00202   void set_params_from_training_set(unsigned int index);
00203 
00207   virtual void set_params_from_training_set_and_broadcast(unsigned int index);
00208 
00214   static void get_global_max_error_pair(const Parallel::Communicator &communicator,
00215                                         std::pair<unsigned int, Real>& error_pair);
00216 
00220   static void generate_training_parameters_random(const Parallel::Communicator &communicator,
00221                                                   std::map<std::string, bool> log_param_scale,
00222                                                   std::map< std::string, NumericVector<Number>* >& training_parameters_in,
00223                                                   unsigned int n_training_samples_in,
00224                                                   const RBParameters& min_parameters,
00225                                                   const RBParameters& max_parameters,
00226                                                   int training_parameters_random_seed=-1,
00227                                                   bool serial_training_set=false);
00228 
00233   static void generate_training_parameters_deterministic(const Parallel::Communicator &communicator,
00234                                                          std::map<std::string, bool> log_param_scale,
00235                                                          std::map< std::string, NumericVector<Number>* >& training_parameters_in,
00236                                                          unsigned int n_training_samples_in,
00237                                                          const RBParameters& min_parameters,
00238                                                          const RBParameters& max_parameters,
00239                                                          bool serial_training_set=false);
00240 
00241 
00242   //----------- PROTECTED DATA MEMBERS -----------//
00243 
00250   bool serial_training_set;
00251 
00257   UniquePtr< NumericVector<Number> > inner_product_storage_vector;
00258 
00271   std::string alternative_solver;
00272 
00273 
00274 private:
00275 
00280   bool training_parameters_initialized;
00281 
00285   std::map< std::string, NumericVector<Number>* > training_parameters;
00286 
00293   int training_parameters_random_seed;
00294 
00295 };
00296 
00297 } // namespace libMesh
00298 
00299 
00300 #endif // LIBMESH_RB_CONSTRUCTION_BASE_H