AnimaL |
Tutorial |
Documentation |
#include <solver.h>
Inheritance diagram for animal::integration::Solver< DerivativeF, StepF, TraitsT >:
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:
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. |
|
|
|
|
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 >. |
|
|
|
Just calls the base class constructor.
|
|
Destructor does nothing.
|
|
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()(). |
|
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()(). |
|
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()(). |
|
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. |
|
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(). |
|
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(). |
|
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(). |
|
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(). |
|
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()(). |