eigen_solver.h
Go to the documentation of this file.00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2012 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner 00003 00004 // This library is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public 00006 // License as published by the Free Software Foundation; either 00007 // version 2.1 of the License, or (at your option) any later version. 00008 00009 // This library is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // Lesser General Public License for more details. 00013 00014 // You should have received a copy of the GNU Lesser General Public 00015 // License along with this library; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 00018 00019 00020 #ifndef LIBMESH_EIGEN_SOLVER_H 00021 #define LIBMESH_EIGEN_SOLVER_H 00022 00023 00024 #include "libmesh/libmesh_config.h" 00025 #ifdef LIBMESH_HAVE_SLEPC 00026 00027 // Local includes 00028 #include "libmesh/libmesh_common.h" 00029 #include "libmesh/enum_solver_package.h" 00030 #include "libmesh/enum_eigen_solver_type.h" 00031 #include "libmesh/reference_counted_object.h" 00032 #include "libmesh/libmesh.h" 00033 00034 // C++ includes 00035 00036 namespace libMesh 00037 { 00038 00039 // forward declarations 00040 template <typename T> class AutoPtr; 00041 template <typename T> class SparseMatrix; 00042 template <typename T> class ShellMatrix; 00043 template <typename T> class NumericVector; 00044 00045 00051 template <typename T> 00052 class EigenSolver : public ReferenceCountedObject<EigenSolver<T> > 00053 { 00054 public: 00055 00059 EigenSolver (); 00060 00064 virtual ~EigenSolver (); 00065 00070 static AutoPtr<EigenSolver<T> > build(const SolverPackage solver_package = 00071 SLEPC_SOLVERS); 00072 00077 bool initialized () const { return _is_initialized; } 00078 00079 00083 virtual void clear () {} 00084 00088 virtual void init () = 0; 00089 00093 EigenSolverType eigen_solver_type () const { return _eigen_solver_type; } 00094 00098 EigenProblemType eigen_problem_type () const { return _eigen_problem_type;} 00099 00103 PositionOfSpectrum position_of_spectrum () const 00104 { return _position_of_spectrum;} 00105 00109 void set_eigensolver_type (const EigenSolverType est) 00110 { _eigen_solver_type = est; } 00111 00115 void set_eigenproblem_type ( EigenProblemType ept) 00116 {_eigen_problem_type = ept;} 00117 00121 void set_position_of_spectrum (PositionOfSpectrum pos) 00122 {_position_of_spectrum= pos;} 00123 00129 virtual std::pair<unsigned int, unsigned int> solve_standard (SparseMatrix<T> &matrix_A, 00130 int nev, 00131 int ncv, 00132 const double tol, 00133 const unsigned int m_its) = 0; 00134 00140 virtual std::pair<unsigned int, unsigned int> solve_standard (ShellMatrix<T> &matrix_A, 00141 int nev, 00142 int ncv, 00143 const double tol, 00144 const unsigned int m_its) = 0; 00145 00146 00153 virtual std::pair<unsigned int, unsigned int> solve_generalized (SparseMatrix<T> &matrix_A, 00154 SparseMatrix<T> &matrix_B, 00155 int nev, 00156 int ncv, 00157 const double tol, 00158 const unsigned int m_its) = 0; 00159 00164 virtual std::pair<unsigned int, unsigned int> solve_generalized (ShellMatrix<T> &matrix_A, 00165 SparseMatrix<T> &matrix_B, 00166 int nev, 00167 int ncv, 00168 const double tol, 00169 const unsigned int m_its) = 0; 00170 00175 virtual std::pair<unsigned int, unsigned int> solve_generalized (SparseMatrix<T> &matrix_A, 00176 ShellMatrix<T> &matrix_B, 00177 int nev, 00178 int ncv, 00179 const double tol, 00180 const unsigned int m_its) = 0; 00181 00186 virtual std::pair<unsigned int, unsigned int> solve_generalized (ShellMatrix<T> &matrix_A, 00187 ShellMatrix<T> &matrix_B, 00188 int nev, 00189 int ncv, 00190 const double tol, 00191 const unsigned int m_its) = 0; 00192 00193 00198 virtual std::pair<Real, Real> get_eigenpair (unsigned int i, 00199 NumericVector<T> &solution) = 0; 00200 00205 virtual std::pair<Real, Real> get_eigenvalue (unsigned int i) = 0; 00206 00210 virtual void attach_deflation_space(NumericVector<T> &deflation_vector) = 0; 00211 00212 protected: 00213 00217 EigenSolverType _eigen_solver_type; 00218 00222 EigenProblemType _eigen_problem_type; 00223 00227 PositionOfSpectrum _position_of_spectrum; 00228 00232 bool _is_initialized; 00233 00234 }; 00235 00236 00237 00238 00239 /*----------------------- inline functions ----------------------------------*/ 00240 template <typename T> 00241 inline 00242 EigenSolver<T>::EigenSolver () : 00243 00244 _eigen_solver_type (ARNOLDI), 00245 _eigen_problem_type (NHEP), 00246 _position_of_spectrum (LARGEST_MAGNITUDE), 00247 _is_initialized (false) 00248 { 00249 } 00250 00251 00252 00253 template <typename T> 00254 inline 00255 EigenSolver<T>::~EigenSolver () 00256 { 00257 this->clear (); 00258 } 00259 00260 } // namespace libMesh 00261 00262 #endif // LIBMESH_HAVE_SLEPC 00263 00264 #endif // LIBMESH_EIGEN_SOLVER_H
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:46 UTC
Hosted By: