libMesh
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
24 #include "libmesh/rb_parametrized.h"
25 
26 // libMesh includes
27 #include "libmesh/dense_matrix.h"
28 #include "libmesh/dense_vector.h"
29 #include "libmesh/parallel_object.h"
30 
31 // C++ includes
32 #include <memory>
33 
34 namespace libMesh
35 {
36 
37 class System;
38 template <typename T> class NumericVector;
39 class RBThetaExpansion;
40 
51  public ParallelObject
52 {
53 public:
54 
58  RBEvaluation (const Parallel::Communicator & comm);
59 
63  virtual ~RBEvaluation ();
64 
69  virtual void clear() override;
70 
74  void set_rb_theta_expansion(RBThetaExpansion & rb_theta_expansion_in);
75 
80 
85 
92  virtual void resize_data_structures(const unsigned int Nmax,
93  bool resize_error_bound_data=true);
94 
98  NumericVector<Number> & get_basis_function(unsigned int i);
99 
109  virtual Real rb_solve(unsigned int N);
110 
116 
121  virtual Real compute_residual_dual_norm(const unsigned int N);
122 
128  virtual Real residual_scaling_denom(Real alpha_LB);
129 
134  Real eval_output_dual_norm(unsigned int n, const RBParameters & mu);
135 
141 
145  virtual unsigned int get_n_basis_functions() const
146  { return cast_int<unsigned int>(basis_functions.size()); }
147 
152  virtual void set_n_basis_functions(unsigned int n_bfs);
153 
159  virtual void clear_riesz_representors();
160 
167  virtual void legacy_write_offline_data_to_files(const std::string & directory_name = "offline_data",
168  const bool write_binary_data=true);
169 
176  virtual void legacy_read_offline_data_from_files(const std::string & directory_name = "offline_data",
177  bool read_error_bound_data=true,
178  const bool read_binary_data=true);
179 
187  virtual void write_out_basis_functions(System & sys,
188  const std::string & directory_name = "offline_data",
189  const bool write_binary_basis_functions = true);
190 
195  virtual void write_out_vectors(System & sys,
196  std::vector<NumericVector<Number>*> & vectors,
197  const std::string & directory_name = "offline_data",
198  const std::string & data_name = "bf",
199  const bool write_binary_basis_functions = true);
200 
208  virtual void read_in_basis_functions(System & sys,
209  const std::string & directory_name = "offline_data",
210  const bool read_binary_basis_functions = true);
211 
217  void read_in_vectors(System & sys,
218  std::vector<std::unique_ptr<NumericVector<Number>>> & vectors,
219  const std::string & directory_name,
220  const std::string & data_name,
221  const bool read_binary_vectors);
222 
230  std::vector<std::vector<std::unique_ptr<NumericVector<Number>>> *> multiple_vectors,
231  const std::vector<std::string> & multiple_directory_names,
232  const std::vector<std::string> & multiple_data_names,
233  const bool read_binary_vectors);
234 
235  //----------- PUBLIC DATA MEMBERS -----------//
236 
241  std::vector<std::unique_ptr<NumericVector<Number>>> basis_functions;
242 
247  std::vector<RBParameters> greedy_param_list;
248 
256 
260  std::vector<DenseMatrix<Number>> RB_Aq_vector;
261 
265  std::vector<DenseVector<Number>> RB_Fq_vector;
266 
271 
275  std::vector<std::vector<DenseVector<Number>>> RB_output_vectors;
276 
281  std::vector<Number > RB_outputs;
282  std::vector<Real > RB_output_error_bounds;
283 
290  std::vector<Number> Fq_representor_innerprods;
291 
299  std::vector<std::vector<std::vector<Number>>> Fq_Aq_representor_innerprods;
300  std::vector<std::vector<std::vector<Number>>> Aq_Aq_representor_innerprods;
301 
308  std::vector<std::vector<Number >> output_dual_innerprods;
309 
316  std::vector<std::vector<std::unique_ptr<NumericVector<Number>>>> Aq_representor;
317 
323 
328 
329 protected:
330 
334  void assert_file_exists(const std::string & file_name);
335 
336 private:
337 
345 
346 };
347 
348 }
349 
350 #endif // LIBMESH_RB_EVALUATION_H
libMesh::System
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:100
libMesh::RBEvaluation::get_n_basis_functions
virtual unsigned int get_n_basis_functions() const
Get the current number of basis functions.
Definition: rb_evaluation.h:145
libMesh::RBEvaluation::RB_Aq_vector
std::vector< DenseMatrix< Number > > RB_Aq_vector
Dense matrices for the RB computations.
Definition: rb_evaluation.h:260
libMesh::RBEvaluation::set_n_basis_functions
virtual void set_n_basis_functions(unsigned int n_bfs)
Set the number of basis functions.
Definition: rb_evaluation.C:78
libMesh::RBEvaluation::~RBEvaluation
virtual ~RBEvaluation()
Destructor.
Definition: rb_evaluation.C:57
libMesh::RBEvaluation::write_out_basis_functions
virtual void write_out_basis_functions(System &sys, const std::string &directory_name="offline_data", const bool write_binary_basis_functions=true)
Write out all the basis functions to file.
Definition: rb_evaluation.C:880
libMesh::RBEvaluation::is_rb_theta_expansion_initialized
bool is_rb_theta_expansion_initialized() const
Definition: rb_evaluation.C:96
libMesh::RBEvaluation::rb_solve
virtual Real rb_solve(unsigned int N)
Perform online solve with the N RB basis functions, for the set of parameters in current_params,...
Definition: rb_evaluation.C:209
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::RBEvaluation::output_dual_innerprods
std::vector< std::vector< Number > > output_dual_innerprods
The vector storing the dual norm inner product terms for each output.
Definition: rb_evaluation.h:308
libMesh::ParallelObject::comm
const Parallel::Communicator & comm() const
Definition: parallel_object.h:94
libMesh::DenseMatrix< Number >
libMesh::RBEvaluation::read_in_basis_functions
virtual void read_in_basis_functions(System &sys, const std::string &directory_name="offline_data", const bool read_binary_basis_functions=true)
Read in all the basis functions from file.
Definition: rb_evaluation.C:958
libMesh::RBParameters
This class is part of the rbOOmit framework.
Definition: rb_parameters.h:42
libMesh::RBEvaluation::clear
virtual void clear() override
Clear this RBEvaluation object.
Definition: rb_evaluation.C:62
libMesh::RBEvaluation::set_rb_theta_expansion
void set_rb_theta_expansion(RBThetaExpansion &rb_theta_expansion_in)
Set the RBThetaExpansion object.
Definition: rb_evaluation.C:83
libMesh::RBEvaluation::assert_file_exists
void assert_file_exists(const std::string &file_name)
Helper function that checks if file_name exists.
Definition: rb_evaluation.C:874
libMesh::RBEvaluation::RBEvaluation
RBEvaluation(const Parallel::Communicator &comm)
Constructor.
Definition: rb_evaluation.C:47
libMesh::RBEvaluation::RB_outputs
std::vector< Number > RB_outputs
The vectors storing the RB output values and corresponding error bounds.
Definition: rb_evaluation.h:281
libMesh::NumericVector< Number >
libMesh::RBEvaluation::residual_scaling_denom
virtual Real residual_scaling_denom(Real alpha_LB)
Specifies the residual scaling on the denominator to be used in the a posteriori error bound.
Definition: rb_evaluation.C:385
libMesh::RBEvaluation::evaluate_RB_error_bound
bool evaluate_RB_error_bound
Boolean to indicate whether we evaluate a posteriori error bounds when rb_solve is called.
Definition: rb_evaluation.h:322
libMesh::RBEvaluation::legacy_read_offline_data_from_files
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)
Read in the saved Offline reduced basis data to initialize the system for Online solves.
Definition: rb_evaluation.C:641
libMesh::RBEvaluation::RB_solution
DenseVector< Number > RB_solution
The RB solution vector.
Definition: rb_evaluation.h:270
libMesh::RBEvaluation::Fq_representor_innerprods
std::vector< Number > Fq_representor_innerprods
Vectors storing the residual representor inner products to be used in computing the residuals online.
Definition: rb_evaluation.h:290
libMesh::RBEvaluation::read_in_vectors
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)
Same as read_in_basis_functions, except in this case we pass in the vectors to be written.
Definition: rb_evaluation.C:971
libMesh::RBEvaluation::Fq_Aq_representor_innerprods
std::vector< std::vector< std::vector< Number > > > Fq_Aq_representor_innerprods
Vectors storing the residual representor inner products to be used in computing the residuals online.
Definition: rb_evaluation.h:299
libMesh::RBEvaluation::clear_riesz_representors
virtual void clear_riesz_representors()
Clear all the Riesz representors that are used to compute the RB residual (and hence error bound).
Definition: rb_evaluation.C:411
libMesh::RBEvaluation::rb_theta_expansion
RBThetaExpansion * rb_theta_expansion
A pointer to to the object that stores the theta expansion.
Definition: rb_evaluation.h:344
libMesh::RBEvaluation::read_in_vectors_from_multiple_files
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)
Performs read_in_vectors for a list of directory names and data names.
Definition: rb_evaluation.C:993
libMesh::RBEvaluation::get_stability_lower_bound
virtual Real get_stability_lower_bound()
Get a lower bound for the stability constant (e.g.
Definition: rb_evaluation.C:377
libMesh::RBEvaluation::compute_residual_dual_norm
virtual Real compute_residual_dual_norm(const unsigned int N)
Compute the dual norm of the residual for the solution saved in RB_solution_vector.
Definition: rb_evaluation.C:302
libMesh::RBEvaluation::write_out_vectors
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)
Same as write_out_basis_functions, except in this case we pass in the vectors to be written.
Definition: rb_evaluation.C:899
libMesh::RBEvaluation::Aq_Aq_representor_innerprods
std::vector< std::vector< std::vector< Number > > > Aq_Aq_representor_innerprods
Definition: rb_evaluation.h:300
libMesh::RBEvaluation::legacy_write_offline_data_to_files
virtual void legacy_write_offline_data_to_files(const std::string &directory_name="offline_data", const bool write_binary_data=true)
Write out all the data to text files in order to segregate the Offline stage from the Online stage.
Definition: rb_evaluation.C:416
libMesh::RBEvaluation::RB_output_vectors
std::vector< std::vector< DenseVector< Number > > > RB_output_vectors
The vectors storing the RB output vectors.
Definition: rb_evaluation.h:275
libMesh::RBEvaluation::eval_output_dual_norm
Real eval_output_dual_norm(unsigned int n, const RBParameters &mu)
Evaluate the dual norm of output n for the current parameters.
Definition: rb_evaluation.C:392
libMesh::RBEvaluation::compute_RB_inner_product
bool compute_RB_inner_product
Boolean flag to indicate whether we compute the RB_inner_product_matrix.
Definition: rb_evaluation.h:327
libMesh::RBEvaluation::RB_inner_product_matrix
DenseMatrix< Number > RB_inner_product_matrix
The inner product matrix.
Definition: rb_evaluation.h:255
libMesh::RBEvaluation::get_error_bound_normalization
virtual Real get_error_bound_normalization()
Definition: rb_evaluation.C:291
libMesh::RBEvaluation
This class is part of the rbOOmit framework.
Definition: rb_evaluation.h:50
libMesh::RBEvaluation::Aq_representor
std::vector< std::vector< std::unique_ptr< NumericVector< Number > > > > Aq_representor
Vector storing the residual representors associated with the left-hand side.
Definition: rb_evaluation.h:316
libMesh::RBParametrized
This class is part of the rbOOmit framework.
Definition: rb_parametrized.h:44
libMesh::RBEvaluation::RB_output_error_bounds
std::vector< Real > RB_output_error_bounds
Definition: rb_evaluation.h:282
libMesh::RBEvaluation::resize_data_structures
virtual void resize_data_structures(const unsigned int Nmax, bool resize_error_bound_data=true)
Resize and clear the data vectors corresponding to the value of Nmax.
Definition: rb_evaluation.C:108
libMesh::RBEvaluation::get_rb_theta_expansion
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the rb_theta_expansion.
Definition: rb_evaluation.C:88
libMesh::RBEvaluation::basis_functions
std::vector< std::unique_ptr< NumericVector< Number > > > basis_functions
The libMesh vectors storing the finite element coefficients of the RB basis functions.
Definition: rb_evaluation.h:241
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::ParallelObject
An object whose state is distributed along a set of processors.
Definition: parallel_object.h:55
libMesh::RBEvaluation::RB_Fq_vector
std::vector< DenseVector< Number > > RB_Fq_vector
Dense vector for the RHS.
Definition: rb_evaluation.h:265
libMesh::RBThetaExpansion
This class stores the set of RBTheta functor objects that define the "parameter-dependent expansion" ...
Definition: rb_theta_expansion.h:44
libMesh::RBEvaluation::get_basis_function
NumericVector< Number > & get_basis_function(unsigned int i)
Get a reference to the i^th basis function.
Definition: rb_evaluation.C:202
libMesh::DenseVector< Number >
libMesh::RBEvaluation::greedy_param_list
std::vector< RBParameters > greedy_param_list
The list of parameters selected by the Greedy algorithm in generating the Reduced Basis associated wi...
Definition: rb_evaluation.h:247