List of all members | Public Member Functions | Private Attributes
utl::RK4ODEIntegrator< DerivativeFunctor > Class Template Reference

#include "utl/RK4ODEIntegrator.h"

Public Member Functions

template<class VectorType >
RK4Iterator< DerivativeFunctor,
VectorType > 
Begin (const double x, const VectorType &y)
 
DerivativeFunctor & GetDerivativeFunctor ()
 
 RK4ODEIntegrator (DerivativeFunctor &d)
 

Private Attributes

DerivativeFunctor & fDerivativeFunctor
 

Detailed Description

template<class DerivativeFunctor>
class utl::RK4ODEIntegrator< DerivativeFunctor >

This class prepares the integration of the Ordinary Differential Equations (ODE) of the form

\[ \frac{{\rm d}y_i}{{\rm d}x} = f_i(x, y_0, \ldots, y_{n-1}) \]

for $i\in{0, \ldots, n-1}$.

ODE is defined through an function class with operator() defined (usualy such classes are called functor in C++). This functor has to define the operator() and unsigned int cast operator:

class MyODE {
public:
bool
operator()(const double x, const double y[10], double dydx[10])
{
dydx[0] = ...
dydx[1] = ...
return true; // everything is ok
}
operator unsigned int() { return 10; }
};

Operator() calculates derivatives ${\rm d}y_i/{\rm d}x$ of variables $y_i$ with respect to the independent variable x.

The cast operator unsigned int() returns number of OD equations (in this example 10).

The class RK4ODEIntegrator returns an iterator that can be advanced with operator += dx for some step dx in independent variable.

typedef double VectorType[10];
RK4ODEIntegrator<MyODE, VectorType> ode(MyODE());
RK4Iterator<MyODE, VectorType> it = ode.Begin(x0, y0);
it += dx;
if (it)

Note that the suitable candidates for template parameter VectorType are vector classes with fixed size (std::vector<> is not appropriate since the default constructor leaves the object with zero size) that support the operator[] for element access. You can use the C-style arrays double[n] or Offline class utl::SVectorType<n>.

See also utl::RK5ODEIntegrator and testODEIntegrator.cc for a real examples.

Author
Darko Veberic
Date
20 Jun 2008

Definition at line 161 of file RK4ODEIntegrator.h.

Constructor & Destructor Documentation

template<class DerivativeFunctor>
utl::RK4ODEIntegrator< DerivativeFunctor >::RK4ODEIntegrator ( DerivativeFunctor &  d)
inline

Definition at line 163 of file RK4ODEIntegrator.h.

Member Function Documentation

template<class DerivativeFunctor>
template<class VectorType >
RK4Iterator<DerivativeFunctor, VectorType> utl::RK4ODEIntegrator< DerivativeFunctor >::Begin ( const double  x,
const VectorType &  y 
)
inline
template<class DerivativeFunctor>
DerivativeFunctor& utl::RK4ODEIntegrator< DerivativeFunctor >::GetDerivativeFunctor ( )
inline

Member Data Documentation

template<class DerivativeFunctor>
DerivativeFunctor& utl::RK4ODEIntegrator< DerivativeFunctor >::fDerivativeFunctor
private

The documentation for this class was generated from the following file:

, generated on Tue Sep 26 2023.