void do_step_impl( System system , const StateIn &in , const time_type &t , StateOut &out , const time_type &dt , boost::mpl::true_ ) { typedef typename detail::unwrap_reference< System >::type system_type; typedef typename detail::unwrap_reference< typename system_type::first_type >::type coor_deriv_func_type; typedef typename detail::unwrap_reference< typename system_type::second_type >::type momentum_deriv_func_type; system_type &sys = system; coor_deriv_func_type &coor_func = sys.first; momentum_deriv_func_type &momentum_func = sys.second; typedef typename detail::unwrap_reference< StateIn >::type state_in_type; typedef typename detail::unwrap_reference< typename state_in_type::first_type >::type coor_in_type; typedef typename detail::unwrap_reference< typename state_in_type::second_type >::type momentum_in_type; const state_in_type &state_in = in; const coor_in_type &coor_in = state_in.first; const momentum_in_type &momentum_in = state_in.second; typedef typename detail::unwrap_reference< StateOut >::type state_out_type; typedef typename detail::unwrap_reference< typename state_out_type::first_type >::type coor_out_type; typedef typename detail::unwrap_reference< typename state_out_type::second_type >::type momentum_out_type; state_out_type &state_out = out; coor_out_type &coor_out = state_out.first; momentum_out_type &momentum_out = state_out.second; m_dqdt_resizer.adjust_size( coor_in , detail::bind( &internal_stepper_base_type::template resize_dqdt< coor_in_type > , detail::ref( *this ) , detail::_1 ) ); m_dpdt_resizer.adjust_size( momentum_in , detail::bind( &internal_stepper_base_type::template resize_dpdt< momentum_in_type > , detail::ref( *this ) , detail::_1 ) ); // ToDo: check sizes? for( size_t l=0 ; l<num_of_stages ; ++l ) { if( l == 0 ) { coor_func( momentum_in , m_dqdt.m_v ); this->m_algebra.for_each3( coor_out , coor_in , m_dqdt.m_v , typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , m_coef_a[l] * dt ) ); momentum_func( coor_out , m_dpdt.m_v ); this->m_algebra.for_each3( momentum_out , momentum_in , m_dpdt.m_v , typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , m_coef_b[l] * dt ) ); } else { coor_func( momentum_out , m_dqdt.m_v ); this->m_algebra.for_each3( coor_out , coor_out , m_dqdt.m_v , typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , m_coef_a[l] * dt ) ); momentum_func( coor_out , m_dpdt.m_v ); this->m_algebra.for_each3( momentum_out , momentum_out , m_dpdt.m_v , typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , m_coef_b[l] * dt ) ); } } }
void do_step_impl( System system , const StateIn &in , time_type /* t */ , StateOut &out , time_type dt , boost::mpl::false_ ) { typedef typename odeint::unwrap_reference< System >::type momentum_deriv_func_type; momentum_deriv_func_type &momentum_func = system; typedef typename odeint::unwrap_reference< StateIn >::type state_in_type; typedef typename odeint::unwrap_reference< typename state_in_type::first_type >::type coor_in_type; typedef typename odeint::unwrap_reference< typename state_in_type::second_type >::type momentum_in_type; const state_in_type &state_in = in; const coor_in_type &coor_in = state_in.first; const momentum_in_type &momentum_in = state_in.second; typedef typename odeint::unwrap_reference< StateOut >::type state_out_type; typedef typename odeint::unwrap_reference< typename state_out_type::first_type >::type coor_out_type; typedef typename odeint::unwrap_reference< typename state_out_type::second_type >::type momentum_out_type; state_out_type &state_out = out; coor_out_type &coor_out = state_out.first; momentum_out_type &momentum_out = state_out.second; // m_dqdt not required when called with momentum_func only - don't resize // m_dqdt_resizer.adjust_size( coor_in , detail::bind( &internal_stepper_base_type::template resize_dqdt< coor_in_type > , detail::ref( *this ) , detail::_1 ) ); m_dpdt_resizer.adjust_size( momentum_in , detail::bind( &internal_stepper_base_type::template resize_dpdt< momentum_in_type > , detail::ref( *this ) , detail::_1 ) ); // ToDo: check sizes? // step 0 this->m_algebra.for_each3( coor_out , coor_in , momentum_in , typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , m_coef_a[0] * dt ) ); momentum_func( coor_out , m_dpdt.m_v ); this->m_algebra.for_each3( momentum_out , momentum_in , m_dpdt.m_v , typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , m_coef_b[0] * dt ) ); for( size_t l=1 ; l<num_of_stages ; ++l ) { this->m_algebra.for_each3( coor_out , coor_out , momentum_out , typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , m_coef_a[l] * dt ) ); momentum_func( coor_out , m_dpdt.m_v ); this->m_algebra.for_each3( momentum_out , momentum_out , m_dpdt.m_v , typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , m_coef_b[l] * dt ) ); } }