Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /*
0002  [auto_generated]
0003  boost/numeric/odeint/stepper/euler.hpp
0004 
0005  [begin_description]
0006  Implementation of the classical explicit Euler stepper. This method is really simple and should only
0007  be used for demonstration purposes.
0008  [end_description]
0009 
0010  Copyright 2010-2013 Karsten Ahnert
0011  Copyright 2010-2013 Mario Mulansky
0012 
0013  Distributed under the Boost Software License, Version 1.0.
0014  (See accompanying file LICENSE_1_0.txt or
0015  copy at http://www.boost.org/LICENSE_1_0.txt)
0016  */
0017 
0018 
0019 #ifndef BOOST_NUMERIC_ODEINT_STEPPER_EULER_HPP_INCLUDED
0020 #define BOOST_NUMERIC_ODEINT_STEPPER_EULER_HPP_INCLUDED
0021 
0022 
0023 #include <boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp>
0024 #include <boost/numeric/odeint/util/resizer.hpp>
0025 #include <boost/numeric/odeint/algebra/range_algebra.hpp>
0026 #include <boost/numeric/odeint/algebra/default_operations.hpp>
0027 #include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
0028 #include <boost/numeric/odeint/algebra/operations_dispatcher.hpp>
0029 
0030 namespace boost {
0031 namespace numeric {
0032 namespace odeint {
0033 
0034 
0035 template<
0036 class State ,
0037 class Value = double ,
0038 class Deriv = State ,
0039 class Time = Value ,
0040 class Algebra = typename algebra_dispatcher< State >::algebra_type ,
0041 class Operations = typename operations_dispatcher< State >::operations_type ,
0042 class Resizer = initially_resizer
0043 >
0044 #ifndef DOXYGEN_SKIP
0045 class euler
0046 : public explicit_stepper_base<
0047   euler< State , Value , Deriv , Time , Algebra , Operations , Resizer > ,
0048   1 , State , Value , Deriv , Time , Algebra , Operations , Resizer >
0049 #else
0050 class euler : public explicit_stepper_base
0051 #endif
0052 {
0053 public :
0054 
0055     #ifndef DOXYGEN_SKIP
0056     typedef explicit_stepper_base< euler< State , Value , Deriv , Time , Algebra , Operations , Resizer > , 1 , State , Value , Deriv , Time , Algebra , Operations , Resizer > stepper_base_type;
0057     #else
0058     typedef explicit_stepper_base< euler< ... > , ... > stepper_base_type;
0059     #endif
0060     typedef typename stepper_base_type::state_type state_type;
0061     typedef typename stepper_base_type::value_type value_type;
0062     typedef typename stepper_base_type::deriv_type deriv_type;
0063     typedef typename stepper_base_type::time_type time_type;
0064     typedef typename stepper_base_type::algebra_type algebra_type;
0065     typedef typename stepper_base_type::operations_type operations_type;
0066     typedef typename stepper_base_type::resizer_type resizer_type;
0067 
0068     #ifndef DOXYGEN_SKIP
0069     typedef typename stepper_base_type::stepper_type stepper_type;
0070     typedef typename stepper_base_type::wrapped_state_type wrapped_state_type;
0071     typedef typename stepper_base_type::wrapped_deriv_type wrapped_deriv_type;
0072     #endif 
0073 
0074 
0075     euler( const algebra_type &algebra = algebra_type() ) : stepper_base_type( algebra )
0076     { }
0077 
0078     template< class System , class StateIn , class DerivIn , class StateOut >
0079     void do_step_impl( System /* system */ , const StateIn &in , const DerivIn &dxdt , time_type /* t */ , StateOut &out , time_type dt )
0080     {
0081         stepper_base_type::m_algebra.for_each3( out , in , dxdt ,
0082                 typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , dt ) );
0083 
0084     }
0085 
0086     template< class StateOut , class StateIn1 , class StateIn2 >
0087     void calc_state( StateOut &x , time_type t ,  const StateIn1 &old_state , time_type t_old , const StateIn2 & /*current_state*/ , time_type /* t_new */ ) const
0088     {
0089         const time_type delta = t - t_old;
0090         stepper_base_type::m_algebra.for_each3( x , old_state , stepper_base_type::m_dxdt.m_v ,
0091                 typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , delta ) );
0092     }
0093 
0094     template< class StateType >
0095     void adjust_size( const StateType &x )
0096     {
0097         stepper_base_type::adjust_size( x );
0098     }
0099 };
0100 
0101 
0102 
0103 /********** DOXYGEN ***********/
0104 
0105 /**
0106  * \class euler
0107  * \brief An implementation of the Euler method.
0108  *
0109  * The Euler method is a very simply solver for ordinary differential equations. This method should not be used
0110  * for real applications. It is only useful for demonstration purposes. Step size control is not provided but
0111  * trivial continuous output is available.
0112  * 
0113  * This class derives from explicit_stepper_base and inherits its interface via CRTP (current recurring template pattern),
0114  * see explicit_stepper_base
0115  *
0116  * \tparam State The state type.
0117  * \tparam Value The value type.
0118  * \tparam Deriv The type representing the time derivative of the state.
0119  * \tparam Time The time representing the independent variable - the time.
0120  * \tparam Algebra The algebra type.
0121  * \tparam Operations The operations type.
0122  * \tparam Resizer The resizer policy type.
0123  */
0124 
0125     /**
0126      * \fn euler::euler( const algebra_type &algebra )
0127      * \brief Constructs the euler class. This constructor can be used as a default
0128      * constructor of the algebra has a default constructor.
0129      * \param algebra A copy of algebra is made and stored inside explicit_stepper_base.
0130      */
0131     
0132     /**
0133      * \fn euler::do_step_impl( System system , const StateIn &in , const DerivIn &dxdt , time_type t , StateOut &out , time_type dt )
0134      * \brief This method performs one step. The derivative `dxdt` of `in` at the time `t` is passed to the method.
0135      * The result is updated out of place, hence the input is in `in` and the output in `out`.
0136      * Access to this step functionality is provided by explicit_stepper_base and 
0137      * `do_step_impl` should not be called directly.
0138      *
0139      * \param system The system function to solve, hence the r.h.s. of the ODE. It must fulfill the
0140      *               Simple System concept.
0141      * \param in The state of the ODE which should be solved. in is not modified in this method
0142      * \param dxdt The derivative of x at t.
0143      * \param t The value of the time, at which the step should be performed.
0144      * \param out The result of the step is written in out.
0145      * \param dt The step size.
0146      */
0147 
0148 
0149     /**
0150      * \fn euler::calc_state( StateOut &x , time_type t ,  const StateIn1 &old_state , time_type t_old , const StateIn2 &current_state , time_type t_new ) const
0151      * \brief This method is used for continuous output and it calculates the state `x` at a time `t` from the 
0152      * knowledge of two states `old_state` and `current_state` at time points `t_old` and `t_new`.
0153      */
0154 
0155     /**
0156      * \fn euler::adjust_size( const StateType &x )
0157      * \brief Adjust the size of all temporaries in the stepper manually.
0158      * \param x A state from which the size of the temporaries to be resized is deduced.
0159      */
0160 
0161 } // odeint
0162 } // numeric
0163 } // boost
0164 
0165 
0166 #endif // BOOST_NUMERIC_ODEINT_STEPPER_EULER_HPP_INCLUDED