IFPACK Development
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 // 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_IC_H
00044 #define IFPACK_IC_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_RowMatrix.h"
00053 #include "Epetra_Time.h"
00054 #include "Teuchos_RefCountPtr.hpp"
00055 
00056 class Epetra_Comm;
00057 class Epetra_Map;
00058 class Epetra_MultiVector;
00059 namespace Teuchos {
00060   class ParameterList;
00061 }
00062 
00064 
00080 class Ifpack_IC: public Ifpack_Preconditioner {
00081       
00082  public:
00084 
00091   Ifpack_IC(Epetra_RowMatrix* A);
00092   
00094   virtual ~Ifpack_IC();
00095 
00097   void SetAbsoluteThreshold( double Athresh) {Athresh_ = Athresh; return;}
00098 
00100   void SetRelativeThreshold( double Rthresh) {Rthresh_ = Rthresh; return;}
00101 
00103   /* This method is only available if the Teuchos package is enabled.
00104      This method recognizes five parameter names: level_fill, drop_tolerance,
00105      absolute_threshold, relative_threshold and overlap_mode. These names are
00106      case insensitive. For level_fill the ParameterEntry must have type int, the 
00107      threshold entries must have type double and overlap_mode must have type
00108      Epetra_CombineMode.
00109   */
00110   int SetParameters(Teuchos::ParameterList& parameterlis);
00111   
00112   int SetParameter(const string Name, const int Value)
00113   {
00114     IFPACK_CHK_ERR(-98);
00115   }
00116   int SetParameter(const string Name, const double Value)
00117   {
00118     IFPACK_CHK_ERR(-98);
00119   }
00120 
00121   const Epetra_RowMatrix& Matrix() const
00122   {
00123     return(*A_);
00124   }
00125 
00126   Epetra_RowMatrix& Matrix()
00127   {
00128     return(*A_);
00129   }
00130 
00131   bool IsInitialized() const
00132   {
00133     return(IsInitialized_);
00134   }
00135 
00137 
00143   int Initialize();
00144 
00146 
00154   int Compute();
00155   int ComputeSetup();
00156 
00158   bool IsComputed() const {return(IsComputed_);};
00159 
00160   // Mathematical functions.
00161   
00163 
00173   int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00174 
00175   int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00176 
00178 
00186   double Condest(const Ifpack_CondestType CT = Ifpack_Cheap, 
00187                  const int MaxIters = 1550, 
00188                  const double Tol = 1e-9,
00189          Epetra_RowMatrix* Matrix_in = 0);
00190 
00191   double Condest() const
00192   {
00193     return(Condest_);
00194   }
00195 
00196   // Attribute access functions
00197   
00199   double GetAbsoluteThreshold() {return Athresh_;}
00200 
00202   double GetRelativeThreshold() {return Rthresh_;}
00203     
00205 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00206   int NumGlobalNonzeros() const {return(U().NumGlobalNonzeros()+D().GlobalLength());};
00207 #endif
00208   long long NumGlobalNonzeros64() const {return(U().NumGlobalNonzeros64()+D().GlobalLength64());};
00209  
00211   int NumMyNonzeros() const {return(U().NumMyNonzeros()+D().MyLength());};
00213   const Epetra_Vector & D() const {return(*D_);};
00214     
00216   const Epetra_CrsMatrix & U() const {return(*U_);};
00217 
00219 
00221 
00230   int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
00231 
00233     double NormInf() const {return(0.0);};
00234 
00236     bool HasNormInf() const {return(false);};
00237 
00239     bool UseTranspose() const {return(UseTranspose_);};
00240 
00242     const Epetra_Map & OperatorDomainMap() const {return(A_->OperatorDomainMap());};
00243 
00245     const Epetra_Map & OperatorRangeMap() const{return(A_->OperatorRangeMap());};
00246 
00248     const Epetra_Comm & Comm() const{return(Comm_);};
00250 
00251     const char* Label() const
00252     {
00253       return(Label_);
00254     }
00255 
00256     int SetLabel(const char* Label_in)
00257     {
00258       strcpy(Label_,Label_in);
00259       return(0);
00260     }
00261  
00263   virtual ostream& Print(std::ostream& os) const;
00264 
00266   virtual int NumInitialize() const
00267   {
00268     return(NumInitialize_);
00269   }
00270 
00272   virtual int NumCompute() const
00273   {
00274     return(NumCompute_);
00275   }
00276 
00278   virtual int NumApplyInverse() const
00279   {
00280     return(NumApplyInverse_);
00281   }
00282 
00284   virtual double InitializeTime() const
00285   {
00286     return(InitializeTime_);
00287   }
00288 
00290   virtual double ComputeTime() const
00291   {
00292     return(ComputeTime_);
00293   }
00294 
00296   virtual double ApplyInverseTime() const
00297   {
00298     return(ApplyInverseTime_);
00299   }
00300 
00302   virtual double InitializeFlops() const
00303   {
00304     return(0.0);
00305   }
00306 
00307   virtual double ComputeFlops() const
00308   {
00309     return(ComputeFlops_);
00310   }
00311 
00312   virtual double ApplyInverseFlops() const
00313   {
00314     return(ApplyInverseFlops_);
00315   }
00316 
00317 
00318  private:
00319   
00320   double LevelOfFill() const
00321   {
00322     return(Lfil_);
00323   }
00324 
00325   double AbsoluteThreshold() const
00326   {
00327     return(Athresh_);
00328   }
00329 
00330   double RelativeThreshold() const
00331   {
00332     return(Rthresh_);
00333   }
00334 
00335   double DropTolerance() const
00336   {
00337     return(Droptol_);
00338   }
00339 
00340   Teuchos::RefCountPtr<Epetra_RowMatrix> A_;
00341   const Epetra_Comm & Comm_;
00342   Teuchos::RefCountPtr<Epetra_CrsMatrix> U_;
00343   Teuchos::RefCountPtr<Epetra_Vector> D_;
00344   bool UseTranspose_;
00345 
00346   double Condest_;
00347   double Athresh_;
00348   double Rthresh_;
00349   double Droptol_;
00350   double Lfil_;
00351 
00352   void * Aict_;
00353   void * Lict_;
00354   double * Ldiag_;
00355   char Label_[160];
00356 
00357   bool IsInitialized_;
00358   bool IsComputed_;
00359  
00361   int NumInitialize_;
00363   int NumCompute_;
00365   mutable int NumApplyInverse_;
00366 
00368   double InitializeTime_;
00370   double ComputeTime_;
00372   mutable double ApplyInverseTime_;
00374   mutable Epetra_Time Time_;
00375 
00377   double ComputeFlops_;
00379   mutable double ApplyInverseFlops_;
00380 
00381 };
00382 
00383 #endif /* IFPACK_IC_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends