Ifpack2 Templated Preconditioning Package  Version 1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Ifpack2_Chebyshev_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Ifpack2: Templated Object-Oriented Algebraic Preconditioner Package
4 //
5 // Copyright 2009 NTESS and the Ifpack2 contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
16 
17 #ifndef IFPACK2_CHEBYSHEV_DECL_HPP
18 #define IFPACK2_CHEBYSHEV_DECL_HPP
19 
22 
23 // FIXME (mfh 20 Nov 2013) We really shouldn't have to include this.
24 // We should handle the implementation by pointer instead of by value.
25 #include "Ifpack2_Details_Chebyshev.hpp"
26 
27 // We only need the declaration here, and only for the method
28 // getCrsMatrix. I would very much prefer that this method not exist.
29 // Furthermore, it is both unsafe (MatrixType need not be CrsMatrix)
30 // and completely redundant (just call getMatrix() and do the
31 // dynamic_cast yourself).
32 #include "Tpetra_CrsMatrix_decl.hpp"
33 
34 #include <type_traits>
35 
36 namespace Ifpack2 {
37 
164 template<class MatrixType>
165 class Chebyshev :
166  virtual public Ifpack2::Preconditioner<typename MatrixType::scalar_type,
167  typename MatrixType::local_ordinal_type,
168  typename MatrixType::global_ordinal_type,
169  typename MatrixType::node_type>,
170  virtual public Ifpack2::Details::CanChangeMatrix<Tpetra::RowMatrix<typename MatrixType::scalar_type,
171  typename MatrixType::local_ordinal_type,
172  typename MatrixType::global_ordinal_type,
173  typename MatrixType::node_type> >
174 {
175 public:
177 
178 
180  typedef MatrixType matrix_type;
181 
183  typedef typename MatrixType::scalar_type scalar_type;
184 
186  typedef typename MatrixType::local_ordinal_type local_ordinal_type;
187 
189  typedef typename MatrixType::global_ordinal_type global_ordinal_type;
190 
192  typedef typename MatrixType::node_type::device_type device_type;
193 
195  typedef typename MatrixType::node_type node_type;
196 
199 
204  typedef Tpetra::RowMatrix<scalar_type, local_ordinal_type,
206 
207  static_assert (std::is_same<MatrixType, row_matrix_type>::value,
208  "Ifpack2::Chebyshev: MatrixType must be a Tpetra::RowMatrix "
209  "specialization. Don't use Tpetra::CrsMatrix here.");
210 
212  typedef Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> map_type;
213 
219  typedef Tpetra::Vector<scalar_type, local_ordinal_type,
221 
223  // \name Constructors and destructors
225 
248 
250  virtual ~Chebyshev ();
251 
253 
255 
392  void setParameters (const Teuchos::ParameterList& params);
393 
394  bool supportsZeroStartingSolution() { return true; }
395 
396  void setZeroStartingSolution (bool zeroStartingSolution);
397 
404  void initialize();
405 
408  inline bool isInitialized() const {
409  return IsInitialized_;
410  }
411 
444  void compute ();
445 
455  inline bool isComputed() const {
456  return IsComputed_;
457  }
458 
460 
462 
485  virtual void
487 
489 
491 
520  void
521  apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
522  Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
526 
529 
532 
534  bool hasTransposeApply() const;
535 
556  void
557  applyMat (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
558  Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
559  Teuchos::ETransp mode = Teuchos::NO_TRANS) const;
560 
562 
564 
567 
570 
576  getCrsMatrix() const;
577 
579  double getComputeFlops() const;
580 
582  double getApplyFlops() const;
583 
585  int getNumInitialize() const;
586 
588  int getNumCompute() const;
589 
591  int getNumApply() const;
592 
594  double getInitializeTime() const;
595 
597  double getComputeTime() const;
598 
600  double getApplyTime() const;
601 
603  size_t getNodeSmootherComplexity() const;
604 
606  typename MatrixType::scalar_type getLambdaMaxForApply() const;
607 
609 
611 
613  std::string description() const;
614 
617 
619 
620 private:
621 
624 
626  typedef Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type> MV;
627 
630 
632  Chebyshev<MatrixType>& operator= (const Chebyshev<MatrixType>&);
633 
641  void
642  applyImpl (const MV& X,
643  MV& Y,
644  Teuchos::ETransp mode,
645  scalar_type alpha,
646  scalar_type beta) const;
647 
649 
650 
659 
661  bool IsInitialized_;
663  bool IsComputed_;
665  int NumInitialize_;
667  int NumCompute_;
669  bool TimerForApply_;
674  mutable int NumApply_;
676  double InitializeTime_;
678  double ComputeTime_;
683  mutable double ApplyTime_;
685  double ComputeFlops_;
690  mutable double ApplyFlops_;
691 
693 }; // class Chebyshev
694 
695 } // namespace Ifpack2
696 
697 #endif // IFPACK2_CHEBYSHEV_DECL_HPP
698 
Mix-in interface for preconditioners that can change their matrix after construction.
Definition: Ifpack2_Details_CanChangeMatrix.hpp:60
double getApplyFlops() const
The total number of floating-point operations taken by all calls to apply().
Definition: Ifpack2_Chebyshev_def.hpp:188
Teuchos::RCP< const Tpetra::CrsMatrix< scalar_type, local_ordinal_type, global_ordinal_type, node_type > > getCrsMatrix() const
Attempt to return the matrix A as a Tpetra::CrsMatrix.
Definition: Ifpack2_Chebyshev_def.hpp:104
MatrixType::global_ordinal_type global_ordinal_type
The type of global indices in the input MatrixType.
Definition: Ifpack2_Chebyshev_decl.hpp:189
MatrixType::scalar_type scalar_type
The type of the entries of the input MatrixType.
Definition: Ifpack2_Chebyshev_decl.hpp:183
double getApplyTime() const
The total time spent in all calls to apply().
Definition: Ifpack2_Chebyshev_def.hpp:176
virtual void setMatrix(const Teuchos::RCP< const row_matrix_type > &A)
Change the matrix to be preconditioned.
Definition: Ifpack2_Chebyshev_def.hpp:49
Tpetra::Vector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > vector_type
The Tpetra::Vector specialization matching MatrixType.
Definition: Ifpack2_Chebyshev_decl.hpp:220
void setParameters(const Teuchos::ParameterList &params)
Set (or reset) parameters.
Definition: Ifpack2_Chebyshev_def.hpp:61
double getComputeTime() const
The total time spent in all calls to compute().
Definition: Ifpack2_Chebyshev_def.hpp:170
int getNumApply() const
The total number of successful calls to apply().
Definition: Ifpack2_Chebyshev_def.hpp:158
MatrixType::node_type node_type
The Node type used by the input MatrixType.
Definition: Ifpack2_Chebyshev_decl.hpp:195
MatrixType::node_type::device_type device_type
The Kokkos::Device specialization used by the input MatrixType.
Definition: Ifpack2_Chebyshev_decl.hpp:192
bool isInitialized() const
Definition: Ifpack2_Chebyshev_decl.hpp:408
void compute()
(Re)compute the left scaling, and (if applicable) estimate max and min eigenvalues of D_inv * A...
Definition: Ifpack2_Chebyshev_def.hpp:287
bool hasTransposeApply() const
Whether it&#39;s possible to apply the transpose of this operator.
Definition: Ifpack2_Chebyshev_def.hpp:140
Tpetra::RowMatrix< scalar_type, local_ordinal_type, global_ordinal_type, node_type > row_matrix_type
The Tpetra::RowMatrix specialization matching MatrixType.
Definition: Ifpack2_Chebyshev_decl.hpp:205
double getComputeFlops() const
The total number of floating-point operations taken by all calls to compute().
Definition: Ifpack2_Chebyshev_def.hpp:182
Diagonally scaled Chebyshev iteration for Tpetra sparse matrices.
Definition: Ifpack2_Chebyshev_decl.hpp:165
void apply(const Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &X, Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, scalar_type alpha=Teuchos::ScalarTraits< scalar_type >::one(), scalar_type beta=Teuchos::ScalarTraits< scalar_type >::zero()) const
Apply the preconditioner to X, returning the result in Y.
Definition: Ifpack2_Chebyshev_def.hpp:208
Interface for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:74
Chebyshev(const Teuchos::RCP< const row_matrix_type > &A)
Constructor.
Definition: Ifpack2_Chebyshev_def.hpp:25
bool isComputed() const
Definition: Ifpack2_Chebyshev_decl.hpp:455
std::string description() const
A simple one-line description of this object.
Definition: Ifpack2_Chebyshev_def.hpp:314
void initialize()
Initialize the preconditioner.
Definition: Ifpack2_Chebyshev_def.hpp:272
Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > map_type
The Tpetra::Map specialization matching MatrixType.
Definition: Ifpack2_Chebyshev_decl.hpp:209
Declaration of interface for preconditioners that can change their matrix after construction.
static const EVerbosityLevel verbLevel_default
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
The communicator over which the matrix is distributed.
Definition: Ifpack2_Chebyshev_def.hpp:79
MatrixType::local_ordinal_type local_ordinal_type
The type of local indices in the input MatrixType.
Definition: Ifpack2_Chebyshev_decl.hpp:186
int getNumInitialize() const
The total number of successful calls to initialize().
Definition: Ifpack2_Chebyshev_def.hpp:146
double getInitializeTime() const
The total time spent in all calls to initialize().
Definition: Ifpack2_Chebyshev_def.hpp:164
MatrixType::scalar_type getLambdaMaxForApply() const
The estimate of the maximum eigenvalue used in the apply().
Definition: Ifpack2_Chebyshev_def.hpp:477
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
The type of the magnitude (absolute value) of a matrix entry.
Definition: Ifpack2_Chebyshev_decl.hpp:198
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
Definition: Ifpack2_Chebyshev_def.hpp:193
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to a Teuchos::FancyOStream.
Definition: Ifpack2_Chebyshev_def.hpp:343
Teuchos::RCP< const row_matrix_type > getMatrix() const
The matrix for which this is a preconditioner.
Definition: Ifpack2_Chebyshev_def.hpp:93
Teuchos::RCP< const map_type > getDomainMap() const
The Tpetra::Map representing the domain of this operator.
Definition: Ifpack2_Chebyshev_def.hpp:114
MatrixType matrix_type
The template parameter of this class.
Definition: Ifpack2_Chebyshev_decl.hpp:180
virtual ~Chebyshev()
Destructor.
Definition: Ifpack2_Chebyshev_def.hpp:44
Teuchos::RCP< const map_type > getRangeMap() const
The Tpetra::Map representing the range of this operator.
Definition: Ifpack2_Chebyshev_def.hpp:128
int getNumCompute() const
The total number of successful calls to compute().
Definition: Ifpack2_Chebyshev_def.hpp:152
void applyMat(const Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &X, Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS) const
Compute Y = Op(A)*X, where Op(A) is either A, , or .
Definition: Ifpack2_Chebyshev_def.hpp:253
void setZeroStartingSolution(bool zeroStartingSolution)
Set this preconditioner&#39;s parameters.
Definition: Ifpack2_Chebyshev_def.hpp:72