IFPACK  Development
 All Classes Files Functions Variables Enumerations Friends
Ifpack_Euclid.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_EUCLID_H
00044 #define IFPACK_EUCLID_H
00045 
00046 #include "Ifpack_ConfigDefs.h"
00047 #ifdef HAVE_EUCLID
00048 
00049 #include "Ifpack_Condest.h"
00050 #include "Ifpack_ScalingType.h"
00051 #include "Epetra_CompObject.h"
00052 #include "Epetra_MultiVector.h"
00053 #include "Epetra_Vector.h"
00054 #include "Epetra_CrsGraph.h"
00055 #include "Epetra_CrsMatrix.h"
00056 #include "Epetra_BlockMap.h"
00057 #include "Epetra_Map.h"
00058 #include "Epetra_Object.h"
00059 #include "Epetra_Comm.h"
00060 #include "Epetra_CrsMatrix.h"
00061 #include "Epetra_Time.h"
00062 #include "Teuchos_RefCountPtr.hpp"
00063 #include "Teuchos_ParameterList.hpp"
00064 #include "Epetra_MpiComm.h"
00065 
00066 #include "Mem_dh.h"
00067 #include "io_dh.h"
00068 #include "TimeLog_dh.h"
00069 #include "Parser_dh.h"
00070 #include "Euclid_dh.h"
00071 
00072 namespace Teuchos {
00073   class ParameterList;
00074 }
00075 
00077 
00082   //The other files that were modified for Trilinos are getRow.c, call_epetra.{cpp,h}.
00083 
00084 class Ifpack_Euclid: public Epetra_Object, public Epetra_CompObject, public virtual Epetra_Operator {
00085       
00086   friend ostream& operator << (ostream& os, const Ifpack_Euclid& A);
00087 
00088 public:
00089   // @{ Constructors and destructors.
00091   Ifpack_Euclid(Epetra_CrsMatrix* A);
00092   
00094   ~Ifpack_Euclid(){ Destroy();}
00095 
00096   // @}
00097   // @{ Construction methods
00098   
00100   int Initialize();
00101   
00103   bool IsInitialized() const{ return(IsInitialized_);}
00104 
00106 
00108   int Compute();
00109 
00111   bool IsComputed() const{ return(IsComputed_);}
00112 
00113 
00115 
00127   int SetParameters(Teuchos::ParameterList& parameterlist);
00128 
00130 
00136   int SetParameter(string name, int Value);
00137 
00139 
00145   int SetParameter(string name, double Value);
00146 
00148   int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
00149   // @}
00150 
00151   // @{ Mathematical functions.
00152   // Applies the matrix to X, returns the result in Y.
00153   int Apply(const Epetra_MultiVector& X, 
00154            Epetra_MultiVector& Y) const{ return(Multiply(false,X,Y));}
00155 
00157 
00167   int Multiply(bool Trans, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const{ return A_->Multiply(Trans, X, Y); }
00168 
00170 
00183   int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00184 
00186   double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,  const int MaxIters = 1550,
00187                  const double Tol = 1e-9, Epetra_RowMatrix* Matrix_in = 0);
00188 
00190   double Condest() const{ return(Condest_);}
00191 
00192   // @}
00193   // @{ Query methods
00194   
00196   const char* Label() const {return(Label_);}
00197 
00199   void SetLabel(const char* Label_in){ strcpy(Label_,Label_in);}
00200   
00202   const Epetra_Map &OperatorDomainMap() const{return A_->DomainMap();}
00203 
00205   const Epetra_Map &OperatorRangeMap() const{return A_->RangeMap();}
00206 
00208   double NormInf() const {return(0.0);};
00209 
00211   bool HasNormInf() const {return(false);};
00212 
00214   bool UseTranspose() const {return(UseTranspose_);};
00215 
00217   const Epetra_Comm & Comm() const{return(A_->Comm());};
00218 
00220   const Epetra_CrsMatrix& Matrix() const{ return(*A_);}
00221 
00223   virtual int NumInitialize() const{ return(NumInitialize_);}
00224 
00226   virtual int NumCompute() const{ return(NumCompute_);}
00227 
00229   virtual int NumApplyInverse() const{ return(NumApplyInverse_);}
00230 
00232   virtual double InitializeTime() const{ return(InitializeTime_);}
00233 
00235   virtual double ComputeTime() const{ return(ComputeTime_);}
00236 
00238   virtual double ApplyInverseTime() const{ return(ApplyInverseTime_);}
00239 
00241   virtual double InitializeFlops() const{ return(0.0);}
00242 
00244   virtual double ComputeFlops() const{ return(ComputeFlops_);}
00245 
00247   virtual double ApplyInverseFlops() const{ return(ApplyInverseFlops_);}
00248 
00249 private:
00250 
00251   // @}
00252   // @{ Private methods
00253 
00255   Ifpack_Euclid(const Ifpack_Euclid& RHS) : Time_(RHS.Comm()){}
00256 
00258   Ifpack_Euclid& operator=(const Ifpack_Euclid& RHS){ return(*this);}
00259 
00261   void Destroy();
00262 
00264   MPI_Comm GetMpiComm() const{ return (dynamic_cast<const Epetra_MpiComm*>(&A_->Comm()))->GetMpiComm();}
00265 
00267   int CallEuclid(double *x, double *y) const;
00268 
00270 
00280   int Solve(bool Trans, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00281 
00283   int NumGlobalRows() const {return(A_->NumGlobalRows());};
00284   
00286   int NumGlobalCols() const {return(A_->NumGlobalCols());};
00287   
00289   int NumMyRows() const {return(A_->NumMyRows());};
00290   
00292   int NumMyCols() const {return(A_->NumMyCols());};
00293   
00294   // @}
00295   // @{ Internal data
00296   
00298   Teuchos::RefCountPtr<Epetra_CrsMatrix> A_;
00300   Teuchos::ParameterList List_;
00302   bool UseTranspose_;
00304   double Condest_;
00306   bool IsInitialized_;
00308   bool IsComputed_;
00310   char Label_[160];
00312   int NumInitialize_;
00314   int NumCompute_;
00316   mutable int NumApplyInverse_;
00318   double InitializeTime_;
00320   double ComputeTime_;
00322   mutable double ApplyInverseTime_;
00324   double ComputeFlops_;
00326   mutable double ApplyInverseFlops_;
00328   mutable Epetra_Time Time_;
00330   Euclid_dh eu;
00332   int SetLevel_;
00334   int SetBJ_;
00336   int SetStats_;
00338   int SetMem_;
00340   double SetSparse_;
00342   int SetRowScale_;
00344   double SetILUT_;
00345 };
00346 
00348 ostream& operator << (ostream& os, const Ifpack_Euclid& A);
00349 
00350 #endif // HAVE_EUCLID
00351 #endif /* IFPACK_EUCLID_H */
 All Classes Files Functions Variables Enumerations Friends