IFPACK Development
Ifpack_SingletonFilter.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_SINGLETONFILTER_H
00044 #define IFPACK_SINGLETONFILTER_H
00045 
00046 #include "Ifpack_ConfigDefs.h"
00047 #include "Epetra_RowMatrix.h"
00048 #include "Teuchos_RefCountPtr.hpp"
00049 
00050 class Epetra_Comm;
00051 class Epetra_Map;
00052 class Epetra_MultiVector;
00053 class Epetra_Import;
00054 class Epetra_BlockMap;
00055 
00057 //
00058 class Ifpack_SingletonFilter : public virtual Epetra_RowMatrix {
00059 
00060 public:
00062   Ifpack_SingletonFilter(const Teuchos::RefCountPtr<Epetra_RowMatrix>& Matrix);
00063 
00065   virtual ~Ifpack_SingletonFilter() {};
00066 
00068   virtual inline int NumMyRowEntries(int MyRow, int & NumEntries) const
00069   {
00070     return(NumEntries_[MyRow]);
00071   }
00072 
00074   virtual int MaxNumEntries() const
00075   {
00076     return(MaxNumEntries_);
00077   }
00078 
00079   virtual int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
00080 
00081   virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
00082 
00083   virtual int Multiply(bool TransA, const Epetra_MultiVector& X, 
00084                Epetra_MultiVector& Y) const;
00085 
00086   virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, 
00087             const Epetra_MultiVector& X,
00088             Epetra_MultiVector& Y) const;
00089 
00090   virtual int Apply(const Epetra_MultiVector& X,
00091             Epetra_MultiVector& Y) const;
00092 
00093   virtual int ApplyInverse(const Epetra_MultiVector& X,
00094                Epetra_MultiVector& Y) const;
00095 
00096   virtual int InvRowSums(Epetra_Vector& x) const
00097   {
00098     return(-98); // NOT IMPLEMENTED
00099   }
00100 
00101   virtual int LeftScale(const Epetra_Vector& x)
00102   {
00103     return(-98); // NOT IMPLEMENTED
00104   }
00105 
00106   virtual int InvColSums(Epetra_Vector& x) const
00107   {
00108     return(-98); // NOT IMPLEMENTED
00109   }
00110 
00111   virtual int RightScale(const Epetra_Vector& x) 
00112   {
00113     return(-98); // NOT IMPLEMENTED
00114   }
00115 
00116   virtual bool Filled() const
00117   {
00118     return(A_->Filled());
00119   }
00120 
00121   virtual double NormInf() const
00122   {
00123     return(-1.0);
00124   }
00125 
00126   virtual double NormOne() const
00127   {
00128     return(-1.0);
00129   }
00130 
00131 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00132   virtual int NumGlobalNonzeros() const
00133   {
00134     return(NumNonzeros_);
00135   }
00136 
00137   virtual int NumGlobalRows() const
00138   {
00139     return(NumRows_);
00140   }
00141 
00142   virtual int NumGlobalCols() const
00143   {
00144     return(NumRows_);
00145   }
00146 
00147   virtual int NumGlobalDiagonals() const
00148   {
00149     return(NumRows_);
00150   }
00151 #endif
00152 
00153   virtual long long NumGlobalNonzeros64() const
00154   {
00155     return(NumNonzeros_);
00156   }
00157 
00158   virtual long long NumGlobalRows64() const
00159   {
00160     return(NumRows_);
00161   }
00162 
00163   virtual long long NumGlobalCols64() const
00164   {
00165     return(NumRows_);
00166   }
00167 
00168   virtual long long NumGlobalDiagonals64() const
00169   {
00170     return(NumRows_);
00171   }
00172 
00173   virtual int NumMyNonzeros() const
00174   {
00175     return(NumNonzeros_);
00176   }
00177 
00178   virtual int NumMyRows() const
00179   {
00180     return(NumRows_);
00181   }
00182 
00183   virtual int NumMyCols() const
00184   {
00185     return(NumRows_);
00186   }
00187 
00188   virtual int NumMyDiagonals() const
00189   {
00190     return(NumRows_);
00191   }
00192 
00193   virtual bool LowerTriangular() const
00194   {
00195     return(false);
00196   }
00197 
00198   virtual bool UpperTriangular() const
00199   {
00200     return(false);
00201   }
00202 
00203   virtual const Epetra_Map & RowMatrixRowMap() const
00204   {
00205     return(*Map_);
00206   }
00207 
00208   virtual const Epetra_Map & RowMatrixColMap() const
00209   {
00210     return(*Map_);
00211   }
00212 
00213   virtual const Epetra_Import * RowMatrixImporter() const
00214   {
00215     return(A_->RowMatrixImporter());
00216   }
00217 
00218   int SetUseTranspose(bool UseTranspose_in)
00219   {
00220     return(A_->SetUseTranspose(UseTranspose_in));
00221   }
00222 
00223   bool UseTranspose() const 
00224   {
00225     return(A_->UseTranspose());
00226   }
00227 
00228   bool HasNormInf() const
00229   {
00230     return(false);
00231   }
00232 
00233   const Epetra_Comm & Comm() const
00234   {
00235     return(A_->Comm());
00236   }
00237 
00238   const Epetra_Map & OperatorDomainMap() const 
00239   {
00240     return(*Map_);
00241   }
00242 
00243   const Epetra_Map & OperatorRangeMap() const 
00244   {
00245     return(*Map_);
00246   }
00247 
00248   const Epetra_BlockMap& Map() const 
00249   {
00250     return(*(const Epetra_BlockMap*)(&*Map_));
00251   }
00252 
00253   const char* Label() const{
00254     return(Label_);
00255   }
00256 
00257   int SolveSingletons(const Epetra_MultiVector& RHS, 
00258               Epetra_MultiVector& LHS);
00259 
00260   int CreateReducedRHS(const Epetra_MultiVector& LHS,
00261                const Epetra_MultiVector& RHS, 
00262                Epetra_MultiVector& ReducedRHS);
00263 
00264   int UpdateLHS(const Epetra_MultiVector& ReducedLHS,
00265         Epetra_MultiVector& LHS);
00266 
00267 private:
00268 
00270   Teuchos::RefCountPtr<Epetra_RowMatrix> A_;
00271 
00273   mutable std::vector<int> Indices_;
00275   mutable std::vector<double> Values_;
00277   char Label_[80];
00278   
00279   int NumSingletons_;
00280   std::vector<int> SingletonIndex_;
00281 
00282   std::vector<int> Reorder_;
00283   std::vector<int> InvReorder_;
00284 
00285   std::vector<int> NumEntries_;
00286 
00287   int NumRows_;
00288   int NumRowsA_;
00289   int MaxNumEntries_;
00290   int MaxNumEntriesA_;
00291   int NumNonzeros_;
00292   Teuchos::RefCountPtr<Epetra_Map> Map_;
00293   
00294   Teuchos::RefCountPtr<Epetra_Vector> Diagonal_;
00295 
00296 };
00297 
00298 #endif /* IFPACK_SINGLETONFILTER_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends