libMesh
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
libMesh::EigenSolver< T > Class Template Referenceabstract

This class provides an interface to solvers for eigenvalue problems. More...

#include <eigen_solver.h>

Inheritance diagram for libMesh::EigenSolver< T >:
[legend]

Public Member Functions

 EigenSolver (const Parallel::Communicator &comm_in)
 Constructor. More...
 
virtual ~EigenSolver ()
 Destructor. More...
 
bool initialized () const
 
bool get_close_matrix_before_solve () const
 
void set_close_matrix_before_solve (bool val)
 Set the flag which controls whether libmesh closes the eigenproblem matrices before solving. More...
 
virtual void clear ()
 Release all memory and clear data structures. More...
 
virtual void init ()=0
 Initialize data structures if not done so already. More...
 
EigenSolverType eigen_solver_type () const
 
EigenProblemType eigen_problem_type () const
 
PositionOfSpectrum position_of_spectrum () const
 
void set_eigensolver_type (const EigenSolverType est)
 Sets the type of eigensolver to use. More...
 
void set_eigenproblem_type (EigenProblemType ept)
 Sets the type of the eigenproblem. More...
 
void set_position_of_spectrum (PositionOfSpectrum pos)
 Sets the position of the spectrum. More...
 
void set_position_of_spectrum (Real pos)
 
void set_position_of_spectrum (Real pos, PositionOfSpectrum target)
 
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
 Solves the standard eigenproblem involving the SparseMatrix matrix_A. More...
 
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
 Solves the standard eigenproblem involving the ShellMatrix matrix_A. More...
 
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
 Solves the generalized eigenproblem involving SparseMatrices matrix_A and matrix_B. More...
 
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
 Solves the generalized eigenproblem with ShellMatrix matrix_A and SparseMatrix matrix_B. More...
 
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
 Solves the generalized eigenproblem with SparseMatrix matrix_A and ShellMatrix matrix_B. More...
 
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
 Solves the generalized eigenproblem involving ShellMatrices matrix_A and matrix_B. More...
 
virtual std::pair< Real, Realget_eigenpair (dof_id_type i, NumericVector< T > &solution)=0
 
virtual std::pair< Real, Realget_eigenvalue (dof_id_type i)=0
 
virtual void attach_deflation_space (NumericVector< T > &deflation_vector)=0
 Attach a deflation space defined by a single vector. More...
 
virtual void set_initial_space (NumericVector< T > &initial_space_in)=0
 Provide one basis vector for the initial guess. More...
 
void set_solver_configuration (SolverConfiguration &solver_configuration)
 Set the solver configuration object. More...
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static std::unique_ptr< EigenSolver< T > > build (const Parallel::Communicator &comm_in, const SolverPackage solver_package=SLEPC_SOLVERS)
 Builds an EigenSolver using the linear solver package specified by solver_package. More...
 
static std::string get_info ()
 Gets a string containing the reference information. More...
 
static void print_info (std::ostream &out=libMesh::out)
 Prints the reference information, by default to libMesh::out. More...
 
static unsigned int n_objects ()
 Prints the number of outstanding (created, but not yet destroyed) objects. More...
 
static void enable_print_counter_info ()
 Methods to enable/disable the reference counter output from print_info() More...
 
static void disable_print_counter_info ()
 

Protected Types

typedef std::map< std::string, std::pair< unsigned int, unsigned int > > Counts
 Data structure to log the information. More...
 

Protected Member Functions

void increment_constructor_count (const std::string &name)
 Increments the construction counter. More...
 
void increment_destructor_count (const std::string &name)
 Increments the destruction counter. More...
 

Protected Attributes

EigenSolverType _eigen_solver_type
 Enum stating which type of eigensolver to use. More...
 
EigenProblemType _eigen_problem_type
 Enum stating which type of eigen problem we deal with. More...
 
PositionOfSpectrum _position_of_spectrum
 Enum stating where to evaluate the spectrum. More...
 
bool _is_initialized
 Flag indicating if the data structures have been initialized. More...
 
SolverConfiguration_solver_configuration
 Optionally store a SolverOptions object that can be used to set parameters like solver type, tolerances and iteration limits. More...
 
Real _target_val
 
bool _close_matrix_before_solve
 
const Parallel::Communicator_communicator
 

Static Protected Attributes

static Counts _counts
 Actually holds the data. More...
 
static Threads::atomic< unsigned int > _n_objects
 The number of objects. More...
 
static Threads::spin_mutex _mutex
 Mutual exclusion object to enable thread-safe reference counting. More...
 
static bool _enable_print_counter
 Flag to control whether reference count information is printed when print_info is called. More...
 

Detailed Description

template<typename T>
class libMesh::EigenSolver< T >

This class provides an interface to solvers for eigenvalue problems.

Author
Steffen Peterson
Date
2005 Base class which defines the interface for solving eigenproblems.

Definition at line 68 of file eigen_solver.h.

Member Typedef Documentation

◆ Counts

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

Data structure to log the information.

The log is identified by the class name.

Definition at line 117 of file reference_counter.h.

Constructor & Destructor Documentation

◆ EigenSolver()

template<typename T >
libMesh::EigenSolver< T >::EigenSolver ( const Parallel::Communicator comm_in)

Constructor.

Initializes Solver data structures

◆ ~EigenSolver()

template<typename T >
virtual libMesh::EigenSolver< T >::~EigenSolver ( )
virtual

Destructor.

Member Function Documentation

◆ attach_deflation_space()

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

Attach a deflation space defined by a single vector.

Implemented in libMesh::SlepcEigenSolver< T >.

◆ build()

template<typename T >
static std::unique_ptr<EigenSolver<T> > libMesh::EigenSolver< T >::build ( const Parallel::Communicator comm_in,
const SolverPackage  solver_package = SLEPC_SOLVERS 
)
static

Builds an EigenSolver using the linear solver package specified by solver_package.

◆ clear()

template<typename T >
virtual void libMesh::EigenSolver< T >::clear ( )
virtual

Release all memory and clear data structures.

Reimplemented in libMesh::SlepcEigenSolver< T >.

Definition at line 120 of file eigen_solver.h.

120 {}

◆ comm()

const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inherited

◆ disable_print_counter_info()

static void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

◆ eigen_problem_type()

template<typename T >
EigenProblemType libMesh::EigenSolver< T >::eigen_problem_type ( ) const
Returns
The type of the eigen problem.

Definition at line 135 of file eigen_solver.h.

References libMesh::EigenSolver< T >::_eigen_problem_type.

135 { return _eigen_problem_type;}
EigenProblemType _eigen_problem_type
Enum stating which type of eigen problem we deal with.
Definition: eigen_solver.h:285

◆ eigen_solver_type()

template<typename T >
EigenSolverType libMesh::EigenSolver< T >::eigen_solver_type ( ) const
Returns
The type of eigensolver to use.

Definition at line 130 of file eigen_solver.h.

References libMesh::EigenSolver< T >::_eigen_solver_type.

130 { return _eigen_solver_type; }
EigenSolverType _eigen_solver_type
Enum stating which type of eigensolver to use.
Definition: eigen_solver.h:280

◆ enable_print_counter_info()

static void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

Methods to enable/disable the reference counter output from print_info()

◆ get_close_matrix_before_solve()

template<typename T >
bool libMesh::EigenSolver< T >::get_close_matrix_before_solve ( ) const
Returns
The value of the flag which controls whether libmesh closes the eigenproblem matrices before solving. true by default.

Definition at line 101 of file eigen_solver.h.

References libMesh::EigenSolver< T >::_close_matrix_before_solve.

102  {
103  libmesh_experimental();
105  }

◆ get_eigenpair()

template<typename T >
virtual std::pair<Real, Real> libMesh::EigenSolver< T >::get_eigenpair ( dof_id_type  i,
NumericVector< T > &  solution 
)
pure virtual
Returns
The ith eigenvalue (real and imaginary part), and copies the ith eigenvector into the solution vector.

Implemented in libMesh::SlepcEigenSolver< T >.

◆ get_eigenvalue()

template<typename T >
virtual std::pair<Real, Real> libMesh::EigenSolver< T >::get_eigenvalue ( dof_id_type  i)
pure virtual
Returns
The ith eigenvalue (real and imaginary part).

Same as above function, except it does not copy the eigenvector.

Implemented in libMesh::SlepcEigenSolver< T >.

◆ get_info()

static std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

Gets a string containing the reference information.

◆ increment_constructor_count()

void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
protectedinherited

Increments the construction counter.

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

Definition at line 181 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

182 {
183  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
184  std::pair<unsigned int, unsigned int> & p = _counts[name];
185 
186  p.first++;
187 }
std::string name(const ElemQuality q)
static Counts _counts
Actually holds the data.
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.

◆ increment_destructor_count()

void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
protectedinherited

Increments the destruction counter.

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

Definition at line 194 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().

195 {
196  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
197  std::pair<unsigned int, unsigned int> & p = _counts[name];
198 
199  p.second++;
200 }
std::string name(const ElemQuality q)
static Counts _counts
Actually holds the data.
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.

◆ init()

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

Initialize data structures if not done so already.

Implemented in libMesh::SlepcEigenSolver< T >.

◆ initialized()

template<typename T >
bool libMesh::EigenSolver< T >::initialized ( ) const
Returns
true if the data structures are initialized, false otherwise.

Definition at line 94 of file eigen_solver.h.

References libMesh::EigenSolver< T >::_is_initialized.

94 { return _is_initialized; }
bool _is_initialized
Flag indicating if the data structures have been initialized.
Definition: eigen_solver.h:295

◆ n_objects()

static unsigned int libMesh::ReferenceCounter::n_objects ( )
staticinherited

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

Definition at line 83 of file reference_counter.h.

References libMesh::ReferenceCounter::_n_objects.

84  { return _n_objects; }
static Threads::atomic< unsigned int > _n_objects
The number of objects.

◆ n_processors()

processor_id_type libMesh::ParallelObject::n_processors ( ) const
inherited
Returns
The number of processors in the group.

Definition at line 93 of file parallel_object.h.

References libMesh::ParallelObject::_communicator, and libMesh::Parallel::Communicator::size().

Referenced by libMesh::MeshBase::partition().

94  { return cast_int<processor_id_type>(_communicator.size()); }
processor_id_type size() const
Definition: communicator.h:175
const Parallel::Communicator & _communicator

◆ position_of_spectrum()

template<typename T >
PositionOfSpectrum libMesh::EigenSolver< T >::position_of_spectrum ( ) const
Returns
The position of the spectrum to compute.

Definition at line 140 of file eigen_solver.h.

References libMesh::EigenSolver< T >::_position_of_spectrum.

141  { return _position_of_spectrum;}
PositionOfSpectrum _position_of_spectrum
Enum stating where to evaluate the spectrum.
Definition: eigen_solver.h:290

◆ print_info()

static void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out)
staticinherited

Prints the reference information, by default to libMesh::out.

◆ processor_id()

processor_id_type libMesh::ParallelObject::processor_id ( ) const
inherited

◆ set_close_matrix_before_solve()

template<typename T >
void libMesh::EigenSolver< T >::set_close_matrix_before_solve ( bool  val)

Set the flag which controls whether libmesh closes the eigenproblem matrices before solving.

Definition at line 111 of file eigen_solver.h.

References libMesh::EigenSolver< T >::_close_matrix_before_solve.

112  {
113  libmesh_experimental();
115  }

◆ set_eigenproblem_type()

template<typename T >
void libMesh::EigenSolver< T >::set_eigenproblem_type ( EigenProblemType  ept)

Sets the type of the eigenproblem.

Definition at line 152 of file eigen_solver.h.

References libMesh::EigenSolver< T >::_eigen_problem_type.

153  {_eigen_problem_type = ept;}
EigenProblemType _eigen_problem_type
Enum stating which type of eigen problem we deal with.
Definition: eigen_solver.h:285

◆ set_eigensolver_type()

template<typename T >
void libMesh::EigenSolver< T >::set_eigensolver_type ( const EigenSolverType  est)

Sets the type of eigensolver to use.

Definition at line 146 of file eigen_solver.h.

References libMesh::EigenSolver< T >::_eigen_solver_type.

147  { _eigen_solver_type = est; }
EigenSolverType _eigen_solver_type
Enum stating which type of eigensolver to use.
Definition: eigen_solver.h:280

◆ set_initial_space()

template<typename T >
virtual void libMesh::EigenSolver< T >::set_initial_space ( NumericVector< T > &  initial_space_in)
pure virtual

Provide one basis vector for the initial guess.

Implemented in libMesh::SlepcEigenSolver< T >.

◆ set_position_of_spectrum() [1/3]

template<typename T >
void libMesh::EigenSolver< T >::set_position_of_spectrum ( PositionOfSpectrum  pos)

Sets the position of the spectrum.

Definition at line 158 of file eigen_solver.h.

References libMesh::EigenSolver< T >::_position_of_spectrum.

159  {_position_of_spectrum= pos;}
PositionOfSpectrum _position_of_spectrum
Enum stating where to evaluate the spectrum.
Definition: eigen_solver.h:290

◆ set_position_of_spectrum() [2/3]

template<typename T >
void libMesh::EigenSolver< T >::set_position_of_spectrum ( Real  pos)

◆ set_position_of_spectrum() [3/3]

template<typename T >
void libMesh::EigenSolver< T >::set_position_of_spectrum ( Real  pos,
PositionOfSpectrum  target 
)

◆ set_solver_configuration()

template<typename T >
void libMesh::EigenSolver< T >::set_solver_configuration ( SolverConfiguration solver_configuration)

