IFPACK  Development
 All Classes Files Functions Variables Enumerations Friends
Ifpack_Krylov.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_KRYLOV_H
00044 #define IFPACK_KRYLOV_H
00045 
00046 #include "Ifpack_ConfigDefs.h"
00047 #include "Ifpack_Preconditioner.h"
00048 #include "Teuchos_RefCountPtr.hpp"
00049 #include "Ifpack_PointRelaxation.h"
00050 #include "Ifpack_BlockRelaxation.h"
00051 #include "Ifpack_SparseContainer.h"
00052 #include "Ifpack_DenseContainer.h"
00053 #include "Ifpack_Amesos.h"
00054 #ifdef HAVE_IFPACK_AZTECOO
00055 #include "AztecOO.h"
00056 #endif
00057 
00058 namespace Teuchos {
00059   class ParameterList;
00060 }
00061 
00062 class Epetra_MultiVector;
00063 class Epetra_Vector;
00064 class Epetra_Map;
00065 class Epetra_Comm;
00066 class Epetra_Time;
00067 class Epetra_Vector;
00068 class Epetra_Operator;
00069 class Epetra_RowMatrix;
00070 #ifdef HAVE_IFPACK_AZTECOO
00071 class AztecOO;
00072 #endif
00073 
00074 
00075 #ifdef HAVE_IFPACK_EPETRAEXT
00076 class EpetraExt_PointToBlockDiagPermute;
00077 #endif
00078 
00080 
00081 class Ifpack_Krylov : public Ifpack_Preconditioner {
00082 
00083   typedef double                SC;
00084   typedef Epetra_MultiVector    MV;
00085   typedef Epetra_Operator       OP;
00086   typedef Epetra_RowMatrix      RM;
00087 
00088 public:
00089 
00091   Ifpack_Krylov(Epetra_Operator* Matrix);
00092 
00094   Ifpack_Krylov(Epetra_RowMatrix* Matrix);
00095 
00097   virtual ~Ifpack_Krylov() {};
00098 
00100 
00107   virtual inline int SetUseTranspose(bool UseTranspose_in)
00108   {
00109     UseTranspose_ = UseTranspose_in;
00110     return(0);
00111   }
00112 
00114 
00116 
00118 
00126   virtual inline int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00127 
00129 
00139   virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00140 
00142   virtual double NormInf() const
00143   {
00144     return(-1.0);
00145   }
00147 
00149 
00150   virtual const char * Label() const
00151   {
00152     return(Label_.c_str());
00153   }
00154 
00156   virtual bool UseTranspose() const
00157   {
00158     return(UseTranspose_);
00159   }
00160 
00162   virtual bool HasNormInf() const
00163   {
00164     return(false);
00165   }
00166 
00168   virtual const Epetra_Comm & Comm() const;
00169 
00171   virtual const Epetra_Map & OperatorDomainMap() const;
00172 
00174   virtual const Epetra_Map & OperatorRangeMap() const;
00175 
00176   virtual int Initialize();
00177   
00178   virtual bool IsInitialized() const
00179   {
00180     return(IsInitialized_);
00181   }
00182 
00184   virtual inline bool IsComputed() const
00185   {
00186     return(IsComputed_);
00187   }
00188 
00190   virtual int Compute();
00191 
00192   virtual const Epetra_RowMatrix& Matrix() const 
00193   {
00194     return(*Matrix_);
00195   }
00196 
00198   virtual double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
00199                          const int MaxIters = 1550,
00200                          const double Tol = 1e-9,
00201                          Epetra_RowMatrix* Matrix_in = 0);
00202 
00204   virtual double Condest() const
00205   {
00206     return(Condest_);
00207   }
00208 
00210   virtual int SetParameters(Teuchos::ParameterList& List);
00211 
00213   virtual ostream& Print(ostream & os) const;
00214 
00216 
00218 
00220   virtual int NumInitialize() const
00221   {
00222     return(NumInitialize_);
00223   }
00224 
00226   virtual int NumCompute() const
00227   {
00228     return(NumCompute_);
00229   }
00230 
00232   virtual int NumApplyInverse() const
00233   {
00234     return(NumApplyInverse_);
00235   }
00236 
00238   virtual double InitializeTime() const
00239   {
00240     return(InitializeTime_);
00241   }
00242 
00244   virtual double ComputeTime() const
00245   {
00246     return(ComputeTime_);
00247   }
00248 
00250   virtual double ApplyInverseTime() const
00251   {
00252     return(ApplyInverseTime_);
00253   }
00254 
00256   virtual double InitializeFlops() const
00257   {
00258     return(0.0);
00259   }
00260 
00262   virtual double ComputeFlops() const
00263   {
00264     return(ComputeFlops_);
00265   }
00266 
00268   virtual double ApplyInverseFlops() const
00269   {
00270     return(ApplyInverseFlops_);
00271   }
00272 
00273 private:
00274   
00275   // @}
00276   // @{ \name Private methods
00277   
00279   virtual void SetLabel();
00280 
00282   Ifpack_Krylov(const Ifpack_Krylov& rhs)
00283   {}
00284   
00286   Ifpack_Krylov& operator=(const Ifpack_Krylov& rhs)
00287   {
00288     return(*this);
00289   }
00290 
00291   // @{ Initializations, timing and flops
00293   bool IsInitialized_;
00295   bool IsComputed_;
00297   int NumInitialize_;
00299   int NumCompute_;
00301   mutable int NumApplyInverse_;
00303   double InitializeTime_;
00305   double ComputeTime_;
00307   mutable double ApplyInverseTime_;
00309   double ComputeFlops_;
00311   mutable double ApplyInverseFlops_;
00312   // @}
00313 
00314   // @{ Settings
00316   int Iterations_;
00318   double Tolerance_;
00320   int SolverType_;
00322   int PreconditionerType_;
00324   int NumSweeps_;
00326   int BlockSize_;
00328   double DampingParameter_;
00330   bool UseTranspose_;
00332   double Condest_;
00334   bool ComputeCondest_;
00336   string Label_;
00337 
00338   // @{ Other data
00340   int NumMyRows_;
00342   int NumMyNonzeros_;
00344   long long NumGlobalRows_;
00346   long long NumGlobalNonzeros_;
00348   Teuchos::RefCountPtr<Epetra_Operator> Operator_;
00350   Teuchos::RefCountPtr<Epetra_RowMatrix> Matrix_;
00351 
00353   bool IsRowMatrix_;
00355   Teuchos::RefCountPtr<Epetra_Time> Time_;
00357   bool ZeroStartingSolution_;
00358 
00359   // Aztec solver
00360 #ifdef HAVE_IFPACK_AZTECOO
00361   Teuchos::RCP<AztecOO> AztecSolver_;
00362 #endif
00363 
00364   // Inner preconditioner
00365   Teuchos::RCP<Ifpack_Preconditioner> IfpackPrec_;
00366 
00367 };
00368 
00369 
00370 #endif // IFPACK_KRYLOV_H
 All Classes Files Functions Variables Enumerations Friends