Ifpack_IC.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 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 //@HEADER
00028 */
00029 
00030 #ifndef IFPACK_IC_H
00031 #define IFPACK_IC_H
00032 
00033 #include "Ifpack_ConfigDefs.h"
00034 #ifdef HAVE_IFPACK_TEUCHOS
00035 #include "Ifpack_CondestType.h"
00036 #include "Ifpack_ScalingType.h"
00037 #include "Ifpack_Preconditioner.h"
00038 #include "Epetra_Vector.h"
00039 #include "Epetra_CrsMatrix.h"
00040 class Epetra_RowMatrix;
00041 class Epetra_Comm;
00042 class Epetra_Map;
00043 class Epetra_MultiVector;
00044 namespace Teuchos {
00045   class ParameterList;
00046   template<class T>
00047   class RefCountPtr;  
00048 }
00049 
00051 
00068 class Ifpack_IC: public Ifpack_Preconditioner {
00069       
00070  public:
00072 
00079   Ifpack_IC(Epetra_RowMatrix* A);
00080   
00082   virtual ~Ifpack_IC();
00083 
00085   void SetAbsoluteThreshold( double Athresh) {Athresh_ = Athresh; return;}
00086 
00088   void SetRelativeThreshold( double Rthresh) {Rthresh_ = Rthresh; return;}
00089 
00090 #ifdef HAVE_IFPACK_TEUCHOS
00091 
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 #endif
00101   int SetParameter(const string Name, const int Value)
00102   {
00103     IFPACK_CHK_ERR(-98);
00104   }
00105   int SetParameter(const string Name, const double Value)
00106   {
00107     IFPACK_CHK_ERR(-98);
00108   }
00109 
00110   const Epetra_RowMatrix& Matrix() const
00111   {
00112     return(A_);
00113   }
00114 
00115   Epetra_RowMatrix& Matrix()
00116   {
00117     return(A_);
00118   }
00119 
00120   bool IsInitialized() const
00121   {
00122     return(IsInitialized_);
00123   }
00124 
00126 
00132   int Initialize();
00133 
00135 
00143   int Compute();
00144   int ComputeSetup();
00145 
00147   bool IsComputed() const {return(IsComputed_);};
00148 
00149   // Mathematical functions.
00150   
00152 
00162   int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00163 
00164   int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00165 
00167 
00175   double Condest(const Ifpack_CondestType CT = Ifpack_Cheap, 
00176                  const int MaxIters = 1550, 
00177                  const double Tol = 1e-9,
00178          Epetra_RowMatrix* Matrix = 0);
00179 
00180   double Condest() const
00181   {
00182     return(Condest_);
00183   }
00184 
00185   // Atribute access functions
00186   
00188   double GetAbsoluteThreshold() {return Athresh_;}
00189 
00191   double GetRelativeThreshold() {return Rthresh_;}
00192     
00194   int NumGlobalNonzeros() const {return(U().NumGlobalNonzeros()+D().GlobalLength());};
00195  
00197   int NumMyNonzeros() const {return(U().NumMyNonzeros()+D().MyLength());};
00199   const Epetra_Vector & D() const {return(*D_);};
00200     
00202   const Epetra_CrsMatrix & U() const {return(*U_);};
00203 
00205 
00207 
00216   int SetUseTranspose(bool UseTranspose) {UseTranspose_ = UseTranspose; return(0);};
00217 
00219     double NormInf() const {return(0.0);};
00220 
00222     bool HasNormInf() const {return(false);};
00223 
00225     bool UseTranspose() const {return(UseTranspose_);};
00226 
00228     const Epetra_Map & OperatorDomainMap() const {return(A_.OperatorDomainMap());};
00229 
00231     const Epetra_Map & OperatorRangeMap() const{return(A_.OperatorRangeMap());};
00232 
00234     const Epetra_Comm & Comm() const{return(Comm_);};
00236 
00237     const char* Label() const
00238     {
00239       return(Label_);
00240     }
00241 
00242     int SetLabel(const char* Label)
00243     {
00244       strcpy(Label_,Label);
00245       return(0);
00246     }
00247  
00249   virtual ostream& Print(std::ostream& os) const;
00250 
00252   virtual int NumInitialize() const
00253   {
00254     return(NumInitialize_);
00255   }
00256 
00258   virtual int NumCompute() const
00259   {
00260     return(NumCompute_);
00261   }
00262 
00264   virtual int NumApplyInverse() const
00265   {
00266     return(NumApplyInverse_);
00267   }
00268 
00270   virtual double InitializeTime() const
00271   {
00272     return(InitializeTime_);
00273   }
00274 
00276   virtual double ComputeTime() const
00277   {
00278     return(ComputeTime_);
00279   }
00280 
00282   virtual double ApplyInverseTime() const
00283   {
00284     return(ApplyInverseTime_);
00285   }
00286 
00288   virtual double InitializeFlops() const
00289   {
00290     return(0.0);
00291   }
00292 
00293   virtual double ComputeFlops() const
00294   {
00295     return(ComputeFlops_);
00296   }
00297 
00298   virtual double ApplyInverseFlops() const
00299   {
00300     return(ApplyInverseFlops_);
00301   }
00302 
00303 
00304  private:
00305   
00306   double LevelOfFill() const
00307   {
00308     return(Lfil_);
00309   }
00310 
00311   double AbsoluteThreshold() const
00312   {
00313     return(Athresh_);
00314   }
00315 
00316   double RelativeThreshold() const
00317   {
00318     return(Rthresh_);
00319   }
00320 
00321   double DropTolerance() const
00322   {
00323     return(Droptol_);
00324   }
00325 
00326   Epetra_RowMatrix &A_;
00327   const Epetra_Comm & Comm_;
00328   Teuchos::RefCountPtr<Epetra_CrsMatrix> U_;
00329   Teuchos::RefCountPtr<Epetra_Vector> D_;
00330   bool UseTranspose_;
00331 
00332   double Condest_;
00333   double Athresh_;
00334   double Rthresh_;
00335   double Droptol_;
00336   int Lfil_;
00337 
00338   void * Aict_;
00339   void * Lict_;
00340   double * Ldiag_;
00341   char Label_[160];
00342 
00343   bool IsInitialized_;
00344   bool IsComputed_;
00345  
00347   int NumInitialize_;
00349   int NumCompute_;
00351   mutable int NumApplyInverse_;
00352 
00354   double InitializeTime_;
00356   double ComputeTime_;
00358   mutable double ApplyInverseTime_;
00359 
00361   double ComputeFlops_;
00363   mutable double ApplyInverseFlops_;
00364 
00365 };
00366 
00367 #endif // HAVE_IFPACK_TEUCHOS
00368 #endif /* IFPACK_IC_H */

Generated on Thu Sep 18 12:37:07 2008 for IFPACK by doxygen 1.3.9.1