#include #include #include #include #include #include #include #include using namespace boost; using boost::graph::distributed::mpi_process_group; //--> Cell structure to be attached to each vertex struct Cell { Cell() {} Cell(int id, double volume = -1) : id_(id), volume_(volume) { } template void serialize(Archiver& ar, const unsigned int /*version*/) { ar & id_; ar & volume_; } int id_; double volume_; unsigned int rank_; }; namespace boost { namespace graph { // Use the cell id as a key for indexing vertices in the graph template<> struct internal_vertex_name { typedef multi_index::member type; }; // Allow the graph to build vertices only given cell id template<> struct internal_vertex_constructor { typedef vertex_from_name type; }; } //end namespace graph } // end namespace boost typedef boost::adjacency_list, undirectedS, Cell> Mesh; typedef graph_traits::vertex_descriptor Vertex; typedef graph_traits::edge_descriptor Edge; int test_main(int argc, char** argv) { boost::mpi::environment env(argc, argv); Mesh mesh; mpi_process_group pg = mesh.process_group(); int rank = process_id(pg); bool i_am_root = (rank == 0); // Add vertices by properties to the system add_vertex(Cell(0, 1.1), mesh); add_vertex(Cell(1, 2.1), mesh); add_vertex(Cell(2, 3.1), mesh); add_vertex(Cell(3, 4.1), mesh); add_vertex(Cell(4, 5.1), mesh); add_vertex(Cell(5, 6.1), mesh); // Add edges through vertex names if (i_am_root) { add_edge(0, 2, mesh); add_edge(2, 1, mesh); add_edge(2, 3, mesh); add_edge(3, 4, mesh); add_edge(4, 5, mesh); add_edge(5, 3, mesh); } synchronize(mesh); //---> how do i redistribute using a named graph??? //--> Create a VertexProcessorMap //???? //--> assign a new distribution typename graph_traits::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(mesh); vi != vi_end; ++vi) { Vertex vert = *vi; //--> ???? } //--> redistribute // mesh.redistribute(to_processor_map); synchronize(mesh); return 0; }