IFPACK  Development
 All Classes Files Functions Variables Enumerations Friends
Ifpack_Polynomial.h
00001 /*@HEADER
00002 // ***********************************************************************
00003 //
00004 //       Ifpack: Object-Oriented Algebraic Preconditioner Package
00005 //                 Copyright (2002) Sandia Corporation
00006 //
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00038 //
00039 // ***********************************************************************
00040 //@HEADER
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   // @{ \name Utility methods
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   // WARNING: This only works in Block Mode.
00317   int CG(const int MaximumIterations, 
00318          double& lambda_min, double& lambda_max);
00320   // WARNING: This only works in Block Mode.
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   // @{ \name Private methods
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   // @{ Initializations, timing and flops
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   // @{ Settings
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   // @{ Other data
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
 All Classes Files Functions Variables Enumerations Friends