Ifpack2 Templated Preconditioning Package Version 1.0
Ifpack2_ReorderFilter_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_REORDERFILTER_DECL_HPP
00031 #define IFPACK2_REORDERFILTER_DECL_HPP
00032 
00033 #include "Ifpack2_ConfigDefs.hpp"
00034 #include "Tpetra_ConfigDefs.hpp"
00035 #include "Tpetra_RowMatrix.hpp"
00036 #include "Teuchos_RefCountPtr.hpp"
00037 #include "Teuchos_ScalarTraits.hpp"
00038 
00039 #ifdef HAVE_IFPACK2_ZOLTAN2
00040 #include "Zoltan2_config.h"
00041 #include "Zoltan2_OrderingSolution.hpp"
00042 #endif
00043 
00044 
00045 namespace Ifpack2 {
00047 
00068 template<class MatrixType>
00069 class ReorderFilter : virtual public Tpetra::RowMatrix<typename MatrixType::scalar_type,typename MatrixType::local_ordinal_type,typename MatrixType::global_ordinal_type,typename MatrixType::node_type> {
00070   
00071 public:
00072   typedef typename MatrixType::scalar_type Scalar;
00073   typedef typename MatrixType::local_ordinal_type LocalOrdinal;
00074   typedef typename MatrixType::global_ordinal_type GlobalOrdinal;
00075   typedef typename MatrixType::node_type Node;
00076   typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType magnitudeType;
00077   
00078 
00079 public:
00081 
00082 
00084 #ifdef HAVE_IFPACK2_ZOLTAN2
00085   explicit ReorderFilter(const Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > & Matrix,
00086        const Teuchos::RCP<const Zoltan2::OrderingSolution<GlobalOrdinal,LocalOrdinal> > & Reordering);
00087 #endif
00088 
00089   virtual ~ReorderFilter();
00090 
00092 
00094 
00095 
00097   virtual const Teuchos::RCP<const Teuchos::Comm<int> > & getComm() const;
00098 
00100   virtual Teuchos::RCP<Node> getNode() const;
00101 
00103   virtual const Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > & getRowMap() const;
00104 
00106   virtual const Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > & getColMap() const;
00107 
00109   virtual const Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > & getDomainMap() const;
00110 
00112   virtual const Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > & getRangeMap() const;
00113 
00115   virtual Teuchos::RCP<const Tpetra::RowGraph<LocalOrdinal,GlobalOrdinal,Node> > getGraph() const;
00116 
00118   virtual global_size_t getGlobalNumRows() const;
00119 
00121   virtual global_size_t getGlobalNumCols() const;
00122 
00124   virtual size_t getNodeNumRows() const;
00125 
00127   virtual size_t getNodeNumCols() const;
00128 
00130   virtual GlobalOrdinal getIndexBase() const;
00131 
00133   virtual global_size_t getGlobalNumEntries() const;
00134 
00136   virtual size_t getNodeNumEntries() const;
00137   
00139 
00140   virtual size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const;
00141   
00143 
00144   virtual size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const;
00145   
00147   virtual global_size_t getGlobalNumDiags() const;
00148   
00150   virtual size_t getNodeNumDiags() const;
00151   
00153   virtual size_t getGlobalMaxNumRowEntries() const;
00154   
00156   virtual size_t getNodeMaxNumRowEntries() const;
00157   
00159   virtual bool hasColMap() const;
00160   
00162   virtual bool isLowerTriangular() const;
00163   
00165   virtual bool isUpperTriangular() const;
00166   
00168   virtual bool isLocallyIndexed() const;
00169   
00171   virtual bool isGloballyIndexed() const;
00172   
00174   virtual bool isFillComplete() const;
00175 
00177   virtual bool supportsRowViews() const;  
00178 
00180   
00182 
00183   
00185 
00195   virtual void getGlobalRowCopy(GlobalOrdinal GlobalRow,
00196         const Teuchos::ArrayView<GlobalOrdinal> &Indices,
00197         const Teuchos::ArrayView<Scalar> &Values,
00198         size_t &NumEntries) const;
00199   
00201 
00211   virtual void getLocalRowCopy(LocalOrdinal DropRow, 
00212              const Teuchos::ArrayView<LocalOrdinal> &Indices, 
00213              const Teuchos::ArrayView<Scalar> &Values,
00214              size_t &NumEntries) const ;
00215   
00217 
00225   virtual void getGlobalRowView(GlobalOrdinal GlobalRow, 
00226         Teuchos::ArrayView<const GlobalOrdinal> &indices, 
00227         Teuchos::ArrayView<const Scalar> &values) const;
00228   
00230 
00239   virtual void getLocalRowView(LocalOrdinal LocalRow, 
00240              Teuchos::ArrayView<const LocalOrdinal> &indices, 
00241              Teuchos::ArrayView<const Scalar> &values) const;
00242   
00244 
00246   virtual void getLocalDiagCopy(Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &diag) const;
00247   
00249   
00251 
00252   
00262   virtual void leftScale(const Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& x);
00263   
00273   virtual void rightScale(const Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& x);
00274   
00276 
00279   virtual typename Teuchos::ScalarTraits<Scalar>::magnitudeType getFrobeniusNorm() const;
00280 
00282 
00289   virtual void apply(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &X, 
00290          Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &Y, 
00291          Teuchos::ETransp mode = Teuchos::NO_TRANS, 
00292          Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
00293          Scalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const;
00294   
00296   virtual bool hasTransposeApply() const;
00297 
00298 
00300   virtual void permuteOriginalToReordered(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &originalX, 
00301             Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &reorderedY) const;
00302   
00304   virtual void permuteReorderedToOriginal(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &reorderedX, 
00305             Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &originalY) const;
00306 
00307   
00309   
00311 
00312   
00314 
00323   TPETRA_DEPRECATED virtual void getGlobalRowView(GlobalOrdinal GlobalRow, 
00324               Teuchos::ArrayRCP<const GlobalOrdinal> &indices,
00325               Teuchos::ArrayRCP<const Scalar>        &values) const;
00326   
00328 
00337   TPETRA_DEPRECATED virtual void getLocalRowView(LocalOrdinal DropRow,
00338              Teuchos::ArrayRCP<const LocalOrdinal> &indices,
00339              Teuchos::ArrayRCP<const Scalar>       &values) const;  
00341 
00342   
00343 private:
00344 
00346   Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > A_;
00348   Teuchos::ArrayRCP<LocalOrdinal> perm_;        /* Original  -> Reordered  */
00349   Teuchos::ArrayRCP<LocalOrdinal> reverseperm_; /* Reordered -> Original */
00350 
00352   mutable Teuchos::Array<LocalOrdinal> Indices_;
00354   mutable Teuchos::Array<Scalar> Values_;
00355 
00356 };// class ReorderFilter
00357 
00358 }// namespace Ifpack2
00359 
00360 #endif /* IFPACK2_REORDERFILTER_DECL_HPP */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends