All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OdeSolverRungeKutta4.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_ODESOLVERRUNGEKUTTA4_H
17 #define SURGSIM_MATH_ODESOLVERRUNGEKUTTA4_H
18 
19 #include <array>
20 
21 #include "SurgSim/Math/OdeSolver.h"
22 
23 namespace SurgSim
24 {
25 
26 namespace Math
27 {
28 
44 {
45 public:
48  explicit OdeSolverRungeKutta4(OdeEquation* equation);
49 
54  virtual void solve(double dt, const OdeState& currentState, OdeState* newState) override;
55 
56 protected:
59 
62  {
64  RungeKuttaDerivedState(const Vector& v, const Vector& a) : velocity(v), acceleration(a) {}
67  };
70 };
71 
72 }; // namespace Math
73 
74 }; // namespace SurgSim
75 
76 #endif // SURGSIM_MATH_ODESOLVERRUNGEKUTTA4_H
RungeKuttaDerivedState m_k4
Definition: OdeSolverRungeKutta4.h:69
RungeKuttaDerivedState(const Vector &v, const Vector &a)
Definition: OdeSolverRungeKutta4.h:64
Internal structure to hold the 4 temporary evaluations.
Definition: OdeSolverRungeKutta4.h:61
Ode equation of 2nd order of the form M(x,v).a = F(x, v) with (x0, v0) for initial conditions and a s...
Definition: OdeEquation.h:40
OdeState defines the state y of an ode of 2nd order of the form M(x,v).a = F(x, v) with boundary cond...
Definition: OdeState.h:34
RungeKuttaDerivedState m_k3
Definition: OdeSolverRungeKutta4.h:69
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
A dynamic size column vector.
Definition: Vector.h:67
virtual void solve(double dt, const OdeState &currentState, OdeState *newState) override
Solves the equation.
Definition: OdeSolverRungeKutta4.cpp:31
RungeKuttaDerivedState()
Definition: OdeSolverRungeKutta4.h:63
Runge Kutta 4 ode solver See http://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods.
Definition: OdeSolverRungeKutta4.h:43
Base class for all solvers of ode equation of order 2 of the form M(x(t), v(t)).a(t) = f(t...
Definition: OdeSolver.h:73
Vector m_force
Temporary vectors to store the 4 intermediates evaluations.
Definition: OdeSolverRungeKutta4.h:58
RungeKuttaDerivedState m_k1
Runge kutta 4 intermediate system evaluations.
Definition: OdeSolverRungeKutta4.h:69
Vector acceleration
Definition: OdeSolverRungeKutta4.h:66
RungeKuttaDerivedState m_k2
Definition: OdeSolverRungeKutta4.h:69
OdeSolverRungeKutta4(OdeEquation *equation)
Constructor.
Definition: OdeSolverRungeKutta4.cpp:25
Vector velocity
Definition: OdeSolverRungeKutta4.h:65