DOLFINx 0.12.0.0
DOLFINx C++
Loading...
Searching...
No Matches
SLEPcEigenSolver Class Reference

This class provides an eigenvalue solver for PETSc matrices. It is a wrapper for the SLEPc eigenvalue solver. More...

#include <slepc.h>

Public Member Functions

 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.
SLEPcEigenSolveroperator= (const SLEPcEigenSolver &)=delete
SLEPcEigenSolveroperator= (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.

Detailed Description

This class provides an eigenvalue solver for PETSc matrices. It is a wrapper for the SLEPc eigenvalue solver.

Constructor & Destructor Documentation

◆ SLEPcEigenSolver() [1/2]

SLEPcEigenSolver ( MPI_Comm comm)
explicit

Create eigenvalue solver.

Note
SLEPc must have been initialised (SlepcInitialize) before this is called.
Parameters
[in]commMPI communicator.

◆ SLEPcEigenSolver() [2/2]

SLEPcEigenSolver ( EPS eps,
bool inc_ref_count )

Create eigenvalue solver from an existing EPS object.

Parameters
[in]epsSLEPc EPS object, which must already have been created. The reference count of eps is always decreased when this SLEPcEigenSolver is destroyed.
[in]inc_ref_countTrue if the reference count of eps should be incremented.

Member Function Documentation

◆ get_eigenpair()

void get_eigenpair ( PetscScalar & lr,
PetscScalar & lc,
Vec r,
Vec c,
PetscInt i ) const

Get the ith eigenpair.

Parameters
[out]lrReal part of the eigenvalue.
[out]lcImaginary part of the eigenvalue.
[out]rReal part of the eigenvector.
[out]cImaginary part of the eigenvector.
[in]iIndex 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]iIndex 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]AOperator 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]BRight-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: