3 boost/numeric/odeint/integrate/integrate_n_steps.hpp
6 Integration of n steps with constant time size. Adaptive and dense-output methods are fully supported.
9 Copyright 2011-2013 Karsten Ahnert
10 Copyright 2011-2015 Mario Mulansky
12 Distributed under the Boost Software License, Version 1.0.
13 (See accompanying file LICENSE_1_0.txt or
14 copy at http://www.boost.org/LICENSE_1_0.txt)
18 #ifndef BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_N_STEPS_HPP_INCLUDED
19 #define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_N_STEPS_HPP_INCLUDED
21 #include <boost/type_traits/is_same.hpp>
23 #include <boost/numeric/odeint/stepper/stepper_categories.hpp>
24 #include <boost/numeric/odeint/integrate/null_observer.hpp>
25 #include <boost/numeric/odeint/integrate/detail/integrate_n_steps.hpp>
35 * the two overloads are needed in order to solve the forwarding problem
37 template< class Stepper , class System , class State , class Time , class Observer , class StepOverflowChecker >
38 Time integrate_n_steps(
39 Stepper stepper , System system , State &start_state ,
40 Time start_time , Time dt , size_t num_of_steps ,
41 Observer observer , StepOverflowChecker checker )
44 typedef typename odeint::unwrap_reference< Stepper >::type stepper_type;
45 typedef typename odeint::unwrap_reference< Observer >::type observer_type;
46 typedef typename odeint::unwrap_reference< StepOverflowChecker >::type checker_type;
47 typedef typename stepper_type::stepper_category stepper_category;
49 return detail::integrate_n_steps(
50 checked_stepper<stepper_type, checker_type>(stepper, checker),
51 system , start_state ,
52 start_time , dt , num_of_steps ,
53 checked_observer<observer_type, checker_type>(observer, checker),
58 * \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
60 template< class Stepper , class System , class State , class Time , class Observer , class StepOverflowChecker >
61 Time integrate_n_steps(
62 Stepper stepper , System system , const State &start_state ,
63 Time start_time , Time dt , size_t num_of_steps ,
64 Observer observer , StepOverflowChecker checker )
66 typedef typename odeint::unwrap_reference< Stepper >::type stepper_type;
67 typedef typename odeint::unwrap_reference< Observer >::type observer_type;
68 typedef typename odeint::unwrap_reference< StepOverflowChecker >::type checker_type;
69 typedef typename stepper_type::stepper_category stepper_category;
71 return detail::integrate_n_steps(
72 checked_stepper<stepper_type, checker_type>(stepper, checker),
73 system , start_state ,
74 start_time , dt , num_of_steps ,
75 checked_observer<observer_type, checker_type>(observer, checker),
81 * \brief The same function as above, but without checker.
83 template< class Stepper , class System , class State , class Time , class Observer >
84 Time integrate_n_steps(
85 Stepper stepper , System system , State &start_state ,
86 Time start_time , Time dt , size_t num_of_steps , Observer observer )
88 typedef typename odeint::unwrap_reference<Stepper>::type::stepper_category stepper_category;
90 return detail::integrate_n_steps(
91 stepper , system , start_state ,
92 start_time , dt , num_of_steps ,
93 observer , stepper_category() );
97 * \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
99 template< class Stepper , class System , class State , class Time , class Observer >
100 Time integrate_n_steps(
101 Stepper stepper , System system , const State &start_state ,
102 Time start_time , Time dt , size_t num_of_steps , Observer observer )
104 typedef typename odeint::unwrap_reference<Stepper>::type::stepper_category stepper_category;
106 return detail::integrate_n_steps(
107 stepper , system , start_state ,
108 start_time , dt , num_of_steps ,
109 observer , stepper_category() );
113 * \brief The same function as above, but without observer calls.
115 template< class Stepper , class System , class State , class Time >
116 Time integrate_n_steps(
117 Stepper stepper , System system , State &start_state ,
118 Time start_time , Time dt , size_t num_of_steps )
120 return integrate_n_steps(stepper, system, start_state, start_time,
121 dt, num_of_steps, null_observer());
125 * \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
127 template< class Stepper , class System , class State , class Time >
128 Time integrate_n_steps(
129 Stepper stepper , System system , const State &start_state ,
130 Time start_time , Time dt , size_t num_of_steps )
132 return integrate_n_steps(stepper, system, start_state, start_time,
133 dt, num_of_steps, null_observer());
138 /************* DOXYGEN *************/
140 * \fn Time integrate_n_steps( Stepper stepper , System system , State &start_state , Time start_time , Time dt , size_t num_of_steps , Observer observer )
141 * \brief Integrates the ODE with constant step size.
143 * This function is similar to integrate_const. The observer is called at
144 * equidistant time intervals t0 + n*dt.
145 * If the Stepper is a normal stepper without step size control, dt is also
146 * used for the numerical scheme. If a ControlledStepper is provided, the
147 * algorithm might reduce the step size to meet the error bounds, but it is
148 * ensured that the observer is always called at equidistant time points
149 * t0 + n*dt. If a DenseOutputStepper is used, the step size also may vary
150 * and the dense output is used to call the observer at equidistant time
151 * points. The final integration time is always t0 + num_of_steps*dt.
152 * If a max_step_checker is provided as StepOverflowChecker, a
153 * no_progress_errror is thrown if too many steps (default: 500) are
154 * performed without progress, i.e. in between observer calls. If no
155 * checker is provided, no such overflow check is performed.
158 * \param stepper The stepper to be used for numerical integration.
159 * \param system Function/Functor defining the rhs of the ODE.
160 * \param start_state The initial condition x0.
161 * \param start_time The initial time t0.
162 * \param dt The time step between observer calls, _not_ necessarily the
163 * time step of the integration.
164 * \param num_of_steps Number of steps to be performed
165 * \param observer Function/Functor called at equidistant time intervals.
166 * \param checker [optional] Functor to check for step count overflows, if no
167 * checker is provided, no exception is thrown.
168 * \return The number of steps performed.
173 } // namespace odeint
174 } // namespace numeric
179 #endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_N_STEPS_HPP_INCLUDED