• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Boost check_thrust.cu test file
2 
3  Copyright 2010-2013 Mario Mulansky
4  Copyright 2010-2011 Karsten Ahnert
5 
6  This file tests the use of the euler stepper
7 
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)
11 */
12 
13 //#include <boost/test/unit_test.hpp>
14 
15 #include <boost/numeric/odeint/stepper/euler.hpp>
16 #include <boost/numeric/odeint/external/thrust/thrust.hpp>
17 
18 #include <thrust/device_vector.h>
19 #include <thrust/fill.h>
20 
21 using namespace boost::numeric::odeint;
22 
23 typedef float base_type;
24 // typedef thrust::device_vector< base_type > state_type;
25 typedef thrust::host_vector< base_type > state_type;
26 
constant_system(const state_type & x,state_type & dxdt,base_type t)27 void constant_system( const state_type &x , state_type &dxdt , base_type t )
28 {
29 	thrust::fill( dxdt.begin() , dxdt.end() , static_cast<base_type>(1.0) );
30 }
31 
32 const base_type eps = 1.0e-7;
33 
34 
35 template< class Stepper , class System >
check_stepper_concept(Stepper & stepper,System system,typename Stepper::state_type & x)36 void check_stepper_concept( Stepper &stepper , System system , typename Stepper::state_type &x )
37 {
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;
42 
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;
47     else
48     	std::clog << "TEST FAILED" << std::endl;
49 }
50 
test_euler_with_thrust(void)51 void test_euler_with_thrust( void )
52 {
53 	state_type x(1);
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 );
57 
58 
59 }
60 
61 /*test_suite* init_unit_test_suite( int argc, char* argv[] )
62 {
63     test_suite *test = BOOST_TEST_SUITE("check stepper with thrust");
64 
65     test->add( BOOST_TEST_CASE( &test_euler_with_thrust ) );
66 
67     return test;
68 }*/
69 
main()70 int main() {
71 	test_euler_with_thrust();
72 }
73