IFPACK Development
Ifpack_OverlappingRowMatrix.h
00001 
00002 /*@HEADER
00003 // ***********************************************************************
00004 //
00005 //       Ifpack: Object-Oriented Algebraic Preconditioner Package
00006 //                 Copyright (2002) Sandia Corporation
00007 //
00008 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00009 // license for use of this work by or on behalf of the U.S. Government.
00010 //
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA
00025 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00026 //
00027 // ***********************************************************************
00028 //@HEADER
00029 */
00030 
00031 #ifndef IFPACK_OVERLAPPINGROWMATRIX_H
00032 #define IFPACK_OVERLAPPINGROWMATRIX_H
00033 
00034 #include "Ifpack_ConfigDefs.h"
00035 #include "Epetra_RowMatrix.h"
00036 #include "Epetra_CombineMode.h"
00037 #include "Teuchos_RefCountPtr.hpp"
00038 #include "Epetra_Import.h"
00039 #include "Epetra_Map.h"
00040 #ifdef IFPACK_SUBCOMM_CODE
00041 #include "Epetra_IntVector.h"
00042 #else
00043 # ifdef IFPACK_NODE_AWARE_CODE
00044 # include "Epetra_IntVector.h"
00045 # endif
00046 #endif
00047 
00048 class Epetra_Map;
00049 class Epetra_BlockMap;
00050 class Epetra_CrsMatrix;
00051 class Epetra_Comm;
00052 
00054 //
00055 class Ifpack_OverlappingRowMatrix : public virtual Epetra_RowMatrix {
00056 
00057 public:
00058 
00060 #ifdef IFPACK_SUBCOMM_CODE
00061   Ifpack_OverlappingRowMatrix(const Teuchos::RefCountPtr<const Epetra_RowMatrix>& Matrix_in,
00062                               int OverlapLevel_in, int subdomainID);
00063 #else
00064 # ifdef IFPACK_NODE_AWARE_CODE
00065   Ifpack_OverlappingRowMatrix(const Teuchos::RefCountPtr<const Epetra_RowMatrix>& Matrix_in,
00066                               int OverlapLevel_in, int myNodeID);
00067 # endif
00068 #endif
00069   Ifpack_OverlappingRowMatrix(const Teuchos::RefCountPtr<const Epetra_RowMatrix>& Matrix_in,
00070                               int OverlapLevel_in);
00071 
00072 #ifdef IFPACK_SUBCOMM_CODE
00073   ~Ifpack_OverlappingRowMatrix() {};
00074 #else
00075 # ifdef IFPACK_NODE_AWARE_CODE
00076   ~Ifpack_OverlappingRowMatrix();
00077 # else
00078   ~Ifpack_OverlappingRowMatrix() {};
00079 # endif
00080 #endif
00081 
00082 
00084 
00086 
00094   virtual int NumMyRowEntries(int MyRow, int & NumEntries) const;
00095 
00097   virtual int MaxNumEntries() const
00098   {
00099     return(MaxNumEntries_);
00100   }
00101 
00103 
00117   virtual int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
00118 #ifdef IFPACK_SUBCOMM_CODE
00119   virtual int ExtractGlobalRowCopy(int MyRow, int Length, int & NumEntries, double* Values, int* Indices) const;
00120 #else
00121 # ifdef IFPACK_NODE_AWARE_CODE
00122   virtual int ExtractGlobalRowCopy(int MyRow, int Length, int & NumEntries, double* Values, int* Indices) const;
00123 # endif
00124 #endif
00125 
00127 
00133   virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
00135 
00137 
00139 
00149   virtual int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00150 
00152   virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector& X, 
00153             Epetra_MultiVector& Y) const
00154   {
00155     IFPACK_RETURN(-1); // not implemented 
00156   }
00157 
00158   virtual int Apply(const Epetra_MultiVector& X,
00159             Epetra_MultiVector& Y) const;
00160 
00161   virtual int ApplyInverse(const Epetra_MultiVector& X,
00162                Epetra_MultiVector& Y) const;
00164   virtual int InvRowSums(Epetra_Vector& x) const
00165   {
00166     IFPACK_RETURN(-1); // not implemented
00167   }
00168 
00170   virtual int LeftScale(const Epetra_Vector& x)
00171   {
00172     IFPACK_RETURN(-1); // not implemented
00173   }
00174 
00176   virtual int InvColSums(Epetra_Vector& x) const
00177   {
00178     IFPACK_RETURN(-1); // not implemented
00179   }
00180 
00181 
00183   virtual int RightScale(const Epetra_Vector& x) 
00184   {
00185     IFPACK_RETURN(-1); // not implemented
00186   }
00187 
00189 
00191 
00193   virtual bool Filled() const
00194   {
00195     return(true);
00196   }
00197 
00199   /* Returns the quantity \f$ \| A \|_\infty\f$ such that
00200      \f[\| A \|_\infty = \max_{1\lei\len} \sum_{i=1}^m |a_{ij}| \f].
00201      */ 
00202   virtual double NormInf() const
00203   {
00204     return(A().NormInf());
00205   }
00206 
00208   /* Returns the quantity \f$ \| A \|_1\f$ such that
00209      \f[\| A \|_1= \max_{1\lej\len} \sum_{j=1}^n |a_{ij}| \f].
00210      */ 
00211   virtual double NormOne() const
00212   {
00213     IFPACK_RETURN(A().NormOne());
00214   }
00215 
00216 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00217 
00218   virtual int NumGlobalNonzeros() const
00219   {
00220     if(A().RowMatrixRowMap().GlobalIndicesInt())
00221        return (int) NumGlobalNonzeros_;
00222     else
00223        throw "Ifpack_OverlappingRowMatrix::NumGlobalNonzeros: Global indices not int";
00224   }
00225 
00227   virtual int NumGlobalRows() const
00228   {
00229     return(A().NumGlobalRows());
00230   }
00231 
00233   virtual int NumGlobalCols() const
00234   {
00235     return(A().NumGlobalCols());
00236   }
00237 
00239   virtual int NumGlobalDiagonals() const
00240   {
00241     return(A().NumGlobalDiagonals());
00242   }
00243 #endif
00244 
00245   virtual long long NumGlobalNonzeros64() const
00246   {
00247     return(NumGlobalNonzeros_);
00248   }
00249 
00251   virtual long long NumGlobalRows64() const
00252   {
00253     return(A().NumGlobalRows64());
00254   }
00255 
00257   virtual long long NumGlobalCols64() const
00258   {
00259     return(A().NumGlobalCols64());
00260   }
00261 
00263   virtual long long NumGlobalDiagonals64() const
00264   {
00265     return(A().NumGlobalDiagonals64());
00266   }
00267 
00269   virtual int NumMyNonzeros() const
00270   {
00271     return(NumMyNonzeros_);
00272   }
00273 
00275   virtual int NumMyRows() const
00276   {
00277     return(NumMyRows_);
00278   }
00279 
00281   virtual int NumMyCols() const
00282   {
00283     return(NumMyCols_);
00284   }
00285 
00287   virtual int NumMyDiagonals() const
00288   {
00289     return(NumMyDiagonals_);
00290   }
00291 
00293   virtual bool LowerTriangular() const
00294   {
00295     return(A().LowerTriangular());
00296   }
00297 
00299   virtual bool UpperTriangular() const
00300   {
00301     return(A().UpperTriangular());
00302   }
00303 
00305   virtual const Epetra_Map & RowMatrixRowMap() const
00306   {
00307     return(*Map_);
00308   }
00309 
00311   virtual const Epetra_Map & RowMatrixColMap() const
00312   {
00313 #ifdef IFPACK_SUBCOMM_CODE
00314     return(*colMap_);
00315 #else
00316 #   ifdef IFPACK_NODE_AWARE_CODE
00317     return(*colMap_);
00318 #   else
00319     return(*Map_);
00320 #   endif
00321 #endif
00322   }
00323 
00325   virtual const Epetra_Import * RowMatrixImporter() const
00326   {
00327     return(&*Importer_);
00328   }
00330 
00331   // following functions are required to derive Epetra_RowMatrix objects.
00332 
00334   int SetOwnership(bool ownership)
00335   {
00336     IFPACK_RETURN(-1);
00337   }
00338 
00340   int SetUseTranspose(bool UseTranspose_in)
00341   {
00342     UseTranspose_ = UseTranspose_in;
00343     return(0);
00344   }
00345 
00347   bool UseTranspose() const 
00348   {
00349     return(UseTranspose_);
00350   }
00351 
00353   bool HasNormInf() const
00354   {
00355     return(A().HasNormInf());
00356   }
00357 
00359   const Epetra_Comm & Comm() const
00360   {
00361     return(A().Comm());
00362   }
00363 
00365   const Epetra_Map & OperatorDomainMap() const 
00366   {
00367     return(*Map_);
00368   }
00369 
00371   const Epetra_Map & OperatorRangeMap() const 
00372   {
00373     return(*Map_);
00374   }
00376 
00377 const Epetra_BlockMap& Map() const;
00378 
00379 const char* Label() const{
00380   return(Label_.c_str());
00381 };
00382 
00383 int OverlapLevel() const
00384 {
00385   return(OverlapLevel_);
00386 }
00387 
00388 int ImportMultiVector(const Epetra_MultiVector& X,
00389                       Epetra_MultiVector& OvX,
00390                       Epetra_CombineMode CM = Insert);
00391 
00392 int ExportMultiVector(const Epetra_MultiVector& OvX,
00393                       Epetra_MultiVector& X,
00394                       Epetra_CombineMode CM = Add);
00395 #ifdef IFPACK_SUBCOMM_CODE
00396   inline const Epetra_RowMatrix& A() const 
00397   {
00398     return(*Matrix_);
00399   }
00400 
00401   inline Epetra_CrsMatrix& B() const
00402   {
00403     return(*ExtMatrix_);
00404   }
00405 #else
00406 # ifdef IFPACK_NODE_AWARE_CODE
00407   inline const Epetra_RowMatrix& A() const 
00408   {
00409     return(*Matrix_);
00410   }
00411 
00412   inline Epetra_CrsMatrix& B() const
00413   {
00414     return(*ExtMatrix_);
00415   }
00416 # endif
00417 #endif
00418 
00419 private: 
00420 #ifndef IFPACK_SUBCOMM_CODE
00421 # ifndef IFPACK_NODE_AWARE_CODE
00422   inline const Epetra_RowMatrix& A() const 
00423   {
00424     return(*Matrix_);
00425   }
00426 
00427   inline Epetra_RowMatrix& B() const;
00428 # endif
00429 #endif
00430 
00431   int NumMyRows_;
00432   int NumMyCols_;
00433   int NumMyDiagonals_;
00434   int NumMyNonzeros_;
00435 
00436   long long NumGlobalNonzeros_;
00437   int MaxNumEntries_;
00438 
00439   int NumMyRowsA_;
00440   int NumMyRowsB_;
00441 
00442   bool UseTranspose_;
00443 
00444   Teuchos::RefCountPtr<const Epetra_Map> Map_;
00445 #ifdef IFPACK_SUBCOMM_CODE
00446   const Epetra_Map *colMap_;
00447 #else
00448 # ifdef IFPACK_NODE_AWARE_CODE
00449   const Epetra_Map *colMap_;
00450 # endif
00451 #endif
00452   Teuchos::RefCountPtr<const Epetra_Import> Importer_;
00453 
00454   Teuchos::RefCountPtr<const Epetra_RowMatrix> Matrix_;
00455   Teuchos::RefCountPtr<Epetra_CrsMatrix> ExtMatrix_;
00456   Teuchos::RefCountPtr<Epetra_Map> ExtMap_;
00457   Teuchos::RefCountPtr<Epetra_Import> ExtImporter_;
00458 
00459   int OverlapLevel_;
00460   string Label_;
00461 
00462 }; // class Ifpack_OverlappingRowMatrix
00463 
00464 #endif // IFPACK_OVERLAPPINGROWMATRIX_H
 All Classes Files Functions Variables Typedefs Enumerations Friends