EigenSolver< T > Class Template Reference

#include <eigen_solver.h>

Inheritance diagram for EigenSolver< T >:

List of all members.

Public Member Functions

 EigenSolver ()
virtual ~EigenSolver ()
bool initialized () const
virtual void clear ()
virtual void init ()=0
EigenSolverType eigen_solver_type () const
EigenProblemType eigen_problem_type () const
PositionOfSpectrum position_of_spectrum () const
void set_eigensolver_type (const EigenSolverType est)
void set_eigenproblem_type (EigenProblemType ept)
void set_position_of_spectrum (PositionOfSpectrum pos)
virtual std::pair< unsigned
int, unsigned int > 
solve_standard (SparseMatrix< T > &matrix_A, int nev, int ncv, const double tol, const unsigned int m_its)=0
virtual std::pair< unsigned
int, unsigned int > 
solve_standard (ShellMatrix< T > &matrix_A, int nev, int ncv, const double tol, const unsigned int m_its)=0
virtual std::pair< unsigned
int, unsigned int > 
solve_generalized (SparseMatrix< T > &matrix_A, SparseMatrix< T > &matrix_B, int nev, int ncv, const double tol, const unsigned int m_its)=0
virtual std::pair< unsigned
int, unsigned int > 
solve_generalized (ShellMatrix< T > &matrix_A, SparseMatrix< T > &matrix_B, int nev, int ncv, const double tol, const unsigned int m_its)=0
virtual std::pair< unsigned
int, unsigned int > 
solve_generalized (SparseMatrix< T > &matrix_A, ShellMatrix< T > &matrix_B, int nev, int ncv, const double tol, const unsigned int m_its)=0
virtual std::pair< unsigned
int, unsigned int > 
solve_generalized (ShellMatrix< T > &matrix_A, ShellMatrix< T > &matrix_B, int nev, int ncv, const double tol, const unsigned int m_its)=0
virtual std::pair< Real, Realget_eigenpair (unsigned int i, NumericVector< T > &solution)=0
virtual void attach_deflation_space (NumericVector< T > &deflation_vector)=0

Static Public Member Functions

static AutoPtr< EigenSolver< T > > build (const SolverPackage solver_package=SLEPC_SOLVERS)
static std::string get_info ()
static void print_info ()
static unsigned int n_objects ()

Protected Types

typedef std::map< std::string,
std::pair< unsigned int,
unsigned int > > 
Counts

Protected Member Functions

void increment_constructor_count (const std::string &name)
void increment_destructor_count (const std::string &name)

Protected Attributes

EigenSolverType _eigen_solver_type
EigenProblemType _eigen_problem_type
PositionOfSpectrum _position_of_spectrum
bool _is_initialized

Static Protected Attributes

static Counts _counts
static Threads::atomic
< unsigned int > 
_n_objects
static Threads::spin_mutex _mutex


Detailed Description

template<typename T>
class EigenSolver< T >

This class provides an interface to solvers for eigenvalue problems.

Definition at line 51 of file eigen_solver.h.


Member Typedef Documentation

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > ReferenceCounter::Counts [protected, inherited]

Data structure to log the information. The log is identified by the class name.

Definition at line 105 of file reference_counter.h.


Constructor & Destructor Documentation

template<typename T >
EigenSolver< T >::EigenSolver (  )  [inline]

Constructor. Initializes Solver data structures

Definition at line 235 of file eigen_solver.h.

00235                              :
00236   
00237   _eigen_solver_type    (ARNOLDI),
00238   _eigen_problem_type   (NHEP),
00239   _position_of_spectrum (LARGEST_MAGNITUDE),
00240   _is_initialized       (false)
00241 {
00242 }

template<typename T >
EigenSolver< T >::~EigenSolver (  )  [inline, virtual]

Destructor.

Definition at line 248 of file eigen_solver.h.

References EigenSolver< T >::clear().

00249 {
00250   this->clear ();
00251 }


Member Function Documentation

template<typename T >
virtual void EigenSolver< T >::attach_deflation_space ( NumericVector< T > &  deflation_vector  )  [pure virtual]

Attach a deflation space defined by a single vector.

Implemented in SlepcEigenSolver< T >.

template<typename T >
AutoPtr< EigenSolver< T > > EigenSolver< T >::build ( const SolverPackage  solver_package = SLEPC_SOLVERS  )  [inline, static]

Builds an EigenSolver using the linear solver package specified by solver_package

Definition at line 36 of file eigen_solver.C.

References libMeshEnums::SLEPC_SOLVERS.

00037 {
00038   // Build the appropriate solver
00039   switch (solver_package)
00040     {
00041 
00042 
00043 
00044 #ifdef LIBMESH_HAVE_SLEPC
00045         case SLEPC_SOLVERS:
00046       {
00047         AutoPtr<EigenSolver<T> > ap(new SlepcEigenSolver<T>);
00048         return ap;
00049       }
00050 #endif
00051 
00052 
00053     default:
00054       std::cerr << "ERROR:  Unrecognized eigen solver package: "
00055                 << solver_package
00056                 << std::endl;
00057       libmesh_error();
00058     }
00059     
00060   AutoPtr<EigenSolver<T> > ap(NULL);
00061   return ap;    
00062 }

