adaptive_time_iterator.hpp 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*
  2. [auto_generated]
  3. boost/numeric/odeint/iterator/adaptive_time_iterator.hpp
  4. [begin_description]
  5. Iterator for iterating throught the solution of an ODE with adaptive step size. The dereferenced types containes also the time.
  6. [end_description]
  7. Copyright 2012-2013 Karsten Ahnert
  8. Copyright 2012-2013 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_ITERATOR_ADAPTIVE_TIME_ITERATOR_HPP_INCLUDED
  14. #define BOOST_NUMERIC_ODEINT_ITERATOR_ADAPTIVE_TIME_ITERATOR_HPP_INCLUDED
  15. #include <boost/numeric/odeint/stepper/stepper_categories.hpp>
  16. #include <boost/numeric/odeint/util/stepper_traits.hpp>
  17. #include <boost/numeric/odeint/iterator/impl/adaptive_iterator_impl.hpp>
  18. namespace boost {
  19. namespace numeric {
  20. namespace odeint {
  21. /* use the adaptive_iterator_impl with the right tags */
  22. template< class Stepper , class System , class State
  23. #ifndef DOXYGEN_SKIP
  24. , class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
  25. #endif
  26. >
  27. class adaptive_time_iterator : public adaptive_iterator_impl<
  28. adaptive_time_iterator< Stepper , System , State , StepperTag > ,
  29. Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag
  30. >
  31. {
  32. typedef typename traits::time_type< Stepper >::type time_type;
  33. typedef adaptive_time_iterator< Stepper , System , State , StepperTag > iterator_type;
  34. public:
  35. adaptive_time_iterator( Stepper stepper , System sys , State &s , time_type t_start , time_type t_end , time_type dt )
  36. : adaptive_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s , t_start , t_end , dt )
  37. {}
  38. adaptive_time_iterator( Stepper stepper , System sys , State &s )
  39. : adaptive_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s )
  40. {}
  41. };
  42. template< class Stepper , class System , class State >
  43. adaptive_time_iterator< Stepper , System , State > make_adaptive_time_iterator_begin(
  44. Stepper stepper ,
  45. System system ,
  46. State &x ,
  47. typename traits::time_type< Stepper >::type t_start ,
  48. typename traits::time_type< Stepper >::type t_end ,
  49. typename traits::time_type< Stepper >::type dt )
  50. {
  51. return adaptive_time_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt );
  52. }
  53. template< class Stepper , class System , class State >
  54. adaptive_time_iterator< Stepper , System , State > make_adaptive_time_iterator_end(
  55. Stepper stepper ,
  56. System system ,
  57. State &x )
  58. {
  59. return adaptive_time_iterator< Stepper , System , State >( stepper , system , x );
  60. }
  61. template< class Stepper , class System , class State >
  62. std::pair< adaptive_time_iterator< Stepper , System , State > , adaptive_time_iterator< Stepper , System , State > >
  63. make_adaptive_time_range(
  64. Stepper stepper ,
  65. System system ,
  66. State &x ,
  67. typename traits::time_type< Stepper >::type t_start ,
  68. typename traits::time_type< Stepper >::type t_end ,
  69. typename traits::time_type< Stepper >::type dt )
  70. {
  71. return std::make_pair(
  72. adaptive_time_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt ) ,
  73. adaptive_time_iterator< Stepper , System , State >( stepper , system , x ) );
  74. }
  75. /**
  76. * \class adaptive_time_iterator
  77. *
  78. * \brief ODE Iterator with adaptive step size. The value type of this iterator is a std::pair containing state and time.
  79. *
  80. * Implements an iterator representing the solution of an ODE from t_start
  81. * to t_end evaluated at steps with an adaptive step size dt.
  82. * After each iteration the iterator dereferences to a pair containing state
  83. * and time at the next time point t+dt where dt is controlled by the stepper.
  84. * This iterator can be used with ControlledSteppers and
  85. * DenseOutputSteppers and it always makes use of the all the given steppers
  86. * capabilities. A for_each over such an iterator range behaves similar to
  87. * the integrate_adaptive routine.
  88. *
  89. * adaptive_iterator is a model of single-pass iterator.
  90. *
  91. * The value type of this iterator is a std::pair of state and time of the stepper.
  92. *
  93. * \tparam Stepper The stepper type which should be used during the iteration.
  94. * \tparam System The type of the system function (ODE) which should be solved.
  95. * \tparam State The state type of the ODE.
  96. */
  97. /**
  98. * \fn make_adaptive_time_iterator_begin( Stepper stepper , System system , State &x ,
  99. typename traits::time_type< Stepper >::type t_start ,
  100. typename traits::time_type< Stepper >::type t_end ,
  101. typename traits::time_type< Stepper >::type dt )
  102. *
  103. * \brief Factory function for adaptive_time_iterator. Constructs a begin iterator.
  104. *
  105. * \param stepper The stepper to use during the iteration.
  106. * \param system The system function (ODE) to solve.
  107. * \param x The initial state. adaptive_time_iterator stores a reference of s and changes its value during the iteration.
  108. * \param t_start The initial time.
  109. * \param t_end The end time, at which the iteration should stop.
  110. * \param dt The initial time step.
  111. * \returns The adaptive time iterator.
  112. */
  113. /**
  114. * \fn make_adaptive_time_iterator_end( Stepper stepper , System system , State &x )
  115. * \brief Factory function for adaptive_time_iterator. Constructs a end iterator.
  116. *
  117. * \param stepper The stepper to use during the iteration.
  118. * \param system The system function (ODE) to solve.
  119. * \param x The initial state. adaptive_time_iterator stores a reference of s and changes its value during the iteration.
  120. * \returns The adaptive time iterator.
  121. */
  122. /**
  123. * \fn make_adaptive_time_range( Stepper stepper , System system , State &x ,
  124. typename traits::time_type< Stepper >::type t_start ,
  125. typename traits::time_type< Stepper >::type t_end ,
  126. typename traits::time_type< Stepper >::type dt )
  127. *
  128. * \brief Factory function to construct a single pass range of adaptive time iterators. A range is here a pair of adaptive_time_iterators.
  129. *
  130. * \param stepper The stepper to use during the iteration.
  131. * \param system The system function (ODE) to solve.
  132. * \param x The initial state. adaptive_time_iterator stores a reference of s and changes its value during the iteration.
  133. * \param t_start The initial time.
  134. * \param t_end The end time, at which the iteration should stop.
  135. * \param dt The initial time step.
  136. * \returns The adaptive time range.
  137. */
  138. } // namespace odeint
  139. } // namespace numeric
  140. } // namespace boost
  141. #endif // BOOST_NUMERIC_ODEINT_ITERATOR_ADAPTIVE_TIME_ITERATOR_HPP_INCLUDED