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 // 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_SINGLETONFILTER_DECL_HPP
00044 #define IFPACK2_SINGLETONFILTER_DECL_HPP
00045 
00046 #include "Ifpack2_ConfigDefs.hpp"
00047 #include "Tpetra_ConfigDefs.hpp"
00048 #include "Tpetra_RowMatrix.hpp"
00049 #include "Tpetra_MultiVector.hpp"
00050 #include "Teuchos_RefCountPtr.hpp"
00051 #include "Teuchos_ScalarTraits.hpp"
00052 #include <vector>
00053 
00054 
00055 namespace Ifpack2 {
00057 template<class MatrixType>
00058 class SingletonFilter :
00059     virtual public Tpetra::RowMatrix<typename MatrixType::scalar_type,
00060                                      typename MatrixType::local_ordinal_type,
00061                                      typename MatrixType::global_ordinal_type,
00062                                      typename MatrixType::node_type> {
00063 public:
00064   typedef typename MatrixType::scalar_type Scalar;
00065   typedef typename MatrixType::local_ordinal_type LocalOrdinal;
00066   typedef typename MatrixType::global_ordinal_type GlobalOrdinal;
00067   typedef typename MatrixType::node_type Node;
00068   typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType magnitudeType;
00069 
00071 
00072 
00074   explicit SingletonFilter(const Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> >& Matrix);
00075 
00077   virtual ~SingletonFilter();
00078 
00080 
00082 
00083 
00085   virtual Teuchos::RCP<const Teuchos::Comm<int> > getComm() const;
00086 
00088   virtual Teuchos::RCP<Node> getNode() const;
00089 
00091   virtual Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > getRowMap() const;
00092 
00094   virtual Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > getColMap() const;
00095 
00097   virtual Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > getDomainMap() const;
00098 
00100   virtual Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > getRangeMap() const;
00101 
00103   virtual Teuchos::RCP<const Tpetra::RowGraph<LocalOrdinal,GlobalOrdinal,Node> > getGraph() const;
00104 
00106   virtual global_size_t getGlobalNumRows() const;
00107 
00109   virtual global_size_t getGlobalNumCols() const;
00110 
00112   virtual size_t getNodeNumRows() const;
00113 
00115   virtual size_t getNodeNumCols() const;
00116 
00118   virtual GlobalOrdinal getIndexBase() const;
00119 
00121   virtual global_size_t getGlobalNumEntries() const;
00122 
00124   virtual size_t getNodeNumEntries() const;
00125 
00127 
00128   virtual size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const;
00129 
00131 
00132   virtual size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const;
00133 
00135   virtual global_size_t getGlobalNumDiags() const;
00136 
00138   virtual size_t getNodeNumDiags() const;
00139 
00141   virtual size_t getGlobalMaxNumRowEntries() const;
00142 
00144   virtual size_t getNodeMaxNumRowEntries() const;
00145 
00147   virtual bool hasColMap() const;
00148 
00150   virtual bool isLowerTriangular() const;
00151 
00153   virtual bool isUpperTriangular() const;
00154 
00156   virtual bool isLocallyIndexed() const;
00157 
00159   virtual bool isGloballyIndexed() const;
00160 
00162   virtual bool isFillComplete() const;
00163 
00165   virtual bool supportsRowViews() const;
00166 
00168 
00170 
00171 
00173 
00183   virtual void getGlobalRowCopy(GlobalOrdinal GlobalRow,
00184                                 const Teuchos::ArrayView<GlobalOrdinal> &Indices,
00185                                 const Teuchos::ArrayView<Scalar> &Values,
00186                                 size_t &NumEntries) const;
00187 
00189 
00199   virtual void getLocalRowCopy(LocalOrdinal LocalRow,
00200                                const Teuchos::ArrayView<LocalOrdinal> &Indices,
00201                                const Teuchos::ArrayView<Scalar> &Values,
00202                                size_t &NumEntries) const ;
00203 
00205 
00214   virtual void getGlobalRowView(GlobalOrdinal GlobalRow,
00215                                 Teuchos::ArrayView<const GlobalOrdinal> &indices,
00216                                 Teuchos::ArrayView<const Scalar> &values) const;
00217 
00219 
00228   virtual void getLocalRowView(LocalOrdinal LocalRow,
00229                                Teuchos::ArrayView<const LocalOrdinal> &indices,
00230                                Teuchos::ArrayView<const Scalar> &values) const;
00231 
00233 
00235   virtual void getLocalDiagCopy(Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &diag) const;
00236 
00238 
00240 
00241 
00251   virtual void leftScale(const Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& x);
00252 
00262   virtual void rightScale(const Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& x);
00263 
00265 
00268   virtual typename Teuchos::ScalarTraits<Scalar>::magnitudeType getFrobeniusNorm() const;
00269 
00271 
00276   virtual void apply(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &X,
00277                      Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &Y,
00278                      Teuchos::ETransp mode = Teuchos::NO_TRANS,
00279                      Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
00280                      Scalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const;
00281 
00283   virtual bool hasTransposeApply() const;
00284 
00286   virtual void SolveSingletons(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& RHS,
00287                       Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& LHS);
00288 
00289   template <class DomainScalar, class RangeScalar>
00290   void SolveSingletonsTempl(const Tpetra::MultiVector<DomainScalar,LocalOrdinal,GlobalOrdinal,Node>& RHS,
00291                             Tpetra::MultiVector<RangeScalar,LocalOrdinal,GlobalOrdinal,Node>& LHS);
00292 
00294   virtual void CreateReducedRHS(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& LHS,
00295                        const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& RHS,
00296                        Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& ReducedRHS);
00297 
00298   template <class DomainScalar, class RangeScalar>
00299   void CreateReducedRHSTempl(const Tpetra::MultiVector<DomainScalar,LocalOrdinal,GlobalOrdinal,Node>& LHS,
00300                              const Tpetra::MultiVector<RangeScalar,LocalOrdinal,GlobalOrdinal,Node>& RHS,
00301                              Tpetra::MultiVector<RangeScalar,LocalOrdinal,GlobalOrdinal,Node>& ReducedRHS);
00302 
00304   virtual void UpdateLHS(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& ReducedLHS,
00305                 Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& LHS);
00306 
00307   template <class DomainScalar, class RangeScalar>
00308   void UpdateLHSTempl(const Tpetra::MultiVector<DomainScalar,LocalOrdinal,GlobalOrdinal,Node>& ReducedLHS,
00309                       Tpetra::MultiVector<RangeScalar,LocalOrdinal,GlobalOrdinal,Node>& LHS);
00310 
00311 
00313 
00315 
00316 
00318 
00327   TPETRA_DEPRECATED virtual void getGlobalRowView(GlobalOrdinal GlobalRow,
00328                                                   Teuchos::ArrayRCP<const GlobalOrdinal> &indices,
00329                                                   Teuchos::ArrayRCP<const Scalar>        &values) const;
00330 
00332 
00341   TPETRA_DEPRECATED virtual void getLocalRowView(LocalOrdinal LocalRow,
00342                                                  Teuchos::ArrayRCP<const LocalOrdinal> &indices,
00343                                                  Teuchos::ArrayRCP<const Scalar>       &values) const;
00345 
00346 
00347 private:
00348 
00350   Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > A_;
00352   Teuchos::RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > ReducedMap_;
00354   Teuchos::RCP<Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > Diagonal_;
00356   size_t NumSingletons_;
00358   std::vector<LocalOrdinal> SingletonIndex_;
00360   std::vector<LocalOrdinal> Reorder_;
00362   std::vector<LocalOrdinal> InvReorder_;
00364   size_t NumRows_;
00366   size_t NumNonzeros_;
00368   size_t MaxNumEntries_;
00370   size_t MaxNumEntriesA_;
00372   std::vector<size_t> NumEntries_;
00374   mutable Teuchos::Array<LocalOrdinal> Indices_;
00376   mutable Teuchos::Array<Scalar> Values_;
00377 };// class SingletonFilter
00378 
00379 }// namespace Ifpack2
00380 
00381 #endif /* IFPACK2_SINGLETONFILTER_DECL_HPP */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends