integrate_const.hpp 5.3 KB

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