eigen_system.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 #ifndef LIBMESH_EIGEN_SYSTEM_H
20 #define LIBMESH_EIGEN_SYSTEM_H
21 
22 #include "libmesh/libmesh_config.h"
23 
24 // Currently, the EigenSystem should only be available
25 // if SLEPc support is enabled.
26 #if defined(LIBMESH_HAVE_SLEPC)
27 
28 // Local Includes
29 #include "libmesh/system.h"
30 #include "libmesh/eigen_solver.h"
31 
32 namespace libMesh
33 {
34 
35 // Forward Declarations
36 template <typename T> class SparseMatrix;
37 
38 
54 class EigenSystem : public System
55 {
56 public:
57 
63  const std::string & name_in,
64  const unsigned int number_in);
65 
69  virtual ~EigenSystem ();
70 
75 
79  typedef System Parent;
80 
84  sys_type & system () { return *this; }
85 
90  virtual void clear () override;
91 
96  virtual void reinit () override;
97 
101  virtual void solve () override;
102 
106  virtual void assemble () override;
107 
112  virtual std::pair<Real, Real> get_eigenpair (dof_id_type i);
113 
118  virtual std::string system_type () const override { return "Eigen"; }
119 
123  virtual unsigned int n_matrices () const override;
124 
128  unsigned int get_n_converged () const {return _n_converged_eigenpairs;}
129 
133  unsigned int get_n_iterations () const {return _n_iterations;}
134 
139 
144 
149  bool generalized () const { return _is_generalized_eigenproblem; }
150 
154  std::unique_ptr<SparseMatrix<Number>> matrix_A;
155 
159  std::unique_ptr<SparseMatrix<Number>> matrix_B;
160 
165  std::unique_ptr<EigenSolver<Number>> eigen_solver;
166 
167 
168 protected:
169 
170 
175  virtual void init_data () override;
176 
180  virtual void init_matrices ();
181 
186  void set_n_converged (unsigned int nconv)
187  { _n_converged_eigenpairs = nconv; }
188 
193  void set_n_iterations (unsigned int its)
194  { _n_iterations = its;}
195 
196 
197 private:
198 
203 
207  unsigned int _n_iterations;
208 
214 
219 };
220 
221 
222 
223 // ------------------------------------------------------------
224 // EigenSystem inline methods
225 inline
226 unsigned int EigenSystem::n_matrices () const
227 {
229  return 2;
230 
231  return 1;
232 }
233 
234 } // namespace libMesh
235 
236 #endif // LIBMESH_HAVE_SLEPC
237 
238 #endif // LIBMESH_EIGEN_SYSTEM_H
virtual void reinit() override
Definition: eigen_system.C:165
virtual std::pair< Real, Real > get_eigenpair(dof_id_type i)
Definition: eigen_system.C:256
bool generalized() const
Definition: eigen_system.h:149
Manages multiples systems of equations.
EigenSystem sys_type
Definition: eigen_system.h:74
unsigned int _n_converged_eigenpairs
Definition: eigen_system.h:202
sys_type & system()
Definition: eigen_system.h:84
virtual std::string system_type() const override
Definition: eigen_system.h:118
virtual unsigned int n_matrices() const override
Definition: eigen_system.h:226
virtual void assemble() override
Definition: eigen_system.C:247
unsigned int _n_iterations
Definition: eigen_system.h:207
std::unique_ptr< SparseMatrix< Number > > matrix_A
Definition: eigen_system.h:154
void set_n_iterations(unsigned int its)
Definition: eigen_system.h:193
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:92
EigenProblemType get_eigenproblem_type() const
Definition: eigen_system.h:143
void set_n_converged(unsigned int nconv)
Definition: eigen_system.h:186
virtual ~EigenSystem()
Definition: eigen_system.C:55
virtual void solve() override
Definition: eigen_system.C:198
EigenSystem(EquationSystems &es, const std::string &name_in, const unsigned int number_in)
Definition: eigen_system.C:40
std::unique_ptr< EigenSolver< Number > > eigen_solver
Definition: eigen_system.h:165
virtual void init_matrices()
Definition: eigen_system.C:135
EigenProblemType _eigen_problem_type
Definition: eigen_system.h:218
void set_eigenproblem_type(EigenProblemType ept)
Definition: eigen_system.C:77
std::unique_ptr< SparseMatrix< Number > > matrix_B
Definition: eigen_system.h:159
unsigned int get_n_converged() const
Definition: eigen_system.h:128
virtual void clear() override
Definition: eigen_system.C:63
Manages consistently variables, degrees of freedom, and coefficient vectors for eigenvalue problems...
Definition: eigen_system.h:54
virtual void init_data() override
Definition: eigen_system.C:116
uint8_t dof_id_type
Definition: id_types.h:64
unsigned int get_n_iterations() const
Definition: eigen_system.h:133