DOLFINx 0.12.0.0
DOLFINx C++
Loading...
Searching...
No Matches
slepc.h
1// Copyright (C) 2005-2018 Garth N. Wells
2//
3// This file is part of DOLFINx (https://www.fenicsproject.org)
4//
5// SPDX-License-Identifier: LGPL-3.0-or-later
6
7#pragma once
8
9#ifdef HAS_SLEPC
10
11#include <complex>
12#include <dolfinx/common/MPI.h>
13#include <petscmat.h>
14#include <petscvec.h>
15#include <slepceps.h>
16#include <string>
17#include <string_view>
18
19namespace dolfinx::la
20{
21
25{
26public:
31 explicit SLEPcEigenSolver(MPI_Comm comm);
32
39 SLEPcEigenSolver(EPS eps, bool inc_ref_count);
40
41 // Copy constructor (deleted)
42 SLEPcEigenSolver(const SLEPcEigenSolver&) = delete;
43
45 SLEPcEigenSolver(SLEPcEigenSolver&& solver) noexcept;
46
49
50 // Assignment operator (deleted)
51 SLEPcEigenSolver& operator=(const SLEPcEigenSolver&) = delete;
52
54 SLEPcEigenSolver& operator=(SLEPcEigenSolver&& solver) noexcept;
55
62 void set_operators(const Mat A, const Mat B);
63
83 [[nodiscard(
84 "check the converged reason - positive on convergence, negative on "
85 "divergence")]] EPSConvergedReason
86 solve();
87
93 std::complex<PetscReal> get_eigenvalue(PetscInt i) const;
94
106 void get_eigenpair(PetscScalar& lr, PetscScalar& lc, Vec r, Vec c,
107 PetscInt i) const;
108
111 void set_options_prefix(std::string_view options_prefix);
112
115 std::string get_options_prefix() const;
116
120 void set_from_options() const;
121
123 EPS eps() const;
124
126 MPI_Comm comm() const;
127
128private:
129 // SLEPc solver pointer
130 EPS _eps;
131};
132} // namespace dolfinx::la
133#endif
std::complex< PetscReal > get_eigenvalue(PetscInt i) const
Get the ith eigenvalue.
Definition slepc.cpp:95
std::string get_options_prefix() const
Definition slepc.cpp:132
~SLEPcEigenSolver()
Destructor.
Definition slepc.cpp:43
void set_options_prefix(std::string_view options_prefix)
Definition slepc.cpp:124
void set_from_options() const
Set options from the PETSc options database.
Definition slepc.cpp:141
MPI_Comm comm() const
Return MPI communicator.
Definition slepc.cpp:149
void set_operators(const Mat A, const Mat B)
Set the operators defining the eigenvalue problem.
Definition slepc.cpp:58
EPSConvergedReason solve()
Solve the eigenvalue problem (or ).
Definition slepc.cpp:65
void get_eigenpair(PetscScalar &lr, PetscScalar &lc, Vec r, Vec c, PetscInt i) const
Get the ith eigenpair.
Definition slepc.cpp:113
SLEPcEigenSolver(MPI_Comm comm)
Create eigenvalue solver.
Definition slepc.cpp:20
EPS eps() const
Return SLEPc EPS pointer.
Definition slepc.cpp:147
Linear algebra interface.
Definition dolfinx_la.h:7