|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69821 - in sandbox/odeint/branches/karsten: boost/numeric/odeint/integrate boost/numeric/odeint/integrate/detail boost/numeric/odeint/stepper libs/numeric/odeint/regression_test
From: karsten.ahnert_at_[hidden]
Date: 2011-03-10 11:51:09
Author: karsten
Date: 2011-03-10 11:51:05 EST (Thu, 10 Mar 2011)
New Revision: 69821
URL: http://svn.boost.org/trac/boost/changeset/69821
Log:
integrate functions
Text files modified:
sandbox/odeint/branches/karsten/boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp | 6 ++--
sandbox/odeint/branches/karsten/boost/numeric/odeint/integrate/detail/integrate_const.hpp | 49 +++++++++++++++++++++++++++++++--------
sandbox/odeint/branches/karsten/boost/numeric/odeint/integrate/integrate.hpp | 4 +++
sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/controlled_error_stepper.hpp | 1
sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/integrate_functions.cpp | 9 ++++---
5 files changed, 51 insertions(+), 18 deletions(-)
Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp 2011-03-10 11:51:05 EST (Thu, 10 Mar 2011)
@@ -14,13 +14,13 @@
namespace detail {
template< class Stepper , class System , class State , class Time , class Observer >
-size_t integrate_adaptive( Stepper stepper , System system , State &start_state , Time start_time , const Time &end_time , Time dt , Observer observer , stepper_tag )
+size_t integrate_adaptive( Stepper stepper , System system , State &start_state , Time start_time , const Time &end_time , Time dt , Observer &observer , stepper_tag )
{
size_t count = 0;
while( start_time < end_time )
{
stepper.do_step( system , start_state , start_time , dt );
- observer( start_state , start_time );
+ observer( start_time , start_state );
start_time += dt;
++count;
}
@@ -28,7 +28,7 @@
}
template< class Stepper , class System , class State , class Time , class Observer >
-size_t integrate_adaptive( Stepper stepper , System system , State &start_state , const Time &start_time , const Time &end_time , const Time &dt , Observer observer , error_stepper_tag )
+size_t integrate_adaptive( Stepper stepper , System system , State &start_state , const Time &start_time , const Time &end_time , const Time &dt , Observer &observer , error_stepper_tag )
{
return 0;
}
Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/integrate/detail/integrate_const.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/integrate/detail/integrate_const.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/integrate/detail/integrate_const.hpp 2011-03-10 11:51:05 EST (Thu, 10 Mar 2011)
@@ -8,6 +8,9 @@
#ifndef BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_CONST_HPP_
#define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_CONST_HPP_
+#include <iostream>
+using namespace std;
+
namespace boost {
namespace numeric {
@@ -15,30 +18,54 @@
namespace detail {
template< class Stepper , class System , class State , class Time , class Observer >
-size_t integrate_const( Stepper stepper , System system , State &start_state , const Time &start_time , const Time &end_time , const Time &dt , Observer observer , stepper_tag )
+size_t integrate_const( Stepper stepper , System system , State &start_state , Time start_time , const Time &end_time , const Time &dt , Observer &observer , stepper_tag )
{
- observer( start_state , start_time );
+ while( start_time < end_time )
+ {
+ observer( start_time , start_state );
+ stepper.do_step( system , start_state , start_time , dt );
+ start_time += dt;
+ }
+ observer( start_time , start_state );
return 0;
}
template< class Stepper , class System , class State , class Time , class Observer >
-size_t integrate_const( Stepper stepper , System system , State &start_state , const Time &start_time , const Time &end_time , const Time &dt , Observer observer , error_stepper_tag )
+size_t integrate_const( Stepper stepper , System system , State &start_state , Time start_time , const Time &end_time , const Time &dt , Observer observer , controlled_stepper_tag )
{
- observer( start_state , start_time );
- return 0;
-}
+ clog << "huhu" << endl;
+ Time time_step = dt;
+ while( start_time < end_time )
+ {
+ observer( start_time , start_state );
+ Time next_time = start_time + dt;
+ while( start_time < next_time )
+ {
+ if( ( start_time + time_step ) > next_time )
+ {
+ time_step = next_time - start_time;
+ }
+ size_t trials = 0;
+
+ // the following loop can maybe be taken from another integrate functions
+ controlled_step_result res = success_step_size_unchanged;
+ do
+ {
+ stepper.try_step( system , start_state , start_time , time_step );
+ ++trials;
+ }
+ while( ( res == step_size_decreased ) || ( trials < 1000 ) );
+ }
+ }
+ observer( start_time , start_state );
-template< class Stepper , class System , class State , class Time , class Observer >
-size_t integrate_const( Stepper stepper , System system , State &start_state , const Time &start_time , const Time &end_time , const Time &dt , Observer observer , controlled_stepper_tag )
-{
- observer( start_state , start_time );
return 0;
}
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_const( Stepper stepper , System system , State &start_state , const Time &start_time , const Time &end_time , const Time &dt , Observer observer , dense_output_stepper_tag )
{
- observer( start_state , start_time );
+ observer( start_time , start_state );
return 0;
}
Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/integrate/integrate.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/integrate/integrate.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/integrate/integrate.hpp 2011-03-10 11:51:05 EST (Thu, 10 Mar 2011)
@@ -34,6 +34,10 @@
+
+/*
+ * Integrates with constant time step dt.
+ */
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate( Stepper stepper , System system , State &start_state , const Time &start_time , const Time &end_time , const Time &dt , Observer observer )
{
Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/controlled_error_stepper.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/controlled_error_stepper.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/controlled_error_stepper.hpp 2011-03-10 11:51:05 EST (Thu, 10 Mar 2011)
@@ -379,6 +379,7 @@
typedef typename stepper_type::order_type order_type;
typedef AdjustSizePolicy adjust_size_policy;
typedef ErrorChecker error_checker_type;
+ typedef controlled_stepper_tag stepper_category;
controlled_error_stepper(
const stepper_type &stepper = stepper_type() ,
Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/integrate_functions.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/integrate_functions.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/integrate_functions.cpp 2011-03-10 11:51:05 EST (Thu, 10 Mar 2011)
@@ -92,10 +92,9 @@
using namespace std;
using namespace boost::numeric::odeint;
-
-using boost::lambda::_1;
using namespace boost::lambda;
+
struct tmp_func
{
template< class T1 , class T2 >
@@ -122,11 +121,13 @@
// integrate_n_steps( rosenbrock4_controller< rosenbrock4< double > >() , make_pair( lorenz() , lorenz_jacobi() ) , x2 , 0.0 , 1000 , 0.1 );
// integrate_adaptive( rosenbrock4_controller< rosenbrock4< double > >() , make_pair( lorenz() , lorenz_jacobi() ) , x2 , 0.0 , 10.0 , 0.1 );
- integrate( explicit_euler< state_type >() , lorenz() , x1 , 0.0 , 10.0 , 0.1 , tmp_func() );
-// integrate( explicit_euler< state_type >() , lorenz() , x1 , 0.0 , 10.0 , 0.1 , cout << _1 << "\n" );
+// integrate( explicit_euler< state_type >() , lorenz() , x1 , 0.0 , 10.0 , 0.01 , tmp_func() );
+// integrate( explicit_euler< state_type >() , lorenz() , x1 , 0.0 , 1.0 , 0.01 , cout << _1 << "\n" );
// integrate_n_steps( explicit_euler< state_type >() , lorenz() , x1 , 0.0 , 0.1 , 100 , cout << _1 << "\n" );
// integrate_adaptive( explicit_euler< state_type >() , lorenz() , x1 , 0.0 , 10.0 , 0.1 , cout << _1 << "\n" );
+ integrate( controlled_error_stepper< explicit_error_rk54_ck< state_type > >() , lorenz() , x1 , 0.0 , 10.0 , 0.01 , tmp_func() );
+
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk