47 #include "Teuchos_ParameterList.hpp"
48 #include "Teuchos_RefCountPtr.hpp"
52 using Teuchos::RefCountPtr;
56 #ifdef HAVE_IFPACK_EPETRAEXT
57 #include "EpetraExt_MatrixMatrix.h"
61 IsInitialized_(
false),
82 int Ifpack_IHSS::Initialize(){
83 EigMaxIters_ = List_.get(
"ihss: eigenvalue max iterations",EigMaxIters_);
84 EigRatio_ = List_.get(
"ihss: ratio eigenvalue", EigRatio_);
85 NumSweeps_ = List_.get(
"ihss: sweeps",NumSweeps_);
99 int Ifpack_IHSS::Compute(){
110 Aherm->FillComplete();
123 avec.MaxValue(&Alpha_);
126 for(
int i=0;i<Aherm->NumMyRows();i++) avec[i]+=Alpha_;
135 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
138 int gid=Askew->
GRID(i);
144 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
147 long long gid=Askew->
GRID64(i);
153 throw "Ifpack_IHSS::Compute: Unable to deduce GlobalIndices type";
160 std::string htype=List_.get(
"ihss: hermetian type",
"ILU");
161 Pherm= Factory.
Create(htype, Aherm);
168 std::string stype=List_.get(
"ihss: skew hermetian type",
"ILU");
169 Pskew= Factory.
Create(stype, Askew);
175 sprintf(
Label_,
"IFPACK IHSS (H,S)=(%s/%s)",htype.c_str(),stype.c_str());
186 if(!IsComputed_)
return -1;
188 bool initial_guess_is_zero=
false;
192 Teuchos::RefCountPtr<const Epetra_MultiVector> Xcopy;
194 if (X.Pointers()[0] == Y.Pointers()[0]){
198 initial_guess_is_zero=
true;
215 for(
int i=0;i<NumSweeps_;i++){
217 if(!initial_guess_is_zero || i >0 ){
219 T2.Update(2*Alpha_,Y,-1,T1,1);
221 Pherm_->ApplyInverse(T2,Y);
225 T2.Scale(1.0,*Xcopy);
226 T2.Update(2*Alpha_,Y,-1,T1,1.0);
227 Pskew_->ApplyInverse(T2,Y);
237 std::ostream& Ifpack_IHSS::Print(std::ostream& os)
const{
240 os<<
"Ifpack_IHSS"<<endl;
241 os<<
"-Hermetian preconditioner"<<endl;
242 os<<
"-Skew Hermetian preconditioner"<<endl;
256 int Ifpack_IHSS::PowerMethod(
Epetra_Operator * Op,
const int MaximumIterations,
double& lambda_max)
261 double RQ_top, RQ_bottom, norm;
270 for (
int iter = 0;
iter < MaximumIterations; ++
iter)
275 lambda_max = RQ_top / RQ_bottom;
int NumApplyInverse_
Contains the number of successful call to ApplyInverse().
int NumCompute_
Contains the number of successful call to Compute().
bool GlobalIndicesLongLong() const
double ComputeTime_
Contains the time for all successful calls to Compute().
double ElapsedTime(void) const
Epetra_Time Time_
Used for timing purposes.
virtual int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
double ApplyInverseTime_
Contains the time for all successful calls to ApplyInverse().
long long GRID64(int LRID_in) const
RCP< ParameterList > sublist(const RCP< ParameterList > ¶mList, const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
virtual const Epetra_Map & OperatorDomainMap() const =0
bool GlobalIndicesInt() const
int FillComplete(bool OptimizeDataStorage=true)
int Initialize()
Initialize L and U with values from user matrix A.
bool IsInitialized_
If true, the preconditioner has been successfully initialized.
Ifpack_CondestType
Ifpack_CondestType: enum to define the type of condition number estimate.
const Epetra_Map & RowMap() const
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
virtual const Epetra_Map & OperatorRangeMap() const =0
std::string Label_
Label of this object.
virtual int SetParameters(Teuchos::ParameterList &List)=0
Sets all parameters for the preconditioner.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Ifpack_Preconditioner: basic class for preconditioning in Ifpack.
int NumInitialize_
Contains the number of successful calls to Initialize().
void Destroy()
Destroys all data associated to the preconditioner.
static int Add(const Epetra_CrsMatrix &A, bool transposeA, double scalarA, Epetra_CrsMatrix &B, double scalarB)
Ifpack: a function class to define Ifpack preconditioners.
int GRID(int LRID_in) const
static Ifpack_Preconditioner * Create(EPrecType PrecType, Epetra_RowMatrix *Matrix, const int overlap=0, bool overrideSerialDefault=false)
Creates an instance of Ifpack_Preconditioner given the enum value of the preconditioner type (can not...
virtual int Compute()=0
Computes all it is necessary to apply the preconditioner.
bool IsComputed_
If true, the preconditioner has been successfully computed.
#define IFPACK_CHK_ERR(ifpack_err)
const Epetra_RowMatrix & A_
Reference to the matrix to be preconditioned, supposed symmetric.
void ResetStartTime(void)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)