integrate_const.hpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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/integrate/null_observer.hpp>
  19. #include <boost/numeric/odeint/integrate/detail/integrate_const.hpp>
  20. #include <boost/numeric/odeint/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. // we want to get as fast as possible to the end
  35. if( boost::is_same< null_observer , Observer >::value )
  36. {
  37. return detail::integrate_adaptive(
  38. stepper , system , start_state ,
  39. start_time , end_time , dt ,
  40. observer , typename Stepper::stepper_category() );
  41. }
  42. else
  43. {
  44. return detail::integrate_const( stepper , system , start_state ,
  45. start_time , end_time , dt ,
  46. observer , typename Stepper::stepper_category() );
  47. }
  48. }
  49. /**
  50. * \brief Second version to solve the forwarding problem,
  51. * can be called with Boost.Range as start_state.
  52. */
  53. template< class Stepper , class System , class State , class Time , class Observer >
  54. size_t integrate_const(
  55. Stepper stepper , System system , const State &start_state ,
  56. Time start_time , Time end_time , Time dt ,
  57. Observer observer
  58. )
  59. {
  60. // we want to get as fast as possible to the end
  61. if( boost::is_same< null_observer , Observer >::value )
  62. {
  63. return detail::integrate_adaptive(
  64. stepper , system , start_state ,
  65. start_time , end_time , dt ,
  66. observer , typename Stepper::stepper_category() );
  67. }
  68. else
  69. {
  70. return detail::integrate_const( stepper , system , start_state ,
  71. start_time , end_time , dt ,
  72. observer , typename Stepper::stepper_category() );
  73. }
  74. }
  75. /**
  76. * \brief integrate_const without observer calls
  77. */
  78. template< class Stepper , class System , class State , class Time >
  79. size_t integrate_const(
  80. Stepper stepper , System system , State &start_state ,
  81. Time start_time , Time end_time , Time dt
  82. )
  83. {
  84. return integrate_const( stepper , system , start_state , start_time , end_time , dt , null_observer() );
  85. }
  86. /**
  87. * \brief Second version to solve the forwarding problem,
  88. * can be called with Boost.Range as start_state.
  89. */
  90. template< class Stepper , class System , class State , class Time >
  91. size_t integrate_const(
  92. Stepper stepper , System system , const State &start_state ,
  93. Time start_time , Time end_time , Time dt
  94. )
  95. {
  96. return integrate_const( stepper , system , start_state , start_time , end_time , dt , null_observer() );
  97. }
  98. /********* DOXYGEN *********/
  99. /**
  100. * \fn integrate_const( Stepper stepper , System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer )
  101. * \brief Integrates the ODE with constant step size.
  102. *
  103. * Integrates the ODE defined by system using the given stepper.
  104. * This method ensures that the observer is called at constant intervals dt.
  105. * If the Stepper is a normal stepper without step size control, dt is also
  106. * used for the numerical scheme. If a ControlledStepper is provided, the
  107. * algorithm might reduce the step size to meet the error bounds, but it is
  108. * ensured that the observer is always called at equidistant time points
  109. * t0 + n*dt. If a DenseOutputStepper is used, the step size also may vary
  110. * and the dense output is used to call the observer at equidistant time
  111. * points.
  112. *
  113. * \param stepper The stepper to be used for numerical integration.
  114. * \param system Function/Functor defining the rhs of the ODE.
  115. * \param start_state The initial condition x0.
  116. * \param start_time The initial time t0.
  117. * \param end_time The final integration time tend.
  118. * \param dt The time step between observer calls, _not_ necessarily the
  119. * time step of the integration.
  120. * \param observer Function/Functor called at equidistant time intervals.
  121. * \return The number of steps performed.
  122. */
  123. } // namespace odeint
  124. } // namespace numeric
  125. } // namespace boost
  126. #endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_CONST_HPP_INCLUDED