Chris@16
|
1 /*
|
Chris@16
|
2 [auto_generated]
|
Chris@16
|
3 boost/numeric/odeint/integrate/integrate_const.hpp
|
Chris@16
|
4
|
Chris@16
|
5 [begin_description]
|
Chris@16
|
6 Constant integration of ODEs, meaning that the state of the ODE is observed on constant time intervals.
|
Chris@16
|
7 The routines makes full use of adaptive and dense-output methods.
|
Chris@16
|
8 [end_description]
|
Chris@16
|
9
|
Chris@101
|
10 Copyright 2011-2013 Karsten Ahnert
|
Chris@101
|
11 Copyright 2011-2012 Mario Mulansky
|
Chris@16
|
12
|
Chris@16
|
13 Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
14 (See accompanying file LICENSE_1_0.txt or
|
Chris@16
|
15 copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
16 */
|
Chris@16
|
17
|
Chris@16
|
18
|
Chris@16
|
19 #ifndef BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_CONST_HPP_INCLUDED
|
Chris@16
|
20 #define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_CONST_HPP_INCLUDED
|
Chris@16
|
21
|
Chris@16
|
22 #include <boost/type_traits/is_same.hpp>
|
Chris@16
|
23
|
Chris@16
|
24 #include <boost/numeric/odeint/stepper/stepper_categories.hpp>
|
Chris@16
|
25 #include <boost/numeric/odeint/integrate/null_observer.hpp>
|
Chris@16
|
26 #include <boost/numeric/odeint/integrate/detail/integrate_const.hpp>
|
Chris@16
|
27 #include <boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp>
|
Chris@16
|
28
|
Chris@16
|
29 namespace boost {
|
Chris@16
|
30 namespace numeric {
|
Chris@16
|
31 namespace odeint {
|
Chris@16
|
32
|
Chris@16
|
33
|
Chris@16
|
34
|
Chris@16
|
35
|
Chris@16
|
36
|
Chris@16
|
37 /*
|
Chris@16
|
38 * Integrates with constant time step dt.
|
Chris@16
|
39 */
|
Chris@16
|
40 template< class Stepper , class System , class State , class Time , class Observer >
|
Chris@16
|
41 size_t integrate_const(
|
Chris@16
|
42 Stepper stepper , System system , State &start_state ,
|
Chris@16
|
43 Time start_time , Time end_time , Time dt ,
|
Chris@16
|
44 Observer observer
|
Chris@16
|
45 )
|
Chris@16
|
46 {
|
Chris@101
|
47 typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
|
Chris@16
|
48 // we want to get as fast as possible to the end
|
Chris@16
|
49 if( boost::is_same< null_observer , Observer >::value )
|
Chris@16
|
50 {
|
Chris@16
|
51 return detail::integrate_adaptive(
|
Chris@16
|
52 stepper , system , start_state ,
|
Chris@16
|
53 start_time , end_time , dt ,
|
Chris@101
|
54 observer , stepper_category() );
|
Chris@16
|
55 }
|
Chris@16
|
56 else
|
Chris@16
|
57 {
|
Chris@16
|
58 return detail::integrate_const( stepper , system , start_state ,
|
Chris@16
|
59 start_time , end_time , dt ,
|
Chris@101
|
60 observer , stepper_category() );
|
Chris@16
|
61 }
|
Chris@16
|
62 }
|
Chris@16
|
63
|
Chris@16
|
64 /**
|
Chris@16
|
65 * \brief Second version to solve the forwarding problem,
|
Chris@16
|
66 * can be called with Boost.Range as start_state.
|
Chris@16
|
67 */
|
Chris@16
|
68 template< class Stepper , class System , class State , class Time , class Observer >
|
Chris@16
|
69 size_t integrate_const(
|
Chris@16
|
70 Stepper stepper , System system , const State &start_state ,
|
Chris@16
|
71 Time start_time , Time end_time , Time dt ,
|
Chris@16
|
72 Observer observer
|
Chris@16
|
73 )
|
Chris@16
|
74 {
|
Chris@101
|
75 typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
|
Chris@16
|
76 // we want to get as fast as possible to the end
|
Chris@16
|
77 if( boost::is_same< null_observer , Observer >::value )
|
Chris@16
|
78 {
|
Chris@16
|
79 return detail::integrate_adaptive(
|
Chris@16
|
80 stepper , system , start_state ,
|
Chris@16
|
81 start_time , end_time , dt ,
|
Chris@101
|
82 observer , stepper_category() );
|
Chris@16
|
83 }
|
Chris@16
|
84 else
|
Chris@16
|
85 {
|
Chris@16
|
86 return detail::integrate_const( stepper , system , start_state ,
|
Chris@16
|
87 start_time , end_time , dt ,
|
Chris@101
|
88 observer , stepper_category() );
|
Chris@16
|
89 }
|
Chris@16
|
90 }
|
Chris@16
|
91
|
Chris@16
|
92
|
Chris@16
|
93
|
Chris@16
|
94
|
Chris@16
|
95
|
Chris@16
|
96 /**
|
Chris@16
|
97 * \brief integrate_const without observer calls
|
Chris@16
|
98 */
|
Chris@16
|
99 template< class Stepper , class System , class State , class Time >
|
Chris@16
|
100 size_t integrate_const(
|
Chris@16
|
101 Stepper stepper , System system , State &start_state ,
|
Chris@16
|
102 Time start_time , Time end_time , Time dt
|
Chris@16
|
103 )
|
Chris@16
|
104 {
|
Chris@16
|
105 return integrate_const( stepper , system , start_state , start_time , end_time , dt , null_observer() );
|
Chris@16
|
106 }
|
Chris@16
|
107
|
Chris@16
|
108 /**
|
Chris@16
|
109 * \brief Second version to solve the forwarding problem,
|
Chris@16
|
110 * can be called with Boost.Range as start_state.
|
Chris@16
|
111 */
|
Chris@16
|
112 template< class Stepper , class System , class State , class Time >
|
Chris@16
|
113 size_t integrate_const(
|
Chris@16
|
114 Stepper stepper , System system , const State &start_state ,
|
Chris@16
|
115 Time start_time , Time end_time , Time dt
|
Chris@16
|
116 )
|
Chris@16
|
117 {
|
Chris@16
|
118 return integrate_const( stepper , system , start_state , start_time , end_time , dt , null_observer() );
|
Chris@16
|
119 }
|
Chris@16
|
120
|
Chris@16
|
121
|
Chris@16
|
122
|
Chris@16
|
123
|
Chris@16
|
124
|
Chris@16
|
125
|
Chris@16
|
126 /********* DOXYGEN *********/
|
Chris@16
|
127 /**
|
Chris@16
|
128 * \fn integrate_const( Stepper stepper , System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer )
|
Chris@16
|
129 * \brief Integrates the ODE with constant step size.
|
Chris@16
|
130 *
|
Chris@16
|
131 * Integrates the ODE defined by system using the given stepper.
|
Chris@16
|
132 * This method ensures that the observer is called at constant intervals dt.
|
Chris@16
|
133 * If the Stepper is a normal stepper without step size control, dt is also
|
Chris@16
|
134 * used for the numerical scheme. If a ControlledStepper is provided, the
|
Chris@16
|
135 * algorithm might reduce the step size to meet the error bounds, but it is
|
Chris@16
|
136 * ensured that the observer is always called at equidistant time points
|
Chris@16
|
137 * t0 + n*dt. If a DenseOutputStepper is used, the step size also may vary
|
Chris@16
|
138 * and the dense output is used to call the observer at equidistant time
|
Chris@16
|
139 * points.
|
Chris@16
|
140 *
|
Chris@16
|
141 * \param stepper The stepper to be used for numerical integration.
|
Chris@16
|
142 * \param system Function/Functor defining the rhs of the ODE.
|
Chris@16
|
143 * \param start_state The initial condition x0.
|
Chris@16
|
144 * \param start_time The initial time t0.
|
Chris@16
|
145 * \param end_time The final integration time tend.
|
Chris@16
|
146 * \param dt The time step between observer calls, _not_ necessarily the
|
Chris@16
|
147 * time step of the integration.
|
Chris@16
|
148 * \param observer Function/Functor called at equidistant time intervals.
|
Chris@16
|
149 * \return The number of steps performed.
|
Chris@16
|
150 */
|
Chris@16
|
151
|
Chris@16
|
152 } // namespace odeint
|
Chris@16
|
153 } // namespace numeric
|
Chris@16
|
154 } // namespace boost
|
Chris@16
|
155
|
Chris@16
|
156
|
Chris@16
|
157
|
Chris@16
|
158 #endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_CONST_HPP_INCLUDED
|