IFPACK  Development
 All Classes Files Functions Variables Enumerations Friends
Ifpack_ILU.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_ILU_H
00044 #define IFPACK_ILU_H
00045 
00046 #include "Ifpack_ConfigDefs.h"
00047 #include "Ifpack_Preconditioner.h"
00048 #include "Ifpack_Condest.h"
00049 #include "Ifpack_ScalingType.h"
00050 #include "Ifpack_IlukGraph.h"
00051 #include "Epetra_CompObject.h"
00052 #include "Epetra_MultiVector.h"
00053 #include "Epetra_Vector.h"
00054 #include "Epetra_CrsGraph.h"
00055 #include "Epetra_CrsMatrix.h"
00056 #include "Epetra_BlockMap.h"
00057 #include "Epetra_Map.h"
00058 #include "Epetra_Object.h"
00059 #include "Epetra_Comm.h"
00060 #include "Epetra_RowMatrix.h"
00061 #include "Epetra_Time.h"
00062 #include "Teuchos_RefCountPtr.hpp"
00063 
00064 namespace Teuchos {
00065   class ParameterList;
00066 }
00067 
00069 
00083 class Ifpack_ILU: public Ifpack_Preconditioner {
00084       
00085 public:
00086   // @{ Constructors and destructors.
00088   Ifpack_ILU(Epetra_RowMatrix* A);
00089   
00091   ~Ifpack_ILU()
00092   {
00093     Destroy();
00094   }
00095 
00096   // @}
00097   // @{ Construction methods
00098   
00100   int Initialize();
00101   
00103   bool IsInitialized() const
00104   {
00105     return(IsInitialized_);
00106   }
00107 
00109 
00117   int Compute();
00118 
00120   bool IsComputed() const 
00121   {
00122     return(IsComputed_);
00123   }
00124 
00126   /* This method is only available if the Teuchos package is enabled.
00127      This method recognizes four parameter names: relax_value,
00128      absolute_threshold, relative_threshold and overlap_mode. These names are
00129      case insensitive, and in each case except overlap_mode, the ParameterEntry
00130      must have type double. For overlap_mode, the ParameterEntry must have
00131      type Epetra_CombineMode.
00132   */
00133   int SetParameters(Teuchos::ParameterList& parameterlist);
00134 
00136 
00145   int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
00146   // @}
00147 
00148   // @{ Mathematical functions.
00149   // Applies the matrix to X, returns the result in Y.
00150   int Apply(const Epetra_MultiVector& X, 
00151            Epetra_MultiVector& Y) const
00152   {
00153     return(Multiply(false,X,Y));
00154   }
00155 
00156   int Multiply(bool Trans, const Epetra_MultiVector& X, 
00157            Epetra_MultiVector& Y) const;
00158 
00160 
00173   int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00174 
00176   double Condest(const Ifpack_CondestType CT = Ifpack_Cheap, 
00177                  const int MaxIters = 1550,
00178                  const double Tol = 1e-9,
00179          Epetra_RowMatrix* Matrix_in = 0);
00180 
00182   double Condest() const
00183   {
00184     return(Condest_);
00185   }
00186 
00187   // @}
00188   // @{ Query methods
00189   
00191   const Epetra_CrsMatrix & L() const {return(*L_);};
00192     
00194   const Epetra_Vector & D() const {return(*D_);};
00195     
00197   const Epetra_CrsMatrix & U() const {return(*U_);};
00198 
00200   const char* Label() const {return(Label_);}
00201 
00203   int SetLabel(const char* Label_in)
00204   {
00205     strcpy(Label_,Label_in);
00206     return(0);
00207   }
00208   
00210   double NormInf() const {return(0.0);};
00211 
00213   bool HasNormInf() const {return(false);};
00214 
00216   bool UseTranspose() const {return(UseTranspose_);};
00217 
00219   const Epetra_Map & OperatorDomainMap() const {return(U_->OperatorDomainMap());};
00220 
00222   const Epetra_Map & OperatorRangeMap() const{return(L_->OperatorRangeMap());};
00223 
00225   const Epetra_Comm & Comm() const{return(Comm_);};
00226 
00228   const Epetra_RowMatrix& Matrix() const
00229   { 
00230     return(*A_);
00231   }
00232 
00234   virtual ostream& Print(ostream& os) const;
00235 
00237   virtual int NumInitialize() const
00238   {
00239     return(NumInitialize_);
00240   }
00241 
00243   virtual int NumCompute() const
00244   {
00245     return(NumCompute_);
00246   }
00247 
00249   virtual int NumApplyInverse() const
00250   {
00251     return(NumApplyInverse_);
00252   }
00253 
00255   virtual double InitializeTime() const
00256   {
00257     return(InitializeTime_);
00258   }
00259 
00261   virtual double ComputeTime() const
00262   {
00263     return(ComputeTime_);
00264   }
00265 
00267   virtual double ApplyInverseTime() const
00268   {
00269     return(ApplyInverseTime_);
00270   }
00271 
00273   virtual double InitializeFlops() const
00274   {
00275     return(0.0);
00276   }
00277 
00278   virtual double ComputeFlops() const
00279   {
00280     return(ComputeFlops_);
00281   }
00282 
00283   virtual double ApplyInverseFlops() const
00284   {
00285     return(ApplyInverseFlops_);
00286   }
00287 
00288 private:
00289 
00290   // @}
00291   // @{ Private methods
00292 
00294   Ifpack_ILU(const Ifpack_ILU& RHS) :
00295     Comm_(RHS.Comm()),
00296     Time_(RHS.Comm())
00297   {}
00298 
00300   Ifpack_ILU& operator=(const Ifpack_ILU& RHS)
00301   {
00302     return(*this);
00303   }
00304 
00306   void Destroy();
00307 
00309 
00319   int Solve(bool Trans, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00320 
00321   int ComputeSetup();
00322   int InitAllValues(const Epetra_RowMatrix & A, int MaxNumEntries);
00323 
00325   int LevelOfFill() const {return LevelOfFill_;}
00326 
00328   double RelaxValue() const {return RelaxValue_;}
00329 
00331   double AbsoluteThreshold() const {return Athresh_;}
00332 
00334   double RelativeThreshold() const {return Rthresh_;}
00335 
00336 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00337 
00338   int NumGlobalRows() const {return(Graph().NumGlobalRows());};
00339   
00341   int NumGlobalCols() const {return(Graph().NumGlobalCols());};
00342   
00344   int NumGlobalNonzeros() const {return(L().NumGlobalNonzeros()+U().NumGlobalNonzeros());};
00345 
00347   virtual int NumGlobalBlockDiagonals() const {return(Graph().NumGlobalBlockDiagonals());};
00348 #endif
00349 
00350   long long NumGlobalRows64() const {return(Graph().NumGlobalRows64());};
00351   
00352   long long NumGlobalCols64() const {return(Graph().NumGlobalCols64());};
00353 
00354   long long NumGlobalNonzeros64() const {return(L().NumGlobalNonzeros64()+U().NumGlobalNonzeros64());};
00355     
00356   virtual long long NumGlobalBlockDiagonals64() const {return(Graph().NumGlobalBlockDiagonals64());};
00357 
00359   int NumMyRows() const {return(Graph().NumMyRows());};
00360   
00362   int NumMyCols() const {return(Graph().NumMyCols());};
00363   
00365   int NumMyNonzeros() const {return(L().NumMyNonzeros()+U().NumMyNonzeros());};
00366   
00368   virtual int NumMyBlockDiagonals() const {return(Graph().NumMyBlockDiagonals());};
00369   
00371   virtual int NumMyDiagonals() const {return(NumMyDiagonals_);};
00372   
00374 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00375   int IndexBase() const {return(Graph().IndexBase());};
00376 #endif
00377   long long IndexBase64() const {return(Graph().IndexBase64());};
00378   
00380   const Ifpack_IlukGraph & Graph() const {return(*Graph_);};
00381   
00383   Epetra_RowMatrix& Matrix()
00384   {
00385     return(*A_);
00386   }
00387 
00388   // @}
00389   // @{ Internal data
00390   
00392   Teuchos::RefCountPtr<Epetra_RowMatrix> A_;
00393   Teuchos::RefCountPtr<Ifpack_IlukGraph> Graph_;
00394   Teuchos::RefCountPtr<Epetra_CrsGraph> CrsGraph_;
00395   Teuchos::RefCountPtr<Epetra_Map> IlukRowMap_;
00396   Teuchos::RefCountPtr<Epetra_Map> IlukDomainMap_;
00397   Teuchos::RefCountPtr<Epetra_Map> IlukRangeMap_;
00398   const Epetra_Map * U_DomainMap_;
00399   const Epetra_Map * L_RangeMap_;
00400   const Epetra_Comm & Comm_;
00402   Teuchos::RefCountPtr<Epetra_CrsMatrix> L_;
00404   Teuchos::RefCountPtr<Epetra_CrsMatrix> U_;
00405   Teuchos::RefCountPtr<Epetra_CrsGraph> L_Graph_;
00406   Teuchos::RefCountPtr<Epetra_CrsGraph> U_Graph_;
00408   Teuchos::RefCountPtr<Epetra_Vector> D_;
00409   bool UseTranspose_;
00410 
00411   int NumMyDiagonals_;
00412   bool Allocated_;
00413   bool ValuesInitialized_;
00414   bool Factored_;
00416   double RelaxValue_;
00418   double Athresh_;
00420   double Rthresh_;
00422   double Condest_;
00424   int LevelOfFill_;
00426   bool IsInitialized_;
00428   bool IsComputed_;
00430   char Label_[160];
00432   int NumInitialize_;
00434   int NumCompute_;
00436   mutable int NumApplyInverse_;
00438   double InitializeTime_;
00440   double ComputeTime_;
00442   mutable double ApplyInverseTime_;
00444   double ComputeFlops_;
00446   mutable double ApplyInverseFlops_;
00448   mutable Epetra_Time Time_;
00449 
00450 };
00451 
00452 #endif /* IFPACK_ILU_H */
 All Classes Files Functions Variables Enumerations Friends