Ifpack2 Templated Preconditioning Package Version 1.0
Ifpack2_Chebyshev_decl.hpp
Go to the documentation of this file.
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_CHEBYSHEV_DECL_HPP
00031 #define IFPACK2_CHEBYSHEV_DECL_HPP
00032 
00035 
00036 #include "Ifpack2_ConfigDefs.hpp"
00037 #include "Ifpack2_Preconditioner.hpp"
00038 #include "Ifpack2_Condest.hpp"
00039 #include "Ifpack2_Parameters.hpp"
00040 #include "Ifpack2_Details_Chebyshev_decl.hpp"
00041 #include "Ifpack2_Details_Chebyshev_def.hpp"
00042 
00043 #include <Tpetra_CrsMatrix.hpp>
00044 #include <Tpetra_Vector.hpp>
00045 
00046 #include <Teuchos_RCP.hpp>
00047 #include <Teuchos_ScalarTraits.hpp>
00048 #include <Teuchos_Time.hpp>
00049 
00050 #include <iostream>
00051 #include <string>
00052 #include <sstream>
00053 
00054 
00055 namespace Ifpack2 {
00056 
00183 template<class MatrixType>
00184 class Chebyshev : 
00185     virtual public Ifpack2::Preconditioner<typename MatrixType::scalar_type,
00186              typename MatrixType::local_ordinal_type,
00187              typename MatrixType::global_ordinal_type,
00188              typename MatrixType::node_type> 
00189 {
00190 public:
00192 
00193 
00195   typedef MatrixType matrix_type;
00196 
00198   typedef typename MatrixType::scalar_type scalar_type;
00199 
00201   TEUCHOS_DEPRECATED typedef typename MatrixType::scalar_type Scalar;
00202 
00203 
00205   typedef typename MatrixType::local_ordinal_type local_ordinal_type;
00206 
00208   TEUCHOS_DEPRECATED typedef typename MatrixType::local_ordinal_type LocalOrdinal;
00209 
00210 
00212   typedef typename MatrixType::global_ordinal_type global_ordinal_type;
00213 
00215   TEUCHOS_DEPRECATED typedef typename MatrixType::global_ordinal_type GlobalOrdinal;
00216 
00217 
00219   typedef typename MatrixType::node_type node_type;
00220 
00222   TEUCHOS_DEPRECATED typedef typename MatrixType::node_type Node;
00223 
00224 
00226   typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
00227 
00229   TEUCHOS_DEPRECATED typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitudeType;
00230 
00231 
00238   typedef Tpetra::RowMatrix<scalar_type,local_ordinal_type,global_ordinal_type,node_type> row_matrix_type;
00239 
00241   typedef Tpetra::Map<local_ordinal_type,global_ordinal_type,node_type> map_type;
00242 
00248   typedef Tpetra::Vector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> vector_type;
00249 
00251   // \name Constructors and destructors
00253 
00275   explicit Chebyshev (const Teuchos::RCP<const row_matrix_type>& A);
00276 
00278   virtual ~Chebyshev ();
00279 
00281 
00282 
00283 
00413   void setParameters (const Teuchos::ParameterList& params);
00414 
00421   void initialize();
00422 
00425   inline bool isInitialized() const {
00426     return(IsInitialized_);
00427   }
00428 
00448   void compute ();
00449 
00452   inline bool isComputed() const {
00453     return IsComputed_;
00454   }
00455 
00457 
00458 
00459 
00488   void
00489   apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
00490    Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
00491    Teuchos::ETransp mode = Teuchos::NO_TRANS,
00492    scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
00493    scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
00494 
00496   const Teuchos::RCP<const map_type>& getDomainMap() const;
00497 
00499   const Teuchos::RCP<const map_type>& getRangeMap() const;
00500 
00502   bool hasTransposeApply() const;
00503 
00524   void 
00525   applyMat (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
00526       Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
00527       Teuchos::ETransp mode = Teuchos::NO_TRANS) const;
00528 
00530 
00531 
00532 
00534   magnitude_type
00535   computeCondEst (CondestType CT = Cheap, 
00536       local_ordinal_type MaxIters = 1550,
00537       magnitude_type Tol = 1e-9,
00538       const Teuchos::Ptr<const row_matrix_type>& matrix = Teuchos::null);
00539 
00541 
00542 
00543 
00545   magnitude_type getCondEst() const;
00546 
00548   const Teuchos::RCP<const Teuchos::Comm<int> > & getComm() const;
00549 
00551   Teuchos::RCP<const row_matrix_type> getMatrix() const;
00552 
00554   double getComputeFlops() const;
00555 
00557   double getApplyFlops() const;
00558 
00560   int getNumInitialize() const;
00561 
00563   int getNumCompute() const;
00564 
00566   int getNumApply() const;
00567 
00569   double getInitializeTime() const;
00570 
00572   double getComputeTime() const;
00573 
00575   double getApplyTime() const;
00576 
00578 
00579 
00580 
00582   std::string description() const;
00583 
00585   void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const;
00586 
00588 
00589 
00590 
00597   static void TEUCHOS_DEPRECATED 
00598   PowerMethod (const Tpetra::Operator<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Operator,
00599          const vector_type& InvPointDiagonal,
00600          const int MaximumIterations, 
00601          scalar_type& LambdaMax);
00602 
00604   static void TEUCHOS_DEPRECATED 
00605   CG (const Tpetra::Operator<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Operator, 
00606       const vector_type& InvPointDiagonal, 
00607       const int MaximumIterations, 
00608       scalar_type& lambda_min, scalar_type& lambda_max);
00609 
00611 
00612 private:
00614   typedef Teuchos::ScalarTraits<typename MatrixType::scalar_type> STS;
00615 
00617   typedef Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type> MV;
00618   
00620   Chebyshev (const Chebyshev<MatrixType>&);
00621 
00623   Chebyshev<MatrixType>& operator= (const Chebyshev<MatrixType>&);
00624 
00632   void 
00633   applyImpl (const MV& X,
00634        MV& Y,
00635        Teuchos::ETransp mode,
00636        scalar_type alpha,
00637        scalar_type beta) const;
00638 
00640 
00641 
00649   mutable Details::Chebyshev<scalar_type, MV, row_matrix_type> impl_;
00650 
00652   Teuchos::RCP<Teuchos::Time> Time_;
00654   magnitude_type Condest_;
00656   bool IsInitialized_;
00658   bool IsComputed_;
00660   int NumInitialize_;
00662   int NumCompute_;
00667   mutable int NumApply_;
00669   double InitializeTime_;
00671   double ComputeTime_;
00676   mutable double ApplyTime_;
00678   double ComputeFlops_;
00683   mutable double ApplyFlops_;
00684 
00686 }; // class Chebyshev
00687 
00688 }//namespace Ifpack2
00689 
00690 #endif // IFPACK2_CHEBYSHEV_DECL_HPP
00691 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends