diff options
Diffstat (limited to 'boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp')
-rw-r--r-- | boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp b/boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp index 743e57709c..7516d44087 100644 --- a/boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp +++ b/boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp @@ -7,7 +7,7 @@ [end_description] Copyright 2011-2013 Karsten Ahnert - Copyright 2011-2012 Mario Mulansky + Copyright 2011-2015 Mario Mulansky Copyright 2012 Christoph Koke Distributed under the Boost Software License, Version 1.0. @@ -25,6 +25,7 @@ #include <boost/numeric/odeint/stepper/stepper_categories.hpp> #include <boost/numeric/odeint/stepper/controlled_step_result.hpp> +#include <boost/numeric/odeint/integrate/max_step_checker.hpp> #include <boost/numeric/odeint/integrate/detail/integrate_const.hpp> #include <boost/numeric/odeint/util/bind.hpp> #include <boost/numeric/odeint/util/unwrap_reference.hpp> @@ -41,7 +42,7 @@ namespace odeint { namespace detail { // forward declaration -template< class Stepper , class System , class State , class Time , class Observer> +template< class Stepper , class System , class State , class Time , class Observer > size_t integrate_const( Stepper stepper , System system , State &start_state , Time start_time , Time end_time , Time dt , @@ -74,7 +75,7 @@ size_t integrate_adaptive( /* - * classical integrate adaptive + * integrate adaptive for controlled stepper */ template< class Stepper , class System , class State , class Time , class Observer > size_t integrate_adaptive( @@ -86,8 +87,7 @@ size_t integrate_adaptive( typename odeint::unwrap_reference< Observer >::type &obs = observer; typename odeint::unwrap_reference< Stepper >::type &st = stepper; - const size_t max_attempts = 1000; - const char *error_string = "Integrate adaptive : Maximal number of iterations reached. A step size could not be found."; + failed_step_checker fail_checker; // to throw a runtime_error if step size adjustment fails size_t count = 0; while( less_with_sign( start_time , end_time , dt ) ) { @@ -97,15 +97,14 @@ size_t integrate_adaptive( dt = end_time - start_time; } - size_t trials = 0; controlled_step_result res; do { res = st.try_step( system , start_state , start_time , dt ); - ++trials; + fail_checker(); // check number of failed steps } - while( ( res == fail ) && ( trials < max_attempts ) ); - if( trials == max_attempts ) BOOST_THROW_EXCEPTION( std::overflow_error( error_string ) ); + while( res == fail ); + fail_checker.reset(); // if we reach here, the step was successful -> reset fail checker ++count; } |