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_RB_CONSTRUCTION_H 00021 #define LIBMESH_RB_CONSTRUCTION_H 00022 00023 // rbOOmit includes 00024 #include "libmesh/rb_construction_base.h" 00025 #include "libmesh/rb_evaluation.h" 00026 00027 // libMesh includes 00028 #include "libmesh/linear_implicit_system.h" 00029 #include "libmesh/dense_vector.h" 00030 #include "libmesh/dense_matrix.h" 00031 #include "libmesh/fem_context.h" 00032 #include "libmesh/elem_assembly.h" 00033 #include "libmesh/dirichlet_boundaries.h" 00034 00035 // C++ includes 00036 00037 namespace libMesh 00038 { 00039 00040 class RBThetaExpansion; 00041 class RBAssemblyExpansion; 00042 00054 // ------------------------------------------------------------ 00055 // RBConstruction class definition 00056 00057 class RBConstruction : public RBConstructionBase<LinearImplicitSystem> 00058 { 00059 public: 00060 00065 RBConstruction (EquationSystems& es, 00066 const std::string& name, 00067 const unsigned int number); 00068 00072 virtual ~RBConstruction (); 00073 00077 typedef RBConstruction sys_type; 00078 00082 void set_rb_evaluation(RBEvaluation& rb_eval_in); 00083 00087 RBEvaluation& get_rb_evaluation(); 00088 00092 bool is_rb_eval_initialized() const; 00093 00098 RBThetaExpansion& get_rb_theta_expansion(); 00099 00103 void set_rb_assembly_expansion(RBAssemblyExpansion& rb_assembly_expansion_in); 00104 00108 RBAssemblyExpansion& get_rb_assembly_expansion(); 00109 00113 sys_type & system () { return *this; } 00114 00118 typedef RBConstructionBase<LinearImplicitSystem> Parent; 00119 00124 virtual void clear (); 00125 00129 virtual std::string system_type () const; 00130 00137 virtual Real truth_solve(int plot_solution); 00138 00155 virtual Real train_reduced_basis(const std::string& directory_name = "offline_data", 00156 const bool resize_rb_eval_data=true); 00157 00163 virtual Real compute_max_error_bound(); 00164 00169 const RBParameters& get_greedy_parameter(unsigned int i); 00170 00174 void set_training_tolerance(Real new_training_tolerance) 00175 {this->training_tolerance = new_training_tolerance; } 00176 Real get_training_tolerance() { return training_tolerance; } 00177 00182 unsigned int get_Nmax() const { return Nmax; } 00183 virtual void set_Nmax(unsigned int Nmax); 00184 00190 void set_quiet_mode(bool quiet_mode_in) 00191 { this->quiet_mode = quiet_mode_in; } 00192 00196 bool is_quiet() const 00197 { return this->quiet_mode; } 00198 00203 virtual void load_basis_function(unsigned int i); 00204 00209 virtual void load_rb_solution(); 00210 00217 SparseMatrix<Number>* get_inner_product_matrix(); 00218 00227 SparseMatrix<Number>* get_non_dirichlet_inner_product_matrix(); 00228 00232 SparseMatrix<Number>* get_Aq(unsigned int q); 00233 00237 SparseMatrix<Number>* get_non_dirichlet_Aq(unsigned int q); 00238 00244 virtual void initialize_rb_construction(); 00245 00249 NumericVector<Number>* get_Fq(unsigned int q); 00250 00254 NumericVector<Number>* get_non_dirichlet_Fq(unsigned int q); 00255 00259 NumericVector<Number>* get_output_vector(unsigned int n, unsigned int q_l); 00260 00264 NumericVector<Number>* get_non_dirichlet_output_vector(unsigned int n, unsigned int q_l); 00265 00269 void assemble_inner_product_matrix(SparseMatrix<Number>* input_matrix, bool apply_dof_constraints=true); 00270 00274 void assemble_constraint_matrix(SparseMatrix<Number>* input_matrix); 00275 00279 void assemble_and_add_constraint_matrix(SparseMatrix<Number>* input_matrix); 00280 00284 void assemble_Aq_matrix(unsigned int q, SparseMatrix<Number>* input_matrix, bool apply_dof_constraints=true); 00285 00289 void assemble_Fq_vector(unsigned int q, NumericVector<Number>* input_vector, bool apply_dof_constraints=true); 00290 00295 void add_scaled_Aq(Number scalar, unsigned int q_a, 00296 SparseMatrix<Number>* input_matrix, 00297 bool symmetrize); 00298 00304 virtual void write_riesz_representors_to_files(const std::string& riesz_representors_dir, 00305 const bool write_binary_residual_representors); 00306 00313 virtual void read_riesz_representors_from_files(const std::string& riesz_representors_dir, 00314 const bool write_binary_residual_representors); 00315 00316 00324 virtual void recompute_all_residual_terms(const bool compute_inner_products=true); 00325 00330 virtual void process_parameters_file(const std::string& parameters_filename); 00331 00335 virtual void print_info(); 00336 00344 unsigned int get_delta_N() const { return delta_N; } 00345 00349 void set_inner_product_assembly(ElemAssembly& inner_product_assembly_in); 00350 00354 ElemAssembly& get_inner_product_assembly(); 00355 00359 void set_constraint_assembly(ElemAssembly& constraint_assembly_in); 00360 00364 ElemAssembly& get_constraint_assembly(); 00365 00370 void zero_constrained_dofs_on_vector(NumericVector<Number>& vector); 00371 00376 static AutoPtr<DirichletBoundary> build_zero_dirichlet_boundary_object(); 00377 00378 //----------- PUBLIC DATA MEMBERS -----------// 00379 00387 std::vector<Real> training_error_bounds; 00388 00392 AutoPtr< SparseMatrix<Number> > inner_product_matrix; 00393 00398 AutoPtr< SparseMatrix<Number> > non_dirichlet_inner_product_matrix; 00399 00404 AutoPtr< SparseMatrix<Number> > constraint_matrix; 00405 00410 std::vector< Number > truth_outputs; 00411 00416 std::vector< std::vector< Number > > output_dual_innerprods; 00417 00424 std::vector< NumericVector<Number>* > Fq_representor; 00425 00433 std::vector<Number> Fq_representor_innerprods; 00434 00439 bool constrained_problem; 00440 00446 bool single_matrix_mode; 00447 00452 bool reuse_preconditioner; 00453 00459 bool use_relative_bound_in_greedy; 00460 00467 bool exit_on_repeated_greedy_parameters; 00468 00474 bool write_data_during_training; 00475 00481 bool impose_internal_dirichlet_BCs; 00482 00488 bool impose_internal_fluxes; 00489 00496 bool compute_RB_inner_product; 00497 00503 bool store_non_dirichlet_operators; 00504 00511 bool enforce_constraints_exactly; 00512 00518 bool use_empty_rb_solve_in_greedy; 00519 00520 protected: 00521 00526 virtual void allocate_data_structures(); 00527 00534 virtual void assemble_affine_expansion(); 00535 00540 virtual void truth_assembly(); 00541 00546 virtual AutoPtr<FEMContext> build_context(); 00547 00553 virtual void assemble_matrix_for_output_dual_solves(); 00554 00559 virtual bool greedy_termination_test(Real training_greedy_error, int count); 00560 00565 void update_greedy_param_list(); 00566 00574 void add_scaled_matrix_and_vector(Number scalar, 00575 ElemAssembly* elem_assembly, 00576 SparseMatrix<Number>* input_matrix, 00577 NumericVector<Number>* input_vector, 00578 bool symmetrize=false, 00579 bool apply_dof_constraints=true); 00580 00586 virtual void set_context_solution_vec(NumericVector<Number>& vec); 00587 00593 void assemble_scaled_matvec(Number scalar, 00594 ElemAssembly* elem_assembly, 00595 NumericVector<Number>& dest, 00596 NumericVector<Number>& arg); 00597 00604 virtual void assemble_misc_matrices(); 00605 00610 virtual void assemble_all_affine_operators(); 00611 00615 virtual void assemble_all_affine_vectors(); 00616 00620 virtual void assemble_all_output_vectors(); 00621 00625 virtual void compute_output_dual_innerprods(); 00626 00639 virtual void compute_Fq_representor_innerprods(bool compute_inner_products=true); 00640 00645 virtual void enrich_RB_space(); 00646 00651 virtual void update_system(); 00652 00657 virtual Real get_RB_error_bound(); 00658 00662 virtual void update_RB_system_matrices(); 00663 00671 virtual void update_residual_terms(bool compute_inner_products=true); 00672 00679 virtual void init_context(FEMContext& ) {} 00680 00681 //----------- PROTECTED DATA MEMBERS -----------// 00682 00687 unsigned int Nmax; 00688 00693 unsigned int delta_N; 00694 00699 bool quiet_mode; 00700 00706 bool output_dual_innerprods_computed; 00707 00713 bool Fq_representor_innerprods_computed; 00714 00715 private: 00716 00717 //----------- PRIVATE DATA MEMBERS -----------// 00718 00724 RBEvaluation* rb_eval; 00725 00730 RBAssemblyExpansion* rb_assembly_expansion; 00731 00735 ElemAssembly* inner_product_assembly; 00736 00741 ElemAssembly* constraint_assembly; 00742 00746 std::vector< SparseMatrix<Number>* > Aq_vector; 00747 00752 std::vector< NumericVector<Number>* > Fq_vector; 00753 00758 std::vector< std::vector< NumericVector<Number>* > > outputs_vector; 00759 00765 std::vector< SparseMatrix<Number>* > non_dirichlet_Aq_vector; 00766 std::vector< NumericVector<Number>* > non_dirichlet_Fq_vector; 00767 std::vector< std::vector< NumericVector<Number>* > > non_dirichlet_outputs_vector; 00768 00772 Real training_tolerance; 00773 00774 }; 00775 00776 } // namespace libMesh 00777 00778 #endif // LIBMESH_RB_CONSTRUCTION_H
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:48 UTC
Hosted By: