OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
metis_util_unit_test.hpp
1 /*
2  * metis_util_unit_test.hpp
3  *
4  * Created on: Dec 21, 2014
5  * Author: i-bird
6  */
7 
8 #ifndef METIS_UTIL_UNIT_TEST_HPP_
9 #define METIS_UTIL_UNIT_TEST_HPP_
10 
11 #include "Graph/CartesianGraphFactory.hpp"
12 #include "Graph/map_graph.hpp"
13 #include "metis_util.hpp"
14 
15 #undef GS_SIZE
16 #define GS_SIZE 8
17 
24 BOOST_AUTO_TEST_SUITE( Metis_test )
25 
26 BOOST_AUTO_TEST_CASE( Metis_test_use)
27 {
28  Vcluster & v_cl = create_vcluster();
29 
30  if (v_cl.getProcessingUnits() != 3)
31  return;
32 
33  if (v_cl.getProcessUnitID() != 0)
34  return;
35 
38 
39  // Cartesian grid
40  size_t sz[3] = {GS_SIZE,GS_SIZE,GS_SIZE};
41 
42  // Box
43  Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0});
44 
45  // Boundary conditions, non periodic
46  size_t bc[] = {NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
47 
48  // Graph to decompose
49  Graph_CSR<nm_v,nm_e> g = g_factory.construct<nm_e::communication,NO_VERTEX_ID,float,2,0>(sz,box,bc);
50 
51  // Processor graph
52  Graph_CSR<nm_part_v,nm_part_e> gp = g_factory_part.construct<NO_EDGE,NO_VERTEX_ID,float,2>(sz,box,bc);
53 
54  // Convert the graph to metis
55 
57 
58  // decompose
59 
60  met.decompose<nm_part_v::id>(gp);
61  met.decompose<nm_v::proc_id>();
62 
63  // Write the VTK file
64 
66  vtk.write("vtk_metis_util_gp.vtk");
67 
68  VTKWriter<Graph_CSR<nm_v,nm_e>,VTK_GRAPH> vtk2(g);
69  vtk2.write("vtk_metis_util_g.vtk");
70 
71  // check that match
72 
73 #ifdef HAVE_OSX
74  bool test = compare("vtk_metis_util_gp.vtk","src/Decomposition/Distribution/test_data/vtk_metis_util_gp_osx_test.vtk");
75  bool test2 = compare("vtk_metis_util_g.vtk","src/Decomposition/Distribution/test_data/vtk_metis_util_g_osx_test.vtk");
76 #else
77  bool test = compare("vtk_metis_util_gp.vtk","src/Decomposition/Distribution/test_data/vtk_metis_util_gp_test.vtk");
78  bool test2 = compare("vtk_metis_util_g.vtk","src/Decomposition/Distribution/test_data/vtk_metis_util_g_test.vtk");
79 #endif
80 
81  BOOST_REQUIRE_EQUAL(true,test);
82  BOOST_REQUIRE_EQUAL(true,test2);
83 }
84 
85 BOOST_AUTO_TEST_SUITE_END()
86 
87 #endif
size_t getProcessUnitID()
Get the process unit id.
static const unsigned int communication
computation property id in boost::fusion::vector
Helper class to define Metis graph.
Definition: metis_util.hpp:73
Implementation of VCluster class.
Definition: VCluster.hpp:36
This class construct a cartesian graph.
static const unsigned int id
partition id in the boost::fusion::vector
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.
static const unsigned int proc_id
proc_id property id in boost::fusion::vector
size_t getProcessingUnits()
Get the total number of processors.