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