Isorropia_EpetraCostDescriber.hpp

Go to the documentation of this file.
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_EpetraCostDescriber_hpp_
00031 #define _Isorropia_EpetraCostDescriber_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_EPETRA
00044 class Epetra_Vector;
00045 class Epetra_CrsMatrix;
00046 
00047 namespace Isorropia {
00048 
00086 class Operator;
00087 
00088 namespace Epetra {
00089 
00107 // Forward declarations of friends
00108 
00109 namespace ZoltanLib{
00110   class QueryObject;
00111 }
00112 class ZoltanLibClass;
00113 
00114 class CostDescriber : public Isorropia::CostDescriber {
00115 
00116   // public methods are part of API, private methods are used by different
00117   // classes in isorropia
00118 
00119   friend class Isorropia::Operator;
00120   friend class Isorropia::Epetra::ZoltanLib::QueryObject;
00121   friend class Isorropia::Epetra::ZoltanLibClass;
00122 
00123 public:
00125   CostDescriber();
00126 
00128   ~CostDescriber();
00129 
00132   friend std::ostream& operator <<(std::ostream &, const Isorropia::Epetra::CostDescriber &cd);
00133 
00142   void setVertexWeights(Teuchos::RCP<const Epetra_Vector> vwts);
00143 
00155   void setGraphEdgeWeights(Teuchos::RCP<const Epetra_CrsMatrix> gewts);
00156 
00166   void setHypergraphEdgeWeights(Teuchos::RCP<const Epetra_Vector> hgewts);
00167 
00184   void setHypergraphEdgeWeights(int numHGedges, const int *hgGIDs, const float *hgEwgts);
00185 
00189   void setHypergraphEdgeWeights(int numHGedges, const int *hgGIDs, const double *hgEwgts);
00190 
00199   void getCosts(std::map<int, float > &vertexWeights,
00200                 std::map<int, std::map<int, float > > &graphEdgeWeights,
00201                 std::map<int, float > &hypergraphEdgeWeights) const;
00202 
00205   void show_cd(std::ostream &) const;
00206 
00207 private:
00208 
00211   void setParameters(const Teuchos::ParameterList& paramlist);
00212 
00215   bool haveVertexWeights() const;
00218   int getNumVertices() const;
00221   void getVertexWeights(int numVertices,
00222                       int* global_ids, float* weights) const; 
00225   bool haveGraphEdgeWeights() const;
00228   int getNumGraphEdges(int vertex_global_id) const;
00229 
00234   int getGraphEdgeVertices(std::set<int> &gids) const;
00235 
00236 
00239   void getGraphEdgeWeights(int vertex_global_id,
00240                                    int num_neighbors,
00241                                    int* neighbor_global_ids,
00242                                    float* weights) const; 
00245   bool haveHypergraphEdgeWeights() const;
00248   int getNumHypergraphEdgeWeights() const;
00251   void getHypergraphEdgeWeights(int numEdges,
00252                                         int* global_ids,
00253                                         float* weights) const;
00254 
00260    int getHypergraphEdgeWeights(std::map<int, float> &wgtMap) const;
00261 
00262 
00268   int getVertexWeights(std::map<int, float> &wgtMap) const;
00269 
00270 
00271 
00279   int getGraphEdgeWeights(int vertex_global_id, std::map<int, float> &wgtMap) const;
00280 
00281 
00282 
00286   bool haveGlobalVertexWeights() const;
00287 
00291   void setNumGlobalVertexWeights(int num);
00292 
00296   bool haveGlobalGraphEdgeWeights() const;
00297 
00301   void setNumGlobalGraphEdgeWeights(int num);
00302 
00306   bool haveGlobalHypergraphEdgeWeights() const;
00307 
00311   void setNumGlobalHypergraphEdgeWeights(int num);
00312 
00315   void allocate_hg_edge_weights_(int n);
00316 
00319   void free_hg_edge_weights_();
00320 
00321   Teuchos::RCP<const Epetra_Vector> vertex_weights_;
00322   Teuchos::RCP<const Epetra_CrsMatrix> graph_edge_weights_;
00323   std::set<int> graph_self_edges_;
00324 
00325   Teuchos::ParameterList paramlist_;
00326 
00327   int *hg_edge_gids_;
00328   float *hg_edge_weights_;
00329   int num_hg_edge_weights_;
00330 
00331   int numGlobalVertexWeights_;
00332   int numGlobalGraphEdgeWeights_;
00333   int numGlobalHypergraphEdgeWeights_;
00334 
00347   int getEdges(int vertexGID, int len, int *nborGID, float *weights) const;
00348 
00349 
00350 };//class CostDescriber
00351 
00352 }//namespace Epetra
00353 }//namespace Isorropia
00354 
00355 #endif //HAVE_EPETRA
00356 
00357 #endif
00358