00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef IFPACK_POLYNOMIAL_H
00044 #define IFPACK_POLYNOMIAL_H
00045
00046 #include "Ifpack_ConfigDefs.h"
00047 #include "Ifpack_Preconditioner.h"
00048 #include "Teuchos_RefCountPtr.hpp"
00049 #include "Teuchos_LAPACK.hpp"
00050 #include "Teuchos_SerialDenseMatrix.hpp"
00051
00052 namespace Teuchos {
00053 class ParameterList;
00054 }
00055
00056 class Epetra_MultiVector;
00057 class Epetra_Vector;
00058 class Epetra_Map;
00059 class Epetra_Comm;
00060 class Epetra_Time;
00061 class Epetra_Vector;
00062 class Epetra_Operator;
00063 class Epetra_RowMatrix;
00064
00065 #ifdef HAVE_IFPACK_EPETRAEXT
00066 class EpetraExt_PointToBlockDiagPermute;
00067 #endif
00068
00070
00099 class Ifpack_Polynomial : public Ifpack_Preconditioner {
00100
00101 public:
00102
00104
00105
00110 Ifpack_Polynomial(const Epetra_Operator* Matrix);
00111
00113
00118 Ifpack_Polynomial(const Epetra_RowMatrix* Matrix);
00119
00121 virtual ~Ifpack_Polynomial() {};
00122
00124
00131 virtual inline int SetUseTranspose(bool UseTranspose_in)
00132 {
00133 UseTranspose_ = UseTranspose_in;
00134 return(0);
00135 }
00136
00138
00140
00142
00150 virtual inline int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00151
00153
00163 virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00164
00166 virtual double NormInf() const
00167 {
00168 return(-1.0);
00169 }
00171
00173
00174 virtual const char * Label() const
00175 {
00176 return(Label_.c_str());
00177 }
00178
00180 virtual bool UseTranspose() const
00181 {
00182 return(UseTranspose_);
00183 }
00184
00186 virtual bool HasNormInf() const
00187 {
00188 return(false);
00189 }
00190
00192 virtual const Epetra_Comm & Comm() const;
00193
00195 virtual const Epetra_Map & OperatorDomainMap() const;
00196
00198 virtual const Epetra_Map & OperatorRangeMap() const;
00199
00200 virtual int Initialize();
00201
00202 virtual bool IsInitialized() const
00203 {
00204 return(IsInitialized_);
00205 }
00206
00208 virtual inline bool IsComputed() const
00209 {
00210 return(IsComputed_);
00211 }
00212
00214 virtual int Compute();
00215
00217
00218 virtual const Epetra_RowMatrix& Matrix() const
00219 {
00220 return(*Matrix_);
00221 }
00222
00224 virtual double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
00225 const int MaxIters = 1550,
00226 const double Tol = 1e-9,
00227 Epetra_RowMatrix* Matrix_in = 0);
00228
00230 virtual double Condest() const
00231 {
00232 return(Condest_);
00233 }
00234
00236 virtual int SetParameters(Teuchos::ParameterList& List);
00237
00239 virtual ostream& Print(ostream & os) const;
00240
00242
00244
00246 virtual int NumInitialize() const
00247 {
00248 return(NumInitialize_);
00249 }
00250
00252 virtual int NumCompute() const
00253 {
00254 return(NumCompute_);
00255 }
00256
00258 virtual int NumApplyInverse() const
00259 {
00260 return(NumApplyInverse_);
00261 }
00262
00264 virtual double InitializeTime() const
00265 {
00266 return(InitializeTime_);
00267 }
00268
00270 virtual double ComputeTime() const
00271 {
00272 return(ComputeTime_);
00273 }
00274
00276 virtual double ApplyInverseTime() const
00277 {
00278 return(ApplyInverseTime_);
00279 }
00280
00282 virtual double InitializeFlops() const
00283 {
00284 return(0.0);
00285 }
00286
00288 virtual double ComputeFlops() const
00289 {
00290 return(ComputeFlops_);
00291 }
00292
00294 virtual double ApplyInverseFlops() const
00295 {
00296 return(ApplyInverseFlops_);
00297 }
00298
00299
00300
00301
00303 static int PowerMethod(const Epetra_Operator& Operator,
00304 const Epetra_Vector& InvPointDiagonal,
00305 const int MaximumIterations,
00306 double& LambdaMax);
00307
00309 static int CG(const Epetra_Operator& Operator,
00310 const Epetra_Vector& InvPointDiagonal,
00311 const int MaximumIterations,
00312 double& lambda_min, double& lambda_max);
00313
00314 #ifdef HAVE_IFPACK_EPETRAEXT
00315
00316
00317 int CG(const int MaximumIterations,
00318 double& lambda_min, double& lambda_max);
00320
00321 int PowerMethod(const int MaximumIterations,double& lambda_max);
00322 #endif
00323
00325 int GMRES(const Epetra_Operator& Operator,
00326 const Epetra_Vector& InvPointDiagonal,
00327 const int MaximumIterations,
00328 double& lambda_real_min, double& lambda_real_max,
00329 double& lambda_imag_min, double& lambda_imag_max);
00330
00331 private:
00332
00333
00334
00335
00337 virtual void SetLabel();
00338
00340 Ifpack_Polynomial(const Ifpack_Polynomial& rhs)
00341 {}
00342
00344 Ifpack_Polynomial& operator=(const Ifpack_Polynomial& rhs)
00345 {
00346 return(*this);
00347 }
00348
00349
00351 bool IsInitialized_;
00353 bool IsComputed_;
00355 bool IsIndefinite_;
00357 bool IsComplex_;
00359 int NumInitialize_;
00361 int NumCompute_;
00363 mutable int NumApplyInverse_;
00365 double InitializeTime_;
00367 double ComputeTime_;
00369 mutable double ApplyInverseTime_;
00371 double ComputeFlops_;
00373 mutable double ApplyInverseFlops_;
00374
00375
00376
00378 int PolyDegree_;
00380 int LSPointsReal_, LSPointsImag_;
00382 bool UseTranspose_;
00384 double Condest_;
00386 bool ComputeCondest_;
00389 double RealEigRatio_, ImagEigRatio_;
00391 int EigMaxIters_;
00393 string Label_;
00395 double LambdaRealMin_, LambdaRealMax_, LambdaImagMin_, LambdaImagMax_;
00397 double MinDiagonalValue_;
00399 std::vector<double> coeff_;
00400
00401
00403 int NumMyRows_;
00405 int NumMyNonzeros_;
00407 long long NumGlobalRows_;
00409 long long NumGlobalNonzeros_;
00411 Teuchos::RefCountPtr<const Epetra_Operator> Operator_;
00413 Teuchos::RefCountPtr<const Epetra_RowMatrix> Matrix_;
00415 mutable Teuchos::RefCountPtr<Epetra_Vector> InvDiagonal_;
00417 bool UseBlockMode_;
00418 #ifdef HAVE_IFPACK_EPETRAEXT
00419
00420 Teuchos::ParameterList BlockList_;
00421 Teuchos::RefCountPtr<EpetraExt_PointToBlockDiagPermute> InvBlockDiagonal_;
00422 #endif
00423
00424
00426 bool SolveNormalEquations_;
00427
00429 bool IsRowMatrix_;
00431 Teuchos::RefCountPtr<Epetra_Time> Time_;
00433 bool ZeroStartingSolution_;
00434
00435
00436
00437 };
00438
00439
00440 #endif // IFPACK_POLYNOMIAL_H