IFPACK Development
Ifpack_DiagonalFilter.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_DIAGONALFILTER_H
00044 #define IFPACK_DIAGONALFILTER_H
00045 
00046 #include "Ifpack_ConfigDefs.h"
00047 #include "Epetra_ConfigDefs.h"
00048 #include "Epetra_RowMatrix.h"
00049 #include "Epetra_Time.h"
00050 #include "Teuchos_RefCountPtr.hpp"
00051 
00052 class Epetra_Comm;
00053 class Epetra_Map;
00054 class Epetra_MultiVector;
00055 class Epetra_Import;
00056 class Epetra_BlockMap;
00057 
00059 
00080 class Ifpack_DiagonalFilter : public virtual Epetra_RowMatrix {
00081 
00082 public:
00084   Ifpack_DiagonalFilter(const Teuchos::RefCountPtr<Epetra_RowMatrix>& Matrix,
00085                         double AbsoluteThreshold,
00086                         double RelativeThreshold);
00087   
00089   virtual ~Ifpack_DiagonalFilter() {};
00090 
00092   virtual int NumMyRowEntries(int MyRow, int& NumEntries) const
00093   {
00094     return(A_->NumMyRowEntries(MyRow, NumEntries));
00095   }
00096 
00098   virtual int MaxNumEntries() const
00099   {
00100     return(A_->MaxNumEntries());
00101   }
00102 
00103   inline virtual int ExtractMyRowCopy(int MyRow, int Length, int& NumEntries, 
00104                                double* Values, int* Indices) const;
00105 
00106   virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const
00107   {
00108     int ierr = A_->ExtractDiagonalCopy(Diagonal);
00109     IFPACK_RETURN(ierr);
00110   }
00111 
00112   virtual int Multiply(bool TransA, const Epetra_MultiVector& X, 
00113                Epetra_MultiVector& Y) const;
00114 
00115   virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, 
00116             const Epetra_MultiVector& X,
00117             Epetra_MultiVector& Y) const
00118   {
00119     IFPACK_CHK_ERR(-1);
00120   }
00121 
00122   virtual int Apply(const Epetra_MultiVector& X,
00123             Epetra_MultiVector& Y) const
00124   {
00125     int ierr = Multiply(UseTranspose(),X,Y);
00126     IFPACK_RETURN(ierr);
00127   }
00128 
00129   virtual int ApplyInverse(const Epetra_MultiVector& X,
00130                Epetra_MultiVector& Y) const
00131   {
00132     IFPACK_CHK_ERR(-1);
00133   }
00134 
00135   virtual int InvRowSums(Epetra_Vector& x) const
00136   {
00137     IFPACK_CHK_ERR(-1);
00138   }
00139 
00140   virtual int LeftScale(const Epetra_Vector& x)
00141   {
00142     return(A_->LeftScale(x));
00143   }
00144 
00145   virtual int InvColSums(Epetra_Vector& x) const
00146   {
00147     IFPACK_CHK_ERR(-1);;
00148   }
00149 
00150   virtual int RightScale(const Epetra_Vector& x) 
00151   {
00152     return(A_->RightScale(x));
00153   }
00154 
00155   virtual bool Filled() const
00156   {
00157     return(A_->Filled());
00158   }
00159 
00161   virtual double NormInf() const
00162   {
00163     return(-1.0);
00164   }
00165 
00167   virtual double NormOne() const
00168   {
00169     return(-1.0);
00170   }
00171 
00172 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00173   virtual int NumGlobalNonzeros() const
00174   {
00175     return(A_->NumGlobalNonzeros());
00176   }
00177 
00178   virtual int NumGlobalRows() const
00179   {
00180     return(A_->NumGlobalRows());
00181   }
00182 
00183   virtual int NumGlobalCols() const
00184   {
00185     return(A_->NumGlobalCols());
00186   }
00187 
00188   virtual int NumGlobalDiagonals() const
00189   {
00190     return(A_->NumGlobalDiagonals());
00191   }
00192 #endif
00193 
00194   virtual long long NumGlobalNonzeros64() const
00195   {
00196     return(A_->NumGlobalNonzeros64());
00197   }
00198 
00199   virtual long long NumGlobalRows64() const
00200   {
00201     return(A_->NumGlobalRows64());
00202   }
00203 
00204   virtual long long NumGlobalCols64() const
00205   {
00206     return(A_->NumGlobalCols64());
00207   }
00208 
00209   virtual long long NumGlobalDiagonals64() const
00210   {
00211     return(A_->NumGlobalDiagonals64());
00212   }
00213 
00214   virtual int NumMyNonzeros() const
00215   {
00216     return(A_->NumMyNonzeros());
00217   }
00218 
00219   virtual int NumMyRows() const
00220   {
00221     return(A_->NumMyRows());
00222   }
00223 
00224   virtual int NumMyCols() const
00225   {
00226     return(A_->NumMyCols());
00227   }
00228 
00229   virtual int NumMyDiagonals() const
00230   {
00231     return(A_->NumMyDiagonals());
00232   }
00233 
00234   virtual bool LowerTriangular() const
00235   {
00236     return(A_->LowerTriangular());
00237   }
00238 
00239   virtual bool UpperTriangular() const
00240   {
00241     return(A_->UpperTriangular());
00242   }
00243 
00244   virtual const Epetra_Map& RowMatrixRowMap() const
00245   {
00246     return(A_->RowMatrixRowMap());
00247   }
00248 
00249   virtual const Epetra_Map& RowMatrixColMap() const
00250   {
00251     return(A_->RowMatrixColMap());
00252   }
00253 
00254   virtual const Epetra_Import* RowMatrixImporter() const
00255   {
00256     return(A_->RowMatrixImporter());
00257   }
00258 
00259   int SetUseTranspose(bool UseTranspose_in)
00260   {
00261     return(A_->SetUseTranspose(UseTranspose_in));
00262   }
00263 
00264   bool UseTranspose() const 
00265   {
00266     return(A_->UseTranspose());
00267   }
00268 
00270   bool HasNormInf() const
00271   {
00272     return(false);
00273   }
00274 
00275   const Epetra_Comm& Comm() const
00276   {
00277     return(A_->Comm());
00278   }
00279 
00280   const Epetra_Map& OperatorDomainMap() const 
00281   {
00282     return(A_->OperatorDomainMap());
00283   }
00284 
00285   const Epetra_Map& OperatorRangeMap() const 
00286   {
00287     return(A_->OperatorRangeMap());
00288   }
00289 
00290   const Epetra_BlockMap& Map() const 
00291   {
00292     return(A_->Map());
00293   }
00294 
00295   const char* Label() const{
00296     return(A_->Label());
00297   }
00298 
00299 private:
00300 
00302   Teuchos::RefCountPtr<Epetra_RowMatrix> A_;
00304   double AbsoluteThreshold_;
00306   double RelativeThreshold_;
00308   std::vector<int> pos_;
00310   std::vector<double> val_;
00311 
00312 };
00313 
00314 
00315 #endif /* IFPACK_DIAGONALFILTER_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends