G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsStaticDR.h
1 
15 
16 namespace gismo
17 {
18 
26 template <class T>
27 class gsStaticDR : public gsStaticBase<T>
28 {
29 protected:
30 
31  typedef gsStaticBase<T> Base;
32 
33  typedef typename Base::Residual_t Residual_t;
34  typedef typename Base::ALResidual_t ALResidual_t;
35 
36 public:
37 
45  gsStaticDR( const gsVector<T> & M, // lumped
46  const gsVector<T> & F,
47  const Residual_t &Residual
48  )
49  :
50  m_mass(M),
51  m_forcing(F),
52  m_residualFun(Residual),
53  m_ALresidualFun(nullptr)
54  {
55  this->_init();
56  }
57 
58 
66  gsStaticDR( const gsVector<T> & M, // lumped
67  const gsVector<T> & F,
68  const ALResidual_t & ALResidual
69  )
70  :
71  m_mass(M),
72  m_forcing(F),
73  m_ALresidualFun(ALResidual)
74  {
75  m_L = 1.0;
76  m_residualFun = [this](gsVector<T> const & x, gsVector<T> & result) -> bool
77  {
78  return m_ALresidualFun(x,m_L,result);
79  };
80  this->_init();
81  }
82 
84 public:
86  gsStatus solve() override;
87 
89  void initialize() override;
90 
92  void initOutput() override;
93 
95  void stepOutput(index_t k) override;
96 
98  void defaultOptions() override;
99 
101  void reset() override;
102 
104  void getOptions() override;
105 
106 public:
108  T kineticEnergy() const { return m_Ek; }
110  gsVector<T> energies() const { return gsAsVector<T>(m_Eks); }
112  gsVector<T> relEnergies() const { return gsAsVector<T>(m_Eks)/m_Ek0; }
114  gsVector<T> velocities() const {return m_v;}
115 
116 protected:
118  void _solve();
120  void _iteration();
122  void _peak();
124  void _start();
126  void _init();
127 
128  gsVector<T> _computeResidual(const gsVector<T> & U);
129 
130 public:
132  void _stepBack()
133  {
134  m_U -= m_DeltaU;
135  }
136 
138  void _reset()
139  {
140  _start();
141  }
142 
144  T residualNorm() const { return m_R.norm(); }
145 
146 protected:
147  const gsVector<T> & m_mass;
148  const gsVector<T> & m_forcing;
149  Residual_t m_residualFun;
150  const ALResidual_t m_ALresidualFun;
151 
152  // Solution
153  using Base::m_U;
154  using Base::m_DeltaU;
155  using Base::m_deltaU;
156 
157  using Base::m_L;
158  using Base::m_DeltaL;
159  using Base::m_deltaL;
160 
161  // Iterations
162  using Base::m_numIterations;
163  using Base::m_maxIterations;
164  index_t m_resetIterations;
165 
166  // Residuals
167  using Base::m_R;
168 
169  // Tolerances
170  using Base::m_tolF;
171  using Base::m_tolU;
172  T m_tolE;
173 
174  // Residual norms
175  using Base::m_residual;
176  using Base::m_residualIni;
177  using Base::m_residualOld;
178 
179  // Options
180  using Base::m_options;
181  using Base::m_verbose;
182 
183  // DoFs
184  using Base::m_dofs;
185 
186  // Headstart
187  using Base::m_headstart;
188 
189  // Solver status
190  using Base::m_status;
191 
192  // Velocities
193  gsVector<T> m_v; // (class-specific)
194  gsVector<T> m_massInv, m_damp; // (class-specific)
195 
196  // Coefficients
197  T m_dt, m_alpha, m_c; // (class-specific)
198 
199  // Kinetic energy
200  T m_Ek, m_Ek_prev, m_Ek0; // (class-specific)
201  mutable std::vector<T> m_Eks; // (class-specific)
202 };
203 
204 } //namespace
205 
206 
207 #ifndef GISMO_BUILD_LIB
208 #include GISMO_HPP_HEADER(gsStaticDR.hpp)
209 #endif
Base class for static solvers.
void getOptions() override
See gsStaticBase.
Definition: gsStaticDR.hpp:31
T residualNorm() const
Return the residual norm.
Definition: gsStaticDR.h:144
void initialize() override
See gsStaticBase.
Definition: gsStaticDR.hpp:149
gsStatus solve() override
gsStaticBase base functions
Definition: gsStaticDR.hpp:73
#define index_t
Definition: gsConfig.h:32
gsStatus
Definition: gsStructuralAnalysisTypes.h:20
void _reset()
Start over again.
Definition: gsStaticDR.h:138
void _start()
Starts the method.
Definition: gsStaticDR.hpp:217
Creates a mapped object or data pointer to a vector without copying data.
Definition: gsLinearAlgebra.h:129
void reset() override
See gsStaticBase.
Definition: gsStaticDR.hpp:158
T kineticEnergy() const
Returns the kinetic energy.
Definition: gsStaticDR.h:108
Static solver using the Dynamic Relaxation method.
Definition: gsStaticDR.h:27
void _solve()
See solve()
Definition: gsStaticDR.hpp:99
void _iteration()
Performs an iteration.
Definition: gsStaticDR.hpp:187
void _peak()
Identifies a peak.
Definition: gsStaticDR.hpp:205
void _init()
Initializes the method.
Definition: gsStaticDR.hpp:170
gsStaticDR(const gsVector< T > &M, const gsVector< T > &F, const Residual_t &Residual)
Constructor.
Definition: gsStaticDR.h:45
gsStaticDR(const gsVector< T > &M, const gsVector< T > &F, const ALResidual_t &ALResidual)
Constructs a new instance.
Definition: gsStaticDR.h:66
void initOutput() override
See gsStaticBase.
Definition: gsStaticDR.hpp:41
gsVector< T > energies() const
Returns the kinetic energy in all steps.
Definition: gsStaticDR.h:110
gsVector< T > relEnergies() const
Returns the kinetic energy relative to the first iteration.
Definition: gsStaticDR.h:112
gsVector< T > velocities() const
Returns the velocity.
Definition: gsStaticDR.h:114
void stepOutput(index_t k) override
See gsStaticBase.
Definition: gsStaticDR.hpp:57
void defaultOptions() override
See gsStaticBase.
Definition: gsStaticDR.hpp:21
Base class for static solvers.
Definition: gsStaticBase.h:37