template<typename T >
virtual void EigenSolver< T >::clear (  )  [inline, virtual]

Release all memory and clear data structures.

Reimplemented in SlepcEigenSolver< T >.

Definition at line 82 of file eigen_solver.h.

Referenced by EigenSolver< T >::~EigenSolver().

00082 {}

template<typename T >
EigenProblemType EigenSolver< T >::eigen_problem_type (  )  const [inline]

Returns the type of the eigen problem.

Definition at line 97 of file eigen_solver.h.

References EigenSolver< T >::_eigen_problem_type.

00097 { return _eigen_problem_type;}

template<typename T >
EigenSolverType EigenSolver< T >::eigen_solver_type (  )  const [inline]

Returns the type of eigensolver to use.

Definition at line 92 of file eigen_solver.h.

References EigenSolver< T >::_eigen_solver_type.

00092 { return _eigen_solver_type; }

template<typename T >
virtual std::pair<Real, Real> EigenSolver< T >::get_eigenpair ( unsigned int  i,
NumericVector< T > &  solution 
) [pure virtual]

Returns the ith eigenvalue (real and imaginary part), and copies the \ ith eigen vector to the solution vector.

Implemented in SlepcEigenSolver< T >.

std::string ReferenceCounter::get_info (  )  [static, inherited]

Gets a string containing the reference information.

Definition at line 45 of file reference_counter.C.

References ReferenceCounter::_counts, and QuadratureRules::name().

Referenced by ReferenceCounter::print_info().

00046 {
00047 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
00048 
00049   std::ostringstream out;
00050   
00051   out << '\n'
00052       << " ---------------------------------------------------------------------------- \n"
00053       << "| Reference count information                                                |\n"
00054       << " ---------------------------------------------------------------------------- \n";
00055   
00056   for (Counts::iterator it = _counts.begin();
00057        it != _counts.end(); ++it)
00058     {
00059       const std::string name(it->first);
00060       const unsigned int creations    = it->second.first;
00061       const unsigned int destructions = it->second.second;
00062 
00063       out << "| " << name << " reference count information:\n"
00064           << "|  Creations:    " << creations    << '\n'
00065           << "|  Destructions: " << destructions << '\n';
00066     }
00067   
00068   out << " ---------------------------------------------------------------------------- \n";
00069 
00070   return out.str();
00071 
00072 #else
00073 
00074   return "";
00075   
00076 #endif
00077 }

void ReferenceCounter::increment_constructor_count ( const std::string &  name  )  [inline, protected, inherited]

Increments the construction counter. Should be called in the constructor of any derived class that will be reference counted.

Definition at line 149 of file reference_counter.h.

References ReferenceCounter::_counts, and Threads::spin_mtx.

Referenced by ReferenceCountedObject< SparseMatrix< T > >::ReferenceCountedObject().

00150 {
00151   Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
00152   std::pair<unsigned int, unsigned int>& p = _counts[name];
00153 
00154   p.first++;
00155 }

void ReferenceCounter::increment_destructor_count ( const std::string &  name  )  [inline, protected, inherited]

Increments the destruction counter. Should be called in the destructor of any derived class that will be reference counted.

Definition at line 167 of file reference_counter.h.

References ReferenceCounter::_counts, and Threads::spin_mtx.

Referenced by ReferenceCountedObject< SparseMatrix< T > >::~ReferenceCountedObject().

00168 {
00169   Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
00170   std::pair<unsigned int, unsigned int>& p = _counts[name];
00171 
00172   p.second++;
00173 }

template<typename T >
virtual void EigenSolver< T >::init (  )  [pure virtual]

Initialize data structures if not done so already.

Implemented in SlepcEigenSolver< T >.

template<typename T >
bool EigenSolver< T >::initialized (  )  const [inline]

Returns:
true if the data structures are initialized, false otherwise.

Definition at line 76 of file eigen_solver.h.

References EigenSolver< T >::_is_initialized.

Referenced by SlepcEigenSolver< T >::clear(), and SlepcEigenSolver< T >::init().

00076 { return _is_initialized; }

static unsigned int ReferenceCounter::n_objects (  )  [inline, static, inherited]

Prints the number of outstanding (created, but not yet destroyed) objects.

Definition at line 76 of file reference_counter.h.

References ReferenceCounter::_n_objects.

00077   { return _n_objects; }

template<typename T >
PositionOfSpectrum EigenSolver< T >::position_of_spectrum (  )  const [inline]

Returns the position of the spectrum to compute.

Definition at line 102 of file eigen_solver.h.

References EigenSolver< T >::_position_of_spectrum.

00103     { return _position_of_spectrum;}

void ReferenceCounter::print_info (  )  [static, inherited]

Prints the reference information to std::cout.

Definition at line 83 of file reference_counter.C.

References ReferenceCounter::get_info().

