1 /* Boost check_thrust.cu test file
3 Copyright 2010-2013 Mario Mulansky
4 Copyright 2010-2011 Karsten Ahnert
6 This file tests the use of the euler stepper
8 Distributed under the Boost Software License, Version 1.0.
9 (See accompanying file LICENSE_1_0.txt or
10 copy at http://www.boost.org/LICENSE_1_0.txt)
13 //#include <boost/test/unit_test.hpp>
15 #include <boost/numeric/odeint/stepper/euler.hpp>
16 #include <boost/numeric/odeint/external/thrust/thrust.hpp>
18 #include <thrust/device_vector.h>
19 #include <thrust/fill.h>
21 using namespace boost::numeric::odeint;
23 typedef float base_type;
24 // typedef thrust::device_vector< base_type > state_type;
25 typedef thrust::host_vector< base_type > state_type;
27 void constant_system( const state_type &x , state_type &dxdt , base_type t )
29 thrust::fill( dxdt.begin() , dxdt.end() , static_cast<base_type>(1.0) );
32 const base_type eps = 1.0e-7;
35 template< class Stepper , class System >
36 void check_stepper_concept( Stepper &stepper , System system , typename Stepper::state_type &x )
38 typedef Stepper stepper_type;
39 typedef typename stepper_type::state_type container_type;
40 typedef typename stepper_type::order_type order_type;
41 typedef typename stepper_type::time_type time_type;
43 stepper.do_step( system , x , 0.0 , 0.1 );
44 base_type xval = *boost::begin( x );
45 if( fabs( xval - 0.1 ) < eps )
46 std::clog << "TEST PASSED" << std::endl;
48 std::clog << "TEST FAILED" << std::endl;
51 void test_euler_with_thrust( void )
54 thrust::fill( x.begin() , x.end() , static_cast<base_type>(0.0) );
55 euler< state_type , base_type , state_type , base_type > euler;
56 check_stepper_concept( euler , constant_system , x );
61 /*test_suite* init_unit_test_suite( int argc, char* argv[] )
63 test_suite *test = BOOST_TEST_SUITE("check stepper with thrust");
65 test->add( BOOST_TEST_CASE( &test_euler_with_thrust ) );
71 test_euler_with_thrust();