rb_construction_base.h
Go to the documentation of this file.
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_CONSTRUCTION_BASE_H
21 #define LIBMESH_RB_CONSTRUCTION_BASE_H
22 
23 // rbOOmit includes
26 #include "libmesh/rb_theta.h"
27 
28 // libMesh includes
29 #include "libmesh/system.h"
30 #include "libmesh/numeric_vector.h"
31 #include "libmesh/linear_solver.h"
32 #include "libmesh/perf_log.h"
33 
34 // C++ includes
35 #include <set>
36 
37 namespace libMesh
38 {
39 
53 template<class Base>
54 class RBConstructionBase : public Base, public RBParametrized
55 {
56 public:
57 
63  const std::string & name,
64  const unsigned int number);
65 
69  virtual ~RBConstructionBase ();
70 
75 
79  sys_type & system () { return *this; }
80 
85  virtual void clear ();
86 
92  void set_quiet_mode(bool quiet_mode_in)
93  { this->quiet_mode = quiet_mode_in; }
94 
98  bool is_quiet() const
99  { return this->quiet_mode; }
100 
105 
110 
115 
120 
126  virtual void initialize_training_parameters(const RBParameters & mu_min,
127  const RBParameters & mu_max,
128  unsigned int n_training_parameters,
129  std::map<std::string, bool> log_param_scale,
130  bool deterministic=true);
131 
135  virtual void load_training_set(std::map<std::string, std::vector<Number>> & new_training_set);
136 
141  void broadcast_parameters(unsigned int proc_id);
142 
146  void set_training_random_seed(unsigned int seed);
147 
160  void set_deterministic_training_parameter_name(const std::string & name);
161 
165  const std::string & get_deterministic_training_parameter_name() const;
166 
170  void set_deterministic_training_parameter_repeats(unsigned int repeats);
171 
176 
177 protected:
178 
183  virtual void init_data ();
184 
188  RBParameters get_params_from_training_set(unsigned int index);
189 
193  void set_params_from_training_set(unsigned int index);
194 
198  virtual void set_params_from_training_set_and_broadcast(unsigned int index);
199 
206  std::pair<numeric_index_type, Real> & error_pair);
207 
212  std::map<std::string, bool> log_param_scale,
213  std::map<std::string, std::unique_ptr<NumericVector<Number>>> & training_parameters_in,
214  unsigned int n_training_samples_in,
215  const RBParameters & min_parameters,
216  const RBParameters & max_parameters,
218  bool serial_training_set=false);
219 
225  std::map<std::string, bool> log_param_scale,
226  std::map<std::string, std::unique_ptr<NumericVector<Number>>> & training_parameters_in,
227  unsigned int n_training_samples_in,
228  const RBParameters & min_parameters,
229  const RBParameters & max_parameters,
230  bool serial_training_set=false);
231 
232 
233  //----------- PROTECTED DATA MEMBERS -----------//
234 
240 
248 
254  std::unique_ptr<NumericVector<Number>> inner_product_storage_vector;
255 
256 
257 private:
258 
264 
268  std::map<std::string, std::unique_ptr<NumericVector<Number>>> training_parameters;
269 
277 
278 };
279 
280 } // namespace libMesh
281 
282 
283 #endif // LIBMESH_RB_CONSTRUCTION_BASE_H
std::string name(const ElemQuality q)
Definition: elem_quality.C:42
numeric_index_type get_first_local_training_index() const
Manages multiples systems of equations.
void broadcast_parameters(unsigned int proc_id)
MPI_Comm communicator
Definition: communicator.h:57
static void generate_training_parameters_deterministic(const Parallel::Communicator &communicator, std::map< std::string, bool > log_param_scale, std::map< std::string, std::unique_ptr< NumericVector< Number >>> &training_parameters_in, unsigned int n_training_samples_in, const RBParameters &min_parameters, const RBParameters &max_parameters, bool serial_training_set=false)
void set_quiet_mode(bool quiet_mode_in)
static void get_global_max_error_pair(const Parallel::Communicator &communicator, std::pair< numeric_index_type, Real > &error_pair)
std::unique_ptr< NumericVector< Number > > inner_product_storage_vector
RBConstructionBase< Base > sys_type
void set_deterministic_training_parameter_repeats(unsigned int repeats)
std::map< std::string, std::unique_ptr< NumericVector< Number > > > training_parameters
dof_id_type numeric_index_type
Definition: id_types.h:92
void set_params_from_training_set(unsigned int index)
RBConstructionBase(EquationSystems &es, const std::string &name, const unsigned int number)
numeric_index_type get_last_local_training_index() const
numeric_index_type get_local_n_training_samples() const
unsigned int get_deterministic_training_parameter_repeats() const
numeric_index_type get_n_training_samples() const
Extends EigenSystem to allow certain DOFs to be condensed out.
static void generate_training_parameters_random(const Parallel::Communicator &communicator, std::map< std::string, bool > log_param_scale, std::map< std::string, std::unique_ptr< NumericVector< Number >>> &training_parameters_in, unsigned int n_training_samples_in, const RBParameters &min_parameters, const RBParameters &max_parameters, int training_parameters_random_seed=-1, bool serial_training_set=false)
void set_deterministic_training_parameter_name(const std::string &name)
virtual void set_params_from_training_set_and_broadcast(unsigned int index)
void set_training_random_seed(unsigned int seed)
RBParameters get_params_from_training_set(unsigned int index)
const std::string & get_deterministic_training_parameter_name() const
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)
virtual void load_training_set(std::map< std::string, std::vector< Number >> &new_training_set)