Ifpack2 Templated Preconditioning Package  Version 1.0
Ifpack2_Chebyshev_decl.hpp
Go to the documentation of this file.
1 /*@HEADER
2 // ***********************************************************************
3 //
4 // Ifpack2: Tempated Object-Oriented Algebraic Preconditioner Package
5 // Copyright (2009) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 //@HEADER
41 */
42 
43 #ifndef IFPACK2_CHEBYSHEV_DECL_HPP
44 #define IFPACK2_CHEBYSHEV_DECL_HPP
45 
48 
49 #include "Ifpack2_ConfigDefs.hpp"
50 #include "Ifpack2_Preconditioner.hpp"
51 #include "Ifpack2_Condest.hpp"
52 #include "Ifpack2_Parameters.hpp"
55 
56 #include <Tpetra_CrsMatrix.hpp>
57 #include <Tpetra_Vector.hpp>
58 
59 #include <Teuchos_RCP.hpp>
60 #include <Teuchos_ScalarTraits.hpp>
61 #include <Teuchos_Time.hpp>
62 
63 #include <iostream>
64 #include <string>
65 #include <sstream>
66 
67 
68 namespace Ifpack2 {
69 
196 template<class MatrixType>
197 class Chebyshev :
198  virtual public Ifpack2::Preconditioner<typename MatrixType::scalar_type,
199  typename MatrixType::local_ordinal_type,
200  typename MatrixType::global_ordinal_type,
201  typename MatrixType::node_type>
202 {
203 public:
205 
206 
208  typedef MatrixType matrix_type;
209 
211  typedef typename MatrixType::scalar_type scalar_type;
212 
214  TEUCHOS_DEPRECATED typedef typename MatrixType::scalar_type Scalar;
215 
216 
218  typedef typename MatrixType::local_ordinal_type local_ordinal_type;
219 
221  TEUCHOS_DEPRECATED typedef typename MatrixType::local_ordinal_type LocalOrdinal;
222 
223 
225  typedef typename MatrixType::global_ordinal_type global_ordinal_type;
226 
228  TEUCHOS_DEPRECATED typedef typename MatrixType::global_ordinal_type GlobalOrdinal;
229 
230 
232  typedef typename MatrixType::node_type node_type;
233 
235  TEUCHOS_DEPRECATED typedef typename MatrixType::node_type Node;
236 
237 
239  typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
240 
242  TEUCHOS_DEPRECATED typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitudeType;
243 
244 
251  typedef Tpetra::RowMatrix<scalar_type,local_ordinal_type,global_ordinal_type,node_type> row_matrix_type;
252 
254  typedef Tpetra::Map<local_ordinal_type,global_ordinal_type,node_type> map_type;
255 
261  typedef Tpetra::Vector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> vector_type;
262 
264  // \name Constructors and destructors
266 
288  explicit Chebyshev (const Teuchos::RCP<const row_matrix_type>& A);
289 
291  virtual ~Chebyshev ();
292 
294 
296 
433  void setParameters (const Teuchos::ParameterList& params);
434 
441  void initialize();
442 
445  inline bool isInitialized() const {
446  return IsInitialized_;
447  }
448 
481  void compute ();
482 
490  inline bool isComputed() const {
491  return IsComputed_;
492  }
493 
495 
497 
526  void
527  apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
528  Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
529  Teuchos::ETransp mode = Teuchos::NO_TRANS,
530  scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
531  scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
532 
534  const Teuchos::RCP<const map_type>& getDomainMap() const;
535 
537  const Teuchos::RCP<const map_type>& getRangeMap() const;
538 
540  bool hasTransposeApply() const;
541 
562  void
563  applyMat (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
564  Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
565  Teuchos::ETransp mode = Teuchos::NO_TRANS) const;
566 
568 
570 
572  magnitude_type
573  computeCondEst (CondestType CT = Cheap,
574  local_ordinal_type MaxIters = 1550,
575  magnitude_type Tol = 1e-9,
576  const Teuchos::Ptr<const row_matrix_type>& matrix = Teuchos::null);
577 
579 
581 
583  magnitude_type getCondEst() const;
584 
586  const Teuchos::RCP<const Teuchos::Comm<int> > & getComm() const;
587 
589  Teuchos::RCP<const row_matrix_type> getMatrix() const;
590 
592  double getComputeFlops() const;
593 
595  double getApplyFlops() const;
596 
598  int getNumInitialize() const;
599 
601  int getNumCompute() const;
602 
604  int getNumApply() const;
605 
607  double getInitializeTime() const;
608 
610  double getComputeTime() const;
611 
613  double getApplyTime() const;
614 
616  typename MatrixType::scalar_type getLambdaMaxForApply() const;
617 
619 
621 
623  std::string description() const;
624 
626  void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const;
627 
629 
631 
638  static void TEUCHOS_DEPRECATED
639  PowerMethod (const Tpetra::Operator<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Operator,
640  const vector_type& InvPointDiagonal,
641  const int MaximumIterations,
642  scalar_type& LambdaMax);
643 
645  static void TEUCHOS_DEPRECATED
646  CG (const Tpetra::Operator<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Operator,
647  const vector_type& InvPointDiagonal,
648  const int MaximumIterations,
649  scalar_type& lambda_min, scalar_type& lambda_max);
650 
652 
653 private:
655  typedef Teuchos::ScalarTraits<typename MatrixType::scalar_type> STS;
656 
658  typedef Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type> MV;
659 
661  Chebyshev (const Chebyshev<MatrixType>&);
662 
664  Chebyshev<MatrixType>& operator= (const Chebyshev<MatrixType>&);
665 
673  void
674  applyImpl (const MV& X,
675  MV& Y,
676  Teuchos::ETransp mode,
677  scalar_type alpha,
678  scalar_type beta) const;
679 
681 
682 
690  mutable Details::Chebyshev<scalar_type, MV, row_matrix_type> impl_;
691 
693  Teuchos::RCP<Teuchos::Time> Time_;
695  magnitude_type Condest_;
697  bool IsInitialized_;
699  bool IsComputed_;
701  int NumInitialize_;
703  int NumCompute_;
708  mutable int NumApply_;
710  double InitializeTime_;
712  double ComputeTime_;
717  mutable double ApplyTime_;
719  double ComputeFlops_;
724  mutable double ApplyFlops_;
725 
727 }; // class Chebyshev
728 
729 }//namespace Ifpack2
730 
731 #endif // IFPACK2_CHEBYSHEV_DECL_HPP
732 
CondestType
Ifpack2::CondestType: enum to define the type of condition number estimate.
Definition: Ifpack2_CondestType.hpp:50
Base class for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:130
Definition of Chebyshev implementation.
Declaration of Chebyshev implementation.
Uses AztecOO&#39;s CG.
Definition: Ifpack2_CondestType.hpp:52
Ifpack2::Container: a pure virtual class for creating and solving local linear problems.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:67
cheap estimate
Definition: Ifpack2_CondestType.hpp:51