Ifpack Package Browser (Single Doxygen Collection) Development
Ifpack_SORa.h
Go to the documentation of this file.
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_SORA_H
00031 #define IFPACK_SORA_H
00032 
00033 #include "Ifpack_ConfigDefs.h"
00034 #include "Ifpack_Preconditioner.h"
00035 
00036 #ifdef HAVE_IFPACK_EPETRAEXT
00037 #include "Ifpack_Condest.h"
00038 #include "Ifpack_ScalingType.h"
00039 #include "Epetra_CompObject.h"
00040 #include "Epetra_MultiVector.h"
00041 #include "Epetra_Vector.h"
00042 #include "Epetra_CrsGraph.h"
00043 #include "Epetra_CrsMatrix.h"
00044 #include "Epetra_BlockMap.h"
00045 #include "Epetra_Map.h"
00046 #include "Epetra_Object.h"
00047 #include "Epetra_Comm.h"
00048 #include "Epetra_CrsMatrix.h"
00049 #include "Epetra_Time.h"
00050 #include "Teuchos_RefCountPtr.hpp"
00051 #include "EpetraExt_Transpose_RowMatrix.h"
00052 
00053 
00054 namespace Teuchos {
00055   class ParameterList;
00056 }
00057 
00059 
00067 class Ifpack_SORa: public Ifpack_Preconditioner {
00068       
00069 public:
00070   // @{ Constructors and destructors.
00072 
00074   Ifpack_SORa(Epetra_RowMatrix* A);
00075   
00077   ~Ifpack_SORa()
00078   {
00079     Destroy();
00080   }
00081 
00082   // @}
00083   // @{ Construction methods
00084   
00086   int Initialize();
00087   
00089   bool IsInitialized() const
00090   {
00091     return(IsInitialized_);
00092   }
00093 
00095 
00097   int Compute();
00098 
00100   bool IsComputed() const 
00101   {
00102     return(IsComputed_);
00103   }
00104 
00106   /* This method is only available if the Teuchos package is enabled.
00107      This method recognizes four parameter names: relax_value,
00108      absolute_threshold, relative_threshold and overlap_mode. These names are
00109      case insensitive, and in each case except overlap_mode, the ParameterEntry
00110      must have type double. For overlap_mode, the ParameterEntry must have
00111      type Epetra_CombineMode.
00112   */
00113   int SetParameters(Teuchos::ParameterList& parameterlist);
00114 
00116 
00125   int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
00126   // @}
00127 
00128   // @{ Mathematical functions.
00129   // Applies the matrix to X, returns the result in Y.
00130   int Apply(const Epetra_MultiVector& X, 
00131          Epetra_MultiVector& Y) const
00132   {
00133     return(Multiply(false,X,Y));
00134   }
00135 
00136   int Multiply(bool Trans, const Epetra_MultiVector& X, 
00137          Epetra_MultiVector& Y) const{return A_->Multiply(Trans,X,Y);}
00138 
00140 
00153   int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00154 
00156   double Condest(const Ifpack_CondestType CT = Ifpack_Cheap, 
00157                  const int MaxIters = 1550,
00158                  const double Tol = 1e-9,
00159      Epetra_RowMatrix* Matrix_in = 0);
00160 
00162   double Condest() const
00163   {
00164     return(Condest_);
00165   }
00166 
00167   // @}
00168   // @{ Query methods
00169   
00171   const char* Label() const {return(Label_);}
00172 
00174   int SetLabel(const char* Label_in)
00175   {
00176     strcpy(Label_,Label_in);
00177     return(0);
00178   }
00179   
00181   double NormInf() const {return(0.0);};
00182 
00184   bool HasNormInf() const {return(false);};
00185 
00187   bool UseTranspose() const {return(UseTranspose_);};
00188 
00190   const Epetra_Map & OperatorDomainMap() const {return(A_->OperatorDomainMap());};
00191 
00193   const Epetra_Map & OperatorRangeMap() const{return(A_->OperatorRangeMap());};
00194 
00196   const Epetra_Comm & Comm() const{return(A_->Comm());};
00197 
00199   const Epetra_RowMatrix& Matrix() const
00200   { 
00201     return(*A_);
00202   }
00203 
00205   virtual double GetLambdaMax() const{return LambdaMax_;}
00206   
00208   virtual double GetOmega() const{if(UseGlobalDamping_) return 12.0/(11.0*LambdaMax_); else return 1.0;}
00209 
00211   virtual ostream& Print(ostream& os) const;
00212 
00214   virtual int NumInitialize() const
00215   {
00216     return(NumInitialize_);
00217   }
00218 
00220   virtual int NumCompute() const
00221   {
00222     return(NumCompute_);
00223   }
00224 
00226   virtual int NumApplyInverse() const
00227   {
00228     return(NumApplyInverse_);
00229   }
00230 
00232   virtual double InitializeTime() const
00233   {
00234     return(InitializeTime_);
00235   }
00236 
00238   virtual double ComputeTime() const
00239   {
00240     return(ComputeTime_);
00241   }
00242 
00244   virtual double ApplyInverseTime() const
00245   {
00246     return(ApplyInverseTime_);
00247   }
00248 
00250   virtual double InitializeFlops() const
00251   {
00252     return(0.0);
00253   }
00254 
00255   virtual double ComputeFlops() const
00256   {
00257     return(ComputeFlops_);
00258   }
00259 
00260   virtual double ApplyInverseFlops() const
00261   {
00262     return(ApplyInverseFlops_);
00263   }
00264 
00265 private:
00266 
00267   // @}
00268   // @{ Private methods
00269 
00271   Ifpack_SORa(const Ifpack_SORa& RHS) :
00272     Time_(RHS.Comm())
00273   {}
00274 
00276   Ifpack_SORa& operator=(const Ifpack_SORa& RHS)
00277   {
00278     return(*this);
00279   }
00280 
00282   void Destroy();
00283 
00285 
00295   int Solve(bool Trans, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00296 
00297 
00299   int NumGlobalRows() const {return(A_->NumGlobalRows());};
00300   
00302   int NumGlobalCols() const {return(A_->NumGlobalCols());};
00303   
00305   int NumMyRows() const {return(A_->NumMyRows());};
00306   
00308   int NumMyCols() const {return(A_->NumMyCols());};
00309   
00311   int PowerMethod(const int MaximumIterations,  double& lambda_max);
00312 
00313 
00315   /*  Epetra_RowMatrix& Matrix()
00316   {
00317     return(*A_);
00318     }*/
00319 
00320   // @}
00321   // @{ Internal data
00322   
00324   Teuchos::RefCountPtr<Epetra_CrsMatrix> Acrs_;
00325   Teuchos::RefCountPtr<Epetra_RowMatrix> A_;
00326   Teuchos::RefCountPtr<Epetra_CrsMatrix> W_; // Strict lower triangle
00327   Teuchos::RefCountPtr<Epetra_Vector>    Wdiag_;
00328   Teuchos::RefCountPtr<EpetraExt::RowMatrix_Transpose> transposer2_;
00329   Teuchos::ParameterList List_;  
00330   
00331   bool UseTranspose_;
00332   double Condest_;
00333 
00334 
00336   bool IsInitialized_;
00338   bool IsComputed_;
00340   char Label_[160];
00342   int NumInitialize_;
00344   int NumCompute_;
00345   
00347   double Alpha_;
00349   double Gamma_;
00351   int NumSweeps_;  
00353   bool IsParallel_;
00355   bool HaveOAZBoundaries_;
00357   bool UseInterprocDamping_;
00359   bool UseGlobalDamping_;
00361   double LambdaMax_;
00362 
00364   mutable int NumApplyInverse_;
00366   double InitializeTime_;
00368   double ComputeTime_;
00370   mutable double ApplyInverseTime_;
00372   double ComputeFlops_;
00374   mutable double ApplyInverseFlops_;
00376   mutable Epetra_Time Time_;
00377 
00378 };
00379 #else
00380 #endif
00381 #endif /* IFPACK_SORa_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines