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),
94 Operator_(Teuchos::
rcp(Operator,
false)),
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),
136 Operator_(Teuchos::
rcp(Operator,
false)),
137 Matrix_(Teuchos::
rcp(Operator,
false)),
139 ZeroStartingSolution_(
true)
183 if (X.NumVectors() != Y.NumVectors())
211 if (
Matrix().NumGlobalRows64() !=
Matrix().NumGlobalCols64())
221 if (
Operator_->OperatorDomainMap().NumGlobalElements64() !=
222 Operator_->OperatorRangeMap().NumGlobalElements64())
238 Time_->ResetStartTime();
240 #ifdef HAVE_IFPACK_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);
271 NumRows =
Matrix_->NumMyRows();
274 long long NumRows_LL =
Operator_->OperatorDomainMap().NumGlobalElements64();
276 throw "Ifpack_Krylov::Compute: NumGlobalElements don't fit an int";
278 NumRows =
static_cast<int>(NumRows_LL);
280 List.
set(
"partitioner: type",
"linear");
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,
389 int nVec = X.NumVectors();
390 if (nVec != Y.NumVectors())
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;
int NumApplyInverse_
Contains the number of successful call to ApplyInverse().
int PreconditionerType_
Preconditioner - 0 for none, 1 for Jacobi, 2 for GS, 3 for SGS.
Ifpack_BlockRelaxation: a class to define block relaxation preconditioners of Epetra_RowMatrix's.
double Tolerance_
Residual Tolerance.
virtual int Initialize()
Computes all it is necessary to initialize the preconditioner.
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the matrix to an Epetra_MultiVector.
T & get(ParameterList &l, const std::string &name)
virtual double Condest() const
Returns the condition number estimate, or -1.0 if not computed.
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
double ApplyInverseTime_
Contains the time for all successful calls to ApplyInverse().
double DampingParameter_
Damping parameter for inner preconditioner.
virtual void SetLabel()
Sets the label.
bool ZeroStartingSolution_
If true, the starting solution is always the zero vector.
int NumInitialize_
Contains the number of successful calls to Initialize().
int NumSweeps_
Number of GS or Jacobi sweeps.
double ComputeFlops_
Contains the number of flops for Compute().
int BlockSize_
Block Size (for block relaxation)
std::string Label_
Contains the label of this object.
long long NumGlobalRows_
Number of global rows.
virtual int Compute()
Computes the preconditioners.
Ifpack_CondestType
Ifpack_CondestType: enum to define the type of condition number estimate.
double ApplyInverseFlops_
Contain sthe number of flops for ApplyInverse().
Teuchos::RefCountPtr< Epetra_Operator > Operator_
Pointers to the matrix as an Epetra_Operator.
int Iterations_
Max number of iterations.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual int SetParameters(Teuchos::ParameterList &List)
Sets all the parameters for the preconditioner.
virtual std::ostream & Print(std::ostream &os) const
Prints object to an output stream.
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...
virtual bool IsInitialized() const
Returns true if the preconditioner has been successfully initialized, false otherwise.
bool IsInitialized_
If true, the preconditioner has been computed successfully.
int NumCompute_
Contains the number of successful call to Compute().
virtual bool IsComputed() const
Returns true if the preconditioner has been successfully computed.
long long NumGlobalNonzeros_
Number of global nonzeros.
bool IsRowMatrix_
If true, the Operator_ is an Epetra_RowMatrix.
std::string Ifpack_toString(const int &x)
Converts an integer to std::string.
double InitializeTime_
Contains the time for all successful calls to Initialize().
int NumMyRows_
Number of local rows.
virtual const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
Ifpack_Krylov(Epetra_Operator *Matrix)
Teuchos::RefCountPtr< Epetra_Time > Time_
Time object to track timing.
double Ifpack_Condest(const Ifpack_Preconditioner &IFP, const Ifpack_CondestType CT, const int MaxIters, const double Tol, Epetra_RowMatrix *Matrix)
double ComputeTime_
Contains the time for all successful calls to Compute().
virtual const Epetra_RowMatrix & Matrix() const
Returns a pointer to the matrix to be preconditioned.
Teuchos::RCP< Ifpack_Preconditioner > IfpackPrec_
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
virtual const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
int NumMyNonzeros_
Number of local nonzeros.
Teuchos::RefCountPtr< Epetra_RowMatrix > Matrix_
Pointers to the matrix as an Epetra_RowMatrix.
#define IFPACK_CHK_ERR(ifpack_err)
bool IsComputed_
If true, the preconditioner has been computed successfully.
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the preconditioner to X, returns the result in Y.
double Condest_
Contains the estimated condition number.
int SolverType_
Solver - 0 for CG, 1 for GMRES.