Ifpack_Chebyshev.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 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00025 //
00026 // ***********************************************************************
00027 //@HEADER
00028 */
00029 
00030 #ifndef IFPACK_CHEBYSHEV_H
00031 #define IFPACK_CHEBYSHEV_H
00032 
00033 #include "Ifpack_ConfigDefs.h"
00034 #include "Ifpack_Preconditioner.h"
00035 #include "Teuchos_RefCountPtr.hpp"
00036 
00037 namespace Teuchos {
00038   class ParameterList;
00039 }
00040 
00041 class Epetra_MultiVector;
00042 class Epetra_Vector;
00043 class Epetra_Map;
00044 class Epetra_Comm;
00045 class Epetra_Time;
00046 class Epetra_Vector;
00047 class Epetra_Operator;
00048 class Epetra_RowMatrix;
00049 
00050 #ifdef HAVE_IFPACK_EPETRAEXT
00051 class EpetraExt_PointToBlockDiagPermute;
00052 #endif
00053 
00055 
00091 class Ifpack_Chebyshev : public Ifpack_Preconditioner {
00092 
00093 public:
00094 
00096 
00097 
00102   Ifpack_Chebyshev(const Epetra_Operator* Matrix);
00103 
00105 
00110   Ifpack_Chebyshev(const Epetra_RowMatrix* Matrix);
00111 
00113   virtual ~Ifpack_Chebyshev() {};
00114 
00116 
00123   virtual inline int SetUseTranspose(bool UseTranspose_in)
00124   {
00125     UseTranspose_ = UseTranspose_in;
00126     return(0);
00127   }
00128 
00130 
00132 
00134 
00142   virtual inline int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00143 
00145 
00155   virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00156 
00158   virtual double NormInf() const
00159   {
00160     return(-1.0);
00161   }
00163 
00165 
00166   virtual const char * Label() const
00167   {
00168     return(Label_.c_str());
00169   }
00170 
00172   virtual bool UseTranspose() const
00173   {
00174     return(UseTranspose_);
00175   }
00176 
00178   virtual bool HasNormInf() const
00179   {
00180     return(false);
00181   }
00182 
00184   virtual const Epetra_Comm & Comm() const;
00185 
00187   virtual const Epetra_Map & OperatorDomainMap() const;
00188 
00190   virtual const Epetra_Map & OperatorRangeMap() const;
00191 
00192   virtual int Initialize();
00193   
00194   virtual bool IsInitialized() const
00195   {
00196     return(IsInitialized_);
00197   }
00198 
00200   virtual inline bool IsComputed() const
00201   {
00202     return(IsComputed_);
00203   }
00204 
00206   virtual int Compute();
00207 
00209   virtual double GetLambdaMax(){return LambdaMax_;}
00210 
00212   virtual double GetLambdaMin(){return LambdaMin_;}
00213   
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 private:
00324   
00325   // @}
00326   // @{ \name Private methods
00327   
00329   virtual void SetLabel();
00330 
00332   Ifpack_Chebyshev(const Ifpack_Chebyshev& rhs)
00333   {}
00334   
00336   Ifpack_Chebyshev& operator=(const Ifpack_Chebyshev& rhs)
00337   {
00338     return(*this);
00339   }
00340 
00341   // @{ Initializations, timing and flops
00343   bool IsInitialized_;
00345   bool IsComputed_;
00347   int NumInitialize_;
00349   int NumCompute_;
00351   mutable int NumApplyInverse_;
00353   double InitializeTime_;
00355   double ComputeTime_;
00357   mutable double ApplyInverseTime_;
00359   double ComputeFlops_;
00361   mutable double ApplyInverseFlops_;
00362   // @}
00363 
00364   // @{ Settings
00366   int PolyDegree_;
00368   bool UseTranspose_;
00370   double Condest_;
00372   bool ComputeCondest_;
00375   double EigRatio_;
00377   int EigMaxIters_;  
00379   string Label_;
00381   double LambdaMin_;
00383   double LambdaMax_;
00385   double MinDiagonalValue_;
00386   // @}
00387 
00388   // @{ Other data
00390   int NumMyRows_;
00392   int NumMyNonzeros_;
00394   int NumGlobalRows_;
00396   int NumGlobalNonzeros_;
00398   Teuchos::RefCountPtr<const Epetra_Operator> Operator_;
00400   Teuchos::RefCountPtr<const Epetra_RowMatrix> Matrix_;
00402   mutable Teuchos::RefCountPtr<Epetra_Vector> InvDiagonal_;
00404   bool UseBlockMode_;
00405 #ifdef HAVE_IFPACK_EPETRAEXT
00406 
00407   Teuchos::ParameterList BlockList_;
00408   Teuchos::RefCountPtr<EpetraExt_PointToBlockDiagPermute> InvBlockDiagonal_;
00409 #endif
00410 
00411 
00413   bool SolveNormalEquations_;
00414 
00416   bool IsRowMatrix_;
00418   Teuchos::RefCountPtr<Epetra_Time> Time_;
00420   bool ZeroStartingSolution_;
00421 
00422   // @}
00423 
00424 };
00425 
00426 
00427 #endif // IFPACK_CHEBYSHEV_H
 All Classes Files Functions Variables Enumerations Friends
Generated on Wed Apr 13 10:05:22 2011 for IFPACK by  doxygen 1.6.3