OdeSolverRungeKutta4.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_ODESOLVERRUNGEKUTTA4_H
#define SURGSIM_MATH_ODESOLVERRUNGEKUTTA4_H
#include <array>
#include "SurgSim/Math/OdeSolver.h"
namespace SurgSim
{
namespace Math
{
class OdeSolverRungeKutta4 : public OdeSolver
{
public:
explicit OdeSolverRungeKutta4(OdeEquation* equation);
void solve(double dt, const OdeState& currentState, OdeState* newState, bool computeCompliance = true) override;
protected:
void assembleLinearSystem(double dt, const OdeState& state, const OdeState& newState,
bool computeRHS = true) override;
struct RungeKuttaDerivedState
{
RungeKuttaDerivedState(){}
RungeKuttaDerivedState(const Vector& v, const Vector& a) : velocity(v), acceleration(a) {}
Vector velocity;
Vector acceleration;
};
RungeKuttaDerivedState m_k1, m_k2, m_k3, m_k4;
};
}; // namespace Math
}; // namespace SurgSim
#endif // SURGSIM_MATH_ODESOLVERRUNGEKUTTA4_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Math::OdeSolverRungeKutta4::m_k4
RungeKuttaDerivedState m_k4
Definition: OdeSolverRungeKutta4.h:79
SurgSim::Math::OdeSolverRungeKutta4::RungeKuttaDerivedState::RungeKuttaDerivedState
RungeKuttaDerivedState(const Vector &v, const Vector &a)
Definition: OdeSolverRungeKutta4.h:72
SurgSim::Math::OdeSolverRungeKutta4::RungeKuttaDerivedState
Internal structure to hold the 4 temporary evaluations.
Definition: OdeSolverRungeKutta4.h:69
OdeSolver.h
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::OdeSolverRungeKutta4::m_k3
RungeKuttaDerivedState m_k3
Definition: OdeSolverRungeKutta4.h:79
SurgSim::Math::OdeSolverRungeKutta4::solve
void solve(double dt, const OdeState &currentState, OdeState *newState, bool computeCompliance=true) override
Solves the equation.
Definition: OdeSolverRungeKutta4.cpp:31
SurgSim::Math::Vector
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
A dynamic size column vector.
Definition: Vector.h:68
SurgSim::Math::OdeSolverRungeKutta4::RungeKuttaDerivedState::RungeKuttaDerivedState
RungeKuttaDerivedState()
Definition: OdeSolverRungeKutta4.h:71
SurgSim::Math::OdeSolverRungeKutta4
Runge Kutta 4 ode solver (See http://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods) solves the fo...
Definition: OdeSolverRungeKutta4.h:55
SurgSim::Math::OdeSolverRungeKutta4::assembleLinearSystem
void assembleLinearSystem(double dt, const OdeState &state, const OdeState &newState, bool computeRHS=true) override
Assemble the linear system (A.x=b) to be solved for the state and new states (useful for certain ode ...
Definition: OdeSolverRungeKutta4.cpp:94
SurgSim::Math::OdeSolver
Base class for all solvers of ode equation of order 2 of the form .
Definition: OdeSolver.h:78
SurgSim::Math::OdeSolverRungeKutta4::m_k1
RungeKuttaDerivedState m_k1
Definition: OdeSolverRungeKutta4.h:79
SurgSim::Math::OdeSolverRungeKutta4::RungeKuttaDerivedState::acceleration
Vector acceleration
Definition: OdeSolverRungeKutta4.h:74
SurgSim::Math::OdeSolverRungeKutta4::m_k2
RungeKuttaDerivedState m_k2
Definition: OdeSolverRungeKutta4.h:79
SurgSim::Math::OdeSolverRungeKutta4::OdeSolverRungeKutta4
OdeSolverRungeKutta4(OdeEquation *equation)
Constructor.
Definition: OdeSolverRungeKutta4.cpp:25
SurgSim::Math::OdeSolverRungeKutta4::RungeKuttaDerivedState::velocity
Vector velocity
Definition: OdeSolverRungeKutta4.h:73