DOLFIN-X
DOLFIN-X C++ interface
SLEPcEigenSolver.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 "dolfinx/common/MPI.h"
12 #include "dolfinx/common/types.h"
13 #include <memory>
14 #include <petscmat.h>
15 #include <petscvec.h>
16 #include <slepceps.h>
17 #include <string>
18 
19 namespace dolfinx
20 {
21 namespace la
22 {
23 class VectorSpaceBasis;
24 
27 
28 class SLEPcEigenSolver
29 {
30 public:
32  explicit SLEPcEigenSolver(MPI_Comm comm);
33 
35  explicit SLEPcEigenSolver(EPS eps, bool inc_ref_count = true);
36 
38  ~SLEPcEigenSolver();
39 
42  void set_operators(const Mat A, const Mat B);
43 
45  void solve();
46 
48  void solve(std::int64_t n);
49 
51  std::complex<PetscReal> get_eigenvalue(std::size_t i) const;
52 
54  void get_eigenpair(PetscScalar& lr, PetscScalar& lc, Vec r, Vec c,
55  std::size_t i) const;
56 
58  std::size_t get_iteration_number() const;
59 
61  std::size_t get_number_converged() const;
62 
65  void set_options_prefix(std::string options_prefix);
66 
69  std::string get_options_prefix() const;
70 
72  void set_from_options() const;
73 
75  EPS eps() const;
76 
78  MPI_Comm mpi_comm() const;
79 
80 private:
81  // SLEPc solver pointer
82  EPS _eps;
83 };
84 } // namespace la
85 } // namespace dolfinx
86 #endif