This class provides an eigenvalue solver for PETSc matrices. It is a wrapper for the SLEPc eigenvalue solver.
More...
#include <slepc.h>
|
| | SLEPcEigenSolver (MPI_Comm comm) |
| | Create eigenvalue solver.
|
| | SLEPcEigenSolver (EPS eps, bool inc_ref_count) |
| | Create eigenvalue solver from an existing EPS object.
|
|
| SLEPcEigenSolver (const SLEPcEigenSolver &)=delete |
|
| SLEPcEigenSolver (SLEPcEigenSolver &&solver) noexcept |
| | Move constructor.
|
|
| ~SLEPcEigenSolver () |
| | Destructor.
|
|
SLEPcEigenSolver & | operator= (const SLEPcEigenSolver &)=delete |
|
SLEPcEigenSolver & | operator= (SLEPcEigenSolver &&solver) noexcept |
| | Move assignment.
|
| void | set_operators (const Mat A, const Mat B) |
| | Set the operators defining the eigenvalue problem.
|
| EPSConvergedReason | solve () |
| | Solve the eigenvalue problem \(A x = \lambda x\) (or \(A x = \lambda B x\)).
|
| std::complex< PetscReal > | get_eigenvalue (PetscInt i) const |
| | Get the ith eigenvalue.
|
| void | get_eigenpair (PetscScalar &lr, PetscScalar &lc, Vec r, Vec c, PetscInt i) const |
| | Get the ith eigenpair.
|
| void | set_options_prefix (std::string_view options_prefix) |
| std::string | get_options_prefix () const |
| void | set_from_options () const |
| | Set options from the PETSc options database.
|
|
EPS | eps () const |
| | Return SLEPc EPS pointer.
|
|
MPI_Comm | comm () const |
| | Return MPI communicator.
|
This class provides an eigenvalue solver for PETSc matrices. It is a wrapper for the SLEPc eigenvalue solver.
◆ SLEPcEigenSolver() [1/2]
| SLEPcEigenSolver |
( |
MPI_Comm | comm | ) |
|
|
explicit |
Create eigenvalue solver.
- Note
- SLEPc must have been initialised (SlepcInitialize) before this is called.
- Parameters
-
| [in] | comm | MPI communicator. |
◆ SLEPcEigenSolver() [2/2]
| SLEPcEigenSolver |
( |
EPS | eps, |
|
|
bool | inc_ref_count ) |
Create eigenvalue solver from an existing EPS object.
- Parameters
-
| [in] | eps | SLEPc EPS object, which must already have been created. The reference count of eps is always decreased when this SLEPcEigenSolver is destroyed. |
| [in] | inc_ref_count | True if the reference count of eps should be incremented. |
◆ get_eigenpair()
| void get_eigenpair |
( |
PetscScalar & | lr, |
|
|
PetscScalar & | lc, |
|
|
Vec | r, |
|
|
Vec | c, |
|
|
PetscInt | i ) const |
Get the ith eigenpair.
- Parameters
-
| [out] | lr | Real part of the eigenvalue. |
| [out] | lc | Imaginary part of the eigenvalue. |
| [out] | r | Real part of the eigenvector. |
| [out] | c | Imaginary part of the eigenvector. |
| [in] | i | Index of the eigenpair, in [0, nconv), where nconv is the number of converged eigenpairs reported by EPSGetConverged(eps(), &nconv). |
- Note
- For a complex PETSc scalar type the eigenvalue and eigenvector are held entirely in lr and r, and lc and c are set to zero.
◆ get_eigenvalue()
| std::complex< PetscReal > get_eigenvalue |
( |
PetscInt | i | ) |
const |
Get the ith eigenvalue.
- Parameters
-
| [in] | i | Index of the eigenvalue, in [0, nconv), where nconv is the number of converged eigenpairs reported by EPSGetConverged(eps(), &nconv). |
- Returns
- The eigenvalue.
◆ get_options_prefix()
| std::string get_options_prefix |
( |
| ) |
const |
Returns the prefix used by PETSc when searching the PETSc options database
◆ set_from_options()
| void set_from_options |
( |
| ) |
const |
Set options from the PETSc options database.
- Note
- Call after set_options_prefix and after any settings the database should override.
◆ set_operators()
| void set_operators |
( |
const Mat | A, |
|
|
const Mat | B ) |
Set the operators defining the eigenvalue problem.
- Parameters
-
| [in] | A | Operator for the standard problem \(A x = \lambda x\), or the left-hand operator of the generalised problem \(A x = \lambda B x\). Must not be null. |
| [in] | B | Right-hand operator of the generalised problem, or nullptr for a standard eigenvalue problem. |
◆ set_options_prefix()
| void set_options_prefix |
( |
std::string_view | options_prefix | ) |
|
Sets the prefix used by PETSc when searching the PETSc options database
◆ solve()
| EPSConvergedReason solve |
( |
| ) |
|
|
nodiscard |
Solve the eigenvalue problem \(A x = \lambda x\) (or \(A x = \lambda B x\)).
Non-convergence is not treated as an error (a warning is logged); check the returned convergence reason.
- Note
- The number of eigenpairs to compute, and every other solver setting, is applied to the EPS object returned by eps(). SLEPc sizes its working subspace from the requested number, which defaults to one, e.g.
solver.set_operators(A, nullptr);
EPSSetDimensions(solver.eps(), 5, PETSC_DETERMINE, PETSC_DETERMINE);
EPSSetWhichEigenpairs(solver.eps(), EPS_SMALLEST_REAL);
solver.solve();
MPI_Comm comm() const
Return MPI communicator.
Definition slepc.cpp:149
SLEPcEigenSolver(MPI_Comm comm)
Create eigenvalue solver.
Definition slepc.cpp:20
- Returns
- The PETSc convergence reason (positive on convergence, negative on divergence).
The documentation for this class was generated from the following files:
- /__w/dolfinx/dolfinx/cpp/dolfinx/la/slepc.h
- /__w/dolfinx/dolfinx/cpp/dolfinx/la/slepc.cpp