integrate_adaptive.hpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. [auto_generated]
  3. boost/numeric/odeint/integrate/integrate_adaptive.hpp
  4. [begin_description]
  5. Adaptive integration of ODEs.
  6. [end_description]
  7. Copyright 2011-2013 Karsten Ahnert
  8. Copyright 2011-2015 Mario Mulansky
  9. Distributed under the Boost Software License, Version 1.0.
  10. (See accompanying file LICENSE_1_0.txt or
  11. copy at http://www.boost.org/LICENSE_1_0.txt)
  12. */
  13. #ifndef BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_ADAPTIVE_HPP_INCLUDED
  14. #define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_ADAPTIVE_HPP_INCLUDED
  15. #include <boost/type_traits/is_same.hpp>
  16. #include <boost/numeric/odeint/stepper/stepper_categories.hpp>
  17. #include <boost/numeric/odeint/integrate/null_observer.hpp>
  18. #include <boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp>
  19. namespace boost {
  20. namespace numeric {
  21. namespace odeint {
  22. /*
  23. * the two overloads are needed in order to solve the forwarding problem
  24. */
  25. template< class Stepper , class System , class State , class Time , class Observer >
  26. size_t integrate_adaptive(
  27. Stepper stepper , System system , State &start_state ,
  28. Time start_time , Time end_time , Time dt ,
  29. Observer observer )
  30. {
  31. typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
  32. return detail::integrate_adaptive(
  33. stepper , system , start_state ,
  34. start_time , end_time , dt ,
  35. observer , stepper_category() );
  36. /*
  37. * Suggestion for a new extendable version:
  38. *
  39. * integrator_adaptive< Stepper , System, State , Time , Observer , typename Stepper::stepper_category > integrator;
  40. * return integrator.run( stepper , system , start_state , start_time , end_time , dt , observer );
  41. */
  42. }
  43. /**
  44. * \brief Second version to solve the forwarding problem,
  45. * can be called with Boost.Range as start_state.
  46. */
  47. template< class Stepper , class System , class State , class Time , class Observer >
  48. size_t integrate_adaptive(
  49. Stepper stepper , System system , const State &start_state ,
  50. Time start_time , Time end_time , Time dt ,
  51. Observer observer )
  52. {
  53. typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
  54. return detail::integrate_adaptive(
  55. stepper , system , start_state ,
  56. start_time , end_time , dt ,
  57. observer , stepper_category() );
  58. }
  59. /**
  60. * \brief integrate_adaptive without an observer.
  61. */
  62. template< class Stepper , class System , class State , class Time >
  63. size_t integrate_adaptive(
  64. Stepper stepper , System system , State &start_state ,
  65. Time start_time , Time end_time , Time dt )
  66. {
  67. return integrate_adaptive( stepper , system , start_state , start_time , end_time , dt , null_observer() );
  68. }
  69. /**
  70. * \brief Second version to solve the forwarding problem,
  71. * can be called with Boost.Range as start_state.
  72. */
  73. template< class Stepper , class System , class State , class Time >
  74. size_t integrate_adaptive(
  75. Stepper stepper , System system , const State &start_state ,
  76. Time start_time , Time end_time , Time dt )
  77. {
  78. return integrate_adaptive( stepper , system , start_state , start_time , end_time , dt , null_observer() );
  79. }
  80. /************* DOXYGEN ************/
  81. /**
  82. * \fn integrate_adaptive( Stepper stepper , System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer )
  83. * \brief Integrates the ODE with adaptive step size.
  84. *
  85. * This function integrates the ODE given by system with the given stepper.
  86. * The observer is called after each step. If the stepper has no error
  87. * control, the step size remains constant and the observer is called at
  88. * equidistant time points t0+n*dt. If the stepper is a ControlledStepper,
  89. * the step size is adjusted and the observer is called in non-equidistant
  90. * intervals.
  91. *
  92. * \param stepper The stepper to be used for numerical integration.
  93. * \param system Function/Functor defining the rhs of the ODE.
  94. * \param start_state The initial condition x0.
  95. * \param start_time The initial time t0.
  96. * \param end_time The final integration time tend.
  97. * \param dt The time step between observer calls, _not_ necessarily the
  98. * time step of the integration.
  99. * \param observer Function/Functor called at equidistant time intervals.
  100. * \return The number of steps performed.
  101. */
  102. } // namespace odeint
  103. } // namespace numeric
  104. } // namespace boost
  105. #endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_ADAPTIVE_HPP_INCLUDED