Ifpack_NodeFilter.h

Go to the documentation of this file.
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_NODEFILTER_H
00031 #define IFPACK_NODEFILTER_H
00032 
00033 #ifdef IFPACK_NODE_AWARE_CODE
00034 
00035 #include "Ifpack_ConfigDefs.h"
00036 #ifdef HAVE_MPI
00037 #include "Epetra_MpiComm.h"
00038 #else
00039 #include "Epetra_SerialComm.h"
00040 #endif
00041 #include "Epetra_RowMatrix.h"
00042 #include "Epetra_CrsMatrix.h"
00043 #include "Epetra_IntVector.h"
00044 #include "Teuchos_RCP.hpp"
00045 #include "Ifpack_OverlappingRowMatrix.h"
00046 class Epetra_Map;
00047 class Epetra_MultiVector;
00048 class Epetra_Vector;
00049 class Epetra_Import;
00050 class Epetra_BlockMap;
00051 
00053 
00087 class Ifpack_NodeFilter : public virtual Epetra_RowMatrix {
00088 
00089 public:
00091 
00092   Ifpack_NodeFilter(const Teuchos::RCP<const Epetra_RowMatrix>& Matrix, int nodeID);
00093   //Ifpack_NodeFilter(const Teuchos::RCP<const Epetra_RowMatrix>& Matrix,const Epetra_Comm *);
00094 
00096 
00097 
00098   ~Ifpack_NodeFilter(){
00099     if(Ac_LIDMap_) delete [] Ac_LIDMap_;
00100     if(Bc_LIDMap_) delete [] Bc_LIDMap_;
00101     if(Ar_LIDMap_) delete [] Ar_LIDMap_;
00102     if(Br_LIDMap_) delete [] Br_LIDMap_;
00103     if(tempX_) delete [] tempX_;
00104     if(tempY_) delete [] tempY_;
00105     if(ImportVector_) delete ImportVector_; 
00106 
00107   };
00109 
00111 
00113 
00121   virtual int NumMyRowEntries(int MyRow, int & NumEntries) const
00122   {
00123     NumEntries = NumEntries_[MyRow];
00124     return(0);
00125   }
00126 
00128   virtual int MaxNumEntries() const
00129   {
00130     return(MaxNumEntries_);
00131   }
00132 
00134 
00148   virtual inline int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
00149 
00151 
00157   virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
00159 
00161 
00163 
00173   virtual int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const
00174   {
00175     if (TransA == true) {
00176       IFPACK_CHK_ERR(-1);
00177     }
00178 
00179     IFPACK_CHK_ERR(Apply(X,Y));
00180     return(0);
00181   }
00182 
00184   virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector& X, 
00185         Epetra_MultiVector& Y) const
00186   {
00187     IFPACK_RETURN(-1); // not implemented 
00188   }
00189 
00190   virtual int Apply(const Epetra_MultiVector& X,
00191         Epetra_MultiVector& Y) const;
00192 
00193   virtual int ApplyInverse(const Epetra_MultiVector& X,
00194          Epetra_MultiVector& Y) const;
00196   virtual int InvRowSums(Epetra_Vector& x) const
00197   {
00198     IFPACK_RETURN(-1); // not implemented
00199   }
00200 
00202   virtual int LeftScale(const Epetra_Vector& x)
00203   {
00204     IFPACK_RETURN(-1); // not implemented
00205   }
00206 
00208   virtual int InvColSums(Epetra_Vector& x) const
00209   {
00210     IFPACK_RETURN(-1); // not implemented
00211   }
00212 
00213 
00215   virtual int RightScale(const Epetra_Vector& x) 
00216   {
00217     IFPACK_RETURN(-1); // not implemented
00218   }
00219 
00221 
00223 
00225   virtual bool Filled() const
00226   {
00227     return true;
00228   }
00229 
00231   /* Returns the quantity \f$ \| A \|_\infty\f$ such that
00232      \f[\| A \|_\infty = \max_{1\lei\len} \sum_{i=1}^m |a_{ij}| \f].
00233      */ 
00234   virtual double NormInf() const
00235   {
00236     return(-1.0);
00237   }
00238 
00240   /* Returns the quantity \f$ \| A \|_1\f$ such that
00241      \f[\| A \|_1= \max_{1\lej\len} \sum_{j=1}^n |a_{ij}| \f].
00242      */ 
00243   virtual double NormOne() const
00244   {
00245     IFPACK_RETURN(-1.0);
00246   }
00247 
00249   virtual int NumGlobalNonzeros() const
00250   {
00251     return(NumGlobalNonzeros_);
00252   }
00253 
00255   virtual int NumGlobalRows() const
00256   {
00257     return(NumGlobalRows_);
00258   }
00259 
00261   virtual int NumGlobalCols() const
00262   {
00263     return(NumGlobalRows_);
00264   }
00265 
00267   virtual int NumGlobalDiagonals() const
00268   {
00269     return(NumGlobalRows_);
00270   }
00271 
00273   virtual int NumMyNonzeros() const
00274   {
00275     return(NumMyNonzeros_);
00276   }
00277 
00279   virtual int NumMyRows() const
00280   {
00281     return(NumMyRows_);
00282   }
00283 
00285   virtual int NumMyCols() const
00286   {
00287     return(NumMyCols_);
00288   }
00289 
00291   virtual int NumMyDiagonals() const
00292   {
00293     return(NumMyRows_);
00294   }
00295 
00297   virtual bool LowerTriangular() const
00298   {
00299     return(Matrix_->LowerTriangular());
00300   }
00301 
00303   virtual bool UpperTriangular() const
00304   {
00305     return(Matrix_->UpperTriangular());
00306   }
00307 
00309   virtual const Epetra_Map & RowMatrixRowMap() const
00310   {
00311     return(*Map_);
00312   }
00313 
00315   virtual const Epetra_Map & RowMatrixColMap() const
00316   {
00317     return(*colMap_);
00318   }
00319 
00321   virtual const Epetra_Import * RowMatrixImporter() const
00322   {
00323     return(&*Importer_);
00324   }
00326 
00327   virtual const Epetra_Import* Importer() const {return(&*Importer_);}
00328 
00329   virtual const Epetra_Export* Exporter() const {return(&*Exporter_);}
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(false);
00356   }
00357 
00359   const Epetra_Comm & Comm() const
00360   {
00361     return(*SubComm_);
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_);
00381 };
00382 
00383 private:
00384   void UpdateImportVector(int NumVectors) const;
00385   void UpdateExportVector(int NumVectors) const;
00386 
00388   Teuchos::RCP<const Epetra_RowMatrix> Matrix_;
00389   const Ifpack_OverlappingRowMatrix* ovA_;
00390 #ifdef HAVE_MPI
00391 
00392   Teuchos::RCP<Epetra_MpiComm> SubComm_;
00393   MPI_Comm nodeMPIComm_;
00394 #else
00395 
00396   Teuchos::RCP<Epetra_SerialComm> SubComm_;
00397 #endif
00398 
00399   Teuchos::RCP<Epetra_Map> Map_;
00401   Teuchos::RCP<Epetra_Map> colMap_;
00403   int NumMyRows_;
00405   int NumMyCols_;
00407   int NumMyNonzeros_;
00409   int NumGlobalRows_;
00411   int NumGlobalNonzeros_;
00413   int MaxNumEntries_;
00415   int MaxNumEntriesA_;
00417   std::vector<int> NumEntries_;
00419   mutable std::vector<int> Indices_;
00421   mutable std::vector<double> Values_;
00423   bool UseTranspose_;
00425   char Label_[80];
00426   Teuchos::RCP<Epetra_Vector> Diagonal_;
00427   double NormOne_;
00428   double NormInf_;
00429 
00431   int* Ac_LIDMap_;
00432   int* Bc_LIDMap_;
00433   int* Ar_LIDMap_;
00434   int* Br_LIDMap_;
00435 
00437   const Epetra_CrsMatrix* Acrs_;
00438 
00439   int NumMyRowsA_;
00440   int NumMyColsA_;
00441   double *tempX_,*tempY_;
00442   int NumMyRowsB_;
00443   
00444   //mutable Teuchos::RCP<Epetra_MultiVector> ImportVector_;
00445   //mutable Teuchos::RCP<Epetra_MultiVector> ExportVector_;
00446   mutable Epetra_MultiVector* ExportVector_;
00447   mutable Epetra_MultiVector* ImportVector_;
00448   Teuchos::RCP<Epetra_Import> Importer_;
00449   Teuchos::RCP<Epetra_Export> Exporter_;
00450 
00451 };
00452 #endif //ifdef IFPACK_NODE_AWARE_CODE
00453 #endif /* IFPACK_NODEFILTER_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 10:05:35 2011 for Ifpack Package Browser (Single Doxygen Collection) by  doxygen 1.6.3