G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsEigenProblemBase.h
Go to the documentation of this file.
1
14#include <typeinfo>
15
17#ifdef gsSpectra_ENABLED
18#include <gsSpectra/gsSpectra.h>
19#endif
20#include <gsIO/gsOptionList.h>
22
23#pragma once
24
25
26namespace gismo
27{
28
36template <class T>
38{
39
40public:
41
43 {
44 m_options = defaultOptions();
45 m_status = gsStatus::NotStarted;
46 }
47
49
50public:
51
52 virtual gsOptionList defaultOptions()
53 {
55 options.addSwitch("verbose","Verbose output",false);
56 options.addInt("solver","Spectra solver to be used (see Spectra documentation):"
57 "0: Cholesky (default)"
58 "1: RegularInverse"
59 "2: ShiftInvert"
60 "3: Buckling"
61 "4: Cayley",0);
62
63 options.addInt("selectionRule","Selection rule to be used (see Spectra documentation):"
64 "0: LargestMagn"
65 "1: LargestReal"
66 "2: LargestImag"
67 "3: LargestAlge"
68 "4: SmallestMagn"
69 "5: SmallestReal"
70 "6: SmallestImag"
71 "7: SmallestAlge"
72 "8: BothEnds",4);
73
74 options.addInt("sortRule","Sort rule to be used (see Spectra documentation):"
75 "0: LargestMagn"
76 "1: LargestReal"
77 "2: LargestImag"
78 "3: LargestAlge"
79 "4: SmallestMagn"
80 "5: SmallestReal"
81 "6: SmallestImag"
82 "7: SmallestAlge"
83 "8: BothEnds",4);
84
85 options.addInt("ncvFac","Factor for Spectra's ncv number. Ncv = ncvFac * numEigenvalues",3);
86 options.addReal("tolerance","Tolerance for spectra and the power method",1e-10);
87 options.addReal("shift","Shift for the eigenvalue solver",0.0);
88 return options;
89 }
90
92 gsOptionList & options() {return m_options; };
93
95 virtual void setOptions(gsOptionList & options) {m_options.update(options,gsOptionList::addIfUnknown); }
96
97 virtual gsStatus compute();
98
99 virtual gsStatus computeSparse(const index_t number = 10);
100
101 virtual gsStatus computePower();
102
103 virtual const gsMatrix<T> & values() const { return m_values; };
104 virtual T value(int k) const { return m_values.at(k); };
105
106 virtual const gsMatrix<T> & vectors() const { return m_vectors; };
107 virtual gsMatrix<T> vector(int k) const { return m_vectors.col(k); };
108
109 virtual std::vector<std::pair<T,gsMatrix<T>> > mode(int k) const {return makeMode(k); }
110
111protected:
112
113 virtual std::vector<std::pair<T,gsMatrix<T>> > makeMode(int k) const;
114
115private:
116 #ifdef gsSpectra_ENABLED
117 template<Spectra::GEigsMode _GEigsMode>
118 typename std::enable_if<_GEigsMode==Spectra::GEigsMode::Cholesky ||
119 _GEigsMode==Spectra::GEigsMode::RegularInverse
120 ,
121 gsStatus>::type computeSparse_impl(index_t number);
122 #endif
123
124 #ifdef gsSpectra_ENABLED
125 template<Spectra::GEigsMode _GEigsMode>
126 typename std::enable_if<_GEigsMode==Spectra::GEigsMode::ShiftInvert ||
127 _GEigsMode==Spectra::GEigsMode::Buckling ||
128 _GEigsMode==Spectra::GEigsMode::Cayley
129 ,
130 gsStatus>::type computeSparse_impl(index_t number);
131 #endif
132
133protected:
134
135 gsSparseMatrix<T> m_A;
136 gsSparseMatrix<T> m_B;
137
138 gsOptionList m_options;
139
140 gsEigen::GeneralizedSelfAdjointEigenSolver< typename gsMatrix<T>::Base > m_eigSolver;
141
142 gsMatrix<T> m_values,m_vectors;
143
144 index_t m_num;
145
146 gsStatus m_status;
147};
148
149
150} // namespace gismo
151
152
153#ifndef GISMO_BUILD_LIB
154#include GISMO_HPP_HEADER(gsEigenProblemBase.hpp)
155#endif
Base class for buckling and modal analyses.
Definition gsEigenProblemBase.h:38
gsOptionList & options()
Get options.
Definition gsEigenProblemBase.h:92
virtual void setOptions(gsOptionList &options)
Set the options from options.
Definition gsEigenProblemBase.h:95
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
T at(index_t i) const
Returns the i-th element of the vectorization of the matrix.
Definition gsMatrix.h:211
Class which holds a list of parameters/options, and provides easy access to them.
Definition gsOptionList.h:33
void addInt(const std::string &label, const std::string &desc, const index_t &value)
Adds a option named label, with description desc and value value.
Definition gsOptionList.cpp:201
void update(const gsOptionList &other, updateType type=ignoreIfUnknown)
Updates the object using the data from other.
Definition gsOptionList.cpp:253
void addReal(const std::string &label, const std::string &desc, const Real &value)
Adds a option named label, with description desc and value value.
Definition gsOptionList.cpp:211
void addSwitch(const std::string &label, const std::string &desc, const bool &value)
Adds a option named label, with description desc and value value.
Definition gsOptionList.cpp:235
#define index_t
Definition gsConfig.h:32
This is the main header file that collects wrappers of Eigen for linear algebra.
Provides a list of labeled parameters/options that can be set and accessed easily.
Header file for using Spectra extension.
Provides a status object and typedefs.
The G+Smo namespace, containing all definitions for the library.
gsStatus
Definition gsStructuralAnalysisTypes.h:21
@ NotStarted
ALM has not started yet.