Documentation


animal::integration::Solver< DerivativeF, StepF, TraitsT > Struct Template Reference

#include <solver.h>

Inheritance diagram for animal::integration::Solver< DerivativeF, StepF, TraitsT >:

animal::integration::Euler< DerivativeF, StepF, TraitsT > animal::integration::Modified_Midpoint< N, DerivativeF, StepF, TraitsT > animal::integration::Modified_Midpoint_V< NStepF, DerivativeF, StepF, TraitsT > animal::integration::Runge_Kutta_2< DerivativeF, StepF, TraitsT > animal::integration::Runge_Kutta_4< DerivativeF, StepF, TraitsT > List of all members.

Detailed Description

template<class DerivativeF, class StepF, class TraitsT>
struct animal::integration::Solver< DerivativeF, StepF, TraitsT >

Base class for all explicit Ordinary Differential Equation solvers.

A Solver integrates a function of time over a given time step. Contrary with a Stepper, a Solver can NOT decide to subdivide the given time step for purposes of accuracy.

State and derivative variables are seen as stl-like containers of elementary variables. Iterators begin() and end() are used, and methods * (dereferencing) and ++ (next element) are applied to iterators. Auxiliary state and derivative containers are internally used by the different integration schemes.

The base class is pure virtual. Derived classes implement Euler's method (the simplest), Runge_Kutta with order 2 or 4, and the "modified midpoint method".

Three auxiliary types are used to instanciate the template class:

Author:
David Bourguignon, March 2000, file animal/integration/solver.h
See also:
Solver_Traits

Solver_Traits_M

Euler

Runge_Kutta_2

Runge_Kutta_4

Modified_Midpoint

Definition at line 71 of file solver.h.

Public Types

typedef TraitsT Traits
 Traits class: includes all type definitions.

typedef Traits::Real Real
 Floating-point value for time.

typedef Traits::State State
 Container of state variables.

typedef Traits::CopyState CopyState
 Container of copies of state variables.

typedef Traits::Derivative Derivative
 Container of derivative variables.

typedef Traits::SizeType SizeType
 Natural number to define container size, typically unsigned int.


Public Member Functions

Constructor
Default constructor is typically used, unless the lower-level objects include special data.

 Solver (const DerivativeF &df=DerivativeF(), const StepF &sf=StepF(), const Traits &tr=Traits())
 Just calls the base class constructor.

virtual ~Solver ()
 Destructor does nothing.

Integration scheme
Implementation of the numerical integration method.

virtual void doStep (const State &initial_S, State &final_S, const Derivative &initial_D, const Real t, const Real h)=0
 This method implements the integration scheme to be applied (Euler, Runge-Kutta, ...) Given a state initial_S and a derivative initial_D at time t, integrate over a time step h and write the result in final_S.

Call operators
These methods apply time integration.

They internally call the doStep method. However, the doStep method may be called directly if the derivative at the beginning of the time step is known.

template<class S> void operator() (const State &initial_S, S &final_S, const Real t, const Real h)
 Starting from state initial_S at time t, integrate time to t+h and write the result in final_S.

template<class S> void operator() (S &s, const Real t, const Real h)
 Similar with the other call operator, except that the final state overwrites the initial state.

Resize
Resize the auxiliary container(s).

void resize (const SizeType size)
 Resize the auxiliary container(s) when the number of elements in the state grows.


Public Attributes

Lower-level objects and algorithms
Traits traits
 An instance of Traits is defined in order to allow data storage within the Traits.

DerivativeF writeDerivative
 Computation of the derivative.

StepF applyStep
 Increment state by a given derivative over a given time step.


Protected Member Functions

virtual void setSize (const SizeType size)=0
 Pure virtual method used to resize all the additional auxiliary containers used by the derived classes.


Protected Attributes

Derivative D1
 An auxiliary derivative container used by all integration schemes.


Member Typedef Documentation

template<class DerivativeF, class StepF, class TraitsT>
typedef Traits::CopyState animal::integration::Solver< DerivativeF, StepF, TraitsT >::CopyState
 

Container of copies of state variables.

Reimplemented in animal::integration::Euler< DerivativeF, StepF, TraitsT >, animal::integration::Runge_Kutta_2< DerivativeF, StepF, TraitsT >, animal::integration::Runge_Kutta_4< DerivativeF, StepF, TraitsT >, animal::integration::Modified_Midpoint< N, DerivativeF, StepF, TraitsT >, and animal::integration::Modified_Midpoint_V< NStepF, DerivativeF, StepF, TraitsT >.

Definition at line 84 of file solver.h.

template<class DerivativeF, class StepF, class TraitsT>
typedef Traits::Derivative animal::integration::Solver< DerivativeF, StepF, TraitsT >::Derivative
 

Container of derivative variables.

Reimplemented in animal::integration::Euler< DerivativeF, StepF, TraitsT >, animal::integration::Runge_Kutta_2< DerivativeF, StepF, TraitsT >, animal::integration::Runge_Kutta_4< DerivativeF, StepF, TraitsT >, animal::integration::Modified_Midpoint< N, DerivativeF, StepF, TraitsT >, and animal::integration::Modified_Midpoint_V< NStepF, DerivativeF, StepF, TraitsT >.

