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 63 template<
class TpetraOperatorType>
64 class ChebyshevKernel;
65 #endif // DOXYGEN_SHOULD_SKIP_THIS 105 template<
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);
318 ST getLambdaMaxForApply()
const;
321 Teuchos::RCP<const row_matrix_type>
getMatrix ()
const;
328 void setMatrix (
const Teuchos::RCP<const row_matrix_type>& A);
334 void print (std::ostream& out);
345 describe (Teuchos::FancyOStream& out,
346 const Teuchos::EVerbosityLevel verbLevel =
347 Teuchos::Describable::verbLevel_default)
const;
359 Teuchos::RCP<const row_matrix_type> A_;
362 Teuchos::RCP<ChebyshevKernel<op_type> > ck_;
374 Teuchos::RCP<const V> D_;
377 typedef Kokkos::View<size_t*, typename MV::node_type::device_type> offsets_type;
384 offsets_type diagOffsets_;
393 bool savedDiagOffsets_;
409 ST computedLambdaMax_;
416 ST computedLambdaMin_;
424 ST lambdaMaxForApply_;
435 ST lambdaMinForApply_;
438 ST eigRatioForApply_;
448 Teuchos::RCP<const V> userInvDiag_;
478 bool zeroStartingSolution_;
486 bool assumeMatrixUnchanged_;
489 bool textbookAlgorithm_;
492 bool computeMaxResNorm_;
497 Teuchos::RCP<Teuchos::FancyOStream> out_;
507 void checkConstructorInput ()
const;
510 void checkInputMatrix ()
const;
526 Teuchos::RCP<MV> makeTempMultiVector (
const MV& B);
530 firstIterationWithZeroStartingSolution
532 const ScalarType& alpha,
539 computeResidual (MV& R,
const MV& B,
const op_type& A,
const MV& X,
540 const Teuchos::ETransp mode = Teuchos::NO_TRANS);
547 static void solve (MV& Z,
const V& D_inv,
const MV& R);
554 static void solve (MV& Z,
const ST alpha,
const V& D_inv,
const MV& R);
563 Teuchos::RCP<const V>
564 makeInverseDiagonal (
const row_matrix_type& A,
const bool useDiagOffsets=
false)
const;
575 Teuchos::RCP<V> makeRangeMapVector (
const Teuchos::RCP<V>& D)
const;
578 Teuchos::RCP<const V>
579 makeRangeMapVectorConst (
const Teuchos::RCP<const V>& D)
const;
600 textbookApplyImpl (
const op_type& A,
607 const V& D_inv)
const;
632 ifpackApplyImpl (
const op_type& A,
652 void computeInitialGuessForPowerMethod (
V& x,
const bool nonnegativeRealParts =
false)
const;
667 powerMethodWithInitGuess (
const op_type& A,
const V& D_inv,
const int numIters,
V& x);
679 powerMethod (
const op_type& A,
const V& D_inv,
const int numIters);
682 static MT maxNormInf (
const MV& X);
720 const ST zero = Teuchos::as<ST> (0);
721 const ST one = Teuchos::as<ST> (1);
722 const ST two = Teuchos::as<ST> (2);
724 MV pAux (B.getMap (), B.getNumVectors ());
725 MV dk (B.getMap (), B.getNumVectors ());
726 MV R (B.getMap (), B.getNumVectors ());
728 ST beta = Teuchos::as<ST> (1.1) * lambdaMax;
729 ST alpha = lambdaMax / eigRatio;
731 ST delta = (beta - alpha) / two;
732 ST theta = (beta + alpha) / two;
733 ST s1 = theta / delta;
744 if (lambdaMin == one && lambdaMin == lambdaMax) {
753 if (! zeroStartingSolution_) {
757 R.update (-one, pAux, one);
758 dk.elementWiseMultiply (one/theta, D_inv, R, zero);
759 X.update (one, dk, one);
761 dk.elementWiseMultiply (one/theta, D_inv, B, zero);
765 ST rhokp1, dtemp1, dtemp2;
766 for (
int k = 0; k < numIters-1; ++k) {
768 rhokp1 = one / (two*s1 - rhok);
769 dtemp1 = rhokp1*rhok;
770 dtemp2 = two*rhokp1/delta;
774 R.update (-one, pAux, one);
776 dk.elementWiseMultiply (dtemp2, D_inv, B, dtemp1);
777 X.update (one, dk, one);
787 #endif // IFPACK2_DETAILS_CHEBYSHEV_DECL_HPP void setParameters(Teuchos::ParameterList &plist)
Set (or reset) parameters.
Definition: Ifpack2_Details_Chebyshev_def.hpp:333
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:905
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
void setMatrix(const Teuchos::RCP< const row_matrix_type > &A)
Set the matrix.
Definition: Ifpack2_Details_Chebyshev_def.hpp:697
Chebyshev(Teuchos::RCP< const row_matrix_type > A)
Definition: Ifpack2_Details_Chebyshev_def.hpp:279
std::string description() const
A single-line description of the Chebyshev solver.
Definition: Ifpack2_Details_Chebyshev_def.hpp:1505
Ifpack2 implementation details.
bool hasTransposeApply() const
Whether it's possible to apply the transpose of this operator.
Definition: Ifpack2_Details_Chebyshev_def.hpp:1480
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
void print(std::ostream &out)
Print instance data to the given output stream.
Definition: Ifpack2_Details_Chebyshev_def.hpp:958
STS::magnitudeType MT
The type of the absolute value of a ScalarType.
Definition: Ifpack2_Details_Chebyshev_decl.hpp:116
ScalarType ST
The type of entries in the matrix and vectors.
Definition: Ifpack2_Details_Chebyshev_decl.hpp:112
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
Left-scaled Chebyshev iteration.
Definition: Ifpack2_Details_Chebyshev_decl.hpp:106
Teuchos::ScalarTraits< ScalarType > STS
Traits class for ST.
Definition: Ifpack2_Details_Chebyshev_decl.hpp:114
Teuchos::RCP< const row_matrix_type > getMatrix() const
Get the matrix given to the constructor.
Definition: Ifpack2_Details_Chebyshev_def.hpp:1473
Preconditioners and smoothers for Tpetra sparse matrices.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:73
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:1523
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:738
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