opensurgsim
OdeEquation.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_MATH_ODEEQUATION_H
17 #define SURGSIM_MATH_ODEEQUATION_H
18 
19 #include <memory>
20 
22 #include "SurgSim/Math/Matrix.h"
23 #include "SurgSim/Math/Vector.h"
24 
25 namespace SurgSim
26 {
27 
28 namespace Math
29 {
30 
31 class OdeState;
32 
34 enum OdeEquationUpdate
35 {
36  ODEEQUATIONUPDATE_F = 1<<0,
37  ODEEQUATIONUPDATE_M = 1<<1,
38  ODEEQUATIONUPDATE_D = 1<<2,
39  ODEEQUATIONUPDATE_K = 1<<3,
40  ODEEQUATIONUPDATE_FMDK = ODEEQUATIONUPDATE_F | ODEEQUATIONUPDATE_M | ODEEQUATIONUPDATE_D | ODEEQUATIONUPDATE_K
41 };
42 
55 {
56 public:
57 
58  OdeEquation() : m_initState(0)
59  {
60 
61  }
63  virtual ~OdeEquation() {}
64 
67  const std::shared_ptr<OdeState> getInitialState() const;
68 
75  virtual Matrix applyCompliance(const OdeState& state, const Matrix& b) = 0;
76 
80  virtual void updateFMDK(const OdeState& state, int options);
81 
83  const Vector& getF() const;
84 
86  const SparseMatrix& getM() const;
87 
89  const SparseMatrix& getD() const;
90 
92  const SparseMatrix& getK() const;
93 
94  bool hasF()const;
95 
96  bool hasM()const;
97 
98  bool hasK()const;
99 
100  bool hasD()const;
101 
102 protected:
105  virtual void computeF(const OdeState& state) = 0;
106 
109  virtual void computeM(const OdeState& state) = 0;
110 
113  virtual void computeD(const OdeState& state) = 0;
114 
117  virtual void computeK(const OdeState& state) = 0;
118 
124  virtual void computeFMDK(const OdeState& state) = 0;
125 
128  std::shared_ptr<OdeState> m_initialState;
129 
130  unsigned int m_initState;
131 
134 
137 
140 
143 };
144 
145 }; // namespace Math
146 
147 }; // namespace SurgSim
148 
149 #endif // SURGSIM_MATH_ODEEQUATION_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
Vector m_f
The vector containing .
Definition: OdeEquation.h:133
virtual ~OdeEquation()
Virtual destructor.
Definition: OdeEquation.h:63
Eigen::SparseMatrix< double > SparseMatrix
A sparse matrix.
Definition: SparseMatrix.h:32
SparseMatrix m_D
The The matrix .
Definition: OdeEquation.h:139
virtual void updateFMDK(const OdeState &state, int options)
Update the OdeEquation (and support data) based on the given state.
Definition: OdeEquation.cpp:71
Ode equation of 2nd order of the form with for initial conditions and a set of boundary conditions...
Definition: OdeEquation.h:54
The state of an ode of 2nd order of the form with boundary conditions.
Definition: OdeState.h:38
virtual void computeD(const OdeState &state)=0
Evaluation of for a given state.
Definitions of useful sparse matrix functions.
const SparseMatrix & getK() const
Definition: OdeEquation.cpp:46
virtual void computeK(const OdeState &state)=0
Evaluation of for a given state.
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
A dynamic size column vector.
Definition: Vector.h:68
virtual void computeF(const OdeState &state)=0
Evaluation of the RHS function for a given state.
const SparseMatrix & getM() const
Definition: OdeEquation.cpp:36
virtual Matrix applyCompliance(const OdeState &state, const Matrix &b)=0
Calculate the product where is the compliance matrix with boundary conditions applied.
const SparseMatrix & getD() const
Definition: OdeEquation.cpp:41
Definitions of small fixed-size square matrix types.
Definitions of small fixed-size vector types.
SparseMatrix m_M
The matrix .
Definition: OdeEquation.h:136
virtual void computeFMDK(const OdeState &state)=0
Evaluation of , , and .
virtual void computeM(const OdeState &state)=0
Evaluation of the LHS matrix for a given state.
const Vector & getF() const
Definition: OdeEquation.cpp:31
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > Matrix
A dynamic size matrix.
Definition: Matrix.h:65
SparseMatrix m_K
The The matrix .
Definition: OdeEquation.h:142
std::shared_ptr< OdeState > m_initialState
The initial state (which defines the ODE initial conditions )
Definition: OdeEquation.h:128
const std::shared_ptr< OdeState > getInitialState() const
Retrieves the ode initial conditions (i.e the initial state)
Definition: OdeEquation.cpp:26