Ifpack2 Templated Preconditioning Package Version 1.0
Ifpack2_OverlappingRowMatrix_decl.hpp
00001 /*@HEADER
00002 // ***********************************************************************
00003 // 
00004 //       Ifpack2: Tempated Object-Oriented Algebraic Preconditioner Package
00005 //                 Copyright (2009) 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 IFPACK2_OVERLAPPINGROWMATRIX_DECL_HPP
00031 #define IFPACK2_OVERLAPPINGROWMATRIX_DECL_HPP
00032 
00033 #include "Ifpack2_ConfigDefs.hpp"
00034 #include "Tpetra_ConfigDefs.hpp"
00035 #include "Tpetra_RowMatrix.hpp"
00036 #include "Tpetra_Import.hpp"
00037 #include "Tpetra_Map.hpp"
00038 #include "Teuchos_RefCountPtr.hpp"
00039 
00040 namespace Ifpack2 {
00041 
00043 
00046 template<class MatrixType>
00047 class  OverlappingRowMatrix : virtual public Tpetra::RowMatrix<typename MatrixType::scalar_type,typename MatrixType::local_ordinal_type,typename MatrixType::global_ordinal_type,typename MatrixType::node_type> {
00048 
00049 public:
00050 
00051   typedef typename MatrixType::scalar_type Scalar;
00052   typedef typename MatrixType::local_ordinal_type LocalOrdinal;
00053   typedef typename MatrixType::global_ordinal_type GlobalOrdinal;
00054   typedef typename MatrixType::node_type Node;
00055   typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType magnitudeType;
00056 
00058 
00060   OverlappingRowMatrix(const Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> >& Matrix_in,
00061            int OverlapLevel_in);
00062   
00064   OverlappingRowMatrix(const Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > & Matrix_in,          
00065            int OverlapLevel_in, int subdomainID);
00066 
00068   ~OverlappingRowMatrix();
00070 
00071 
00073 
00074   
00076   virtual const Teuchos::RCP<const Teuchos::Comm<int> > & getComm() const;
00077   
00079   virtual Teuchos::RCP<Node> getNode() const;
00080   
00082   virtual const Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > & getRowMap() const;
00083   
00085   virtual const Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > & getColMap() const;
00086 
00088   virtual const Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > & getDomainMap() const;
00089   
00091   virtual const Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > & getRangeMap() const;
00092   
00094   virtual Teuchos::RCP<const Tpetra::RowGraph<LocalOrdinal,GlobalOrdinal,Node> > getGraph() const;
00095   
00097   virtual global_size_t getGlobalNumRows() const;
00098   
00100   virtual global_size_t getGlobalNumCols() const;
00101   
00103   virtual size_t getNodeNumRows() const;
00104   
00106   virtual size_t getNodeNumCols() const;
00107   
00109   virtual GlobalOrdinal getIndexBase() const;
00110   
00112   virtual global_size_t getGlobalNumEntries() const;
00113   
00115   virtual size_t getNodeNumEntries() const;
00116   
00118 
00119   virtual size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const;
00120   
00122 
00123   virtual size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const;
00124   
00126   virtual global_size_t getGlobalNumDiags() const;
00127   
00129   virtual size_t getNodeNumDiags() const;
00130   
00132   virtual size_t getGlobalMaxNumRowEntries() const;
00133   
00135   virtual size_t getNodeMaxNumRowEntries() const;
00136   
00138   virtual bool hasColMap() const;
00139   
00141   virtual bool isLowerTriangular() const;
00142   
00144   virtual bool isUpperTriangular() const;
00145   
00147   virtual bool isLocallyIndexed() const;
00148   
00150   virtual bool isGloballyIndexed() const;
00151   
00153   virtual bool isFillComplete() const;
00154 
00156   virtual bool supportsRowViews() const;  
00157 
00159   
00161 
00162   
00164 
00174   virtual void getGlobalRowCopy(GlobalOrdinal GlobalRow,
00175         const Teuchos::ArrayView<GlobalOrdinal> &Indices,
00176         const Teuchos::ArrayView<Scalar> &Values,
00177         size_t &NumEntries) const;
00178   
00180 
00190   virtual void getLocalRowCopy(LocalOrdinal LocalRow, 
00191              const Teuchos::ArrayView<LocalOrdinal> &Indices, 
00192              const Teuchos::ArrayView<Scalar> &Values,
00193              size_t &NumEntries) const;
00194   
00196 
00205   virtual void getGlobalRowView(GlobalOrdinal GlobalRow, 
00206         Teuchos::ArrayView<const GlobalOrdinal> &indices, 
00207         Teuchos::ArrayView<const Scalar> &values) const;
00208   
00210 
00219   virtual void getLocalRowView(LocalOrdinal LocalRow, 
00220              Teuchos::ArrayView<const LocalOrdinal> &indices, 
00221              Teuchos::ArrayView<const Scalar> &values) const;
00222   
00224 
00226   virtual void getLocalDiagCopy(Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &diag) const;
00227   
00229   
00231 
00232   
00242   virtual void leftScale(const Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& x);
00243   
00253   virtual void rightScale(const Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& x);
00254   
00256 
00259   virtual typename Teuchos::ScalarTraits<Scalar>::magnitudeType getFrobeniusNorm() const;
00260   
00262 
00269   virtual void apply(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &X, 
00270          Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &Y, 
00271          Teuchos::ETransp mode = Teuchos::NO_TRANS, 
00272          Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
00273          Scalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const;
00274   
00276   virtual bool hasTransposeApply() const;
00277 
00278   virtual void importMultiVector(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &X, 
00279          Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &OvX, 
00280          Tpetra::CombineMode CM = Tpetra::INSERT);
00281 
00282   virtual void exportMultiVector(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &OvX, 
00283          Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &X, 
00284          Tpetra::CombineMode CM = Tpetra::ADD);
00286 
00287 
00288 private: 
00289 
00290   // Original matrix object
00291   Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > A_;
00292 
00293   size_t NumMyRows_;
00294   size_t NumMyCols_;
00295   size_t NumMyDiagonals_;
00296   size_t NumMyNonzeros_;
00297 
00298   Tpetra::global_size_t NumGlobalRows_;
00299   Tpetra::global_size_t NumGlobalNonzeros_;
00300   size_t MaxNumEntries_;
00301 
00302   size_t NumMyRowsA_;
00303   size_t NumMyRowsB_;
00304   int OverlapLevel_;
00305 
00306   // Subcommunicator stuff
00307   bool UseSubComm_;
00308   int subdomainID_;
00309 
00310   // Wrapper matrix objects
00311   Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >    RowMap_;
00312   Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >    ColMap_;
00313   Teuchos::RCP<const Tpetra::Import<LocalOrdinal,GlobalOrdinal,Node> > Importer_;
00314 
00315   // External matrix objects
00316   Teuchos::RCP<Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > ExtMatrix_;
00317   Teuchos::RCP<Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >              ExtMap_;
00318   Teuchos::RCP<Tpetra::Import<LocalOrdinal,GlobalOrdinal,Node> >           ExtImporter_;
00319 
00321   mutable Teuchos::Array<LocalOrdinal> Indices_;
00323   mutable Teuchos::Array<Scalar> Values_;
00324 
00325 }; // class OverlappingRowMatrix
00326 
00327 } // namespace Ifpack2
00328 
00329 #endif // IFPACK2_OVERLAPPINGROWMATRIX_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends