IFPACK  Development
 All Classes Files Functions Variables Enumerations Friends
Ifpack_NodeFilter.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_NODEFILTER_H
00044 #define IFPACK_NODEFILTER_H
00045 
00046 #ifdef IFPACK_NODE_AWARE_CODE
00047 
00048 #include "Ifpack_ConfigDefs.h"
00049 #ifdef HAVE_MPI
00050 #include "Epetra_MpiComm.h"
00051 #else
00052 #include "Epetra_SerialComm.h"
00053 #endif
00054 #include "Epetra_RowMatrix.h"
00055 #include "Epetra_CrsMatrix.h"
00056 #include "Epetra_IntVector.h"
00057 #include "Teuchos_RCP.hpp"
00058 #include "Ifpack_OverlappingRowMatrix.h"
00059 class Epetra_Map;
00060 class Epetra_MultiVector;
00061 class Epetra_Vector;
00062 class Epetra_Import;
00063 class Epetra_BlockMap;
00064 
00066 
00100 class Ifpack_NodeFilter : public virtual Epetra_RowMatrix {
00101 
00102 public:
00104 
00105   Ifpack_NodeFilter(const Teuchos::RCP<const Epetra_RowMatrix>& Matrix, int nodeID);
00106   //Ifpack_NodeFilter(const Teuchos::RCP<const Epetra_RowMatrix>& Matrix,const Epetra_Comm *);
00107 
00109 
00110 
00111   ~Ifpack_NodeFilter(){
00112     if(Ac_LIDMap_) delete [] Ac_LIDMap_;
00113     if(Bc_LIDMap_) delete [] Bc_LIDMap_;
00114     if(Ar_LIDMap_) delete [] Ar_LIDMap_;
00115     if(Br_LIDMap_) delete [] Br_LIDMap_;
00116     if(tempX_) delete [] tempX_;
00117     if(tempY_) delete [] tempY_;
00118     if(ImportVector_) delete ImportVector_; 
00119 
00120   };
00122 
00124 
00126 
00134   virtual int NumMyRowEntries(int MyRow, int & NumEntries) const
00135   {
00136     NumEntries = NumEntries_[MyRow];
00137     return(0);
00138   }
00139 
00141   virtual int MaxNumEntries() const
00142   {
00143     return(MaxNumEntries_);
00144   }
00145 
00147 
00161   virtual inline int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
00162 
00164 
00170   virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
00172 
00174 
00176 
00186   virtual int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const
00187   {
00188     if (TransA == true) {
00189       IFPACK_CHK_ERR(-1);
00190     }
00191 
00192     IFPACK_CHK_ERR(Apply(X,Y));
00193     return(0);
00194   }
00195 
00197   virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector& X, 
00198             Epetra_MultiVector& Y) const
00199   {
00200     IFPACK_RETURN(-1); // not implemented 
00201   }
00202 
00203   virtual int Apply(const Epetra_MultiVector& X,
00204             Epetra_MultiVector& Y) const;
00205 
00206   virtual int ApplyInverse(const Epetra_MultiVector& X,
00207                Epetra_MultiVector& Y) const;
00209   virtual int InvRowSums(Epetra_Vector& x) const
00210   {
00211     IFPACK_RETURN(-1); // not implemented
00212   }
00213 
00215   virtual int LeftScale(const Epetra_Vector& x)
00216   {
00217     IFPACK_RETURN(-1); // not implemented
00218   }
00219 
00221   virtual int InvColSums(Epetra_Vector& x) const
00222   {
00223     IFPACK_RETURN(-1); // not implemented
00224   }
00225 
00226 
00228   virtual int RightScale(const Epetra_Vector& x) 
00229   {
00230     IFPACK_RETURN(-1); // not implemented
00231   }
00232 
00234 
00236 
00238   virtual bool Filled() const
00239   {
00240     return true;
00241   }
00242 
00244   /* Returns the quantity \f$ \| A \|_\infty\f$ such that
00245      \f[\| A \|_\infty = \max_{1\lei\len} \sum_{i=1}^m |a_{ij}| \f].
00246      */ 
00247   virtual double NormInf() const
00248   {
00249     return(-1.0);
00250   }
00251 
00253   /* Returns the quantity \f$ \| A \|_1\f$ such that
00254      \f[\| A \|_1= \max_{1\lej\len} \sum_{j=1}^n |a_{ij}| \f].
00255      */ 
00256   virtual double NormOne() const
00257   {
00258     IFPACK_RETURN(-1.0);
00259   }
00260 
00262   virtual int NumGlobalNonzeros() const
00263   {
00264     return(NumGlobalNonzeros_);
00265   }
00266 
00268   virtual int NumGlobalRows() const
00269   {
00270     return(NumGlobalRows_);
00271   }
00272 
00274   virtual int NumGlobalCols() const
00275   {
00276     return(NumGlobalRows_);
00277   }
00278 
00280   virtual int NumGlobalDiagonals() const
00281   {
00282     return(NumGlobalRows_);
00283   }
00284 
00286   virtual int NumMyNonzeros() const
00287   {
00288     return(NumMyNonzeros_);
00289   }
00290 
00292   virtual int NumMyRows() const
00293   {
00294     return(NumMyRows_);
00295   }
00296 
00298   virtual int NumMyCols() const
00299   {
00300     return(NumMyCols_);
00301   }
00302 
00304   virtual int NumMyDiagonals() const
00305   {
00306     return(NumMyRows_);
00307   }
00308 
00310   virtual bool LowerTriangular() const
00311   {
00312     return(Matrix_->LowerTriangular());
00313   }
00314 
00316   virtual bool UpperTriangular() const
00317   {
00318     return(Matrix_->UpperTriangular());
00319   }
00320 
00322   virtual const Epetra_Map & RowMatrixRowMap() const
00323   {
00324     return(*Map_);
00325   }
00326 
00328   virtual const Epetra_Map & RowMatrixColMap() const
00329   {
00330     return(*colMap_);
00331   }
00332 
00334   virtual const Epetra_Import * RowMatrixImporter() const
00335   {
00336     return(&*Importer_);
00337   }
00339 
00340   virtual const Epetra_Import* Importer() const {return(&*Importer_);}
00341 
00342   virtual const Epetra_Export* Exporter() const {return(&*Exporter_);}
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(false);
00369   }
00370 
00372   const Epetra_Comm & Comm() const
00373   {
00374     return(*SubComm_);
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_);
00394 };
00395 
00396 private:
00397   void UpdateImportVector(int NumVectors) const;
00398   void UpdateExportVector(int NumVectors) const;
00399 
00401   Teuchos::RCP<const Epetra_RowMatrix> Matrix_;
00402   const Ifpack_OverlappingRowMatrix* ovA_;
00403 #ifdef HAVE_MPI
00404 
00405   Teuchos::RCP<Epetra_MpiComm> SubComm_;
00406   MPI_Comm nodeMPIComm_;
00407 #else
00408 
00409   Teuchos::RCP<Epetra_SerialComm> SubComm_;
00410 #endif
00411 
00412   Teuchos::RCP<Epetra_Map> Map_;
00414   Teuchos::RCP<Epetra_Map> colMap_;
00416   int NumMyRows_;
00418   int NumMyCols_;
00420   int NumMyNonzeros_;
00422   int NumGlobalRows_;
00424   int NumGlobalNonzeros_;
00426   int MaxNumEntries_;
00428   int MaxNumEntriesA_;
00430   std::vector<int> NumEntries_;
00432   mutable std::vector<int> Indices_;
00434   mutable std::vector<double> Values_;
00436   bool UseTranspose_;
00438   char Label_[80];
00439   Teuchos::RCP<Epetra_Vector> Diagonal_;
00440   double NormOne_;
00441   double NormInf_;
00442 
00444   int* Ac_LIDMap_;
00445   int* Bc_LIDMap_;
00446   int* Ar_LIDMap_;
00447   int* Br_LIDMap_;
00448 
00450   const Epetra_CrsMatrix* Acrs_;
00451 
00452   int NumMyRowsA_;
00453   int NumMyColsA_;
00454   double *tempX_,*tempY_;
00455   int NumMyRowsB_;
00456   
00457   //mutable Teuchos::RCP<Epetra_MultiVector> ImportVector_;
00458   //mutable Teuchos::RCP<Epetra_MultiVector> ExportVector_;
00459   mutable Epetra_MultiVector* ExportVector_;
00460   mutable Epetra_MultiVector* ImportVector_;
00461   Teuchos::RCP<Epetra_Import> Importer_;
00462   Teuchos::RCP<Epetra_Export> Exporter_;
00463 
00464 };
00465 #endif //ifdef IFPACK_NODE_AWARE_CODE
00466 #endif /* IFPACK_NODEFILTER_H */
 All Classes Files Functions Variables Enumerations Friends