slepc_eigen_solver.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 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 
20 #ifndef LIBMESH_SLEPC_EIGEN_SOLVER_H
21 #define LIBMESH_SLEPC_EIGEN_SOLVER_H
22 
23 #include "libmesh/libmesh_config.h"
24 
25 #ifdef LIBMESH_HAVE_SLEPC
26 
27 // Local includes
28 #include "libmesh/eigen_solver.h"
29 #include "libmesh/slepc_macro.h"
30 
34 EXTERN_C_FOR_SLEPC_BEGIN
35 # include <slepceps.h>
36 EXTERN_C_FOR_SLEPC_END
37 
38 // C++ includes
39 
40 
41 namespace libMesh
42 {
43 
44 
50 template <typename T>
51 class SlepcEigenSolver : public EigenSolver<T>
52 {
53 
54 public:
55 
60  LIBMESH_CAN_DEFAULT_TO_COMMWORLD);
61 
62 
67 
68 
72  void clear();
73 
74 
78  void init();
79 
80 
91  std::pair<unsigned int, unsigned int> solve_standard (SparseMatrix<T> &matrix_A,
92  int nev,
93  int ncv,
94  const double tol,
95  const unsigned int m_its);
96 
101  std::pair<unsigned int, unsigned int> solve_standard (ShellMatrix<T> &shell_matrix,
102  int nev,
103  int ncv,
104  const double tol,
105  const unsigned int m_its);
106 
107 
120  std::pair<unsigned int, unsigned int> solve_generalized(SparseMatrix<T> &matrix_A,
121  SparseMatrix<T> &matrix_B,
122  int nev,
123  int ncv,
124  const double tol,
125  const unsigned int m_its);
126 
131  std::pair<unsigned int, unsigned int> solve_generalized(ShellMatrix<T> &matrix_A,
132  SparseMatrix<T> &matrix_B,
133  int nev,
134  int ncv,
135  const double tol,
136  const unsigned int m_its);
137 
148  std::pair<unsigned int, unsigned int> solve_generalized(SparseMatrix<T> &matrix_A,
149  ShellMatrix<T> &matrix_B,
150  int nev,
151  int ncv,
152  const double tol,
153  const unsigned int m_its);
154 
165  std::pair<unsigned int, unsigned int> solve_generalized(ShellMatrix<T> &matrix_A,
166  ShellMatrix<T> &matrix_B,
167  int nev,
168  int ncv,
169  const double tol,
170  const unsigned int m_its);
171 
172 
173 
180  std::pair<Real, Real> get_eigenpair (unsigned int i,
181  NumericVector<T> &solution_in);
182 
186  std::pair<Real, Real> get_eigenvalue (unsigned int i);
187 
192  Real get_relative_error (unsigned int i);
193 
197  void attach_deflation_space(NumericVector<T>& deflation_vector);
198 
199 private:
200 
204  std::pair<unsigned int, unsigned int> _solve_standard_helper (Mat mat,
205  int nev,
206  int ncv,
207  const double tol,
208  const unsigned int m_its);
209 
213  std::pair<unsigned int, unsigned int> _solve_generalized_helper (Mat mat_A,
214  Mat mat_B,
215  int nev,
216  int ncv,
217  const double tol,
218  const unsigned int m_its);
219 
224  void set_slepc_solver_type ();
225 
230  void set_slepc_problem_type ();
231 
237 
243  static PetscErrorCode _petsc_shell_matrix_mult(Mat mat, Vec arg, Vec dest);
244 
250  static PetscErrorCode _petsc_shell_matrix_get_diagonal(Mat mat, Vec dest);
251 
255  EPS _eps;
256 
257 };
258 
259 
260 /*----------------------- inline functions ----------------------------------*/
261 template <typename T>
262 inline
264  EigenSolver<T>(comm)
265 {
266  this->_eigen_solver_type = ARNOLDI;
267  this->_eigen_problem_type = NHEP;
268 }
269 
270 
271 
272 template <typename T>
273 inline
275 {
276  this->clear ();
277 }
278 
279 } // namespace libMesh
280 
281 
282 #endif // #ifdef LIBMESH_HAVE_SLEPC
283 #endif // LIBMESH_SLEPC_EIGEN_SOLVER_H

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

Hosted By:
SourceForge.net Logo