Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r68527 - in sandbox/odeint/branches/karsten: . boost/numeric boost/numeric/odeint/stepper boost/numeric/odeint/stepper/base libs/numeric/odeint/doc libs/numeric/odeint/regression_test libs/numeric/odeint/test
From: karsten.ahnert_at_[hidden]
Date: 2011-01-28 07:09:01


Author: karsten
Date: 2011-01-28 07:08:52 EST (Fri, 28 Jan 2011)
New Revision: 68527
URL: http://svn.boost.org/trac/boost/changeset/68527

Log:
dense output for dopri5
Added:
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/dense_output_controlled_explicit_fsal.hpp (contents, props changed)
   sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/dense_output_controlled_explicit_fsal.cpp (contents, props changed)
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/prepare_stepper_testing.hpp (contents, props changed)
Removed:
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/dense_output_explicit_euler.hpp
   sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/dense_output_explicit_euler.cpp
Text files modified:
   sandbox/odeint/branches/karsten/TODO | 13 +++++---
   sandbox/odeint/branches/karsten/boost/numeric/odeint.hpp | 2
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp | 6 ++++
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/controlled_error_stepper.hpp | 55 ++++++++++++++++++++++++++++++---------
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/dense_output_explicit.hpp | 55 ++++++++++++++++++++++++++++++++--------
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_error_dopri5.hpp | 2
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_euler.hpp | 8 +++++
   sandbox/odeint/branches/karsten/libs/numeric/odeint/doc/concepts.qbk | 15 ++++++++++
   sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/Jamfile | 10 +++---
   sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/dense_output_explicit.cpp | 42 +++++++++++++++++++++++++++++
   sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/dense_output_stepper_evolution.cpp | 5 ++-
   11 files changed, 174 insertions(+), 39 deletions(-)

Modified: sandbox/odeint/branches/karsten/TODO
==============================================================================
--- sandbox/odeint/branches/karsten/TODO (original)
+++ sandbox/odeint/branches/karsten/TODO 2011-01-28 07:08:52 EST (Fri, 28 Jan 2011)
@@ -4,6 +4,7 @@
   OK * test fusion_algebra
   * test vector_space_algebra, maybe with some proto lib
   * test copying
+ * test, if copy construct of stepper_base is called when explicit_euler is used
   * test gsl
   * test explicit stepper with ranges
 OK * change standard_operations::rel_error in order to word with units and test it
@@ -21,20 +22,22 @@
   OK * move error_checker into controlled_stepper
   * rename controlled_stepper to a more specific name
 DIFICULT * change dense_output to units
- * roll out dense_output_explicit_euler::calc_state() to explicit_euler::dense_output()
+ OK * roll out dense_output_explicit_euler::calc_state() to explicit_euler::dense_output()
   * roll out dense_output_dopri5::calc_state() to explicit_error_dopri5::dense_output()
- * create dense_output_explicit
- * create dense_output_explicit_controlled
+ OK * create dense_output_explicit
   * create dense_output_explicit_controlled_fsal
- * maybe remove dense_output_explicit
 * split check_concepts into check_stepper_concept, check_error_stepper_concept, check_controlled_stepper_concept
-* split resizing and copy/destruct/construct in different files
+* file cleanup
+ * split resizing and copy/destruct/construct in different files
+ * subfolder algebra, operations, util
 OK * change resizing concept, in order to word within the implicit steppers
 OK * in all tests and regression test do not include odeint.hpp, only include the headers which are really needed
 OK * start new doc or cleanup the old project
 * check header guards
 * check copyright note
 * documente every file in the preamble
+* include adjust_size_by_policy in all steppers and call this routine inside do_step()
+* check once more, if all contructor, destructors and assign-operators are present
 
 * Integrate functions
 * skript for setting the include defines according to the position in file system an writing a general copyright comment at the beginning

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint.hpp 2011-01-28 07:08:52 EST (Fri, 28 Jan 2011)
@@ -25,7 +25,7 @@
 
 #include <boost/numeric/odeint/stepper/controlled_error_stepper.hpp>
 
