1 | /* |
2 | |
3 | [begin_description] |
4 | Test case for issue 149: |
5 | Error C2582 with msvc-10 when using iterator-based integration |
6 | [end_description] |
7 | |
8 | Copyright 2011-2015 Karsten Ahnert |
9 | Copyright 2011-2015 Mario Mulansky |
10 | |
11 | Distributed under the Boost Software License, Version 1.0. |
12 | (See accompanying file LICENSE_1_0.txt or |
13 | copy at http://www.boost.org/LICENSE_1_0.txt) |
14 | */ |
15 | |
16 | |
17 | // disable checked iterator warning for msvc |
18 | |
19 | #include <boost/config.hpp> |
20 | #ifdef BOOST_MSVC |
21 | #pragma warning(disable:4996) |
22 | #endif |
23 | |
24 | #define BOOST_TEST_MODULE odeint_regression_147 |
25 | |
26 | #include <utility> |
27 | #include <iostream> |
28 | |
29 | #include <boost/array.hpp> |
30 | |
31 | #include <boost/test/unit_test.hpp> |
32 | |
33 | #include <boost/mpl/vector.hpp> |
34 | #include <boost/range/algorithm/find_if.hpp> |
35 | |
36 | #include <boost/numeric/odeint.hpp> |
37 | #include <boost/numeric/odeint/algebra/fusion_algebra.hpp> |
38 | #include <boost/numeric/odeint/algebra/fusion_algebra_dispatcher.hpp> |
39 | |
40 | |
41 | #include <boost/units/systems/si/length.hpp> |
42 | #include <boost/units/systems/si/time.hpp> |
43 | #include <boost/units/systems/si/velocity.hpp> |
44 | #include <boost/units/systems/si/acceleration.hpp> |
45 | #include <boost/units/systems/si/io.hpp> |
46 | |
47 | #include <boost/fusion/container.hpp> |
48 | |
49 | |
50 | using namespace boost::unit_test; |
51 | using namespace boost::numeric::odeint; |
52 | namespace mpl = boost::mpl; |
53 | |
54 | namespace fusion = boost::fusion; |
55 | namespace units = boost::units; |
56 | namespace si = boost::units::si; |
57 | |
58 | typedef units::quantity< si::time , double > time_type; |
59 | typedef units::quantity< si::length , double > length_type; |
60 | typedef units::quantity< si::velocity , double > velocity_type; |
61 | typedef units::quantity< si::acceleration , double > acceleration_type; |
62 | typedef units::quantity< si::frequency , double > frequency_type; |
63 | |
64 | typedef fusion::vector< length_type , velocity_type > state_type; |
65 | typedef fusion::vector< velocity_type , acceleration_type > deriv_type; |
66 | |
67 | |
68 | struct oscillator |
69 | { |
70 | frequency_type m_omega; |
71 | |
72 | oscillator( const frequency_type &omega = 1.0 * si::hertz ) : m_omega( omega ) { } |
73 | |
74 | void operator()( const state_type &x , deriv_type &dxdt , time_type t ) const |
75 | { |
76 | fusion::at_c< 0 >( seq&: dxdt ) = fusion::at_c< 1 >( seq: x ); |
77 | fusion::at_c< 1 >( seq&: dxdt ) = - m_omega * m_omega * fusion::at_c< 0 >( seq: x ); |
78 | } |
79 | }; |
80 | |
81 | |
82 | BOOST_AUTO_TEST_CASE( regression_168 ) |
83 | { |
84 | typedef runge_kutta_dopri5< state_type , double , deriv_type , time_type > stepper_type; |
85 | |
86 | state_type x( 1.0 * si::meter , 0.0 * si::meter_per_second ); |
87 | |
88 | integrate_const( stepper: make_dense_output( abs_error: 1.0e-6 , rel_error: 1.0e-6 , stepper: stepper_type() ) , system: oscillator( 2.0 * si::hertz ) , |
89 | start_state&: x , start_time: 0.0 * si::second , end_time: 100.0 * si::second , dt: 0.1 * si::second); |
90 | } |