IFPACK  Development
 All Classes Files Functions Variables Enumerations Friends
Ifpack_HIPS.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_HIPS_H
00044 #define IFPACK_HIPS_H
00045 
00046 #include "Ifpack_ConfigDefs.h"
00047 #ifdef HAVE_IFPACK_HIPS
00048 
00049 
00050 #include "Ifpack_Preconditioner.h"
00051 #include "Ifpack_Condest.h"
00052 #include "Ifpack_ScalingType.h"
00053 #include "Epetra_CompObject.h"
00054 #include "Epetra_MultiVector.h"
00055 #include "Epetra_Vector.h"
00056 #include "Epetra_CrsGraph.h"
00057 #include "Epetra_CrsMatrix.h"
00058 #include "Epetra_BlockMap.h"
00059 #include "Epetra_Map.h"
00060 #include "Epetra_Object.h"
00061 #include "Epetra_Comm.h"
00062 #include "Epetra_CrsMatrix.h"
00063 #include "Epetra_Time.h"
00064 #include "Teuchos_RefCountPtr.hpp"
00065 
00066 
00067 namespace Teuchos {
00068   class ParameterList;
00069 }
00070 
00072 
00080 class Ifpack_HIPS: public Ifpack_Preconditioner {
00081       
00082 public:
00083   // @{ Constructors and destructors.
00085   Ifpack_HIPS(Epetra_RowMatrix* A);
00086   
00088   ~Ifpack_HIPS()
00089   {
00090     Destroy();
00091   }
00092 
00093   // @}
00094   // @{ Construction methods
00095   
00097   int Initialize();
00098   
00100   bool IsInitialized() const
00101   {
00102     return(IsInitialized_);
00103   }
00104 
00106 
00108   int Compute();
00109 
00111   bool IsComputed() const 
00112   {
00113     return(IsComputed_);
00114   }
00115 
00117   /* This method is only available if the Teuchos package is enabled.
00118      This method recognizes four parameter names: relax_value,
00119      absolute_threshold, relative_threshold and overlap_mode. These names are
00120      case insensitive, and in each case except overlap_mode, the ParameterEntry
00121      must have type double. For overlap_mode, the ParameterEntry must have
00122      type Epetra_CombineMode.
00123   */
00124   int SetParameters(Teuchos::ParameterList& parameterlist);
00125 
00127 
00136   int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
00137   // @}
00138 
00139   // @{ Mathematical functions.
00140   // Applies the matrix to X, returns the result in Y.
00141   int Apply(const Epetra_MultiVector& X, 
00142            Epetra_MultiVector& Y) const
00143   {
00144     return(Multiply(false,X,Y));
00145   }
00146 
00147   int Multiply(bool Trans, const Epetra_MultiVector& X, 
00148            Epetra_MultiVector& Y) const{return A_->Multiply(Trans,X,Y);}
00149 
00151 
00164   int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00165 
00167   double Condest(const Ifpack_CondestType CT = Ifpack_Cheap, 
00168                  const int MaxIters = 1550,
00169                  const double Tol = 1e-9,
00170          Epetra_RowMatrix* Matrix_in = 0);
00171 
00173   double Condest() const
00174   {
00175     return(Condest_);
00176   }
00177 
00178   // @}
00179   // @{ Query methods
00180   
00182   const char* Label() const {return(Label_);}
00183 
00185   int SetLabel(const char* Label_in)
00186   {
00187     strcpy(Label_,Label_in);
00188     return(0);
00189   }
00190 
00191   
00193   double NormInf() const {return(0.0);};
00194 
00196   bool HasNormInf() const {return(false);};
00197 
00199   bool UseTranspose() const {return(UseTranspose_);};
00200 
00202   const Epetra_Map & OperatorDomainMap() const {return(A_->OperatorDomainMap());};
00203 
00205   const Epetra_Map & OperatorRangeMap() const{return(A_->OperatorRangeMap());};
00206 
00208   const Epetra_Comm & Comm() const{return(A_->Comm());};
00209 
00211   const Epetra_RowMatrix& Matrix() const
00212   { 
00213     return(*A_);
00214   }
00215 
00217   virtual ostream& Print(ostream& os) const;
00218 
00220   virtual int NumInitialize() const
00221   {
00222     return(NumInitialize_);
00223   }
00224 
00226   virtual int NumCompute() const
00227   {
00228     return(NumCompute_);
00229   }
00230 
00232   virtual int NumApplyInverse() const
00233   {
00234     return(NumApplyInverse_);
00235   }
00236 
00238   virtual double InitializeTime() const
00239   {
00240     return(InitializeTime_);
00241   }
00242 
00244   virtual double ComputeTime() const
00245   {
00246     return(ComputeTime_);
00247   }
00248 
00250   virtual double ApplyInverseTime() const
00251   {
00252     return(ApplyInverseTime_);
00253   }
00254 
00256   virtual double InitializeFlops() const
00257   {
00258     return(0.0);
00259   }
00260 
00261   virtual double ComputeFlops() const
00262   {
00263     return(ComputeFlops_);
00264   }
00265 
00266   virtual double ApplyInverseFlops() const
00267   {
00268     return(ApplyInverseFlops_);
00269   }
00270 
00271 private:
00272 
00273   // @}
00274   // @{ Private methods
00275 
00277   Ifpack_HIPS(const Ifpack_HIPS& RHS) :
00278     Time_(RHS.Comm())
00279   {}
00280 
00282   Ifpack_HIPS& operator=(const Ifpack_HIPS& RHS)
00283   {
00284     return(*this);
00285   }
00286 
00288   void Destroy();
00289 
00291 
00301   int Solve(bool Trans, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00302 
00303 
00305   int NumGlobalRows() const {return(A_->NumGlobalRows());};
00306   
00308   int NumGlobalCols() const {return(A_->NumGlobalCols());};
00309   
00311   int NumMyRows() const {return(A_->NumMyRows());};
00312   
00314   int NumMyCols() const {return(A_->NumMyCols());};
00315   
00317   /*  Epetra_RowMatrix& Matrix()
00318   {
00319     return(*A_);
00320     }*/
00321 
00322   // @}
00323   // @{ Internal data
00324   
00326   Teuchos::RefCountPtr<Epetra_RowMatrix> A_;
00327   Teuchos::ParameterList List_;
00328   Teuchos::RefCountPtr<Epetra_Map> RowMap0_;
00329   Teuchos::RefCountPtr<Epetra_Map> ColMap0_;
00330   
00331   
00332   int HIPS_id;
00333   
00334   bool UseTranspose_;
00335   bool Allocated_;
00336   bool ValuesInitialized_;
00337   bool Factored_;
00338   
00339   double Condest_;
00340 
00341   bool IsParallel_;
00343   bool IsInitialized_;
00345   bool IsComputed_;
00347   char Label_[160];
00349   int NumInitialize_;
00351   int NumCompute_;
00352 
00354   mutable int NumApplyInverse_;
00356   double InitializeTime_;
00358   double ComputeTime_;
00360   mutable double ApplyInverseTime_;
00362   double ComputeFlops_;
00364   mutable double ApplyInverseFlops_;
00366   mutable Epetra_Time Time_;
00367 
00368 };
00369 
00370 #endif
00371 #endif /* IFPACK_HIPS_H */
 All Classes Files Functions Variables Enumerations Friends