IFPACK  Development
 All Classes Files Functions Variables Enumerations Friends
Ifpack_PointRelaxation.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_POINTRELAXATION_H
00044 #define IFPACK_POINTRELAXATION_H
00045 
00046 #include "Ifpack_ConfigDefs.h"
00047 #include "Ifpack_Preconditioner.h"
00048 
00049 #include "Epetra_Vector.h"
00050 #include "Epetra_Time.h"
00051 #include "Epetra_RowMatrix.h"
00052 #include "Epetra_Import.h"
00053 
00054 #include "Teuchos_RefCountPtr.hpp"
00055 
00056 namespace Teuchos {
00057   class ParameterList;
00058 }
00059 class Epetra_MultiVector;
00060 class Epetra_Vector;
00061 class Epetra_Map;
00062 class Epetra_Comm;
00063 class Epetra_CrsMatrix;
00064 
00066 
00130 class Ifpack_PointRelaxation : public Ifpack_Preconditioner {
00131 
00132 public:
00133 
00135 
00136 
00141   Ifpack_PointRelaxation(const Epetra_RowMatrix* Matrix);
00142 
00144   virtual ~Ifpack_PointRelaxation() {}
00145 
00147 
00154   virtual inline int SetUseTranspose(bool UseTranspose_in)
00155   {
00156     UseTranspose_ = UseTranspose_in;
00157     return(0);
00158   }
00159 
00161 
00163 
00165 
00173   virtual inline int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const
00174   {
00175     if (IsComputed() == false)
00176       IFPACK_CHK_ERR(-3);
00177 
00178     if (X.NumVectors() != Y.NumVectors())
00179       IFPACK_CHK_ERR(-2);
00180 
00181     IFPACK_CHK_ERR(Matrix_->Multiply(UseTranspose(),X,Y));
00182     return(0);
00183   }
00184 
00186 
00196   virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00197 
00199   virtual double NormInf() const
00200   {
00201     return(-1.0);
00202   }
00204 
00206 
00207   virtual const char * Label() const
00208   {
00209     return(Label_.c_str());
00210   }
00211 
00213   virtual bool UseTranspose() const
00214   {
00215     return(UseTranspose_);
00216   }
00217 
00219   virtual bool HasNormInf() const
00220   {
00221     return(false);
00222   }
00223 
00225   virtual const Epetra_Comm & Comm() const;
00226 
00228   virtual const Epetra_Map & OperatorDomainMap() const;
00229 
00231   virtual const Epetra_Map & OperatorRangeMap() const;
00232 
00233   virtual int Initialize();
00234 
00235   virtual bool IsInitialized() const
00236   {
00237     return(IsInitialized_);
00238   }
00239 
00241   virtual inline bool IsComputed() const
00242   {
00243     return(IsComputed_);
00244   }
00245 
00247   virtual int Compute();
00248 
00250 
00252 
00253   virtual const Epetra_RowMatrix& Matrix() const
00254   {
00255     return(*Matrix_);
00256   }
00257 
00259   virtual double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
00260                          const int MaxIters = 1550,
00261                          const double Tol = 1e-9,
00262              Epetra_RowMatrix* Matrix = 0);
00263 
00265   virtual double Condest() const
00266   {
00267     return(Condest_);
00268   }
00269 
00271   virtual int SetParameters(Teuchos::ParameterList& List);
00272 
00274   virtual ostream& Print(ostream & os) const;
00275 
00277 
00279 
00281   virtual int NumInitialize() const
00282   {
00283     return(NumInitialize_);
00284   }
00285 
00287   virtual int NumCompute() const
00288   {
00289     return(NumCompute_);
00290   }
00291 
00293   virtual int NumApplyInverse() const
00294   {
00295     return(NumApplyInverse_);
00296   }
00297 
00299   virtual double InitializeTime() const
00300   {
00301     return(InitializeTime_);
00302   }
00303 
00305   virtual double ComputeTime() const
00306   {
00307     return(ComputeTime_);
00308   }
00309 
00311   virtual double ApplyInverseTime() const
00312   {
00313     return(ApplyInverseTime_);
00314   }
00315 
00317   virtual double InitializeFlops() const
00318   {
00319     return(0.0);
00320   }
00321 
00323   virtual double ComputeFlops() const
00324   {
00325     return(ComputeFlops_);
00326   }
00327 
00329   virtual double ApplyInverseFlops() const
00330   {
00331     return(ApplyInverseFlops_);
00332   }
00333 
00334   // @}
00335 
00336 private:
00337 
00338   // @{ Application of the preconditioner
00339 
00341   virtual int ApplyInverseJacobi(const Epetra_MultiVector& X,
00342                                  Epetra_MultiVector& Y) const;
00343 
00345   virtual int ApplyInverseGS(const Epetra_MultiVector& X,
00346                               Epetra_MultiVector& Y) const;
00347 
00348   virtual int ApplyInverseGS_RowMatrix(const Epetra_MultiVector& X,
00349                                         Epetra_MultiVector& Y) const;
00350 
00351   virtual int ApplyInverseGS_CrsMatrix(const Epetra_CrsMatrix* A,
00352                                         const Epetra_MultiVector& X,
00353                                         Epetra_MultiVector& Y) const;
00354 
00355   virtual int ApplyInverseGS_FastCrsMatrix(const Epetra_CrsMatrix* A,
00356                                             const Epetra_MultiVector& X,
00357                                             Epetra_MultiVector& Y) const;
00358   virtual int ApplyInverseGS_LocalFastCrsMatrix(const Epetra_CrsMatrix* A,
00359                                             const Epetra_MultiVector& X,
00360                                             Epetra_MultiVector& Y) const;
00361 
00363   virtual int ApplyInverseSGS(const Epetra_MultiVector& X,
00364                               Epetra_MultiVector& Y) const;
00365 
00366   virtual int ApplyInverseSGS_RowMatrix(const Epetra_MultiVector& X,
00367                                         Epetra_MultiVector& Y) const;
00368 
00369   virtual int ApplyInverseSGS_CrsMatrix(const Epetra_CrsMatrix* A,
00370                                         const Epetra_MultiVector& X,
00371                                         Epetra_MultiVector& Y) const;
00372 
00373   virtual int ApplyInverseSGS_FastCrsMatrix(const Epetra_CrsMatrix* A,
00374                                             const Epetra_MultiVector& X,
00375                                             Epetra_MultiVector& Y) const;
00376 
00377   virtual int ApplyInverseSGS_LocalFastCrsMatrix(const Epetra_CrsMatrix* A,
00378                                             const Epetra_MultiVector& X,
00379                                             Epetra_MultiVector& Y) const;
00380 
00381 
00383 
00384 private:
00385 
00387   virtual void SetLabel();
00388 
00390   Ifpack_PointRelaxation(const Ifpack_PointRelaxation& rhs)
00391   {}
00392 
00394   Ifpack_PointRelaxation& operator=(const Ifpack_PointRelaxation& rhs)
00395   {
00396     return(*this);
00397   }
00398 
00399   // @{ Initializations, timing and flops
00401   bool IsInitialized_;
00403   bool IsComputed_;
00405   int NumInitialize_;
00407   int NumCompute_;
00409   mutable int NumApplyInverse_;
00411   double InitializeTime_;
00413   double ComputeTime_;
00415   mutable double ApplyInverseTime_;
00417   double ComputeFlops_;
00419   mutable double ApplyInverseFlops_;
00420   // @}
00421 
00422   // @{ Settings
00424   int NumSweeps_;
00426   double DampingFactor_;
00428   bool UseTranspose_;
00430   double Condest_;
00432   bool ComputeCondest_;
00434   string Label_;
00435   int PrecType_;
00436   double MinDiagonalValue_;
00437   // @}
00438 
00439   // @{ Other data
00441   int NumMyRows_;
00443   int NumMyNonzeros_;
00445   long long NumGlobalRows_;
00447   long long NumGlobalNonzeros_;
00449   Teuchos::RefCountPtr<const Epetra_RowMatrix> Matrix_;
00451   Teuchos::RefCountPtr<Epetra_Import> Importer_;
00453   mutable Teuchos::RefCountPtr<Epetra_Vector> Diagonal_;
00455   Teuchos::RefCountPtr<Epetra_Time> Time_;
00457   bool IsParallel_;
00459   bool ZeroStartingSolution_;
00461   bool DoBackwardGS_;
00463   bool DoL1Method_;
00465   double L1Eta_;
00466 
00468   int NumLocalSmoothingIndices_;
00470   int * LocalSmoothingIndices_;
00471 
00472   // @}
00473 
00474 
00475 
00476 };
00477 
00478 #endif // IFPACK_POINTRELAXATION_H
 All Classes Files Functions Variables Enumerations Friends