Ifpack2 Templated Preconditioning Package Version 1.0
Ifpack2_RILUK_decl.hpp
00001 /*@HEADER
00002 // ***********************************************************************
00003 //
00004 //       Ifpack2: 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 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00025 //
00026 // ***********************************************************************
00027 //@HEADER
00028 */
00029 
00030 #ifndef IFPACK2_CRSRILUK_DECL_HPP
00031 #define IFPACK2_CRSRILUK_DECL_HPP
00032 
00033 #include "Ifpack2_ConfigDefs.hpp"
00034 #include "Ifpack2_ScalingType.hpp"
00035 #include "Ifpack2_IlukGraph.hpp"
00036 #include "Ifpack2_Preconditioner.hpp"
00037 #include "Tpetra_CrsMatrix.hpp"
00038 #include "Tpetra_MultiVector.hpp"
00039 
00040 #include "Teuchos_RefCountPtr.hpp"
00041 
00042 namespace Teuchos {
00043   class ParameterList;
00044 }
00045 
00046 namespace Ifpack2 {
00047 
00200 template<class MatrixType>
00201 class RILUK: public virtual Ifpack2::Preconditioner<typename MatrixType::scalar_type,typename MatrixType::local_ordinal_type,typename MatrixType::global_ordinal_type,typename MatrixType::node_type> {
00202 
00203  public:
00205   typedef typename MatrixType::scalar_type scalar_type;
00206 
00208   TEUCHOS_DEPRECATED typedef typename MatrixType::scalar_type Scalar;
00209 
00210 
00212   typedef typename MatrixType::local_ordinal_type local_ordinal_type;
00213 
00215   TEUCHOS_DEPRECATED typedef typename MatrixType::local_ordinal_type LocalOrdinal;
00216 
00217 
00219   typedef typename MatrixType::global_ordinal_type global_ordinal_type;
00220 
00222   TEUCHOS_DEPRECATED typedef typename MatrixType::global_ordinal_type GlobalOrdinal;
00223 
00224 
00226   typedef typename MatrixType::node_type node_type;
00227 
00229   TEUCHOS_DEPRECATED typedef typename MatrixType::node_type Node;
00230 
00231 
00233   typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
00234 
00236   TEUCHOS_DEPRECATED typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitudeType;
00237 
00239 
00244   RILUK(const Teuchos::RCP<const MatrixType>& A_in);
00245 
00246  private:
00248   RILUK(const RILUK<MatrixType> & src);
00249 
00250  public:
00252   virtual ~RILUK();
00253 
00255   void SetRelaxValue( magnitude_type RelaxValue) {RelaxValue_ = RelaxValue;}
00256 
00258   void SetAbsoluteThreshold( magnitude_type Athresh) {Athresh_ = Athresh;}
00259 
00261   void SetRelativeThreshold( magnitude_type Rthresh) {Rthresh_ = Rthresh;}
00262 
00264   void SetOverlapMode( Tpetra::CombineMode OverlapMode) {OverlapMode_ = OverlapMode;}
00265 
00277   void setParameters(const Teuchos::ParameterList& params);
00278 
00280   void initialize();
00281 
00283   bool isInitialized() const {return isInitialized_;}
00284 
00286   int getNumInitialize() const {return numInitialize_;}
00287 
00296   void compute();
00297 
00299   bool isComputed() const {return(Factored_);}
00300 
00302   int getNumCompute() const {return numCompute_;}
00303 
00305   int getNumApply() const {return numApply_;}
00306 
00307   double getInitializeTime() const {return -1;}
00308   double getComputeTime() const {return -1;}
00309   double getApplyTime() const {return -1;}
00310 
00311   // Mathematical functions.
00312 
00331   void apply(
00332       const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
00333             Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
00334             Teuchos::ETransp mode = Teuchos::NO_TRANS,
00335                scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
00336                scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
00337 
00338 
00353   int Multiply(const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
00354                      Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
00355                Teuchos::ETransp mode = Teuchos::NO_TRANS) const;
00356 
00358 
00366   magnitude_type computeCondEst(Teuchos::ETransp mode) const;
00367   magnitude_type computeCondEst(CondestType CT = Ifpack2::Cheap,
00368                                local_ordinal_type MaxIters = 1550,
00369                                magnitude_type Tol = 1e-9,
00370                                const Teuchos::Ptr<const Tpetra::RowMatrix<scalar_type,local_ordinal_type,global_ordinal_type,node_type> > &Matrix = Teuchos::null)
00371   {
00372     std::cerr << "Warning, Ifpack2::RILUK::computeCondEst currently does not use MaxIters/Tol/etc arguments..." << std::endl;
00373     return computeCondEst(Teuchos::NO_TRANS);
00374   }
00375 
00376   magnitude_type getCondEst() const {return Condest_;}
00377 
00378   Teuchos::RCP<const Tpetra::RowMatrix<scalar_type,local_ordinal_type,global_ordinal_type,node_type> > getMatrix() const
00379   {
00380     return A_;
00381   }
00382 
00383   // Attribute access functions
00384 
00386   magnitude_type GetRelaxValue() const {return RelaxValue_;}
00387 
00389   magnitude_type getAbsoluteThreshold() const {return Athresh_;}
00390 
00392   magnitude_type getRelativeThreshold() const {return Rthresh_;}
00393 
00394   int getLevelOfFill() const { return LevelOfFill_; }
00395 
00397   Tpetra::CombineMode getOverlapMode() {return OverlapMode_;}
00398 
00400   int getGlobalNumEntries() const {return(getL().getGlobalNumEntries()+getU().getGlobalNumEntries());}
00401 
00403   const Teuchos::RCP<Ifpack2::IlukGraph<local_ordinal_type,global_ordinal_type,node_type> >& getGraph() const {return(Graph_);}
00404 
00406   const MatrixType& getL() const {return(*L_);}
00407 
00409   const Tpetra::Vector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> & getD() const {return(*D_);}
00410 
00412   const MatrixType& getU() const {return(*U_);}
00413 
00415 
00417   const Teuchos::RCP<const Tpetra::Map<local_ordinal_type,global_ordinal_type,node_type> >& getDomainMap() const
00418   { return Graph_->getL_Graph()->getDomainMap(); }
00419 
00421   const Teuchos::RCP<const Tpetra::Map<local_ordinal_type,global_ordinal_type,node_type> >& getRangeMap() const
00422   { return Graph_->getU_Graph()->getRangeMap(); }
00423 
00425 
00426  protected:
00427   void setFactored(bool Flag) {Factored_ = Flag;}
00428   void setInitialized(bool Flag) {isInitialized_ = Flag;}
00429   bool isAllocated() const {return(isAllocated_);}
00430   void setAllocated(bool Flag) {isAllocated_ = Flag;}
00431 
00432  private:
00433 
00434 
00435   void allocate_L_and_U();
00436   void initAllValues(const Tpetra::RowMatrix<scalar_type,local_ordinal_type,global_ordinal_type,node_type> & overlapA);
00437   void generateXY(Teuchos::ETransp mode,
00438                  const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Xin,
00439      const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Yin,
00440      Teuchos::RCP<const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> >& Xout,
00441      Teuchos::RCP<Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> >& Yout) const;
00442   bool isOverlapped_;
00443   Teuchos::RCP<Ifpack2::IlukGraph<local_ordinal_type,global_ordinal_type,node_type> > Graph_;
00444   const Teuchos::RCP<const MatrixType> A_;
00445   Teuchos::RCP<MatrixType> L_;
00446   Teuchos::RCP<MatrixType> U_;
00447   Teuchos::RCP<Tpetra::Vector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> > D_;
00448   bool UseTranspose_;
00449 
00450   int LevelOfFill_;
00451   int LevelOfOverlap_;
00452 
00453   int NumMyDiagonals_;
00454   bool isAllocated_;
00455   bool isInitialized_;
00456   mutable int numInitialize_;
00457   mutable int numCompute_;
00458   mutable int numApply_;
00459   bool Factored_;
00460   magnitude_type RelaxValue_;
00461   magnitude_type Athresh_;
00462   magnitude_type Rthresh_;
00463   mutable magnitude_type Condest_;
00464 
00465   mutable Teuchos::RCP<Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> > OverlapX_;
00466   mutable Teuchos::RCP<Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> > OverlapY_;
00467   Tpetra::CombineMode OverlapMode_;
00468 };
00469 
00470 }//namespace Ifpack2
00471 
00472 #endif /* IFPACK2_CRSRILUK_DECL_HPP */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends