libMesh
rb_eim_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_EIM_CONSTRUCTION_H
21 #define LIBMESH_RB_EIM_CONSTRUCTION_H
22 
23 // rbOOmit includes
24 #include "libmesh/rb_construction.h"
25 #include "libmesh/rb_assembly_expansion.h"
26 #include "libmesh/rb_eim_assembly.h"
27 
28 // libMesh includes
29 #include "libmesh/mesh_function.h"
30 #include "libmesh/coupling_matrix.h"
31 
32 // C++ includes
33 
34 namespace libMesh
35 {
36 
49 {
50 public:
51 
53 
59  const std::string & name,
60  const unsigned int number);
61 
65  virtual ~RBEIMConstruction ();
66 
71 
76 
80  virtual void clear() override;
81 
86  virtual void process_parameters_file (const std::string & parameters_filename) override;
87 
92  void set_best_fit_type_flag (const std::string & best_fit_type_string);
93 
97  virtual void print_info() override;
98 
103  virtual void initialize_rb_construction(bool skip_matrix_assembly=false,
104  bool skip_vector_assembly=false) override;
105 
109  virtual Real train_reduced_basis(const bool resize_rb_eval_data=true) override;
110 
119  virtual Real truth_solve(int plot_solution) override;
120 
128  virtual Real compute_best_fit_error();
129 
133  virtual void init_context_with_sys(FEMContext & c, System & sys);
134 
139  virtual void init_explicit_system() = 0;
140 
145  virtual void init_implicit_system() = 0;
146 
150  Number evaluate_mesh_function(unsigned int var_number,
151  Point p);
152 
157  void set_point_locator_tol(Real point_locator_tol);
158 
162  Real get_point_locator_tol() const;
163 
170  virtual void initialize_eim_assembly_objects();
171 
175  std::vector<std::unique_ptr<ElemAssembly>> & get_eim_assembly_objects();
176 
183  virtual std::unique_ptr<ElemAssembly> build_eim_assembly(unsigned int bf_index) = 0;
184 
189 
195  virtual void load_basis_function(unsigned int i) override;
196 
202  virtual void load_rb_solution() override;
203 
209  unsigned int var,
210  NumericVector<Number>& source);
211 
217  unsigned int var,
218  NumericVector<Number>& localized_source);
219 
224 
230  void plot_parametrized_functions_in_training_set(const std::string & pathname);
231 
232  //----------- PUBLIC DATA MEMBERS -----------//
233 
244 
245 protected:
246 
250  virtual void init_data() override;
251 
256  virtual void enrich_RB_space() override;
257 
262  virtual void update_system() override;
263 
269  virtual void update_RB_system_matrices() override;
270 
275  virtual Real get_RB_error_bound() override;
276 
282 
288 
293  std::vector<std::unique_ptr<NumericVector<Number>>> _parametrized_functions_in_training_set;
294 
295 private:
296 
300  std::unique_ptr<MeshFunction> _mesh_function;
301 
306  std::unique_ptr<NumericVector<Number>> _ghosted_meshfunction_vector;
307 
313 
318  std::vector<std::unique_ptr<ElemAssembly>> _rb_eim_assembly_objects;
319 
328 
332  std::vector<std::vector<dof_id_type>> _dof_map_between_systems;
333 
338  std::vector<std::unique_ptr<NumericVector<Number>>> _matrix_times_bfs;
339 
344 };
345 
346 } // namespace libMesh
347 
348 #endif // LIBMESH_RB_EIM_CONSTRUCTION_H
libMesh::RBEIMConstruction::process_parameters_file
virtual void process_parameters_file(const std::string &parameters_filename) override
Read parameters in from file and set up this system accordingly.
Definition: rb_eim_construction.C:112
libMesh::RBEIMConstruction::train_reduced_basis
virtual Real train_reduced_basis(const bool resize_rb_eval_data=true) override
Override train_reduced_basis to first initialize _parametrized_functions_in_training_set.
Definition: rb_eim_construction.C:195
libMesh::System
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:100
libMesh::Number
Real Number
Definition: libmesh_common.h:195
libMesh::RBEIMConstruction::print_info
virtual void print_info() override
Print out info that describes the current setup of this RBConstruction.
Definition: rb_eim_construction.C:137
libMesh::RBEIMConstruction::load_rb_solution
virtual void load_rb_solution() override
Load the RB solution from the most recent solve with rb_eval into this system's solution vector.
Definition: rb_eim_construction.C:283
libMesh::RBEIMConstruction::enrich_RB_space
virtual void enrich_RB_space() override
Add a new basis function to the RB space.
Definition: rb_eim_construction.C:307
libMesh::RBEIMConstruction::update_system
virtual void update_system() override
Update the system after enriching the RB space; this calls a series of functions to update the system...
Definition: rb_eim_construction.C:796
libMesh::RBEIMConstruction::init_explicit_system
virtual void init_explicit_system()=0
Add variables to the ExplicitSystem that is used to store the basis functions.
libMesh::RBEIMConstruction::EIM_BEST_FIT
Definition: rb_eim_construction.h:52
libMesh::RBEIMConstruction::~RBEIMConstruction
virtual ~RBEIMConstruction()
Destructor.
Definition: rb_eim_construction.C:90
libMesh::RBEIMConstruction::_empty_rb_assembly_expansion
RBAssemblyExpansion _empty_rb_assembly_expansion
We initialize RBEIMConstruction so that it has an "empty" RBAssemblyExpansion, because this isn't use...
Definition: rb_eim_construction.h:312
libMesh::RBEIMConstruction::Parent
RBConstruction Parent
The type of the parent.
Definition: rb_eim_construction.h:75
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::RBEIMConstruction::_matrix_times_bfs
std::vector< std::unique_ptr< NumericVector< Number > > > _matrix_times_bfs
This vector is used to store inner_product_matrix * basis_function[i] for each i, since we frequently...
Definition: rb_eim_construction.h:338
libMesh::RBEIMConstruction::truth_solve
virtual Real truth_solve(int plot_solution) override
Load the truth representation of the parametrized function at the current parameters into the solutio...
Definition: rb_eim_construction.C:566
libMesh::RBEIMConstruction::BEST_FIT_TYPE
BEST_FIT_TYPE
Definition: rb_eim_construction.h:52
libMesh::System::number
unsigned int number() const
Definition: system.h:2075
libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set
void initialize_parametrized_functions_in_training_set()
Loop over the training set and compute the parametrized function for each training index.
Definition: rb_eim_construction.C:458
libMesh::RBEIMConstruction::_dof_map_between_systems
std::vector< std::vector< dof_id_type > > _dof_map_between_systems
The index map between the explicit system and the implicit system.
Definition: rb_eim_construction.h:332
libMesh::RBEIMConstruction::_mesh_function
std::unique_ptr< MeshFunction > _mesh_function
A mesh function to interpolate on the mesh.
Definition: rb_eim_construction.h:300
libMesh::RBEIMConstruction::plot_parametrized_functions_in_training_set
void plot_parametrized_functions_in_training_set(const std::string &pathname)
Plot all the parameterized functions that we are storing in _parametrized_functions_in_training_set.
Definition: rb_eim_construction.C:484
libMesh::RBEIMConstruction::_parametrized_functions_in_training_set_initialized
bool _parametrized_functions_in_training_set_initialized
Boolean flag to indicate whether or not we have called compute_parametrized_functions_in_training_set...
Definition: rb_eim_construction.h:287
libMesh::NumericVector< Number >
libMesh::RBEIMConstruction::evaluate_mesh_function
Number evaluate_mesh_function(unsigned int var_number, Point p)
Evaluate the mesh function at the specified point and for the specified variable.
Definition: rb_eim_construction.C:203
libMesh::RBAssemblyExpansion
This class stores the set of ElemAssembly functor objects that define the "parameter-independent expa...
Definition: rb_assembly_expansion.h:44
libMesh::RBEIMConstruction::load_basis_function
virtual void load_basis_function(unsigned int i) override
Load the i^th RB function into the RBConstruction solution vector.
Definition: rb_eim_construction.C:272
libMesh::RBEIMConstruction::init_context_with_sys
virtual void init_context_with_sys(FEMContext &c, System &sys)
Initialize c based on sys.
Definition: rb_eim_construction.C:713
libMesh::RBEIMConstruction::set_explicit_sys_subvector
void set_explicit_sys_subvector(NumericVector< Number > &dest, unsigned int var, NumericVector< Number > &source)
Load source into the subvector of dest corresponding to var var.
Definition: rb_eim_construction.C:802
libMesh::RBEIMConstruction::_ghosted_meshfunction_vector
std::unique_ptr< NumericVector< Number > > _ghosted_meshfunction_vector
We also need an extra vector in which we can store a ghosted copy of the vector that we wish to use M...
Definition: rb_eim_construction.h:306
libMesh::RBEIMConstruction::set_best_fit_type_flag
void set_best_fit_type_flag(const std::string &best_fit_type_string)
Specify which type of "best fit" we use to guide the EIM greedy algorithm.
Definition: rb_eim_construction.C:122
libMesh::RBEIMConstruction::set_point_locator_tol
void set_point_locator_tol(Real point_locator_tol)
Set a point locator tolerance to be used in this class's MeshFunction, and other operations that requ...
Definition: rb_eim_construction.C:250
libMesh::RBEIMConstruction::init_dof_map_between_systems
void init_dof_map_between_systems()
Set up the index map between the implicit and explicit systems.
Definition: rb_eim_construction.C:849
libMesh::Point
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
libMesh::RBEIMConstruction::get_point_locator_tol
Real get_point_locator_tol() const
Definition: rb_eim_construction.C:255
libMesh::RBConstruction
This class is part of the rbOOmit framework.
Definition: rb_construction.h:53
libMesh::RBEIMConstruction::PROJECTION_BEST_FIT
Definition: rb_eim_construction.h:52
libMesh::RBEIMConstruction::get_eim_assembly_objects
std::vector< std::unique_ptr< ElemAssembly > > & get_eim_assembly_objects()
Definition: rb_eim_construction.C:302
libMesh::EquationSystems
This is the EquationSystems class.
Definition: equation_systems.h:74
libMesh::RBEIMConstruction::compute_best_fit_error
virtual Real compute_best_fit_error()
We compute the best fit of parametrized_function into the EIM space and then evaluate the error in th...
Definition: rb_eim_construction.C:511
libMesh::ExplicitSystem
Manages consistently variables, degrees of freedom, and coefficient vectors for explicit systems.
Definition: explicit_system.h:48
libMesh::RBEIMConstruction::_point_locator_tol
Real _point_locator_tol
The point locator tolerance.
Definition: rb_eim_construction.h:343
libMesh::RBEIMConstruction::_rb_eim_assembly_objects
std::vector< std::unique_ptr< ElemAssembly > > _rb_eim_assembly_objects
The vector of assembly objects that are created to point to this RBEIMConstruction.
Definition: rb_eim_construction.h:318
libMesh::RBEIMConstruction::_explicit_system_name
std::string _explicit_system_name
We use an ExplicitSystem to store the EIM basis functions.
Definition: rb_eim_construction.h:327
libMesh::System::name
const std::string & name() const
Definition: system.h:2067
libMesh::RBEIMConstruction::get_RB_error_bound
virtual Real get_RB_error_bound() override
Override to return the best fit error.
Definition: rb_eim_construction.C:790
libMesh::RBEIMConstruction::RBEIMConstruction
RBEIMConstruction(EquationSystems &es, const std::string &name, const unsigned int number)
Constructor.
Definition: rb_eim_construction.C:53
libMesh::RBEIMConstruction::get_explicit_system
ExplicitSystem & get_explicit_system()
Get the ExplicitSystem associated with this system.
Definition: rb_eim_construction.C:267
libMesh::RBEIMConstruction::build_eim_assembly
virtual std::unique_ptr< ElemAssembly > build_eim_assembly(unsigned int bf_index)=0
Build an element assembly object that will access basis function bf_index.
libMesh::RBEIMConstruction::best_fit_type_flag
BEST_FIT_TYPE best_fit_type_flag
Enum that indicates which type of "best fit" algorithm we should use.
Definition: rb_eim_construction.h:243
libMesh::RBEIMConstruction::update_RB_system_matrices
virtual void update_RB_system_matrices() override
Compute the reduced basis matrices for the current basis.
Definition: rb_eim_construction.C:727
libMesh::RBEIMConstruction::_parametrized_functions_in_training_set
std::vector< std::unique_ptr< NumericVector< Number > > > _parametrized_functions_in_training_set
The libMesh vectors storing the finite element coefficients of the RB basis functions.
Definition: rb_eim_construction.h:293
libMesh::RBEIMConstruction::initialize_eim_assembly_objects
virtual void initialize_eim_assembly_objects()
Build a vector of ElemAssembly objects that accesses the basis functions stored in this RBEIMConstruc...
Definition: rb_eim_construction.C:260
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::RBEIMConstruction::initialize_rb_construction
virtual void initialize_rb_construction(bool skip_matrix_assembly=false, bool skip_vector_assembly=false) override
Initialize this system so that we can perform the Construction stage of the RB method.
Definition: rb_eim_construction.C:166
libMesh::RBEIMConstruction::clear
virtual void clear() override
Clear this object.
Definition: rb_eim_construction.C:95
libMesh::RBEIMConstruction::get_explicit_sys_subvector
void get_explicit_sys_subvector(NumericVector< Number > &dest, unsigned int var, NumericVector< Number > &localized_source)
Load the subvector of localized_source corresponding to variable var into dest.
Definition: rb_eim_construction.C:829
libMesh::RBEIMConstruction::init_data
virtual void init_data() override
Override to initialize the coupling matrix to decouple variables in this system.
Definition: rb_eim_construction.C:155
libMesh::RBEIMConstruction::sys_type
RBEIMConstruction sys_type
The type of system.
Definition: rb_eim_construction.h:70
libMesh::RBEIMConstruction
This class is part of the rbOOmit framework.
Definition: rb_eim_construction.h:48
libMesh::RBEIMConstruction::init_implicit_system
virtual void init_implicit_system()=0
Add one variable to the ImplicitSystem (i.e.
libMesh::FEMContext
This class provides all data required for a physics package (e.g.
Definition: fem_context.h:62