10 #ifndef IFPACK2_DETAILS_CHEBYSHEV_DECL_HPP
11 #define IFPACK2_DETAILS_CHEBYSHEV_DECL_HPP
20 #include "Ifpack2_ConfigDefs.hpp"
22 #include "Teuchos_Describable.hpp"
23 #include "Tpetra_CrsMatrix.hpp"
28 #ifndef DOXYGEN_SHOULD_SKIP_THIS
29 template <
class TpetraOperatorType>
30 class ChebyshevKernel;
31 #endif // DOXYGEN_SHOULD_SKIP_THIS
74 template <
class ScalarType,
class MV>
81 typedef ScalarType
ST;
87 typedef Tpetra::Operator<
typename MV::scalar_type,
88 typename MV::local_ordinal_type,
89 typename MV::global_ordinal_type,
90 typename MV::node_type>
93 typedef Tpetra::RowMatrix<
typename MV::scalar_type,
94 typename MV::local_ordinal_type,
95 typename MV::global_ordinal_type,
96 typename MV::node_type>
99 typedef Tpetra::Vector<
typename MV::scalar_type,
100 typename MV::local_ordinal_type,
101 typename MV::global_ordinal_type,
102 typename MV::node_type>
105 typedef Tpetra::Map<
typename MV::local_ordinal_type,
106 typename MV::global_ordinal_type,
107 typename MV::node_type>
241 void setZeroStartingSolution(
bool zeroStartingSolution) { zeroStartingSolution_ = zeroStartingSolution; }
296 ST getLambdaMaxForApply()
const;
312 void print(std::ostream& out);
355 typedef Kokkos::View<size_t*, typename MV::node_type::device_type> offsets_type;
362 offsets_type diagOffsets_;
371 bool savedDiagOffsets_;
388 ST computedLambdaMax_;
395 ST computedLambdaMin_;
403 ST lambdaMaxForApply_;
414 ST lambdaMinForApply_;
417 ST eigRatioForApply_;
460 bool eigKeepVectors_;
463 std::string eigenAnalysisType_;
470 int eigNormalizationFreq_;
473 bool zeroStartingSolution_;
481 bool assumeMatrixUnchanged_;
484 std::string chebyshevAlgorithm_;
487 bool computeMaxResNorm_;
490 bool computeSpectralRadius_;
494 bool ckUseNativeSpMV_;
509 void checkConstructorInput()
const;
512 void checkInputMatrix()
const;
540 firstIterationWithZeroStartingSolution(MV& W,
541 const ScalarType& alpha,
548 computeResidual(MV& R,
const MV& B,
const op_type& A,
const MV& X,
556 static void solve(MV& Z,
const V& D_inv,
const MV& R);
563 static void solve(MV& Z,
const ST alpha,
const V& D_inv,
const MV& R);
573 makeInverseDiagonal(
const row_matrix_type& A,
const bool useDiagOffsets =
false)
const;
609 textbookApplyImpl(
const op_type& A,
616 const V& D_inv)
const;
640 fourthKindApplyImpl(
const op_type& A,
670 ifpackApplyImpl(
const op_type& A,
691 ST cgMethodWithInitGuess(
const op_type& A,
const V& D_inv,
const int numIters,
V& x);
702 ST cgMethod(
const op_type& A,
const V& D_inv,
const int numIters);
705 static MT maxNormInf(
const MV& X);
743 const ST zero = Teuchos::as<ST> (0);
744 const ST one = Teuchos::as<ST> (1);
745 const ST two = Teuchos::as<ST> (2);
747 MV pAux (B.getMap (), B.getNumVectors ());
748 MV dk (B.getMap (), B.getNumVectors ());
749 MV R (B.getMap (), B.getNumVectors ());
751 ST beta = Teuchos::as<ST> (1.1) * lambdaMax;
752 ST alpha = lambdaMax / eigRatio;
754 ST delta = (beta - alpha) / two;
755 ST theta = (beta + alpha) / two;
756 ST s1 = theta / delta;
767 if (lambdaMin == one && lambdaMin == lambdaMax) {
776 if (! zeroStartingSolution_) {
780 R.update (-one, pAux, one);
781 dk.elementWiseMultiply (one/theta, D_inv, R, zero);
782 X.update (one, dk, one);
784 dk.elementWiseMultiply (one/theta, D_inv, B, zero);
788 ST rhokp1, dtemp1, dtemp2;
789 for (
int k = 0; k < numIters-1; ++k) {
791 rhokp1 = one / (two*s1 - rhok);
792 dtemp1 = rhokp1*rhok;
793 dtemp2 = two*rhokp1/delta;
797 R.update (-one, pAux, one);
799 dk.elementWiseMultiply (dtemp2, D_inv, B, dtemp1);
800 X.update (one, dk, one);
810 #endif // IFPACK2_DETAILS_CHEBYSHEV_DECL_HPP
void setParameters(Teuchos::ParameterList &plist)
Set (or reset) parameters.
Definition: Ifpack2_Details_Chebyshev_def.hpp:326
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:959
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:91
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:1613
void setMatrix(const Teuchos::RCP< const row_matrix_type > &A)
Set the matrix.
Definition: Ifpack2_Details_Chebyshev_def.hpp:734
Teuchos::RCP< const row_matrix_type > getMatrix() const
Get the matrix given to the constructor.
Definition: Ifpack2_Details_Chebyshev_def.hpp:1549
Chebyshev(Teuchos::RCP< const row_matrix_type > A)
Definition: Ifpack2_Details_Chebyshev_def.hpp:263
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:108
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:85
ScalarType ST
The type of entries in the matrix and vectors.
Definition: Ifpack2_Details_Chebyshev_decl.hpp:81
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:97
Left-scaled Chebyshev iteration.
Definition: Ifpack2_Details_Chebyshev_decl.hpp:75
static const EVerbosityLevel verbLevel_default
std::string description() const
A single-line description of the Chebyshev solver.
Definition: Ifpack2_Details_Chebyshev_def.hpp:1593
Teuchos::ScalarTraits< ScalarType > STS
Traits class for ST.
Definition: Ifpack2_Details_Chebyshev_decl.hpp:83
bool hasTransposeApply() const
Whether it's possible to apply the transpose of this operator.
Definition: Ifpack2_Details_Chebyshev_def.hpp:1555
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:770
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:103