| 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_EpetraLibrary_hpp_ |
| 41 |
#define _Isorropia_EpetraLibrary_hpp_ |
| 42 |
|
| 43 |
#include <Isorropia_ConfigDefs.hpp> |
| 44 |
#include <Teuchos_RCP.hpp> |
| 45 |
#include <Teuchos_ParameterList.hpp> |
| 46 |
|
| 47 |
#include <Isorropia_EpetraCostDescriber.hpp> |
| 48 |
|
| 49 |
#ifdef HAVE_EPETRA |
| 50 |
class Epetra_Map; |
| 51 |
class Epetra_BlockMap; |
| 52 |
class Epetra_Import; |
| 53 |
class Epetra_Vector; |
| 54 |
class Epetra_MultiVector; |
| 55 |
class Epetra_CrsGraph; |
| 56 |
class Epetra_CrsMatrix; |
| 57 |
class Epetra_RowMatrix; |
| 58 |
class Epetra_LinearProblem; |
| 59 |
|
| 60 |
namespace Isorropia { |
| 61 |
|
| 62 |
namespace Epetra { |
| 63 |
class CostDescriber; |
| 64 |
|
| 65 |
/** An implementation of the Partitioner interface that operates on |
| 66 |
Epetra matrices and linear systems. |
| 67 |
|
| 68 |
*/ |
| 69 |
|
| 70 |
class Library { |
| 71 |
public: |
| 72 |
|
| 73 |
Library(Teuchos::RCP<const Epetra_CrsGraph> input_graph, int itype = unspecified_input_); |
| 74 |
Library(Teuchos::RCP<const Epetra_CrsGraph> input_graph, Teuchos::RCP<const Epetra_MultiVector> input_coords, |
| 75 |
int itype = unspecified_input_); |
| 76 |
Library(Teuchos::RCP<const Epetra_CrsGraph> input_graph, |
| 77 |
Teuchos::RCP<CostDescriber> costs, int itype = unspecified_input_); |
| 78 |
Library(Teuchos::RCP<const Epetra_CrsGraph> input_graph, Teuchos::RCP<CostDescriber> costs, |
| 79 |
Teuchos::RCP<const Epetra_MultiVector> input_coords, Teuchos::RCP<const Epetra_MultiVector> weights, |
| 80 |
int itype = unspecified_input_); |
| 81 |
Library(Teuchos::RCP<const Epetra_RowMatrix> input_matrix, int itype = unspecified_input_); |
| 82 |
Library(Teuchos::RCP<const Epetra_RowMatrix> input_matrix, Teuchos::RCP<const Epetra_MultiVector> input_coords, |
| 83 |
int itype = unspecified_input_); |
| 84 |
Library(Teuchos::RCP<const Epetra_RowMatrix> input_matrix, |
| 85 |
Teuchos::RCP<CostDescriber> costs, int itype = unspecified_input_); |
| 86 |
Library(Teuchos::RCP<const Epetra_RowMatrix> input_matrix, Teuchos::RCP<CostDescriber> costs, |
| 87 |
Teuchos::RCP<const Epetra_MultiVector> input_coords, Teuchos::RCP<const Epetra_MultiVector> weights, |
| 88 |
int itype = unspecified_input_); |
| 89 |
Library(Teuchos::RCP<const Epetra_MultiVector> input_coords, int itype = unspecified_input_); |
| 90 |
Library(Teuchos::RCP<const Epetra_MultiVector> input_coords, |
| 91 |
Teuchos::RCP<const Epetra_MultiVector> weights, int itype = unspecified_input_); |
| 92 |
Library(Teuchos::RCP<const Epetra_BlockMap> input_map, int itype = unspecified_input_); |
| 93 |
|
| 94 |
virtual ~Library(); |
| 95 |
|
| 96 |
virtual int |
| 97 |
repartition(Teuchos::ParameterList& paramlist, |
| 98 |
std::vector<int>& myNewElements, |
| 99 |
int& exportsSize, |
| 100 |
std::vector<int>& imports) = 0; |
| 101 |
|
| 102 |
virtual int |
| 103 |
color(Teuchos::ParameterList& paramlist, |
| 104 |
std::vector<int>& colorAssignment) = 0 ; |
| 105 |
|
| 106 |
virtual int |
| 107 |
order(Teuchos::ParameterList& paramlist, |
| 108 |
std::vector<int>& orderAssignment) = 0 ; |
| 109 |
|
| 110 |
/** input_type_ == hgraph_input_ |
| 111 |
This indicates that the matrix or graph represents a hypergraph. Columns |
| 112 |
represent hyperedges, and row (vertex) partitioning is to be performed. |
| 113 |
*/ |
| 114 |
|
| 115 |
static const int hgraph_input_ = 1; |
| 116 |
|
| 117 |
/** input_type_ == hgraph2d_finegrain_input_ |
| 118 |
This indicates that the matrix or graph represents a hypergraph. Columns |
| 119 |
represent hyperedges, and non-zeroes are to be partitioned. |
| 120 |
*/ |
| 121 |
static const int hgraph2d_finegrain_input_ = 2; |
| 122 |
|
| 123 |
/** input_type_ == graph_input_ |
| 124 |
This indicates that the square symmetric matrix or graph represents a graph |
| 125 |
in the sense that row/column IDs are vertices and non-zeroes represent |
| 126 |
edges. The vertices are to be partitioned. |
| 127 |
*/ |
| 128 |
static const int graph_input_ = 3; |
| 129 |
|
| 130 |
/** input_type_ == geometric_input_ |
| 131 |
This indicates that the Epetra_MultiVector represents geometric |
| 132 |
coordinates. The MultiVector should have 1, 2 or 3 vectors, |
| 133 |
representing 1, 2 or 3 dimensional coordinates. The coordinates |
| 134 |
are to be partitioned. |
| 135 |
*/ |
| 136 |
static const int geometric_input_ = 4; |
| 137 |
|
| 138 |
/** input_type_ == hgraph_graph_input_ |
| 139 |
This indicates that the Epetra_MultiVector represents a hypergraph |
| 140 |
and graph (see above). This is necessary for hierarchical partitioning |
| 141 |
with both hypergraph and graph methods. |
| 142 |
*/ |
| 143 |
static const int hgraph_graph_input_ = 5; |
| 144 |
|
| 145 |
/** input_type_ == hgraph_geom_input_ |
| 146 |
This indicates that the Epetra_MultiVector represents a hypergraph |
| 147 |
and graph (see above). This is necessary for hierarchical partitioning |
| 148 |
with both hypergraph and geometric methods. |
| 149 |
*/ |
| 150 |
static const int hgraph_geometric_input_ = 6; |
| 151 |
|
| 152 |
/** input_type_ == graph_geom_input_ |
| 153 |
This indicates that the Epetra_MultiVector represents a hypergraph |
| 154 |
and graph (see above). This is necessary for hierarchical partitioning |
| 155 |
with both graph and geometric methods. |
| 156 |
*/ |
| 157 |
static const int graph_geometric_input_ = 7; |
| 158 |
|
| 159 |
/** input_type_ == hgraph_graph_geom_input_ |
| 160 |
This indicates that the Epetra_MultiVector represents a hypergraph |
| 161 |
and graph (see above). This is necessary for hierarchical partitioning |
| 162 |
using hypergraph, graph, and geometric methods. |
| 163 |
*/ |
| 164 |
static const int hgraph_graph_geometric_input_ = 8; |
| 165 |
|
| 166 |
|
| 167 |
/** input_type_ == simple_input_ |
| 168 |
This is used to indicate that a simple partitiong method |
| 169 |
(block, cyclic, or random) will be used. |
| 170 |
*/ |
| 171 |
static const int simple_input_ = 9; |
| 172 |
|
| 173 |
|
| 174 |
/** input_type_ == unspecified_input_ |
| 175 |
This value is the "unset" state for the input_type_ instance variable. |
| 176 |
*/ |
| 177 |
|
| 178 |
static const int unspecified_input_ = 10; |
| 179 |
|
| 180 |
int input_type_; |
| 181 |
|
| 182 |
int numPartSizes; |
| 183 |
int *partGIDs; |
| 184 |
float *partSizes; |
| 185 |
|
| 186 |
protected: |
| 187 |
|
| 188 |
Teuchos::RCP<const Epetra_BlockMap> input_map_; |
| 189 |
Teuchos::RCP<const Epetra_CrsGraph> input_graph_; |
| 190 |
Teuchos::RCP<const Epetra_RowMatrix> input_matrix_; |
| 191 |
Teuchos::RCP<const Epetra_MultiVector> input_coords_; |
| 192 |
Teuchos::RCP<Isorropia::Epetra::CostDescriber> costs_; |
| 193 |
Teuchos::RCP<const Epetra_MultiVector> weights_; |
| 194 |
|
| 195 |
virtual int precompute(); |
| 196 |
|
| 197 |
virtual int postcompute() = 0; |
| 198 |
|
| 199 |
};//class Library |
| 200 |
|
| 201 |
}//namespace Epetra |
| 202 |
}//namespace Isorropia |
| 203 |
|
| 204 |
#endif //HAVE_EPETRA |
| 205 |
|
| 206 |
#endif |
| 207 |
|
| 208 |
|
| 209 |
#if defined(Isorropia_SHOW_DEPRECATED_WARNINGS) |
| 210 |
#ifdef __GNUC__ |
| 211 |
#warning "The Isorropia package is deprecated" |
| 212 |
#endif |
| 213 |
#endif |
| 214 |
|