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 
00049 
00181 template<class MatrixType>
00182 class RILUK: public virtual Ifpack2::Preconditioner<typename MatrixType::scalar_type,typename MatrixType::local_ordinal_type,typename MatrixType::global_ordinal_type,typename MatrixType::node_type> {
00183       
00184  public:
00185   typedef typename MatrixType::scalar_type Scalar;
00186   typedef typename MatrixType::local_ordinal_type LocalOrdinal;
00187   typedef typename MatrixType::global_ordinal_type GlobalOrdinal;
00188   typedef typename MatrixType::node_type Node;
00189   typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType magnitudeType;
00190 
00192 
00197   RILUK(const Teuchos::RCP<const MatrixType>& A_in);
00198   
00199  private:
00201   RILUK(const RILUK<MatrixType> & src);
00202 
00203  public:
00205   virtual ~RILUK();
00206 
00208   void SetRelaxValue( magnitudeType RelaxValue) {RelaxValue_ = RelaxValue;}
00209 
00211   void SetAbsoluteThreshold( magnitudeType Athresh) {Athresh_ = Athresh;}
00212 
00214   void SetRelativeThreshold( magnitudeType Rthresh) {Rthresh_ = Rthresh;}
00215 
00217   void SetOverlapMode( Tpetra::CombineMode OverlapMode) {OverlapMode_ = OverlapMode;}
00218 
00220 
00230   void setParameters(const Teuchos::ParameterList& parameterlist);
00231 
00232   void initialize();
00233   bool isInitialized() const {return isInitialized_;}
00234   int getNumInitialize() const {return numInitialize_;}
00235 
00237 
00245   void compute();
00246 
00248   bool isComputed() const {return(Factored_);}
00249   
00250   int getNumCompute() const {return numCompute_;}
00251   int getNumApply() const {return numApply_;}
00252 
00253   double getInitializeTime() const {return -1;}
00254   double getComputeTime() const {return -1;}
00255   double getApplyTime() const {return -1;}
00256 
00257   // Mathematical functions.
00258   
00259   
00261 
00271   void apply(
00272       const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& X,
00273             Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& Y,
00274             Teuchos::ETransp mode = Teuchos::NO_TRANS,
00275                Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
00276                Scalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const;
00277 
00278 
00280 
00290   int Multiply(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& X,
00291                      Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& Y,
00292                Teuchos::ETransp mode = Teuchos::NO_TRANS) const;
00293 
00295 
00303   magnitudeType computeCondEst(Teuchos::ETransp mode) const;
00304   magnitudeType computeCondEst(CondestType CT = Ifpack2::Cheap,
00305                                LocalOrdinal MaxIters = 1550,
00306                                magnitudeType Tol = 1e-9,
00307                                const Teuchos::Ptr<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &Matrix = Teuchos::null)
00308   {
00309     std::cerr << "Warning, Ifpack2::RILUK::computeCondEst currently does not use MaxIters/Tol/etc arguments..." << std::endl;
00310     return computeCondEst(Teuchos::NO_TRANS);
00311   }
00312 
00313   magnitudeType getCondEst() const {return Condest_;}
00314 
00315   Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > getMatrix() const
00316   {
00317     return A_;
00318   }
00319 
00320   // Attribute access functions
00321   
00323   magnitudeType GetRelaxValue() const {return RelaxValue_;}
00324 
00326   magnitudeType getAbsoluteThreshold() const {return Athresh_;}
00327 
00329   magnitudeType getRelativeThreshold() const {return Rthresh_;}
00330 
00331   int getLevelOfFill() const { return LevelOfFill_; }
00332 
00334   Tpetra::CombineMode getOverlapMode() {return OverlapMode_;}
00335  
00337   int getGlobalNumEntries() const {return(getL().getGlobalNumEntries()+getU().getGlobalNumEntries());}
00338  
00340   const Teuchos::RCP<Ifpack2::IlukGraph<LocalOrdinal,GlobalOrdinal,Node> >& getGraph() const {return(Graph_);}
00341 
00343   const MatrixType& getL() const {return(*L_);}
00344     
00346   const Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> & getD() const {return(*D_);}
00347 
00349   const MatrixType& getU() const {return(*U_);}
00350 
00352 
00354   const Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >& getDomainMap() const
00355   { return Graph_->getL_Graph()->getDomainMap(); }
00356 
00358   const Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >& getRangeMap() const
00359   { return Graph_->getU_Graph()->getRangeMap(); }
00360 
00362 
00363  protected:
00364   void setFactored(bool Flag) {Factored_ = Flag;}
00365   void setInitialized(bool Flag) {isInitialized_ = Flag;}
00366   bool isAllocated() const {return(isAllocated_);}
00367   void setAllocated(bool Flag) {isAllocated_ = Flag;}
00368   
00369  private:
00370   
00371   
00372   void allocate_L_and_U();
00373   void initAllValues(const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> & overlapA);
00374   void generateXY(Teuchos::ETransp mode, 
00375      const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& Xin,
00376      const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& Yin,
00377      Teuchos::RCP<const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >& Xout, 
00378      Teuchos::RCP<Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >& Yout) const;
00379   bool isOverlapped_;
00380   Teuchos::RCP<Ifpack2::IlukGraph<LocalOrdinal,GlobalOrdinal,Node> > Graph_;
00381   const Teuchos::RCP<const MatrixType> A_;
00382   Teuchos::RCP<MatrixType> L_;
00383   Teuchos::RCP<MatrixType> U_;
00384   Teuchos::RCP<Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > D_;
00385   bool UseTranspose_;
00386 
00387   int LevelOfFill_;
00388   int LevelOfOverlap_;
00389 
00390   int NumMyDiagonals_;
00391   bool isAllocated_;
00392   bool isInitialized_;
00393   mutable int numInitialize_;
00394   mutable int numCompute_;
00395   mutable int numApply_;
00396   bool Factored_;
00397   magnitudeType RelaxValue_;
00398   magnitudeType Athresh_;
00399   magnitudeType Rthresh_;
00400   mutable magnitudeType Condest_;
00401 
00402   mutable Teuchos::RCP<Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > OverlapX_;
00403   mutable Teuchos::RCP<Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > OverlapY_;
00404   Tpetra::CombineMode OverlapMode_;
00405 };
00406 
00407 }//namespace Ifpack2
00408 
00409 #endif /* IFPACK2_CRSRILUK_DECL_HPP */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends