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 // 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_REORDERFILTER_DECL_HPP
00044 #define IFPACK2_REORDERFILTER_DECL_HPP
00045 
00046 #include "Ifpack2_ConfigDefs.hpp"
00047 #include "Tpetra_RowMatrix.hpp"
00048 
00049 
00050 namespace Ifpack2 {
00051 
00067 template<class MatrixType>
00068 class ReorderFilter :
00069     virtual public Tpetra::RowMatrix<typename MatrixType::scalar_type,
00070                                      typename MatrixType::local_ordinal_type,
00071                                      typename MatrixType::global_ordinal_type,
00072                                      typename MatrixType::node_type> {
00073 public:
00074   typedef typename MatrixType::scalar_type scalar_type;
00075   typedef typename MatrixType::local_ordinal_type local_ordinal_type;
00076   typedef typename MatrixType::global_ordinal_type global_ordinal_type;
00077   typedef typename MatrixType::node_type node_type;
00078   typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
00079   typedef Tpetra::RowMatrix<scalar_type,
00080                             local_ordinal_type,
00081                             global_ordinal_type,
00082                             node_type> row_matrix_type;
00083   typedef Tpetra::Map<local_ordinal_type,
00084                       global_ordinal_type,
00085                       node_type> map_type;
00086 
00088 
00089 
00105   ReorderFilter (const Teuchos::RCP<const row_matrix_type>& A,
00106                  const Teuchos::ArrayRCP<local_ordinal_type>& perm,
00107                  const Teuchos::ArrayRCP<local_ordinal_type>& reverseperm);
00108 
00110   virtual ~ReorderFilter ();
00111 
00113 
00114 
00115 
00117   virtual Teuchos::RCP<const Teuchos::Comm<int> > getComm() const;
00118 
00120   virtual Teuchos::RCP<node_type> getNode () const;
00121 
00123   virtual Teuchos::RCP<const map_type> getRowMap() const;
00124 
00126   virtual Teuchos::RCP<const map_type> getColMap() const;
00127 
00129   virtual Teuchos::RCP<const map_type> getDomainMap() const;
00130 
00132   virtual Teuchos::RCP<const map_type> getRangeMap() const;
00133 
00135   virtual Teuchos::RCP<const Tpetra::RowGraph<local_ordinal_type,global_ordinal_type,node_type> > getGraph() const;
00136 
00138   virtual global_size_t getGlobalNumRows() const;
00139 
00141   virtual global_size_t getGlobalNumCols() const;
00142 
00144   virtual size_t getNodeNumRows() const;
00145 
00147   virtual size_t getNodeNumCols() const;
00148 
00150   virtual global_ordinal_type getIndexBase() const;
00151 
00153   virtual global_size_t getGlobalNumEntries() const;
00154 
00156   virtual size_t getNodeNumEntries() const;
00157 
00164   virtual size_t getNumEntriesInGlobalRow (global_ordinal_type globalRow) const;
00165 
00172   virtual size_t getNumEntriesInLocalRow (local_ordinal_type localRow) const;
00173 
00175   virtual global_size_t getGlobalNumDiags() const;
00176 
00178   virtual size_t getNodeNumDiags() const;
00179 
00181   virtual size_t getGlobalMaxNumRowEntries() const;
00182 
00184   virtual size_t getNodeMaxNumRowEntries() const;
00185 
00187   virtual bool hasColMap() const;
00188 
00190   virtual bool isLowerTriangular() const;
00191 
00193   virtual bool isUpperTriangular() const;
00194 
00196   virtual bool isLocallyIndexed() const;
00197 
00199   virtual bool isGloballyIndexed() const;
00200 
00202   virtual bool isFillComplete() const;
00203 
00205   virtual bool supportsRowViews() const;
00206 
00208 
00210 
00211 
00213 
00223   virtual void getGlobalRowCopy(global_ordinal_type GlobalRow,
00224                                 const Teuchos::ArrayView<global_ordinal_type> &Indices,
00225                                 const Teuchos::ArrayView<scalar_type> &Values,
00226                                 size_t &NumEntries) const;
00227 
00229 
00239   virtual void getLocalRowCopy(local_ordinal_type DropRow,
00240                                const Teuchos::ArrayView<local_ordinal_type> &Indices,
00241                                const Teuchos::ArrayView<scalar_type> &Values,
00242                                size_t &NumEntries) const ;
00243 
00245 
00253   virtual void getGlobalRowView(global_ordinal_type GlobalRow,
00254                                 Teuchos::ArrayView<const global_ordinal_type> &indices,
00255                                 Teuchos::ArrayView<const scalar_type> &values) const;
00256 
00258 
00267   virtual void getLocalRowView(local_ordinal_type LocalRow,
00268                                Teuchos::ArrayView<const local_ordinal_type> &indices,
00269                                Teuchos::ArrayView<const scalar_type> &values) const;
00270 
00272 
00274   virtual void getLocalDiagCopy(Tpetra::Vector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &diag) const;
00275 
00277 
00279 
00280 
00290   virtual void leftScale(const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& x);
00291 
00301   virtual void rightScale(const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& x);
00302 
00304 
00307   virtual typename Teuchos::ScalarTraits<scalar_type>::magnitudeType getFrobeniusNorm() const;
00308 
00330   virtual void
00331   apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &X,
00332          Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &Y,
00333          Teuchos::ETransp mode = Teuchos::NO_TRANS,
00334          scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
00335          scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
00336 
00338   virtual bool hasTransposeApply() const;
00339 
00341   virtual void permuteOriginalToReordered(const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &originalX,
00342                                           Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &reorderedY) const;
00343 
00344   template <class DomainScalar, class RangeScalar>
00345   void
00346   permuteOriginalToReorderedTempl (const Tpetra::MultiVector<DomainScalar,local_ordinal_type,global_ordinal_type,node_type> &originalX,
00347                                        Tpetra::MultiVector<RangeScalar,local_ordinal_type,global_ordinal_type,node_type> &reorderedY) const;
00348 
00350   virtual void permuteReorderedToOriginal(const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &reorderedX,
00351                                           Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &originalY) const;
00352 
00353   template <class DomainScalar, class RangeScalar>
00354   void permuteReorderedToOriginalTempl(const Tpetra::MultiVector<DomainScalar,local_ordinal_type,global_ordinal_type,node_type> &reorderedX,
00355                                        Tpetra::MultiVector<RangeScalar,local_ordinal_type,global_ordinal_type,node_type> &originalY) const;
00356 
00357 
00359 
00360 
00361 
00363 
00372   TPETRA_DEPRECATED
00373   virtual void getGlobalRowView (global_ordinal_type GlobalRow,
00374                                  Teuchos::ArrayRCP<const global_ordinal_type> &indices,
00375                                  Teuchos::ArrayRCP<const scalar_type> &values) const;
00376 
00378 
00387   TPETRA_DEPRECATED
00388   virtual void getLocalRowView (local_ordinal_type DropRow,
00389                                 Teuchos::ArrayRCP<const local_ordinal_type> &indices,
00390                                 Teuchos::ArrayRCP<const scalar_type> &values) const;
00392 
00393 private:
00395   Teuchos::RCP<const row_matrix_type> A_;
00397   Teuchos::ArrayRCP<local_ordinal_type> perm_;
00399   Teuchos::ArrayRCP<local_ordinal_type> reverseperm_;
00400 
00402   mutable Teuchos::Array<local_ordinal_type> Indices_;
00404   mutable Teuchos::Array<scalar_type> Values_;
00405 
00406 };// class ReorderFilter
00407 
00408 }// namespace Ifpack2
00409 
00410 #endif /* IFPACK2_REORDERFILTER_DECL_HPP */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends