]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /* |
2 | [auto_generated] | |
3 | boost/numeric/odeint/integrate/integrate_times.hpp | |
4 | ||
5 | [begin_description] | |
6 | Integration of ODEs with observation at user defined points | |
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_TIMES_HPP_INCLUDED | |
19 | #define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_TIMES_HPP_INCLUDED | |
20 | ||
21 | #include <boost/type_traits/is_same.hpp> | |
22 | ||
23 | #include <boost/range.hpp> | |
24 | ||
25 | #include <boost/numeric/odeint/stepper/stepper_categories.hpp> | |
26 | #include <boost/numeric/odeint/integrate/null_observer.hpp> | |
27 | #include <boost/numeric/odeint/integrate/check_adapter.hpp> | |
28 | #include <boost/numeric/odeint/integrate/detail/integrate_times.hpp> | |
29 | ||
30 | namespace boost { | |
31 | namespace numeric { | |
32 | namespace odeint { | |
33 | ||
34 | ||
35 | /* | |
36 | * \brief Integrates while calling the observer at the time points given by sequence [times_start, time_end) | |
37 | * the two overloads are needed in order to solve the forwarding problem | |
38 | */ | |
39 | template< class Stepper , class System , class State , class TimeIterator , class Time , class Observer , class StepOverflowChecker > | |
40 | size_t integrate_times( | |
41 | Stepper stepper , System system , State &start_state , | |
42 | TimeIterator times_start , TimeIterator times_end , Time dt , | |
43 | Observer observer , StepOverflowChecker checker ) | |
44 | { | |
45 | // unwrap references | |
46 | typedef typename odeint::unwrap_reference< Stepper >::type stepper_type; | |
47 | typedef typename odeint::unwrap_reference< Observer >::type observer_type; | |
48 | typedef typename odeint::unwrap_reference< StepOverflowChecker >::type checker_type; | |
49 | typedef typename stepper_type::stepper_category stepper_category; | |
50 | ||
51 | // pass on checked stepper and observer | |
52 | // checked_stepper/observer use references internally, so passing by value is fine | |
53 | return detail::integrate_times( | |
54 | checked_stepper<stepper_type, checker_type>(stepper, checker) , | |
55 | system , start_state , | |
56 | times_start , times_end , dt , | |
57 | checked_observer<observer_type, checker_type>(observer, checker), | |
58 | stepper_category() ); | |
59 | } | |
60 | ||
61 | /** | |
62 | * \brief Solves the forwarding problem, can be called with Boost.Range as start_state. | |
63 | */ | |
64 | template< class Stepper , class System , class State , class TimeIterator , class Time , class Observer , class StepOverflowChecker > | |
65 | size_t integrate_times( | |
66 | Stepper stepper , System system , const State &start_state , | |
67 | TimeIterator times_start , TimeIterator times_end , Time dt , | |
68 | Observer observer , StepOverflowChecker checker ) | |
69 | { | |
70 | typedef typename odeint::unwrap_reference< Stepper >::type stepper_type; | |
71 | typedef typename odeint::unwrap_reference< Observer >::type observer_type; | |
72 | typedef typename odeint::unwrap_reference< StepOverflowChecker >::type checker_type; | |
73 | typedef typename stepper_type::stepper_category stepper_category; | |
74 | ||
75 | stepper_type &st = stepper; | |
76 | observer_type &obs = observer; | |
77 | checker_type &chk = checker; | |
78 | ||
79 | return detail::integrate_times( | |
80 | checked_stepper<stepper_type, checker_type>(stepper, checker) , | |
81 | system , start_state , | |
82 | times_start , times_end , dt , | |
83 | checked_observer<observer_type, checker_type>(observer, checker), | |
84 | stepper_category() ); | |
85 | } | |
86 | ||
87 | /** | |
88 | * \brief The same function as above, but with the observation times given as range. | |
89 | */ | |
90 | template< class Stepper , class System , class State , class TimeRange , class Time , class Observer , class StepOverflowChecker > | |
91 | size_t integrate_times( | |
92 | Stepper stepper , System system , State &start_state , | |
93 | const TimeRange × , Time dt , | |
94 | Observer observer , StepOverflowChecker checker ) | |
95 | { | |
96 | return integrate_times( | |
97 | stepper , system , start_state , | |
98 | boost::begin( times ) , boost::end( times ) , dt , observer , checker ); | |
99 | } | |
100 | ||
101 | /** | |
102 | * \brief Solves the forwarding problem, can be called with Boost.Range as start_state. | |
103 | */ | |
104 | template< class Stepper , class System , class State , class TimeRange , class Time , class Observer , class StepOverflowChecker > | |
105 | size_t integrate_times( | |
106 | Stepper stepper , System system , const State &start_state , | |
107 | const TimeRange × , Time dt , | |
108 | Observer observer , StepOverflowChecker checker ) | |
109 | { | |
110 | return integrate_times( | |
111 | stepper , system , start_state , | |
112 | boost::begin( times ) , boost::end( times ) , dt , observer , checker ); | |
113 | } | |
114 | ||
115 | ||
116 | ||
117 | ||
118 | /* | |
119 | * The same functions as above, but without a StepOverflowChecker | |
120 | */ | |
121 | template< class Stepper , class System , class State , class TimeIterator , class Time , class Observer > | |
122 | size_t integrate_times( | |
123 | Stepper stepper , System system , State &start_state , | |
124 | TimeIterator times_start , TimeIterator times_end , Time dt , | |
125 | Observer observer ) | |
126 | { | |
127 | typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category; | |
128 | // simply don't use checked_* adapters | |
129 | return detail::integrate_times( | |
130 | stepper , system , start_state , | |
131 | times_start , times_end , dt , | |
132 | observer , stepper_category() ); | |
133 | } | |
134 | ||
135 | /** | |
136 | * \brief Solves the forwarding problem, can be called with Boost.Range as start_state. | |
137 | */ | |
138 | template< class Stepper , class System , class State , class TimeIterator , class Time , class Observer > | |
139 | size_t integrate_times( | |
140 | Stepper stepper , System system , const State &start_state , | |
141 | TimeIterator times_start , TimeIterator times_end , Time dt , | |
142 | Observer observer ) | |
143 | { | |
144 | typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category; | |
145 | return detail::integrate_times( | |
146 | stepper , system , start_state , | |
147 | times_start , times_end , dt , | |
148 | observer , stepper_category() ); | |
149 | } | |
150 | ||
151 | /** | |
152 | * \brief The same function as above, but with the observation times given as range. | |
153 | */ | |
154 | template< class Stepper , class System , class State , class TimeRange , class Time , class Observer > | |
155 | size_t integrate_times( | |
156 | Stepper stepper , System system , State &start_state , | |
157 | const TimeRange × , Time dt , | |
158 | Observer observer ) | |
159 | { | |
160 | return integrate_times( | |
161 | stepper , system , start_state , | |
162 | boost::begin( times ) , boost::end( times ) , dt , observer ); | |
163 | } | |
164 | ||
165 | /** | |
166 | * \brief Solves the forwarding problem, can be called with Boost.Range as start_state. | |
167 | */ | |
168 | template< class Stepper , class System , class State , class TimeRange , class Time , class Observer > | |
169 | size_t integrate_times( | |
170 | Stepper stepper , System system , const State &start_state , | |
171 | const TimeRange × , Time dt , | |
172 | Observer observer ) | |
173 | { | |
174 | return integrate_times( | |
175 | stepper , system , start_state , | |
176 | boost::begin( times ) , boost::end( times ) , dt , observer); | |
177 | } | |
178 | ||
179 | ||
180 | /********* DOXYGEN ***********/ | |
181 | ||
182 | /** | |
183 | * \fn size_t integrate_times( Stepper stepper , System system , State &start_state , TimeIterator times_start , TimeIterator times_end , Time dt , Observer observer ) | |
184 | * \brief Integrates the ODE with observer calls at given time points. | |
185 | * | |
186 | * Integrates the ODE given by system using the given stepper. This function | |
187 | * does observer calls at the subsequent time points given by the range | |
188 | * times_start, times_end. If the stepper has not step size control, the | |
189 | * step size might be reduced occasionally to ensure observer calls exactly | |
190 | * at the time points from the given sequence. If the stepper is a | |
191 | * ControlledStepper, the step size is adjusted to meet the error bounds, | |
192 | * but also might be reduced occasionally to ensure correct observer calls. | |
193 | * If a DenseOutputStepper is provided, the dense output functionality is | |
194 | * used to call the observer at the given times. The end time of the | |
195 | * integration is always *(end_time-1). | |
196 | * If a max_step_checker is provided as StepOverflowChecker, a | |
197 | * no_progress_error is thrown if too many steps (default: 500) are | |
198 | * performed without progress, i.e. in between observer calls. If no | |
199 | * checker is provided, no such overflow check is performed. | |
200 | * | |
201 | * \param stepper The stepper to be used for numerical integration. | |
202 | * \param system Function/Functor defining the rhs of the ODE. | |
203 | * \param start_state The initial condition x0. | |
204 | * \param times_start Iterator to the start time | |
205 | * \param times_end Iterator to the end time | |
206 | * \param dt The time step between observer calls, _not_ necessarily the | |
207 | * time step of the integration. | |
208 | * \param observer Function/Functor called at equidistant time intervals. | |
209 | * \param checker [optional] Functor to check for step count overflows, if no | |
210 | * checker is provided, no exception is thrown. | |
211 | * \return The number of steps performed. | |
212 | */ | |
213 | ||
214 | ||
215 | ||
216 | } // namespace odeint | |
217 | } // namespace numeric | |
218 | } // namespace boost | |
219 | ||
220 | ||
221 | ||
222 | #endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_TIMES_HPP_INCLUDED |