Isorropia: Partitioning, Load Balancing and more
Isorropia_EpetraOperator.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_EpetraOperator_hpp_
41 #define _Isorropia_EpetraOperator_hpp_
42 
43 #include <Isorropia_ConfigDefs.hpp>
44 #include <Teuchos_RCP.hpp>
45 #include <Teuchos_ParameterList.hpp>
46 
48 #include <Isorropia_Operator.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 
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 
105  Operator(Teuchos::RCP<const Epetra_CrsGraph> input_graph,
106  const Teuchos::ParameterList& paramlist, int base);
107 
108 
123  Operator(Teuchos::RCP<const Epetra_BlockMap> input_map,
124  const Teuchos::ParameterList& paramlist, int base);
125 
126 
127 
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 
171  Operator (Teuchos::RCP<const Epetra_CrsGraph> input_graph,
172  Teuchos::RCP<CostDescriber> costs,
173  const Teuchos::ParameterList& paramlist, int base);
174 
175 
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 
223  Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix,
224  const Teuchos::ParameterList& paramlist, int base);
225 
226 
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 
270  Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix,
271  Teuchos::RCP<CostDescriber> costs,
272  const Teuchos::ParameterList& paramlist, int base);
273 
274 
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 
324  Operator(Teuchos::RCP<const Epetra_MultiVector> coords,
325  const Teuchos::ParameterList& paramlist, int base);
326 
346  Operator(Teuchos::RCP<const Epetra_MultiVector> coords,
347  Teuchos::RCP<const Epetra_MultiVector> weights,
348  const Teuchos::ParameterList& paramlist, int base);
349 
351  virtual ~Operator();
352 
356  void setParameters(const Teuchos::ParameterList& paramlist);
357 
361  Teuchos::RCP<Isorropia::Epetra::CostDescriber> & getCosts() { return costs_; }
362 
363  virtual void compute(bool force_compute) = 0 ;
364 
367  bool alreadyComputed() const {
369  }
370 
371  int numProperties() const {
372  return (numberOfProperties_);
373  }
374 
375  int numLocalProperties() const {
376  return (localNumberOfProperties_);
377  }
378 
382  virtual const int& operator[](int myElem) const;
383 
386  virtual int numElemsWithProperty(int property) const;
387 
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);
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 
421  std::vector<int> imports_;
422  std::vector<int> properties_;
423 
425 
429 
430  Teuchos::RCP<Library> lib_;
431 
432  int base_;
433 
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 
Teuchos::RCP< Isorropia::Epetra::CostDescriber > & getCosts()
Get the cost object.
Definition: Isorropia_EpetraOperator.hpp:361
Operator(Teuchos::RCP< const Epetra_CrsGraph > input_graph, const Teuchos::ParameterList &paramlist, int base)
Constructor that accepts an Epetra_CrsGraph object.
int global_num_hg_edge_weights_
Definition: Isorropia_EpetraOperator.hpp:428
int global_num_vertex_weights_
Definition: Isorropia_EpetraOperator.hpp:426
virtual int extractPropertiesCopy(int len, int &size, int *array) const
Copy a part of the property array.
An implementation of the Partitioner interface that operates on Epetra matrices and linear systems...
Definition: Isorropia_EpetraOperator.hpp:72
std::vector< int > numberElemsByProperties_
Definition: Isorropia_EpetraOperator.hpp:408
int exportsSize_
Definition: Isorropia_EpetraOperator.hpp:420
Teuchos::RCP< Isorropia::Epetra::CostDescriber > costs_
Definition: Isorropia_EpetraOperator.hpp:415
Teuchos::ParameterList paramlist_
Definition: Isorropia_EpetraOperator.hpp:418
virtual ~Operator()
Destructor.
Teuchos::RCP< const Epetra_MultiVector > input_coords_
Definition: Isorropia_EpetraOperator.hpp:414
Teuchos::RCP< const Epetra_BlockMap > input_map_
Definition: Isorropia_EpetraOperator.hpp:411
std::vector< int > properties_
Definition: Isorropia_EpetraOperator.hpp:422
int localNumberOfProperties_
Definition: Isorropia_EpetraOperator.hpp:407
Teuchos::RCP< const Epetra_MultiVector > weights_
Definition: Isorropia_EpetraOperator.hpp:416
virtual void elemsWithProperty(int property, int *elementList, int len) const
Fill user-allocated list (of length len) with the global element ids to be located in the given parti...
int numLocalProperties() const
Return the number of different values used for &quot;properties&quot; for this process only.
Definition: Isorropia_EpetraOperator.hpp:375
bool alreadyComputed() const
Query whether compute_operation() has already been called.
Definition: Isorropia_EpetraOperator.hpp:367
int base_
Definition: Isorropia_EpetraOperator.hpp:432
Teuchos::RCP< const Epetra_CrsGraph > input_graph_
Definition: Isorropia_EpetraOperator.hpp:412
virtual int numElemsWithProperty(int property) const
Return the number of elements in a given partition.
void stringToUpper(std::string &s, int &changed, bool rmUnderscore=false)
int global_num_graph_edge_weights_
Definition: Isorropia_EpetraOperator.hpp:427
Interface (abstract base class) for computing a new partitioning/coloring/ ordering and exploiting th...
Definition: Isorropia_Operator.hpp:58
int numProperties() const
Return the number of different values used for &quot;properties&quot;.
Definition: Isorropia_EpetraOperator.hpp:371
virtual int extractPropertiesView(int &size, const int *&array) const
Give access of the property array that is owned by the current processor.
std::vector< int > imports_
Definition: Isorropia_EpetraOperator.hpp:421
Teuchos::RCP< Library > lib_
Definition: Isorropia_EpetraOperator.hpp:430
int numberOfProperties_
Definition: Isorropia_EpetraOperator.hpp:406
bool operation_already_computed_
Definition: Isorropia_EpetraOperator.hpp:424
void paramsToUpper(Teuchos::ParameterList &, int &changed, bool rmUnderscore=true)
virtual void compute(bool force_compute)=0
Method which does the work of computing a new partitioning/coloring/ordering, depending on the child ...
virtual const int & operator[](int myElem) const
Return the new partition ID for a given element that resided locally in the old operation.
void setParameters(const Teuchos::ParameterList &paramlist)
setParameters() is an internal method which handles the parameters from a Teuchos::ParameterList obje...
Teuchos::RCP< const Epetra_RowMatrix > input_matrix_
Definition: Isorropia_EpetraOperator.hpp:413