-#include <boost/numeric/odeint/stepper/dense_output_explicit_euler.hpp>
+#include <boost/numeric/odeint/stepper/dense_output_explicit.hpp>
 #include <boost/numeric/odeint/stepper/dense_output_dopri5.hpp>
 
 /*

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp 2011-01-28 07:08:52 EST (Fri, 28 Jan 2011)
@@ -134,6 +134,12 @@
                 m_size_adjuster.adjust_size( x );
         }
 
+ template< class StateType >
+ void adjust_size_by_policy( const StateType &x )
+ {
+ m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() );
+ }
+
 
 protected:
 

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-01-28 07:08:52 EST (Fri, 28 Jan 2011)
@@ -15,7 +15,6 @@
 
 #include <cmath>
 
-#include <boost/noncopyable.hpp>
 #include <boost/ref.hpp>
 
 #include <boost/numeric/odeint/stepper/size_adjuster.hpp>
@@ -104,7 +103,7 @@
         class ErrorChecker ,
         class AdjustSizePolicy
>
-class controlled_error_stepper< ErrorStepper , ErrorChecker , AdjustSizePolicy , explicit_error_stepper_tag > : boost::noncopyable
+class controlled_error_stepper< ErrorStepper , ErrorChecker , AdjustSizePolicy , explicit_error_stepper_tag >
 {
         void initialize( void )
         {
@@ -310,8 +309,29 @@
     class ErrorChecker ,
         class AdjustSizePolicy
>
-class controlled_error_stepper< ErrorStepper , ErrorChecker , AdjustSizePolicy , explicit_error_stepper_fsal_tag > : boost::noncopyable
+class controlled_error_stepper< ErrorStepper , ErrorChecker , AdjustSizePolicy , explicit_error_stepper_fsal_tag >
 {
+ void initialize( void )
+ {
+ boost::numeric::odeint::construct( m_dxdt );
+ boost::numeric::odeint::construct( m_xerr );
+ boost::numeric::odeint::construct( m_xnew );
+ boost::numeric::odeint::construct( m_dxdtnew );
+ m_dxdt_size_adjuster.register_state( 0 , m_dxdt );
+ m_xerr_size_adjuster.register_state( 0 , m_xerr );
+ m_new_size_adjuster.register_state( 0 , m_xnew );
+ m_new_size_adjuster.register_state( 1 , m_dxdtnew );
+ }
+
+ void copy( controlled_error_stepper &stepper )
+ {
+ boost::numeric::odeint::copy( stepper.m_dxdt , m_dxdt );
+ boost::numeric::odeint::copy( stepper.m_xerr , m_xerr );
+ boost::numeric::odeint::copy( stepper.m_xnew , m_xnew );
+ boost::numeric::odeint::copy( stepper.m_dxdtnew , m_dxdtnew );
+ m_first_call = stepper.m_first_call;
+ }
+
 public:
 
     typedef ErrorStepper stepper_type;
@@ -324,7 +344,7 @@
     typedef ErrorChecker error_checker_type;
 
     controlled_error_stepper(
- stepper_type &stepper ,
+ const stepper_type &stepper = stepper_type() ,
             const error_checker_type &error_checker = error_checker_type()
             )
     : m_stepper( stepper ) , m_error_checker( error_checker ) ,
@@ -332,14 +352,17 @@
       m_dxdt() , m_xerr() , m_xnew() , m_dxdtnew() ,
       m_first_call( true )
     {
- boost::numeric::odeint::construct( m_dxdt );
- boost::numeric::odeint::construct( m_xerr );
- boost::numeric::odeint::construct( m_xnew );
- boost::numeric::odeint::construct( m_dxdtnew );
- m_dxdt_size_adjuster.register_state( 0 , m_dxdt );
- m_xerr_size_adjuster.register_state( 0 , m_xerr );
- m_new_size_adjuster.register_state( 0 , m_xnew );
- m_new_size_adjuster.register_state( 1 , m_dxdtnew );
+ initialize();
+ }
+
+ controlled_error_stepper( const controlled_error_stepper &stepper )
+ : m_stepper( stepper.m_stepper ) , m_error_checker( stepper.m_error_checker ) ,
+ m_dxdt_size_adjuster() , m_xerr_size_adjuster() , m_new_size_adjuster() ,
+ m_dxdt() , m_xerr() , m_xnew() , m_dxdtnew() ,
+ m_first_call( true )
+ {
+ initialize();
+ copy( stepper );
     }
 
     ~controlled_error_stepper( void )
@@ -350,6 +373,12 @@
         boost::numeric::odeint::destruct( m_dxdtnew );
     }
 
+ controlled_error_stepper& operator=( const controlled_error_stepper &stepper )
+ {
+ copy( stepper );
+ return *this;
+ }
+
 
 
 
@@ -465,7 +494,7 @@
 
 private:
 
- stepper_type &m_stepper;
+ stepper_type m_stepper;
     error_checker_type m_error_checker;
 
     size_adjuster< deriv_type , 1 > m_dxdt_size_adjuster;

Added: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/dense_output_controlled_explicit_fsal.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/dense_output_controlled_explicit_fsal.hpp 2011-01-28 07:08:52 EST (Fri, 28 Jan 2011)
@@ -0,0 +1,228 @@
+/*
+ * dense_output_controlled_explicit_fsal.hpp
+ *
+ * Created on: Jan 28, 2011
+ * Author: karsten
+ */
+
+#ifndef BOOST_NUMERIC_ODEINT_STEPPER_DENSE_OUTPUT_CONTROLLED_EXPLICIT_FSAL_HPP_
+#define BOOST_NUMERIC_ODEINT_STEPPER_DENSE_OUTPUT_CONTROLLED_EXPLICIT_FSAL_HPP_
+
+#include <utility>
+#include <stdexcept>
+
+#include <boost/numeric/odeint/stepper/size_adjuster.hpp>
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+
+template
+<
+ class ControlledStepper
+>
+class dense_output_controlled_explicit_fsal
+{
+private:
+
+ void initialize_variables( void )
+ {
+ boost::numeric::odeint::construct( m_x1 );
+ boost::numeric::odeint::construct( m_x2 );
+ boost::numeric::odeint::construct( m_dxdt1 );
+ boost::numeric::odeint::construct( m_dxdt2 );
+ m_state_adjuster.register_state( 0 , m_x1 );
+ m_state_adjuster.register_state( 1 , m_x2 );
+ m_deriv_adjuster.register_state( 0 , m_x1 );
+ m_deriv_adjuster.register_state( 1 , m_x2 );
+ }
+
+ void copy_variables( const dense_output_controlled_explicit_fsal &dense_output )
+ {
+ m_stepper = dense_output.m_stepper;
+ boost::numeric::odeint::copy( dense_output.m_x1 , m_x1 );
+ boost::numeric::odeint::copy( dense_output.m_x2 , m_x2 );
+ boost::numeric::odeint::copy( dense_output.m_dxdt1 , m_dxdt1 );
+ boost::numeric::odeint::copy( dense_output.m_dxdt2 , m_dxdt2 );
+ if( dense_output.m_current_state == (&dense_output.m_x1 ) )
+ {
+ m_current_state = &m_x1;
+ m_old_state = &m_x2;
+ }
+ else
+ {
+ m_current_state = &m_x2;
+ m_old_state = &m_x1;
+ }
+ if( dense_output.m_current_deriv == ( &dense_output.m_dxdt1 ) )
+ {
+ m_current_deriv = &m_dxdt1;
+ m_old_deriv = &m_dxdt2;
+ }
+ else
+ {
+ m_current_deriv = &m_dxdt2;
+ m_old_deriv = &m_dxdt1;
+ }
+ m_t = dense_output.m_t;
+ m_t_old = dense_output.m_t_old;
+ m_dt = dense_output.m_dt;
+ m_is_deriv_initialized = dense_output.m_is_deriv_initialized;
+ }
+
+public:
+
+ /*
+ * We do not need all typedefs.
+ */
+ typedef ControlledStepper controlled_stepper_type;
+
+ typedef typename controlled_stepper_type::stepper_type stepper_type;
+ typedef typename stepper_type::state_type state_type;
+ typedef typename stepper_type::value_type value_type;
+ typedef typename stepper_type::deriv_type deriv_type;
+ typedef typename stepper_type::time_type time_type;
+ typedef typename stepper_type::algebra_type algebra_type;
+ typedef typename stepper_type::operations_type operations_type;
+ typedef typename stepper_type::adjust_size_policy adjust_size_policy;
+
+
+ dense_output_controlled_explicit_fsal( const controlled_stepper_type &stepper = controlled_stepper_type() )
+ : m_stepper( stepper ) ,
+ m_state_adjuster() , m_deriv_adjuster() ,
+ m_x1() , m_x2() , m_current_state( &m_x1 ) , m_old_state( &m_x2 ) ,
+ m_dxdt1() , m_dxdt2() , m_current_deriv( &m_dxdt1 ) , m_old_deriv( &m_dxdt2 ) ,
+ m_t( 0.0 ) , m_t_old( 0.0 ) , m_dt( 1.0 ) , m_is_deriv_initialized( false )
+ {
+ initialize_variables();
+ }
+
+ dense_output_controlled_explicit_fsal( const dense_output_controlled_explicit_fsal &dense_output )
+ : m_stepper( dense_output.m_stepper ) ,
+ m_state_adjuster() , m_deriv_adjuster() ,
+ m_x1() , m_x2() , m_current_state( &m_x1 ) , m_old_state( &m_x2 ) ,
+ m_dxdt1() , m_dxdt2() , m_current_deriv( &m_dxdt1 ) , m_old_deriv( &m_dxdt2 ) ,
+ m_t( 0.0 ) , m_t_old( 0.0 ) , m_dt( 1.0 ) , m_is_deriv_initialized( false )
+ {
+ initialize_variables();
+ copy_variables( dense_output );
+ }
+
+ ~dense_output_controlled_explicit_fsal( void )
+ {
+ boost::numeric::odeint::destruct( m_x1 );
+ boost::numeric::odeint::destruct( m_x2 );
+ boost::numeric::odeint::destruct( m_dxdt1 );
+ boost::numeric::odeint::destruct( m_dxdt2 );
+ }
+
+ dense_output_controlled_explicit_fsal& operator=( const dense_output_controlled_explicit_fsal &dense_output )
+ {
+ copy_variables( dense_output );
+ return *this;
+ }
+
+ template< class StateType >
+ void initialize( const StateType &x0 , const time_type &t0 , const time_type &dt0 )
+ {
+ adjust_size_by_policy( x0 );
+ boost::numeric::odeint::copy( x0 , *m_current_state );
+ m_t = t0;
+ m_dt = dt0;
+ m_is_deriv_initialized = false;
+ }
+
+ template< class System >
+ std::pair< time_type , time_type > do_step( System system )
+ {
+ const size_t max_count = 1000;
+
+ if( !m_is_deriv_initialized )
+ {
+ typename boost::unwrap_reference< System >::type &sys = system;
+ sys( *m_current_state , *m_current_deriv , m_t );
+ m_is_deriv_initialized = true;
+ }
+
+ controlled_step_result res = step_size_decreased;
+ m_t_old = m_t;
+ size_t count = 0;
+ do
+ {
+ res = m_stepper.try_step( system , *m_current_state , *m_current_deriv , m_t , *m_old_state , *m_old_deriv , m_dt );
+ if( count++ == max_count )
+ throw std::overflow_error( "dense_output_dopri5 : too much iterations!");
+ }
+ while( res == step_size_decreased );
+ std::swap( m_current_state , m_old_state );
+ std::swap( m_current_deriv , m_old_deriv );
+ return std::make_pair( m_t_old , m_t );
+ }
+
+ template< class StateOut >
+ void calc_state( const time_type &t , StateOut &x )
+ {
+// m_stepper.calc_state( x , t , *m_old_state , m_t_old );
+ }
+
+ template< class StateType >
+ void adjust_size( const StateType &x )
+ {
+ m_state_adjuster.adjust_size( x );
+ m_deriv_adjuster.adjust_size( x );
+ m_stepper.adjust_size( x );
+ }
+
+ template< class StateType >
+ void adjust_size_by_policy( const StateType &x )
+ {
+ m_state_adjuster.adjust_size_by_policy( x , adjust_size_policy() );
+ m_deriv_adjuster.adjust_size_by_policy( x , adjust_size_policy() );
+ // ToDo : implement this in all stepper
+// m_stepper.adjust_size_by_policy( x );
+ }
+
+
+ const state_type& current_state( void ) const
+ {
+ return *m_current_state;
+ }
+
+ const time_type& current_time( void ) const
+ {
+ return m_t;
+ }
+
+ const time_type& previous_state( void ) const
+ {
+ return *m_old_state;
+ }
+
+ const time_type& previous_time( void ) const
+ {
+ return m_t_old;
+ }
+
+
+private:
+
+ controlled_stepper_type m_stepper;
+ size_adjuster< state_type , 2 > m_state_adjuster;
+ size_adjuster< deriv_type , 2 > m_deriv_adjuster;
+ state_type m_x1 , m_x2;
+ state_type *m_current_state , *m_old_state;
+ deriv_type m_dxdt1 , m_dxdt2;
+ state_type *m_current_deriv , *m_old_deriv;
+ time_type m_t , m_t_old , m_dt;
+ bool m_is_deriv_initialized;
+
+};
+
+} // namespace odeint
+} // namespace numeric
+} // namespace boost
+
+
+
+#endif /* BOOST_NUMERIC_ODEINT_STEPPER_DENSE_OUTPUT_CONTROLLED_EXPLICIT_FSAL_HPP_ */

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/dense_output_explicit.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/dense_output_explicit.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/dense_output_explicit.hpp 2011-01-28 07:08:52 EST (Fri, 28 Jan 2011)
@@ -11,6 +11,7 @@
 #include <utility>
 
 #include <boost/numeric/odeint/stepper/size_adjuster.hpp>
