#include <Ifpack_CrsRick.h>
Inheritance diagram for Ifpack_CrsRick:
char * | Label () const |
Returns a character string describing the operator. | |
int | SetUseTranspose (bool UseTranspose) |
If set true, transpose of this operator will be applied. | |
int | Apply (const Epetra_MultiVector &X, Epetra_MultiVector &Y) const |
Returns the result of a Epetra_Operator applied to a Epetra_MultiVector X in Y. | |
int | ApplyInverse (const Epetra_MultiVector &X, Epetra_MultiVector &Y) const |
Returns the result of a Epetra_Operator inverse applied to an Epetra_MultiVector X in Y. | |
double | NormInf () const |
Returns 0.0 because this class cannot compute Inf-norm. | |
bool | HasNormInf () const |
Returns false because this class cannot compute an Inf-norm. | |
bool | UseTranspose () const |
Returns the current UseTranspose setting. | |
const Epetra_Map & | OperatorDomainMap () const |
Returns the Epetra_Map object associated with the domain of this operator. | |
const Epetra_Map & | OperatorRangeMap () const |
Returns the Epetra_Map object associated with the range of this operator. | |
Public Member Functions | |
Ifpack_CrsRick (const Epetra_CrsMatrix &A, const Ifpack_IlukGraph &Graph) | |
Ifpack_CrsRick constuctor with variable number of indices per row. | |
Ifpack_CrsRick (const Ifpack_CrsRick &Matrix) | |
Copy constructor. | |
virtual | ~Ifpack_CrsRick () |
Ifpack_CrsRick Destructor. | |
int | InitValues () |
Initialize L and U with values from user matrix A. | |
bool | ValuesInitialized () const |
If values have been initialized, this query returns true, otherwise it returns false. | |
void | SetRelaxValue (double RelaxValue) |
Set RILU(k) relaxation parameter. | |
void | SetAbsoluteThreshold (double Athresh) |
Set absolute threshold value. | |
void | SetRelativeThreshold (double Rthresh) |
Set relative threshold value. | |
void | SetOverlapMode (Epetra_CombineMode OverlapMode) |
Set overlap mode type. | |
int | SetParameters (const Teuchos::ParameterList ¶meterlist, bool cerr_warning_if_unused=false) |
Set parameters using a Teuchos::ParameterList object. | |
int | Factor () |
Compute ILU factors L and U using the specified graph, diagonal perturbation thresholds and relaxation parameters. | |
bool | Factored () const |
If factor is completed, this query returns true, otherwise it returns false. | |
int | Solve (bool Trans, const Epetra_Vector &x, Epetra_Vector &y) const |
Returns the result of a Ifpack_CrsRick forward/back solve on a Epetra_Vector x in y. | |
int | Solve (bool Trans, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const |
Returns the result of a Ifpack_CrsRick forward/back solve on a Epetra_MultiVector X in Y. | |
int | Multiply (bool Trans, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const |
Returns the result of multiplying U, D and U^T in that order on an Epetra_MultiVector X in Y. | |
int | Condest (bool Trans, double &ConditionNumberEstimate) const |
Returns the maximum over all the condition number estimate for each local ILU set of factors. | |
double | GetRelaxValue () |
Get RILU(k) relaxation parameter. | |
double | GetAbsoluteThreshold () |
Get absolute threshold value. | |
double | GetRelativeThreshold () |
Get relative threshold value. | |
Epetra_CombineMode | GetOverlapMode () |
Get overlap mode type. | |
int | NumGlobalRows () const |
Returns the number of global matrix rows. | |
int | NumGlobalCols () const |
Returns the number of global matrix columns. | |
int | NumGlobalNonzeros () const |
Returns the number of nonzero entries in the global graph. | |
virtual int | NumGlobalDiagonals () const |
Returns the number of diagonal entries found in the global input graph. | |
int | NumMyRows () const |
Returns the number of local matrix rows. | |
int | NumMyCols () const |
Returns the number of local matrix columns. | |
int | NumMyNonzeros () const |
Returns the number of nonzero entries in the local graph. | |
virtual int | NumMyDiagonals () const |
Returns the number of diagonal entries found in the local input graph. | |
int | IndexBase () const |
Returns the index base for row and column indices for this graph. | |
const Ifpack_IlukGraph & | Graph () const |
Returns the address of the Ifpack_IlukGraph associated with this factored matrix. | |
const Epetra_Vector & | D () const |
Returns the address of the D factor associated with this factored matrix. | |
const Epetra_CrsMatrix & | U () const |
Returns the address of the U factor associated with this factored matrix. | |
Protected Member Functions | |
void | SetFactored (bool Flag) |
void | SetValuesInitialized (bool Flag) |
bool | Allocated () const |
int | SetAllocated (bool Flag) |
Private Member Functions | |
int | Allocate () |
Private Attributes | |
const Epetra_CrsMatrix & | A_ |
const Ifpack_IlukGraph & | Graph_ |
Epetra_CrsMatrix * | U_ |
Epetra_Vector * | D_ |
bool | UseTranspose_ |
bool | Allocated_ |
bool | ValuesInitialized_ |
bool | Factored_ |
double | RelaxValue_ |
double | Athresh_ |
double | Rthresh_ |
double | Condest_ |
Epetra_MultiVector * | OverlapX_ |
Epetra_MultiVector * | OverlapY_ |
Epetra_CombineMode | OverlapMode_ |
Friends | |
ostream & | operator<< (ostream &os, const Ifpack_CrsRick &A) |
<< operator will work for Ifpack_CrsRick. |
The Ifpack_CrsRick class computes a "Relaxed" ILU factorization with level k fill of a given Epetra_CrsMatrix. The factorization that is produced is a function of several parameters:
Once the factorization is computed, applying the factorization \(LUy = x\) results in redundant approximations for any elements of y that correspond to rows that are part of more than one local ILU factor. The OverlapMode (changed by calling SetOverlapMode()) defines how these redundancies are handled using the Epetra_CombineMode enum. The default is to zero out all values of y for rows that were not part of the original matrix row distribution.
For most situations, RelaxValue should be set to zero. For certain kinds of problems, e.g., reservoir modeling, there is a conservation principle involved such that any operator should obey a zero row-sum property. MILU was designed for these cases and you should set the RelaxValue to 1. For other situations, setting RelaxValue to some nonzero value may improve the stability of factorization, and can be used if the computed ILU factors are poorly conditioned.
Estimating Preconditioner Condition Numbers
For ill-conditioned matrices, we often have difficulty computing usable incomplete factorizations. The most common source of problems is that the factorization may encounter a small or zero pivot, in which case the factorization can fail, or even if the factorization succeeds, the factors may be so poorly conditioned that use of them in the iterative phase produces meaningless results. Before we can fix this problem, we must be able to detect it. To this end, we use a simple but effective condition number estimate for .
The condition of a matrix , called , is defined as in some appropriate norm . gives some indication of how many accurate floating point digits can be expected from operations involving the matrix and its inverse. A condition number approaching the accuracy of a given floating point number system, about 15 decimal digits in IEEE double precision, means that any results involving or may be meaningless.
The -norm of a vector is defined as the maximum of the absolute values of the vector entries, and the -norm of a matrix C is defined as . A crude lower bound for the is where . It is a lower bound because .
For our purposes, we want to estimate , where and are our incomplete factors. Edmond in his Ph.D. thesis demonstrates that provides an effective estimate for . Furthermore, since finding such that is a basic kernel for applying the preconditioner, computing this estimate of is performed by setting , calling the solve kernel to compute and then computing .
A priori Diagonal Perturbations
Given the above method to estimate the conditioning of the incomplete factors, if we detect that our factorization is too ill-conditioned we can improve the conditioning by perturbing the matrix diagonal and restarting the factorization using this more diagonally dominant matrix. In order to apply perturbation, prior to starting the factorization, we compute a diagonal perturbation of our matrix and perform the factorization on this perturbed matrix. The overhead cost of perturbing the diagonal is minimal since the first step in computing the incomplete factors is to copy the matrix into the memory space for the incomplete factors. We simply compute the perturbed diagonal at this point.
The actual perturbation values we use are the diagonal values with , , where is the matrix dimension and returns the sign of the diagonal entry. This has the effect of forcing the diagonal values to have minimal magnitude of and to increase each by an amount proportional to , and still keep the sign of the original diagonal entry.
Constructing Ifpack_CrsRick objects
Constructing Ifpack_CrsRick objects is a multi-step process. The basic steps are as follows:
Note that, even after a matrix is constructed, it is possible to update existing matrix entries. It is not possible to create new entries.
Counting Floating Point Operations
Each Ifpack_CrsRick object keep track of the number of serial floating point operations performed using the specified object as the this argument to the function. The Flops() function returns this number as a double precision number. Using this information, in conjunction with the Epetra_Time class, one can get accurate parallel performance numbers. The ResetFlops() function resets the floating point counter.
Definition at line 192 of file Ifpack_CrsRick.h.
Ifpack_CrsRick::Ifpack_CrsRick | ( | const Epetra_CrsMatrix & | A, | |
const Ifpack_IlukGraph & | Graph | |||
) |
Ifpack_CrsRick constuctor with variable number of indices per row.
Creates a Ifpack_CrsRick object and allocates storage.
In | A - User matrix to be factored. | |
In | Graph - Graph generated by Ifpack_IlukGraph. |
Definition at line 42 of file Ifpack_CrsRick.cpp.
Ifpack_CrsRick::Ifpack_CrsRick | ( | const Ifpack_CrsRick & | Matrix | ) |
Ifpack_CrsRick::~Ifpack_CrsRick | ( | ) | [virtual] |
int Ifpack_CrsRick::InitValues | ( | ) |
Initialize L and U with values from user matrix A.
Copies values from the user's matrix into the nonzero pattern of L and U.
Definition at line 128 of file Ifpack_CrsRick.cpp.
bool Ifpack_CrsRick::ValuesInitialized | ( | ) | const [inline] |
If values have been initialized, this query returns true, otherwise it returns false.
Definition at line 221 of file Ifpack_CrsRick.h.
void Ifpack_CrsRick::SetRelaxValue | ( | double | RelaxValue | ) | [inline] |
void Ifpack_CrsRick::SetAbsoluteThreshold | ( | double | Athresh | ) | [inline] |
void Ifpack_CrsRick::SetRelativeThreshold | ( | double | Rthresh | ) | [inline] |
void Ifpack_CrsRick::SetOverlapMode | ( | Epetra_CombineMode | OverlapMode | ) | [inline] |
int Ifpack_CrsRick::SetParameters | ( | const Teuchos::ParameterList & | parameterlist, | |
bool | cerr_warning_if_unused = false | |||
) |
Set parameters using a Teuchos::ParameterList object.
Definition at line 108 of file Ifpack_CrsRick.cpp.
int Ifpack_CrsRick::Factor | ( | ) |
Compute ILU factors L and U using the specified graph, diagonal perturbation thresholds and relaxation parameters.
This function computes the RILU(k) factors L and U using the current:
Definition at line 221 of file Ifpack_CrsRick.cpp.
bool Ifpack_CrsRick::Factored | ( | ) | const [inline] |
If factor is completed, this query returns true, otherwise it returns false.
Definition at line 257 of file Ifpack_CrsRick.h.
int Ifpack_CrsRick::Solve | ( | bool | Trans, | |
const Epetra_Vector & | x, | |||
Epetra_Vector & | y | |||
) | const |
Returns the result of a Ifpack_CrsRick forward/back solve on a Epetra_Vector x in y.
In | Trans -If true, solve transpose problem. | |
In | x -A Epetra_Vector to solve for. | |
Out | y -A Epetra_Vector containing result. |
Definition at line 362 of file Ifpack_CrsRick.cpp.
int Ifpack_CrsRick::Solve | ( | bool | Trans, | |
const Epetra_MultiVector & | X, | |||
Epetra_MultiVector & | Y | |||
) | const |
Returns the result of a Ifpack_CrsRick forward/back solve on a Epetra_MultiVector X in Y.
In | Trans -If true, solve transpose problem. | |
In | X - A Epetra_MultiVector of dimension NumVectors to solve for. | |
Out | Y -A Epetra_MultiVector of dimension NumVectorscontaining result. |
Definition at line 414 of file Ifpack_CrsRick.cpp.
int Ifpack_CrsRick::Multiply | ( | bool | Trans, | |
const Epetra_MultiVector & | X, | |||
Epetra_MultiVector & | Y | |||
) | const |
Returns the result of multiplying U, D and U^T in that order on an Epetra_MultiVector X in Y.
In | Trans -If true, multiply by L^T, D and U^T in that order. | |
In | X - A Epetra_MultiVector of dimension NumVectors to solve for. | |
Out | Y -A Epetra_MultiVector of dimension NumVectorscontaining result. |
Definition at line 473 of file Ifpack_CrsRick.cpp.
int Ifpack_CrsRick::Condest | ( | bool | Trans, | |
double & | ConditionNumberEstimate | |||
) | const |
Returns the maximum over all the condition number estimate for each local ILU set of factors.
This functions computes a local condition number estimate on each processor and return the maximum over all processor of the estimate.
In | Trans -If true, solve transpose problem. | |
Out | ConditionNumberEstimate - The maximum across all processors of the infinity-norm estimate of the condition number of the inverse of LDU. |
Definition at line 536 of file Ifpack_CrsRick.cpp.
double Ifpack_CrsRick::GetRelaxValue | ( | ) | [inline] |
double Ifpack_CrsRick::GetAbsoluteThreshold | ( | ) | [inline] |
double Ifpack_CrsRick::GetRelativeThreshold | ( | ) | [inline] |
Epetra_CombineMode Ifpack_CrsRick::GetOverlapMode | ( | ) | [inline] |
int Ifpack_CrsRick::NumGlobalRows | ( | ) | const [inline] |
int Ifpack_CrsRick::NumGlobalCols | ( | ) | const [inline] |
int Ifpack_CrsRick::NumGlobalNonzeros | ( | ) | const [inline] |
Returns the number of nonzero entries in the global graph.
Definition at line 334 of file Ifpack_CrsRick.h.
virtual int Ifpack_CrsRick::NumGlobalDiagonals | ( | ) | const [inline, virtual] |
Returns the number of diagonal entries found in the global input graph.
Definition at line 337 of file Ifpack_CrsRick.h.
int Ifpack_CrsRick::NumMyRows | ( | ) | const [inline] |
int Ifpack_CrsRick::NumMyCols | ( | ) | const [inline] |
int Ifpack_CrsRick::NumMyNonzeros | ( | ) | const [inline] |
Returns the number of nonzero entries in the local graph.
Definition at line 346 of file Ifpack_CrsRick.h.
virtual int Ifpack_CrsRick::NumMyDiagonals | ( | ) | const [inline, virtual] |
Returns the number of diagonal entries found in the local input graph.
Definition at line 349 of file Ifpack_CrsRick.h.
int Ifpack_CrsRick::IndexBase | ( | ) | const [inline] |
Returns the index base for row and column indices for this graph.
Definition at line 352 of file Ifpack_CrsRick.h.
const Ifpack_IlukGraph& Ifpack_CrsRick::Graph | ( | ) | const [inline] |
Returns the address of the Ifpack_IlukGraph associated with this factored matrix.
Definition at line 355 of file Ifpack_CrsRick.h.
const Epetra_Vector& Ifpack_CrsRick::D | ( | ) | const [inline] |
Returns the address of the D factor associated with this factored matrix.
Definition at line 358 of file Ifpack_CrsRick.h.
const Epetra_CrsMatrix& Ifpack_CrsRick::U | ( | ) | const [inline] |
Returns the address of the U factor associated with this factored matrix.
Definition at line 361 of file Ifpack_CrsRick.h.
char* Ifpack_CrsRick::Label | ( | ) | const [inline, virtual] |
Returns a character string describing the operator.
Reimplemented from Epetra_Object.
Definition at line 366 of file Ifpack_CrsRick.h.
int Ifpack_CrsRick::SetUseTranspose | ( | bool | UseTranspose | ) | [inline, virtual] |
If set true, transpose of this operator will be applied.
This flag allows the transpose of the given operator to be used implicitly. Setting this flag affects only the Apply() and ApplyInverse() methods. If the implementation of this interface does not support transpose use, this method should return a value of -1.
In | UseTranspose -If true, multiply by the transpose of operator, otherwise just use operator. |
Implements Epetra_Operator.
Definition at line 378 of file Ifpack_CrsRick.h.
int Ifpack_CrsRick::Apply | ( | const Epetra_MultiVector & | X, | |
Epetra_MultiVector & | Y | |||
) | const [inline, virtual] |
Returns the result of a Epetra_Operator applied to a Epetra_MultiVector X in Y.
Note that this implementation of Apply does NOT perform a forward back solve with the LDU factorization. Instead it applies these operators via multiplication with U, D and L respectively. The ApplyInverse() method performs a solve.
In | X - A Epetra_MultiVector of dimension NumVectors to multiply with matrix. | |
Out | Y -A Epetra_MultiVector of dimension NumVectors containing result. |
Implements Epetra_Operator.
Definition at line 392 of file Ifpack_CrsRick.h.
int Ifpack_CrsRick::ApplyInverse | ( | const Epetra_MultiVector & | X, | |
Epetra_MultiVector & | Y | |||
) | const [inline, virtual] |
Returns the result of a Epetra_Operator inverse applied to an Epetra_MultiVector X in Y.
In this implementation, we use several existing attributes to determine how virtual method ApplyInverse() should call the concrete method Solve(). We pass in the UpperTriangular(), the Epetra_CrsMatrix::UseTranspose(), and NoDiagonal() methods. The most notable warning is that if a matrix has no diagonal values we assume that there is an implicit unit diagonal that should be accounted for when doing a triangular solve.
In | X - A Epetra_MultiVector of dimension NumVectors to solve for. | |
Out | Y -A Epetra_MultiVector of dimension NumVectors containing result. |
Implements Epetra_Operator.
Definition at line 409 of file Ifpack_CrsRick.h.
double Ifpack_CrsRick::NormInf | ( | ) | const [inline, virtual] |
Returns 0.0 because this class cannot compute Inf-norm.
Implements Epetra_Operator.
Definition at line 413 of file Ifpack_CrsRick.h.
bool Ifpack_CrsRick::HasNormInf | ( | ) | const [inline, virtual] |
Returns false because this class cannot compute an Inf-norm.
Implements Epetra_Operator.
Definition at line 416 of file Ifpack_CrsRick.h.
bool Ifpack_CrsRick::UseTranspose | ( | ) | const [inline, virtual] |
Returns the current UseTranspose setting.
Implements Epetra_Operator.
Definition at line 419 of file Ifpack_CrsRick.h.
const Epetra_Map& Ifpack_CrsRick::OperatorDomainMap | ( | ) | const [inline, virtual] |
Returns the Epetra_Map object associated with the domain of this operator.
Implements Epetra_Operator.
Definition at line 422 of file Ifpack_CrsRick.h.
const Epetra_Map& Ifpack_CrsRick::OperatorRangeMap | ( | ) | const [inline, virtual] |
Returns the Epetra_Map object associated with the range of this operator.
Implements Epetra_Operator.
Definition at line 425 of file Ifpack_CrsRick.h.
void Ifpack_CrsRick::SetFactored | ( | bool | Flag | ) | [inline, protected] |
Definition at line 429 of file Ifpack_CrsRick.h.
void Ifpack_CrsRick::SetValuesInitialized | ( | bool | Flag | ) | [inline, protected] |
Definition at line 430 of file Ifpack_CrsRick.h.
bool Ifpack_CrsRick::Allocated | ( | ) | const [inline, protected] |
Definition at line 431 of file Ifpack_CrsRick.h.
int Ifpack_CrsRick::SetAllocated | ( | bool | Flag | ) | [inline, protected] |
Definition at line 432 of file Ifpack_CrsRick.h.
int Ifpack_CrsRick::Allocate | ( | ) | [private] |
Definition at line 82 of file Ifpack_CrsRick.cpp.
ostream& operator<< | ( | ostream & | os, | |
const Ifpack_CrsRick & | A | |||
) | [friend] |
const Epetra_CrsMatrix& Ifpack_CrsRick::A_ [private] |
Definition at line 439 of file Ifpack_CrsRick.h.
const Ifpack_IlukGraph& Ifpack_CrsRick::Graph_ [private] |
Definition at line 440 of file Ifpack_CrsRick.h.
Epetra_CrsMatrix* Ifpack_CrsRick::U_ [private] |
Definition at line 441 of file Ifpack_CrsRick.h.
Epetra_Vector* Ifpack_CrsRick::D_ [private] |
Definition at line 442 of file Ifpack_CrsRick.h.
bool Ifpack_CrsRick::UseTranspose_ [private] |
Definition at line 443 of file Ifpack_CrsRick.h.
bool Ifpack_CrsRick::Allocated_ [private] |
Definition at line 446 of file Ifpack_CrsRick.h.
bool Ifpack_CrsRick::ValuesInitialized_ [private] |
Definition at line 447 of file Ifpack_CrsRick.h.
bool Ifpack_CrsRick::Factored_ [private] |
Definition at line 448 of file Ifpack_CrsRick.h.
double Ifpack_CrsRick::RelaxValue_ [private] |
Definition at line 449 of file Ifpack_CrsRick.h.
double Ifpack_CrsRick::Athresh_ [private] |
Definition at line 450 of file Ifpack_CrsRick.h.
double Ifpack_CrsRick::Rthresh_ [private] |
Definition at line 451 of file Ifpack_CrsRick.h.
double Ifpack_CrsRick::Condest_ [mutable, private] |
Definition at line 452 of file Ifpack_CrsRick.h.
Epetra_MultiVector* Ifpack_CrsRick::OverlapX_ [mutable, private] |
Definition at line 454 of file Ifpack_CrsRick.h.
Epetra_MultiVector* Ifpack_CrsRick::OverlapY_ [mutable, private] |
Definition at line 455 of file Ifpack_CrsRick.h.
Definition at line 456 of file Ifpack_CrsRick.h.