Isorropia: Partitioning, Load Balancing and more
Isorropia_TpetraCostDescriber.hpp
Go to the documentation of this file.
1 //@HEADER
2 //************************************************************************
3 //
4 // Isorropia: Partitioning and Load Balancing Package
5 // Copyright (2006) Sandia Corporation
6 //
7 //Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 //license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 //************************************************************************
38 //@HEADER
39 
40 #ifndef _Isorropia_TpetraCostDescriber_hpp_
41 #define _Isorropia_TpetraCostDescriber_hpp_
42 
43 #include <Isorropia_ConfigDefs.hpp>
45 #include <Teuchos_RCP.hpp>
46 #include <Teuchos_ParameterList.hpp>
47 
48 #include <map>
49 #include <list>
50 #include <set>
51 #include <iostream>
52 
53 #ifdef HAVE_ISORROPIA_TPETRA
54 
55 #include <Kokkos_DefaultNode.hpp>
56 #include <Tpetra_Vector_decl.hpp>
57 #include <Tpetra_CrsMatrix_decl.hpp>
58 
59 
60 namespace Isorropia {
61 
100 namespace Tpetra {
101 
119 // Forward declarations of friends
120 
121 
122 template <typename Node = ::Tpetra::Map<int, int>::node_type >
123 class CostDescriber : public Isorropia::CostDescriber {
124 
125  // public methods are part of API, private methods are used by different
126  // classes in isorropia
127 
128  //friend class Isorropia::Operator;
129  //friend class Isorropia::Tpetra::ZoltanLib::QueryObject;
130  //friend class Isorropia::Tpetra::ZoltanLibClass;
131 
132 public:
134  CostDescriber();
135 
137  ~CostDescriber();
138 
140  // */
141  //friend std::ostream& operator << (std::ostream &, const Isorropia::Tpetra::CostDescriber<Node> &cd);
142 
151  void setVertexWeights(Teuchos::RCP<const ::Tpetra::Vector<double,int,int,Node> > vwgts);
152 
164  void setGraphEdgeWeights(Teuchos::RCP<const ::Tpetra::CrsMatrix<double,int,int,Node> > gewts);
165 
175  void setHypergraphEdgeWeights(Teuchos::RCP<const ::Tpetra::Vector<double,int,int,Node> > hgewts);
176 
193  void setHypergraphEdgeWeights(int numHGedges, const int *hgGIDs, const float *hgEwgts);
194 
195 
196  void setHypergraphEdgeWeights(int numHGedges, const int *hgGIDs, const double *hgEwgts);
197 
206  void getCosts(std::map<int, float > &vertexWeights,
207  std::map<int, std::map<int, float > > &graphEdgeWeights,
208  std::map<int, float > &hypergraphEdgeWeights) const;
209 
212  void show_cd(std::ostream &) const;
213 
214 private:
215 
218  void setParameters(const Teuchos::ParameterList& paramlist);
219 
222  bool haveVertexWeights() const;
225  int getNumVertices() const;
228  void getVertexWeights(int numVertices,
229  int* global_ids, float* weights) const;
232  bool haveGraphEdgeWeights() const;
235  int getNumGraphEdges(int vertex_global_id) const;
236 
241  int getGraphEdgeVertices(std::set<int> &gids) const;
242 
243 
246  void getGraphEdgeWeights(int vertex_global_id,
247  int num_neighbors,
248  int* neighbor_global_ids,
249  float* weights) const;
252  bool haveHypergraphEdgeWeights() const;
255  int getNumHypergraphEdgeWeights() const;
258  void getHypergraphEdgeWeights(int numEdges,
259  int* global_ids,
260  float* weights) const;
261 
267  int getHypergraphEdgeWeights(std::map<int, float> &wgtMap) const;
268 
269 
275  int getVertexWeights(std::map<int, float> &wgtMap) const;
276 
277 
278 
286  int getGraphEdgeWeights(int vertex_global_id, std::map<int, float> &wgtMap) const;
287 
288 
289 
293  bool haveGlobalVertexWeights() const;
294 
298  void setNumGlobalVertexWeights(int num);
299 
303  bool haveGlobalGraphEdgeWeights() const;
304 
308  void setNumGlobalGraphEdgeWeights(int num);
309 
313  bool haveGlobalHypergraphEdgeWeights() const;
314 
318  void setNumGlobalHypergraphEdgeWeights(int num);
319 
322  void allocate_hg_edge_weights_(int n);
323 
326  void free_hg_edge_weights_();
327 
328  Teuchos::RCP<const ::Tpetra::Vector<double,int,int,Node> > vertex_weights_;
329  Teuchos::RCP<const ::Tpetra::CrsMatrix<double,int,int,Node> > graph_edge_weights_;
330  std::set<int> graph_self_edges_;
331 
332  Teuchos::ParameterList paramlist_;
333 
334  int *hg_edge_gids_;
335  float *hg_edge_weights_;
336  int num_hg_edge_weights_;
337 
338  int numGlobalVertexWeights_;
339  int numGlobalGraphEdgeWeights_;
340  int numGlobalHypergraphEdgeWeights_;
341 
354  int getEdges(int vertexGID, int len, int *nborGID, float *weights) const;
355 
356 
357 };//class CostDescriber
358 
359 }//namespace Tpetra
360 }//namespace Isorropia
361 
362 #endif //HAVE_TPETRA
363 
364 #endif
365 
Isorropia is the namespace that contains general definitions that apply to all partitioners and that ...
Definition: Isorropia_Epetra.hpp:60
Interface (abstract base class) for describing the weights or costs associated with the vertices and/...
Definition: Isorropia_CostDescriber.hpp:61