CppNoddy  0.92
Loading...
Searching...
No Matches
SparseLinearEigenSystem.h
Go to the documentation of this file.
1/// \file SparseLinearEigenSystem.h
2/// Specification of the sparse linear eigensystem class.
3/// This class links to complex SLEPc to perform the solver phase.
4
5#ifndef SPARSELINEAREIGENSYSTEM_BASE_H
6#define SPARSELINEAREIGENSYSTEM_BASE_H
7
8#include <set>
9#include <SparseMatrix.h>
10#include <Uncopyable.h>
11#include <Types.h>
13
14#ifdef SLEPC
15#include <slepc.h>
16
17namespace CppNoddy {
18 PetscErrorCode monitor_function(EPS eps, PetscInt its,PetscInt nconv,
19 PetscScalar *eigr,PetscScalar *eigi,
20 PetscReal* errest,
21 PetscInt nest,void *mctx) {
22 std::cout << "[MONITOR] nconv = " << nconv;
23 std::cout << " its = " << its << "\n";
24 std::cout << "[MONITOR] est_err() = ";
25 for(int i = 0; i < nest; i++) {
26 std::cout << errest[i] << " ";
27 }
28 std::cout << "\n";
29 return 0;
30 }
31
32 /// A linear Nth-order generalised eigensystem class.
33 /// Here we can construct a linear eigenproblem in the form
34 /// \f[ A_{NxN} \,{\underline x}_i = \lambda_i\, B_{NxN}\, {\underline x}_i \f]
35 /// for Banded double/complex matrices \f$ A \f$ and \f$ B \f$. The eigenvalues
36 /// and eigenvectors can be tagged and retrieved as required.
37 template <typename _Type>
38 class SparseLinearEigenSystem : public LinearEigenSystem_base {
39
40 public:
41
42 /// Constructor for a linear system object.
43 /// \param Aptr A pointer to a typed A matrix
44 /// \param Bptr A pointer to a typed B matrix
45 SparseLinearEigenSystem(SparseMatrix<_Type>* Aptr, SparseMatrix<_Type>* Bptr);
46
47 /// Destructor for a linear system object.
48 ~SparseLinearEigenSystem();
49
50 /// Access the (actual) number of (converged) eigenvalues found.
51 /// \return A hande to the number of eigenvalues
52 unsigned get_nconv() const;
53
54 /// Request a certain number of eigenvalues (not guaranteed)
55 /// \param n The number of eigenvalues being asked for
56 void set_nev(unsigned n);
57
58 /// Set target for the shift-invert algorithm.
59 /// \param target The target eigenvalue
60 void set_target(std::complex<double> target);
61
62 /// Defines the ordering of returned set of eigenvalues/vectors
63 /// \param order_string A string that defines the SLEPc enum options
64 /// for ordering (see EPSWhich)
65 void set_order(std::string order_string);
66
67 /// Gives a handle to the boolean that sets a region in the complex plane
68 bool& region_defined();
69
70 /// Set a rectangular region of the complex plane in which to look for eigenvalues.
71 /// Calling this will also set REGION_DEFINED to true.
72 /// \param a Real=a defines left edge of the rectangular region
73 /// \param b Real=b defines right edge of the rectangular region
74 /// \param c Imag=c defines bottom edge of the rectangular region
75 /// \param d Imag=d defines top edge of the rectangular region
76 void set_region(const double& a, const double& b, const double& c, const double& d);
77
78 /// Gives a handle to the boolean that sets if an initial guess has been used
79 bool& guess_defined();
80
81 /// Set the initial guess
82 /// \param guess The vector of the guess
83 void set_initial_guess(const DenseVector<_Type>& guess);
84
85 /// Solve the matrix linear eigensystem
86 void eigensolve();
87
88 private:
89
90 /// Solve the generalised eigenproblem and compute eigenvectors
91 void eigensolve_slepc();
92
93 /// number of eigenvalues requested
94 unsigned m_nev;
95 /// number of (converged) eigenvalues located by the solver will be changed by the solver.
96 unsigned m_nconv;
97
98 /// defines how to seek and order eigenvalues (e.g. smallest real part?)
99 EPSWhich m_order;
100
101 /// defines if ev's are to be sought in a specific region
102 bool m_region_defined;
103 /// defines if an initial guess is to be used
104 bool m_guess_defined;
105
106 /// four numbers that define a rectangular region in the complex plane
107 double m_real_left,m_real_right,m_imag_bottom,m_imag_top;
108
109 /// stores an initial guess to work with
110 DenseVector<_Type> m_initial_guess;
111
112 /// pointer to the LHS matrix
113 SparseMatrix<_Type>* m_pA;
114 /// pointer to the RHS matrix
115 SparseMatrix<_Type>* m_pB;
116
117 // SLEPc* p_LIBRARY;
118 };
119
120} //end namepsace
121#endif
122
123
124#endif
Specification of the linear eigensystem base class.
A matrix class that constructs a SPARSE matrix as an STL Vector of SparseVectors, inheriting from Mat...
Some standard typedefs.
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...

© 2012

R.E. Hewitt