Ifpack2 Templated Preconditioning Package Version 1.0
Ifpack2_DiagonalFilter_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_DIAGONALFILTER_DECL_HPP
00044 #define IFPACK2_DIAGONALFILTER_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 namespace Ifpack2 {
00053 
00055 
00077 template<class MatrixType>
00078 class DiagonalFilter :
00079     virtual public Tpetra::RowMatrix<typename MatrixType::scalar_type,
00080                                      typename MatrixType::local_ordinal_type,
00081                                      typename MatrixType::global_ordinal_type,
00082                                      typename MatrixType::node_type> {
00083 public:
00084   typedef typename MatrixType::scalar_type Scalar;
00085   typedef typename MatrixType::local_ordinal_type LocalOrdinal;
00086   typedef typename MatrixType::global_ordinal_type GlobalOrdinal;
00087   typedef typename MatrixType::node_type Node;
00088   typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType magnitudeType;
00089 
00091 
00092 
00094   explicit DiagonalFilter(const Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> >& Matrix,
00095                           magnitudeType AbsoluteThreshold,
00096                           magnitudeType RelativeThreshold);
00097 
00099   virtual ~DiagonalFilter();
00100 
00102 
00104 
00105 
00107   virtual Teuchos::RCP<const Teuchos::Comm<int> > getComm() const;
00108 
00110   virtual Teuchos::RCP<Node> getNode() const;
00111 
00113   virtual Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > getRowMap() const;
00114 
00116   virtual Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > getColMap() const;
00117 
00119   virtual Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > getDomainMap() const;
00120 
00122   virtual Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > getRangeMap() const;
00123 
00125   virtual Teuchos::RCP<const Tpetra::RowGraph<LocalOrdinal,GlobalOrdinal,Node> > getGraph() const;
00126 
00128   virtual global_size_t getGlobalNumRows() const;
00129 
00131   virtual global_size_t getGlobalNumCols() const;
00132 
00134   virtual size_t getNodeNumRows() const;
00135 
00137   virtual size_t getNodeNumCols() const;
00138 
00140   virtual GlobalOrdinal getIndexBase() const;
00141 
00143   virtual global_size_t getGlobalNumEntries() const;
00144 
00146   virtual size_t getNodeNumEntries() const;
00147 
00149 
00150   virtual size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const;
00151 
00153 
00154   virtual size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const;
00155 
00157   virtual global_size_t getGlobalNumDiags() const;
00158 
00160   virtual size_t getNodeNumDiags() const;
00161 
00163   virtual size_t getGlobalMaxNumRowEntries() const;
00164 
00166   virtual size_t getNodeMaxNumRowEntries() const;
00167 
00169   virtual bool hasColMap() const;
00170 
00172   virtual bool isLowerTriangular() const;
00173 
00175   virtual bool isUpperTriangular() const;
00176 
00178   virtual bool isLocallyIndexed() const;
00179 
00181   virtual bool isGloballyIndexed() const;
00182 
00184   virtual bool isFillComplete() const;
00185 
00187   virtual bool supportsRowViews() const;
00188 
00190 
00192 
00193 
00195 
00205   virtual void getGlobalRowCopy(GlobalOrdinal GlobalRow,
00206                                 const Teuchos::ArrayView<GlobalOrdinal> &Indices,
00207                                 const Teuchos::ArrayView<Scalar> &Values,
00208                                 size_t &NumEntries) const;
00209 
00211 
00221   virtual void getLocalRowCopy(LocalOrdinal LocalRow,
00222                                const Teuchos::ArrayView<LocalOrdinal> &Indices,
00223                                const Teuchos::ArrayView<Scalar> &Values,
00224                                size_t &NumEntries) const ;
00225 
00227 
00236   virtual void getGlobalRowView(GlobalOrdinal GlobalRow,
00237                                 Teuchos::ArrayView<const GlobalOrdinal> &indices,
00238                                 Teuchos::ArrayView<const Scalar> &values) const;
00239 
00241 
00250   virtual void getLocalRowView(LocalOrdinal LocalRow,
00251                                Teuchos::ArrayView<const LocalOrdinal> &indices,
00252                                Teuchos::ArrayView<const Scalar> &values) const;
00253 
00255 
00257   virtual void getLocalDiagCopy(Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &diag) const;
00258 
00260 
00262 
00263 
00273   virtual void leftScale(const Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& x);
00274 
00284   virtual void rightScale(const Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& x);
00285 
00287 
00290   virtual typename Teuchos::ScalarTraits<Scalar>::magnitudeType getFrobeniusNorm() const;
00291 
00293 
00300   virtual void apply(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &X,
00301                      Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &Y,
00302                      Teuchos::ETransp mode = Teuchos::NO_TRANS,
00303                      Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
00304                      Scalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const;
00305 
00307   virtual bool hasTransposeApply() const;
00308 
00310 
00312 
00313 
00315 
00324   TPETRA_DEPRECATED virtual void getGlobalRowView(GlobalOrdinal GlobalRow,
00325                                                   Teuchos::ArrayRCP<const GlobalOrdinal> &indices,
00326                                                   Teuchos::ArrayRCP<const Scalar>        &values) const;
00327 
00329 
00338   TPETRA_DEPRECATED virtual void getLocalRowView(LocalOrdinal LocalRow,
00339                                                  Teuchos::ArrayRCP<const LocalOrdinal> &indices,
00340                                                  Teuchos::ArrayRCP<const Scalar>       &values) const;
00342 
00343 
00344 private:
00345 
00347   Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > A_;
00349   magnitudeType  AbsoluteThreshold_;
00351   magnitudeType RelativeThreshold_;
00353   std::vector<LocalOrdinal> pos_;
00355   Teuchos::RCP<Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > val_;
00356 
00357 };// class DiagonalFilter
00358 
00359 }// namespace Ifpack2
00360 
00361 #endif /* IFPACK2_DIAGONALFILTER_DECL_HPP */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends