| 1 | #ifndef CARTESIAN_GRAPH_UNIT_TEST_HPP | 
| 2 | #define CARTESIAN_GRAPH_UNIT_TEST_HPP | 
| 3 |  | 
| 4 | #include "Graph/CartesianGraphFactory.hpp" | 
| 5 | #include "Graph/map_graph.hpp" | 
| 6 |  | 
| 7 | #define GS_SIZE 64 | 
| 8 |  | 
| 9 | /*! | 
| 10 |  * | 
| 11 |  * Test node | 
| 12 |  * | 
| 13 |  */ | 
| 14 |  | 
| 15 | struct node_cp | 
| 16 | { | 
| 17 | 	//! The node contain 3 unsigned long integer for comunication computation and memory | 
| 18 | 	typedef boost::fusion::vector<size_t,size_t,size_t> type; | 
| 19 |  | 
| 20 | 	//! Attributes name | 
| 21 | 	struct attributes | 
| 22 | 	{ | 
| 23 | 		static const std::string name[]; | 
| 24 | 	}; | 
| 25 |  | 
| 26 | 	//! The data | 
| 27 | 	type data; | 
| 28 |  | 
| 29 | 	//! communication property id in boost::fusion::vector | 
| 30 | 	static const unsigned int communication = 0; | 
| 31 | 	//! computation property id in boost::fusion::vector | 
| 32 | 	static const unsigned int computation = 1; | 
| 33 | 	//! memory property id in boost::fusion::vector | 
| 34 | 	static const unsigned int memory = 2; | 
| 35 | 	//! total number of properties boost::fusion::vector | 
| 36 | 	static const unsigned int max_prop = 3; | 
| 37 | }; | 
| 38 |  | 
| 39 | const std::string node_cp::attributes::name[] = {"communication" ,"computation" ,"memory" }; | 
| 40 |  | 
| 41 | BOOST_AUTO_TEST_SUITE( CartesianGraphFactory_test ) | 
| 42 |  | 
| 43 | BOOST_AUTO_TEST_CASE( CartesianGraphFactory_use_np) | 
| 44 | { | 
| 45 | 	typedef node_cp node; | 
| 46 |  | 
| 47 | 	CartesianGraphFactory<3,Graph_CSR<Point_test<float>,Point_test<float>>> g_factory; | 
| 48 |  | 
| 49 | 	// Cartesian grid | 
| 50 | 	size_t sz[3] = {GS_SIZE,GS_SIZE,GS_SIZE}; | 
| 51 |  | 
| 52 | 	// Box | 
| 53 | 	Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0}); | 
| 54 |  | 
| 55 | 	// Boundary conditions, non periodic | 
| 56 | 	size_t bc[] = {NON_PERIODIC,NON_PERIODIC,NON_PERIODIC}; | 
| 57 |  | 
| 58 | 	Graph_CSR<Point_test<float>,Point_test<float>> g = g_factory.construct<node::communication,NO_VERTEX_ID,float,2>(sz,box,bc); | 
| 59 |  | 
| 60 | 	// check that the number of vertex are equal to GS_SIZE^3 | 
| 61 | 	BOOST_REQUIRE_EQUAL(g.getNVertex(),(size_t)GS_SIZE*GS_SIZE*GS_SIZE); | 
| 62 |  | 
| 63 | 	// check that the number of vertex are equal to GS_SIZE^3 | 
| 64 | 	BOOST_REQUIRE_EQUAL(g.getNEdge(),(size_t)3*8+4*(GS_SIZE-2)*12+6*(GS_SIZE-2)*(GS_SIZE-2)*5+(GS_SIZE-2)*(GS_SIZE-2)*(GS_SIZE-2)*6); | 
| 65 | } | 
| 66 |  | 
| 67 | BOOST_AUTO_TEST_CASE( CartesianGraphFactory_use_p) | 
| 68 | { | 
| 69 | 	typedef node_cp node; | 
| 70 |  | 
| 71 | 	CartesianGraphFactory<3,Graph_CSR<Point_test<float>,Point_test<float>>> g_factory; | 
| 72 |  | 
| 73 | 	// Cartesian grid | 
| 74 | 	size_t sz[3] = {GS_SIZE,GS_SIZE,GS_SIZE}; | 
| 75 |  | 
| 76 | 	// Box | 
| 77 | 	Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0}); | 
| 78 |  | 
| 79 | 	// Boundary conditions, non periodic | 
| 80 | 	size_t bc[] = {PERIODIC,PERIODIC,PERIODIC}; | 
| 81 |  | 
| 82 | 	Graph_CSR<Point_test<float>,Point_test<float>> g = g_factory.construct<node::communication,NO_VERTEX_ID,float,2>(sz,box,bc); | 
| 83 |  | 
| 84 | 	// check that the number of vertex are equal to GS_SIZE^3 | 
| 85 | 	BOOST_REQUIRE_EQUAL(g.getNVertex(),(size_t)GS_SIZE*GS_SIZE*GS_SIZE); | 
| 86 |  | 
| 87 | 	// check that the number of vertex are equal to GS_SIZE^3 | 
| 88 | 	BOOST_REQUIRE_EQUAL(g.getNEdge(),(size_t)(GS_SIZE)*(GS_SIZE)*(GS_SIZE)*6); | 
| 89 | } | 
| 90 |  | 
| 91 | BOOST_AUTO_TEST_SUITE_END() | 
| 92 |  | 
| 93 | #endif | 
| 94 |  |