libMesh
transient_rb_construction.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_TRANSIENT_RB_CONSTRUCTION_H
21 #define LIBMESH_TRANSIENT_RB_CONSTRUCTION_H
22 
23 // rbOOmit includes
24 #include "libmesh/rb_construction.h"
25 #include "libmesh/transient_rb_evaluation.h"
26 #include "libmesh/rb_temporal_discretization.h"
27 
28 // libMesh includes
29 #include "libmesh/transient_system.h"
30 
31 // C++ includes
32 
33 namespace libMesh
34 {
35 
49 {
50 public:
51 
57  const std::string & name,
58  const unsigned int number);
59 
63  virtual ~TransientRBConstruction ();
64 
69 
74 
79  virtual void clear () override;
80 
89  virtual void initialize_rb_construction(bool skip_matrix_assembly=false,
90  bool skip_vector_assembly=false) override;
91 
95  virtual Real truth_solve(int write_interval) override;
96 
104  virtual Real train_reduced_basis(const bool resize_rb_eval_data=true) override;
105 
110  virtual void process_parameters_file (const std::string & parameters_filename) override;
111 
115  virtual void print_info() override;
116 
121  virtual bool greedy_termination_test(Real abs_greedy_error,
122  Real initial_greedy_error,
123  int count) override;
124 
129  virtual void assemble_all_affine_operators() override;
130 
134  virtual void assemble_misc_matrices() override;
135 
139  void assemble_L2_matrix(SparseMatrix<Number> * input_matrix,
140  bool apply_dirichlet_bc=true);
141 
146  void assemble_mass_matrix(SparseMatrix<Number> * input_matrix);
147 
152  void add_scaled_mass_matrix(Number scalar,
153  SparseMatrix<Number> * input_matrix);
154 
159  void mass_matrix_scaled_matvec(Number scalar,
160  NumericVector<Number> & dest,
161  NumericVector<Number> & arg);
162 
166  void set_L2_assembly(ElemAssembly & L2_assembly_in);
167 
172 
176  void assemble_Mq_matrix(unsigned int q,
177  SparseMatrix<Number> * input_matrix,
178  bool apply_dirichlet_bc=true);
179 
183  SparseMatrix<Number> * get_M_q(unsigned int q);
184 
189 
193  virtual void get_all_matrices(std::map<std::string, SparseMatrix<Number> *> & all_matrices) override;
194 
198  virtual void truth_assembly() override;
199 
208  int get_max_truth_solves() const { return max_truth_solves; }
209  void set_max_truth_solves(int max_truth_solves_in) { this->max_truth_solves = max_truth_solves_in; }
210 
214  Real get_POD_tol() const { return POD_tol; }
215  void set_POD_tol(const Real POD_tol_in) { this->POD_tol = POD_tol_in; }
216 
221  void set_delta_N(const unsigned int new_delta_N) { this->delta_N = new_delta_N; }
222 
227  virtual void load_rb_solution() override;
228 
236 
243 
248  virtual void write_riesz_representors_to_files(const std::string & riesz_representors_dir,
249  const bool write_binary_residual_representors) override;
250 
255  virtual void read_riesz_representors_from_files(const std::string & riesz_representors_dir,
256  const bool write_binary_residual_representors) override;
257 
258 
259  //----------- PUBLIC DATA MEMBERS -----------//
260 
264  std::unique_ptr<SparseMatrix<Number>> L2_matrix;
265 
270  std::unique_ptr<SparseMatrix<Number>> non_dirichlet_L2_matrix;
271 
275  std::vector<std::unique_ptr<SparseMatrix<Number>>> M_q_vector;
276 
282  std::vector<std::unique_ptr<SparseMatrix<Number>>> non_dirichlet_M_q_vector;
283 
288  std::vector<std::vector<Number>> truth_outputs_all_k;
289 
295 
302 
307  std::string init_filename;
308 
309 protected:
310 
315  virtual void allocate_data_structures() override;
316 
321  virtual void assemble_affine_expansion(bool skip_matrix_assembly,
322  bool skip_vector_assembly) override;
323 
329  virtual void initialize_truth();
330 
336 
341  void add_IC_to_RB_space();
342 
348  virtual void enrich_RB_space() override;
349 
353  virtual void update_system() override;
354 
358  virtual void update_RB_system_matrices() override;
359 
364  virtual void update_residual_terms(bool compute_inner_products) override;
365 
372 
373  //----------- PROTECTED DATA MEMBERS -----------//
374 
381 
389 
394 
400 
401 private:
402 
403  //----------- PRIVATE DATA MEMBERS -----------//
404 
408  std::vector<std::unique_ptr<NumericVector<Number>>> temporal_data;
409 };
410 
411 } // namespace libMesh
412 
413 #endif // LIBMESH_TRANSIENT_RB_CONSTRUCTION_H
libMesh::Number
Real Number
Definition: libmesh_common.h:195
libMesh::TransientRBConstruction::sys_type
TransientRBConstruction sys_type
The type of system.
Definition: transient_rb_construction.h:68
libMesh::TransientRBConstruction::truth_solve
virtual Real truth_solve(int write_interval) override
Perform a truth solve at the current parameter.
Definition: transient_rb_construction.C:520
libMesh::TransientSystem
Manages storage and variables for transient systems.
Definition: transient_system.h:57
libMesh::TransientRBConstruction::get_error_temporal_data
const NumericVector< Number > & get_error_temporal_data()
Get the column of temporal_data corresponding to the current time level.
Definition: transient_rb_construction.C:702
libMesh::TransientRBConstruction::greedy_termination_test
virtual bool greedy_termination_test(Real abs_greedy_error, Real initial_greedy_error, int count) override
Function that indicates when to terminate the Greedy basis training.
Definition: transient_rb_construction.C:619
libMesh::TransientRBConstruction::compute_truth_projection_error
bool compute_truth_projection_error
Boolean flag that indicates whether we will compute the projection error for the truth solution into ...
Definition: transient_rb_construction.h:301
libMesh::TransientRBConstruction::set_delta_N
void set_delta_N(const unsigned int new_delta_N)
Set delta_N, the number of basis functions we add to the RB space from each POD.
Definition: transient_rb_construction.h:221
libMesh::TransientRBConstruction::L2_assembly
ElemAssembly * L2_assembly
Function pointer for assembling the L2 matrix.
Definition: transient_rb_construction.h:393
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::TransientRBConstruction::M_q_vector
std::vector< std::unique_ptr< SparseMatrix< Number > > > M_q_vector
Vector storing the Q_m matrices from the mass operator.
Definition: transient_rb_construction.h:275
libMesh::TransientRBConstruction::get_all_matrices
virtual void get_all_matrices(std::map< std::string, SparseMatrix< Number > * > &all_matrices) override
Get a map that stores pointers to all of the matrices.
Definition: transient_rb_construction.C:321
libMesh::TransientRBConstruction::~TransientRBConstruction
virtual ~TransientRBConstruction()
Destructor.
Definition: transient_rb_construction.C:85
libMesh::TransientRBConstruction::print_info
virtual void print_info() override
Print out info that describes the current setup of this RBConstruction.
Definition: transient_rb_construction.C:149
libMesh::TransientRBConstruction::update_residual_terms
virtual void update_residual_terms(bool compute_inner_products) override
Compute the terms that are combined ‘online’ to determine the dual norm of the residual.
Definition: transient_rb_construction.C:1026
libMesh::TransientRBConstruction::clear
virtual void clear() override
Clear all the data structures associated with the system.
Definition: transient_rb_construction.C:91
libMesh::System::number
unsigned int number() const
Definition: system.h:2075
libMesh::TransientRBConstruction::get_non_dirichlet_M_q
SparseMatrix< Number > * get_non_dirichlet_M_q(unsigned int q)
Get a pointer to non_dirichlet_M_q.
Definition: transient_rb_construction.C:307
libMesh::SparseMatrix< Number >
libMesh::TransientRBConstruction::POD_tol
Real POD_tol
If positive, this tolerance determines the number of POD modes we add to the space on a call to enric...
Definition: transient_rb_construction.h:380
libMesh::TransientRBConstruction::write_riesz_representors_to_files
virtual void write_riesz_representors_to_files(const std::string &riesz_representors_dir, const bool write_binary_residual_representors) override
Write out all the Riesz representor data to files.
Definition: transient_rb_construction.C:1304
libMesh::NumericVector< Number >
libMesh::TransientRBConstruction::set_max_truth_solves
void set_max_truth_solves(int max_truth_solves_in)
Definition: transient_rb_construction.h:209
libMesh::TransientRBConstruction::set_L2_assembly
void set_L2_assembly(ElemAssembly &L2_assembly_in)
Set the L2 object.
Definition: transient_rb_construction.C:456
libMesh::TransientRBConstruction::add_scaled_mass_matrix
void add_scaled_mass_matrix(Number scalar, SparseMatrix< Number > *input_matrix)
Add the scaled mass matrix (assembled for the current parameter) to input_matrix.
Definition: transient_rb_construction.C:365
libMesh::TransientRBConstruction::initialize_truth
virtual void initialize_truth()
This function imposes a truth initial condition, defaults to zero initial condition if the flag nonze...
Definition: transient_rb_construction.C:711
libMesh::TransientRBConstruction::init_filename
std::string init_filename
The filename of the file containing the initial condition projected onto the truth mesh.
Definition: transient_rb_construction.h:307
libMesh::TransientRBConstruction::Parent
TransientSystem< RBConstruction > Parent
The type of the parent.
Definition: transient_rb_construction.h:73
libMesh::TransientRBConstruction::train_reduced_basis
virtual Real train_reduced_basis(const bool resize_rb_eval_data=true) override
Train the reduced basis.
Definition: transient_rb_construction.C:287
libMesh::TransientRBConstruction::get_matrix_for_output_dual_solves
virtual SparseMatrix< Number > & get_matrix_for_output_dual_solves() override
Override to return the L2 product matrix for output dual norm solves for transient state problems.
Definition: transient_rb_construction.C:939
libMesh::TransientRBConstruction::assemble_L2_matrix
void assemble_L2_matrix(SparseMatrix< Number > *input_matrix, bool apply_dirichlet_bc=true)
Assemble the L2 matrix.
Definition: transient_rb_construction.C:348
libMesh::TransientRBConstruction::process_parameters_file
virtual void process_parameters_file(const std::string &parameters_filename) override
Read in the parameters from file and set up the system accordingly.
Definition: transient_rb_construction.C:122
libMesh::TransientRBConstruction::update_system
virtual void update_system() override
Update the system after enriching the RB space.
Definition: transient_rb_construction.C:927
libMesh::TransientRBConstruction::non_dirichlet_M_q_vector
std::vector< std::unique_ptr< SparseMatrix< Number > > > non_dirichlet_M_q_vector
We sometimes also need a second set of M_q matrices that do not have the Dirichlet boundary condition...
Definition: transient_rb_construction.h:282
libMesh::TransientRBConstruction::read_riesz_representors_from_files
virtual void read_riesz_representors_from_files(const std::string &riesz_representors_dir, const bool write_binary_residual_representors) override
Write out all the Riesz representor data to files.
Definition: transient_rb_construction.C:1353
libMesh::TransientRBConstruction::add_IC_to_RB_space
void add_IC_to_RB_space()
Initialize RB space by adding the truth initial condition as the first RB basis function.
Definition: transient_rb_construction.C:729
libMesh::TransientRBConstruction::initialize_rb_construction
virtual void initialize_rb_construction(bool skip_matrix_assembly=false, bool skip_vector_assembly=false) override
Allocate all the data structures necessary for the construction stage of the RB method.
Definition: transient_rb_construction.C:105
libMesh::TransientRBConstruction::L2_matrix
std::unique_ptr< SparseMatrix< Number > > L2_matrix
The L2 matrix.
Definition: transient_rb_construction.h:264
libMesh::TransientRBConstruction::allocate_data_structures
virtual void allocate_data_structures() override
Helper function that actually allocates all the data structures required by this class.
Definition: transient_rb_construction.C:185
libMesh::EquationSystems
This is the EquationSystems class.
Definition: equation_systems.h:74
libMesh::TransientRBConstruction
This class is part of the rbOOmit framework.
Definition: transient_rb_construction.h:48
libMesh::TransientRBConstruction::truth_outputs_all_k
std::vector< std::vector< Number > > truth_outputs_all_k
The truth outputs for all time-levels from the most recent truth_solve.
Definition: transient_rb_construction.h:288
libMesh::RBConstruction::delta_N
unsigned int delta_N
The number of basis functions that we add at each greedy step.
Definition: rb_construction.h:768
libMesh::TransientRBConstruction::RB_ic_proj_rhs_all_N
DenseVector< Number > RB_ic_proj_rhs_all_N
The vector that stores the right-hand side for the initial condition projections.
Definition: transient_rb_construction.h:399
libMesh::ElemAssembly
ElemAssembly provides a per-element (interior and boundary) assembly functionality.
Definition: elem_assembly.h:38
libMesh::TransientRBConstruction::assemble_mass_matrix
void assemble_mass_matrix(SparseMatrix< Number > *input_matrix)
Assemble the mass matrix at the current parameter and store it in input_matrix.
Definition: transient_rb_construction.C:359
libMesh::System::name
const std::string & name() const
Definition: system.h:2067
libMesh::TransientRBConstruction::TransientRBConstruction
TransientRBConstruction(EquationSystems &es, const std::string &name, const unsigned int number)
Constructor.
Definition: transient_rb_construction.C:61
libMesh::TransientRBConstruction::update_RB_system_matrices
virtual void update_RB_system_matrices() override
Compute the reduced basis matrices for the current basis.
Definition: transient_rb_construction.C:968
libMesh::TransientRBConstruction::update_RB_initial_condition_all_N
void update_RB_initial_condition_all_N()
Compute the L2 projection of the initial condition onto the RB space for 1 <= N <= RB_size and store ...
Definition: transient_rb_construction.C:1161
libMesh::TransientRBConstruction::enrich_RB_space
virtual void enrich_RB_space() override
Add a new basis functions to the RB space.
Definition: transient_rb_construction.C:761
libMesh::RBTemporalDiscretization
Define a class that encapsulates the details of a "generalized Euler" temporal discretization to be u...
Definition: rb_temporal_discretization.h:40
libMesh::TransientRBConstruction::get_max_truth_solves
int get_max_truth_solves() const
Get/set max_truth_solves, the maximum number of RB truth solves we are willing to compute in the tran...
Definition: transient_rb_construction.h:208
libMesh::TransientRBConstruction::assemble_all_affine_operators
virtual void assemble_all_affine_operators() override
Assemble and store all the affine operators.
Definition: transient_rb_construction.C:489
libMesh::TransientRBConstruction::non_dirichlet_L2_matrix
std::unique_ptr< SparseMatrix< Number > > non_dirichlet_L2_matrix
The L2 matrix without Dirichlet conditions enforced.
Definition: transient_rb_construction.h:270
libMesh::TransientRBConstruction::max_truth_solves
int max_truth_solves
Maximum number of truth solves in the POD-Greedy.
Definition: transient_rb_construction.h:388
libMesh::TransientRBConstruction::assemble_misc_matrices
virtual void assemble_misc_matrices() override
Override to assemble the L2 matrix as well.
Definition: transient_rb_construction.C:506
libMesh::TransientRBConstruction::nonzero_initialization
bool nonzero_initialization
Boolean flag to indicate whether we are using a non-zero initialization.
Definition: transient_rb_construction.h:294
libMesh::TransientRBConstruction::assemble_Mq_matrix
void assemble_Mq_matrix(unsigned int q, SparseMatrix< Number > *input_matrix, bool apply_dirichlet_bc=true)
Assemble the q^th affine term of the mass matrix and store it in input_matrix.
Definition: transient_rb_construction.C:469
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::TransientRBConstruction::get_POD_tol
Real get_POD_tol() const
Get/set POD_tol.
Definition: transient_rb_construction.h:214
libMesh::TransientRBConstruction::set_POD_tol
void set_POD_tol(const Real POD_tol_in)
Definition: transient_rb_construction.h:215
libMesh::TransientRBConstruction::assemble_affine_expansion
virtual void assemble_affine_expansion(bool skip_matrix_assembly, bool skip_vector_assembly) override
Override assemble_affine_expansion to also initialize RB_ic_proj_rhs_all_N, if necessary.
Definition: transient_rb_construction.C:258
libMesh::TransientRBConstruction::set_error_temporal_data
Number set_error_temporal_data()
Set column k (i.e.
Definition: transient_rb_construction.C:633
libMesh::TransientRBConstruction::temporal_data
std::vector< std::unique_ptr< NumericVector< Number > > > temporal_data
Dense matrix to store the data that we use for the temporal POD.
Definition: transient_rb_construction.h:408
libMesh::TransientRBConstruction::load_rb_solution
virtual void load_rb_solution() override
Load the RB solution from the current time-level into the libMesh solution vector.
Definition: transient_rb_construction.C:944
libMesh::TransientRBConstruction::mass_matrix_scaled_matvec
void mass_matrix_scaled_matvec(Number scalar, NumericVector< Number > &dest, NumericVector< Number > &arg)
Perform a matrix-vector multiplication with the current mass matrix and store the result in dest.
Definition: transient_rb_construction.C:378
libMesh::TransientRBConstruction::get_M_q
SparseMatrix< Number > * get_M_q(unsigned int q)
Get a pointer to M_q.
Definition: transient_rb_construction.C:296
libMesh::TransientRBConstruction::truth_assembly
virtual void truth_assembly() override
Assemble the truth system in the transient linear case.
Definition: transient_rb_construction.C:403
libMesh::DenseVector< Number >
libMesh::TransientRBConstruction::get_L2_assembly
ElemAssembly & get_L2_assembly()
Definition: transient_rb_construction.C:461