]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /* |
2 | [auto_generated] | |
3 | boost/numeric/odeint/integrate/integrate_n_steps.hpp | |
4 | ||
5 | [begin_description] | |
6 | Integration of n steps with constant time size. Adaptive and dense-output methods are fully supported. | |
7 | [end_description] | |
8 | ||
9 | Copyright 2011-2013 Karsten Ahnert | |
10 | Copyright 2011-2015 Mario Mulansky | |
11 | ||
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) | |
15 | */ | |
16 | ||
17 | ||
18 | #ifndef BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_N_STEPS_HPP_INCLUDED | |
19 | #define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_N_STEPS_HPP_INCLUDED | |
20 | ||
21 | #include <boost/type_traits/is_same.hpp> | |
22 | ||
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 | ||
27 | namespace boost { | |
28 | namespace numeric { | |
29 | namespace odeint { | |
30 | ||
31 | ||
32 | /* | |
33 | * Integrates n steps | |
34 | * | |
35 | * the two overloads are needed in order to solve the forwarding problem | |
36 | */ | |
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 ) | |
42 | { | |
43 | // unwrap references | |
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; | |
48 | ||
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), | |
54 | stepper_category() ); | |
55 | } | |
56 | ||
57 | /** | |
58 | * \brief Solves the forwarding problem, can be called with Boost.Range as start_state. | |
59 | */ | |
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 ) | |
65 | { | |
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; | |
70 | ||
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), | |
76 | stepper_category() ); | |
77 | } | |
78 | ||
79 | ||
80 | /** | |
81 | * \brief The same function as above, but without checker. | |
82 | */ | |
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 ) | |
87 | { | |
88 | typedef typename odeint::unwrap_reference<Stepper>::type::stepper_category stepper_category; | |
89 | ||
90 | return detail::integrate_n_steps( | |
91 | stepper , system , start_state , | |
92 | start_time , dt , num_of_steps , | |
93 | observer , stepper_category() ); | |
94 | } | |
95 | ||
96 | /** | |
97 | * \brief Solves the forwarding problem, can be called with Boost.Range as start_state. | |
98 | */ | |
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 ) | |
103 | { | |
104 | typedef typename odeint::unwrap_reference<Stepper>::type::stepper_category stepper_category; | |
105 | ||
106 | return detail::integrate_n_steps( | |
107 | stepper , system , start_state , | |
108 | start_time , dt , num_of_steps , | |
109 | observer , stepper_category() ); | |
110 | } | |
111 | ||
112 | /** | |
113 | * \brief The same function as above, but without observer calls. | |
114 | */ | |
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 ) | |
119 | { | |
120 | return integrate_n_steps(stepper, system, start_state, start_time, | |
121 | dt, num_of_steps, null_observer()); | |
122 | } | |
123 | ||
124 | /** | |
125 | * \brief Solves the forwarding problem, can be called with Boost.Range as start_state. | |
126 | */ | |
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 ) | |
131 | { | |
132 | return integrate_n_steps(stepper, system, start_state, start_time, | |
133 | dt, num_of_steps, null_observer()); | |
134 | } | |
135 | ||
136 | ||
137 | ||
138 | /************* DOXYGEN *************/ | |
139 | /** | |
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. | |
142 | * | |
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. | |
156 | ||
157 | * | |
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. | |
169 | */ | |
170 | ||
171 | ||
172 | ||
173 | } // namespace odeint | |
174 | } // namespace numeric | |
175 | } // namespace boost | |
176 | ||
177 | ||
178 | ||
179 | #endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_N_STEPS_HPP_INCLUDED |