IFPACK  Development
 All Classes Files Functions Variables Enumerations Friends
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 // 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_SORA_H
00044 #define IFPACK_SORA_H
00045 
00046 #include "Ifpack_ConfigDefs.h"
00047 #include "Ifpack_Preconditioner.h"
00048 
00049 #ifdef HAVE_IFPACK_EPETRAEXT
00050 #include "Ifpack_Condest.h"
00051 #include "Ifpack_ScalingType.h"
00052 #include "Epetra_CompObject.h"
00053 #include "Epetra_MultiVector.h"
00054 #include "Epetra_Vector.h"
00055 #include "Epetra_CrsGraph.h"
00056 #include "Epetra_CrsMatrix.h"
00057 #include "Epetra_BlockMap.h"
00058 #include "Epetra_Map.h"
00059 #include "Epetra_Object.h"
00060 #include "Epetra_Comm.h"
00061 #include "Epetra_CrsMatrix.h"
00062 #include "Epetra_Time.h"
00063 #include "Teuchos_RefCountPtr.hpp"
00064 #include "EpetraExt_Transpose_RowMatrix.h"
00065 
00066 
00067 namespace Teuchos {
00068   class ParameterList;
00069 }
00070 
00072 
00080 class Ifpack_SORa: public Ifpack_Preconditioner {
00081       
00082 public:
00083   // @{ Constructors and destructors.
00085 
00087   Ifpack_SORa(Epetra_RowMatrix* A);
00088   
00090   ~Ifpack_SORa()
00091   {
00092     Destroy();
00093   }
00094 
00095   // @}
00096   // @{ Construction methods
00097   
00099   int Initialize();
00100   
00102   bool IsInitialized() const
00103   {
00104     return(IsInitialized_);
00105   }
00106 
00108 
00110   int Compute();
00111 
00113   bool IsComputed() const 
00114   {
00115     return(IsComputed_);
00116   }
00117 
00119   /* This method is only available if the Teuchos package is enabled.
00120      This method recognizes four parameter names: relax_value,
00121      absolute_threshold, relative_threshold and overlap_mode. These names are
00122      case insensitive, and in each case except overlap_mode, the ParameterEntry
00123      must have type double. For overlap_mode, the ParameterEntry must have
00124      type Epetra_CombineMode.
00125   */
00126   int SetParameters(Teuchos::ParameterList& parameterlist);
00127 
00129 
00138   int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
00139   // @}
00140 
00141   // @{ Mathematical functions.
00142   // Applies the matrix to X, returns the result in Y.
00143   int Apply(const Epetra_MultiVector& X, 
00144            Epetra_MultiVector& Y) const
00145   {
00146     return(Multiply(false,X,Y));
00147   }
00148 
00149   int Multiply(bool Trans, const Epetra_MultiVector& X, 
00150            Epetra_MultiVector& Y) const{return A_->Multiply(Trans,X,Y);}
00151 
00153 
00166   int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00167 
00169   double Condest(const Ifpack_CondestType CT = Ifpack_Cheap, 
00170                  const int MaxIters = 1550,
00171                  const double Tol = 1e-9,
00172          Epetra_RowMatrix* Matrix_in = 0);
00173 
00175   double Condest() const
00176   {
00177     return(Condest_);
00178   }
00179 
00180   // @}
00181   // @{ Query methods
00182   
00184   const char* Label() const {return(Label_);}
00185 
00187   int SetLabel(const char* Label_in)
00188   {
00189     strcpy(Label_,Label_in);
00190     return(0);
00191   }
00192   
00194   double NormInf() const {return(0.0);};
00195 
00197   bool HasNormInf() const {return(false);};
00198 
00200   bool UseTranspose() const {return(UseTranspose_);};
00201 
00203   const Epetra_Map & OperatorDomainMap() const {return(A_->OperatorDomainMap());};
00204 
00206   const Epetra_Map & OperatorRangeMap() const{return(A_->OperatorRangeMap());};
00207 
00209   const Epetra_Comm & Comm() const{return(A_->Comm());};
00210 
00212   const Epetra_RowMatrix& Matrix() const
00213   { 
00214     return(*A_);
00215   }
00216 
00218   virtual double GetLambdaMax() const{return LambdaMax_;}
00219   
00221   virtual double GetOmega() const{if(UseGlobalDamping_) return 12.0/(11.0*LambdaMax_); else return 1.0;}
00222 
00224   virtual ostream& Print(ostream& os) const;
00225 
00227   virtual int NumInitialize() const
00228   {
00229     return(NumInitialize_);
00230   }
00231 
00233   virtual int NumCompute() const
00234   {
00235     return(NumCompute_);
00236   }
00237 
00239   virtual int NumApplyInverse() const
00240   {
00241     return(NumApplyInverse_);
00242   }
00243 
00245   virtual double InitializeTime() const
00246   {
00247     return(InitializeTime_);
00248   }
00249 
00251   virtual double ComputeTime() const
00252   {
00253     return(ComputeTime_);
00254   }
00255 
00257   virtual double ApplyInverseTime() const
00258   {
00259     return(ApplyInverseTime_);
00260   }
00261 
00263   virtual double InitializeFlops() const
00264   {
00265     return(0.0);
00266   }
00267 
00268   virtual double ComputeFlops() const
00269   {
00270     return(ComputeFlops_);
00271   }
00272 
00273   virtual double ApplyInverseFlops() const
00274   {
00275     return(ApplyInverseFlops_);
00276   }
00277 
00278 private:
00279 
00280   // @}
00281   // @{ Private methods
00282 
00284   Ifpack_SORa(const Ifpack_SORa& RHS) :
00285     Time_(RHS.Comm())
00286   {}
00287 
00289   Ifpack_SORa& operator=(const Ifpack_SORa& RHS)
00290   {
00291     return(*this);
00292   }
00293 
00295   void Destroy();
00296 
00298 
00308   int Solve(bool Trans, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00309 
00310 
00311 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00312 
00313   int NumGlobalRows() const {return(A_->NumGlobalRows());};
00314   
00316   int NumGlobalCols() const {return(A_->NumGlobalCols());};
00317 #endif
00318   long long NumGlobalRows64() const {return(A_->NumGlobalRows64());};
00319   long long NumGlobalCols64() const {return(A_->NumGlobalCols64());};
00320   
00322   int NumMyRows() const {return(A_->NumMyRows());};
00323   
00325   int NumMyCols() const {return(A_->NumMyCols());};
00326   
00328   int PowerMethod(const int MaximumIterations,  double& lambda_max);
00329 
00330 
00332   /*  Epetra_RowMatrix& Matrix()
00333   {
00334     return(*A_);
00335     }*/
00336   template<typename int_type>
00337   int TCompute();
00338 
00339   // @}
00340   // @{ Internal data
00341   
00343   Teuchos::RefCountPtr<Epetra_CrsMatrix> Acrs_;
00344   Teuchos::RefCountPtr<Epetra_RowMatrix> A_;
00345   Teuchos::RefCountPtr<Epetra_CrsMatrix> W_; // Strict lower triangle
00346   Teuchos::RefCountPtr<Epetra_Vector>    Wdiag_;
00347   Teuchos::ParameterList List_;  
00348   
00349   bool UseTranspose_;
00350   double Condest_;
00351 
00352 
00354   bool IsInitialized_;
00356   bool IsComputed_;
00358   char Label_[160];
00360   int NumInitialize_;
00362   int NumCompute_;
00363   
00365   double Alpha_;
00367   double Gamma_;
00369   int NumSweeps_;  
00371   bool IsParallel_;
00373   bool HaveOAZBoundaries_;
00375   bool UseInterprocDamping_;
00377   bool UseGlobalDamping_;
00379   double LambdaMax_;
00380 
00382   mutable int NumApplyInverse_;
00384   double InitializeTime_;
00386   double ComputeTime_;
00388   mutable double ApplyInverseTime_;
00390   double ComputeFlops_;
00392   mutable double ApplyInverseFlops_;
00394   mutable Epetra_Time Time_;
00395 
00396 };
00397 #else
00398 #endif
00399 #endif /* IFPACK_SORa_H */
 All Classes Files Functions Variables Enumerations Friends