27 #ifndef __vtkPBGLGraphAdapter_h
28 #define __vtkPBGLGraphAdapter_h
33 #include <boost/graph/use_mpi.hpp>
34 #include <boost/graph/distributed/mpi_process_group.hpp>
35 #include <boost/graph/properties.hpp>
36 #include <boost/graph/parallel/container_traits.hpp>
37 #include <boost/property_map/parallel/local_property_map.hpp>
38 #include <boost/property_map/parallel/distributed_property_map.hpp>
39 #include <boost/serialization/base_object.hpp>
40 #include <boost/functional/hash.hpp>
51 #define SUBCLASS_PROPERTY_MAP_SPECIALIZATIONS(Property) \
53 struct property_map<vtkDirectedGraph *, Property> \
54 : property_map<vtkGraph *, Property> { }; \
57 struct property_map<vtkUndirectedGraph *, Property> \
58 : property_map<vtkGraph *, Property> { }; \
61 struct property_map<vtkDirectedGraph * const, Property> \
62 : property_map<vtkGraph *, Property> { }; \
65 struct property_map<vtkUndirectedGraph * const, Property> \
66 : property_map<vtkGraph *, Property> { }
76 :
helper(graph? graph->GetDistributedGraphHelper() : 0) { }
99 return owner_map.helper->GetVertexOwner(key);
105 struct property_map<vtkGraph*, vertex_owner_t>
115 get(vertex_owner_t, vtkGraph* graph)
129 :
helper(graph? graph->GetDistributedGraphHelper() : 0) { }
152 return local_map.helper->GetVertexIndex(key);
158 struct property_map<vtkGraph*, vertex_local_t>
168 get(vertex_local_t, vtkGraph* graph)
179 :
helper(graph? graph->GetDistributedGraphHelper() : 0) { }
198 return std::pair<int,vtkIdType>(global_map.helper->GetVertexOwner(key),
199 global_map.helper->GetVertexIndex(key));
204 struct property_map<vtkGraph*, vertex_global_t>
213 get(vertex_global_t, vtkGraph* graph)
224 :
helper(graph? graph->GetDistributedGraphHelper() : 0) { }
243 return std::pair<int, vtkIdType>
244 (global_map.helper->GetEdgeOwner(key.Id), key.Id);
249 struct property_map<vtkGraph*, edge_global_t>
258 get(edge_global_t, vtkGraph* graph)
263 #undef SUBCLASS_PROPERTY_MAP_SPECIALIZATIONS
268 struct hash<vtkEdgeType>
272 return hash_value(edge.Id);
282 namespace boost {
namespace graph {
namespace parallel {
284 struct process_group_type<vtkGraph *>
286 typedef boost::graph::distributed::mpi_process_group
type;
294 struct process_group_type<vtkUndirectedGraph *>
302 struct process_group_type<vtkUndirectedGraph *
const>
306 boost::graph::distributed::mpi_process_group
process_group(vtkGraph *graph);
308 inline boost::graph::distributed::mpi_process_group
314 inline boost::graph::distributed::mpi_process_group
325 template<
typename Archiver>
326 void serialize(Archiver& ar, vtkEdgeBase& edge,
const unsigned int)
331 template<
typename Archiver>
332 void serialize(Archiver& ar, vtkOutEdgeType& edge,
const unsigned int)
334 ar & boost::serialization::base_object<vtkEdgeBase>(edge)
338 template<
typename Archiver>
339 void serialize(Archiver& ar, vtkInEdgeType& edge,
const unsigned int)
341 ar & boost::serialization::base_object<vtkEdgeBase>(edge)
345 template<
typename Archiver>
346 void serialize(Archiver& ar, vtkEdgeType& edge,
const unsigned int)
348 ar & boost::serialization::base_object<vtkEdgeBase>(edge)
363 typedef boost::local_property_map<boost::graph::distributed::mpi_process_group,
374 vtkDistributedGraphHelper *helper = graph->GetDistributedGraphHelper();
377 vtkErrorWithObjectMacro(graph,
"A vtkGraph without a distributed graph helper is not a distributed graph");
386 vtkErrorWithObjectMacro(graph,
"A vtkGraph with a non-Parallel BGL distributed graph helper cannot be used with the Parallel BGL");
398 template<
typename DataArray>
401 typedef boost::parallel::distributed_property_map<
402 boost::graph::distributed::mpi_process_group,
411 template<
typename DataArray>
418 vtkDistributedGraphHelper *helper = graph->GetDistributedGraphHelper();
421 vtkErrorWithObjectMacro(graph,
"A vtkGraph without a distributed graph helper is not a distributed graph");
429 vtkErrorWithObjectMacro(graph,
"A vtkGraph with a non-Parallel BGL distributed graph helper cannot be used with the Parallel BGL");
441 template<
typename DataArray>
444 typedef boost::parallel::distributed_property_map<
445 boost::graph::distributed::mpi_process_group,
454 template<
typename DataArray>
461 vtkDistributedGraphHelper *helper = graph->GetDistributedGraphHelper();
464 vtkErrorWithObjectMacro(graph,
"A vtkGraph without a distributed graph helper is not a distributed graph");
472 vtkErrorWithObjectMacro(graph,
"A vtkGraph with a non-Parallel BGL distributed graph helper cannot be used with the Parallel BGL");
481 #endif // __vtkPBGLGraphAdapter_h
SUBCLASS_PROPERTY_MAP_SPECIALIZATIONS(vertex_owner_t)
boost::parallel::distributed_property_map< boost::graph::distributed::mpi_process_group, boost::vtkVertexGlobalMap, DataArray * > type
readable_property_map_tag category
readable_property_map_tag category
boost::graph::distributed::mpi_process_group GetProcessGroup()
vtkVertexOwnerMap(vtkGraph *graph)
vtkVertexGlobalMap const_type
vtkGraphDistributedVertexIndexMap MakeDistributedVertexIndexMap(vtkGraph *graph)
readable_property_map_tag category
vtkDistributedGraphHelper * helper
vtkDistributedGraphHelper * helper
std::pair< int, vtkIdType > value_type
static vtkPBGLDistributedGraphHelper * SafeDownCast(vtkObjectBase *o)
std::pair< int, vtkIdType > value_type
vtkEdgeGlobalMap const_type
boost::parallel::distributed_property_map< boost::graph::distributed::mpi_process_group, boost::vtkEdgeGlobalMap, DataArray * > type
boost::local_property_map< boost::graph::distributed::mpi_process_group, boost::vtkVertexGlobalMap, boost::vtkGraphIndexMap > vtkGraphDistributedVertexIndexMap
vtkEdgeGlobalMap(vtkGraph *graph)
boost::graph::distributed::mpi_process_group process_group(vtkGraph *graph)
vtkVertexOwnerMap const_type
vtkDistributedEdgePropertyMapType< DataArray >::type MakeDistributedEdgePropertyMap(vtkGraph *graph, DataArray *array)
vtkDistributedVertexPropertyMapType< DataArray >::type MakeDistributedVertexPropertyMap(vtkGraph *graph, DataArray *array)
vtkDistributedGraphHelper * helper
vtkDistributedGraphHelper * helper
vtkVertexGlobalMap(vtkGraph *graph)
std::size_t operator()(const vtkEdgeType &edge) const
readable_property_map_tag category
boost::graph::distributed::mpi_process_group type
void serialize(Archiver &ar, vtkEdgeBase &edge, const unsigned int)
vtkVertexLocalMap(vtkGraph *graph)
vtkVertexLocalMap const_type
end namespace boost::graph::distributed