rb_evaluation.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_EVALUATION_H
21 #define LIBMESH_RB_EVALUATION_H
22 
23 // rbOOmit includes
25 
26 // libMesh includes
27 #include "libmesh/dense_matrix.h"
28 #include "libmesh/dense_vector.h"
29 #include "libmesh/auto_ptr.h" // deprecated
31 
32 // C++ includes
33 #include <memory>
34 
35 namespace libMesh
36 {
37 
38 class System;
39 template <typename T> class NumericVector;
40 class RBThetaExpansion;
41 
52  public ParallelObject
53 {
54 public:
55 
60 
64  virtual ~RBEvaluation ();
65 
70  virtual void clear() override;
71 
75  void set_rb_theta_expansion(RBThetaExpansion & rb_theta_expansion_in);
76 
81 
86 
93  virtual void resize_data_structures(const unsigned int Nmax,
94  bool resize_error_bound_data=true);
95 
99  NumericVector<Number> & get_basis_function(unsigned int i);
100 
110  virtual Real rb_solve(unsigned int N);
111 
117 
122  virtual Real compute_residual_dual_norm(const unsigned int N);
123 
129  virtual Real residual_scaling_denom(Real alpha_LB);
130 
135  Real eval_output_dual_norm(unsigned int n, const RBParameters & mu);
136 
142 
146  virtual unsigned int get_n_basis_functions() const
147  { return cast_int<unsigned int>(basis_functions.size()); }
148 
153  virtual void set_n_basis_functions(unsigned int n_bfs);
154 
160  virtual void clear_riesz_representors();
161 
168  virtual void legacy_write_offline_data_to_files(const std::string & directory_name = "offline_data",
169  const bool write_binary_data=true);
170 
177  virtual void legacy_read_offline_data_from_files(const std::string & directory_name = "offline_data",
178  bool read_error_bound_data=true,
179  const bool read_binary_data=true);
180 
188  virtual void write_out_basis_functions(System & sys,
189  const std::string & directory_name = "offline_data",
190  const bool write_binary_basis_functions = true);
191 
196  virtual void write_out_vectors(System & sys,
197  std::vector<NumericVector<Number>*> & vectors,
198  const std::string & directory_name = "offline_data",
199  const std::string & data_name = "bf",
200  const bool write_binary_basis_functions = true);
201 
209  virtual void read_in_basis_functions(System & sys,
210  const std::string & directory_name = "offline_data",
211  const bool read_binary_basis_functions = true);
212 
218  void read_in_vectors(System & sys,
219  std::vector<std::unique_ptr<NumericVector<Number>>> & vectors,
220  const std::string & directory_name,
221  const std::string & data_name,
222  const bool read_binary_vectors);
223 
231  std::vector<std::vector<std::unique_ptr<NumericVector<Number>>> *> multiple_vectors,
232  const std::vector<std::string> & multiple_directory_names,
233  const std::vector<std::string> & multiple_data_names,
234  const bool read_binary_vectors);
235 
236  //----------- PUBLIC DATA MEMBERS -----------//
237 
242  std::vector<std::unique_ptr<NumericVector<Number>>> basis_functions;
243 
248  std::vector<RBParameters> greedy_param_list;
249 
257 
261  std::vector<DenseMatrix<Number>> RB_Aq_vector;
262 
266  std::vector<DenseVector<Number>> RB_Fq_vector;
267 
272 
276  std::vector<std::vector<DenseVector<Number>>> RB_output_vectors;
277 
282  std::vector<Number > RB_outputs;
283  std::vector<Real > RB_output_error_bounds;
284 
291  std::vector<Number> Fq_representor_innerprods;
292 
300  std::vector<std::vector<std::vector<Number>>> Fq_Aq_representor_innerprods;
301  std::vector<std::vector<std::vector<Number>>> Aq_Aq_representor_innerprods;
302 
309  std::vector<std::vector<Number >> output_dual_innerprods;
310 
317  std::vector<std::vector<std::unique_ptr<NumericVector<Number>>>> Aq_representor;
318 
324 
329 
330 protected:
331 
335  void assert_file_exists(const std::string & file_name);
336 
337 private:
338 
346 
347 };
348 
349 }
350 
351 #endif // LIBMESH_RB_EVALUATION_H
virtual Real residual_scaling_denom(Real alpha_LB)
std::vector< std::vector< std::unique_ptr< NumericVector< Number > > > > Aq_representor
std::vector< Number > Fq_representor_innerprods
virtual void read_in_basis_functions(System &sys, const std::string &directory_name="offline_data", const bool read_binary_basis_functions=true)
DenseVector< Number > RB_solution
RBThetaExpansion & get_rb_theta_expansion()
DenseMatrix< Number > RB_inner_product_matrix
std::vector< std::unique_ptr< NumericVector< Number > > > basis_functions
virtual void set_n_basis_functions(unsigned int n_bfs)
const Parallel::Communicator & comm() const
std::vector< std::vector< Number > > output_dual_innerprods
NumericVector< Number > & get_basis_function(unsigned int i)
void read_in_vectors_from_multiple_files(System &sys, std::vector< std::vector< std::unique_ptr< NumericVector< Number >>> *> multiple_vectors, const std::vector< std::string > &multiple_directory_names, const std::vector< std::string > &multiple_data_names, const bool read_binary_vectors)
std::vector< RBParameters > greedy_param_list
void read_in_vectors(System &sys, std::vector< std::unique_ptr< NumericVector< Number >>> &vectors, const std::string &directory_name, const std::string &data_name, const bool read_binary_vectors)
RBEvaluation(const Parallel::Communicator &comm)
std::vector< DenseVector< Number > > RB_Fq_vector
virtual Real rb_solve(unsigned int N)
virtual void resize_data_structures(const unsigned int Nmax, bool resize_error_bound_data=true)
virtual void legacy_read_offline_data_from_files(const std::string &directory_name="offline_data", bool read_error_bound_data=true, const bool read_binary_data=true)
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:92
virtual Real get_error_bound_normalization()
std::vector< Real > RB_output_error_bounds
virtual void write_out_basis_functions(System &sys, const std::string &directory_name="offline_data", const bool write_binary_basis_functions=true)
virtual Real get_stability_lower_bound()
An object whose state is distributed along a set of processors.
void set_rb_theta_expansion(RBThetaExpansion &rb_theta_expansion_in)
std::vector< std::vector< std::vector< Number > > > Fq_Aq_representor_innerprods
virtual void legacy_write_offline_data_to_files(const std::string &directory_name="offline_data", const bool write_binary_data=true)
std::vector< DenseMatrix< Number > > RB_Aq_vector
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void clear() override
virtual void write_out_vectors(System &sys, std::vector< NumericVector< Number > *> &vectors, const std::string &directory_name="offline_data", const std::string &data_name="bf", const bool write_binary_basis_functions=true)
virtual Real compute_residual_dual_norm(const unsigned int N)
Real eval_output_dual_norm(unsigned int n, const RBParameters &mu)
void assert_file_exists(const std::string &file_name)
virtual unsigned int get_n_basis_functions() const
std::vector< Number > RB_outputs
virtual void clear_riesz_representors()
RBThetaExpansion * rb_theta_expansion
std::vector< std::vector< std::vector< Number > > > Aq_Aq_representor_innerprods
bool is_rb_theta_expansion_initialized() const
std::vector< std::vector< DenseVector< Number > > > RB_output_vectors