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/auto_ptr.h"
30 #include "libmesh/parallel_object.h"
31 
32 // C++ includes
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 
59  LIBMESH_CAN_DEFAULT_TO_COMMWORLD);
60 
64  virtual ~RBEvaluation ();
65 
70  virtual void clear() libmesh_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) { basis_functions.resize(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<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<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<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<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
std::vector< NumericVector< Number > * > basis_functions
The libMesh vectors storing the finite element coefficients of the RB basis functions.
bool compute_RB_inner_product
Boolean flag to indicate whether we compute the RB_inner_product_matrix.
Encapsulates the MPI_Comm object.
Definition: parallel.h:657
bool evaluate_RB_error_bound
Boolean to indicate whether we evaluate a posteriori error bounds when rb_solve is called...
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.
std::vector< Number > Fq_representor_innerprods
Vectors storing the residual representor inner products to be used in computing the residuals online...
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.
DenseVector< Number > RB_solution
The RB solution vector.
std::vector< std::vector< NumericVector< Number > * > > Aq_representor
Vector storing the residual representors associated with the left-hand side.
ImplicitSystem & sys
DenseMatrix< Number > RB_inner_product_matrix
The inner product matrix.
virtual void set_n_basis_functions(unsigned int n_bfs)
Set the number of basis functions.
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.
std::vector< std::vector< Number > > output_dual_innerprods
The vector storing the dual norm inner product terms for each output.
virtual Real get_error_bound_normalization()
The libMesh namespace provides an interface to certain functionality in the library.
std::vector< RBParameters > greedy_param_list
The list of parameters selected by the Greedy algorithm in generating the Reduced Basis associated wi...
This class stores the set of RBTheta functor objects that define the "parameter-dependent expansion" ...
std::vector< DenseVector< Number > > RB_Fq_vector
Dense vector for the RHS.
virtual Real get_stability_lower_bound()
Get a lower bound for the stability constant (e.g.
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...
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.
This is the base class for classes which contain information related to any physical process that mig...
Definition: system.h:76
NumericVector< Number > & get_basis_function(unsigned int i)
Get a reference to the i^th basis function.
void read_in_vectors(System &sys, std::vector< 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...
std::vector< Real > RB_output_error_bounds
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.
virtual ~RBEvaluation()
Destructor.
Definition: rb_evaluation.C:55
This class is part of the rbOOmit framework.
Definition: rb_parameters.h:42
This class forms the base class for all other classes that are expected to be implemented in parallel...
virtual Real residual_scaling_denom(Real alpha_LB)
Specifies the residual scaling on the denominator to be used in the a posteriori error bound...
void set_rb_theta_expansion(RBThetaExpansion &rb_theta_expansion_in)
Set the RBThetaExpansion object.
Definition: rb_evaluation.C:84
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...
virtual Real rb_solve(unsigned int N)
Perform online solve with the N RB basis functions, for the set of parameters in current_params, where 0 <= N <= RB_size.
RBEvaluation(const Parallel::Communicator &comm LIBMESH_CAN_DEFAULT_TO_COMMWORLD)
Constructor.
Definition: rb_evaluation.C:45
This class is part of the rbOOmit framework.
Definition: rb_evaluation.h:50
virtual void clear_riesz_representors()
Clear all the Riesz representors that are used to compute the RB residual (and hence error bound)...
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...
std::vector< DenseMatrix< Number > > RB_Aq_vector
Dense matrices for the RB computations.
virtual void clear() libmesh_override
Clear this RBEvaluation object.
Definition: rb_evaluation.C:60
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real eval_output_dual_norm(unsigned int n, const RBParameters &mu)
Evaluate the dual norm of output n for the current parameters.
void assert_file_exists(const std::string &file_name)
Helper function that checks if file_name exists.
This class is part of the rbOOmit framework.
const Parallel::Communicator & comm() const
bool is_rb_theta_expansion_initialized() const
Definition: rb_evaluation.C:97
std::vector< Number > RB_outputs
The vectors storing the RB output values and corresponding error bounds.
virtual unsigned int get_n_basis_functions() const
Get the current number of basis functions.
RBThetaExpansion * rb_theta_expansion
A pointer to to the object that stores the theta expansion.
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the rb_theta_expansion.
Definition: rb_evaluation.C:89
void read_in_vectors_from_multiple_files(System &sys, std::vector< std::vector< 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.
std::vector< std::vector< std::vector< Number > > > Aq_Aq_representor_innerprods
std::vector< std::vector< DenseVector< Number > > > RB_output_vectors
The vectors storing the RB output vectors.