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"
62 #ifndef DOXYGEN_SHOULD_SKIP_THIS
63 template<
class TpetraOperatorType>
64 class ChebyshevKernel;
65 #endif // DOXYGEN_SHOULD_SKIP_THIS
108 template<
class ScalarType,
class MV>
115 typedef ScalarType
ST;
121 typedef Tpetra::Operator<
typename MV::scalar_type,
122 typename MV::local_ordinal_type,
123 typename MV::global_ordinal_type,
126 typedef Tpetra::RowMatrix<
typename MV::scalar_type,
127 typename MV::local_ordinal_type,
128 typename MV::global_ordinal_type,
131 typedef Tpetra::Vector<
typename MV::scalar_type,
132 typename MV::local_ordinal_type,
133 typename MV::global_ordinal_type,
134 typename MV::node_type>
V;
136 typedef Tpetra::Map<
typename MV::local_ordinal_type,
137 typename MV::global_ordinal_type,
271 void setZeroStartingSolution (
bool zeroStartingSolution) { zeroStartingSolution_ = zeroStartingSolution; }
326 ST getLambdaMaxForApply()
const;
342 void print (std::ostream& out);
385 typedef Kokkos::View<size_t*, typename MV::node_type::device_type> offsets_type;
392 offsets_type diagOffsets_;
401 bool savedDiagOffsets_;
418 ST computedLambdaMax_;
425 ST computedLambdaMin_;
433 ST lambdaMaxForApply_;
444 ST lambdaMinForApply_;
447 ST eigRatioForApply_;
490 bool eigKeepVectors_;
493 std::string eigenAnalysisType_;
500 int eigNormalizationFreq_;
503 bool zeroStartingSolution_;
511 bool assumeMatrixUnchanged_;
514 std::string chebyshevAlgorithm_;
517 bool computeMaxResNorm_;
520 bool computeSpectralRadius_;
524 bool ckUseNativeSpMV_;
539 void checkConstructorInput ()
const;
542 void checkInputMatrix ()
const;
570 firstIterationWithZeroStartingSolution
572 const ScalarType& alpha,
579 computeResidual (MV& R,
const MV& B,
const op_type& A,
const MV& X,
587 static void solve (MV& Z,
const V& D_inv,
const MV& R);
594 static void solve (MV& Z,
const ST alpha,
const V& D_inv,
const MV& R);
604 makeInverseDiagonal (
const row_matrix_type& A,
const bool useDiagOffsets=
false)
const;
640 textbookApplyImpl (
const op_type& A,
647 const V& D_inv)
const;
671 fourthKindApplyImpl (
const op_type& A,
701 ifpackApplyImpl (
const op_type& A,
723 cgMethodWithInitGuess (
const op_type& A,
const V& D_inv,
const int numIters,
V& x);
735 cgMethod (
const op_type& A,
const V& D_inv,
const int numIters);
738 static MT maxNormInf (
const MV& X);
776 const ST zero = Teuchos::as<ST> (0);
777 const ST one = Teuchos::as<ST> (1);
778 const ST two = Teuchos::as<ST> (2);
780 MV pAux (B.getMap (), B.getNumVectors ());
781 MV dk (B.getMap (), B.getNumVectors ());
782 MV R (B.getMap (), B.getNumVectors ());
784 ST beta = Teuchos::as<ST> (1.1) * lambdaMax;
785 ST alpha = lambdaMax / eigRatio;
787 ST delta = (beta - alpha) / two;
788 ST theta = (beta + alpha) / two;
789 ST s1 = theta / delta;
800 if (lambdaMin == one && lambdaMin == lambdaMax) {
809 if (! zeroStartingSolution_) {
813 R.update (-one, pAux, one);
814 dk.elementWiseMultiply (one/theta, D_inv, R, zero);
815 X.update (one, dk, one);
817 dk.elementWiseMultiply (one/theta, D_inv, B, zero);
821 ST rhokp1, dtemp1, dtemp2;
822 for (
int k = 0; k < numIters-1; ++k) {
824 rhokp1 = one / (two*s1 - rhok);
825 dtemp1 = rhokp1*rhok;
826 dtemp2 = two*rhokp1/delta;
830 R.update (-one, pAux, one);
832 dk.elementWiseMultiply (dtemp2, D_inv, B, dtemp1);
833 X.update (one, dk, one);
843 #endif // IFPACK2_DETAILS_CHEBYSHEV_DECL_HPP
void setParameters(Teuchos::ParameterList &plist)
Set (or reset) parameters.
Definition: Ifpack2_Details_Chebyshev_def.hpp:383
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:1044
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:124
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:1737
void setMatrix(const Teuchos::RCP< const row_matrix_type > &A)
Set the matrix.
Definition: Ifpack2_Details_Chebyshev_def.hpp:810
Teuchos::RCP< const row_matrix_type > getMatrix() const
Get the matrix given to the constructor.
Definition: Ifpack2_Details_Chebyshev_def.hpp:1668
Chebyshev(Teuchos::RCP< const row_matrix_type > A)
Definition: Ifpack2_Details_Chebyshev_def.hpp:317
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:138
void print(std::ostream &out)
Print instance data to the given output stream.
Definition: Ifpack2_Details_Chebyshev_def.hpp:1100
STS::magnitudeType MT
The type of the absolute value of a ScalarType.
Definition: Ifpack2_Details_Chebyshev_decl.hpp:119
ScalarType ST
The type of entries in the matrix and vectors.
Definition: Ifpack2_Details_Chebyshev_decl.hpp:115
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:129
Left-scaled Chebyshev iteration.
Definition: Ifpack2_Details_Chebyshev_decl.hpp:109
static const EVerbosityLevel verbLevel_default
std::string description() const
A single-line description of the Chebyshev solver.
Definition: Ifpack2_Details_Chebyshev_def.hpp:1716
Teuchos::ScalarTraits< ScalarType > STS
Traits class for ST.
Definition: Ifpack2_Details_Chebyshev_decl.hpp:117
bool hasTransposeApply() const
Whether it's possible to apply the transpose of this operator.
Definition: Ifpack2_Details_Chebyshev_def.hpp:1675
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:851
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:134