| 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_EpetraOperator_hpp_ |
| 41 |
#define _Isorropia_EpetraOperator_hpp_ |
| 42 |
|
| 43 |
#include <Isorropia_ConfigDefs.hpp> |
| 44 |
#include <Teuchos_RCP.hpp> |
| 45 |
#include <Teuchos_ParameterList.hpp> |
| 46 |
|
| 47 |
#include <Isorropia_EpetraCostDescriber.hpp> |
| 48 |
#include <Isorropia_Operator.hpp> |
| 49 |
#include <Isorropia_EpetraLibrary.hpp> |
| 50 |
|
| 51 |
#ifdef HAVE_EPETRA |
| 52 |
class Epetra_Map; |
| 53 |
class Epetra_BlockMap; |
| 54 |
class Epetra_Import; |
| 55 |
class Epetra_Vector; |
| 56 |
class Epetra_MultiVector; |
| 57 |
class Epetra_CrsGraph; |
| 58 |
class Epetra_CrsMatrix; |
| 59 |
class Epetra_RowMatrix; |
| 60 |
class Epetra_LinearProblem; |
| 61 |
|
| 62 |
namespace Isorropia { |
| 63 |
|
| 64 |
namespace Epetra { |
| 65 |
class CostDescriber; |
| 66 |
|
| 67 |
/** An implementation of the Partitioner interface that operates on |
| 68 |
Epetra matrices and linear systems. |
| 69 |
|
| 70 |
*/ |
| 71 |
|
| 72 |
class Operator : virtual public Isorropia::Operator { |
| 73 |
public: |
| 74 |
|
| 75 |
// Operator(Teuchos::RCP<const Epetra_CrsGraph> input_graph, int base); |
| 76 |
|
| 77 |
// Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix, int base); |
| 78 |
|
| 79 |
// Operator(Teuchos::RCP<const Epetra_MultiVector> input_coords, int base); |
| 80 |
|
| 81 |
// Operator(Teuchos::RCP<const Epetra_BlockMap> input_map, int base); |
| 82 |
|
| 83 |
// Operator(Teuchos::RCP<const Epetra_CrsGraph> input_graph, |
| 84 |
// Teuchos::RCP<const Epetra_MultiVector> input_coords, int base); |
| 85 |
|
| 86 |
// Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix, |
| 87 |
// Teuchos::RCP<const Epetra_MultiVector> input_coords, int base); |
| 88 |
|
| 89 |
|
| 90 |
/** Constructor that accepts an Epetra_CrsGraph object |
| 91 |
|
| 92 |
\param input_graph Matrix-graph object for which a new operation |
| 93 |
is to be computed. |
| 94 |
|
| 95 |
\param[in] paramlist Teuchos::ParameterList which will be copied to an |
| 96 |
internal ParameterList attribute. |
| 97 |
|
| 98 |
\param[in] base index base |
| 99 |
|
| 100 |
If the ParameterList object contains a sublist named "Zoltan", then |
| 101 |
the Zoltan library is used to perform the operation. Also, any |
| 102 |
parameters in the "Zoltan" sublist will be relayed directly to Zoltan. |
| 103 |
*/ |
| 104 |
|
| 105 |
Operator(Teuchos::RCP<const Epetra_CrsGraph> input_graph, |
| 106 |
const Teuchos::ParameterList& paramlist, int base); |
| 107 |
|
| 108 |
|
| 109 |
/** Constructor that accepts an Epetra_BlockMap object |
| 110 |
|
| 111 |
\param[in] input_map BlockMap object for which a new operation |
| 112 |
is to be computed. |
| 113 |
|
| 114 |
\param[in] paramlist Teuchos::ParameterList which will be copied to an |
| 115 |
internal ParameterList attribute. |
| 116 |
|
| 117 |
\param[in] base |
| 118 |
If the ParameterList object contains a sublist named "Zoltan", then |
| 119 |
the Zoltan library is used to perform the operation. Also, any |
| 120 |
parameters in the "Zoltan" sublist will be relayed directly to Zoltan. |
| 121 |
*/ |
| 122 |
|
| 123 |
Operator(Teuchos::RCP<const Epetra_BlockMap> input_map, |
| 124 |
const Teuchos::ParameterList& paramlist, int base); |
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
/** Constructor that accepts an Epetra_CrsGraph object |
| 129 |
and an Epetra_MultiVector object of coordinates |
| 130 |
|
| 131 |
\param input_graph Matrix-graph object for which a new operation |
| 132 |
is to be computed. |
| 133 |
|
| 134 |
\param[in] input_coords The input geometric coordinates (represented in a |
| 135 |
multivector) |
| 136 |
|
| 137 |
\param[in] paramlist Teuchos::ParameterList which will be copied to an |
| 138 |
internal ParameterList attribute. |
| 139 |
|
| 140 |
\param[in] base |
| 141 |
|
| 142 |
If the ParameterList object contains a sublist named "Zoltan", then |
| 143 |
the Zoltan library is used to perform the operation. Also, any |
| 144 |
parameters in the "Zoltan" sublist will be relayed directly to Zoltan. |
| 145 |
*/ |
| 146 |
|
| 147 |
Operator(Teuchos::RCP<const Epetra_CrsGraph> input_graph, |
| 148 |
Teuchos::RCP<const Epetra_MultiVector> input_coords, |
| 149 |
const Teuchos::ParameterList& paramlist, int base); |
| 150 |
|
| 151 |
|
| 152 |
/** Constructor that accepts an Epetra_CrsGraph object, a CostDescriber, |
| 153 |
an Epetra_MultiVector object of coordinates, and an |
| 154 |
Epetra_MultiVector object of coordinate weights. |
| 155 |
|
| 156 |
\param input_graph Matrix-graph object for which a new operation |
| 157 |
is to be computed. |
| 158 |
|
| 159 |
\param costs CostDescriber object which allows for user-specified |
| 160 |
weights |
| 161 |
|
| 162 |
\param paramlist Teuchos::ParameterList which will be copied to an |
| 163 |
internal ParameterList attribute. |
| 164 |
|
| 165 |
\param[in] base |
| 166 |
|
| 167 |
If the ParameterList object contains a sublist named "Zoltan", then |
| 168 |
the Zoltan library is used to perform the operation. Also, any |
| 169 |
parameters in the "Zoltan" sublist will be relayed directly to Zoltan. |
| 170 |
*/ |
| 171 |
Operator (Teuchos::RCP<const Epetra_CrsGraph> input_graph, |
| 172 |
Teuchos::RCP<CostDescriber> costs, |
| 173 |
const Teuchos::ParameterList& paramlist, int base); |
| 174 |
|
| 175 |
|
| 176 |
/** Constructor that accepts an Epetra_CrsGraph object, a CostDescriber, |
| 177 |
an Epetra_MultiVector object of coordinates, and an |
| 178 |
Epetra_MultiVector object of coordinate weights. |
| 179 |
|
| 180 |
\param input_graph Matrix-graph object for which a new operation |
| 181 |
is to be computed. |
| 182 |
|
| 183 |
\param costs CostDescriber object which allows for user-specified |
| 184 |
weights |
| 185 |
|
| 186 |
\param coords The input geometric coordinates (represented in a |
| 187 |
multivector) |
| 188 |
|
| 189 |
\param weights A one or more dimensional weight for each of the |
| 190 |
The input geometric coordinates |
| 191 |
|
| 192 |
\param[in] paramlist Teuchos::ParameterList which will be copied to an |
| 193 |
internal ParameterList attribute. |
| 194 |
|
| 195 |
\param[in] base |
| 196 |
|
| 197 |
If the ParameterList object contains a sublist named "Zoltan", then |
| 198 |
the Zoltan library is used to perform the operation. Also, any |
| 199 |
parameters in the "Zoltan" sublist will be relayed directly to Zoltan. |
| 200 |
*/ |
| 201 |
Operator (Teuchos::RCP<const Epetra_CrsGraph> input_graph, |
| 202 |
Teuchos::RCP<CostDescriber> costs, |
| 203 |
Teuchos::RCP<const Epetra_MultiVector> coords, |
| 204 |
Teuchos::RCP<const Epetra_MultiVector> weights, |
| 205 |
const Teuchos::ParameterList& paramlist, int base); |
| 206 |
|
| 207 |
|
| 208 |
/** |
| 209 |
Constructor that accepts an Epetra_RowMatrix object. |
| 210 |
|
| 211 |
\param input_matrix Matrix object for which a new operation is |
| 212 |
to be computed. |
| 213 |
|
| 214 |
\param[in] paramlist Teuchos::ParameterList which will be copied to an |
| 215 |
internal ParameterList attribute. |
| 216 |
|
| 217 |
\param[in] base Index base |
| 218 |
|
| 219 |
If the ParameterList object contains a sublist named "Zoltan", then |
| 220 |
the Zoltan library is used to perform the operation. Also, any |
| 221 |
parameters in the "Zoltan" sublist will be relayed directly to Zoltan. |
| 222 |
*/ |
| 223 |
Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix, |
| 224 |
const Teuchos::ParameterList& paramlist, int base); |
| 225 |
|
| 226 |
|
| 227 |
/** |
| 228 |
Constructor that accepts an Epetra_RowMatrix object and an |
| 229 |
Epetra_MultiVector object of coordinates. |
| 230 |
|
| 231 |
\param input_matrix Matrix object for which a new operation is |
| 232 |
to be computed. |
| 233 |
|
| 234 |
\param coords The input geometric coordinates (represented in a |
| 235 |
multivector) |
| 236 |
|
| 237 |
\param[in] paramlist Teuchos::ParameterList which will be copied to an |
| 238 |
internal ParameterList attribute. |
| 239 |
|
| 240 |
\param[in] base |
| 241 |
|
| 242 |
If the ParameterList object contains a sublist named "Zoltan", then |
| 243 |
the Zoltan library is used to perform the operation. Also, any |
| 244 |
parameters in the "Zoltan" sublist will be relayed directly to Zoltan. |
| 245 |
*/ |
| 246 |
Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix, |
| 247 |
Teuchos::RCP<const Epetra_MultiVector> coords, |
| 248 |
const Teuchos::ParameterList& paramlist, int base); |
| 249 |
|
| 250 |
|
| 251 |
/** |
| 252 |
Constructor that accepts an Epetra_RowMatrix object and a |
| 253 |
CostDescriber. |
| 254 |
|
| 255 |
\param input_matrix Matrix object for which a new operation is |
| 256 |
to be computed. |
| 257 |
|
| 258 |
\param costs CostDescriber object which allows for user-specified |
| 259 |
weights |
| 260 |
|
| 261 |
\param[in] paramlist Teuchos::ParameterList which will be copied to an |
| 262 |
internal ParameterList attribute. |
| 263 |
|
| 264 |
\param[in] base |
| 265 |
|
| 266 |
If the ParameterList object contains a sublist named "Zoltan", then |
| 267 |
the Zoltan library is used to perform the operation. Also, any |
| 268 |
parameters in the "Zoltan" sublist will be relayed directly to Zoltan. |
| 269 |
*/ |
| 270 |
Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix, |
| 271 |
Teuchos::RCP<CostDescriber> costs, |
| 272 |
const Teuchos::ParameterList& paramlist, int base); |
| 273 |
|
| 274 |
|
| 275 |
/** |
| 276 |
Constructor that accepts an Epetra_RowMatrix object, a |
| 277 |
CostDescriber, an Epetra_MultiVector object of coordinates, |
| 278 |
and an Epetra_MultiVector object of coordinate weights. |
| 279 |
|
| 280 |
\param input_matrix Matrix object for which a new operation is |
| 281 |
to be computed. |
| 282 |
|
| 283 |
\param costs CostDescriber object which allows for user-specified |
| 284 |
weights |
| 285 |
|
| 286 |
\param coords The input geometric coordinates (represented in a |
| 287 |
multivector) |
| 288 |
|
| 289 |
\param weights A one or more dimensional weight for each of the |
| 290 |
The input geometric coordinates |
| 291 |
|
| 292 |
\param[in] paramlist Teuchos::ParameterList which will be copied to an |
| 293 |
internal ParameterList attribute. |
| 294 |
|
| 295 |
\param[in] base |
| 296 |
|
| 297 |
If the ParameterList object contains a sublist named "Zoltan", then |
| 298 |
the Zoltan library is used to perform the operation. Also, any |
| 299 |
parameters in the "Zoltan" sublist will be relayed directly to Zoltan. |
| 300 |
*/ |
| 301 |
Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix, |
| 302 |
Teuchos::RCP<CostDescriber> costs, |
| 303 |
Teuchos::RCP<const Epetra_MultiVector> coords, |
| 304 |
Teuchos::RCP<const Epetra_MultiVector> weights, |
| 305 |
const Teuchos::ParameterList& paramlist, int base); |
| 306 |
|
| 307 |
|
| 308 |
/** |
| 309 |
Constructor that accepts an Epetra_MultiVector object and a |
| 310 |
ParameterList |
| 311 |
|
| 312 |
\param coords The input geometric coordinates (represented in a |
| 313 |
multivector) |
| 314 |
|
| 315 |
\param[in] paramlist Teuchos::ParameterList which will be copied to an |
| 316 |
internal ParameterList attribute. |
| 317 |
|
| 318 |
\param[in] base index base |
| 319 |
|
| 320 |
If the ParameterList object contains a sublist named "Zoltan", then |
| 321 |
the Zoltan library is used to perform the operation. Also, any |
| 322 |
parameters in the "Zoltan" sublist will be relayed directly to Zoltan. |
| 323 |
*/ |
| 324 |
Operator(Teuchos::RCP<const Epetra_MultiVector> coords, |
| 325 |
const Teuchos::ParameterList& paramlist, int base); |
| 326 |
|
| 327 |
/** |
| 328 |
Constructor that accepts an Epetra_MultiVector object and a |
| 329 |
ParameterList |
| 330 |
|
| 331 |
\param coords The input geometric coordinates (represented in a |
| 332 |
multivector) |
| 333 |
|
| 334 |
\param weights A one or more dimensional weight for each of the |
| 335 |
The input geometric coordinates |
| 336 |
|
| 337 |
\param[in] paramlist Teuchos::ParameterList which will be copied to an |
| 338 |
internal ParameterList attribute. |
| 339 |
|
| 340 |
\param[in] base index base |
| 341 |
|
| 342 |
If the ParameterList object contains a sublist named "Zoltan", then |
| 343 |
the Zoltan library is used to perform the operation. Also, any |
| 344 |
parameters in the "Zoltan" sublist will be relayed directly to Zoltan. |
| 345 |
*/ |
| 346 |
Operator(Teuchos::RCP<const Epetra_MultiVector> coords, |
| 347 |
Teuchos::RCP<const Epetra_MultiVector> weights, |
| 348 |
const Teuchos::ParameterList& paramlist, int base); |
| 349 |
|
| 350 |
/** Destructor */ |
| 351 |
virtual ~Operator(); |
| 352 |
|
| 353 |
/** setParameters() is an internal method which handles |
| 354 |
the parameters from a Teuchos::ParameterList object. |
| 355 |
*/ |
| 356 |
void setParameters(const Teuchos::ParameterList& paramlist); |
| 357 |
|
| 358 |
/** Get the cost object |
| 359 |
*/ |
| 360 |
|
| 361 |
Teuchos::RCP<Isorropia::Epetra::CostDescriber> & getCosts() { return costs_; } |
| 362 |
|
| 363 |
virtual void compute(bool force_compute) = 0 ; |
| 364 |
|
| 365 |
/** Query whether compute_operation() has already been called. |
| 366 |
*/ |
| 367 |
bool alreadyComputed() const { |
| 368 |
return operation_already_computed_; |
| 369 |
} |
| 370 |
|
| 371 |
int numProperties() const { |
| 372 |
return (numberOfProperties_); |
| 373 |
} |
| 374 |
|
| 375 |
int numLocalProperties() const { |
| 376 |
return (localNumberOfProperties_); |
| 377 |
} |
| 378 |
|
| 379 |
/** Return the new partition ID for a given element that |
| 380 |
resided locally in the old operation. |
| 381 |
*/ |
| 382 |
virtual const int& operator[](int myElem) const; |
| 383 |
|
| 384 |
/** Return the number of elements in a given partition. |
| 385 |
*/ |
| 386 |
virtual int numElemsWithProperty(int property) const; |
| 387 |
|
| 388 |
/** Fill user-allocated list (of length len) with the |
| 389 |
global element ids to be located in the given partition. |
| 390 |
*/ |
| 391 |
virtual void elemsWithProperty(int property, |
| 392 |
int* elementList, |
| 393 |
int len) const; |
| 394 |
|
| 395 |
virtual int extractPropertiesCopy(int len, |
| 396 |
int& size, |
| 397 |
int* array) const ; |
| 398 |
|
| 399 |
virtual int extractPropertiesView(int& size, |
| 400 |
const int*& array) const; |
| 401 |
|
| 402 |
private: |
| 403 |
|
| 404 |
void paramsToUpper(Teuchos::ParameterList &, int &changed, bool rmUnderscore=true); |
| 405 |
void stringToUpper(std::string &s, int &changed, bool rmUnderscore=false); |
| 406 |
int numberOfProperties_; |
| 407 |
int localNumberOfProperties_; |
| 408 |
std::vector<int> numberElemsByProperties_; |
| 409 |
|
| 410 |
protected: |
| 411 |
Teuchos::RCP<const Epetra_BlockMap> input_map_; |
| 412 |
Teuchos::RCP<const Epetra_CrsGraph> input_graph_; |
| 413 |
Teuchos::RCP<const Epetra_RowMatrix> input_matrix_; |
| 414 |
Teuchos::RCP<const Epetra_MultiVector> input_coords_; |
| 415 |
Teuchos::RCP<Isorropia::Epetra::CostDescriber> costs_; |
| 416 |
Teuchos::RCP<const Epetra_MultiVector> weights_; |
| 417 |
|
| 418 |
Teuchos::ParameterList paramlist_; |
| 419 |
|
| 420 |
int exportsSize_; |
| 421 |
std::vector<int> imports_; |
| 422 |
std::vector<int> properties_; |
| 423 |
|
| 424 |
bool operation_already_computed_; |
| 425 |
|
| 426 |
int global_num_vertex_weights_; |
| 427 |
int global_num_graph_edge_weights_; |
| 428 |
int global_num_hg_edge_weights_; |
| 429 |
|
| 430 |
Teuchos::RCP<Library> lib_; |
| 431 |
|
| 432 |
int base_; |
| 433 |
|
| 434 |
void computeNumberOfProperties(); |
| 435 |
};//class Operator |
| 436 |
|
| 437 |
}//namespace Epetra |
| 438 |
}//namespace Isorropia |
| 439 |
|
| 440 |
#endif //HAVE_EPETRA |
| 441 |
|
| 442 |
#endif |
| 443 |
|
| 444 |
|
| 445 |
#if defined(Isorropia_SHOW_DEPRECATED_WARNINGS) |
| 446 |
#ifdef __GNUC__ |
| 447 |
#warning "The Isorropia package is deprecated" |
| 448 |
#endif |
| 449 |
#endif |
| 450 |
|