IFPACK  Development
 All Classes Files Functions Variables Enumerations Friends
Ifpack_SILU.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_SILU_H
00044 #define IFPACK_SILU_H
00045 
00046 #include "Ifpack_ConfigDefs.h"
00047 
00048 #ifdef HAVE_IFPACK_SUPERLU
00049 #include "Ifpack_Preconditioner.h"
00050 #include "Ifpack_Condest.h"
00051 #include "Ifpack_ScalingType.h"
00052 #include "Ifpack_IlukGraph.h"
00053 #include "Epetra_CompObject.h"
00054 #include "Epetra_MultiVector.h"
00055 #include "Epetra_Vector.h"
00056 #include "Epetra_CrsGraph.h"
00057 #include "Epetra_CrsMatrix.h"
00058 #include "Epetra_BlockMap.h"
00059 #include "Epetra_Map.h"
00060 #include "Epetra_Object.h"
00061 #include "Epetra_Comm.h"
00062 #include "Epetra_RowMatrix.h"
00063 #include "Epetra_Time.h"
00064 #include "Teuchos_RefCountPtr.hpp"
00065 
00066 namespace Teuchos {
00067   class ParameterList;
00068 }
00069 
00070 // SuperLU includes
00071 #include "slu_ddefs.h"
00072 
00073 
00083 class Ifpack_SILU: public Ifpack_Preconditioner {
00084       
00085 public:
00087 
00088 
00089   Ifpack_SILU(Epetra_RowMatrix* A);
00090   
00092   ~Ifpack_SILU()
00093   {
00094     Destroy();
00095   }
00096 
00098 
00099 
00100   
00102   int Initialize();
00103   
00105   bool IsInitialized() const
00106   {
00107     return(IsInitialized_);
00108   }
00109 
00111   int Compute();
00112 
00114   bool IsComputed() const 
00115   {
00116     return(IsComputed_);
00117   }
00118 
00120   /* This method is only available if the Teuchos package is enabled.
00121      This method recognizes four parameter names: relax_value,
00122      absolute_threshold, relative_threshold and overlap_mode. These names are
00123      case insensitive, and in each case except overlap_mode, the ParameterEntry
00124      must have type double. For overlap_mode, the ParameterEntry must have
00125      type Epetra_CombineMode.
00126   */
00127   int SetParameters(Teuchos::ParameterList& parameterlist);
00128 
00130 
00139   int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
00141 
00143 
00144   // Applies the matrix to X, returns the result in Y.
00145   int Apply(const Epetra_MultiVector& X, 
00146            Epetra_MultiVector& Y) const
00147   {
00148     return(Multiply(false,X,Y));
00149   }
00150 
00151   int Multiply(bool Trans, const Epetra_MultiVector& X, 
00152            Epetra_MultiVector& Y) const;
00153 
00155 
00168   int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00169 
00171   double Condest(const Ifpack_CondestType CT = Ifpack_Cheap, 
00172                  const int MaxIters = 1550,
00173                  const double Tol = 1e-9,
00174          Epetra_RowMatrix* Matrix_in = 0);
00175 
00177   double Condest() const
00178   {
00179     return(Condest_);
00180   }
00181 
00183 
00185 
00186   
00188   const char* Label() const {return(Label_);}
00189 
00191   int SetLabel(const char* Label_in)
00192   {
00193     strcpy(Label_,Label_in);
00194     return(0);
00195   }
00196   
00198   double NormInf() const {return(0.0);};
00199 
00201   bool HasNormInf() const {return(false);};
00202 
00204   bool UseTranspose() const {return(UseTranspose_);};
00205 
00207   const Epetra_Map & OperatorDomainMap() const {return(A_->OperatorDomainMap());};
00208 
00210   const Epetra_Map & OperatorRangeMap() const{return(A_->OperatorRangeMap());};
00211 
00213   const Epetra_Comm & Comm() const{return(Comm_);};
00214 
00216   const Epetra_RowMatrix& Matrix() const
00217   { 
00218     return(*A_);
00219   }
00220 
00222   virtual ostream& Print(ostream& os) const;
00223 
00225   virtual int NumInitialize() const
00226   {
00227     return(NumInitialize_);
00228   }
00229 
00231   virtual int NumCompute() const
00232   {
00233     return(NumCompute_);
00234   }
00235 
00237   virtual int NumApplyInverse() const
00238   {
00239     return(NumApplyInverse_);
00240   }
00241 
00243   virtual double InitializeTime() const
00244   {
00245     return(InitializeTime_);
00246   }
00247 
00249   virtual double ComputeTime() const
00250   {
00251     return(ComputeTime_);
00252   }
00253 
00255   virtual double ApplyInverseTime() const
00256   {
00257     return(ApplyInverseTime_);
00258   }
00259 
00260   virtual double InitializeFlops() const
00261   {
00262     return(0.0);
00263   }
00264 
00265   virtual double ComputeFlops() const
00266   {
00267     return(0.0);
00268   }
00269 
00270   virtual double ApplyInverseFlops() const
00271   {
00272     return(0.0);
00273   }
00274 
00275 private:
00276 
00278 
00279 
00280 
00282   Ifpack_SILU(const Ifpack_SILU& RHS):
00283     Comm_(RHS.Comm()),
00284     Time_(RHS.Comm())
00285   {}
00286 
00288   Ifpack_SILU& operator=(const Ifpack_SILU& RHS)
00289   {
00290     return(*this);
00291   }
00292 
00294   void Destroy();
00295 
00297 
00307   int Solve(bool Trans, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00308 
00309   int InitAllValues(const Epetra_RowMatrix & A, int MaxNumEntries);
00310 
00312   double DropTol() const {return DropTol_;}
00313 
00315   double FillTol() const{return FillTol_;}
00316 
00318   double FillFactor() const{return FillFactor_;}
00319 
00321   int DropRule() const{return DropRule_;}
00322 
00323 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00324 
00325   int NumGlobalRows() const {return(Graph().NumGlobalRows());};
00326   
00328   int NumGlobalCols() const {return(Graph().NumGlobalCols());};
00329   
00331   int NumGlobalNonzeros() const {return(Graph().NumGlobalNonzeros());};
00332   
00334   virtual int NumGlobalBlockDiagonals() const {return(Graph().NumGlobalBlockDiagonals());};
00335 #endif
00336 
00338   long long NumGlobalRows64() const {return(Graph().NumGlobalRows64());};
00339   
00341   long long NumGlobalCols64() const {return(Graph().NumGlobalCols64());};
00342   
00344   long long NumGlobalNonzeros64() const {return(Graph().NumGlobalNonzeros64());};
00345   
00347   virtual long long NumGlobalBlockDiagonals64() const {return(Graph().NumGlobalBlockDiagonals64());};
00348 
00350   int NumMyRows() const {return(Graph().NumMyRows());};
00351   
00353   int NumMyCols() const {return(Graph().NumMyCols());};
00354   
00356   int NumMyNonzeros() const {return(Graph().NumMyNonzeros());};
00357   
00359   virtual int NumMyBlockDiagonals() const {return(Graph().NumMyBlockDiagonals());};
00360   
00362   virtual int NumMyDiagonals() const {return(NumMyDiagonals_);};
00363   
00364 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00365 
00366   int IndexBase() const {return(Graph().IndexBase());};
00367 #endif
00368   long long IndexBase64() const {return(Graph().IndexBase64());};
00369 
00371   const Epetra_CrsGraph & Graph() const {return(*Graph_);};
00372   
00374   Epetra_RowMatrix& Matrix()
00375   {
00376     return(*A_);
00377   }
00378 
00380 
00382 
00383   
00385   Teuchos::RefCountPtr<Epetra_RowMatrix> A_;
00386   Teuchos::RefCountPtr<Epetra_CrsGraph> Graph_;
00387   Teuchos::RefCountPtr<Epetra_Map> IlukRowMap_;
00388   Teuchos::RefCountPtr<Epetra_Map> IlukDomainMap_;
00389   Teuchos::RefCountPtr<Epetra_Map> IlukRangeMap_;
00390   const Epetra_Comm & Comm_;
00392   Teuchos::RefCountPtr<Epetra_CrsMatrix> Aover_;
00393   bool UseTranspose_;
00394 
00395   int NumMyDiagonals_;
00396   bool Allocated_;
00397   bool ValuesInitialized_;
00398   bool Factored_;
00399 
00401   double DropTol_;
00403   double FillTol_;
00405   double FillFactor_;
00407   int DropRule_;
00408 
00410   double Condest_;
00412   bool IsInitialized_;
00414   bool IsComputed_;
00416   char Label_[160];
00418   int NumInitialize_;
00420   int NumCompute_;
00422   mutable int NumApplyInverse_;
00424   double InitializeTime_;
00426   double ComputeTime_;
00428   mutable double ApplyInverseTime_;
00430   mutable Epetra_Time Time_;
00432   mutable SuperLUStat_t stat_;
00434   mutable superlu_options_t options_;
00436   mutable SuperMatrix SA_,SAc_,SL_,SU_,SY_;
00438   int *etree_,*perm_r_,*perm_c_;
00440 
00441 
00442   template<typename int_type>
00443   int TInitialize();
00444 };
00445 
00446 #endif /* HAVE_IFPACK_SUPERLU */
00447 #endif /* IFPACK_ILU_H */
 All Classes Files Functions Variables Enumerations Friends