IFPACK  Development
 All Classes Files Functions Variables Enumerations Friends
Ifpack_ILUT.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_ILUT_H
00044 #define IFPACK_ILUT_H
00045 
00046 #include "Ifpack_ConfigDefs.h"
00047 #include "Ifpack_CondestType.h"
00048 #include "Ifpack_ScalingType.h"
00049 #include "Ifpack_Preconditioner.h"
00050 #include "Epetra_Vector.h"
00051 #include "Epetra_CrsMatrix.h"
00052 #include "Epetra_Time.h"
00053 #include "Teuchos_RefCountPtr.hpp"
00054 
00055 class Epetra_RowMatrix;
00056 class Epetra_SerialComm;
00057 class Epetra_Comm;
00058 class Epetra_Map;
00059 class Epetra_MultiVector;
00060 
00061 namespace Teuchos {
00062   class ParameterList;
00063 }
00064 
00066 
00081 class Ifpack_ILUT: public Ifpack_Preconditioner {
00082       
00083 public:
00084   // @{ Constructors and Destructors
00086   Ifpack_ILUT(const Epetra_RowMatrix* A);
00087   
00089   virtual ~Ifpack_ILUT();
00090 
00091   // @}
00092   // @{ Construction methods
00094   /* This method is only available if the Teuchos package is enabled.
00095      This method recognizes five parameter names: level_fill, drop_tolerance,
00096      absolute_threshold, relative_threshold and overlap_mode. These names are
00097      case insensitive. For level_fill the ParameterEntry must have type int, the 
00098      threshold entries must have type double and overlap_mode must have type
00099      Epetra_CombineMode.
00100   */
00101   int SetParameters(Teuchos::ParameterList& parameterlis);
00102 
00104 
00110   int Initialize();
00111 
00113   bool IsInitialized() const
00114   {
00115     return(IsInitialized_);
00116   }
00117 
00119 
00127   int Compute();
00128 
00130   bool IsComputed() const {return(IsComputed_);};
00131 
00132   // Mathematical functions.
00133   
00135 
00143   int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00144 
00145   int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00146 
00148   double Condest(const Ifpack_CondestType CT = Ifpack_Cheap, 
00149                  const int MaxIters = 1550,
00150                  const double Tol = 1e-9,
00151          Epetra_RowMatrix* Matrix_in = 0);
00152 
00154   double Condest() const
00155   {
00156     return(Condest_);
00157   }
00158 
00160 
00169   int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
00170 
00172   double NormInf() const {return(0.0);};
00173 
00175   bool HasNormInf() const {return(false);};
00176 
00178   bool UseTranspose() const {return(UseTranspose_);};
00179 
00181   const Epetra_Map & OperatorDomainMap() const {return(A_.OperatorDomainMap());};
00182 
00184   const Epetra_Map & OperatorRangeMap() const{return(A_.OperatorRangeMap());};
00185 
00187   const Epetra_Comm & Comm() const{return(Comm_);};
00188 
00190   const Epetra_RowMatrix& Matrix() const
00191   {
00192     return(A_);
00193   }
00194 
00196   const Epetra_CrsMatrix & L() const {return(*L_);};
00197   
00199   const Epetra_CrsMatrix & U() const {return(*U_);};
00200     
00202   const char* Label() const
00203   {
00204     return(Label_.c_str());
00205   }
00206 
00208   int SetLabel(const char* Label_in)
00209   {
00210     Label_ = Label_in;
00211     return(0);
00212   }
00213  
00215   virtual ostream& Print(std::ostream& os) const;
00216 
00218   virtual int NumInitialize() const
00219   {
00220     return(NumInitialize_);
00221   }
00222 
00224   virtual int NumCompute() const
00225   {
00226     return(NumCompute_);
00227   }
00228 
00230   virtual int NumApplyInverse() const
00231   {
00232     return(NumApplyInverse_);
00233   }
00234 
00236   virtual double InitializeTime() const
00237   {
00238     return(InitializeTime_);
00239   }
00240 
00242   virtual double ComputeTime() const
00243   {
00244     return(ComputeTime_);
00245   }
00246 
00248   virtual double ApplyInverseTime() const
00249   {
00250     return(ApplyInverseTime_);
00251   }
00252 
00254   virtual double InitializeFlops() const
00255   {
00256     return(0.0);
00257   }
00258 
00259   virtual double ComputeFlops() const
00260   {
00261     return(ComputeFlops_);
00262   }
00263 
00264   virtual double ApplyInverseFlops() const
00265   {
00266     return(ApplyInverseFlops_);
00267   }
00268 
00269   inline double LevelOfFill() const {
00270     return(LevelOfFill_);
00271   }
00272 
00274   inline double RelaxValue() const {
00275     return(Relax_);
00276   }
00277 
00279   inline double AbsoluteThreshold() const
00280   {
00281     return(Athresh_);
00282   }
00283 
00285   inline double RelativeThreshold() const
00286   {
00287     return(Rthresh_);
00288   }
00289     
00291   inline double DropTolerance() const
00292   {
00293     return(DropTolerance_);
00294   }
00295     
00297 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00298   int NumGlobalNonzeros() const {
00299     // FIXME: diagonal of L_ should not be stored
00300     return(L().NumGlobalNonzeros() + U().NumGlobalNonzeros() - L().NumGlobalRows());
00301   }
00302 #endif
00303   long long NumGlobalNonzeros64() const {
00304     // FIXME: diagonal of L_ should not be stored
00305     return(L().NumGlobalNonzeros64() + U().NumGlobalNonzeros64() - L().NumGlobalRows64());
00306   }
00307 
00309   int NumMyNonzeros() const {
00310     return(L().NumMyNonzeros() + U().NumMyNonzeros());
00311   }
00312 
00313 private:
00314   
00315   // @}
00316   // @{ Internal methods
00317 
00319   Ifpack_ILUT(const Ifpack_ILUT& RHS) :
00320     A_(RHS.Matrix()),
00321     Comm_(RHS.Comm()),
00322     Time_(Comm())
00323   {};
00324 
00326   Ifpack_ILUT& operator=(const Ifpack_ILUT& RHS)
00327   {
00328     return(*this);
00329   }
00330 
00331   template<typename int_type>
00332   int TCompute();
00333 
00335   void Destroy();
00336 
00337   // @}
00338   // @{ Internal data
00339 
00341   const Epetra_RowMatrix& A_;
00343   const Epetra_Comm& Comm_;
00345   Teuchos::RefCountPtr<Epetra_CrsMatrix> L_;
00347   Teuchos::RefCountPtr<Epetra_CrsMatrix> U_;
00349   double Condest_;
00351   double Relax_;
00353   double Athresh_;
00355   double Rthresh_;
00357   double LevelOfFill_;
00359   double DropTolerance_;
00361   string Label_;
00363   bool IsInitialized_;
00365   bool IsComputed_;
00367   bool UseTranspose_;
00369   int NumMyRows_;
00371   int NumInitialize_;
00373   int NumCompute_;
00375   mutable int NumApplyInverse_;
00377   double InitializeTime_;
00379   double ComputeTime_;
00381   mutable double ApplyInverseTime_;
00383   double ComputeFlops_;
00385   mutable double ApplyInverseFlops_;
00387   mutable Epetra_Time Time_;
00389   long long GlobalNonzeros_;
00390   Teuchos::RefCountPtr<Epetra_SerialComm> SerialComm_;
00391   Teuchos::RefCountPtr<Epetra_Map> SerialMap_;
00392 }; // Ifpack_ILUT
00393 
00394 #endif /* IFPACK_ILUT_H */
 All Classes Files Functions Variables Enumerations Friends