44#ifndef IFPACK2_DETAILS_CHEBYSHEV_DECL_HPP
45#define IFPACK2_DETAILS_CHEBYSHEV_DECL_HPP
54#include "Ifpack2_ConfigDefs.hpp"
55#include "Teuchos_VerbosityLevel.hpp"
56#include "Teuchos_Describable.hpp"
57#include "Tpetra_CrsMatrix.hpp"
62#ifndef DOXYGEN_SHOULD_SKIP_THIS
63template<
class TpetraOperatorType>
105template<
class ScalarType,
class MV>
112 typedef ScalarType
ST;
114 typedef Teuchos::ScalarTraits<ScalarType>
STS;
116 typedef typename STS::magnitudeType
MT;
118 typedef Tpetra::Operator<
typename MV::scalar_type,
119 typename MV::local_ordinal_type,
120 typename MV::global_ordinal_type,
123 typedef Tpetra::RowMatrix<
typename MV::scalar_type,
124 typename MV::local_ordinal_type,
125 typename MV::global_ordinal_type,
128 typedef Tpetra::Vector<
typename MV::scalar_type,
129 typename MV::local_ordinal_type,
130 typename MV::global_ordinal_type,
131 typename MV::node_type>
V;
133 typedef Tpetra::Map<
typename MV::local_ordinal_type,
134 typename MV::global_ordinal_type,
145 Chebyshev (Teuchos::RCP<const row_matrix_type> A);
156 Chebyshev (Teuchos::RCP<const row_matrix_type> A, Teuchos::ParameterList& params);
268 void setZeroStartingSolution (
bool zeroStartingSolution) { zeroStartingSolution_ = zeroStartingSolution; }
323 ST getLambdaMaxForApply()
const;
326 Teuchos::RCP<const row_matrix_type>
getMatrix ()
const;
333 void setMatrix (
const Teuchos::RCP<const row_matrix_type>& A);
339 void print (std::ostream& out);
350 describe (Teuchos::FancyOStream& out,
351 const Teuchos::EVerbosityLevel verbLevel =
352 Teuchos::Describable::verbLevel_default)
const;
364 Teuchos::RCP<const row_matrix_type> A_;
367 Teuchos::RCP<ChebyshevKernel<op_type> > ck_;
379 Teuchos::RCP<const V> D_;
382 typedef Kokkos::View<size_t*, typename MV::node_type::device_type> offsets_type;
389 offsets_type diagOffsets_;
398 bool savedDiagOffsets_;
414 ST computedLambdaMax_;
421 ST computedLambdaMin_;
429 ST lambdaMaxForApply_;
440 ST lambdaMinForApply_;
443 ST eigRatioForApply_;
453 Teuchos::RCP<const V> userInvDiag_;
486 bool eigKeepVectors_;
489 std::string eigenAnalysisType_;
492 Teuchos::RCP<V> eigVector_;
493 Teuchos::RCP<V> eigVector2_;
496 int eigNormalizationFreq_;
499 bool zeroStartingSolution_;
507 bool assumeMatrixUnchanged_;
510 bool textbookAlgorithm_;
513 bool computeMaxResNorm_;
516 bool computeSpectralRadius_;
520 bool ckUseNativeSpMV_;
525 Teuchos::RCP<Teuchos::FancyOStream> out_;
535 void checkConstructorInput ()
const;
538 void checkInputMatrix ()
const;
554 Teuchos::RCP<MV> makeTempMultiVector (
const MV& B);
558 firstIterationWithZeroStartingSolution
560 const ScalarType& alpha,
567 computeResidual (MV& R,
const MV& B,
const op_type& A,
const MV& X,
568 const Teuchos::ETransp mode = Teuchos::NO_TRANS);
575 static void solve (MV& Z,
const V& D_inv,
const MV& R);
582 static void solve (MV& Z,
const ST alpha,
const V& D_inv,
const MV& R);
591 Teuchos::RCP<const V>
592 makeInverseDiagonal (
const row_matrix_type& A,
const bool useDiagOffsets=
false)
const;
603 Teuchos::RCP<V> makeRangeMapVector (
const Teuchos::RCP<V>& D)
const;
606 Teuchos::RCP<const V>
607 makeRangeMapVectorConst (
const Teuchos::RCP<const V>& D)
const;
628 textbookApplyImpl (
const op_type& A,
635 const V& D_inv)
const;
660 ifpackApplyImpl (
const op_type& A,
682 cgMethodWithInitGuess (
const op_type& A,
const V& D_inv,
const int numIters,
V& x);
694 cgMethod (
const op_type& A,
const V& D_inv,
const int numIters);
697 static MT maxNormInf (
const MV& X);
735 const ST zero = Teuchos::as<ST> (0);
736 const ST one = Teuchos::as<ST> (1);
737 const ST two = Teuchos::as<ST> (2);
739 MV pAux (B.getMap (), B.getNumVectors ());
740 MV dk (B.getMap (), B.getNumVectors ());
741 MV R (B.getMap (), B.getNumVectors ());
743 ST beta = Teuchos::as<ST> (1.1) * lambdaMax;
744 ST alpha = lambdaMax / eigRatio;
746 ST delta = (beta - alpha) / two;
747 ST theta = (beta + alpha) / two;
748 ST s1 = theta / delta;
759 if (lambdaMin == one && lambdaMin == lambdaMax) {
768 if (! zeroStartingSolution_) {
772 R.update (-one, pAux, one);
773 dk.elementWiseMultiply (one/theta, D_inv, R, zero);
774 X.update (one, dk, one);
776 dk.elementWiseMultiply (one/theta, D_inv, B, zero);
780 ST rhokp1, dtemp1, dtemp2;
781 for (
int k = 0; k < numIters-1; ++k) {
783 rhokp1 = one / (two*s1 - rhok);
784 dtemp1 = rhokp1*rhok;
785 dtemp2 = two*rhokp1/delta;
789 R.update (-one, pAux, one);
791 dk.elementWiseMultiply (dtemp2, D_inv, B, dtemp1);
792 X.update (one, dk, one);
Left-scaled Chebyshev iteration.
Definition Ifpack2_Details_Chebyshev_decl.hpp:106
Tpetra::Vector< typename MV::scalar_type, typename MV::local_ordinal_type, typename MV::global_ordinal_type, typename MV::node_type > V
Specialization of Tpetra::Vector.
Definition Ifpack2_Details_Chebyshev_decl.hpp:131
Teuchos::ScalarTraits< ScalarType > STS
Traits class for ST.
Definition Ifpack2_Details_Chebyshev_decl.hpp:114
void compute()
(Re)compute the left scaling D_inv, and estimate min and max eigenvalues of D_inv * A.
Definition Ifpack2_Details_Chebyshev_def.hpp:796
void setParameters(Teuchos::ParameterList &plist)
Set (or reset) parameters.
Definition Ifpack2_Details_Chebyshev_def.hpp:353
void setMatrix(const Teuchos::RCP< const row_matrix_type > &A)
Set the matrix.
Definition Ifpack2_Details_Chebyshev_def.hpp:755
std::string description() const
A single-line description of the Chebyshev solver.
Definition Ifpack2_Details_Chebyshev_def.hpp:1560
Chebyshev(Teuchos::RCP< const row_matrix_type > A)
Definition Ifpack2_Details_Chebyshev_def.hpp:287
Tpetra::Map< typename MV::local_ordinal_type, typename MV::global_ordinal_type, typename MV::node_type > map_type
Specialization of Tpetra::Map.
Definition Ifpack2_Details_Chebyshev_decl.hpp:135
Tpetra::RowMatrix< typename MV::scalar_type, typename MV::local_ordinal_type, typename MV::global_ordinal_type, typename MV::node_type > row_matrix_type
Specialization of Tpetra::RowMatrix.
Definition Ifpack2_Details_Chebyshev_decl.hpp:126
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print a description of the Chebyshev solver to out.
Definition Ifpack2_Details_Chebyshev_def.hpp:1580
void print(std::ostream &out)
Print instance data to the given output stream.
Definition Ifpack2_Details_Chebyshev_def.hpp:1042
Tpetra::Operator< typename MV::scalar_type, typename MV::local_ordinal_type, typename MV::global_ordinal_type, typename MV::node_type > op_type
Specialization of Tpetra::Operator.
Definition Ifpack2_Details_Chebyshev_decl.hpp:121
ScalarType ST
The type of entries in the matrix and vectors.
Definition Ifpack2_Details_Chebyshev_decl.hpp:112
STS::magnitudeType MT
The type of the absolute value of a ScalarType.
Definition Ifpack2_Details_Chebyshev_decl.hpp:116
MT apply(const MV &B, MV &X)
Solve Ax=b for x with Chebyshev iteration with left diagonal scaling.
Definition Ifpack2_Details_Chebyshev_def.hpp:989
bool hasTransposeApply() const
Whether it's possible to apply the transpose of this operator.
Definition Ifpack2_Details_Chebyshev_def.hpp:1536
Teuchos::RCP< const row_matrix_type > getMatrix() const
Get the matrix given to the constructor.
Definition Ifpack2_Details_Chebyshev_def.hpp:1529
Ifpack2 implementation details.
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:74