IFPACK  Development
 All Classes Files Functions Variables Enumerations Friends
Ifpack_SPARSKIT.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_SPARSKIT_H
00044 #define IFPACK_SPARSKIT_H
00045 
00046 #include "Ifpack_ConfigDefs.h"
00047 #ifdef HAVE_IFPACK_SPARSKIT
00048 #include "Ifpack_CondestType.h"
00049 #include "Ifpack_ScalingType.h"
00050 #include "Ifpack_Preconditioner.h"
00051 #include "Epetra_Vector.h"
00052 #include "Epetra_RowMatrix.h"
00053 class Epetra_Comm;
00054 class Epetra_Map;
00055 class Epetra_MultiVector;
00056 namespace Teuchos {
00057   class ParameterList;
00058 }
00059 
00061 
00062 class Ifpack_SPARSKIT: public Ifpack_Preconditioner {
00063       
00064  public:
00066   Ifpack_SPARSKIT(Epetra_RowMatrix* A);
00067   
00069   virtual ~Ifpack_SPARSKIT();
00070 
00072   /* This method is only available if the Teuchos package is enabled.
00073      This method recognizes five parameter names: level_fill, drop_tolerance,
00074      absolute_threshold, relative_threshold and overlap_mode. These names are
00075      case insensitive. For level_fill the ParameterEntry must have type int, the 
00076      threshold entries must have type double and overlap_mode must have type
00077      Epetra_CombineMode.
00078   */
00079   int SetParameters(Teuchos::ParameterList& parameterlis);
00080 
00081   int SetParameter(const string Name, const int Value)
00082   {
00083     IFPACK_CHK_ERR(-98);
00084   }
00085   int SetParameter(const string Name, const double Value)
00086   {
00087     IFPACK_CHK_ERR(-98);
00088   }
00089 
00090   const Epetra_RowMatrix& Matrix() const
00091   {
00092     return(A_);
00093   }
00094 
00095   Epetra_RowMatrix& Matrix()
00096   {
00097     return(A_);
00098   }
00099 
00100   bool IsInitialized() const
00101   {
00102     return(IsInitialized_);
00103   }
00104 
00106   int Initialize();
00107 
00109   int Compute();
00110 
00112   bool IsComputed() const 
00113   {
00114     return(IsComputed_);
00115   }
00116 
00117   // Mathematical functions.
00118   
00120 
00130   int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00131 
00132   int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const
00133   {
00134     IFPACK_CHK_ERR(-1);
00135   }
00136 
00138 
00146   double Condest(const Ifpack_CondestType CT = Ifpack_Cheap, 
00147                  const int MaxIters = 1550, 
00148                  const double Tol = 1e-9,
00149          Epetra_RowMatrix* Matrix = 0);
00150 
00151   double Condest() const
00152   {
00153     return(Condest_);
00154   }
00155 
00156   // Attribute access functions
00157   
00159 
00161 
00170   int SetUseTranspose(bool UseTranspose) {UseTranspose_ = UseTranspose; return(0);};
00171 
00173     double NormInf() const {return(0.0);};
00174 
00176     bool HasNormInf() const {return(false);};
00177 
00179     bool UseTranspose() const {return(UseTranspose_);};
00180 
00182     const Epetra_Map & OperatorDomainMap() const {return(A_.OperatorDomainMap());};
00183 
00185     const Epetra_Map & OperatorRangeMap() const{return(A_.OperatorRangeMap());};
00186 
00188     const Epetra_Comm & Comm() const{return(Comm_);};
00190 
00191     const char* Label() const
00192     {
00193       return(Label_.c_str());
00194     }
00195 
00196     int SetLabel(const char* Label)
00197     {
00198       Label_ = Label;
00199       return(0);
00200     }
00201  
00203   virtual ostream& Print(std::ostream& os) const;
00204 
00206   virtual int NumInitialize() const
00207   {
00208     return(NumInitialize_);
00209   }
00210 
00212   virtual int NumCompute() const
00213   {
00214     return(NumCompute_);
00215   }
00216 
00218   virtual int NumApplyInverse() const
00219   {
00220     return(NumApplyInverse_);
00221   }
00222 
00224   virtual double InitializeTime() const
00225   {
00226     return(InitializeTime_);
00227   }
00228 
00230   virtual double ComputeTime() const
00231   {
00232     return(ComputeTime_);
00233   }
00234 
00236   virtual double ApplyInverseTime() const
00237   {
00238     return(ApplyInverseTime_);
00239   }
00240 
00242   virtual double InitializeFlops() const
00243   {
00244     return(0.0);
00245   }
00246 
00247   virtual double ComputeFlops() const
00248   {
00249     return(0.0);
00250   }
00251 
00252   virtual double ApplyInverseFlops() const
00253   {
00254     return(0.0);
00255   }
00256 
00257 private:
00258   Epetra_RowMatrix& A_;
00259   const Epetra_Comm& Comm_;
00260   bool UseTranspose_;
00261   int lfil_;
00262   double droptol_;
00263   double tol_;
00264   double permtol_;
00265   double alph_;
00266   int mbloc_;
00267   string Type_;
00268 
00269   // Factorization in MSR format.
00270   std::vector<double> alu_;
00271   std::vector<int> jlu_;
00272   std::vector<int> ju_;
00273 
00274   string Label_;
00275   // Permutation vector if required by ILUTP and ILUDP.
00276   std::vector<int> iperm_;
00277 
00278   double Condest_;
00279 
00280   bool IsInitialized_;
00281   bool IsComputed_;
00282  
00284   int NumInitialize_;
00286   int NumCompute_;
00288   mutable int NumApplyInverse_;
00289 
00291   double InitializeTime_;
00293   double ComputeTime_;
00295   mutable double ApplyInverseTime_;
00296 
00298   double ComputeFlops_;
00300   mutable double ApplyInverseFlops_;
00301 
00302 };
00303 
00304 #endif // HAVE_IFPACK_SPARSKIT
00305 #endif /* IFPACK_SPARSKIT_H */
 All Classes Files Functions Variables Enumerations Friends