OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
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
24BOOST_AUTO_TEST_SUITE( Metis_test )
25
26BOOST_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<3>,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<3>,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// Do not check for ARM files are a little different
82
83#ifndef __ARM_ARCH
84 BOOST_REQUIRE_EQUAL(true,test);
85 BOOST_REQUIRE_EQUAL(true,test2);
86#endif
87}
88
89BOOST_AUTO_TEST_SUITE_END()
90
91#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.
Helper class to define Metis graph.
size_t getProcessUnitID()
Get the process unit id.
size_t getProcessingUnits()
Get the total number of processors.
Implementation of VCluster class.
Definition VCluster.hpp:59
sub-domain edge graph node
static const unsigned int communication
computation property id in boost::fusion::vector
static const unsigned int id
partition id in the boost::fusion::vector