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_RB_CONSTRUCTION_H
21 #define LIBMESH_RB_CONSTRUCTION_H
22 
23 // rbOOmit includes
25 #include "libmesh/rb_evaluation.h"
26 
27 // libMesh includes
29 #include "libmesh/dense_vector.h"
30 #include "libmesh/dense_matrix.h"
31 #include "libmesh/dg_fem_context.h"
32 #include "libmesh/elem_assembly.h"
34 
35 // C++ includes
36 
37 namespace libMesh
38 {
39 
40 class RBThetaExpansion;
41 class RBAssemblyExpansion;
42 
54 // ------------------------------------------------------------
55 // RBConstruction class definition
56 
57 class RBConstruction : public RBConstructionBase<LinearImplicitSystem>
58 {
59 public:
60 
66  const std::string& name,
67  const unsigned int number);
68 
72  virtual ~RBConstruction ();
73 
78 
82  void set_rb_evaluation(RBEvaluation& rb_eval_in);
83 
88 
92  bool is_rb_eval_initialized() const;
93 
99 
103  void set_rb_assembly_expansion(RBAssemblyExpansion& rb_assembly_expansion_in);
104 
109 
113  sys_type & system () { return *this; }
114 
119 
124  virtual void clear ();
125 
129  virtual std::string system_type () const;
130 
137  virtual Real truth_solve(int plot_solution);
138 
155  virtual Real train_reduced_basis(const std::string& directory_name = "offline_data",
156  const bool resize_rb_eval_data=true);
157 
163  virtual Real compute_max_error_bound();
164 
169  const RBParameters& get_greedy_parameter(unsigned int i);
170 
174  void set_training_tolerance(Real new_training_tolerance)
175  {this->training_tolerance = new_training_tolerance; }
177 
182  unsigned int get_Nmax() const { return Nmax; }
183  virtual void set_Nmax(unsigned int Nmax);
184 
190  void set_quiet_mode(bool quiet_mode_in)
191  { this->quiet_mode = quiet_mode_in; }
192 
196  bool is_quiet() const
197  { return this->quiet_mode; }
198 
203  virtual void load_basis_function(unsigned int i);
204 
209  virtual void load_rb_solution();
210 
218 
228 
232  SparseMatrix<Number>* get_Aq(unsigned int q);
233 
238 
244  virtual void initialize_rb_construction();
245 
249  NumericVector<Number>* get_Fq(unsigned int q);
250 
255 
259  NumericVector<Number>* get_output_vector(unsigned int n, unsigned int q_l);
260 
264  NumericVector<Number>* get_non_dirichlet_output_vector(unsigned int n, unsigned int q_l);
265 
269  void assemble_inner_product_matrix(SparseMatrix<Number>* input_matrix, bool apply_dof_constraints=true);
270 
275 
280 
284  void assemble_Aq_matrix(unsigned int q, SparseMatrix<Number>* input_matrix, bool apply_dof_constraints=true);
285 
289  void assemble_Fq_vector(unsigned int q, NumericVector<Number>* input_vector, bool apply_dof_constraints=true);
290 
295  void add_scaled_Aq(Number scalar, unsigned int q_a,
296  SparseMatrix<Number>* input_matrix,
297  bool symmetrize);
298 
304  virtual void write_riesz_representors_to_files(const std::string& riesz_representors_dir,
305  const bool write_binary_residual_representors);
306 
313  virtual void read_riesz_representors_from_files(const std::string& riesz_representors_dir,
314  const bool write_binary_residual_representors);
315 
316 
324  virtual void recompute_all_residual_terms(const bool compute_inner_products=true);
325 
330  virtual void process_parameters_file(const std::string& parameters_filename);
331 
337  unsigned int n_training_samples_in,
338  bool deterministic_training_in,
339  std::string deterministic_training_parameter_name_in,
340  unsigned int deterministic_training_parameter_repeats_in,
341  std::string alternative_solver_in,
342  bool reuse_preconditioner_in,
343  bool use_relative_bound_in_greedy_in,
344  bool write_data_during_training_in,
345  unsigned int training_parameters_random_seed_in,
346  bool quiet_mode_in,
347  unsigned int Nmax_in,
348  Real training_tolerance_in,
349  RBParameters mu_min_in,
350  RBParameters mu_max_in,
351  RBParameters initial_mu_in,
352  std::map<std::string,bool> log_scaling);
353 
357  virtual void print_info();
358 
365 
373  unsigned int get_delta_N() const { return delta_N; }
374 
378  void set_inner_product_assembly(ElemAssembly& inner_product_assembly_in);
379 
384 
388  void set_constraint_assembly(ElemAssembly& constraint_assembly_in);
389 
394 
400 
406 
407  //----------- PUBLIC DATA MEMBERS -----------//
408 
416  std::vector<Real> training_error_bounds;
417 
422 
428 
434 
439  std::vector< Number > truth_outputs;
440 
445  std::vector< std::vector< Number > > output_dual_innerprods;
446 
453  std::vector< NumericVector<Number>* > Fq_representor;
454 
462  std::vector<Number> Fq_representor_innerprods;
463 
469 
475 
482 
490 
497 
504 
511 
519 
526 
534 
541 
542 protected:
543 
548  virtual void allocate_data_structures();
549 
556  virtual void assemble_affine_expansion();
557 
562  virtual void truth_assembly();
563 
570 
577 
582  virtual bool greedy_termination_test(Real training_greedy_error, int count);
583 
589 
598  ElemAssembly* elem_assembly,
599  SparseMatrix<Number>* input_matrix,
600  NumericVector<Number>* input_vector,
601  bool symmetrize=false,
602  bool apply_dof_constraints=true);
603 
610 
616  void assemble_scaled_matvec(Number scalar,
617  ElemAssembly* elem_assembly,
618  NumericVector<Number>& dest,
619  NumericVector<Number>& arg);
620 
627  virtual void assemble_misc_matrices();
628 
633  virtual void assemble_all_affine_operators();
634 
638  virtual void assemble_all_affine_vectors();
639 
643  virtual void assemble_all_output_vectors();
644 
648  virtual void compute_output_dual_innerprods();
649 
662  virtual void compute_Fq_representor_innerprods(bool compute_inner_products=true);
663 
668  virtual void enrich_RB_space();
669 
674  virtual void update_system();
675 
680  virtual Real get_RB_error_bound();
681 
685  virtual void update_RB_system_matrices();
686 
694  virtual void update_residual_terms(bool compute_inner_products=true);
695 
702  virtual void init_context(FEMContext& ) {}
703 
704  //----------- PROTECTED DATA MEMBERS -----------//
705 
710  unsigned int Nmax;
711 
716  unsigned int delta_N;
717 
723 
730 
737 
738 private:
739 
740  //----------- PRIVATE DATA MEMBERS -----------//
741 
748 
754 
759 
765 
769  std::vector< SparseMatrix<Number>* > Aq_vector;
770 
775  std::vector< NumericVector<Number>* > Fq_vector;
776 
781  std::vector< std::vector< NumericVector<Number>* > > outputs_vector;
782 
788  std::vector< SparseMatrix<Number>* > non_dirichlet_Aq_vector;
789  std::vector< NumericVector<Number>* > non_dirichlet_Fq_vector;
790  std::vector< std::vector< NumericVector<Number>* > > non_dirichlet_outputs_vector;
791 
796 
797 };
798 
799 } // namespace libMesh
800 
801 #endif // LIBMESH_RB_CONSTRUCTION_H

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:07 UTC

Hosted By:
SourceForge.net Logo