Ifpack_SORa.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_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 
00052 
00053 namespace Teuchos {
00054   class ParameterList;
00055 }
00056 
00058 
00066 class Ifpack_SORa: public Ifpack_Preconditioner {
00067       
00068 public:
00069   // @{ Constructors and destructors.
00071 
00073   Ifpack_SORa(Epetra_RowMatrix* A);
00074   
00076   ~Ifpack_SORa()
00077   {
00078     Destroy();
00079   }
00080 
00081   // @}
00082   // @{ Construction methods
00083   
00085   int Initialize();
00086   
00088   bool IsInitialized() const
00089   {
00090     return(IsInitialized_);
00091   }
00092 
00094 
00096   int Compute();
00097 
00099   bool IsComputed() const 
00100   {
00101     return(IsComputed_);
00102   }
00103 
00105   /* This method is only available if the Teuchos package is enabled.
00106      This method recognizes four parameter names: relax_value,
00107      absolute_threshold, relative_threshold and overlap_mode. These names are
00108      case insensitive, and in each case except overlap_mode, the ParameterEntry
00109      must have type double. For overlap_mode, the ParameterEntry must have
00110      type Epetra_CombineMode.
00111   */
00112   int SetParameters(Teuchos::ParameterList& parameterlist);
00113 
00115 
00124   int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
00125   // @}
00126 
00127   // @{ Mathematical functions.
00128   // Applies the matrix to X, returns the result in Y.
00129   int Apply(const Epetra_MultiVector& X, 
00130            Epetra_MultiVector& Y) const
00131   {
00132     return(Multiply(false,X,Y));
00133   }
00134 
00135   int Multiply(bool Trans, const Epetra_MultiVector& X, 
00136            Epetra_MultiVector& Y) const{return A_->Multiply(Trans,X,Y);}
00137 
00139 
00152   int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00153 
00155   double Condest(const Ifpack_CondestType CT = Ifpack_Cheap, 
00156                  const int MaxIters = 1550,
00157                  const double Tol = 1e-9,
00158          Epetra_RowMatrix* Matrix_in = 0);
00159 
00161   double Condest() const
00162   {
00163     return(Condest_);
00164   }
00165 
00166   // @}
00167   // @{ Query methods
00168   
00170   const char* Label() const {return(Label_);}
00171 
00173   int SetLabel(const char* Label_in)
00174   {
00175     strcpy(Label_,Label_in);
00176     return(0);
00177   }
00178   
00180   double NormInf() const {return(0.0);};
00181 
00183   bool HasNormInf() const {return(false);};
00184 
00186   bool UseTranspose() const {return(UseTranspose_);};
00187 
00189   const Epetra_Map & OperatorDomainMap() const {return(A_->OperatorDomainMap());};
00190 
00192   const Epetra_Map & OperatorRangeMap() const{return(A_->OperatorRangeMap());};
00193 
00195   const Epetra_Comm & Comm() const{return(A_->Comm());};
00196 
00198   const Epetra_RowMatrix& Matrix() const
00199   { 
00200     return(*A_);
00201   }
00202 
00204   virtual ostream& Print(ostream& os) const;
00205 
00207   virtual int NumInitialize() const
00208   {
00209     return(NumInitialize_);
00210   }
00211 
00213   virtual int NumCompute() const
00214   {
00215     return(NumCompute_);
00216   }
00217 
00219   virtual int NumApplyInverse() const
00220   {
00221     return(NumApplyInverse_);
00222   }
00223 
00225   virtual double InitializeTime() const
00226   {
00227     return(InitializeTime_);
00228   }
00229 
00231   virtual double ComputeTime() const
00232   {
00233     return(ComputeTime_);
00234   }
00235 
00237   virtual double ApplyInverseTime() const
00238   {
00239     return(ApplyInverseTime_);
00240   }
00241 
00243   virtual double InitializeFlops() const
00244   {
00245     return(0.0);
00246   }
00247 
00248   virtual double ComputeFlops() const
00249   {
00250     return(ComputeFlops_);
00251   }
00252 
00253   virtual double ApplyInverseFlops() const
00254   {
00255     return(ApplyInverseFlops_);
00256   }
00257 
00258 private:
00259 
00260   // @}
00261   // @{ Private methods
00262 
00264   Ifpack_SORa(const Ifpack_SORa& RHS) :
00265     Time_(RHS.Comm())
00266   {}
00267 
00269   Ifpack_SORa& operator=(const Ifpack_SORa& RHS)
00270   {
00271     return(*this);
00272   }
00273 
00275   void Destroy();
00276 
00278 
00288   int Solve(bool Trans, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00289 
00290 
00292   int NumGlobalRows() const {return(A_->NumGlobalRows());};
00293   
00295   int NumGlobalCols() const {return(A_->NumGlobalCols());};
00296   
00298   int NumMyRows() const {return(A_->NumMyRows());};
00299   
00301   int NumMyCols() const {return(A_->NumMyCols());};
00302   
00304   /*  Epetra_RowMatrix& Matrix()
00305   {
00306     return(*A_);
00307     }*/
00308 
00309   // @}
00310   // @{ Internal data
00311   
00313   Teuchos::RefCountPtr<Epetra_CrsMatrix> A_;
00314   Teuchos::RefCountPtr<Epetra_CrsMatrix> W_; // Strict lower triangle
00315   Teuchos::RefCountPtr<Epetra_Vector>    Wdiag_;
00316 
00317   Teuchos::ParameterList List_;  
00318   
00319   bool UseTranspose_;
00320   double Condest_;
00321 
00322 
00324   bool IsInitialized_;
00326   bool IsComputed_;
00328   char Label_[160];
00330   int NumInitialize_;
00332   int NumCompute_;
00333   
00335   double Alpha_;
00337   double Gamma_;
00339   int NumSweeps_;  
00341   bool IsParallel_;
00342 
00344   mutable int NumApplyInverse_;
00346   double InitializeTime_;
00348   double ComputeTime_;
00350   mutable double ApplyInverseTime_;
00352   double ComputeFlops_;
00354   mutable double ApplyInverseFlops_;
00356   mutable Epetra_Time Time_;
00357 
00358 };
00359 #else
00360 #warning "No EpetraEXT"
00361 
00362 #endif
00363 #endif /* IFPACK_SORa_H */
 All Classes Files Functions Variables Enumerations Friends
Generated on Wed Apr 13 10:05:23 2011 for IFPACK by  doxygen 1.6.3