44 #ifndef IFPACK2_DETAILS_CHEBYSHEV_DECL_HPP
45 #define IFPACK2_DETAILS_CHEBYSHEV_DECL_HPP
54 #include <Ifpack2_ConfigDefs.hpp>
56 #include <Teuchos_Describable.hpp>
57 #include <Tpetra_CrsMatrix.hpp>
100 template<
class ScalarType,
class MV>
107 typedef ScalarType
ST;
113 typedef Tpetra::Operator<
typename MV::scalar_type,
114 typename MV::local_ordinal_type,
115 typename MV::global_ordinal_type,
118 typedef Tpetra::RowMatrix<
typename MV::scalar_type,
119 typename MV::local_ordinal_type,
120 typename MV::global_ordinal_type,
123 typedef Tpetra::Vector<
typename MV::scalar_type,
124 typename MV::local_ordinal_type,
125 typename MV::global_ordinal_type,
126 typename MV::node_type>
V;
128 typedef Tpetra::Map<
typename MV::local_ordinal_type,
129 typename MV::global_ordinal_type,
313 ST getLambdaMaxForApply()
const;
329 void print (std::ostream& out);
369 typedef Kokkos::View<size_t*, typename MV::node_type::device_type> offsets_type;
376 offsets_type diagOffsets_;
385 bool savedDiagOffsets_;
406 ST computedLambdaMax_;
413 ST computedLambdaMin_;
421 ST lambdaMaxForApply_;
432 ST lambdaMinForApply_;
435 ST eigRatioForApply_;
475 bool zeroStartingSolution_;
483 bool assumeMatrixUnchanged_;
486 bool textbookAlgorithm_;
489 bool computeMaxResNorm_;
504 void checkConstructorInput ()
const;
507 void checkInputMatrix ()
const;
537 computeResidual (MV& R,
const MV& B,
const op_type& A,
const MV& X,
545 static void solve (MV& Z,
const V& D_inv,
const MV& R);
552 static void solve (MV& Z,
const ST alpha,
const V& D_inv,
const MV& R);
562 makeInverseDiagonal (
const row_matrix_type& A,
const bool useDiagOffsets=
false)
const;
598 textbookApplyImpl (
const op_type& A,
605 const V& D_inv)
const;
630 ifpackApplyImpl (
const op_type& A,
650 void computeInitialGuessForPowerMethod (
V& x,
const bool nonnegativeRealParts =
false)
const;
665 powerMethodWithInitGuess (
const op_type& A,
const V& D_inv,
const int numIters,
V& x);
677 powerMethod (
const op_type& A,
const V& D_inv,
const int numIters);
680 static MT maxNormInf (
const MV& X);
718 const ST zero = Teuchos::as<ST> (0);
719 const ST one = Teuchos::as<ST> (1);
720 const ST two = Teuchos::as<ST> (2);
722 MV pAux (B.getMap (), B.getNumVectors ());
723 MV dk (B.getMap (), B.getNumVectors ());
724 MV R (B.getMap (), B.getNumVectors ());
726 ST beta = Teuchos::as<ST> (1.1) * lambdaMax;
727 ST alpha = lambdaMax / eigRatio;
729 ST delta = (beta - alpha) / two;
730 ST theta = (beta + alpha) / two;
731 ST s1 = theta / delta;
742 if (lambdaMin == one && lambdaMin == lambdaMax) {
751 if (! zeroStartingSolution_) {
755 R.update (-one, pAux, one);
756 dk.elementWiseMultiply (one/theta, D_inv, R, zero);
757 X.update (one, dk, one);
759 dk.elementWiseMultiply (one/theta, D_inv, B, zero);
763 ST rhokp1, dtemp1, dtemp2;
764 for (
int k = 0; k < numIters-1; ++k) {
766 rhokp1 = one / (two*s1 - rhok);
767 dtemp1 = rhokp1*rhok;
768 dtemp2 = two*rhokp1/delta;
772 R.update (-one, pAux, one);
774 dk.elementWiseMultiply (dtemp2, D_inv, B, dtemp1);
775 X.update (one, dk, one);
785 #endif // IFPACK2_DETAILS_CHEBYSHEV_DECL_HPP
void setParameters(Teuchos::ParameterList &plist)
Set (or reset) parameters.
Definition: Ifpack2_Details_Chebyshev_def.hpp:329
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:956
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:116
scalar_type magnitudeType
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:1574
void setMatrix(const Teuchos::RCP< const row_matrix_type > &A)
Set the matrix.
Definition: Ifpack2_Details_Chebyshev_def.hpp:745
Teuchos::RCP< const row_matrix_type > getMatrix() const
Get the matrix given to the constructor.
Definition: Ifpack2_Details_Chebyshev_def.hpp:1520
Chebyshev(Teuchos::RCP< const row_matrix_type > A)
Definition: Ifpack2_Details_Chebyshev_def.hpp:276
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:130
void print(std::ostream &out)
Print instance data to the given output stream.
Definition: Ifpack2_Details_Chebyshev_def.hpp:1009
STS::magnitudeType MT
The type of the absolute value of a ScalarType.
Definition: Ifpack2_Details_Chebyshev_decl.hpp:111
ScalarType ST
The type of entries in the matrix and vectors.
Definition: Ifpack2_Details_Chebyshev_decl.hpp:107
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:121
Left-scaled Chebyshev iteration.
Definition: Ifpack2_Details_Chebyshev_decl.hpp:101
static const EVerbosityLevel verbLevel_default
std::string description() const
A single-line description of the Chebyshev solver.
Definition: Ifpack2_Details_Chebyshev_def.hpp:1556
Teuchos::ScalarTraits< ScalarType > STS
Traits class for ST.
Definition: Ifpack2_Details_Chebyshev_decl.hpp:109
bool hasTransposeApply() const
Whether it's possible to apply the transpose of this operator.
Definition: Ifpack2_Details_Chebyshev_def.hpp:1527
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:786
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:126