IFPACK Development
Ifpack_ICT.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_ICT_H
00044 #define IFPACK_ICT_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 
00083 class Ifpack_ICT: public Ifpack_Preconditioner {
00084       
00085  public:
00087 
00094   Ifpack_ICT(const Epetra_RowMatrix* A);
00095   
00097   virtual ~Ifpack_ICT();
00098 
00100   /* This method is only available if the Teuchos package is enabled.
00101      This method recognizes five parameter names: level_fill, drop_tolerance,
00102      absolute_threshold, relative_threshold and overlap_mode. These names are
00103      case insensitive. For level_fill the ParameterEntry must have type int, the 
00104      threshold entries must have type double and overlap_mode must have type
00105      Epetra_CombineMode.
00106   */
00107   int SetParameters(Teuchos::ParameterList& parameterlis);
00108 
00110   const Epetra_RowMatrix& Matrix() const
00111   {
00112     return(A_);
00113   }
00114 
00116   bool IsInitialized() const
00117   {
00118     return(IsInitialized_);
00119   }
00120 
00122 
00128   int Initialize();
00129 
00131 
00139   int Compute();
00140 
00142   bool IsComputed() const {return(IsComputed_);};
00143 
00144   // Mathematical functions.
00145   
00147 
00157   int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00158 
00159   int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00160 
00162 
00170   double Condest(const Ifpack_CondestType CT = Ifpack_Cheap, 
00171                  const int MaxIters = 1550,
00172                  const double Tol = 1e-9,
00173          Epetra_RowMatrix* Matrix_in = 0);
00174 
00175   double Condest() const
00176   {
00177     return(Condest_);
00178   }
00179 
00180   // Attribute access functions
00181     
00183 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00184   int NumGlobalNonzeros() const {return(H().NumGlobalNonzeros());};
00185 #endif
00186   long long NumGlobalNonzeros64() const {return(H().NumGlobalNonzeros64());};
00187  
00189   int NumMyNonzeros() const {return(H().NumMyNonzeros());};
00190 
00192   const Epetra_CrsMatrix& H() const {return(*H_);};
00193     
00195 
00197 
00206   int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
00207 
00209   double NormInf() const {return(0.0);};
00210 
00212   bool HasNormInf() const {return(false);};
00213 
00215   bool UseTranspose() const {return(UseTranspose_);};
00216 
00218   const Epetra_Map& OperatorDomainMap() const {return(A_.OperatorDomainMap());};
00219 
00221   const Epetra_Map& OperatorRangeMap() const{return(A_.OperatorRangeMap());};
00222 
00224   const Epetra_Comm& Comm() const{return(Comm_);};
00226 
00227   const char* Label() const
00228   {
00229     return(Label_.c_str());
00230   }
00231 
00232   int SetLabel(const char* Label_in)
00233   {
00234     Label_ = Label_in;
00235     return(0);
00236   }
00237  
00239   virtual ostream& Print(std::ostream& os) const;
00240 
00242   virtual int NumInitialize() const
00243   {
00244     return(NumInitialize_);
00245   }
00246 
00248   virtual int NumCompute() const
00249   {
00250     return(NumCompute_);
00251   }
00252 
00254   virtual int NumApplyInverse() const
00255   {
00256     return(NumApplyInverse_);
00257   }
00258 
00260   virtual double InitializeTime() const
00261   {
00262     return(InitializeTime_);
00263   }
00264 
00266   virtual double ComputeTime() const
00267   {
00268     return(ComputeTime_);
00269   }
00270 
00272   virtual double ApplyInverseTime() const
00273   {
00274     return(ApplyInverseTime_);
00275   }
00276 
00278   virtual double InitializeFlops() const
00279   {
00280     return(0.0);
00281   }
00282 
00284   virtual double ComputeFlops() const
00285   {
00286     return(ComputeFlops_);
00287   }
00288 
00290   virtual double ApplyInverseFlops() const
00291   {
00292     return(ApplyInverseFlops_);
00293   }
00294 
00296 
00299   inline double LevelOfFill() const
00300   {
00301     return(LevelOfFill_);
00302   }
00303 
00305   inline double AbsoluteThreshold() const
00306   {
00307     return(Athresh_);
00308   }
00309 
00311   inline double RelativeThreshold() const
00312   {
00313     return(Rthresh_);
00314   }
00315 
00317   inline double RelaxValue() const
00318   {
00319     return(Relax_);
00320   }
00321 
00323   inline double DropTolerance() const
00324   {
00325     return(DropTolerance_);
00326   }
00327 
00328 private:
00329   
00331   Ifpack_ICT(const Ifpack_ICT& rhs) :
00332     A_(rhs.Matrix()),
00333     Comm_(Comm()),
00334     Time_(Comm())
00335   {}
00336 
00338   Ifpack_ICT& operator=(const Ifpack_ICT& rhs)
00339   {
00340     return(*this);
00341   }
00342 
00344   void Destroy();
00345 
00347   const Epetra_RowMatrix& A_;
00349   const Epetra_Comm& Comm_;
00351   Teuchos::RefCountPtr<Epetra_CrsMatrix> H_;
00353   double Condest_;
00355   double Athresh_;
00357   double Rthresh_;
00359   double LevelOfFill_;
00361   double DropTolerance_;
00363   double Relax_;
00365   string Label_;
00367   bool IsInitialized_;
00369   bool IsComputed_;
00371   bool UseTranspose_;
00373   int NumMyRows_;
00375   int NumInitialize_;
00377   int NumCompute_;
00379   mutable int NumApplyInverse_;
00381   double InitializeTime_;
00383   double ComputeTime_;
00385   mutable double ApplyInverseTime_;
00387   double ComputeFlops_;
00389   mutable double ApplyInverseFlops_;
00391   mutable Epetra_Time Time_;
00393   long long GlobalNonzeros_;
00394   Teuchos::RefCountPtr<Epetra_SerialComm> SerialComm_;
00395   Teuchos::RefCountPtr<Epetra_Map> SerialMap_;
00396 
00397   template<typename int_type>
00398   int TCompute();
00399 };
00400 
00401 #endif /* IFPACK_ICT_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends