Ifpack2 Templated Preconditioning Package
Version 1.0
|
Left-scaled Chebyshev iteration. More...
#include <Ifpack2_Details_Chebyshev_decl.hpp>
Public Types | |
Typedefs | |
typedef ScalarType | ST |
The type of entries in the matrix and vectors. More... | |
typedef Teuchos::ScalarTraits < ScalarType > | STS |
Traits class for ST. More... | |
typedef STS::magnitudeType | MT |
The type of the absolute value of a ScalarType. More... | |
typedef 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. More... | |
typedef 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. More... | |
typedef 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. More... | |
typedef Tpetra::Map< typename MV::local_ordinal_type, typename MV::global_ordinal_type, typename MV::node_type > | map_type |
Specialization of Tpetra::Map. More... | |
Public Member Functions | |
Chebyshev (Teuchos::RCP< const row_matrix_type > A) | |
Chebyshev (Teuchos::RCP< const row_matrix_type > A, Teuchos::ParameterList ¶ms) | |
void | setParameters (Teuchos::ParameterList &plist) |
Set (or reset) parameters. More... | |
void | compute () |
(Re)compute the left scaling D_inv, and estimate min and max eigenvalues of D_inv * A. More... | |
MT | apply (const MV &B, MV &X) |
Solve Ax=b for x with Chebyshev iteration with left diagonal scaling. More... | |
Teuchos::RCP< const row_matrix_type > | getMatrix () const |
Get the matrix given to the constructor. More... | |
void | setMatrix (const Teuchos::RCP< const row_matrix_type > &A) |
Set the matrix. More... | |
bool | hasTransposeApply () const |
Whether it's possible to apply the transpose of this operator. More... | |
void | print (std::ostream &out) |
Print instance data to the given output stream. More... | |
Implementation of Teuchos::Describable | |
std::string | description () const |
A single-line description of the Chebyshev solver. More... | |
void | describe (Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const |
Print a description of the Chebyshev solver to out . More... | |
Left-scaled Chebyshev iteration.
ScalarType | The type of entries in the matrix and vectors. |
MV | Specialization of Tpetra::MultiVector. |
This class implements two variants of Chebyshev iteration:
All implemented variants use the diagonal of the matrix to precondition the linear system on the left. Diagonal entries less than machine precision are replaced with machine precision.
The first version imitates Ifpack_Chebyshev, both in how it sets parameters and in the actual iteration (ApplyInverse()). The "textbook" in variant #2 above is "Templates for the Solution of Linear Systems," 2nd edition. Experiments show that the Ifpack imitation is much less sensitive to the eigenvalue bounds than the textbook version, so users should prefer it. (In fact, it is the default.) Variant #3 is an experimental implementation of Chebyshev polynomials of the 4th kind with optimal coefficients, from https://arxiv.org/pdf/2202.08830.pdf.
We require that the matrix A be real valued and symmetric positive definite. If users could provide the ellipse parameters ("d" and "c" in the literature, where d is the real-valued center of the ellipse, and d-c and d+c the two foci), the iteration itself would work fine with nonsymmetric real-valued A, as long as the eigenvalues of A can be bounded in an ellipse that is entirely to the right of the origin.
There is also dead code for imitating ML's Chebyshev implementation (ML_Cheby(), in packages/ml/src/Smoother/ml_smoother.c). I couldn't get it to converge in time to be useful for testing, so it is disabled.
typedef ScalarType Ifpack2::Details::Chebyshev< ScalarType, MV >::ST |
The type of entries in the matrix and vectors.
typedef Teuchos::ScalarTraits<ScalarType> Ifpack2::Details::Chebyshev< ScalarType, MV >::STS |
Traits class for ST.
typedef STS::magnitudeType Ifpack2::Details::Chebyshev< ScalarType, MV >::MT |
The type of the absolute value of a ScalarType.
typedef Tpetra::Operator<typename MV::scalar_type, typename MV::local_ordinal_type, typename MV::global_ordinal_type, typename MV::node_type> Ifpack2::Details::Chebyshev< ScalarType, MV >::op_type |
Specialization of Tpetra::Operator.
typedef Tpetra::RowMatrix<typename MV::scalar_type, typename MV::local_ordinal_type, typename MV::global_ordinal_type, typename MV::node_type> Ifpack2::Details::Chebyshev< ScalarType, MV >::row_matrix_type |
Specialization of Tpetra::RowMatrix.
typedef Tpetra::Vector<typename MV::scalar_type, typename MV::local_ordinal_type, typename MV::global_ordinal_type, typename MV::node_type> Ifpack2::Details::Chebyshev< ScalarType, MV >::V |
Specialization of Tpetra::Vector.
typedef Tpetra::Map<typename MV::local_ordinal_type, typename MV::global_ordinal_type, typename MV::node_type> Ifpack2::Details::Chebyshev< ScalarType, MV >::map_type |
Specialization of Tpetra::Map.
Ifpack2::Details::Chebyshev< ScalarType, MV >::Chebyshev | ( | Teuchos::RCP< const row_matrix_type > | A | ) |
Constructor that takes a sparse matrix and sets default parameters.
A | [in] The matrix A in the linear system to solve. If A is nonnull, it must be real-valued and symmetric positive definite. The input A may be null. In that case, you must call setMatrix() with a nonnull input before you may call compute() or apply(). |
Ifpack2::Details::Chebyshev< ScalarType, MV >::Chebyshev | ( | Teuchos::RCP< const row_matrix_type > | A, |
Teuchos::ParameterList & | params | ||
) |
Constructor that takes a sparse matrix and sets the user's parameters.
A | [in] The matrix A in the linear system to solve. If A is nonnull, it must be real-valued and symmetric positive definite. The input A may be null. In that case, you must call setMatrix() with a nonnull input before you may call compute() or apply(). |
params | [in/out] On input: the parameters. On output: filled with the current parameter settings. |
void Ifpack2::Details::Chebyshev< ScalarType, MV >::setParameters | ( | Teuchos::ParameterList & | plist | ) |
Set (or reset) parameters.
This method fills in the input ParameterList with missing parameters set to their default values. You may call this method as many times as you want. On each call, the input ParameterList is treated as a complete list of the desired parameters, not as a "delta" or change list from the current set of parameters. (That is, if you remove parameters from the list that were there in the last call to setParameters() and call setParameters() again with the revised list, this method will use default values for the removed parameters, rather than letting the current settings remain.) However, since the method fills in missing parameters, you may keep calling it with the ParameterList used in the previous call in order to get the same behavior as before.
Parameters that govern spectral bounds of the matrix:
ScalarType
): lambdaMax, an upper bound of the bounding ellipse of the eigenvalues of the matrix A. If you do not set this parameter, we will compute an approximation. See "Parameters that govern eigenvalue
analysis" to control this approximation process.ScalarType
): eigRatio, the ratio of lambdaMax to the lower bound of the bounding ellipse of the eigenvalues of A. We use lambdaMax and eigRatio to determine the Chebyshev iteration coefficients. This parameter is optional and defaults to 30.ScalarType
): lambdaMin, a lower bound of real part of bounding ellipse of eigenvalues of the matrix A. This parameter is optional and only used for a quick check if the matrix is the identity matrix (if lambdaMax == lambdaMin == 1).Parameters that govern the number of Chebyshev iterations:
int
): numIters, the number of iterations. This overrides "relaxation: sweeps" and "smoother: sweeps" (see below).int
): numIters, the number of iterations. We include this for compatibility with Ifpack. This overrides "smoother: sweeps" (see below).int
): numIters, as above. We include this for compatibility with ML.Parameters that govern eigenvalue analysis:
int
): eigMaxIters, the number of power method iterations used to compute the maximum eigenvalue. This overrides "eigen-analysis:
iterations" (see below).int
): eigMaxIters, as above. We include this parameter for compatibility with ML.std::string
): The algorithm to use for estimating the max eigenvalue. This parameter is optional. Currently, we only support "power-method" (or "power method"), which is what Ifpack::Chebyshev uses for eigenanalysis. We include this parameter for compatibility with ML.Parameters that govern other algorithmic details:
RCP<const V>
or const V*
): If nonnull, we will use a deep copy of this vector for left scaling as the inverse diagonal of the matrix A, instead of computing the inverse diagonal ourselves. We will make a copy every time you call setParameters(). If you ever call setParameters() without this parameter, we will clear our copy and compute the inverse diagonal ourselves again. If you choose to provide this parameter, you are responsible for updating this if the matrix has changed.ST
): minDiagVal. If any entry of the diagonal of the matrix is less than this in magnitude, it will be replaced with this value in the inverse diagonal used for left scaling.bool
): If true, then always use the zero vector(s) as the initial guess(es). If false, then apply() will use X on input as the initial guess(es).bool
): If true, the power method will compute the spectral radius of the operator. If false, it will compute the dominant eigenvalue.Parameters that govern backwards compatibility:
bool
): If true, use the textbook version of Chebyshev iteration. We recommend against this, since the default algorithm is less sensitive to the quality of the eigenvalue bounds.bool
): If true, apply() will compute and return the max (absolute) residual norm. Otherwise, apply() returns 0. This defaults to false.The above compatibility parameters are not exposed in the documentation of Ifpack2::Chebyshev, because they are more useful to Ifpack2 developers than to users.
Default settings for parameters relating to spectral bounds come from Ifpack.
void Ifpack2::Details::Chebyshev< ScalarType, MV >::compute | ( | ) |
(Re)compute the left scaling D_inv, and estimate min and max eigenvalues of D_inv * A.
You must call this method before calling apply(),
The input matrix must be nonnull before you may call this method. If the input matrix is null, you must first call setMatrix() with a nonnull input matrix before you may call this method.
Users have the option to supply the left scaling vector D_inv
and estimates of the min and max eigenvalues of D_inv * A
as parameters to setParameters(). If users did not supply a left scaling, then this method will compute it by default (if assumeMatrixUnchanged is false). Likewise, if users did not supply at least an estimate of the max eigenvalue, this method will estimate it by default. If estimation of the eigenvalues is required, this method may take as long as several Chebyshev iterations.
Advanced users may avoid recomputing the left scaling vector and eigenvalue estimates by setting the "chebyshev: assume matrix
does not change" parameter of setParameters() to true
. The left scaling vector and eigenvalue estimates will always be computed if the user did not provide them and we have not yet computed them. Any changes to parameters that affect computation of the inverse diagonal or estimation of the eigenvalue bounds will not affect subsequent apply() operations, until the "chebyshev: assume matrix does not change" parameter is set back to false
(its default value).
Chebyshev< ScalarType, MV >::MT Ifpack2::Details::Chebyshev< ScalarType, MV >::apply | ( | const MV & | B, |
MV & | X | ||
) |
Solve Ax=b for x with Chebyshev iteration with left diagonal scaling.
B | [in] Right-hand side(s) in the linear system to solve. |
X | [in] Initial guess(es) for the linear system to solve. |
If the "chebyshev: compute max residual norm" parameter is true (not the default), then this method returns the maximum (over all columns) absolute residual 2-norm after iterating. Otherwise, it returns zero.
Teuchos::RCP< const typename Chebyshev< ScalarType, MV >::row_matrix_type > Ifpack2::Details::Chebyshev< ScalarType, MV >::getMatrix | ( | ) | const |
Get the matrix given to the constructor.
void Ifpack2::Details::Chebyshev< ScalarType, MV >::setMatrix | ( | const Teuchos::RCP< const row_matrix_type > & | A | ) |
bool Ifpack2::Details::Chebyshev< ScalarType, MV >::hasTransposeApply | ( | ) | const |
Whether it's possible to apply the transpose of this operator.
void Ifpack2::Details::Chebyshev< ScalarType, MV >::print | ( | std::ostream & | out | ) |
Print instance data to the given output stream.
|
virtual |
A single-line description of the Chebyshev solver.
Reimplemented from Teuchos::Describable.
|
virtual |
Print a description of the Chebyshev solver to out
.
Reimplemented from Teuchos::Describable.