Ifpack2 Templated Preconditioning Package Version 1.0
Ifpack2_SparsityFilter_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 // 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 IFPACK2_SPARSITYFILTER_DECL_HPP
00044 #define IFPACK2_SPARSITYFILTER_DECL_HPP
00045 
00046 #include "Ifpack2_ConfigDefs.hpp"
00047 #include "Tpetra_ConfigDefs.hpp"
00048 #include "Tpetra_RowMatrix.hpp"
00049 #include "Teuchos_RefCountPtr.hpp"
00050 #include "Teuchos_ScalarTraits.hpp"
00051 
00052 
00053 namespace Ifpack2 {
00054 
00083 template<class MatrixType>
00084 class SparsityFilter : 
00085     virtual public Tpetra::RowMatrix<typename MatrixType::scalar_type,
00086              typename MatrixType::local_ordinal_type,
00087              typename MatrixType::global_ordinal_type,
00088              typename MatrixType::node_type> {
00089 public:
00090   typedef typename MatrixType::scalar_type Scalar;
00091   typedef typename MatrixType::local_ordinal_type LocalOrdinal;
00092   typedef typename MatrixType::global_ordinal_type GlobalOrdinal;
00093   typedef typename MatrixType::node_type Node;
00094   typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType magnitudeType;
00095   
00097 
00098 
00100   explicit SparsityFilter(const Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> >& Matrix,
00101         size_t AllowedNumEntries,
00102         LocalOrdinal AllowedBandwidth = -Teuchos::ScalarTraits<LocalOrdinal>::one());
00104   virtual ~SparsityFilter();
00105 
00107 
00108 
00109 
00111   virtual Teuchos::RCP<const Teuchos::Comm<int> > getComm() const;
00112 
00114   virtual Teuchos::RCP<Node> getNode() const;
00115 
00117   virtual Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > getRowMap() const;
00118 
00120   virtual Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > getColMap() const;
00121 
00123   virtual Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > getDomainMap() const;
00124 
00126   virtual Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > getRangeMap() const;
00127 
00129   virtual Teuchos::RCP<const Tpetra::RowGraph<LocalOrdinal,GlobalOrdinal,Node> > getGraph() const;
00130 
00132   virtual global_size_t getGlobalNumRows() const;
00133 
00135   virtual global_size_t getGlobalNumCols() const;
00136 
00138   virtual size_t getNodeNumRows() const;
00139 
00141   virtual size_t getNodeNumCols() const;
00142 
00144   virtual GlobalOrdinal getIndexBase() const;
00145 
00147   virtual global_size_t getGlobalNumEntries() const;
00148 
00150   virtual size_t getNodeNumEntries() const;
00151   
00153 
00154   virtual size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const;
00155   
00157 
00158   virtual size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const;
00159   
00161   virtual global_size_t getGlobalNumDiags() const;
00162   
00164   virtual size_t getNodeNumDiags() const;
00165   
00167   virtual size_t getGlobalMaxNumRowEntries() const;
00168   
00170   virtual size_t getNodeMaxNumRowEntries() const;
00171   
00173   virtual bool hasColMap() const;
00174   
00176   virtual bool isLowerTriangular() const;
00177   
00179   virtual bool isUpperTriangular() const;
00180   
00182   virtual bool isLocallyIndexed() const;
00183   
00185   virtual bool isGloballyIndexed() const;
00186   
00188   virtual bool isFillComplete() const;
00189   
00191   virtual bool supportsRowViews() const;  
00192 
00194   
00196 
00197   
00199 
00209   virtual void getGlobalRowCopy(GlobalOrdinal GlobalRow,
00210         const Teuchos::ArrayView<GlobalOrdinal> &Indices,
00211         const Teuchos::ArrayView<Scalar> &Values,
00212         size_t &NumEntries) const;
00213   
00215 
00225   virtual void getLocalRowCopy(LocalOrdinal DropRow, 
00226              const Teuchos::ArrayView<LocalOrdinal> &Indices, 
00227              const Teuchos::ArrayView<Scalar> &Values,
00228              size_t &NumEntries) const ;
00229   
00231 
00240   virtual void getGlobalRowView(GlobalOrdinal GlobalRow, 
00241         Teuchos::ArrayView<const GlobalOrdinal> &indices, 
00242         Teuchos::ArrayView<const Scalar> &values) const;
00243   
00245 
00254   virtual void getLocalRowView(LocalOrdinal DropRow, 
00255              Teuchos::ArrayView<const LocalOrdinal> &indices, 
00256              Teuchos::ArrayView<const Scalar> &values) const;
00257   
00259 
00261   virtual void getLocalDiagCopy(Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &diag) const;
00262   
00264   
00266 
00267   
00277   virtual void leftScale(const Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& x);
00278   
00288   virtual void rightScale(const Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& x);
00289   
00291 
00294   virtual typename Teuchos::ScalarTraits<Scalar>::magnitudeType getFrobeniusNorm() const;
00295 
00297 
00302   virtual void apply(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &X, 
00303          Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &Y, 
00304          Teuchos::ETransp mode = Teuchos::NO_TRANS, 
00305          Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
00306          Scalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const;
00307   
00309   virtual bool hasTransposeApply() const;
00310   
00312   
00314 
00315   
00317 
00326   TPETRA_DEPRECATED virtual void getGlobalRowView(GlobalOrdinal GlobalRow, 
00327               Teuchos::ArrayRCP<const GlobalOrdinal> &indices,
00328               Teuchos::ArrayRCP<const Scalar>        &values) const;
00329   
00331 
00340   TPETRA_DEPRECATED virtual void getLocalRowView(LocalOrdinal DropRow,
00341              Teuchos::ArrayRCP<const LocalOrdinal> &indices,
00342              Teuchos::ArrayRCP<const Scalar>       &values) const;  
00344 
00345   
00346 private:
00347 
00349   Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > A_;
00350 
00352   size_t AllowedNumEntries_;  
00354   LocalOrdinal AllowedBandwidth_;
00356   size_t NumRows_;
00358   size_t NumNonzeros_;
00360   size_t MaxNumEntries_;
00362   size_t MaxNumEntriesA_;
00364   std::vector<size_t> NumEntries_;
00366   mutable Teuchos::Array<LocalOrdinal> Indices_;
00368   mutable Teuchos::Array<Scalar> Values_;
00369 
00370 };// class SparsityFilter
00371 
00372 }// namespace Ifpack2
00373 
00374 #endif /* IFPACK2_SPARSITYFILTER_DECL_HPP */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends