gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
eigenSolver.h
Go to the documentation of this file.
1 // Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 
6 #ifndef EIGEN_SOLVER_H
7 #define EIGEN_SOLVER_H
8 
9 #include <string>
10 #include <complex>
11 #include "GmshConfig.h"
12 #include "GmshMessage.h"
13 #include "dofManager.h"
14 
15 #if defined(HAVE_SLEPC)
16 
17 #include "linearSystemPETSc.h"
18 
19 class eigenSolver {
20 private:
21  linearSystemPETSc<double> *_sysA, *_sysB;
22  bool _hermitian;
23  std::vector<std::complex<double> > _eigenValues;
24  std::vector<std::vector<std::complex<double> > > _eigenVectors;
25  void _check(int ierr) const;
26 
27 public:
28  eigenSolver(dofManager<double> *manager, std::string A, std::string B = "",
29  bool hermitian = true);
31  bool hermitian = true);
32  bool solve(int numEigenValues = 0, std::string which = "",
33  std::string method = "krylovschur", double tolVal = 1.e-7,
34  int iterMax = 20);
35 
36  int getNumEigenValues() { return _eigenValues.size(); }
37  int getNumberEigenvectors() { return _eigenVectors.size(); }
38 
39  std::complex<double> getEigenValue(int num) { return _eigenValues[num]; }
40  std::complex<double> getEigenVectorComp(int num, int com)
41  {
42  return _eigenVectors[num][com];
43  };
44  std::vector<std::complex<double> > &getEigenVector(int num)
45  {
46  return _eigenVectors[num];
47  }
48 
49  void normalize_mode(std::vector<int> modeView, double scale = 1.);
50 
51  void clear()
52  {
53  _eigenValues.clear();
54  _eigenVectors.clear();
55  };
56 };
57 
58 #else
59 
60 #include "linearSystemPETSc.h"
61 
62 class eigenSolver {
63 private:
64  std::vector<std::complex<double> > _dummy;
65 
66 public:
67  eigenSolver(dofManager<double> *manager, std::string A, std::string B = "",
68  bool hermitian = false)
69  {
70  }
72  bool hermitian = false)
73  {
74  }
75  bool solve(int = 0, std::string = "", std::string = "", double = 0, int = 0)
76  {
77  Msg::Error("Eigen solver requires SLEPc");
78  return false;
79  }
80  int getNumEigenValues() { return 0; }
81  int getNumberEigenvectors() { return 0; }
82  std::complex<double> getEigenValue(int num) { return 0.; }
83  std::complex<double> getEigenVectorComp(int num, int com) { return 0.; }
84  std::vector<std::complex<double> > &getEigenVector(int num) { return _dummy; }
85  void normalize_mode(std::vector<int> modeView, double scale = 1.) {}
86  void clear() {}
87 };
88 
89 #endif
90 
91 #endif
eigenSolver::getEigenVector
std::vector< std::complex< double > > & getEigenVector(int num)
Definition: eigenSolver.h:84
eigenSolver::getNumberEigenvectors
int getNumberEigenvectors()
Definition: eigenSolver.h:81
linearSystemPETSc
Definition: linearSystemPETSc.h:150
Msg::Error
static void Error(const char *fmt,...)
Definition: GmshMessage.cpp:482
eigenSolver::getEigenVectorComp
std::complex< double > getEigenVectorComp(int num, int com)
Definition: eigenSolver.h:83
linearSystemPETSc.h
eigenSolver::getEigenValue
std::complex< double > getEigenValue(int num)
Definition: eigenSolver.h:82
GmshMessage.h
eigenSolver::eigenSolver
eigenSolver(linearSystemPETSc< double > *A, linearSystemPETSc< double > *B=nullptr, bool hermitian=false)
Definition: eigenSolver.h:71
dofManager< double >
dofManager.h
eigenSolver::eigenSolver
eigenSolver(dofManager< double > *manager, std::string A, std::string B="", bool hermitian=false)
Definition: eigenSolver.h:67
eigenSolver
Definition: eigenSolver.h:62
eigenSolver::getNumEigenValues
int getNumEigenValues()
Definition: eigenSolver.h:80
eigenSolver::_dummy
std::vector< std::complex< double > > _dummy
Definition: eigenSolver.h:64
eigenSolver::normalize_mode
void normalize_mode(std::vector< int > modeView, double scale=1.)
Definition: eigenSolver.h:85
eigenSolver::clear
void clear()
Definition: eigenSolver.h:86
eigenSolver::solve
bool solve(int=0, std::string="", std::string="", double=0, int=0)
Definition: eigenSolver.h:75
scale
static void scale(std::vector< double > &x, double s)
Definition: ConjugateGradients.cpp:21