Metis_gen_vtk.cpp 973 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 19 20 21 22 23 24 25 26
#include "SubdomainGraphNodes.hpp"

int main(int argc, char ** argv)
{
	CartesianGraphFactory<2,Graph_CSR<nm_v,nm_e>> g_factory;

	// 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

31
	Graph_CSR<nm_v,nm_e> g = g_factory.construct<nm_e::communication,NO_VERTEX_ID,float,1,0,1>(sz,box,bc);
32 33 34 35 36 37 38 39 40 41 42

	// Convert the graph to metis

	Metis<Graph_CSR<nm_v,nm_e>> met(g,4);

	// decompose

	met.decompose<nm_v::id>();

	// Write the decomposition

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


#endif /* VTK_METIS_GEN_VTK_CPP_ */