70 #ifndef IFPACK2_DETAILS_CHEBYSHEV_DECL_HPP 71 #define IFPACK2_DETAILS_CHEBYSHEV_DECL_HPP 80 #include <Ifpack2_ConfigDefs.hpp> 81 #include <Teuchos_VerbosityLevel.hpp> 82 #include <Teuchos_Describable.hpp> 83 #include <Tpetra_CrsMatrix.hpp> 126 template<
class ScalarType,
class MV>
133 typedef ScalarType
ST;
135 typedef Teuchos::ScalarTraits<ScalarType>
STS;
137 typedef typename STS::magnitudeType
MT;
139 typedef Tpetra::Operator<
typename MV::scalar_type,
140 typename MV::local_ordinal_type,
141 typename MV::global_ordinal_type,
144 typedef Tpetra::RowMatrix<
typename MV::scalar_type,
145 typename MV::local_ordinal_type,
146 typename MV::global_ordinal_type,
149 typedef Tpetra::Vector<
typename MV::scalar_type,
150 typename MV::local_ordinal_type,
151 typename MV::global_ordinal_type,
152 typename MV::node_type>
V;
154 typedef Tpetra::Map<
typename MV::local_ordinal_type,
155 typename MV::global_ordinal_type,
166 Chebyshev (Teuchos::RCP<const row_matrix_type> A);
177 Chebyshev (Teuchos::RCP<const row_matrix_type> A, Teuchos::ParameterList& params);
337 MT
apply (
const MV& B, MV& X);
339 ST getLambdaMaxForApply()
const;
342 Teuchos::RCP<const row_matrix_type>
getMatrix ()
const;
349 void setMatrix (
const Teuchos::RCP<const row_matrix_type>& A);
355 void print (std::ostream& out);
366 describe (Teuchos::FancyOStream& out,
367 const Teuchos::EVerbosityLevel verbLevel =
368 Teuchos::Describable::verbLevel_default)
const;
380 Teuchos::RCP<const row_matrix_type> A_;
392 Teuchos::RCP<const V> D_;
399 Teuchos::ArrayRCP<size_t> diagOffsets_;
408 bool savedDiagOffsets_;
429 ST computedLambdaMax_;
436 ST computedLambdaMin_;
444 ST lambdaMaxForApply_;
447 ST lambdaMinForApply_;
450 ST eigRatioForApply_;
460 Teuchos::RCP<const V> userInvDiag_;
490 bool zeroStartingSolution_;
498 bool assumeMatrixUnchanged_;
501 bool textbookAlgorithm_;
504 bool computeMaxResNorm_;
511 void checkConstructorInput ()
const;
514 void checkInputMatrix ()
const;
538 makeTempMultiVectors (Teuchos::RCP<MV>& V1,
544 computeResidual (MV& R,
const MV& B,
const op_type& A,
const MV& X,
545 const Teuchos::ETransp mode = Teuchos::NO_TRANS);
552 static void solve (MV& Z,
const V& D_inv,
const MV& R);
559 static void solve (MV& Z,
const ST alpha,
const V& D_inv,
const MV& R);
568 Teuchos::RCP<const V>
569 makeInverseDiagonal (
const row_matrix_type& A,
const bool useDiagOffsets=
false)
const;
580 Teuchos::RCP<V> makeRangeMapVector (
const Teuchos::RCP<V>& D)
const;
583 Teuchos::RCP<const V>
584 makeRangeMapVectorConst (
const Teuchos::RCP<const V>& D)
const;
605 textbookApplyImpl (
const op_type& A,
612 const V& D_inv)
const;
637 ifpackApplyImpl (
const op_type& A,
659 powerMethodWithInitGuess (
const op_type& A,
const V& D_inv,
const int numIters, V& x);
671 powerMethod (
const op_type& A,
const V& D_inv,
const int numIters);
674 static MT maxNormInf (
const MV& X);
703 mlApplyImpl (
const op_type& A,
712 const ST zero = Teuchos::as<ST> (0);
713 const ST one = Teuchos::as<ST> (1);
714 const ST two = Teuchos::as<ST> (2);
716 MV pAux (B.getMap (), B.getNumVectors ());
717 MV dk (B.getMap (), B.getNumVectors ());
718 MV R (B.getMap (), B.getNumVectors ());
720 ST beta = Teuchos::as<ST> (1.1) * lambdaMax;
721 ST alpha = lambdaMax / eigRatio;
723 ST delta = (beta - alpha) / two;
724 ST theta = (beta + alpha) / two;
725 ST s1 = theta / delta;
736 if (lambdaMin == one && lambdaMin == lambdaMax) {
745 if (! zeroStartingSolution_) {
749 R.update (-one, pAux, one);
750 dk.elementWiseMultiply (one/theta, D_inv, R, zero);
751 X.update (one, dk, one);
753 dk.elementWiseMultiply (one/theta, D_inv, B, zero);
757 ST rhokp1, dtemp1, dtemp2;
758 for (
int k = 0; k < numIters-1; ++k) {
760 rhokp1 = one / (two*s1 - rhok);
761 dtemp1 = rhokp1*rhok;
762 dtemp2 = two*rhokp1/delta;
766 R.update (-one, pAux, one);
768 dk.elementWiseMultiply (dtemp2, D_inv, B, dtemp1);
769 X.update (one, dk, one);
779 #endif // IFPACK2_DETAILS_CHEBYSHEV_DECL_HPP void setParameters(Teuchos::ParameterList &plist)
Set (or reset) parameters.
Definition: Ifpack2_Details_Chebyshev_def.hpp:316
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:825
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:142
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:1348
void setMatrix(const Teuchos::RCP< const row_matrix_type > &A)
Set the matrix.
Definition: Ifpack2_Details_Chebyshev_def.hpp:652
Teuchos::RCP< const row_matrix_type > getMatrix() const
Get the matrix given to the constructor.
Definition: Ifpack2_Details_Chebyshev_def.hpp:1298
Chebyshev(Teuchos::RCP< const row_matrix_type > A)
Definition: Ifpack2_Details_Chebyshev_def.hpp:266
Ifpack2 implementation details.
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:156
void print(std::ostream &out)
Print instance data to the given output stream.
Definition: Ifpack2_Details_Chebyshev_def.hpp:872
STS::magnitudeType MT
The type of the absolute value of a ScalarType.
Definition: Ifpack2_Details_Chebyshev_decl.hpp:137
ScalarType ST
The type of entries in the matrix and vectors.
Definition: Ifpack2_Details_Chebyshev_decl.hpp:133
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:147
Left-scaled Chebyshev iteration.
Definition: Ifpack2_Details_Chebyshev_decl.hpp:127
std::string description() const
A single-line description of the Chebyshev solver.
Definition: Ifpack2_Details_Chebyshev_def.hpp:1331
Teuchos::ScalarTraits< ScalarType > STS
Traits class for ST.
Definition: Ifpack2_Details_Chebyshev_decl.hpp:135
bool hasTransposeApply() const
Whether it's possible to apply the transpose of this operator.
Definition: Ifpack2_Details_Chebyshev_def.hpp:1305
Preconditioners and smoothers for Tpetra sparse matrices.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:72
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:665
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:152