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 
oscillatoroscillator72     oscillator( const frequency_type &omega = 1.0 * si::hertz ) : m_omega( omega ) { }
73 
operator ()oscillator74     void operator()( const state_type &x , deriv_type &dxdt , time_type t ) const
75     {
76         fusion::at_c< 0 >( dxdt ) = fusion::at_c< 1 >( x );
77         fusion::at_c< 1 >( dxdt ) = - m_omega * m_omega * fusion::at_c< 0 >( x );
78     }
79 };
80 
81 
BOOST_AUTO_TEST_CASE(regression_168)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( make_dense_output( 1.0e-6 , 1.0e-6 , stepper_type() ) , oscillator( 2.0 * si::hertz ) ,
89                      x , 0.0 * si::second , 100.0 * si::second , 0.1 * si::second);
90 }