Metis_gen_vtk.cpp 984 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10
/*
 * Metis_gen_vtk.hpp
 *
 *  Created on: Aug 29, 2015
 *      Author: i-bird
 */

#ifndef VTK_METIS_GEN_VTK_CPP_
#define VTK_METIS_GEN_VTK_CPP_

tonynsyde's avatar
tonynsyde committed
11
#include <iostream>
12 13
#include "Graph/CartesianGraphFactory.hpp"
#include "Graph/map_graph.hpp"
14
#include "Decomposition/Distribution/metis_util.hpp"
15 16 17 18
#include "SubdomainGraphNodes.hpp"

int main(int argc, char ** argv)
{
incardon's avatar
incardon committed
19
	CartesianGraphFactory<2,Graph_CSR<nm_v<2>,nm_e>> g_factory;
20 21 22 23 24 25 26

	// Cartesian grid
	size_t sz[2] = {20,20};

	// Box
	Box<2,float> box({0.0,0.0},{1.0,1.0});

Pietro Incardona's avatar
Pietro Incardona committed
27 28
	const size_t bc[] = {NON_PERIODIC,NON_PERIODIC};

29 30
	// Graph to decompose

incardon's avatar
incardon committed
31
	Graph_CSR<nm_v<2>,nm_e> g = g_factory.construct<nm_e::communication,NO_VERTEX_ID,float,1,0,1>(sz,box,bc);
32 33 34

	// Convert the graph to metis

incardon's avatar
incardon committed
35
	Metis<Graph_CSR<nm_v<2>,nm_e>> met(g,4);
36 37 38

	// decompose

incardon's avatar
incardon committed
39
	met.decompose<nm_v_id>();
40 41 42

	// Write the decomposition

incardon's avatar
incardon committed
43
	VTKWriter<Graph_CSR<nm_v<2>,nm_e>,VTK_GRAPH> vtk(g);
44 45 46 47 48
	vtk.write("Metis/vtk_partition.vtk");
}


#endif /* VTK_METIS_GEN_VTK_CPP_ */