iMSTK
Interactive Medical Simulation Toolkit
imstkTimeIntegrator.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 "imstkVectorizedState.h"
10 
11 namespace imstk
12 {
22 {
23 public:
24  enum class Type
25  {
26  ForwardEuler,
29  CentralDifference,
30  NoTimeStepper,
31  None
32  };
33 
34 public:
35  TimeIntegrator(Type type, double dT) : m_type(type), m_dT(dT), m_defaultDt(dT) {}
36  virtual ~TimeIntegrator() = default;
37 
41  TimeIntegrator::Type getType() const { return m_type; }
42 
46  void setTimestepSize(const double dT) { m_dT = dT; }
47  double getTimestepSize() const { return m_dT; }
48  void setTimestepSizeToDefault() { m_dT = m_defaultDt; }
50 
54  void setDefaultTimestepSize(const double dT) { m_defaultDt = dT; }
55  double getDefaultTimestepSize() const { return m_defaultDt; }
57 
61  virtual void updateStateGivenDv(std::shared_ptr<FeDeformBodyState> prevState, std::shared_ptr<FeDeformBodyState> currentState, Vectord& dV) = 0;
62  virtual void updateStateGivenDu(std::shared_ptr<FeDeformBodyState> prevState, std::shared_ptr<FeDeformBodyState> currentState, Vectord& dU) = 0;
63  virtual void updateStateGivenV(std::shared_ptr<FeDeformBodyState> prevState, std::shared_ptr<FeDeformBodyState> currentState, Vectord& v) = 0;
64  virtual void updateStateGivenU(std::shared_ptr<FeDeformBodyState> prevState, std::shared_ptr<FeDeformBodyState> currentState, Vectord& u) = 0;
65 
66 protected:
67  Type m_type;
68  double m_dT;
69  double m_defaultDt;
70 };
71 } // namespace imstk
This class defines the time integrators of various types. It only sets the rules of how the velocity ...
virtual void updateStateGivenDv(std::shared_ptr< FeDeformBodyState > prevState, std::shared_ptr< FeDeformBodyState > currentState, Vectord &dV)=0
Update states given the updates in different forms.
Type m_type
Type of the time integrator.
void setTimestepSize(const double dT)
Get/Set the time step size.
Compound Geometry.
void setDefaultTimestepSize(const double dT)
Set/Get the time step size.
Newmark-beta time integration.
Backward Euler time integration.
TimeIntegrator::Type getType() const
Return the type of the time integrator.