libMesh
rb_parametrized.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_PARAMETRIZED_H
21 #define LIBMESH_RB_PARAMETRIZED_H
22 
23 // rbOOmit includes
24 #include "libmesh/rb_parameters.h"
25 
26 // libMesh includes
27 #include "libmesh/reference_counted_object.h"
28 
29 // C++ includes
30 #include <cstddef>
31 #include <vector>
32 
33 namespace libMesh
34 {
35 
45 class RBParametrized : public ReferenceCountedObject<RBParametrized>
46 {
47 public:
48 
52  RBParametrized ();
53 
59  RBParametrized (RBParametrized &&) = default;
61  RBParametrized (const RBParametrized &) = default;
62  RBParametrized & operator= (const RBParametrized &) = default;
63  virtual ~RBParametrized ();
64 
69  virtual void clear ();
70 
78  void initialize_parameters(const RBParameters & mu_min_in,
79  const RBParameters & mu_max_in,
80  const std::map<std::string, std::vector<Real>> & discrete_parameter_values);
81 
85  void initialize_parameters(const RBParametrized & rb_parametrized);
86 
90  unsigned int get_n_params() const;
91 
95  unsigned int get_n_continuous_params() const;
96 
100  unsigned int get_n_discrete_params() const;
101 
102 #ifdef LIBMESH_ENABLE_DEPRECATED
103 
111  std::set<std::string> get_parameter_names() const;
112 #endif // LIBMESH_ENABLE_DEPRECATED
113 
117  const RBParameters & get_parameters() const;
118 
127  bool set_parameters(const RBParameters & params);
128 
133  const RBParameters & get_parameters_min() const;
134 
139  const RBParameters & get_parameters_max() const;
140 
144  Real get_parameter_min(const std::string & param_name) const;
145 
149  Real get_parameter_max(const std::string & param_name) const;
150 
154  void print_parameters() const;
155 
159  void write_parameter_data_to_files(const std::string & continuous_param_file_name,
160  const std::string & discrete_param_file_name,
161  const bool write_binary_data);
162 
166  void read_parameter_data_from_files(const std::string & continuous_param_file_name,
167  const std::string & discrete_param_file_name,
168  const bool read_binary_data);
169 
173  bool is_discrete_parameter(const std::string & mu_name) const;
174 
178  const std::map<std::string, std::vector<Real>> & get_discrete_parameter_values() const;
179 
183  void print_discrete_parameter_values() const;
184 
188  static Real get_closest_value(Real value, const std::vector<Real> & list_of_values);
189 
194 
195 private:
196 
200  void write_parameter_ranges_to_file(const std::string & file_name,
201  const bool write_binary);
202 
206  void write_discrete_parameter_values_to_file(const std::string & file_name,
207  const bool write_binary_data);
208 
213  void read_parameter_ranges_from_file(const std::string & file_name,
214  const bool read_binary,
215  RBParameters & param_min,
216  RBParameters & param_max);
217 
221  void read_discrete_parameter_values_from_file(const std::string & file_name,
222  const bool read_binary_data,
223  std::map<std::string, std::vector<Real>> & discrete_parameter_values_in);
224 
232  bool check_if_valid_params(const RBParameters & params) const;
233 
239  static bool is_value_in_list(Real value, const std::vector<Real> & list_of_values, Real tol);
240 
241  //--------------- PRIVATE DATA MEMBERS ---------------//
242 
247 
252 
258 
262  std::map<std::string, std::vector<Real>> _discrete_parameter_values;
263 };
264 
265 } // namespace libMesh
266 
267 
268 #endif // LIBMESH_RB_PARAMETRIZED_H
virtual void clear()
Clear all the data structures associated with the system.
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
void write_parameter_data_to_files(const std::string &continuous_param_file_name, const std::string &discrete_param_file_name, const bool write_binary_data)
Write out the parameter ranges to files.
void read_parameter_ranges_from_file(const std::string &file_name, const bool read_binary, RBParameters &param_min, RBParameters &param_max)
Read in the parameter ranges from file.
Real get_parameter_min(const std::string &param_name) const
Get minimum allowable value of parameter param_name.
Real get_parameter_max(const std::string &param_name) const
Get maximum allowable value of parameter param_name.
RBParametrized & operator=(RBParametrized &&)=default
void write_discrete_parameter_values_to_file(const std::string &file_name, const bool write_binary_data)
Write out the discrete parameter values to file.
const RBParameters & get_parameters_max() const
Get an RBParameters object that specifies the maximum allowable value for each parameter.
void read_discrete_parameter_values_from_file(const std::string &file_name, const bool read_binary_data, std::map< std::string, std::vector< Real >> &discrete_parameter_values_in)
Read in the discrete parameter values from file, if we have any.
void read_parameter_data_from_files(const std::string &continuous_param_file_name, const std::string &discrete_param_file_name, const bool read_binary_data)
Read in the parameter ranges from files.
The libMesh namespace provides an interface to certain functionality in the library.
static Real get_closest_value(Real value, const std::vector< Real > &list_of_values)
static bool is_value_in_list(Real value, const std::vector< Real > &list_of_values, Real tol)
Helper function to check if the specified value is in the list of values (within a tolerance given by...
unsigned int get_n_discrete_params() const
Get the number of discrete parameters.
RBParameters parameters_min
Vectors that define the ranges (min and max) for the parameters.
const RBParameters & get_parameters_min() const
Get an RBParameters object that specifies the minimum allowable value for each parameter.
std::set< std::string > get_parameter_names() const
Get a set that stores the parameter names.
void write_parameter_ranges_to_file(const std::string &file_name, const bool write_binary)
Write out the parameter ranges to file.
RBParametrized()
Constructor.
const std::map< std::string, std::vector< Real > > & get_discrete_parameter_values() const
Get a const reference to the discrete parameter values.
const RBParameters & get_parameters() const
Get the current parameters.
void print_parameters() const
Print the current parameters.
This class is part of the rbOOmit framework.
Definition: rb_parameters.h:52
std::map< std::string, std::vector< Real > > _discrete_parameter_values
Map that defines the allowable values of any discrete parameters.
unsigned int get_n_continuous_params() const
Get the number of continuous parameters.
bool verbose_mode
Public boolean to toggle verbose mode.
This class implements reference counting.
bool set_parameters(const RBParameters &params)
Set the current parameters to params The parameters are checked for validity; an error is thrown if t...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
This class is part of the rbOOmit framework.
static const bool value
Definition: xdr_io.C:54
bool check_if_valid_params(const RBParameters &params) const
Helper function to check that params is valid:
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.
unsigned int get_n_params() const
Get the number of parameters.
bool is_discrete_parameter(const std::string &mu_name) const
Is parameter mu_name discrete?
void print_discrete_parameter_values() const
Print out all the discrete parameter values.
RBParameters parameters
Vector storing the current parameters.