$extrastylesheet
transient_rb_construction.h
Go to the documentation of this file.
00001 // rbOOmit: An implementation of the Certified Reduced Basis method.
00002 // Copyright (C) 2009, 2010 David J. Knezevic
00003 
00004 // This file is part of rbOOmit.
00005 
00006 // rbOOmit is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License, or (at your option) any later version.
00010 
00011 // rbOOmit is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 #ifndef LIBMESH_TRANSIENT_RB_CONSTRUCTION_H
00021 #define LIBMESH_TRANSIENT_RB_CONSTRUCTION_H
00022 
00023 // rbOOmit includes
00024 #include "libmesh/rb_construction.h"
00025 #include "libmesh/transient_rb_evaluation.h"
00026 #include "libmesh/rb_temporal_discretization.h"
00027 
00028 // libMesh includes
00029 #include "libmesh/transient_system.h"
00030 
00031 // C++ includes
00032 
00033 namespace libMesh
00034 {
00035 
00048 // ------------------------------------------------------------
00049 // TransientRBConstruction class definition
00050 
00051 class TransientRBConstruction : public TransientSystem<RBConstruction>, public RBTemporalDiscretization
00052 {
00053 public:
00054 
00059   TransientRBConstruction (EquationSystems& es,
00060                            const std::string& name,
00061                            const unsigned int number);
00062 
00066   virtual ~TransientRBConstruction ();
00067 
00071   typedef TransientRBConstruction sys_type;
00072 
00076   typedef TransientSystem<RBConstruction> Parent;
00077 
00082   virtual void clear ();
00083 
00092   virtual void initialize_rb_construction(bool skip_matrix_assembly=false,
00093                                           bool skip_vector_assembly=false);
00094 
00098   virtual Real truth_solve(int write_interval);
00099 
00107   virtual Real train_reduced_basis(const std::string& directory_name = "offline_data",
00108                                    const bool resize_rb_eval_data=true);
00109 
00114   virtual void process_parameters_file (const std::string& parameters_filename);
00115 
00119   virtual void print_info();
00120 
00125   virtual bool greedy_termination_test(Real training_greedy_error, int count);
00126 
00131   virtual void assemble_all_affine_operators();
00132 
00136   virtual void assemble_misc_matrices();
00137 
00141   void assemble_L2_matrix(SparseMatrix<Number>* input_matrix, bool apply_dirichlet_bc=true);
00142 
00147   void assemble_mass_matrix(SparseMatrix<Number>* input_matrix);
00148 
00153   void add_scaled_mass_matrix(Number scalar,
00154                               SparseMatrix<Number>* input_matrix);
00155 
00160   void mass_matrix_scaled_matvec(Number scalar,
00161                                  NumericVector<Number>& dest,
00162                                  NumericVector<Number>& arg);
00163 
00167   void set_L2_assembly(ElemAssembly& L2_assembly_in);
00168 
00172   ElemAssembly& get_L2_assembly();
00173 
00177   void assemble_Mq_matrix(unsigned int q, SparseMatrix<Number>* input_matrix, bool apply_dirichlet_bc=true);
00178 
00182   SparseMatrix<Number>* get_M_q(unsigned int q);
00183 
00187   SparseMatrix<Number>* get_non_dirichlet_M_q(unsigned int q);
00188 
00192   virtual void get_all_matrices(std::map<std::string, SparseMatrix<Number>*>& all_matrices);
00193 
00197   virtual void truth_assembly();
00198 
00205   int get_max_truth_solves() const                   { return max_truth_solves; }
00206   void set_max_truth_solves(int max_truth_solves_in) { this->max_truth_solves = max_truth_solves_in; }
00207 
00211   Real get_POD_tol() const                { return POD_tol; }
00212   void set_POD_tol(const Real POD_tol_in) { this->POD_tol = POD_tol_in; }
00213 
00218   void set_delta_N(const unsigned int new_delta_N) { this->delta_N = new_delta_N; }
00219 
00224   virtual void load_rb_solution();
00225 
00232   const NumericVector<Number>& get_error_temporal_data();
00233 
00239   void update_RB_initial_condition_all_N();
00240 
00245   virtual void write_riesz_representors_to_files(const std::string& riesz_representors_dir,
00246                                                  const bool write_binary_residual_representors);
00247 
00252   virtual void read_riesz_representors_from_files(const std::string& riesz_representors_dir,
00253                                                   const bool write_binary_residual_representors);
00254 
00255 
00256   //----------- PUBLIC DATA MEMBERS -----------//
00257 
00261   UniquePtr< SparseMatrix<Number> > L2_matrix;
00262 
00267   UniquePtr< SparseMatrix<Number> > non_dirichlet_L2_matrix;
00268 
00272   std::vector< SparseMatrix<Number>* > M_q_vector;
00273 
00279   std::vector< SparseMatrix<Number>* > non_dirichlet_M_q_vector;
00280 
00285   std::vector< std::vector<Number> > truth_outputs_all_k;
00286 
00291   bool nonzero_initialization;
00292 
00298   bool compute_truth_projection_error;
00299 
00304   std::string init_filename;
00305 
00306 protected:
00307 
00312   virtual void allocate_data_structures();
00313 
00318   virtual void assemble_affine_expansion(bool skip_matrix_assembly,
00319                                          bool skip_vector_assembly);
00320 
00326   virtual void initialize_truth();
00327 
00332   virtual void assemble_matrix_for_output_dual_solves();
00333 
00338   void add_IC_to_RB_space();
00339 
00345   virtual void enrich_RB_space();
00346 
00350   virtual void update_system();
00351 
00355   virtual void update_RB_system_matrices();
00356 
00361   virtual void update_residual_terms(bool compute_inner_products);
00362 
00368   Number set_error_temporal_data();
00369 
00370   //----------- PROTECTED DATA MEMBERS -----------//
00371 
00377   Real POD_tol;
00378 
00385   int max_truth_solves;
00386 
00390   ElemAssembly* L2_assembly;
00391 
00396   DenseVector<Number> RB_ic_proj_rhs_all_N;
00397 
00398 private:
00399 
00400   //----------- PRIVATE DATA MEMBERS -----------//
00401 
00405   std::vector< NumericVector<Number>* > temporal_data;
00406 
00407 };
00408 
00409 } // namespace libMesh
00410 
00411 #endif // LIBMESH_TRANSIENT_RB_CONSTRUCTION_H