libMesh
Loading...
Searching...
No Matches
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
24#include "libmesh/id_types.h"
25#include "libmesh/rb_parametrized.h"
26#include "libmesh/rb_theta_expansion.h"
27#include "libmesh/rb_theta.h"
28
29// libMesh includes
30#include "libmesh/system.h"
31#include "libmesh/numeric_vector.h"
32#include "libmesh/linear_solver.h"
33#include "libmesh/perf_log.h"
34
35// C++ includes
36#include <set>
37
38namespace libMesh
39{
40
54template<class Base>
55class RBConstructionBase : public Base, public RBParametrized
56{
57public:
58
63 const std::string & name,
64 const unsigned int number);
65
78
83
87 sys_type & system () { return *this; }
88
93 virtual void clear ();
94
100 void set_quiet_mode(bool quiet_mode_in)
101 { this->quiet_mode = quiet_mode_in; }
102
106 bool is_quiet() const
107 { return this->quiet_mode; }
108
114
119
124
129
134
142 virtual void initialize_training_parameters(const RBParameters & mu_min,
143 const RBParameters & mu_max,
144 const unsigned int n_global_training_samples,
145 const std::map<std::string, bool> & log_param_scale,
146 const bool deterministic=true);
147
152 virtual void load_training_set(const std::map<std::string, std::vector<RBParameter>> & new_training_set);
153
158 void set_training_parameter_values(const std::string & param_name, const std::vector<RBParameter> & values);
159
165 void broadcast_parameters(const unsigned int proc_id);
166
170 void set_training_random_seed(int seed);
171
184 void set_deterministic_training_parameter_name(const std::string & name);
185
189 const std::string & get_deterministic_training_parameter_name() const;
190
198 static std::pair<std::size_t, std::size_t>
200 const std::map<std::string, bool> & log_param_scale,
201 std::map<std::string, std::vector<RBParameter>> & local_training_parameters_in,
202 const unsigned int n_global_training_samples_in,
203 const RBParameters & min_parameters,
204 const RBParameters & max_parameters,
205 const int training_parameters_random_seed=-1,
206 const bool serial_training_set=false);
207
216 static std::pair<std::size_t, std::size_t>
218 const std::map<std::string, bool> & log_param_scale,
219 std::map<std::string, std::vector<RBParameter>> & local_training_parameters_in,
220 const unsigned int n_global_training_samples_in,
221 const RBParameters & min_parameters,
222 const RBParameters & max_parameters,
223 const bool serial_training_set=false);
224
225protected:
226
231 virtual void init_data ();
232
238 RBParameters get_params_from_training_set(unsigned int global_index);
239
243 void set_params_from_training_set(unsigned int global_index);
244
248 virtual void set_params_from_training_set_and_broadcast(unsigned int global_index);
249
255 static void get_global_max_error_pair(const Parallel::Communicator & communicator,
256 std::pair<numeric_index_type, Real> & error_pair);
257
258
259 //----------- PROTECTED DATA MEMBERS -----------//
260
266
274
282
288 std::unique_ptr<NumericVector<Number>> inner_product_storage_vector;
289
290
291private:
292
298
306 std::map<std::string, std::vector<RBParameter>> _training_parameters;
307
316
324};
325
326} // namespace libMesh
327
328
329#endif // LIBMESH_RB_CONSTRUCTION_BASE_H
This is the EquationSystems class.
This class is part of the rbOOmit framework.
virtual void init_data()
Initializes the member data fields associated with the system, so that, e.g., assemble() may be used.
RBParameters get_params_from_training_set(unsigned int global_index)
Return the RBParameters in index global_index of the global training set.
virtual void set_params_from_training_set_and_broadcast(unsigned int global_index)
Load the specified training parameter and then broadcast to all processors.
std::map< std::string, std::vector< RBParameter > > _training_parameters
The training samples for each parameter.
void set_deterministic_training_parameter_name(const std::string &name)
In some cases we only want to allow discrete parameter values, instead of parameters that may take an...
RBConstructionBase(const RBConstructionBase &)=delete
bool _training_parameters_initialized
Boolean flag to indicate whether or not the parameter ranges have been initialized.
void set_training_random_seed(int seed)
Set the seed that is used to randomly generate 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...
numeric_index_type _n_global_training_samples
virtual void clear()
Clear all the data structures associated with the system.
void set_quiet_mode(bool quiet_mode_in)
Set the quiet_mode flag.
numeric_index_type _n_local_training_samples
static std::pair< std::size_t, std::size_t > generate_training_parameters_random(const Parallel::Communicator &communicator, const std::map< std::string, bool > &log_param_scale, std::map< std::string, std::vector< RBParameter > > &local_training_parameters_in, const unsigned int n_global_training_samples_in, const RBParameters &min_parameters, const RBParameters &max_parameters, const int training_parameters_random_seed=-1, const bool serial_training_set=false)
Static helper function for generating a randomized set of parameters.
bool quiet_mode
Flag to indicate whether we print out extra information during the Offline stage.
int _training_parameters_random_seed
If < 0, use std::time() * processor_id() to seed the random number generator for the training paramet...
void set_training_parameter_values(const std::string &param_name, const std::vector< RBParameter > &values)
Overwrite the local training samples for param_name using values.
numeric_index_type get_first_local_training_index() const
Get the first local index of the training parameters.
numeric_index_type get_local_n_training_samples() const
Get the total number of training samples local to this processor.
RBConstructionBase(RBConstructionBase &&)=default
Special functions.
void broadcast_parameters(const unsigned int proc_id)
Broadcasts parameters from processor proc_id to all processors.
RBConstructionBase & operator=(RBConstructionBase &&)=delete
numeric_index_type get_n_training_samples() const
Get the number of global training samples.
void set_normalize_solution_snapshots(bool value)
Set the boolean option that indicates if we normalization solution snapshots or not.
virtual void initialize_training_parameters(const RBParameters &mu_min, const RBParameters &mu_max, const unsigned int n_global_training_samples, const std::map< std::string, bool > &log_param_scale, const bool deterministic=true)
Initialize the parameter ranges and indicate whether deterministic or random training parameters shou...
RBConstructionBase< Base > sys_type
The type of system.
void set_params_from_training_set(unsigned int global_index)
Set parameters to the RBParameters stored in index global_index of the global training set.
const std::string & get_deterministic_training_parameter_name() const
Get the name of the parameter that we will generate deterministic training parameters for.
static std::pair< std::size_t, std::size_t > generate_training_parameters_deterministic(const Parallel::Communicator &communicator, const std::map< std::string, bool > &log_param_scale, std::map< std::string, std::vector< RBParameter > > &local_training_parameters_in, const unsigned int n_global_training_samples_in, const RBParameters &min_parameters, const RBParameters &max_parameters, const bool serial_training_set=false)
Static helper function for generating a deterministic set of parameters.
numeric_index_type get_last_local_training_index() const
Get the last local index of the training parameters.
bool serial_training_set
This boolean flag indicates whether or not the training set should be the same on all processors.
bool is_quiet() const
Is the system in quiet mode?
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...
bool _normalize_solution_snapshots
Set this boolean to true if we want to normalize solution snapshots used in training to have norm of ...
virtual void load_training_set(const std::map< std::string, std::vector< RBParameter > > &new_training_set)
Overwrite the training parameters with new_training_set.
numeric_index_type _first_local_index
The first sample-vector index from the global vector which is stored in the _training_parameters on t...
This class is part of the rbOOmit framework.
This class is part of the rbOOmit framework.
The libMesh namespace provides an interface to certain functionality in the library.
dof_id_type numeric_index_type
Definition id_types.h:99
static const bool value
Definition xdr_io.C:55