OdeEquation.h
Go to the documentation of this file.
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 
35 {
41 };
42 
55 {
56 public:
58  virtual ~OdeEquation() {}
59 
62  const std::shared_ptr<OdeState> getInitialState() const;
63 
70  virtual Matrix applyCompliance(const OdeState& state, const Matrix& b) = 0;
71 
75  virtual void updateFMDK(const OdeState& state, int options);
76 
78  const Vector& getF() const;
79 
81  const SparseMatrix& getM() const;
82 
84  const SparseMatrix& getD() const;
85 
87  const SparseMatrix& getK() const;
88 
89 protected:
92  virtual void computeF(const OdeState& state) = 0;
93 
96  virtual void computeM(const OdeState& state) = 0;
97 
100  virtual void computeD(const OdeState& state) = 0;
101 
104  virtual void computeK(const OdeState& state) = 0;
105 
111  virtual void computeFMDK(const OdeState& state) = 0;
112 
115  std::shared_ptr<OdeState> m_initialState;
116 
119 
122 
125 
128 };
129 
130 }; // namespace Math
131 
132 }; // namespace SurgSim
133 
134 #endif // SURGSIM_MATH_ODEEQUATION_H
SurgSim::Math::OdeEquation::computeF
virtual void computeF(const OdeState &state)=0
Evaluation of the RHS function for a given state.
SurgSim::Math::ODEEQUATIONUPDATE_F
Definition: OdeEquation.h:36
Vector.h
SurgSim::Math::OdeState
The state of an ode of 2nd order of the form with boundary conditions.
Definition: OdeState.h:38
SurgSim::Math::OdeEquation::updateFMDK
virtual void updateFMDK(const OdeState &state, int options)
Update the OdeEquation (and support data) based on the given state.
Definition: OdeEquation.cpp:51
SurgSim::Math::OdeEquation::computeD
virtual void computeD(const OdeState &state)=0
Evaluation of for a given state.
SurgSim::Math::ODEEQUATIONUPDATE_D
Definition: OdeEquation.h:38
SurgSim::Math::OdeEquation::getInitialState
const std::shared_ptr< OdeState > getInitialState() const
Retrieves the ode initial conditions (i.e the initial state)
Definition: OdeEquation.cpp:26
SurgSim::Math::OdeEquation::m_initialState
std::shared_ptr< OdeState > m_initialState
The initial state (which defines the ODE initial conditions )
Definition: OdeEquation.h:115
Matrix.h
SparseMatrix.h
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Math::OdeEquation::getM
const SparseMatrix & getM() const
Definition: OdeEquation.cpp:36
SurgSim::Math::OdeEquation::getF
const Vector & getF() const
Definition: OdeEquation.cpp:31
SurgSim::Math::OdeEquation::computeK
virtual void computeK(const OdeState &state)=0
Evaluation of for a given state.
SurgSim::Math::SparseMatrix
Eigen::SparseMatrix< double > SparseMatrix
A sparse matrix.
Definition: SparseMatrix.h:32
SurgSim::Math::ODEEQUATIONUPDATE_K
Definition: OdeEquation.h:39
SurgSim::Math::OdeEquation
Ode equation of 2nd order of the form with for initial conditions and a set of boundary conditions.
Definition: OdeEquation.h:54
SurgSim::Math::OdeEquation::computeFMDK
virtual void computeFMDK(const OdeState &state)=0
Evaluation of , , and .
SurgSim::Math::OdeEquation::computeM
virtual void computeM(const OdeState &state)=0
Evaluation of the LHS matrix for a given state.
SurgSim::Math::ODEEQUATIONUPDATE_FMDK
Definition: OdeEquation.h:40
SurgSim::Math::OdeEquation::m_D
SparseMatrix m_D
The The matrix .
Definition: OdeEquation.h:124
SurgSim::Math::OdeEquation::m_K
SparseMatrix m_K
The The matrix .
Definition: OdeEquation.h:127
SurgSim::Math::OdeEquation::m_M
SparseMatrix m_M
The matrix .
Definition: OdeEquation.h:121
SurgSim::Math::OdeEquation::applyCompliance
virtual Matrix applyCompliance(const OdeState &state, const Matrix &b)=0
Calculate the product C.b where C is the compliance matrix with boundary conditions applied.
SurgSim::Math::Vector
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
A dynamic size column vector.
Definition: Vector.h:68
SurgSim::Math::OdeEquation::m_f
Vector m_f
The vector containing .
Definition: OdeEquation.h:118
SurgSim::Math::OdeEquationUpdate
OdeEquationUpdate
Enum to identify which of the data need to be updated by the OdeEquation::update()
Definition: OdeEquation.h:34
SurgSim::Math::OdeEquation::getD
const SparseMatrix & getD() const
Definition: OdeEquation.cpp:41
SurgSim::Math::OdeEquation::getK
const SparseMatrix & getK() const
Definition: OdeEquation.cpp:46
SurgSim::Math::Matrix
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > Matrix
A dynamic size matrix.
Definition: Matrix.h:65
SurgSim::Math::ODEEQUATIONUPDATE_M
Definition: OdeEquation.h:37
SurgSim::Math::OdeEquation::~OdeEquation
virtual ~OdeEquation()
Virtual destructor.
Definition: OdeEquation.h:58