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 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00025 //
00026 // ***********************************************************************
00027 //@HEADER
00028 */
00029 
00030 #ifndef IFPACK_SINGLETONFILTER_H
00031 #define IFPACK_SINGLETONFILTER_H
00032 
00033 #include "Ifpack_ConfigDefs.h"
00034 #include "Epetra_RowMatrix.h"
00035 #include "Teuchos_RefCountPtr.hpp"
00036 
00037 class Epetra_Comm;
00038 class Epetra_Map;
00039 class Epetra_MultiVector;
00040 class Epetra_Import;
00041 class Epetra_BlockMap;
00042 
00043 #ifdef TEUCHOS_DEBUG
00044 // 2007/09/19: If building with --enable-teuchos-debug, then you need to have
00045 // your type T fully defined if you dereference an RCP.  This was flagged on
00046 // the SGI compiler on sasg5000.  Note that this problem goes away if these
00047 // functions where defined in the *.cpp file instead of in the header file.
00048 #include "Epetra_Map.h"
00049 #endif
00050 
00052 //
00053 class Ifpack_SingletonFilter : public virtual Epetra_RowMatrix {
00054 
00055 public:
00057   Ifpack_SingletonFilter(const Teuchos::RefCountPtr<Epetra_RowMatrix>& Matrix);
00058 
00060   virtual ~Ifpack_SingletonFilter() {};
00061 
00063   virtual inline int NumMyRowEntries(int MyRow, int & NumEntries) const
00064   {
00065     return(NumEntries_[MyRow]);
00066   }
00067 
00069   virtual int MaxNumEntries() const
00070   {
00071     return(MaxNumEntries_);
00072   }
00073 
00074   virtual int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
00075 
00076   virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
00077 
00078   virtual int Multiply(bool TransA, const Epetra_MultiVector& X, 
00079                Epetra_MultiVector& Y) const;
00080 
00081   virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, 
00082             const Epetra_MultiVector& X,
00083             Epetra_MultiVector& Y) const;
00084 
00085   virtual int Apply(const Epetra_MultiVector& X,
00086             Epetra_MultiVector& Y) const;
00087 
00088   virtual int ApplyInverse(const Epetra_MultiVector& X,
00089                Epetra_MultiVector& Y) const;
00090 
00091   virtual int InvRowSums(Epetra_Vector& x) const
00092   {
00093     return(-98); // NOT IMPLEMENTED
00094   }
00095 
00096   virtual int LeftScale(const Epetra_Vector& x)
00097   {
00098     return(-98); // NOT IMPLEMENTED
00099   }
00100 
00101   virtual int InvColSums(Epetra_Vector& x) const
00102   {
00103     return(-98); // NOT IMPLEMENTED
00104   }
00105 
00106   virtual int RightScale(const Epetra_Vector& x) 
00107   {
00108     return(-98); // NOT IMPLEMENTED
00109   }
00110 
00111   virtual bool Filled() const
00112   {
00113     return(A_->Filled());
00114   }
00115 
00116   virtual double NormInf() const
00117   {
00118     return(-1.0);
00119   }
00120 
00121   virtual double NormOne() const
00122   {
00123     return(-1.0);
00124   }
00125 
00126   virtual int NumGlobalNonzeros() const
00127   {
00128     return(NumNonzeros_);
00129   }
00130 
00131   virtual int NumGlobalRows() const
00132   {
00133     return(NumRows_);
00134   }
00135 
00136   virtual int NumGlobalCols() const
00137   {
00138     return(NumRows_);
00139   }
00140 
00141   virtual int NumGlobalDiagonals() const
00142   {
00143     return(NumRows_);
00144   }
00145 
00146   virtual int NumMyNonzeros() const
00147   {
00148     return(NumNonzeros_);
00149   }
00150 
00151   virtual int NumMyRows() const
00152   {
00153     return(NumRows_);
00154   }
00155 
00156   virtual int NumMyCols() const
00157   {
00158     return(NumRows_);
00159   }
00160 
00161   virtual int NumMyDiagonals() const
00162   {
00163     return(NumRows_);
00164   }
00165 
00166   virtual bool LowerTriangular() const
00167   {
00168     return(false);
00169   }
00170 
00171   virtual bool UpperTriangular() const
00172   {
00173     return(false);
00174   }
00175 
00176   virtual const Epetra_Map & RowMatrixRowMap() const
00177   {
00178     return(*Map_);
00179   }
00180 
00181   virtual const Epetra_Map & RowMatrixColMap() const
00182   {
00183     return(*Map_);
00184   }
00185 
00186   virtual const Epetra_Import * RowMatrixImporter() const
00187   {
00188     return(A_->RowMatrixImporter());
00189   }
00190 
00191   int SetUseTranspose(bool UseTranspose)
00192   {
00193     return(A_->SetUseTranspose(UseTranspose));
00194   }
00195 
00196   bool UseTranspose() const 
00197   {
00198     return(A_->UseTranspose());
00199   }
00200 
00201   bool HasNormInf() const
00202   {
00203     return(false);
00204   }
00205 
00206   const Epetra_Comm & Comm() const
00207   {
00208     return(A_->Comm());
00209   }
00210 
00211   const Epetra_Map & OperatorDomainMap() const 
00212   {
00213     return(*Map_);
00214   }
00215 
00216   const Epetra_Map & OperatorRangeMap() const 
00217   {
00218     return(*Map_);
00219   }
00220 
00221   const Epetra_BlockMap& Map() const 
00222   {
00223     return(*(const Epetra_BlockMap*)(&*Map_));
00224   }
00225 
00226   const char* Label() const{
00227     return(Label_);
00228   }
00229 
00230   int SolveSingletons(const Epetra_MultiVector& RHS, 
00231               Epetra_MultiVector& LHS);
00232 
00233   int CreateReducedRHS(const Epetra_MultiVector& LHS,
00234                const Epetra_MultiVector& RHS, 
00235                Epetra_MultiVector& ReducedRHS);
00236 
00237   int UpdateLHS(const Epetra_MultiVector& ReducedLHS,
00238         Epetra_MultiVector& LHS);
00239 
00240 private:
00241 
00243   Teuchos::RefCountPtr<Epetra_RowMatrix> A_;
00244 
00246   mutable std::vector<int> Indices_;
00248   mutable std::vector<double> Values_;
00250   char Label_[80];
00251   
00252   int NumSingletons_;
00253   std::vector<int> SingletonIndex_;
00254 
00255   std::vector<int> Reorder_;
00256   std::vector<int> InvReorder_;
00257 
00258   std::vector<int> NumEntries_;
00259 
00260   int NumRows_;
00261   int NumRowsA_;
00262   int MaxNumEntries_;
00263   int MaxNumEntriesA_;
00264   int NumNonzeros_;
00265   Teuchos::RefCountPtr<Epetra_Map> Map_;
00266   
00267   Teuchos::RefCountPtr<Epetra_Vector> Diagonal_;
00268 
00269 };
00270 
00271 #endif /* IFPACK_SINGLETONFILTER_H */

Generated on Tue Oct 20 12:48:54 2009 for IFPACK by doxygen 1.4.7