Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:42:55

0001 /*
0002  [auto_generated]
0003  boost/numeric/odeint/stepper/adams_moulton.hpp
0004 
0005  [begin_description]
0006  Implementation of the Adams-Moulton method. This is method is not a real stepper, it is more a helper class
0007  which computes the corrector step in the Adams-Bashforth-Moulton method.
0008  [end_description]
0009 
0010  Copyright 2011-2012 Karsten Ahnert
0011  Copyright 2011-2013 Mario Mulansky
0012  Copyright 2012 Christoph Koke
0013 
0014  Distributed under the Boost Software License, Version 1.0.
0015  (See accompanying file LICENSE_1_0.txt or
0016  copy at http://www.boost.org/LICENSE_1_0.txt)
0017  */
0018 
0019 
0020 #ifndef BOOST_NUMERIC_ODEINT_STEPPER_ADAMS_MOULTON_HPP_INCLUDED
0021 #define BOOST_NUMERIC_ODEINT_STEPPER_ADAMS_MOULTON_HPP_INCLUDED
0022 
0023 
0024 #include <boost/numeric/odeint/util/bind.hpp>
0025 
0026 #include <boost/numeric/odeint/algebra/range_algebra.hpp>
0027 #include <boost/numeric/odeint/algebra/default_operations.hpp>
0028 #include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
0029 #include <boost/numeric/odeint/algebra/operations_dispatcher.hpp>
0030 
0031 #include <boost/numeric/odeint/util/state_wrapper.hpp>
0032 #include <boost/numeric/odeint/util/is_resizeable.hpp>
0033 #include <boost/numeric/odeint/util/resizer.hpp>
0034 
0035 #include <boost/numeric/odeint/stepper/stepper_categories.hpp>
0036 #include <boost/numeric/odeint/stepper/runge_kutta4_classic.hpp>
0037 
0038 #include <boost/numeric/odeint/stepper/detail/adams_moulton_call_algebra.hpp>
0039 #include <boost/numeric/odeint/stepper/detail/adams_moulton_coefficients.hpp>
0040 #include <boost/numeric/odeint/stepper/detail/rotating_buffer.hpp>
0041 
0042 
0043 
0044 
0045 namespace boost {
0046 namespace numeric {
0047 namespace odeint {
0048 
0049 
0050 /*
0051  * Static implicit Adams-Moulton multistep-solver without step size control and without dense output.
0052  */
0053 template<
0054 size_t Steps ,
0055 class State ,
0056 class Value = double ,
0057 class Deriv = State ,
0058 class Time = Value ,
0059 class Algebra = typename algebra_dispatcher< State >::algebra_type ,
0060 class Operations = typename operations_dispatcher< State >::operations_type ,
0061 class Resizer = initially_resizer
0062 >
0063 class adams_moulton
0064 {
0065 private:
0066 
0067 
0068 public :
0069 
0070     typedef State state_type;
0071     typedef state_wrapper< state_type > wrapped_state_type;
0072     typedef Value value_type;
0073     typedef Deriv deriv_type;
0074     typedef state_wrapper< deriv_type > wrapped_deriv_type;
0075     typedef Time time_type;
0076     typedef Algebra algebra_type;
0077     typedef Operations operations_type;
0078     typedef Resizer resizer_type;
0079     typedef stepper_tag stepper_category;
0080 
0081     typedef adams_moulton< Steps , State , Value , Deriv , Time , Algebra , Operations , Resizer > stepper_type;
0082 
0083     static const size_t steps = Steps;
0084 
0085     typedef unsigned short order_type;
0086     static const order_type order_value = steps + 1;
0087 
0088     typedef detail::rotating_buffer< wrapped_deriv_type , steps > step_storage_type;
0089 
0090     adams_moulton( )
0091     : m_coefficients() , m_dxdt() , m_resizer() ,
0092       m_algebra_instance() , m_algebra( m_algebra_instance )
0093     { }
0094 
0095     adams_moulton( algebra_type &algebra )
0096     : m_coefficients() , m_dxdt() , m_resizer() ,
0097       m_algebra_instance() , m_algebra( algebra )
0098     { }
0099 
0100     adams_moulton& operator=( const adams_moulton &stepper )
0101     {
0102         m_dxdt = stepper.m_dxdt;
0103         m_resizer = stepper.m_resizer;
0104         m_algebra = stepper.m_algebra;
0105         return *this;
0106     }
0107 
0108     order_type order( void ) const { return order_value; }
0109 
0110 
0111     /*
0112      * Version 1 : do_step( system , x , t , dt , buf );
0113      *
0114      * solves the forwarding problem
0115      */
0116     template< class System , class StateInOut , class StateIn , class ABBuf >
0117     void do_step( System system , StateInOut &x , StateIn const & pred , time_type t , time_type dt , const ABBuf &buf )
0118     {
0119         do_step( system , x , pred , t , x , dt , buf );
0120     }
0121 
0122     template< class System , class StateInOut , class StateIn , class ABBuf >
0123     void do_step( System system , const StateInOut &x , StateIn const & pred , time_type t , time_type dt , const ABBuf &buf )
0124     {
0125         do_step( system , x , pred , t , x , dt , buf );
0126     }
0127 
0128 
0129 
0130     /*
0131      * Version 2 : do_step( system , in , t , out , dt , buf );
0132      *
0133      * solves the forwarding problem
0134      */
0135     template< class System , class StateIn , class PredIn , class StateOut , class ABBuf >
0136     void do_step( System system , const StateIn &in , const PredIn &pred , time_type t , StateOut &out , time_type dt , const ABBuf &buf )
0137     {
0138         do_step_impl( system , in , pred , t , out , dt , buf );
0139     }
0140 
0141     template< class System , class StateIn , class PredIn , class StateOut , class ABBuf >
0142     void do_step( System system , const StateIn &in , const PredIn &pred , time_type t , const StateOut &out , time_type dt , const ABBuf &buf )
0143     {
0144         do_step_impl( system , in , pred , t , out , dt , buf );
0145     }
0146 
0147 
0148 
0149     template< class StateType >
0150     void adjust_size( const StateType &x )
0151     {
0152         resize_impl( x );
0153     }
0154 
0155     algebra_type& algebra()
0156     {   return m_algebra; }
0157 
0158     const algebra_type& algebra() const
0159     {   return m_algebra; }
0160 
0161 
0162 private:
0163 
0164 
0165     template< class System , class StateIn , class PredIn , class StateOut , class ABBuf >
0166     void do_step_impl( System system , const StateIn &in , const PredIn &pred , time_type t , StateOut &out , time_type dt , const ABBuf &buf )
0167     {
0168         typename odeint::unwrap_reference< System >::type &sys = system;
0169         m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl<StateIn> , detail::ref( *this ) , detail::_1 ) );
0170         sys( pred , m_dxdt.m_v , t );
0171         detail::adams_moulton_call_algebra< steps , algebra_type , operations_type >()( m_algebra , in , out , m_dxdt.m_v , buf , m_coefficients , dt );
0172     }
0173 
0174 
0175     template< class StateIn >
0176     bool resize_impl( const StateIn &x )
0177     {
0178         return adjust_size_by_resizeability( m_dxdt , x , typename is_resizeable<deriv_type>::type() );
0179     }
0180 
0181 
0182     const detail::adams_moulton_coefficients< value_type , steps > m_coefficients;
0183     wrapped_deriv_type m_dxdt;
0184     resizer_type m_resizer;
0185 
0186 protected:
0187 
0188     algebra_type m_algebra_instance;
0189     algebra_type &m_algebra;
0190 };
0191 
0192 
0193 
0194 
0195 } // odeint
0196 } // numeric
0197 } // boost
0198 
0199 
0200 
0201 #endif // BOOST_NUMERIC_ODEINT_STEPPER_ADAMS_MOULTON_HPP_INCLUDED