opensurgsim
OdeSolverRungeKutta4.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_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 
56 {
57 public:
60  explicit OdeSolverRungeKutta4(OdeEquation* equation);
61 
62  void solve(double dt, const OdeState& currentState, OdeState* newState, bool computeCompliance = true) override;
63 
64 protected:
65  void assembleLinearSystem(double dt, const OdeState& state, const OdeState& newState,
66  bool computeRHS = true) override;
67 
70  {
72  RungeKuttaDerivedState(const Vector& v, const Vector& a) : velocity(v), acceleration(a) {}
73  Vector velocity;
74  Vector acceleration;
75  };
76 
79  RungeKuttaDerivedState m_k1, m_k2, m_k3, m_k4;
81 };
82 
83 }; // namespace Math
84 
85 }; // namespace SurgSim
86 
87 #endif // SURGSIM_MATH_ODESOLVERRUNGEKUTTA4_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
Internal structure to hold the 4 temporary evaluations.
Definition: OdeSolverRungeKutta4.h:69
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
void solve(double dt, const OdeState &currentState, OdeState *newState, bool computeCompliance=true) override
Solves the equation.
Definition: OdeSolverRungeKutta4.cpp:31
Runge Kutta 4 ode solver (See http://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods) solves the fo...
Definition: OdeSolverRungeKutta4.h:55
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
A dynamic size column vector.
Definition: Vector.h:68
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
Base class for all solvers of ode equation of order 2 of the form .
Definition: OdeSolver.h:78
RungeKuttaDerivedState m_k1
Definition: OdeSolverRungeKutta4.h:79
OdeSolverRungeKutta4(OdeEquation *equation)
Constructor.
Definition: OdeSolverRungeKutta4.cpp:25