]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/numeric/odeint/include/boost/numeric/odeint/stepper/explicit_generic_rk.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / numeric / odeint / include / boost / numeric / odeint / stepper / explicit_generic_rk.hpp
CommitLineData
7c673cae
FG
1/*
2 [auto_generated]
3 boost/numeric/odeint/stepper/explicit_generic_rk.hpp
4
5 [begin_description]
6 Implementation of the generic Runge-Kutta steppers. This is the base class for many Runge-Kutta steppers.
7 [end_description]
8
9 Copyright 2011-2013 Mario Mulansky
10 Copyright 2011-2013 Karsten Ahnert
11 Copyright 2012 Christoph Koke
12
13 Distributed under the Boost Software License, Version 1.0.
14 (See accompanying file LICENSE_1_0.txt or
15 copy at http://www.boost.org/LICENSE_1_0.txt)
16 */
17
18
19#ifndef BOOST_NUMERIC_ODEINT_STEPPER_EXPLICIT_GENERIC_RK_HPP_INCLUDED
20#define BOOST_NUMERIC_ODEINT_STEPPER_EXPLICIT_GENERIC_RK_HPP_INCLUDED
21
22
23#include <boost/array.hpp>
24
25
26#include <boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp>
27#include <boost/numeric/odeint/algebra/range_algebra.hpp>
28#include <boost/numeric/odeint/algebra/default_operations.hpp>
29#include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
30#include <boost/numeric/odeint/algebra/operations_dispatcher.hpp>
31#include <boost/numeric/odeint/stepper/detail/generic_rk_algorithm.hpp>
32
33#include <boost/numeric/odeint/util/state_wrapper.hpp>
34#include <boost/numeric/odeint/util/is_resizeable.hpp>
35#include <boost/numeric/odeint/util/resizer.hpp>
36
37namespace boost {
38namespace numeric {
39namespace odeint {
40
41//forward declarations
42
43#ifndef DOXYGEN_SKIP
44template<
45size_t StageCount,
46size_t Order,
47class State ,
48class Value = double ,
49class Deriv = State ,
50class Time = Value ,
51class Algebra = typename algebra_dispatcher< State >::algebra_type ,
52class Operations = typename operations_dispatcher< State >::operations_type ,
53class Resizer = initially_resizer
54>
55class explicit_generic_rk;
56
57
58struct stage_vector;
59
60template< class T , class Constant >
61struct array_wrapper
62{
63 typedef const typename boost::array< T , Constant::value > type;
64};
65
66template< class T , size_t i >
67struct stage
68{
69 T c;
70 boost::array< T , i > a;
71};
72
73
74template< class T , class Constant >
75struct stage_wrapper
76{
77 typedef stage< T , Constant::value > type;
78};
79#endif
80
81
82template<
83size_t StageCount,
84size_t Order,
85class State ,
86class Value ,
87class Deriv ,
88class Time ,
89class Algebra ,
90class Operations ,
91class Resizer
92>
93#ifndef DOXYGEN_SKIP
94class explicit_generic_rk : public explicit_stepper_base<
95explicit_generic_rk< StageCount , Order , State , Value , Deriv , Time , Algebra , Operations , Resizer > ,
96Order , State , Value , Deriv , Time , Algebra , Operations , Resizer >
97#else
98class explicit_generic_rk : public explicit_stepper_base
99#endif
100{
101
102public:
103
104 #ifndef DOXYGEN_SKIP
105 typedef explicit_stepper_base<
106 explicit_generic_rk< StageCount , Order , State , Value , Deriv ,Time , Algebra , Operations , Resizer > ,
107 Order , State , Value , Deriv , Time , Algebra ,
108 Operations , Resizer > stepper_base_type;
109 #else
110 typedef explicit_stepper_base< ... > stepper_base_type;
111 #endif
112
113 typedef typename stepper_base_type::state_type state_type;
114 typedef typename stepper_base_type::wrapped_state_type wrapped_state_type;
115 typedef typename stepper_base_type::value_type value_type;
116 typedef typename stepper_base_type::deriv_type deriv_type;
117 typedef typename stepper_base_type::wrapped_deriv_type wrapped_deriv_type;
118 typedef typename stepper_base_type::time_type time_type;
119 typedef typename stepper_base_type::algebra_type algebra_type;
120 typedef typename stepper_base_type::operations_type operations_type;
121 typedef typename stepper_base_type::resizer_type resizer_type;
122
123 #ifndef DOXYGEN_SKIP
124 typedef explicit_generic_rk< StageCount , Order , State , Value , Deriv ,Time , Algebra , Operations , Resizer > stepper_type;
125 #endif
126
127 typedef detail::generic_rk_algorithm< StageCount , Value , Algebra , Operations > rk_algorithm_type;
128
129 typedef typename rk_algorithm_type::coef_a_type coef_a_type;
130 typedef typename rk_algorithm_type::coef_b_type coef_b_type;
131 typedef typename rk_algorithm_type::coef_c_type coef_c_type;
132
133 #ifndef DOXYGEN_SKIP
134 static const size_t stage_count = StageCount;
135 #endif
136
137public:
138
139 explicit_generic_rk( const coef_a_type &a , const coef_b_type &b , const coef_c_type &c ,
140 const algebra_type &algebra = algebra_type() )
141 : stepper_base_type( algebra ) , m_rk_algorithm( a , b , c )
142 { }
143
144
145 template< class System , class StateIn , class DerivIn , class StateOut >
146 void do_step_impl( System system , const StateIn &in , const DerivIn &dxdt ,
147 time_type t , StateOut &out , time_type dt )
148 {
149 m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl< StateIn > , detail::ref( *this ) , detail::_1 ) );
150
151 // actual calculation done in generic_rk.hpp
152 m_rk_algorithm.do_step( stepper_base_type::m_algebra , system , in , dxdt , t , out , dt , m_x_tmp.m_v , m_F );
153 }
154
155 template< class StateIn >
156 void adjust_size( const StateIn &x )
157 {
158 resize_impl( x );
159 stepper_base_type::adjust_size( x );
160 }
161
162private:
163
164 template< class StateIn >
165 bool resize_impl( const StateIn &x )
166 {
167 bool resized( false );
168 resized |= adjust_size_by_resizeability( m_x_tmp , x , typename is_resizeable<state_type>::type() );
169 for( size_t i = 0 ; i < StageCount-1 ; ++i )
170 {
171 resized |= adjust_size_by_resizeability( m_F[i] , x , typename is_resizeable<deriv_type>::type() );
172 }
173 return resized;
174 }
175
176
177 rk_algorithm_type m_rk_algorithm;
178
179 resizer_type m_resizer;
180
181 wrapped_state_type m_x_tmp;
182 wrapped_deriv_type m_F[StageCount-1];
183
184};
185
186
187
188/*********** DOXYGEN *************/
189
190/**
191 * \class explicit_generic_rk
192 * \brief A generic implementation of explicit Runge-Kutta algorithms. This class is as a base class
193 * for all explicit Runge-Kutta steppers.
194 *
195 * This class implements the explicit Runge-Kutta algorithms without error estimation in a generic way.
196 * The Butcher tableau is passed to the stepper which constructs the stepper scheme with the help of a
197 * template-metaprogramming algorithm. ToDo : Add example!
198 *
199 * This class derives explicit_stepper_base which provides the stepper interface.
200 *
201 * \tparam StageCount The number of stages of the Runge-Kutta algorithm.
202 * \tparam Order The order of the stepper.
203 * \tparam State The type representing the state of the ODE.
204 * \tparam Value The floating point type which is used in the computations.
205 * \tparam Time The type representing the independent variable - the time - of the ODE.
206 * \tparam Algebra The algebra type.
207 * \tparam Operations The operations type.
208 * \tparam Resizer The resizer policy type.
209 */
210
211 /**
212 * \fn explicit_generic_rk::explicit_generic_rk( const coef_a_type &a , const coef_b_type &b , const coef_c_type &c , const algebra_type &algebra )
213 * \brief Constructs the explicit_generic_rk class. See examples section for details on the coefficients.
214 * \param a Triangular matrix of parameters b in the Butcher tableau.
215 * \param b Last row of the butcher tableau.
216 * \param c Parameters to calculate the time points in the Butcher tableau.
217 * \param algebra A copy of algebra is made and stored inside explicit_stepper_base.
218 */
219
220 /**
221 * \fn explicit_generic_rk::do_step_impl( System system , const StateIn &in , const DerivIn &dxdt , time_type t , StateOut &out , time_type dt )
222 * \brief This method performs one step. The derivative `dxdt` of `in` at the time `t` is passed to the method.
223 * The result is updated out of place, hence the input is in `in` and the output in `out`.
224 * Access to this step functionality is provided by explicit_stepper_base and
225 * `do_step_impl` should not be called directly.
226 *
227 * \param system The system function to solve, hence the r.h.s. of the ODE. It must fulfill the
228 * Simple System concept.
229 * \param in The state of the ODE which should be solved. in is not modified in this method
230 * \param dxdt The derivative of x at t.
231 * \param t The value of the time, at which the step should be performed.
232 * \param out The result of the step is written in out.
233 * \param dt The step size.
234 */
235
236
237 /**
238 * \fn explicit_generic_rk::adjust_size( const StateIn &x )
239 * \brief Adjust the size of all temporaries in the stepper manually.
240 * \param x A state from which the size of the temporaries to be resized is deduced.
241 */
242
243}
244}
245}
246#endif // BOOST_NUMERIC_ODEINT_STEPPER_EXPLICIT_GENERIC_RK_HPP_INCLUDED