OdeEquation.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_MATH_ODEEQUATION_H
#define SURGSIM_MATH_ODEEQUATION_H
#include <memory>
#include "SurgSim/Math/SparseMatrix.h"
#include "SurgSim/Math/Matrix.h"
#include "SurgSim/Math/Vector.h"
namespace SurgSim
{
namespace Math
{
class OdeState;
enum OdeEquationUpdate
{
ODEEQUATIONUPDATE_F = 1<<0,
ODEEQUATIONUPDATE_M = 1<<1,
ODEEQUATIONUPDATE_D = 1<<2,
ODEEQUATIONUPDATE_K = 1<<3,
ODEEQUATIONUPDATE_FMDK = ODEEQUATIONUPDATE_F | ODEEQUATIONUPDATE_M | ODEEQUATIONUPDATE_D | ODEEQUATIONUPDATE_K
};
class OdeEquation
{
public:
virtual ~OdeEquation() {}
const std::shared_ptr<OdeState> getInitialState() const;
virtual Matrix applyCompliance(const OdeState& state, const Matrix& b) = 0;
virtual void updateFMDK(const OdeState& state, int options);
const Vector& getF() const;
const SparseMatrix& getM() const;
const SparseMatrix& getD() const;
const SparseMatrix& getK() const;
protected:
virtual void computeF(const OdeState& state) = 0;
virtual void computeM(const OdeState& state) = 0;
virtual void computeD(const OdeState& state) = 0;
virtual void computeK(const OdeState& state) = 0;
virtual void computeFMDK(const OdeState& state) = 0;
std::shared_ptr<OdeState> m_initialState;
Vector m_f;
SparseMatrix m_M;
SparseMatrix m_D;
SparseMatrix m_K;
};
}; // namespace Math
}; // namespace SurgSim
#endif // SURGSIM_MATH_ODEEQUATION_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Math::OdeEquation::m_f
Vector m_f
The vector containing .
Definition: OdeEquation.h:118
SurgSim::Math::OdeEquation::~OdeEquation
virtual ~OdeEquation()
Virtual destructor.
Definition: OdeEquation.h:58
SurgSim::Math::ODEEQUATIONUPDATE_K
Definition: OdeEquation.h:39
SurgSim::Math::Matrix
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > Matrix
A dynamic size matrix.
Definition: Matrix.h:65
SurgSim::Math::OdeEquation::m_D
SparseMatrix m_D
The The matrix .
Definition: OdeEquation.h:124
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
Ode equation of 2nd order of the form with for initial conditions and a set of boundary conditions...
Definition: OdeEquation.h:54
SurgSim::Math::OdeState
The state of an ode of 2nd order of the form with boundary conditions.
Definition: OdeState.h:38
SurgSim::Math::OdeEquation::computeD
virtual void computeD(const OdeState &state)=0
Evaluation of for a given state.
SurgSim::Math::ODEEQUATIONUPDATE_FMDK
Definition: OdeEquation.h:40
SparseMatrix.h
Definitions of useful sparse matrix functions.
SurgSim::Math::Vector
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
A dynamic size column vector.
Definition: Vector.h:68
SurgSim::Math::SparseMatrix
Eigen::SparseMatrix< double > SparseMatrix
A sparse matrix.
Definition: SparseMatrix.h:32
SurgSim::Math::OdeEquation::getK
const SparseMatrix & getK() const
Definition: OdeEquation.cpp:46
SurgSim::Math::ODEEQUATIONUPDATE_F
Definition: OdeEquation.h:36
SurgSim::Math::OdeEquation::computeK
virtual void computeK(const OdeState &state)=0
Evaluation of for a given state.
SurgSim::Math::ODEEQUATIONUPDATE_D
Definition: OdeEquation.h:38
SurgSim::Math::OdeEquation::computeF
virtual void computeF(const OdeState &state)=0
Evaluation of the RHS function for a given state.
SurgSim::Math::OdeEquation::getM
const SparseMatrix & getM() const
Definition: OdeEquation.cpp:36
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::OdeEquation::getD
const SparseMatrix & getD() const
Definition: OdeEquation.cpp:41
Matrix.h
Definitions of small fixed-size square matrix types.
SurgSim::Math::ODEEQUATIONUPDATE_M
Definition: OdeEquation.h:37
Vector.h
Definitions of small fixed-size vector types.
SurgSim::Math::OdeEquation::m_M
SparseMatrix m_M
The matrix .
Definition: OdeEquation.h:121
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::OdeEquation::getF
const Vector & getF() const
Definition: OdeEquation.cpp:31
SurgSim::Math::OdeEquation::m_K
SparseMatrix m_K
The The matrix .
Definition: OdeEquation.h:127
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::m_initialState
std::shared_ptr< OdeState > m_initialState
The initial state (which defines the ODE initial conditions )
Definition: OdeEquation.h:115
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