IFPACK  Development
 All Classes Files Functions Variables Enumerations Friends
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 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00039 //
00040 // ***********************************************************************
00041 //@HEADER
00042 */
00043 
00044 #ifndef IFPACK_OVERLAPPINGROWMATRIX_H
00045 #define IFPACK_OVERLAPPINGROWMATRIX_H
00046 
00047 #include "Ifpack_ConfigDefs.h"
00048 #include "Epetra_RowMatrix.h"
00049 #include "Epetra_CombineMode.h"
00050 #include "Teuchos_RefCountPtr.hpp"
00051 #include "Epetra_Import.h"
00052 #include "Epetra_Map.h"
00053 #ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
00054 #include "Epetra_IntVector.h"
00055 #else
00056 # ifdef IFPACK_NODE_AWARE_CODE
00057 # include "Epetra_IntVector.h"
00058 # endif
00059 #endif
00060 
00061 class Epetra_Map;
00062 class Epetra_BlockMap;
00063 class Epetra_CrsMatrix;
00064 class Epetra_Comm;
00065 
00067 //
00068 class Ifpack_OverlappingRowMatrix : public virtual Epetra_RowMatrix {
00069 
00070 public:
00071 
00073 #ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
00074   Ifpack_OverlappingRowMatrix(const Teuchos::RefCountPtr<const Epetra_RowMatrix>& Matrix_in,
00075                               int OverlapLevel_in, int subdomainID);
00076 #else
00077 # ifdef IFPACK_NODE_AWARE_CODE
00078   Ifpack_OverlappingRowMatrix(const Teuchos::RefCountPtr<const Epetra_RowMatrix>& Matrix_in,
00079                               int OverlapLevel_in, int myNodeID);
00080 # endif
00081 #endif
00082   Ifpack_OverlappingRowMatrix(const Teuchos::RefCountPtr<const Epetra_RowMatrix>& Matrix_in,
00083                               int OverlapLevel_in);
00084 
00085 #ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
00086   ~Ifpack_OverlappingRowMatrix() {};
00087 #else
00088 # ifdef IFPACK_NODE_AWARE_CODE
00089   ~Ifpack_OverlappingRowMatrix();
00090 # else
00091   ~Ifpack_OverlappingRowMatrix() {};
00092 # endif
00093 #endif
00094 
00095 
00097 
00099 
00107   virtual int NumMyRowEntries(int MyRow, int & NumEntries) const;
00108 
00110   virtual int MaxNumEntries() const
00111   {
00112     return(MaxNumEntries_);
00113   }
00114 
00116 
00130   virtual int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
00131 #ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
00132   virtual int ExtractGlobalRowCopy(int MyRow, int Length, int & NumEntries, double* Values, int* Indices) const;
00133 #else
00134 # ifdef IFPACK_NODE_AWARE_CODE
00135   virtual int ExtractGlobalRowCopy(int MyRow, int Length, int & NumEntries, double* Values, int* Indices) const;
00136 # endif
00137 #endif
00138 
00140 
00146   virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
00148 
00150 
00152 
00162   virtual int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00163 
00165   virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector& X, 
00166             Epetra_MultiVector& Y) const
00167   {
00168     IFPACK_RETURN(-1); // not implemented 
00169   }
00170 
00171   virtual int Apply(const Epetra_MultiVector& X,
00172             Epetra_MultiVector& Y) const;
00173 
00174   virtual int ApplyInverse(const Epetra_MultiVector& X,
00175                Epetra_MultiVector& Y) const;
00177   virtual int InvRowSums(Epetra_Vector& x) const
00178   {
00179     IFPACK_RETURN(-1); // not implemented
00180   }
00181 
00183   virtual int LeftScale(const Epetra_Vector& x)
00184   {
00185     IFPACK_RETURN(-1); // not implemented
00186   }
00187 
00189   virtual int InvColSums(Epetra_Vector& x) const
00190   {
00191     IFPACK_RETURN(-1); // not implemented
00192   }
00193 
00194 
00196   virtual int RightScale(const Epetra_Vector& x) 
00197   {
00198     IFPACK_RETURN(-1); // not implemented
00199   }
00200 
00202 
00204 
00206   virtual bool Filled() const
00207   {
00208     return(true);
00209   }
00210 
00212   /* Returns the quantity \f$ \| A \|_\infty\f$ such that
00213      \f[\| A \|_\infty = \max_{1\lei\len} \sum_{i=1}^m |a_{ij}| \f].
00214      */ 
00215   virtual double NormInf() const
00216   {
00217     return(A().NormInf());
00218   }
00219 
00221   /* Returns the quantity \f$ \| A \|_1\f$ such that
00222      \f[\| A \|_1= \max_{1\lej\len} \sum_{j=1}^n |a_{ij}| \f].
00223      */ 
00224   virtual double NormOne() const
00225   {
00226     return(A().NormOne());
00227   }
00228 
00229 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00230 
00231   virtual int NumGlobalNonzeros() const
00232   {
00233     if(A().RowMatrixRowMap().GlobalIndicesInt())
00234        return (int) NumGlobalNonzeros_;
00235     else
00236        throw "Ifpack_OverlappingRowMatrix::NumGlobalNonzeros: Global indices not int";
00237   }
00238 
00240   virtual int NumGlobalRows() const
00241   {
00242     return(A().NumGlobalRows());
00243   }
00244 
00246   virtual int NumGlobalCols() const
00247   {
00248     return(A().NumGlobalCols());
00249   }
00250 
00252   virtual int NumGlobalDiagonals() const
00253   {
00254     return(A().NumGlobalDiagonals());
00255   }
00256 #endif
00257 
00258   virtual long long NumGlobalNonzeros64() const
00259   {
00260     return(NumGlobalNonzeros_);
00261   }
00262 
00264   virtual long long NumGlobalRows64() const
00265   {
00266     return(A().NumGlobalRows64());
00267   }
00268 
00270   virtual long long NumGlobalCols64() const
00271   {
00272     return(A().NumGlobalCols64());
00273   }
00274 
00276   virtual long long NumGlobalDiagonals64() const
00277   {
00278     return(A().NumGlobalDiagonals64());
00279   }
00280 
00282   virtual int NumMyNonzeros() const
00283   {
00284     return(NumMyNonzeros_);
00285   }
00286 
00288   virtual int NumMyRows() const
00289   {
00290     return(NumMyRows_);
00291   }
00292 
00294   virtual int NumMyCols() const
00295   {
00296     return(NumMyCols_);
00297   }
00298 
00300   virtual int NumMyDiagonals() const
00301   {
00302     return(NumMyDiagonals_);
00303   }
00304 
00306   virtual bool LowerTriangular() const
00307   {
00308     return(A().LowerTriangular());
00309   }
00310 
00312   virtual bool UpperTriangular() const
00313   {
00314     return(A().UpperTriangular());
00315   }
00316 
00318   virtual const Epetra_Map & RowMatrixRowMap() const
00319   {
00320     return(*Map_);
00321   }
00322 
00324   virtual const Epetra_Map & RowMatrixColMap() const
00325   {
00326 #ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
00327     return(*colMap_);
00328 #else
00329 #   ifdef IFPACK_NODE_AWARE_CODE
00330     return(*colMap_);
00331 #   else
00332     return(*Map_);
00333 #   endif
00334 #endif
00335   }
00336 
00338   virtual const Epetra_Import * RowMatrixImporter() const
00339   {
00340     return(&*Importer_);
00341   }
00343 
00344   // following functions are required to derive Epetra_RowMatrix objects.
00345 
00347   int SetOwnership(bool ownership)
00348   {
00349     IFPACK_RETURN(-1);
00350   }
00351 
00353   int SetUseTranspose(bool UseTranspose_in)
00354   {
00355     UseTranspose_ = UseTranspose_in;
00356     return(0);
00357   }
00358 
00360   bool UseTranspose() const 
00361   {
00362     return(UseTranspose_);
00363   }
00364 
00366   bool HasNormInf() const
00367   {
00368     return(A().HasNormInf());
00369   }
00370 
00372   const Epetra_Comm & Comm() const
00373   {
00374     return(A().Comm());
00375   }
00376 
00378   const Epetra_Map & OperatorDomainMap() const 
00379   {
00380     return(*Map_);
00381   }
00382 
00384   const Epetra_Map & OperatorRangeMap() const 
00385   {
00386     return(*Map_);
00387   }
00389 
00390 const Epetra_BlockMap& Map() const;
00391 
00392 const char* Label() const{
00393   return(Label_.c_str());
00394 };
00395 
00396 int OverlapLevel() const
00397 {
00398   return(OverlapLevel_);
00399 }
00400 
00401 int ImportMultiVector(const Epetra_MultiVector& X,
00402                       Epetra_MultiVector& OvX,
00403                       Epetra_CombineMode CM = Insert);
00404 
00405 int ExportMultiVector(const Epetra_MultiVector& OvX,
00406                       Epetra_MultiVector& X,
00407                       Epetra_CombineMode CM = Add);
00408 #ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
00409   inline const Epetra_RowMatrix& A() const 
00410   {
00411     return(*Matrix_);
00412   }
00413 
00414   inline Epetra_CrsMatrix& B() const
00415   {
00416     return(*ExtMatrix_);
00417   }
00418 #else
00419 # ifdef IFPACK_NODE_AWARE_CODE
00420   inline const Epetra_RowMatrix& A() const 
00421   {
00422     return(*Matrix_);
00423   }
00424 
00425   inline Epetra_CrsMatrix& B() const
00426   {
00427     return(*ExtMatrix_);
00428   }
00429 # endif
00430 #endif
00431 
00432 private: 
00433 #ifndef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
00434 # ifndef IFPACK_NODE_AWARE_CODE
00435   inline const Epetra_RowMatrix& A() const 
00436   {
00437     return(*Matrix_);
00438   }
00439 
00440   inline Epetra_RowMatrix& B() const;
00441 # endif
00442 #endif
00443 
00444   int NumMyRows_;
00445   int NumMyCols_;
00446   int NumMyDiagonals_;
00447   int NumMyNonzeros_;
00448 
00449   long long NumGlobalNonzeros_;
00450   int MaxNumEntries_;
00451 
00452   int NumMyRowsA_;
00453   int NumMyRowsB_;
00454 
00455   bool UseTranspose_;
00456 
00457   Teuchos::RefCountPtr<const Epetra_Map> Map_;
00458 #ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
00459   const Epetra_Map *colMap_;
00460 #else
00461 # ifdef IFPACK_NODE_AWARE_CODE
00462   const Epetra_Map *colMap_;
00463 # endif
00464 #endif
00465   Teuchos::RefCountPtr<const Epetra_Import> Importer_;
00466 
00467   Teuchos::RefCountPtr<const Epetra_RowMatrix> Matrix_;
00468   Teuchos::RefCountPtr<Epetra_CrsMatrix> ExtMatrix_;
00469   Teuchos::RefCountPtr<Epetra_Map> ExtMap_;
00470   Teuchos::RefCountPtr<Epetra_Import> ExtImporter_;
00471 
00472   int OverlapLevel_;
00473   string Label_;
00474 
00475   template<typename int_type>
00476   void BuildMap(int OverlapLevel_in);
00477 
00478 }; // class Ifpack_OverlappingRowMatrix
00479 
00480 #endif // IFPACK_OVERLAPPINGROWMATRIX_H
 All Classes Files Functions Variables Enumerations Friends