IFPACK  Development
 All Classes Namespaces Files Functions Variables Enumerations Friends Pages
Ifpack_OverlappingPartitioner.h
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 #if defined(Ifpack_SHOW_DEPRECATED_WARNINGS)
47 #ifdef __GNUC__
48 #warning "The Ifpack package is deprecated"
49 #endif
50 #endif
51 
52 #include "Ifpack_ConfigDefs.h"
53 #include "Ifpack_Partitioner.h"
54 #include "Teuchos_ParameterList.hpp"
55 class Epetra_Comm;
56 class Ifpack_Graph;
57 class Epetra_Map;
58 class Epetra_BlockMap;
59 class Epetra_Import;
60 
61 /* \brief Ifpack_OverlappingPartitioner: A class to create overlapping
62  partitions of a local graph.
63 
64 Class Ifpack_OverlappingPartitioner enables the extension of
65 non-overlapping partitions to an arbitrary value of overlap.
66 Note that overlap refers to the overlap among \e local parts,
67 and not the overlap among the processes.
68 
69 Supported parameters are:
70 - \c "partitioner: local parts": the required number of parts;
71 - \c "partitioner: overlap": the required amount of overlap is set in
72  parameter. Default = 0 (integer).
73 - \c "partitioner: verbose": if \c true, information are reported on
74  cout. Nothing is reported otherwise.
75 
76 This class is a semi-virtual class, that contains the basic utilities
77 for derived classes Ifpack_LinearPartitioner, Ifpack_GreedyPartitioner,
78 Ifpack_METISPartitioner, and Ifpack_EquationPartitioner. Graphs in
79 input to one of these classes are supposed to contain no singletons.
80 Usually, this means that the graph is derived from an Epetra_RowMatrix,
81 that has been filtered using Ifpack_SingletonFilter.
82 
83 \author Marzio Sala, SNL 9214.
84 
85 \date Last update: Oct-04.
86 */
88 
89 public:
90 
93 
96 
98  int NumLocalParts() const
99  {
100  return(NumLocalParts_);
101  }
102 
104  int OverlappingLevel() const
105  {
106  return(OverlappingLevel_);
107  }
108 
110 
117  int operator() (int MyRow) const
118  {
119  if ((MyRow < 0) || (MyRow > NumMyRows()))
120  IFPACK_CHK_ERR(-1); // input value not valid
121 
122  return(Partition_[MyRow]);
123  }
124 
126  int operator() (int i, int j) const
127  {
128  if ((i < 0) || (i >= NumLocalParts()))
129  IFPACK_CHK_ERR(-1);
130 
131  if ((j < 0) || (j > (int)Parts_[i].size()))
132  IFPACK_CHK_ERR(-2);
133 
134  return(Parts_[i][j]);
135  }
136 
138  inline int NumRowsInPart(const int Part) const
139  {
140  return(Parts_[Part].size());
141  }
142 
143  int RowsInPart(const int Part, int* List) const
144  {
145  for (int i = 0 ; i < NumRowsInPart(Part) ; ++i)
146  List[i] = Parts_[Part][i];
147 
148  return(0);
149  }
150 
151  const int* NonOverlappingPartition() const
152  {
153  return(&Partition_[0]);
154  }
155 
157 
162  virtual int SetParameters(Teuchos::ParameterList& List);
163 
165 
169  virtual int SetPartitionParameters(Teuchos::ParameterList& List) = 0;
170 
172  virtual int Compute();
173 
175  virtual int ComputePartitions() = 0;
176 
178  virtual int ComputeOverlappingPartitions();
179 
181  bool IsComputed()
182  {
183  return(IsComputed_);
184  }
185 
187  virtual std::ostream& Print(std::ostream& os) const;
188 
189 protected:
190 
192  int NumMyRows() const;
194  int NumMyNonzeros() const;
195 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
196  int NumGlobalRows() const;
198 #endif
199  long long NumGlobalRows64() const;
201  int MaxNumEntries() const;
203  const Epetra_Comm& Comm() const;
207  std::vector<int> Partition_;
209  // partition i
210  std::vector<std::vector<int> > Parts_;
218  bool verbose_;
219 
220 }; // class Ifpack_Partitioner
221 
222 #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.
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:67
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)
int NumGlobalRows() const
Returns the number of global rows.