IFPACK  Development
 All Classes Files Functions Variables Enumerations Friends
Ifpack_IKLU.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_IKLU_H
00044 #define IFPACK_IKLU_H
00045 
00046 #include "Ifpack_ConfigDefs.h"
00047 #include "Ifpack_CondestType.h"
00048 #include "Ifpack_ScalingType.h"
00049 #include "Ifpack_Preconditioner.h"
00050 #include "Ifpack_IKLU_Utils.h"  
00051 #include "Epetra_Vector.h"
00052 #include "Epetra_CrsMatrix.h"
00053 #include "Epetra_Time.h"
00054 #include "Teuchos_RefCountPtr.hpp"
00055 
00056 class Epetra_RowMatrix;
00057 class Epetra_SerialComm;
00058 class Epetra_Comm;
00059 class Epetra_Map;
00060 class Epetra_MultiVector;
00061 
00062 namespace Teuchos {
00063   class ParameterList;
00064 }
00065 
00067 
00079 class Ifpack_IKLU: public Ifpack_Preconditioner {
00080       
00081 public:
00082   // @{ Constructors and Destructors
00084   Ifpack_IKLU(const Epetra_RowMatrix* A);
00085   
00087   virtual ~Ifpack_IKLU();
00088 
00089   // @}
00090   // @{ Construction methods
00092   /* This method is only available if the Teuchos package is enabled.
00093      This method recognizes five parameter names: level_fill, drop_tolerance,
00094      absolute_threshold, relative_threshold and overlap_mode. These names are
00095      case insensitive. For level_fill the ParameterEntry must have type int, the 
00096      threshold entries must have type double and overlap_mode must have type
00097      Epetra_CombineMode.
00098   */
00099   int SetParameters(Teuchos::ParameterList& parameterlis);
00100 
00102 
00108   int Initialize();
00109 
00111   bool IsInitialized() const
00112   {
00113     return(IsInitialized_);
00114   }
00115 
00117 
00125   int Compute();
00126 
00128   bool IsComputed() const {return(IsComputed_);};
00129 
00130   // Mathematical functions.
00131   
00133 
00141   int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00142 
00143   int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00144 
00146   double Condest(const Ifpack_CondestType CT = Ifpack_Cheap, 
00147                  const int MaxIters = 1550,
00148                  const double Tol = 1e-9,
00149          Epetra_RowMatrix* Matrix_in = 0);
00150 
00152   double Condest() const
00153   {
00154     return(Condest_);
00155   }
00156 
00158 
00167   int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
00168 
00170   double NormInf() const {return(0.0);};
00171 
00173   bool HasNormInf() const {return(false);};
00174 
00176   bool UseTranspose() const {return(UseTranspose_);};
00177 
00179   const Epetra_Map & OperatorDomainMap() const {return(A_.OperatorDomainMap());};
00180 
00182   const Epetra_Map & OperatorRangeMap() const{return(A_.OperatorRangeMap());};
00183 
00185   const Epetra_Comm & Comm() const{return(Comm_);};
00186 
00188   const Epetra_RowMatrix& Matrix() const
00189   {
00190     return(A_);
00191   }
00192 
00194   const Epetra_CrsMatrix & L() const {return(*L_);};
00195   
00197   const Epetra_CrsMatrix & U() const {return(*U_);};
00198     
00200   const char* Label() const
00201   {
00202     return(Label_.c_str());
00203   }
00204 
00206   int SetLabel(const char* Label_in)
00207   {
00208     Label_ = Label_in;
00209     return(0);
00210   }
00211  
00213   virtual ostream& Print(std::ostream& os) const;
00214 
00216   virtual int NumInitialize() const
00217   {
00218     return(NumInitialize_);
00219   }
00220 
00222   virtual int NumCompute() const
00223   {
00224     return(NumCompute_);
00225   }
00226 
00228   virtual int NumApplyInverse() const
00229   {
00230     return(NumApplyInverse_);
00231   }
00232 
00234   virtual double InitializeTime() const
00235   {
00236     return(InitializeTime_);
00237   }
00238 
00240   virtual double ComputeTime() const
00241   {
00242     return(ComputeTime_);
00243   }
00244 
00246   virtual double ApplyInverseTime() const
00247   {
00248     return(ApplyInverseTime_);
00249   }
00250 
00252   virtual double InitializeFlops() const
00253   {
00254     return(0.0);
00255   }
00256 
00257   virtual double ComputeFlops() const
00258   {
00259     return(ComputeFlops_);
00260   }
00261 
00262   virtual double ApplyInverseFlops() const
00263   {
00264     return(ApplyInverseFlops_);
00265   }
00266 
00267   inline double LevelOfFill() const {
00268     return(LevelOfFill_);
00269   }
00270 
00272   inline double RelaxValue() const {
00273     return(Relax_);
00274   }
00275 
00277   inline double AbsoluteThreshold() const
00278   {
00279     return(Athresh_);
00280   }
00281 
00283   inline double RelativeThreshold() const
00284   {
00285     return(Rthresh_);
00286   }
00287     
00289   inline double DropTolerance() const
00290   {
00291     return(DropTolerance_);
00292   }
00293     
00295 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00296   int NumGlobalNonzeros() const {
00297     // FIXME: diagonal of L_ should not be stored
00298     return(L().NumGlobalNonzeros() + U().NumGlobalNonzeros() - L().NumGlobalRows());
00299   }
00300 #endif
00301   long long NumGlobalNonzeros64() const {
00302     // FIXME: diagonal of L_ should not be stored
00303     return(L().NumGlobalNonzeros64() + U().NumGlobalNonzeros64() - L().NumGlobalRows64());
00304   }
00305 
00307   int NumMyNonzeros() const {
00308     return(L().NumMyNonzeros() + U().NumMyNonzeros());
00309   }
00310 
00311 private:
00312   
00313   // @}
00314   // @{ Internal methods
00315 
00317   Ifpack_IKLU(const Ifpack_IKLU& RHS) :
00318     A_(RHS.Matrix()),
00319     Comm_(RHS.Comm()),
00320     Time_(Comm())
00321   {};
00322 
00324   Ifpack_IKLU& operator=(const Ifpack_IKLU& RHS)
00325   {
00326     return(*this);
00327   }
00328 
00330   void Destroy();
00331 
00332   // @}
00333   // @{ Internal data
00334 
00336   const Epetra_RowMatrix& A_;
00338   const Epetra_Comm& Comm_;
00340   Teuchos::RefCountPtr<Epetra_CrsMatrix> L_;
00342   Teuchos::RefCountPtr<Epetra_CrsMatrix> U_;
00344   double Condest_;
00346   double Relax_;
00348   double Athresh_;
00350   double Rthresh_;
00352   double LevelOfFill_;
00354   double DropTolerance_;
00356   string Label_;
00358   bool IsInitialized_;
00360   bool IsComputed_;
00362   bool UseTranspose_;
00364   int NumMyRows_;
00366   int NumMyNonzeros_;
00368   int NumInitialize_;
00370   int NumCompute_;
00372   mutable int NumApplyInverse_;
00374   double InitializeTime_;
00376   double ComputeTime_;
00378   mutable double ApplyInverseTime_;
00380   double ComputeFlops_;
00382   mutable double ApplyInverseFlops_;
00384   mutable Epetra_Time Time_;
00386   long long GlobalNonzeros_;
00387   Teuchos::RefCountPtr<Epetra_SerialComm> SerialComm_;
00388   Teuchos::RefCountPtr<Epetra_Map> SerialMap_;
00389 
00391   csr* csrA_;
00392   css* cssS_;
00394   csrn* csrnN_;
00395 
00396 }; // Ifpack_IKLU
00397 
00398 #endif /* IFPACK_IKLU_H */
 All Classes Files Functions Variables Enumerations Friends