Isorropia: Partitioning, Load Balancing and more
Isorropia_TpetraOperator.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_TpetraOperator_hpp_
41 #define _Isorropia_TpetraOperator_hpp_
42 
43 #include <Isorropia_ConfigDefs.hpp>
44 #include <Teuchos_RCP.hpp>
45 #include <Teuchos_ParameterList.hpp>
46 
47 #include <Isorropia_Operator.hpp>
48 
49 #ifdef HAVE_ISORROPIA_TPETRA
52 #include <Tpetra_CrsGraph_decl.hpp>
53 
54 namespace Isorropia {
55 
56 namespace Tpetra {
57 
58 
64 template <class Node = ::Tpetra::Map<int,int>::node_type>
65 class Operator : virtual public Isorropia::Operator
66 {
67 public:
68 
84  Operator(Teuchos::RCP<const ::Tpetra::CrsGraph<int,int,Node> > input_graph,
85  const Teuchos::ParameterList& paramlist, int base);
86 
87 
88 
90  virtual ~Operator();
91 
95  void setParameters(const Teuchos::ParameterList& paramlist);
96 
97  virtual void compute(bool force_compute) = 0 ;
98 
101  bool alreadyComputed() const
102  {
103  return operation_already_computed_;
104  }
105 
106  int numProperties() const {
107  return (numberOfProperties_);
108  }
109 
110  int numLocalProperties() const {
111  return (localNumberOfProperties_);
112  }
113 
117  virtual const int& operator[](int myElem) const;
118 
121  virtual int numElemsWithProperty(int property) const;
122 
126  virtual void elemsWithProperty(int property,
127  int* elementList,
128  int len) const;
129 
130  virtual int extractPropertiesCopy(int len,
131  int& size,
132  int* array) const ;
133 
134  virtual int extractPropertiesView(int& size,
135  const int*& array) const;
136 
137 private:
138 
139  void paramsToUpper(Teuchos::ParameterList &, int &changed, bool rmUnderscore=true);
140  void stringToUpper(std::string &s, int &changed, bool rmUnderscore=false);
141  int numberOfProperties_;
142  int localNumberOfProperties_;
143  std::vector<int> numberElemsByProperties_;
144 
145 protected:
146  Teuchos::RCP<const ::Tpetra::CrsGraph<int,int,Node> > input_graph_;
147  Teuchos::RCP<const ::Tpetra::Map<int,int,Node> > input_map_;
148 
149  Teuchos::RCP<const ::Tpetra::RowMatrix<double,int,int,Node> > input_matrix_;
150  Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > input_coords_;
151  Teuchos::RCP<Isorropia::Tpetra::CostDescriber<Node> > costs_;
152  Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > weights_;
153 
154 
155  Teuchos::ParameterList paramlist_;
156 
157  int exportsSize_;
158  std::vector<int> imports_;
159  std::vector<int> properties_;
160 
161  bool operation_already_computed_;
162 
163  int global_num_vertex_weights_;
164  int global_num_graph_edge_weights_;
165  int global_num_hg_edge_weights_;
166 
167  Teuchos::RCP<Library<Node> > lib_;
168 
169  int base_;
170 
171  void computeNumberOfProperties();
172 };//class Operator
173 
174 }//namespace Epetra
175 }//namespace Isorropia
176 
177 #endif //HAVE_EPETRA
178 
179 #endif
180 
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 computing a new partitioning/coloring/ ordering and exploiting th...
Definition: Isorropia_Operator.hpp:58