Ifpack2 Templated Preconditioning Package Version 1.0
Ifpack2_SingletonFilter_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_SINGLETONFILTER_DECL_HPP
00031 #define IFPACK2_SINGLETONFILTER_DECL_HPP
00032 
00033 #include "Ifpack2_ConfigDefs.hpp"
00034 #include "Tpetra_ConfigDefs.hpp"
00035 #include "Tpetra_RowMatrix.hpp"
00036 #include "Tpetra_MultiVector.hpp"
00037 #include "Teuchos_RefCountPtr.hpp"
00038 #include "Teuchos_ScalarTraits.hpp"
00039 #include <vector>
00040 
00041 
00042 namespace Ifpack2 {
00044 template<class MatrixType>
00045 class  SingletonFilter : virtual public Tpetra::RowMatrix<typename MatrixType::scalar_type,typename MatrixType::local_ordinal_type,typename MatrixType::global_ordinal_type,typename MatrixType::node_type> {
00046   
00047 public:
00048   typedef typename MatrixType::scalar_type Scalar;
00049   typedef typename MatrixType::local_ordinal_type LocalOrdinal;
00050   typedef typename MatrixType::global_ordinal_type GlobalOrdinal;
00051   typedef typename MatrixType::node_type Node;
00052   typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType magnitudeType;
00053   
00054 
00055 public:
00057 
00058 
00060   explicit SingletonFilter(const Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> >& Matrix);
00061   
00063   virtual ~SingletonFilter();
00064 
00066 
00068 
00069 
00071   virtual const Teuchos::RCP<const Teuchos::Comm<int> > & getComm() const;
00072 
00074   virtual Teuchos::RCP<Node> getNode() const;
00075 
00077   virtual const Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > & getRowMap() const;
00078 
00080   virtual const Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > & getColMap() const;
00081 
00083   virtual const Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > & getDomainMap() const;
00084 
00086   virtual const Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > & getRangeMap() const;
00087 
00089   virtual Teuchos::RCP<const Tpetra::RowGraph<LocalOrdinal,GlobalOrdinal,Node> > getGraph() const;
00090 
00092   virtual global_size_t getGlobalNumRows() const;
00093 
00095   virtual global_size_t getGlobalNumCols() const;
00096 
00098   virtual size_t getNodeNumRows() const;
00099 
00101   virtual size_t getNodeNumCols() const;
00102 
00104   virtual GlobalOrdinal getIndexBase() const;
00105 
00107   virtual global_size_t getGlobalNumEntries() const;
00108 
00110   virtual size_t getNodeNumEntries() const;
00111   
00113 
00114   virtual size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const;
00115   
00117 
00118   virtual size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const;
00119   
00121   virtual global_size_t getGlobalNumDiags() const;
00122   
00124   virtual size_t getNodeNumDiags() const;
00125   
00127   virtual size_t getGlobalMaxNumRowEntries() const;
00128   
00130   virtual size_t getNodeMaxNumRowEntries() const;
00131   
00133   virtual bool hasColMap() const;
00134   
00136   virtual bool isLowerTriangular() const;
00137   
00139   virtual bool isUpperTriangular() const;
00140   
00142   virtual bool isLocallyIndexed() const;
00143   
00145   virtual bool isGloballyIndexed() const;
00146   
00148   virtual bool isFillComplete() const;
00149   
00151   virtual bool supportsRowViews() const;  
00152 
00154   
00156 
00157   
00159 
00169   virtual void getGlobalRowCopy(GlobalOrdinal GlobalRow,
00170         const Teuchos::ArrayView<GlobalOrdinal> &Indices,
00171         const Teuchos::ArrayView<Scalar> &Values,
00172         size_t &NumEntries) const;
00173   
00175 
00185   virtual void getLocalRowCopy(LocalOrdinal LocalRow, 
00186              const Teuchos::ArrayView<LocalOrdinal> &Indices, 
00187              const Teuchos::ArrayView<Scalar> &Values,
00188              size_t &NumEntries) const ;
00189   
00191 
00200   virtual void getGlobalRowView(GlobalOrdinal GlobalRow, 
00201         Teuchos::ArrayView<const GlobalOrdinal> &indices, 
00202         Teuchos::ArrayView<const Scalar> &values) const;
00203   
00205 
00214   virtual void getLocalRowView(LocalOrdinal LocalRow, 
00215              Teuchos::ArrayView<const LocalOrdinal> &indices, 
00216              Teuchos::ArrayView<const Scalar> &values) const;
00217   
00219 
00221   virtual void getLocalDiagCopy(Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &diag) const;
00222   
00224   
00226 
00227   
00237   virtual void leftScale(const Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& x);
00238   
00248   virtual void rightScale(const Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& x);
00249   
00251 
00254   virtual typename Teuchos::ScalarTraits<Scalar>::magnitudeType getFrobeniusNorm() const;
00255 
00257 
00262   virtual void apply(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &X, 
00263          Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &Y, 
00264          Teuchos::ETransp mode = Teuchos::NO_TRANS, 
00265          Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
00266          Scalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const;
00267   
00269   virtual bool hasTransposeApply() const;
00270   
00272   virtual void SolveSingletons(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& RHS, 
00273           Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& LHS);
00274 
00276   virtual void CreateReducedRHS(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& LHS,
00277            const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& RHS, 
00278            Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& ReducedRHS);
00279 
00281   virtual void UpdateLHS(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& ReducedLHS,
00282     Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& LHS);
00283   
00284 
00286   
00288 
00289   
00291 
00300   TPETRA_DEPRECATED virtual void getGlobalRowView(GlobalOrdinal GlobalRow, 
00301               Teuchos::ArrayRCP<const GlobalOrdinal> &indices,
00302               Teuchos::ArrayRCP<const Scalar>        &values) const;
00303   
00305 
00314   TPETRA_DEPRECATED virtual void getLocalRowView(LocalOrdinal LocalRow,
00315              Teuchos::ArrayRCP<const LocalOrdinal> &indices,
00316              Teuchos::ArrayRCP<const Scalar>       &values) const;  
00318 
00319   
00320 private:
00321 
00323   Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > A_;
00325   Teuchos::RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > ReducedMap_;
00327   Teuchos::RCP<Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > Diagonal_;
00329   size_t NumSingletons_;
00331   std::vector<LocalOrdinal> SingletonIndex_;
00333   std::vector<LocalOrdinal> Reorder_;
00335   std::vector<LocalOrdinal> InvReorder_; 
00337   size_t NumRows_;
00339   size_t NumNonzeros_;
00341   size_t MaxNumEntries_;
00343   size_t MaxNumEntriesA_;
00345   std::vector<size_t> NumEntries_;
00347   mutable Teuchos::Array<LocalOrdinal> Indices_;
00349   mutable Teuchos::Array<Scalar> Values_;
00350 };// class SingletonFilter
00351 
00352 }// namespace Ifpack2
00353 
00354 #endif /* IFPACK2_SINGLETONFILTER_DECL_HPP */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends