integrate_adaptive.hpp 4.4 KB

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