Set the solver configuration object.

◆ solve_generalized() [1/4]

template<typename T >
virtual std::pair<unsigned int, unsigned int> libMesh::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 eigenproblem involving SparseMatrices matrix_A and matrix_B.

Returns
The number of converged eigenpairs and the number of iterations.

Implemented in libMesh::SlepcEigenSolver< T >.

◆ solve_generalized() [2/4]

template<typename T >
virtual std::pair<unsigned int, unsigned int> libMesh::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 eigenproblem with ShellMatrix matrix_A and SparseMatrix matrix_B.

Returns
The number of converged eigenpairs and the number of iterations.

Implemented in libMesh::SlepcEigenSolver< T >.

◆ solve_generalized() [3/4]

template<typename T >
virtual std::pair<unsigned int, unsigned int> libMesh::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 eigenproblem with SparseMatrix matrix_A and ShellMatrix matrix_B.

Returns
The number of converged eigenpairs and the number of iterations.

Implemented in libMesh::SlepcEigenSolver< T >.

◆ solve_generalized() [4/4]

template<typename T >
virtual std::pair<unsigned int, unsigned int> libMesh::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 eigenproblem involving ShellMatrices matrix_A and matrix_B.

Returns
The number of converged eigenpairs and the number of iterations.

Implemented in libMesh::SlepcEigenSolver< T >.

◆ solve_standard() [1/2]

template<typename T >
virtual std::pair<unsigned int, unsigned int> libMesh::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 eigenproblem involving the SparseMatrix matrix_A.

Returns
The number of converged eigenpairs and the number of iterations.

Implemented in libMesh::SlepcEigenSolver< T >.

◆ solve_standard() [2/2]

template<typename T >
virtual std::pair<unsigned int, unsigned int> libMesh::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 eigenproblem involving the ShellMatrix matrix_A.

Returns
The number of converged eigenpairs and the number of iterations.

Implemented in libMesh::SlepcEigenSolver< T >.

Member Data Documentation

◆ _close_matrix_before_solve

template<typename T >
bool libMesh::EigenSolver< T >::_close_matrix_before_solve
protected

◆ _communicator

const Parallel::Communicator& libMesh::ParallelObject::_communicator
protectedinherited

◆ _counts

Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited

◆ _eigen_problem_type

template<typename T >
EigenProblemType libMesh::EigenSolver< T >::_eigen_problem_type
protected

Enum stating which type of eigen problem we deal with.

Definition at line 285 of file eigen_solver.h.

Referenced by libMesh::EigenSolver< T >::eigen_problem_type(), and libMesh::EigenSolver< T >::set_eigenproblem_type().

◆ _eigen_solver_type

template<typename T >
EigenSolverType libMesh::EigenSolver< T >::_eigen_solver_type
protected

Enum stating which type of eigensolver to use.

Definition at line 280 of file eigen_solver.h.

Referenced by libMesh::EigenSolver< T >::eigen_solver_type(), and libMesh::EigenSolver< T >::set_eigensolver_type().

◆ _enable_print_counter

bool libMesh::ReferenceCounter::_enable_print_counter
staticprotectedinherited

Flag to control whether reference count information is printed when print_info is called.

Definition at line 141 of file reference_counter.h.

◆ _is_initialized

template<typename T >
bool libMesh::EigenSolver< T >::_is_initialized
protected

Flag indicating if the data structures have been initialized.

Definition at line 295 of file eigen_solver.h.

Referenced by libMesh::EigenSolver< T >::initialized().

◆ _mutex

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 135 of file reference_counter.h.

◆ _n_objects

Threads::atomic<unsigned int> libMesh::ReferenceCounter::_n_objects
staticprotectedinherited

The number of objects.

Print the reference count information when the number returns to 0.

Definition at line 130 of file reference_counter.h.

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

◆ _position_of_spectrum

template<typename T >
PositionOfSpectrum libMesh::EigenSolver< T >::_position_of_spectrum
protected

Enum stating where to evaluate the spectrum.

Definition at line 290 of file eigen_solver.h.

Referenced by libMesh::EigenSolver< T >::position_of_spectrum(), and libMesh::EigenSolver< T >::set_position_of_spectrum().

◆ _solver_configuration

template<typename T >
SolverConfiguration* libMesh::EigenSolver< T >::_solver_configuration
protected

Optionally store a SolverOptions object that can be used to set parameters like solver type, tolerances and iteration limits.

Definition at line 301 of file eigen_solver.h.

◆ _target_val

template<typename T >
Real libMesh::EigenSolver< T >::_target_val
protected

Definition at line 303 of file eigen_solver.h.


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