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 <memory>
13 #include <petscmat.h>
14 #include <petscvec.h>
15 #include <slepceps.h>
16 #include <string>
17 
18 namespace dolfinx
19 {
20 namespace la
21 {
22 class VectorSpaceBasis;
23 
26 
27 class SLEPcEigenSolver
28 {
29 public:
31  explicit SLEPcEigenSolver(MPI_Comm comm);
32 
34  explicit SLEPcEigenSolver(EPS eps, bool inc_ref_count = true);
35 
37  ~SLEPcEigenSolver();
38 
41  void set_operators(const Mat A, const Mat B);
42 
44  void solve();
45 
47  void solve(std::int64_t n);
48 
50  std::complex<PetscReal> get_eigenvalue(int i) const;
51 
53  void get_eigenpair(PetscScalar& lr, PetscScalar& lc, Vec r, Vec c,
54  int i) const;
55 
57  int get_iteration_number() const;
58 
60  std::int64_t get_number_converged() const;
61 
64  void set_options_prefix(std::string options_prefix);
65 
68  std::string get_options_prefix() const;
69 
71  void set_from_options() const;
72 
74  EPS eps() const;
75 
77  MPI_Comm mpi_comm() const;
78 
79 private:
80  // SLEPc solver pointer
81  EPS _eps;
82 };
83 } // namespace la
84 } // namespace dolfinx
85 #endif