IFPACK  Development
 All Classes Files Functions Variables Enumerations Friends
Ifpack_LocalFilter.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_LOCALFILTER_H
00044 #define IFPACK_LOCALFILTER_H
00045 
00046 #include "Ifpack_ConfigDefs.h"
00047 #ifdef HAVE_MPI
00048 #include "Epetra_MpiComm.h"
00049 #else
00050 #include "Epetra_SerialComm.h"
00051 #endif
00052 #include "Epetra_RowMatrix.h"
00053 #include "Teuchos_RefCountPtr.hpp"
00054 
00055 class Epetra_Map;
00056 class Epetra_MultiVector;
00057 class Epetra_Vector;
00058 class Epetra_Import;
00059 class Epetra_BlockMap;
00060 
00062 
00098 class Ifpack_LocalFilter : public virtual Epetra_RowMatrix {
00099 
00100 public:
00102 
00103   Ifpack_LocalFilter(const Teuchos::RefCountPtr<const Epetra_RowMatrix>& Matrix);
00104 
00106 
00107 
00108   virtual ~Ifpack_LocalFilter() {};
00109 
00111 
00113 
00115 
00123   virtual int NumMyRowEntries(int MyRow, int & NumEntries) const
00124   {
00125     NumEntries = NumEntries_[MyRow];
00126     return(0);
00127   }
00128 
00130   virtual int MaxNumEntries() const
00131   {
00132     return(MaxNumEntries_);
00133   }
00134 
00136 
00150   virtual inline int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
00151 
00153 
00159   virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
00161 
00163 
00165 
00175   virtual int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const
00176   {
00177     if (TransA == true) {
00178       IFPACK_CHK_ERR(-1);
00179     }
00180 
00181     IFPACK_CHK_ERR(Apply(X,Y));
00182     return(0);
00183   }
00184 
00186   virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector& X, 
00187             Epetra_MultiVector& Y) const
00188   {
00189     IFPACK_RETURN(-1); // not implemented 
00190   }
00191 
00192   virtual int Apply(const Epetra_MultiVector& X,
00193             Epetra_MultiVector& Y) const;
00194 
00195   virtual int ApplyInverse(const Epetra_MultiVector& X,
00196                Epetra_MultiVector& Y) const;
00198   virtual int InvRowSums(Epetra_Vector& x) const
00199   {
00200     IFPACK_RETURN(-1); // not implemented
00201   }
00202 
00204   virtual int LeftScale(const Epetra_Vector& x)
00205   {
00206     IFPACK_RETURN(-1); // not implemented
00207   }
00208 
00210   virtual int InvColSums(Epetra_Vector& x) const
00211   {
00212     IFPACK_RETURN(-1); // not implemented
00213   }
00214 
00215 
00217   virtual int RightScale(const Epetra_Vector& x) 
00218   {
00219     IFPACK_RETURN(-1); // not implemented
00220   }
00221 
00223 
00225 
00227   virtual bool Filled() const
00228   {
00229     return true;
00230   }
00231 
00233   /* Returns the quantity \f$ \| A \|_\infty\f$ such that
00234      \f[\| A \|_\infty = \max_{1\lei\len} \sum_{i=1}^m |a_{ij}| \f].
00235      */ 
00236   virtual double NormInf() const
00237   {
00238     return(-1.0);
00239   }
00240 
00242   /* Returns the quantity \f$ \| A \|_1\f$ such that
00243      \f[\| A \|_1= \max_{1\lej\len} \sum_{j=1}^n |a_{ij}| \f].
00244      */ 
00245   virtual double NormOne() const
00246   {
00247     IFPACK_RETURN(-1.0);
00248   }
00249 
00250 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00251 
00252   virtual int NumGlobalNonzeros() const
00253   {
00254     return(NumNonzeros_);
00255   }
00256 
00258   virtual int NumGlobalRows() const
00259   {
00260     return(NumRows_);
00261   }
00262 
00264   virtual int NumGlobalCols() const
00265   {
00266     return(NumRows_);
00267   }
00268 
00270   virtual int NumGlobalDiagonals() const
00271   {
00272     return(NumRows_);
00273   }
00274 #endif
00275 
00277   virtual long long NumGlobalNonzeros64() const
00278   {
00279     return(NumNonzeros_);
00280   }
00281 
00283   virtual long long NumGlobalRows64() const
00284   {
00285     return(NumRows_);
00286   }
00287 
00289   virtual long long NumGlobalCols64() const
00290   {
00291     return(NumRows_);
00292   }
00293 
00295   virtual long long NumGlobalDiagonals64() const
00296   {
00297     return(NumRows_);
00298   }
00299 
00301   virtual int NumMyNonzeros() const
00302   {
00303     return(NumNonzeros_);
00304   }
00305 
00307   virtual int NumMyRows() const
00308   {
00309     return(NumRows_);
00310   }
00311 
00313   virtual int NumMyCols() const
00314   {
00315     return(NumRows_);
00316   }
00317 
00319   virtual int NumMyDiagonals() const
00320   {
00321     return(NumRows_);
00322   }
00323 
00325   virtual bool LowerTriangular() const
00326   {
00327     return(Matrix_->LowerTriangular());
00328   }
00329 
00331   virtual bool UpperTriangular() const
00332   {
00333     return(Matrix_->UpperTriangular());
00334   }
00335 
00337   virtual const Epetra_Map & RowMatrixRowMap() const
00338   {
00339     return(*Map_);
00340   }
00341 
00343   virtual const Epetra_Map & RowMatrixColMap() const
00344   {
00345     return(*Map_);
00346   }
00347 
00349   virtual const Epetra_Import * RowMatrixImporter() const
00350   {
00351     return(0);
00352   }
00354 
00355   // following functions are required to derive Epetra_RowMatrix objects.
00356 
00358   int SetOwnership(bool ownership)
00359   {
00360     IFPACK_RETURN(-1);
00361   }
00362 
00364   int SetUseTranspose(bool UseTranspose_in)
00365   {
00366     UseTranspose_ = UseTranspose_in;
00367     return(0);
00368   }
00369 
00371   bool UseTranspose() const 
00372   {
00373     return(UseTranspose_);
00374   }
00375 
00377   bool HasNormInf() const
00378   {
00379     return(false);
00380   }
00381 
00383   const Epetra_Comm & Comm() const
00384   {
00385     return(*SerialComm_);
00386   }
00387 
00389   const Epetra_Map & OperatorDomainMap() const 
00390   {
00391     return(*Map_);
00392   }
00393 
00395   const Epetra_Map & OperatorRangeMap() const 
00396   {
00397     return(*Map_);
00398   }
00400 
00401 const Epetra_BlockMap& Map() const;
00402 
00403 const char* Label() const{
00404   return(Label_);
00405 };
00406 
00407 private:
00408 
00410   Teuchos::RefCountPtr<const Epetra_RowMatrix> Matrix_;
00411 #ifdef HAVE_MPI
00412 
00413   Teuchos::RefCountPtr<Epetra_MpiComm> SerialComm_;
00414 #else
00415 
00416   Teuchos::RefCountPtr<Epetra_SerialComm> SerialComm_;
00417 #endif
00418 
00419   Teuchos::RefCountPtr<Epetra_Map> Map_;
00421   int NumRows_;
00423   int NumNonzeros_;
00425   int MaxNumEntries_;
00427   int MaxNumEntriesA_;
00429   std::vector<int> NumEntries_;
00431   mutable std::vector<int> Indices_;
00433   mutable std::vector<double> Values_;
00435   bool UseTranspose_;
00437   char Label_[80];
00438   Teuchos::RefCountPtr<Epetra_Vector> Diagonal_;
00439   double NormOne_;
00440   double NormInf_;
00441 
00442 };
00443 
00444 #endif /* IFPACK_LOCALFILTER_H */
 All Classes Files Functions Variables Enumerations Friends