$extrastylesheet
00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2014 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 #ifndef LIBMESH_EIGEN_SYSTEM_H 00020 #define LIBMESH_EIGEN_SYSTEM_H 00021 00022 #include "libmesh/libmesh_config.h" 00023 00024 // Currently, the EigenSystem should only be available 00025 // if SLEPc support is enabled. 00026 #if defined(LIBMESH_HAVE_SLEPC) 00027 00028 // Local Includes 00029 #include "libmesh/system.h" 00030 #include "libmesh/eigen_solver.h" 00031 00032 // C++ includes 00033 00034 namespace libMesh 00035 { 00036 00037 00038 // Forward Declarations 00039 template <typename T> class SparseMatrix; 00040 00041 00050 // ------------------------------------------------------------ 00051 // EigenSystem class definition 00052 00053 class EigenSystem : public System 00054 { 00055 public: 00056 00061 EigenSystem (EquationSystems& es, 00062 const std::string& name_in, 00063 const unsigned int number_in); 00064 00068 virtual ~EigenSystem (); 00069 00073 typedef EigenSystem sys_type; 00074 00078 typedef System Parent; 00079 00083 sys_type & system () { return *this; } 00084 00089 virtual void clear (); 00090 00095 virtual void reinit (); 00096 00100 virtual void solve (); 00101 00105 virtual void assemble (); 00106 00111 virtual std::pair<Real, Real> get_eigenpair (unsigned int i); 00112 00117 virtual std::string system_type () const { return "Eigen"; } 00118 00122 virtual unsigned int n_matrices () const; 00123 00127 unsigned int get_n_converged () const {return _n_converged_eigenpairs;} 00128 00132 unsigned int get_n_iterations () const {return _n_iterations;} 00133 00137 void set_eigenproblem_type (EigenProblemType ept); 00138 00142 EigenProblemType get_eigenproblem_type () const {return _eigen_problem_type;} 00143 00148 bool generalized () const { return _is_generalized_eigenproblem; } 00149 00153 SparseMatrix<Number> *matrix_A; 00154 00158 SparseMatrix<Number> *matrix_B; 00159 00164 UniquePtr<EigenSolver<Number> > eigen_solver; 00165 00166 00167 protected: 00168 00169 00174 virtual void init_data (); 00175 00179 virtual void init_matrices (); 00180 00185 void set_n_converged (unsigned int nconv) 00186 { _n_converged_eigenpairs = nconv; } 00187 00192 void set_n_iterations (unsigned int its) 00193 { _n_iterations = its;} 00194 00195 00196 private: 00197 00201 unsigned int _n_converged_eigenpairs; 00202 00206 unsigned int _n_iterations; 00207 00212 bool _is_generalized_eigenproblem; 00213 00217 EigenProblemType _eigen_problem_type; 00218 00219 00220 }; 00221 00222 00223 00224 // ------------------------------------------------------------ 00225 // EigenSystem inline methods 00226 inline 00227 unsigned int EigenSystem::n_matrices () const 00228 { 00229 if(_is_generalized_eigenproblem) 00230 return 2; 00231 00232 return 1; 00233 } 00234 00235 00236 } // namespace libMesh 00237 00238 00239 #endif // LIBMESH_HAVE_SLEPC 00240 00241 #endif // LIBMESH_EIGEN_SYSTEM_H