20 #ifndef LIBMESH_SLEPC_EIGEN_SOLVER_H 21 #define LIBMESH_SLEPC_EIGEN_SOLVER_H 23 #include "libmesh/libmesh_config.h" 25 #ifdef LIBMESH_HAVE_SLEPC 28 #include "libmesh/eigen_solver.h" 29 #include "libmesh/slepc_macro.h" 32 EXTERN_C_FOR_SLEPC_BEGIN
33 # include "libmesh/ignore_warnings.h" 34 # include <slepceps.h> 35 # include "libmesh/restore_warnings.h" 36 EXTERN_C_FOR_SLEPC_END
40 template <
typename T>
class PetscVector;
72 virtual void clear() noexcept
override;
78 virtual void init()
override;
91 virtual std::pair<unsigned int, unsigned int>
96 const unsigned int m_its)
override;
102 virtual std::pair<unsigned int, unsigned int>
107 const unsigned int m_its)
override;
113 virtual std::pair<unsigned int, unsigned int>
119 const unsigned int m_its)
override;
125 virtual std::pair<unsigned int, unsigned int>
131 const unsigned int m_its)
override;
146 virtual std::pair<unsigned int, unsigned int>
152 const unsigned int m_its)
override;
158 virtual std::pair<unsigned int, unsigned int>
164 const unsigned int m_its)
override;
176 virtual std::pair<unsigned int, unsigned int>
182 const unsigned int m_its)
override;
194 virtual std::pair<unsigned int, unsigned int>
200 const unsigned int m_its)
override;
203 virtual std::pair<unsigned int, unsigned int>
210 const unsigned int m_its)
override;
212 virtual std::pair<unsigned int, unsigned int>
219 const unsigned int m_its)
override;
227 virtual std::pair<Real, Real>
234 virtual std::pair<Real, Real>
269 const unsigned int m_its);
280 const unsigned int m_its);
285 std::pair<unsigned int, unsigned int>
_solve_helper (Mat precond,
289 const unsigned int m_its);
337 #endif // #ifdef LIBMESH_HAVE_SLEPC 338 #endif // LIBMESH_SLEPC_EIGEN_SOLVER_H This class provides a nice interface to PETSc's Vec object.
std::pair< unsigned int, unsigned int > _solve_generalized_helper(Mat mat_A, Mat mat_B, Mat precond, int nev, int ncv, const double tol, const unsigned int m_its)
Helper function that actually performs the generalized eigensolve.
std::pair< unsigned int, unsigned int > _solve_helper(Mat precond, int nev, int ncv, const double tol, const unsigned int m_its)
Helper function that actually performs either eigensolve.
Real get_relative_error(unsigned int i)
This class provides an interface to the SLEPc eigenvalue solver library from http://slepc.upv.es/.
virtual std::pair< Real, Real > get_eigenvalue(dof_id_type i) override
Same as above, but does not copy the eigenvector.
PetscVector< T > * _initial_space
A vector used for initial space.
Provides a uniform interface to vector storage schemes for different linear algebra libraries...
static PetscErrorCode _petsc_shell_matrix_get_diagonal(Mat mat, Vec dest)
Internal function if shell matrix mode is used, this just calls the shell matrix's get_diagonal funct...
The libMesh namespace provides an interface to certain functionality in the library.
void set_slepc_solver_type()
Tells Slepc to use the user-specified solver stored in _eigen_solver_type.
virtual void set_initial_space(NumericVector< T > &initial_space_in) override
Use initial_space_in as the initial guess.
std::pair< unsigned int, unsigned int > _solve_standard_helper(Mat mat, Mat precond, int nev, int ncv, const double tol, const unsigned int m_its)
Helper function that actually performs the standard eigensolve.
void set_slepc_problem_type()
Tells Slepc to deal with the type of problem stored in _eigen_problem_type.
~SlepcEigenSolver()
Destructor.
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) override
This function calls the SLEPc solver to compute the eigenpairs of the SparseMatrix matrix_A...
EPS _eps
Eigenproblem solver context.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void clear() noexcept override
Release all memory and clear data structures.
static PetscErrorCode _petsc_shell_matrix_mult(Mat mat, Vec arg, Vec dest)
Internal function if shell matrix mode is used, this just calls the shell matrix's matrix multiplicat...
SlepcEigenSolver(const Parallel::Communicator &comm_in)
Constructor.
void set_slepc_position_of_spectrum()
Tells Slepc to compute the spectrum at the position stored in _position_of_spectrum.
virtual void init() override
Initialize data structures if not done so already.
Generic shell matrix, i.e.
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) override
This function calls the SLEPc solver to compute the eigenpairs for the generalized eigenproblem defin...
virtual void attach_deflation_space(NumericVector< T > &deflation_vector) override
Attach a deflation space defined by a single vector.
virtual std::pair< Real, Real > get_eigenpair(dof_id_type i, NumericVector< T > &solution_in) override
This class provides an interface to solvers for eigenvalue problems.