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