Ifpack2 Templated Preconditioning Package Version 1.0
Ifpack2_AdditiveSchwarz_decl.hpp
00001 //@HEADER
00002 // ***********************************************************************
00003 // 
00004 //       Ifpack2: Tempated Object-Oriented Algebraic Preconditioner Package
00005 //                 Copyright (2009) 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 #ifndef IFPACK2_ADDITIVESCHWARZ_DECL_HPP
00030 #define IFPACK2_ADDITIVESCHWARZ_DECL_HPP
00031 
00032 #include "Ifpack2_ConfigDefs.hpp"
00033 #include "Tpetra_ConfigDefs.hpp"
00034 #include "Ifpack2_Preconditioner.hpp"
00035 #include "Teuchos_ParameterList.hpp"
00036 #include "Teuchos_RefCountPtr.hpp"
00037 #include "Teuchos_Time.hpp"
00038 
00039 #include "Tpetra_MultiVector.hpp"
00040 #include "Tpetra_Map.hpp"
00041 #include "Tpetra_CrsMatrix.hpp"
00042 
00043 #include "Ifpack2_ReorderFilter.hpp"
00044 #include "Ifpack2_SingletonFilter.hpp"
00045 #include "Ifpack2_OverlappingRowMatrix.hpp"
00046 
00047 #ifdef HAVE_IFPACK2_ZOLTAN2
00048 #include "Zoltan2_OrderingSolution.hpp"
00049 #endif
00050 
00051 
00052 namespace Ifpack2 {
00053 
00107 template<class MatrixType,class LocalInverseType>
00108 class AdditiveSchwarz : virtual public Ifpack2::Preconditioner<typename MatrixType::scalar_type,typename MatrixType::local_ordinal_type,typename MatrixType::global_ordinal_type,typename MatrixType::node_type> {
00109       
00110 public:
00111   typedef typename MatrixType::scalar_type         Scalar;
00112   typedef typename MatrixType::local_ordinal_type  LocalOrdinal;
00113   typedef typename MatrixType::global_ordinal_type GlobalOrdinal;
00114   typedef typename MatrixType::node_type           Node;
00115   typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType magnitudeType;
00116   typedef typename Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node>  LocalMatrixType;
00117 
00119 
00120 
00131   AdditiveSchwarz(const Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > & Matrix_in, int OverlapLevel_in = 0);
00132   
00134   virtual ~AdditiveSchwarz();
00136 
00139   
00141   virtual const Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > & getDomainMap() const;
00142   
00144   virtual const Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > & getRangeMap() const;
00145   
00147   virtual Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > getMatrix() const;
00148 
00149 
00150 
00152   virtual void apply(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &X, 
00153          Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &Y, 
00154          Teuchos::ETransp mode = Teuchos::NO_TRANS,
00155          Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
00156          Scalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const;
00157   
00159   
00161   virtual void setParameters(const Teuchos::ParameterList& List);
00162   
00164   virtual void initialize();
00165   
00167   virtual bool isInitialized() const;
00168   
00170   virtual void compute();
00171   
00173   virtual bool isComputed() const;
00174   
00176   virtual magnitudeType computeCondEst(CondestType CT = Ifpack2::Cheap,
00177                LocalOrdinal MaxIters = 1550,
00178                magnitudeType Tol = 1e-9,
00179                const Teuchos::Ptr<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &Matrix = Teuchos::null);
00180   
00182   virtual magnitudeType getCondEst() const;
00183   
00185   virtual int getNumInitialize() const;
00186   
00188   virtual int getNumCompute() const;
00189   
00191   virtual int getNumApply() const;
00192   
00194   virtual double getInitializeTime() const;
00195   
00197   virtual double getComputeTime() const;
00198 
00200   virtual double getApplyTime() const;
00201 
00203 
00204 
00206   std::string description() const;
00207 
00209   void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const;
00210 
00212 
00214   virtual std::ostream& print(std::ostream& os) const;
00215 
00217   virtual int getOverlapLevel() const;
00218 
00219 protected:
00220 
00221   // @}
00222 
00223   // @{ Internal merhods.
00224   
00226   AdditiveSchwarz(const AdditiveSchwarz& RHS);
00227 
00229   void setup();
00230   
00231   // @}
00232 
00233   // @{ Internal data.  
00235   const Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > Matrix_;
00236 
00238   Teuchos::RCP<Ifpack2::OverlappingRowMatrix<LocalMatrixType> >OverlappingMatrix_;
00239 
00241   // CMS: Probably not a great idea, but this will remove the Local/Subdomain conflict here
00242   Teuchos::RCP<LocalMatrixType > LocalizedMatrix_;
00244   Teuchos::RCP<Ifpack2::ReorderFilter<LocalMatrixType> > ReorderedLocalizedMatrix_;
00245 
00247   bool IsInitialized_;
00249   bool IsComputed_;
00251   bool IsOverlapping_;
00253   int OverlapLevel_;
00255   Teuchos::ParameterList List_;
00257   Tpetra::CombineMode CombineMode_;
00259   magnitudeType Condest_;
00261   bool ComputeCondest_;
00263   bool UseReordering_;
00265   bool UseSubdomain_;
00266 
00268   bool FilterSingletons_;
00270   Teuchos::RCP<Ifpack2::SingletonFilter<LocalMatrixType> > SingletonMatrix_;
00272   int NumInitialize_;
00274   int NumCompute_;
00276   mutable int NumApply_;
00278   double InitializeTime_;
00280   double ComputeTime_;
00282   mutable double ApplyTime_;
00284   double InitializeFlops_;
00286   double ComputeFlops_;
00288   mutable double ApplyFlops_;
00290   Teuchos::RCP<Teuchos::Time> Time_;
00292   Teuchos::RCP<LocalInverseType> Inverse_;
00293 
00294 }; // class AdditiveSchwarz
00295 
00296 }// end namespace
00297 
00298 #endif // IFPACK2_ADDITIVESCHWARZ_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends