libMesh
eigen_system.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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 
50 class EigenSystem : public System
51 {
52 public:
53 
59  const std::string & name_in,
60  const unsigned int number_in);
61 
65  virtual ~EigenSystem ();
66 
71 
75  typedef System Parent;
76 
80  sys_type & system () { return *this; }
81 
86  virtual void clear () libmesh_override;
87 
92  virtual void reinit () libmesh_override;
93 
97  virtual void solve () libmesh_override;
98 
102  virtual void assemble () libmesh_override;
103 
108  virtual std::pair<Real, Real> get_eigenpair (dof_id_type i);
109 
114  virtual std::string system_type () const libmesh_override { return "Eigen"; }
115 
119  virtual unsigned int n_matrices () const libmesh_override;
120 
124  unsigned int get_n_converged () const {return _n_converged_eigenpairs;}
125 
129  unsigned int get_n_iterations () const {return _n_iterations;}
130 
135 
140 
145  bool generalized () const { return _is_generalized_eigenproblem; }
146 
151 
156 
162 
163 
164 protected:
165 
166 
171  virtual void init_data () libmesh_override;
172 
176  virtual void init_matrices ();
177 
182  void set_n_converged (unsigned int nconv)
183  { _n_converged_eigenpairs = nconv; }
184 
189  void set_n_iterations (unsigned int its)
190  { _n_iterations = its;}
191 
192 
193 private:
194 
199 
203  unsigned int _n_iterations;
204 
210 
215 };
216 
217 
218 
219 // ------------------------------------------------------------
220 // EigenSystem inline methods
221 inline
222 unsigned int EigenSystem::n_matrices () const
223 {
225  return 2;
226 
227  return 1;
228 }
229 
230 } // namespace libMesh
231 
232 #endif // LIBMESH_HAVE_SLEPC
233 
234 #endif // LIBMESH_EIGEN_SYSTEM_H
virtual std::pair< Real, Real > get_eigenpair(dof_id_type i)
Definition: eigen_system.C:257
This is the EquationSystems class.
EigenSystem sys_type
The type of system.
Definition: eigen_system.h:70
unsigned int _n_converged_eigenpairs
The number of converged eigenpairs.
Definition: eigen_system.h:198
sys_type & system()
Definition: eigen_system.h:80
unsigned int get_n_iterations() const
Definition: eigen_system.h:129
EigenProblemType
Defines an enum for eigenproblem types.
UniquePtr< SparseMatrix< Number > > matrix_B
A second system matrix for generalized eigenvalue problems.
Definition: eigen_system.h:155
virtual std::string system_type() const libmesh_override
Definition: eigen_system.h:114
unsigned int get_n_converged() const
Definition: eigen_system.h:124
The libMesh namespace provides an interface to certain functionality in the library.
UniquePtr< SparseMatrix< Number > > matrix_A
The system matrix for standard eigenvalue problems.
Definition: eigen_system.h:150
virtual void init_data() libmesh_override
Initializes the member data fields associated with the system, so that, e.g., assemble() may be used...
Definition: eigen_system.C:117
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
System Parent
The type of the parent.
Definition: eigen_system.h:75
unsigned int _n_iterations
The number of iterations of the eigen solver algorithm.
Definition: eigen_system.h:203
virtual void solve() libmesh_override
Assembles & solves the eigen system.
Definition: eigen_system.C:199
void set_n_iterations(unsigned int its)
Set the _n_iterations member, useful for subclasses of EigenSystem.
Definition: eigen_system.h:189
bool generalized() const
Definition: eigen_system.h:145
This is the base class for classes which contain information related to any physical process that mig...
Definition: system.h:76
void set_n_converged(unsigned int nconv)
Set the _n_converged_eigenpairs member, useful for subclasses of EigenSystem.
Definition: eigen_system.h:182
bool _is_generalized_eigenproblem
A boolean flag to indicate whether we are dealing with a generalized eigenvalue problem.
Definition: eigen_system.h:209
virtual ~EigenSystem()
Destructor.
Definition: eigen_system.C:56
virtual void clear() libmesh_override
Clear all the data structures associated with the system.
Definition: eigen_system.C:64
virtual unsigned int n_matrices() const libmesh_override
Definition: eigen_system.h:222
virtual void assemble() libmesh_override
Assembles the system matrix.
Definition: eigen_system.C:248
EigenSystem(EquationSystems &es, const std::string &name_in, const unsigned int number_in)
Constructor.
Definition: eigen_system.C:41
UniquePtr< EigenSolver< Number > > eigen_solver
The EigenSolver, defining which interface, i.e solver package to use.
Definition: eigen_system.h:161
virtual void init_matrices()
Initializes the matrices associated with the system.
Definition: eigen_system.C:136
EigenProblemType _eigen_problem_type
The type of the eigenvalue problem.
Definition: eigen_system.h:214
void set_eigenproblem_type(EigenProblemType ept)
Sets the type of the current eigen problem.
Definition: eigen_system.C:78
virtual void reinit() libmesh_override
Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be use...
Definition: eigen_system.C:166
This class provides a specific system class.
Definition: eigen_system.h:50
EigenProblemType get_eigenproblem_type() const
Definition: eigen_system.h:139
uint8_t dof_id_type
Definition: id_types.h:64