00084 {
00085 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
00086   
00087   std::cout << ReferenceCounter::get_info();
00088   
00089 #endif
00090 }

template<typename T >
void EigenSolver< T >::set_eigenproblem_type ( EigenProblemType  ept  )  [inline]

Sets the type of the eigenproblem.

Definition at line 114 of file eigen_solver.h.

References EigenSolver< T >::_eigen_problem_type.

00115     {_eigen_problem_type = ept;}

template<typename T >
void EigenSolver< T >::set_eigensolver_type ( const EigenSolverType  est  )  [inline]

Sets the type of eigensolver to use.

Definition at line 108 of file eigen_solver.h.

References EigenSolver< T >::_eigen_solver_type.

00109     { _eigen_solver_type = est; }

template<typename T >
void EigenSolver< T >::set_position_of_spectrum ( PositionOfSpectrum  pos  )  [inline]

Sets the position of the spectrum.

Definition at line 120 of file eigen_solver.h.

References EigenSolver< T >::_position_of_spectrum.

00121     {_position_of_spectrum= pos;}

template<typename T >
virtual std::pair<unsigned int, unsigned int> EigenSolver< T >::solve_generalized ( ShellMatrix< T > &  matrix_A,
ShellMatrix< T > &  matrix_B,
int  nev,
int  ncv,
const double  tol,
const unsigned int  m_its 
) [pure virtual]

Solves the generalized eigen problem when both matrix_A and matrix_B are of type ShellMatrix.

Implemented in SlepcEigenSolver< T >.

template<typename T >
virtual std::pair<unsigned int, unsigned int> EigenSolver< T >::solve_generalized ( SparseMatrix< T > &  matrix_A,
ShellMatrix< T > &  matrix_B,
int  nev,
int  ncv,
const double  tol,
const unsigned int  m_its 
) [pure virtual]

Solves the generalized eigen problem when matrix_A is a SparseMatrix and matrix_B is a ShellMatrix.

Implemented in SlepcEigenSolver< T >.

template<typename T >
virtual std::pair<unsigned int, unsigned int> EigenSolver< T >::solve_generalized ( ShellMatrix< T > &  matrix_A,
SparseMatrix< T > &  matrix_B,
int  nev,
int  ncv,
const double  tol,
const unsigned int  m_its 
) [pure virtual]

Solves the generalized eigen problem when matrix_A is a ShellMatrix and matrix_B is a SparseMatrix.

Implemented in SlepcEigenSolver< T >.

template<typename T >
virtual std::pair<unsigned int, unsigned int> EigenSolver< T >::solve_generalized ( SparseMatrix< T > &  matrix_A,
SparseMatrix< T > &  matrix_B,
int  nev,
int  ncv,
const double  tol,
const unsigned int  m_its 
) [pure virtual]

Solves the generalized eigen problem when both matrix_A and matrix_B are of type SparseMatrix and returns the number of converged eigenpairs and the number of iterations.

Implemented in SlepcEigenSolver< T >.

template<typename T >
virtual std::pair<unsigned int, unsigned int> EigenSolver< T >::solve_standard ( ShellMatrix< T > &  matrix_A,
int  nev,
int  ncv,
const double  tol,
const unsigned int  m_its 
) [pure virtual]

Solves the standard eigen problem when matrix_A is a ShellMatrix, and returns the number of converged eigenpairs and the number of iterations.

Implemented in SlepcEigenSolver< T >.

template<typename T >
virtual std::pair<unsigned int, unsigned int> EigenSolver< T >::solve_standard ( SparseMatrix< T > &  matrix_A,
int  nev,
int  ncv,
const double  tol,
const unsigned int  m_its 
) [pure virtual]

Solves the standard eigen problem when matrix_A is a SparseMatrix, and returns the number of converged eigenpairs and the number of iterations.

Implemented in SlepcEigenSolver< T >.


Member Data Documentation

template<typename T >
EigenProblemType EigenSolver< T >::_eigen_problem_type [protected]

template<typename T >
EigenSolverType EigenSolver< T >::_eigen_solver_type [protected]

template<typename T >
bool EigenSolver< T >::_is_initialized [protected]

Flag indicating if the data structures have been initialized.

Definition at line 225 of file eigen_solver.h.

Referenced by SlepcEigenSolver< T >::clear(), SlepcEigenSolver< T >::init(), and EigenSolver< T >::initialized().

Threads::spin_mutex ReferenceCounter::_mutex [static, protected, inherited]

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 123 of file reference_counter.h.

Threads::atomic< unsigned int > ReferenceCounter::_n_objects [static, protected, inherited]

The number of objects. Print the reference count information when the number returns to 0.

Definition at line 118 of file reference_counter.h.

Referenced by ReferenceCounter::n_objects(), ReferenceCounter::ReferenceCounter(), and ReferenceCounter::~ReferenceCounter().

template<typename T >
PositionOfSpectrum EigenSolver< T >::_position_of_spectrum [protected]


The documentation for this class was generated from the following files:

Site Created By: libMesh Developers
Last modified: November 25 2009 03:44:08.

Hosted By:
SourceForge.net Logo