iMSTK
Interactive Medical Simulation Toolkit
imstkNewmarkBeta.h
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #pragma once
8 
9 #include "imstkTimeIntegrator.h"
10 
11 namespace imstk
12 {
19 {
20 public:
21  NewmarkBeta(const double dT, const double beta = 0.25, const double gamma = 0.5) : TimeIntegrator(Type::NewmarkBeta, dT), m_gamma(gamma), m_beta(beta)
22  {}
23  ~NewmarkBeta() override = default;
24 
25  void updateStateGivenDv(std::shared_ptr<FeDeformBodyState> prevState, std::shared_ptr<FeDeformBodyState> currentState, Vectord& dV)
26  {
27  currentState->getQDot() = prevState->getQDot() + dV;
28  currentState->getQDotDot() = (currentState->getQDot() - prevState->getQDot()) / (m_gamma * m_dT) - (1.0 / m_gamma - 1) * prevState->getQDotDot();
29  currentState->getQ() = prevState->getQ() + m_dT * currentState->getQDot() + 0.5 * m_dT * m_dT * ((1 - 2 * m_beta) * prevState->getQDotDot() + 2 * m_beta * currentState->getQDotDot());
30  }
31 
32  void updateStateGivenDu(std::shared_ptr<FeDeformBodyState> prevState, std::shared_ptr<FeDeformBodyState> currentState, Vectord& dU)
33  {
34  }
35 
36  void updateStateGivenV(std::shared_ptr<FeDeformBodyState> prevState, std::shared_ptr<FeDeformBodyState> currentState, Vectord& v)
37  {
38  currentState->getQDot() = v;
39  currentState->getQDotDot() = (currentState->getQDot() - prevState->getQDot()) / (m_gamma * m_dT) - (1.0 / m_gamma - 1) * prevState->getQDotDot();
40  currentState->getQ() = prevState->getQ() + m_dT * currentState->getQDot() + 0.5 * m_dT * m_dT * ((1 - 2 * m_beta) * prevState->getQDotDot() + 2 * m_beta * currentState->getQDotDot());
41  }
42 
43  void updateStateGivenU(std::shared_ptr<FeDeformBodyState> prevState, std::shared_ptr<FeDeformBodyState> currentState, Vectord& u)
44  {
45  }
46 
47 protected:
48  double m_beta;
49  double m_gamma;
50 
51 // // Coefficients of the time integrator
52 // std::array<double, 3> m_alpha = { { 1, 0, 0 } };
53 // std::array<double, 3> m_beta = { { 1, -1, 0 } };
54 // std::array<double, 3> m_gamma = { { 1, -2, -1 } };
55 };
56 } // namespace imstk
This class defines the time integrators of various types. It only sets the rules of how the velocity ...
Compound Geometry.
void updateStateGivenDv(std::shared_ptr< FeDeformBodyState > prevState, std::shared_ptr< FeDeformBodyState > currentState, Vectord &dV)
Update states given the updates in different forms.
Newmark-beta time integration.