45#include "Epetra_Operator.h"
46#include "Epetra_RowMatrix.h"
47#include "Epetra_Comm.h"
48#include "Epetra_Map.h"
49#include "Epetra_MultiVector.h"
50#include "Epetra_Vector.h"
51#include "Epetra_Time.h"
55#ifdef HAVE_IFPACK_AZTECOO
59#ifdef HAVE_IFPACK_EPETRAEXT
60#include "Epetra_CrsMatrix.h"
61#include "EpetraExt_PointToBlockDiagPermute.h"
69 IsInitialized_(
false),
76 ApplyInverseTime_(0.0),
78 ApplyInverseFlops_(0.0),
82 PreconditionerType_(1),
85 DampingParameter_(1.0),
93 NumGlobalNonzeros_(0),
96 ZeroStartingSolution_(
true)
111 IsInitialized_(
false),
116 InitializeTime_(0.0),
118 ApplyInverseTime_(0.0),
120 ApplyInverseFlops_(0.0),
124 PreconditionerType_(1),
127 DampingParameter_(1.0),
128 UseTranspose_(
false),
135 NumGlobalNonzeros_(0),
139 ZeroStartingSolution_(
true)
206 if (
Time_ == Teuchos::null)
211 if (
Matrix().NumGlobalRows64() !=
Matrix().NumGlobalCols64())
221 if (
Operator_->OperatorDomainMap().NumGlobalElements64() !=
222 Operator_->OperatorRangeMap().NumGlobalElements64())
238 Time_->ResetStartTime();
240#ifdef HAVE_IFPACK_AZTECOO
242 AztecSolver_ = Teuchos::rcp(
new AztecOO );
244 AztecSolver_ -> SetUserMatrix(&*
Matrix_);
247 AztecSolver_ -> SetUserOperator(&*
Operator_);
250 AztecSolver_ -> SetAztecOption(AZ_solver, AZ_cg);
253 AztecSolver_ -> SetAztecOption(AZ_solver, AZ_gmres);
255 AztecSolver_ -> SetAztecOption(AZ_output, AZ_none);
257 Teuchos::ParameterList List;
263 else if(
PreconditionerType_==3) { List.set(
"relaxation: type",
"symmetric Gauss-Seidel"); }
271 NumRows =
Matrix_->NumMyRows();
274 long long NumRows_LL =
Operator_->OperatorDomainMap().NumGlobalElements64();
275 if(NumRows_LL > std::numeric_limits<int>::max())
276 throw "Ifpack_Krylov::Compute: NumGlobalElements don't fit an int";
278 NumRows =
static_cast<int>(NumRows_LL);
280 List.set(
"partitioner: type",
"linear");
281 List.set(
"partitioner: local parts", NumRows/
BlockSize_);
293 cout <<
"You need to configure IFPACK with support for AztecOO" << endl;
294 cout <<
"to use this preconditioner. This may require --enable-aztecoo" << endl;
295 cout <<
"in your configure script." << endl;
314 if (!
Comm().MyPID()) {
316 os <<
"================================================================================" << endl;
317 os <<
"Ifpack_Krylov" << endl;
318 os <<
"Number of iterations = " <<
Iterations_ << endl;
319 os <<
"Residual Tolerance = " <<
Tolerance_ << endl;
320 os <<
"Solver type (O for CG, 1 for GMRES) = " <<
SolverType_ << endl;
322 os <<
"(0 for none, 1 for Jacobi, 2 for GS, 3 for SGS )" << endl;
323 os <<
"Condition number estimate = " <<
Condest() << endl;
324 os <<
"Global number of rows = " <<
Operator_->OperatorRangeMap().NumGlobalElements64() << endl;
326 os <<
"Using zero starting solution" << endl;
328 os <<
"Using input starting solution" << endl;
330 os <<
"Phase # calls Total Time (s) Total MFlops MFlops/s" << endl;
331 os <<
"----- ------- -------------- ------------ --------" << endl;
334 <<
" 0.0 0.0" << endl;
341 os <<
" " << std::setw(15) << 0.0 << endl;
348 os <<
" " << std::setw(15) << 0.0 << endl;
349 os <<
"================================================================================" << endl;
359 const int MaxIters,
const double Tol,
393 Time_->ResetStartTime();
402#ifdef HAVE_IFPACK_AZTECOO
403 AztecSolver_ -> SetLHS(&Y);
404 AztecSolver_ -> SetRHS(&*Xcopy);
410 cout <<
"You need to configure IFPACK with support for AztecOO" << endl;
411 cout <<
"to use this preconditioner. This may require --enable-aztecoo" << endl;
412 cout <<
"in your configure script." << endl;
Ifpack_CondestType
Ifpack_CondestType: enum to define the type of condition number estimate.
double Ifpack_Condest(const Ifpack_Preconditioner &IFP, const Ifpack_CondestType CT, const int MaxIters, const double Tol, Epetra_RowMatrix *Matrix)
#define IFPACK_CHK_ERR(ifpack_err)
std::string Ifpack_toString(const int &x)
Converts an integer to std::string.
int PutScalar(double ScalarConstant)
Ifpack_BlockRelaxation: a class to define block relaxation preconditioners of Epetra_RowMatrix's.
Teuchos::RefCountPtr< Epetra_Operator > Operator_
Pointers to the matrix as an Epetra_Operator.
Teuchos::RefCountPtr< Epetra_RowMatrix > Matrix_
Pointers to the matrix as an Epetra_RowMatrix.
double ComputeFlops_
Contains the number of flops for Compute().
virtual const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
Teuchos::RefCountPtr< Epetra_Time > Time_
Time object to track timing.
Ifpack_Krylov(Epetra_Operator *Matrix)
double Tolerance_
Residual Tolerance.
virtual int Compute()
Computes the preconditioners.
bool IsRowMatrix_
If true, the Operator_ is an Epetra_RowMatrix.
int SolverType_
Solver - 0 for CG, 1 for GMRES.
virtual bool IsComputed() const
Returns true if the preconditioner has been successfully computed.
double ComputeTime_
Contains the time for all successful calls to Compute().
bool IsComputed_
If true, the preconditioner has been computed successfully.
virtual double Condest() const
Returns the condition number estimate, or -1.0 if not computed.
bool ZeroStartingSolution_
If true, the starting solution is always the zero vector.
double DampingParameter_
Damping parameter for inner preconditioner.
virtual int SetParameters(Teuchos::ParameterList &List)
Sets all the parameters for the preconditioner.
int NumCompute_
Contains the number of successful call to Compute().
int Iterations_
Max number of iterations.
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
long long NumGlobalRows_
Number of global rows.
virtual std::ostream & Print(std::ostream &os) const
Prints object to an output stream.
int NumMyRows_
Number of local rows.
int BlockSize_
Block Size (for block relaxation)
Teuchos::RCP< Ifpack_Preconditioner > IfpackPrec_
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the preconditioner to X, returns the result in Y.
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the matrix to an Epetra_MultiVector.
int NumInitialize_
Contains the number of successful calls to Initialize().
virtual bool IsInitialized() const
Returns true if the preconditioner has been successfully initialized, false otherwise.
double ApplyInverseFlops_
Contain sthe number of flops for ApplyInverse().
bool IsInitialized_
If true, the preconditioner has been computed successfully.
long long NumGlobalNonzeros_
Number of global nonzeros.
virtual int Initialize()
Computes all it is necessary to initialize the preconditioner.
double ApplyInverseTime_
Contains the time for all successful calls to ApplyInverse().
virtual const Epetra_RowMatrix & Matrix() const
Returns a pointer to the matrix to be preconditioned.
double InitializeTime_
Contains the time for all successful calls to Initialize().
std::string Label_
Contains the label of this object.
virtual const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
int NumApplyInverse_
Contains the number of successful call to ApplyInverse().
int NumMyNonzeros_
Number of local nonzeros.
virtual void SetLabel()
Sets the label.
double Condest_
Contains the estimated condition number.
int NumSweeps_
Number of GS or Jacobi sweeps.
int PreconditionerType_
Preconditioner - 0 for none, 1 for Jacobi, 2 for GS, 3 for SGS.
virtual const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
Ifpack_PointRelaxation: a class to define point relaxation preconditioners of for Epetra_RowMatrix's.