|
Isorropia: Partitioning, Load Balancing and more Version 3.0
|
00001 //@HEADER 00002 /* 00003 ************************************************************************ 00004 00005 Isorropia: Partitioning and Load Balancing Package 00006 Copyright (2006) Sandia Corporation 00007 00008 Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00009 license for use of this work by or on behalf of the U.S. Government. 00010 00011 This library is free software; you can redistribute it and/or modify 00012 it under the terms of the GNU Lesser General Public License as 00013 published by the Free Software Foundation; either version 2.1 of the 00014 License, or (at your option) any later version. 00015 00016 This library is distributed in the hope that it will be useful, but 00017 WITHOUT ANY WARRANTY; without even the implied warranty of 00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 Lesser General Public License for more details. 00020 00021 You should have received a copy of the GNU Lesser General Public 00022 License along with this library; if not, write to the Free Software 00023 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00024 USA 00025 00026 ************************************************************************ 00027 */ 00028 //@HEADER 00029 00030 #ifndef _Isorropia_TpetraCostDescriber_hpp_ 00031 #define _Isorropia_TpetraCostDescriber_hpp_ 00032 00033 #include <Isorropia_ConfigDefs.hpp> 00034 #include <Isorropia_CostDescriber.hpp> 00035 #include <Teuchos_RCP.hpp> 00036 #include <Teuchos_ParameterList.hpp> 00037 00038 #include <map> 00039 #include <list> 00040 #include <set> 00041 #include <iostream> 00042 00043 #ifdef HAVE_ISORROPIA_TPETRA 00044 00045 #include <Kokkos_DefaultNode.hpp> 00046 #include <Tpetra_Vector_decl.hpp> 00047 #include <Tpetra_CrsMatrix_decl.hpp> 00048 00049 00050 namespace Isorropia { 00051 00090 namespace Tpetra { 00091 00109 // Forward declarations of friends 00110 00111 00112 template <typename Node=Kokkos::DefaultNode::DefaultNodeType> 00113 class CostDescriber : public Isorropia::CostDescriber { 00114 00115 // public methods are part of API, private methods are used by different 00116 // classes in isorropia 00117 00118 //friend class Isorropia::Operator; 00119 //friend class Isorropia::Tpetra::ZoltanLib::QueryObject; 00120 //friend class Isorropia::Tpetra::ZoltanLibClass; 00121 00122 public: 00124 CostDescriber(); 00125 00127 ~CostDescriber(); 00128 00130 // */ 00131 //friend std::ostream& operator << (std::ostream &, const Isorropia::Tpetra::CostDescriber<Node> &cd); 00132 00141 void setVertexWeights(Teuchos::RCP<const ::Tpetra::Vector<double,int,int,Node> > vwgts); 00142 00154 void setGraphEdgeWeights(Teuchos::RCP<const ::Tpetra::CrsMatrix<double,int,int,Node> > gewts); 00155 00165 void setHypergraphEdgeWeights(Teuchos::RCP<const ::Tpetra::Vector<double,int,int,Node> > hgewts); 00166 00183 void setHypergraphEdgeWeights(int numHGedges, const int *hgGIDs, const float *hgEwgts); 00184 00185 00186 void setHypergraphEdgeWeights(int numHGedges, const int *hgGIDs, const double *hgEwgts); 00187 00196 void getCosts(std::map<int, float > &vertexWeights, 00197 std::map<int, std::map<int, float > > &graphEdgeWeights, 00198 std::map<int, float > &hypergraphEdgeWeights) const; 00199 00202 void show_cd(std::ostream &) const; 00203 00204 private: 00205 00208 void setParameters(const Teuchos::ParameterList& paramlist); 00209 00212 bool haveVertexWeights() const; 00215 int getNumVertices() const; 00218 void getVertexWeights(int numVertices, 00219 int* global_ids, float* weights) const; 00222 bool haveGraphEdgeWeights() const; 00225 int getNumGraphEdges(int vertex_global_id) const; 00226 00231 int getGraphEdgeVertices(std::set<int> &gids) const; 00232 00233 00236 void getGraphEdgeWeights(int vertex_global_id, 00237 int num_neighbors, 00238 int* neighbor_global_ids, 00239 float* weights) const; 00242 bool haveHypergraphEdgeWeights() const; 00245 int getNumHypergraphEdgeWeights() const; 00248 void getHypergraphEdgeWeights(int numEdges, 00249 int* global_ids, 00250 float* weights) const; 00251 00257 int getHypergraphEdgeWeights(std::map<int, float> &wgtMap) const; 00258 00259 00265 int getVertexWeights(std::map<int, float> &wgtMap) const; 00266 00267 00268 00276 int getGraphEdgeWeights(int vertex_global_id, std::map<int, float> &wgtMap) const; 00277 00278 00279 00283 bool haveGlobalVertexWeights() const; 00284 00288 void setNumGlobalVertexWeights(int num); 00289 00293 bool haveGlobalGraphEdgeWeights() const; 00294 00298 void setNumGlobalGraphEdgeWeights(int num); 00299 00303 bool haveGlobalHypergraphEdgeWeights() const; 00304 00308 void setNumGlobalHypergraphEdgeWeights(int num); 00309 00312 void allocate_hg_edge_weights_(int n); 00313 00316 void free_hg_edge_weights_(); 00317 00318 Teuchos::RCP<const ::Tpetra::Vector<double,int,int,Node> > vertex_weights_; 00319 Teuchos::RCP<const ::Tpetra::CrsMatrix<double,int,int,Node> > graph_edge_weights_; 00320 std::set<int> graph_self_edges_; 00321 00322 Teuchos::ParameterList paramlist_; 00323 00324 int *hg_edge_gids_; 00325 float *hg_edge_weights_; 00326 int num_hg_edge_weights_; 00327 00328 int numGlobalVertexWeights_; 00329 int numGlobalGraphEdgeWeights_; 00330 int numGlobalHypergraphEdgeWeights_; 00331 00344 int getEdges(int vertexGID, int len, int *nborGID, float *weights) const; 00345 00346 00347 };//class CostDescriber 00348 00349 }//namespace Tpetra 00350 }//namespace Isorropia 00351 00352 #endif //HAVE_TPETRA 00353 00354 #endif 00355