IFPACK Development
Ifpack_OverlappingPartitioner.h
00001 /*@HEADER
00002 // ***********************************************************************
00003 //
00004 //       Ifpack: Object-Oriented Algebraic Preconditioner Package
00005 //                 Copyright (2002) Sandia Corporation
00006 //
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00038 //
00039 // ***********************************************************************
00040 //@HEADER
00041 */
00042 
00043 #ifndef IFPACK_OVERLAPPINGPARTITIONER_H
00044 #define IFPACK_OVERLAPPINGPARTITIONER_H
00045 
00046 #include "Ifpack_ConfigDefs.h"
00047 #include "Ifpack_Partitioner.h"
00048 #include "Teuchos_ParameterList.hpp"
00049 class Epetra_Comm;
00050 class Ifpack_Graph;
00051 class Epetra_Map;
00052 class Epetra_BlockMap;
00053 class Epetra_Import;
00054 
00055 /* \brief Ifpack_OverlappingPartitioner: A class to create overlapping
00056     partitions of a local graph.
00057 
00058 Class Ifpack_OverlappingPartitioner enables the extension of 
00059 non-overlapping partitions to an arbitrary value of overlap.
00060 Note that overlap refers to the overlap among \e local parts,
00061 and not the overlap among the processes.
00062 
00063 Supported parameters are:
00064 - \c "partitioner: local parts": the required number of parts;
00065 - \c "partitioner: overlap": the required amount of overlap is set in 
00066   parameter. Default = 0 (integer).
00067 - \c "partitioner: verbose": if \c true, information are reported on
00068   cout. Nothing is reported otherwise.
00069 
00070 This class is a semi-virtual class, that contains the basic utilities
00071 for derived classes Ifpack_LinearPartitioner, Ifpack_GreedyPartitioner,
00072 Ifpack_METISPartitioner, and Ifpack_EquationPartitioner. Graphs in
00073 input to one of these classes are supposed to contain no singletons.
00074 Usually, this means that the graph is derived from an Epetra_RowMatrix,
00075 that has been filtered using Ifpack_SingletonFilter.
00076 
00077 \author Marzio Sala, SNL 9214.
00078 
00079 \date Last update: Oct-04.
00080 */  
00081 class Ifpack_OverlappingPartitioner : public Ifpack_Partitioner {
00082 
00083 public:
00084 
00086   Ifpack_OverlappingPartitioner(const Ifpack_Graph* Graph);
00087 
00089   virtual ~Ifpack_OverlappingPartitioner();
00090 
00092   int NumLocalParts() const 
00093   {
00094     return(NumLocalParts_);
00095   }
00096 
00098   int OverlappingLevel() const 
00099   {
00100     return(OverlappingLevel_);
00101   }
00102 
00104 
00111   int operator() (int MyRow) const
00112   {
00113     if ((MyRow < 0) || (MyRow > NumMyRows()))
00114       IFPACK_CHK_ERR(-1); // input value not valid
00115 
00116     return(Partition_[MyRow]);
00117   }
00118 
00120   int operator() (int i, int j) const
00121   {
00122     if ((i < 0) || (i >= NumLocalParts()))
00123       IFPACK_CHK_ERR(-1);
00124 
00125     if ((j < 0) || (j > (int)Parts_[i].size()))
00126       IFPACK_CHK_ERR(-2);
00127 
00128     return(Parts_[i][j]);
00129   }
00130 
00132   inline int NumRowsInPart(const int Part) const
00133   {
00134     return(Parts_[Part].size());
00135   }
00136     
00137   int RowsInPart(const int Part, int* List) const
00138   {
00139     for (int i = 0 ; i < NumRowsInPart(Part) ; ++i)
00140       List[i] = Parts_[Part][i];
00141 
00142     return(0);
00143   }
00144   
00145   const int* NonOverlappingPartition() const
00146   {
00147     return(&Partition_[0]);
00148   }
00149 
00151 
00156   virtual int SetParameters(Teuchos::ParameterList& List);
00157 
00159 
00163   virtual int SetPartitionParameters(Teuchos::ParameterList& List) = 0;
00164 
00166   virtual int Compute();
00167 
00169   virtual int ComputePartitions() = 0;
00170 
00172   virtual int ComputeOverlappingPartitions();
00173   
00175   bool IsComputed()
00176   {
00177     return(IsComputed_);
00178   }
00179 
00181   virtual ostream& Print(std::ostream& os) const;
00182 
00183 protected:
00184    
00186   int NumMyRows() const;
00188   int NumMyNonzeros() const;
00189 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00190 
00191   int NumGlobalRows() const;
00192 #endif
00193   long long NumGlobalRows64() const;
00195   int MaxNumEntries() const;
00197   const Epetra_Comm& Comm() const;
00199   int NumLocalParts_;
00201   std::vector<int> Partition_; 
00203   // partition i
00204   std::vector<std::vector<int> > Parts_;
00206   const Ifpack_Graph* Graph_;
00208   int OverlappingLevel_;
00210   bool IsComputed_;
00212   bool verbose_;
00213 
00214 }; // class Ifpack_Partitioner
00215 
00216 #endif // IFPACK_OVERLAPPINGPARTITIONER_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends