Ifpack Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Ifpack_OverlappingPartitioner.h
Go to the documentation of this file.
1 /*@HEADER
2 // ***********************************************************************
3 //
4 // Ifpack: Object-Oriented Algebraic Preconditioner Package
5 // Copyright (2002) 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 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 //@HEADER
41 */
42 
43 #ifndef IFPACK_OVERLAPPINGPARTITIONER_H
44 #define IFPACK_OVERLAPPINGPARTITIONER_H
45 
46 #include "Ifpack_ConfigDefs.h"
47 #include "Ifpack_Partitioner.h"
48 #include "Teuchos_ParameterList.hpp"
49 class Epetra_Comm;
50 class Ifpack_Graph;
51 class Epetra_Map;
52 class Epetra_BlockMap;
53 class Epetra_Import;
54 
55 /* \brief Ifpack_OverlappingPartitioner: A class to create overlapping
56  partitions of a local graph.
57 
58 Class Ifpack_OverlappingPartitioner enables the extension of
59 non-overlapping partitions to an arbitrary value of overlap.
60 Note that overlap refers to the overlap among \e local parts,
61 and not the overlap among the processes.
62 
63 Supported parameters are:
64 - \c "partitioner: local parts": the required number of parts;
65 - \c "partitioner: overlap": the required amount of overlap is set in
66  parameter. Default = 0 (integer).
67 - \c "partitioner: verbose": if \c true, information are reported on
68  cout. Nothing is reported otherwise.
69 
70 This class is a semi-virtual class, that contains the basic utilities
71 for derived classes Ifpack_LinearPartitioner, Ifpack_GreedyPartitioner,
72 Ifpack_METISPartitioner, and Ifpack_EquationPartitioner. Graphs in
73 input to one of these classes are supposed to contain no singletons.
74 Usually, this means that the graph is derived from an Epetra_RowMatrix,
75 that has been filtered using Ifpack_SingletonFilter.
76 
77 \author Marzio Sala, SNL 9214.
78 
79 \date Last update: Oct-04.
80 */
82 
83 public:
84 
87 
90 
92  int NumLocalParts() const
93  {
94  return(NumLocalParts_);
95  }
96 
98  int OverlappingLevel() const
99  {
100  return(OverlappingLevel_);
101  }
102 
104 
111  int operator() (int MyRow) const
112  {
113  if ((MyRow < 0) || (MyRow > NumMyRows()))
114  IFPACK_CHK_ERR(-1); // input value not valid
115 
116  return(Partition_[MyRow]);
117  }
118 
120  int operator() (int i, int j) const
121  {
122  if ((i < 0) || (i >= NumLocalParts()))
123  IFPACK_CHK_ERR(-1);
124 
125  if ((j < 0) || (j > (int)Parts_[i].size()))
126  IFPACK_CHK_ERR(-2);
127 
128  return(Parts_[i][j]);
129  }
130 
132  inline int NumRowsInPart(const int Part) const
133  {
134  return(Parts_[Part].size());
135  }
136 
137  int RowsInPart(const int Part, int* List) const
138  {
139  for (int i = 0 ; i < NumRowsInPart(Part) ; ++i)
140  List[i] = Parts_[Part][i];
141 
142  return(0);
143  }
144 
145  const int* NonOverlappingPartition() const
146  {
147  return(&Partition_[0]);
148  }
149 
151 
156  virtual int SetParameters(Teuchos::ParameterList& List);
157 
159 
163  virtual int SetPartitionParameters(Teuchos::ParameterList& List) = 0;
164 
166  virtual int Compute();
167 
169  virtual int ComputePartitions() = 0;
170 
172  virtual int ComputeOverlappingPartitions();
173 
175  bool IsComputed()
176  {
177  return(IsComputed_);
178  }
179 
181  virtual std::ostream& Print(std::ostream& os) const;
182 
183 protected:
184 
186  int NumMyRows() const;
188  int NumMyNonzeros() const;
189 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
190  int NumGlobalRows() const;
192 #endif
193  long long NumGlobalRows64() const;
195  int MaxNumEntries() const;
197  const Epetra_Comm& Comm() const;
201  std::vector<int> Partition_;
203  // partition i
204  std::vector<std::vector<int> > Parts_;
212  bool verbose_;
213 
214 }; // class Ifpack_Partitioner
215 
216 #endif // IFPACK_OVERLAPPINGPARTITIONER_H
virtual int SetParameters(Teuchos::ParameterList &List)
Sets all the parameters for the partitioner.
virtual int Compute()
Computes the partitions. Returns 0 if successful.
bool IsComputed()
Returns true if partitions have been computed successfully.
virtual int SetPartitionParameters(Teuchos::ParameterList &List)=0
Sets all the parameters for the partitioner.
int MaxNumEntries() const
Returns the max number of local entries in a row.
Ifpack_OverlappingPartitioner(const Ifpack_Graph *Graph)
Constructor.
int NumMyNonzeros() const
Returns the number of local nonzero elements.
int operator()(int MyRow) const
Returns the local non-overlapping partition ID of the specified row.
int NumMyRows() const
Returns the number of local rows.
std::vector< int > Partition_
Partition_[i] contains the ID of non-overlapping part it belongs to.
int RowsInPart(const int Part, int *List) const
Copies into List the rows in the (overlapping) partition Part.
Ifpack_Partitioner: A class to decompose local Ifpack_Graph&#39;s.
const int * NonOverlappingPartition() const
Returns a pointer to the integer vector containing the non-overlapping partition ID of each local row...
virtual int ComputeOverlappingPartitions()
Computes the partitions. Returns 0 if successful.
bool IsComputed_
If true, the graph has been successfully partitioned.
int OverlappingLevel() const
Returns the overlapping level.
int NumRowsInPart(const int Part) const
Returns the number of rows contained in specified partition.
bool verbose_
If true, information are reported on cout.
adjacency_list< vecS, vecS, undirectedS, no_property, property< edge_weight_t, double > > Graph
const Ifpack_Graph * Graph_
Reference to the graph to be partitioned.
int NumLocalParts_
Number of local subgraphs.
virtual int ComputePartitions()=0
Computes the partitions. Returns 0 if successful.
int NumLocalParts() const
Returns the number of computed local partitions.
Ifpack_Graph: a pure virtual class that defines graphs for IFPACK.
Definition: Ifpack_Graph.h:61
virtual std::ostream & Print(std::ostream &os) const
Prints basic information on iostream. This function is used by operator&lt;&lt;.
const Epetra_Comm & Comm() const
Returns the communicator object of Graph.
std::vector< std::vector< int > > Parts_
Parts_[i][j] is the ID of the j-th row contained in the (overlapping)
#define IFPACK_CHK_ERR(ifpack_err)
int NumGlobalRows() const
Returns the number of global rows.