OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
CartesianGraphFactory_unit_test.hpp
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
15struct node_cp
16{
18 typedef boost::fusion::vector<size_t,size_t,size_t> type;
19
22 {
23 static const std::string name[];
24 };
25
28
30 static const unsigned int communication = 0;
32 static const unsigned int computation = 1;
34 static const unsigned int memory = 2;
36 static const unsigned int max_prop = 3;
37};
38
39const std::string node_cp::attributes::name[] = {"communication","computation","memory"};
40
41BOOST_AUTO_TEST_SUITE( CartesianGraphFactory_test )
42
43BOOST_AUTO_TEST_CASE( CartesianGraphFactory_use_np)
44{
45 typedef node_cp node;
46
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
67BOOST_AUTO_TEST_CASE( CartesianGraphFactory_use_p)
68{
69 typedef node_cp node;
70
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
91BOOST_AUTO_TEST_SUITE_END()
92
93#endif
This class represent an N-dimensional box.
Definition Box.hpp:61
This class construct a cartesian graph.
static Graph construct(const size_t(&sz)[dim], Box< dim, T > &dom, const size_t(&bc)[dim])
Construct a cartesian graph, with V and E edge properties.
Structure that store a graph in CSR format or basically in compressed adjacency matrix format.
size_t getNEdge() const
Return the number of edges.
size_t getNVertex() const
Return the number of the vertex.
Test structure used for several test.
static const unsigned int communication
communication property id in boost::fusion::vector
static const unsigned int max_prop
total number of properties boost::fusion::vector
static const unsigned int computation
computation property id in boost::fusion::vector
boost::fusion::vector< size_t, size_t, size_t > type
The node contain 3 unsigned long integer for comunication computation and memory.