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>
26 #include <boost/numeric/odeint/integrate/check_adapter.hpp>
36 * the two overloads are needed in order to solve the forwarding problem
38 template< class Stepper , class System , class State , class Time , class Observer , class StepOverflowChecker >
39 Time integrate_n_steps(
40 Stepper stepper , System system , State &start_state ,
41 Time start_time , Time dt , size_t num_of_steps ,
42 Observer observer , StepOverflowChecker checker )
45 typedef typename odeint::unwrap_reference< Stepper >::type stepper_type;
46 typedef typename odeint::unwrap_reference< Observer >::type observer_type;
47 typedef typename odeint::unwrap_reference< StepOverflowChecker >::type checker_type;
48 typedef typename stepper_type::stepper_category stepper_category;
50 return detail::integrate_n_steps(
51 checked_stepper<stepper_type, checker_type>(stepper, checker),
52 system , start_state ,
53 start_time , dt , num_of_steps ,
54 checked_observer<observer_type, checker_type>(observer, checker),
59 * \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
61 template< class Stepper , class System , class State , class Time , class Observer , class StepOverflowChecker >
62 Time integrate_n_steps(
63 Stepper stepper , System system , const State &start_state ,
64 Time start_time , Time dt , size_t num_of_steps ,
65 Observer observer , StepOverflowChecker checker )
67 typedef typename odeint::unwrap_reference< Stepper >::type stepper_type;
68 typedef typename odeint::unwrap_reference< Observer >::type observer_type;
69 typedef typename odeint::unwrap_reference< StepOverflowChecker >::type checker_type;
70 typedef typename stepper_type::stepper_category stepper_category;
72 return detail::integrate_n_steps(
73 checked_stepper<stepper_type, checker_type>(stepper, checker),
74 system , start_state ,
75 start_time , dt , num_of_steps ,
76 checked_observer<observer_type, checker_type>(observer, checker),
82 * \brief The same function as above, but without checker.
84 template< class Stepper , class System , class State , class Time , class Observer >
85 Time integrate_n_steps(
86 Stepper stepper , System system , State &start_state ,
87 Time start_time , Time dt , size_t num_of_steps , Observer observer )
89 typedef typename odeint::unwrap_reference<Stepper>::type::stepper_category stepper_category;
91 return detail::integrate_n_steps(
92 stepper , system , start_state ,
93 start_time , dt , num_of_steps ,
94 observer , stepper_category() );
98 * \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
100 template< class Stepper , class System , class State , class Time , class Observer >
101 Time integrate_n_steps(
102 Stepper stepper , System system , const State &start_state ,
103 Time start_time , Time dt , size_t num_of_steps , Observer observer )
105 typedef typename odeint::unwrap_reference<Stepper>::type::stepper_category stepper_category;
107 return detail::integrate_n_steps(
108 stepper , system , start_state ,
109 start_time , dt , num_of_steps ,
110 observer , stepper_category() );
114 * \brief The same function as above, but without observer calls.
116 template< class Stepper , class System , class State , class Time >
117 Time integrate_n_steps(
118 Stepper stepper , System system , State &start_state ,
119 Time start_time , Time dt , size_t num_of_steps )
121 return integrate_n_steps(stepper, system, start_state, start_time,
122 dt, num_of_steps, null_observer());
126 * \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
128 template< class Stepper , class System , class State , class Time >
129 Time integrate_n_steps(
130 Stepper stepper , System system , const State &start_state ,
131 Time start_time , Time dt , size_t num_of_steps )
133 return integrate_n_steps(stepper, system, start_state, start_time,
134 dt, num_of_steps, null_observer());
139 /************* DOXYGEN *************/
141 * \fn Time integrate_n_steps( Stepper stepper , System system , State &start_state , Time start_time , Time dt , size_t num_of_steps , Observer observer )
142 * \brief Integrates the ODE with constant step size.
144 * This function is similar to integrate_const. The observer is called at
145 * equidistant time intervals t0 + n*dt.
146 * If the Stepper is a normal stepper without step size control, dt is also
147 * used for the numerical scheme. If a ControlledStepper is provided, the
148 * algorithm might reduce the step size to meet the error bounds, but it is
149 * ensured that the observer is always called at equidistant time points
150 * t0 + n*dt. If a DenseOutputStepper is used, the step size also may vary
151 * and the dense output is used to call the observer at equidistant time
152 * points. The final integration time is always t0 + num_of_steps*dt.
153 * If a max_step_checker is provided as StepOverflowChecker, a
154 * no_progress_errror is thrown if too many steps (default: 500) are
155 * performed without progress, i.e. in between observer calls. If no
156 * checker is provided, no such overflow check is performed.
159 * \param stepper The stepper to be used for numerical integration.
160 * \param system Function/Functor defining the rhs of the ODE.
161 * \param start_state The initial condition x0.
162 * \param start_time The initial time t0.
163 * \param dt The time step between observer calls, _not_ necessarily the
164 * time step of the integration.
165 * \param num_of_steps Number of steps to be performed
166 * \param observer Function/Functor called at equidistant time intervals.
167 * \param checker [optional] Functor to check for step count overflows, if no
168 * checker is provided, no exception is thrown.
169 * \return The number of steps performed.
174 } // namespace odeint
175 } // namespace numeric
180 #endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_N_STEPS_HPP_INCLUDED