+#include <boost/numeric/odeint/algebra/default_resize.hpp>
 
 namespace boost {
 namespace numeric {
@@ -35,13 +36,28 @@
 
         void copy_variables( const dense_output_explicit &dense_output )
         {
- /* ToDo : implement */
+ m_stepper = dense_output.m_stepper;
+ boost::numeric::odeint::copy( dense_output.m_x1 , m_x1 );
+ boost::numeric::odeint::copy( dense_output.m_x2 , m_x2 );
+ if( dense_output.m_current_state == (&dense_output.m_x1 ) )
+ {
+ m_current_state = &m_x1;
+ m_old_state = &m_x2;
+ }
+ else
+ {
+ m_current_state = &m_x2;
+ m_old_state = &m_x1;
+ }
+ m_t = dense_output.m_t;
+ m_t_old = dense_output.m_t_old;
+ m_dt = dense_output.m_dt;
         }
 
 public:
 
         /*
- * ToDo : check which types we really need
+ * We do not need all typedefs.
          */
         typedef Stepper stepper_type;
         typedef typename stepper_type::state_type state_type;
@@ -52,8 +68,7 @@
         typedef typename stepper_type::operations_type operations_type;
         typedef typename stepper_type::adjust_size_policy adjust_size_policy;
 
-
- dense_output_explicit( const stepper_type &stepper )
+ dense_output_explicit( const stepper_type &stepper = stepper_type() )
         : m_stepper( stepper ) , m_size_adjuster() ,
           m_x1() , m_x2() , m_current_state( &m_x1 ) , m_old_state( &m_x2 ) ,
           m_t( 0.0 ) , m_t_old( 0.0 ) , m_dt( 1.0 )
@@ -61,7 +76,16 @@
                 initialize_variables();
         }
 
- dense_output_explicit( const dense_output_explicit &dense_ouput )
+ ~dense_output_explicit( void )
+ {
+ boost::numeric::odeint::destruct( m_x1 );
+ boost::numeric::odeint::destruct( m_x2 );
+ }
+
+ dense_output_explicit( const dense_output_explicit &dense_output )
+ : m_stepper( dense_output.m_stepper ) , m_size_adjuster() ,
+ m_x1() , m_x2() , m_current_state( &m_x1 ) , m_old_state( &m_x2 ) ,
+ m_t( 0.0 ) , m_t_old( 0.0 ) , m_dt( 1.0 )
         {
                 initialize_variables();
                 copy_variables( dense_output );
@@ -73,8 +97,10 @@
                 return *this;
         }
 
- void initialize( const state_type &x0 , const time_type t0 , const time_type dt0 )
+ template< class StateType >
+ void initialize( const StateType &x0 , const time_type &t0 , const time_type &dt0 )
         {
+ adjust_size_by_policy( x0 );
                 boost::numeric::odeint::copy( x0 , *m_current_state );
                 m_t = t0;
                 m_dt = dt0;
@@ -90,19 +116,26 @@
                 return std::make_pair( m_t_old , m_dt );
         }
 
- void calc_state( time_type t , state_type &x )
+ template< class StateOut >
+ void calc_state( const time_type &t , StateOut &x )
         {
- m_stepper.calc_state( x , *m_old_state , t , m_t_old );
-// time_type delta = t - m_t_old;
-// typename algebra_type::for_each3()( x , *m_old_state , m_euler.m_dxdt , typename operations_type::template scale_sum2< time_type , time_type >( 1.0 , delta ) );
+ m_stepper.calc_state( x , t , *m_old_state , m_t_old );
         }
 
- void adjust_size( const state_type &x )
+ template< class StateType >
+ void adjust_size( const StateType &x )
         {
                 m_size_adjuster.adjust_size( x );
                 m_stepper.adjust_size( x );
         }
 
+ template< class StateType >
+ void adjust_size_by_policy( const StateType &x )
+ {
+ m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() );
+ m_stepper.adjust_size_by_policy( x );
+ }
+
 
         const state_type& current_state( void ) const
         {

Deleted: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/dense_output_explicit_euler.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/dense_output_explicit_euler.hpp 2011-01-28 07:08:52 EST (Fri, 28 Jan 2011)
+++ (empty file)
@@ -1,117 +0,0 @@
-/*
- boost header: numeric/odeint/dense_output_explicit_euler.hpp
-
- Copyright 2009 Karsten Ahnert
- Copyright 2009 Mario Mulansky
-
- Distributed under the Boost Software License, Version 1.0.
- (See accompanying file LICENSE_1_0.txt or
- copy at http://www.boost.org/LICENSE_1_0.txt)
-*/
-
-#ifndef BOOST_NUMERIC_ODEINT_DENSE_OUTPUT_EXPLICIT_EULER_HPP_INCLUDED
-#define BOOST_NUMERIC_ODEINT_DENSE_OUTPUT_EXPLICIT_EULER_HPP_INCLUDED
-
-#include <utility>
-
-#include <boost/numeric/odeint/stepper/explicit_euler.hpp>
-
-namespace boost {
-namespace numeric {
-namespace odeint {
-
-template<
- class State ,
- class Value = double ,
- class Deriv = State ,
- class Time = Value ,
- class Algebra = range_algebra ,
- class Operations = default_operations ,
- class AdjustSizePolicy = adjust_size_initially_tag
- >
-class dense_output_explicit_euler
-{
-public:
-
- typedef State state_type;
- typedef Value value_type;
- typedef Deriv deriv_type;
- typedef Time time_type;
- typedef Algebra algebra_type;
- typedef Operations operations_type;
- typedef AdjustSizePolicy adjust_size_policy;
- typedef explicit_euler< state_type , value_type , deriv_type , time_type , algebra_type , operations_type , adjust_size_policy > stepper_type;
-
- dense_output_explicit_euler( void )
- : m_euler() , m_size_adjuster() ,
- m_x1() , m_x2() , m_current_state( &m_x1 ) , m_old_state( &m_x2 ) ,
- m_t( 0.0 ) , m_t_old( 0.0 ) , m_dt( 1.0 )
- {
- boost::numeric::odeint::construct( m_x1 );
- boost::numeric::odeint::construct( m_x2 );
- m_size_adjuster.register_state( 0 , m_x1 );
- m_size_adjuster.register_state( 1 , m_x2 );
- }
-
- ~dense_output_explicit_euler( void )
- {
- boost::numeric::odeint::destruct( m_x1 );
- boost::numeric::odeint::destruct( m_x2 );
- }
-
-
-
-
- void initialize( const state_type &x0 , const time_type t0 , const time_type dt0 )
- {
- boost::numeric::odeint::copy( x0 , *m_current_state );
- m_t = t0;
- m_dt = dt0;
- }
-
-
-
- template< class System >
- std::pair< time_type , time_type > do_step( System system )
- {
- m_euler.do_step( system , *m_current_state , m_t , *m_old_state , m_dt );
- m_t_old = m_t;
- m_t += m_dt;
- std::swap( m_current_state , m_old_state );
- return std::make_pair( m_t_old , m_dt );
- }
-
- void calc_state( time_type t , state_type &x )
- {
- time_type delta = t - m_t_old;
- typename algebra_type::for_each3()( x , *m_old_state , m_euler.m_dxdt , typename operations_type::template scale_sum2< time_type , time_type >( 1.0 , delta ) );
- }
-
- void adjust_size( const state_type &x )
- {
- m_size_adjuster.adjust_size( x );
- m_euler.adjust_size( x );
- }
-
-
- const state_type& current_state( void ) const { return *m_current_state; }
- const time_type& current_time( void ) const { return m_t; }
- const time_type& previous_state( void ) const { return *m_old_state; }
- const time_type& previous_time( void ) const { return m_t_old; }
-
-private:
-
- stepper_type m_euler;
- size_adjuster< state_type , 2 > m_size_adjuster;
- state_type m_x1 , m_x2;
- state_type *m_current_state , *m_old_state;
- time_type m_t , m_t_old , m_dt;
-};
-
-
-} // namespace odeint
-} // namespace numeric
-} // namespace boost
-
-
-#endif //BOOST_NUMERIC_ODEINT_DENSE_OUTPUT_EXPLICIT_EULER_HPP_INCLUDED

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_error_dopri5.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_error_dopri5.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_error_dopri5.hpp 2011-01-28 07:08:52 EST (Fri, 28 Jan 2011)
@@ -60,7 +60,7 @@
                 m_deriv_adjuster.register_state( 4 , m_k6 );
         }
 
- void copy( explicit_error_dopri5 &d )
+ void copy( const explicit_error_dopri5 &d )
         {
                 boost::numeric::odeint::copy( d.m_x_tmp , m_x_tmp );
                 boost::numeric::odeint::copy( d.m_k2 , m_k2 );

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_euler.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_euler.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_euler.hpp 2011-01-28 07:08:52 EST (Fri, 28 Jan 2011)
@@ -52,6 +52,14 @@
                 typename algebra_type::for_each3()( out , in , dxdt , typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , dt ) );
 
         }
+
+ template< class StateOut , class StateIn >
+ void calc_state( StateOut &x , const time_type &t , const StateIn &old_state , const time_type &t_old )
+ {
+ time_type delta = t - t_old;
+ typename algebra_type::for_each3()( x , old_state , stepper_base_type::m_dxdt , typename operations_type::template scale_sum2< time_type , time_type >( 1.0 , delta ) );
+ }
+
 };
 
 

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/doc/concepts.qbk
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/doc/concepts.qbk (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/doc/concepts.qbk 2011-01-28 07:08:52 EST (Fri, 28 Jan 2011)
@@ -252,4 +252,19 @@
 
 [endsect]
 
+
+[section Dense ouput stepper]
+
+[endsect]
+
+[section Size adjusting stepper]
+
+[endsect]
+
+[section CompositeStepper]
+
+[endsect]
+
+see the wiki
+
 [endsect]

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/Jamfile
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/Jamfile (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/Jamfile 2011-01-28 07:08:52 EST (Fri, 28 Jan 2011)
@@ -17,14 +17,14 @@
         : dense_output_dopri5.cpp
         ;
 
-exe dense_output_explicit_euler
- : dense_output_explicit_euler.cpp
- ;
-
 exe dense_output_stepper_evolution
         : dense_output_stepper_evolution.cpp
         ;
         
-exe dense_output_explict
+exe dense_output_explicit
         : dense_output_explicit.cpp
+ ;
+
+exe dense_output_controlled_explicit_fsal
+ : dense_output_controlled_explicit_fsal.cpp
         ;
\ No newline at end of file

Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/dense_output_controlled_explicit_fsal.cpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/dense_output_controlled_explicit_fsal.cpp 2011-01-28 07:08:52 EST (Fri, 28 Jan 2011)
@@ -0,0 +1,44 @@
+/*
+ * dense_output_explicit_controlled_fsal.cpp
+ *
+ * Created on: Jan 28, 2011
+ * Author: karsten
+ */
+
+#include <iostream>
+
+#include <boost/numeric/odeint/stepper/explicit_error_dopri5.hpp>
+#include <boost/numeric/odeint/stepper/controlled_error_stepper.hpp>
+#include <boost/numeric/odeint/stepper/dense_output_controlled_explicit_fsal.hpp>
+
+using namespace std;
+using namespace boost::numeric::odeint;
+
+typedef vector< double > state_type;
+typedef explicit_error_dopri5< state_type > dopri5_type;
+typedef controlled_error_stepper< dopri5_type > controlled_error_stepper_type;
+typedef dense_output_controlled_explicit_fsal< controlled_error_stepper_type > stepper_type;
+
+
+struct lorenz
+{
+ template< class State , class Deriv >
+ void operator()( const State &x , Deriv &dxdt , double t )
+ {
+ const double sigma = 10.0;
+ const double R = 28.0;
+ const double b = 8.0 / 3.0;
+
+ dxdt[0] = sigma * ( x[1] - x[0] );
+ dxdt[1] = R * x[0] - x[1] - x[0] * x[2];
+ dxdt[2] = x[0]*x[1] - b * x[2];
+ }
+};
+
+
+
+int main( int argc , char **argv )
+{
+ stepper_type stepper;
+ return 0;
+}

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/dense_output_explicit.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/dense_output_explicit.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/dense_output_explicit.cpp 2011-01-28 07:08:52 EST (Fri, 28 Jan 2011)
@@ -6,6 +6,7 @@
  */
 
 #include <iostream>
+#include <fstream>
 #include <vector>
 
 #include <boost/numeric/odeint/stepper/explicit_euler.hpp>
@@ -16,11 +17,50 @@
 
 typedef std::vector< double > state_type;
 typedef explicit_euler< state_type > explicit_stepper_type;
-typedef dense_output_explicit< stepper_type > stepper_type;
+typedef dense_output_explicit< explicit_stepper_type > stepper_type;
+
+struct lorenz
+{
+ template< class State , class Deriv >
+ void operator()( const State &x , Deriv &dxdt , double t )
+ {
+ const double sigma = 10.0;
+ const double R = 28.0;
+ const double b = 8.0 / 3.0;
+
+ dxdt[0] = sigma * ( x[1] - x[0] );
+ dxdt[1] = R * x[0] - x[1] - x[0] * x[2];
+ dxdt[2] = x[0]*x[1] - b * x[2];
+ }
+};
 
 int main( int argc , char **argv )
 {
         stepper_type stepper;
 
+ state_type x_start( 3 );
+ x_start[0] = 10.0 , x_start[1] = 10.0 ; x_start[2] = 20.0;
+
+ const double dt1 = 0.025 , dt2 = 0.01;
+ stepper.initialize( x_start , 0.0 , dt1 );
+
+ ofstream fout( "test.dat" );
+ ofstream fout2( "test2.dat" );
+ state_type x( 3 );
+ double t = 0.0;
+ while( stepper.current_time() < 10.0 )
+ {
+ while( t < stepper.current_time() )
+ {
+ stepper.calc_state( t , x );
+ fout << t << " " << x[0] << " " << x[1] << " " << x[2] << endl;
+ t += dt2;
+ }
+ stepper.do_step( lorenz() );
+ const state_type &current = stepper.current_state();
+ fout2 << stepper.current_time() << " " << current[0] << " " << current[1] << " " << current[2] << " " << endl;
+ }
+
+
         return 0;
 }

Deleted: sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/dense_output_explicit_euler.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/dense_output_explicit_euler.cpp 2011-01-28 07:08:52 EST (Fri, 28 Jan 2011)
+++ (empty file)
@@ -1,77 +0,0 @@
-/* Boost check_implicit_euler.cpp test file
-
- Copyright 2009 Karsten Ahnert
- Copyright 2009 Mario Mulansky
-
- This file tests the use of the euler stepper
-
- Distributed under the Boost Software License, Version 1.0.
- (See accompanying file LICENSE_1_0.txt or
- copy at http://www.boost.org/LICENSE_1_0.txt)
-*/
-
-
-#include <tr1/array>
-#include <fstream>
-#include <iostream>
-
-#include <boost/numeric/odeint/stepper/explicit_euler.hpp>
-#include <boost/numeric/odeint/stepper/dense_output_explicit_euler.hpp>
-
-
-using namespace boost::numeric::odeint;
-
-typedef double value_type;
-typedef std::tr1::array< double , 2 > state_type;
-
-inline std::ostream& operator<<( std::ostream &out , const state_type &x )
-{
- out << x[0] << "\t" << x[1];
- return out;
-}
-
-inline void sys( const state_type &x , state_type &dxdt , const value_type t )
-{
- dxdt[0] = x[1];
- dxdt[1] = -x[0];
-}
-
-
-int main( int argc , char **argv )
-{
- using std::abs;
-
- dense_output_explicit_euler< state_type > stepper;
- state_type x0;
- x0[0] = 0.0;
- x0[1] = 1.0;
-
- stepper.initialize( x0 , 0.0 , 0.1 );
-// stepper.do_step( sys );
-
- std::ofstream stepper_out( "stepper_states.dat" );
- std::ofstream states_out( "states.dat" );
-
-
- double t = stepper.current_time();
- double t_end = 10.0;
- double dt = 0.02;
- state_type x;
- while( t < t_end )
- {
- if( t < stepper.current_time() )
- {
- stepper.calc_state( t , x );
- states_out << t << "\t" << x << std::endl;
- }
- else
- {
- stepper.do_step( sys );
- stepper_out << stepper.current_time() << "\t" << stepper.current_state() << std::endl;
- continue;
- }
- t += dt;
- }
-
-}
-

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/dense_output_stepper_evolution.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/dense_output_stepper_evolution.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/dense_output_stepper_evolution.cpp 2011-01-28 07:08:52 EST (Fri, 28 Jan 2011)
@@ -10,8 +10,9 @@
 #include <iostream>
 #include <tr1/array>
 
+#include <boost/numeric/odeint/stepper/explicit_euler.hpp>
 #include <boost/numeric/odeint/stepper/dense_output_dopri5.hpp>
-#include <boost/numeric/odeint/stepper/dense_output_explicit_euler.hpp>
+#include <boost/numeric/odeint/stepper/dense_output_explicit.hpp>
 #include <boost/numeric/odeint/stepper/controlled_error_stepper.hpp>
 
 #define tab "\t"
@@ -88,7 +89,7 @@
         dopri5_type dopri5;
         controlled_dopri5_type controlled_dopri5( dopri5 );
 
- dense_output_explicit_euler< state_type > dense_euler;
+ dense_output_explicit< explicit_euler< state_type > > dense_euler;
         dense_output_dopri5< controlled_dopri5_type > dense_dopri5( controlled_dopri5 );
 
         state_type x0 = {{ 1.25 , 0.43 }};

Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/test/prepare_stepper_testing.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/prepare_stepper_testing.hpp 2011-01-28 07:08:52 EST (Fri, 28 Jan 2011)
@@ -0,0 +1,68 @@
+/*
+ * prepare_stepper_testing.hpp
+ *
+ * Created on: Jan 19, 2011
+ * Author: karsten
+ */
+
+#ifndef PREPARE_STEPPER_TESTING_HPP_
+#define PREPARE_STEPPER_TESTING_HPP_
+
+#include <tr1/array>
+#include <vector>
+
+#include <boost/mpl/vector.hpp>
+
+namespace mpl = boost::mpl;
+
+
+struct constant_system_standard
+{
+ template< class State , class Deriv , class Time >
+ void operator()( const State &x , Deriv &dxdt , const Time &t ) const
+ {
+ dxdt[0] = 1.0;
+ }
+};
+
+struct constant_system_vector_space
+{
+ template< class State , class Deriv , class Time >
+ void operator()( const State &x , class Deriv &dxdt , const Time &t ) const
+ {
+ dxdt.m_x = 1.0;
+ }
+};
+
+struct constant_system_fusion
+{
+ template< class State , class Deriv , class Time >
+ void operator()( const State &x , class Deriv &dxdt , const Time &t ) const
+ {
+ fusion::at_c< 0 >( dxdt ) = fusion::at_c< 0 >( x ) / Time( 1.0 );
+ }
+};
+
+
+
+typedef mpl::vector
+<
+ mpl::vector< float , std::tr1::array< float , 1 > , std::tr1::array< float , 1 > , constant_system_standard , stepper_type > ,
+ mpl::vector< float , std::tr1::array< float , 1 > , std::vector< float > , constant_system_standard , stepper_type >
+> types_and_systems_matrix;
+
+
+struct check_stepper
+{
+ template< class Vector >
+ void operator()( Vector )
+ {
+ typedef typename mpl::at_c< Vector , 0 >::type value_type;
+ typedef typename mpl::at_c< Vector , 1 >::type deriv_type;
+ typedef typename mpl::at_c< Vector , 2 >::type state_type;
+ typedef typename mpl::at_c< Vector , 3 >::type system_type;
+ }
+};
+
+
+#endif /* PREPARE_STEPPER_TESTING_HPP_ */


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