Definition at line 87 of file solver.h.

template<class DerivativeF, class StepF, class TraitsT>
typedef Traits::Real animal::integration::Solver< DerivativeF, StepF, TraitsT >::Real
 

Floating-point value for time.

Reimplemented in animal::integration::Euler< DerivativeF, StepF, TraitsT >, animal::integration::Runge_Kutta_2< DerivativeF, StepF, TraitsT >, animal::integration::Runge_Kutta_4< DerivativeF, StepF, TraitsT >, animal::integration::Modified_Midpoint< N, DerivativeF, StepF, TraitsT >, and animal::integration::Modified_Midpoint_V< NStepF, DerivativeF, StepF, TraitsT >.

Definition at line 78 of file solver.h.

template<class DerivativeF, class StepF, class TraitsT>
typedef Traits::SizeType animal::integration::Solver< DerivativeF, StepF, TraitsT >::SizeType
 

Natural number to define container size, typically unsigned int.

Reimplemented in animal::integration::Euler< DerivativeF, StepF, TraitsT >, animal::integration::Runge_Kutta_2< DerivativeF, StepF, TraitsT >, animal::integration::Runge_Kutta_4< DerivativeF, StepF, TraitsT >, animal::integration::Modified_Midpoint< N, DerivativeF, StepF, TraitsT >, and animal::integration::Modified_Midpoint_V< NStepF, DerivativeF, StepF, TraitsT >.

Definition at line 90 of file solver.h.

template<class DerivativeF, class StepF, class TraitsT>
typedef Traits::State animal::integration::Solver< DerivativeF, StepF, TraitsT >::State
 

Container of state variables.

Reimplemented in animal::integration::Euler< DerivativeF, StepF, TraitsT >, animal::integration::Runge_Kutta_2< DerivativeF, StepF, TraitsT >, animal::integration::Runge_Kutta_4< DerivativeF, StepF, TraitsT >, animal::integration::Modified_Midpoint< N, DerivativeF, StepF, TraitsT >, and animal::integration::Modified_Midpoint_V< NStepF, DerivativeF, StepF, TraitsT >.

Definition at line 81 of file solver.h.

template<class DerivativeF, class StepF, class TraitsT>
typedef TraitsT animal::integration::Solver< DerivativeF, StepF, TraitsT >::Traits
 

Traits class: includes all type definitions.

Reimplemented in animal::integration::Euler< DerivativeF, StepF, TraitsT >, animal::integration::Runge_Kutta_2< DerivativeF, StepF, TraitsT >, animal::integration::Runge_Kutta_4< DerivativeF, StepF, TraitsT >, animal::integration::Modified_Midpoint< N, DerivativeF, StepF, TraitsT >, and animal::integration::Modified_Midpoint_V< NStepF, DerivativeF, StepF, TraitsT >.

Definition at line 75 of file solver.h.


Constructor & Destructor Documentation

template<class DerivativeF, class StepF, class TraitsT>
animal::integration::Solver< DerivativeF, StepF, TraitsT >::Solver const DerivativeF &  df = DerivativeF(),
const StepF &  sf = StepF(),
const Traits tr = Traits()
[inline]
 

Just calls the base class constructor.

Definition at line 124 of file solver.h.

template<class DerivativeF, class StepF, class TraitsT>
virtual animal::integration::Solver< DerivativeF, StepF, TraitsT >::~Solver  )  [inline, virtual]
 

Destructor does nothing.

Definition at line 135 of file solver.h.


Member Function Documentation

template<class DerivativeF, class StepF, class TraitsT>
virtual void animal::integration::Solver< DerivativeF, StepF, TraitsT >::doStep const State initial_S,
State final_S,
const Derivative initial_D,
const Real  t,
const Real  h
[pure virtual]
 

This method implements the integration scheme to be applied (Euler, Runge-Kutta, ...) Given a state initial_S and a derivative initial_D at time t, integrate over a time step h and write the result in final_S.

This method is typically called indirectly by the operator () of the solver, but it may be called directly if the derivative at the beginning of the time step is known.

Implemented in animal::integration::Euler< DerivativeF, StepF, TraitsT >, animal::integration::Runge_Kutta_2< DerivativeF, StepF, TraitsT >, animal::integration::Runge_Kutta_4< DerivativeF, StepF, TraitsT >, animal::integration::Modified_Midpoint< N, DerivativeF, StepF, TraitsT >, and animal::integration::Modified_Midpoint_V< NStepF, DerivativeF, StepF, TraitsT >.

Referenced by animal::integration::Solver< DerivativeF, StepF, TraitsT >::operator()().

template<class DerivativeF, class StepF, class TraitsT>
template<class S>
void animal::integration::Solver< DerivativeF, StepF, TraitsT >::operator() S &  s,
const Real  t,
const Real  h
[inline]
 

Similar with the other call operator, except that the final state overwrites the initial state.

Definition at line 188 of file solver.h.

References animal::integration::Solver< DerivativeF, StepF, TraitsT >::operator()().

template<class DerivativeF, class StepF, class TraitsT>
template<class S>
void animal::integration::Solver< DerivativeF, StepF, TraitsT >::operator() const State initial_S,
S &  final_S,
const Real  t,
const Real  h
[inline]
 

Starting from state initial_S at time t, integrate time to t+h and write the result in final_S.

Definition at line 171 of file solver.h.

References animal::integration::Solver< DerivativeF, StepF, TraitsT >::D1, animal::integration::Solver< DerivativeF, StepF, TraitsT >::doStep(), and animal::integration::Solver< DerivativeF, StepF, TraitsT >::writeDerivative.

Referenced by animal::integration::Solver< DerivativeF, StepF, TraitsT >::operator()().

template<class DerivativeF, class StepF, class TraitsT>
void animal::integration::Solver< DerivativeF, StepF, TraitsT >::resize const SizeType  size  )  [inline]
 

Resize the auxiliary container(s) when the number of elements in the state grows.

Must be called at initialization. Automatically called when the Solver is included within a Driver. Calls method setSize to resize the auxiliary containers included in the derived classes.

Definition at line 206 of file solver.h.

References animal::integration::Solver< DerivativeF, StepF, TraitsT >::D1, animal::integration::Solver< DerivativeF, StepF, TraitsT >::setSize(), and animal::integration::Solver< DerivativeF, StepF, TraitsT >::traits.

template<class DerivativeF, class StepF, class TraitsT>
virtual void animal::integration::Solver< DerivativeF, StepF, TraitsT >::setSize const SizeType  size  )  [protected, pure virtual]
 

Pure virtual method used to resize all the additional auxiliary containers used by the derived classes.

Implemented in animal::integration::Euler< DerivativeF, StepF, TraitsT >, animal::integration::Runge_Kutta_2< DerivativeF, StepF, TraitsT >, animal::integration::Runge_Kutta_4< DerivativeF, StepF, TraitsT >, animal::integration::Modified_Midpoint< N, DerivativeF, StepF, TraitsT >, and animal::integration::Modified_Midpoint_V< NStepF, DerivativeF, StepF, TraitsT >.

Referenced by animal::integration::Solver< DerivativeF, StepF, TraitsT >::resize().


Member Data Documentation

template<class DerivativeF, class StepF, class TraitsT>
StepF animal::integration::Solver< DerivativeF, StepF, TraitsT >::applyStep
 

Increment state by a given derivative over a given time step.

Computation is performed by applying the call operator () to this object.

Definition at line 110 of file solver.h.

Referenced by animal::integration::Modified_Midpoint_V< NStepF, DerivativeF, StepF, TraitsT >::doStep(), animal::integration::Modified_Midpoint< N, DerivativeF, StepF, TraitsT >::doStep(), animal::integration::Runge_Kutta_4< DerivativeF, StepF, TraitsT >::doStep(), animal::integration::Runge_Kutta_2< DerivativeF, StepF, TraitsT >::doStep(), and animal::integration::Euler< DerivativeF, StepF, TraitsT >::doStep().

template<class DerivativeF, class StepF, class TraitsT>
Derivative animal::integration::Solver< DerivativeF, StepF, TraitsT >::D1 [protected]
 

An auxiliary derivative container used by all integration schemes.

Definition at line 217 of file solver.h.

Referenced by animal::integration::Solver< DerivativeF, StepF, TraitsT >::operator()(), and animal::integration::Solver< DerivativeF, StepF, TraitsT >::resize().

template<class DerivativeF, class StepF, class TraitsT>
Traits animal::integration::Solver< DerivativeF, StepF, TraitsT >::traits
 

An instance of Traits is defined in order to allow data storage within the Traits.

The basic solvers (Euler, Runge-Kutta, modified midpoint) do not use this feature.

Definition at line 101 of file solver.h.

Referenced by animal::integration::Solver< DerivativeF, StepF, TraitsT >::resize().

template<class DerivativeF, class StepF, class TraitsT>
DerivativeF animal::integration::Solver< DerivativeF, StepF, TraitsT >::writeDerivative
 

Computation of the derivative.

A functor (function object) is used to represent the computation of the derivative. Computation is performed by applying the call operator () to this object.

Definition at line 106 of file solver.h.

Referenced by animal::integration::Modified_Midpoint_V< NStepF, DerivativeF, StepF, TraitsT >::doStep(), animal::integration::Modified_Midpoint< N, DerivativeF, StepF, TraitsT >::doStep(), animal::integration::Runge_Kutta_4< DerivativeF, StepF, TraitsT >::doStep(), animal::integration::Runge_Kutta_2< DerivativeF, StepF, TraitsT >::doStep(), and animal::integration::Solver< DerivativeF, StepF, TraitsT >::operator()().


The documentation for this struct was generated from the following file:
Generated on Thu Dec 23 13:52:31 2004 by doxygen 1.3.6