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