Ifpack2 Templated Preconditioning Package  Version 1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
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 // 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 IFPACK2_ADDITIVESCHWARZ_DECL_HPP
00044 #define IFPACK2_ADDITIVESCHWARZ_DECL_HPP
00045 
00046 #include "Ifpack2_ConfigDefs.hpp"
00047 #include "Ifpack2_Preconditioner.hpp"
00048 #include "Tpetra_CrsMatrix.hpp"
00049 #include "Tpetra_MultiVector.hpp"
00050 #include "Tpetra_Map.hpp"
00051 
00052 #include "Ifpack2_LocalFilter_decl.hpp"
00053 #include "Ifpack2_OverlappingRowMatrix_decl.hpp"
00054 #include "Ifpack2_ReorderFilter_decl.hpp"
00055 #include "Ifpack2_SingletonFilter_decl.hpp"
00056 
00057 #include "Ifpack2_Details_CanChangeMatrix.hpp"
00058 #include "Ifpack2_Details_NestedPreconditioner.hpp"
00059 
00060 
00061 namespace Ifpack2 {
00062 
00274 template<class MatrixType,
00275          class LocalInverseType =
00276          Preconditioner<typename MatrixType::scalar_type,
00277                         typename MatrixType::local_ordinal_type,
00278                         typename MatrixType::global_ordinal_type,
00279                         typename MatrixType::node_type> >
00280 class AdditiveSchwarz :
00281     virtual public Preconditioner<typename MatrixType::scalar_type,
00282                                   typename MatrixType::local_ordinal_type,
00283                                   typename MatrixType::global_ordinal_type,
00284                                   typename MatrixType::node_type>,
00285     virtual public Details::CanChangeMatrix<Tpetra::RowMatrix<typename MatrixType::scalar_type,
00286                                                               typename MatrixType::local_ordinal_type,
00287                                                               typename MatrixType::global_ordinal_type,
00288                                                               typename MatrixType::node_type> >,
00289     virtual public Details::NestedPreconditioner<Preconditioner<typename MatrixType::scalar_type,
00290                                                                 typename MatrixType::local_ordinal_type,
00291                                                                 typename MatrixType::global_ordinal_type,
00292                                                                 typename MatrixType::node_type> >
00293 {
00294 public:
00296 
00297 
00299   typedef typename MatrixType::scalar_type scalar_type;
00300 
00302   typedef typename MatrixType::local_ordinal_type local_ordinal_type;
00303 
00305   typedef typename MatrixType::global_ordinal_type global_ordinal_type;
00306 
00308   typedef typename MatrixType::node_type node_type;
00309 
00311   typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
00312 
00319   typedef Tpetra::RowMatrix<scalar_type,
00320                             local_ordinal_type,
00321                             global_ordinal_type,
00322                             node_type> row_matrix_type;
00323 
00325   // \name Deprecated typedefs
00327 
00329   TEUCHOS_DEPRECATED typedef typename MatrixType::scalar_type         Scalar;
00330 
00332   TEUCHOS_DEPRECATED typedef typename MatrixType::local_ordinal_type  LocalOrdinal;
00333 
00335   TEUCHOS_DEPRECATED typedef typename MatrixType::global_ordinal_type GlobalOrdinal;
00336 
00338   TEUCHOS_DEPRECATED typedef typename MatrixType::node_type           Node;
00339 
00341   TEUCHOS_DEPRECATED typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitudeType;
00342 
00344   TEUCHOS_DEPRECATED typedef typename Tpetra::RowMatrix<scalar_type,local_ordinal_type,global_ordinal_type,node_type>  LocalMatrixType;
00345 
00347   // \name Constructors and destructor
00349 
00353   AdditiveSchwarz (const Teuchos::RCP<const row_matrix_type>& A);
00354 
00364   AdditiveSchwarz (const Teuchos::RCP<const row_matrix_type>& A,
00365                    const int overlapLevel);
00366 
00368   virtual ~AdditiveSchwarz();
00369 
00371 
00372 
00373 
00375   virtual Teuchos::RCP<const Tpetra::Map<local_ordinal_type,global_ordinal_type,node_type> > getDomainMap() const;
00376 
00378   virtual Teuchos::RCP<const Tpetra::Map<local_ordinal_type,global_ordinal_type,node_type> > getRangeMap() const;
00379 
00381   virtual void
00382   apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &X,
00383          Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &Y,
00384          Teuchos::ETransp mode = Teuchos::NO_TRANS,
00385          scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
00386          scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
00387 
00389 
00390 
00391 
00426   virtual void
00427   setInnerPreconditioner (const Teuchos::RCP<Preconditioner<scalar_type,
00428                                                             local_ordinal_type,
00429                                                             global_ordinal_type,
00430                                                             node_type> >& innerPrec);
00431 
00433 
00434 
00435 
00458   virtual void
00459   setMatrix (const Teuchos::RCP<const row_matrix_type>& A);
00461 
00463   virtual Teuchos::RCP<const row_matrix_type> getMatrix() const;
00464 
00612 
00613 
00639   virtual void setParameters (const Teuchos::ParameterList& plist);
00640 
00664   void
00665   setParameterList (const Teuchos::RCP<Teuchos::ParameterList>& plist);
00666 
00671   Teuchos::RCP<const Teuchos::ParameterList> getValidParameters () const;
00672 
00674   virtual void initialize();
00675 
00677   virtual bool isInitialized() const;
00678 
00680   virtual void compute();
00681 
00683   virtual bool isComputed() const;
00684 
00694   virtual magnitude_type TEUCHOS_DEPRECATED
00695   computeCondEst (CondestType CT = Ifpack2::Cheap,
00696                   local_ordinal_type MaxIters = 1550,
00697                   magnitude_type Tol = 1e-9,
00698                   const Teuchos::Ptr<const row_matrix_type> &Matrix = Teuchos::null);
00699 
00703   virtual magnitude_type TEUCHOS_DEPRECATED getCondEst() const;
00704 
00706   virtual int getNumInitialize() const;
00707 
00709   virtual int getNumCompute() const;
00710 
00712   virtual int getNumApply() const;
00713 
00715   virtual double getInitializeTime() const;
00716 
00718   virtual double getComputeTime() const;
00719 
00721   virtual double getApplyTime() const;
00722 
00724 
00725 
00727   std::string description() const;
00728 
00730   void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const;
00731 
00733 
00735   virtual std::ostream& print(std::ostream& os) const;
00736 
00738   virtual int getOverlapLevel() const;
00739 
00740 
00741 private:
00743   typedef Tpetra::Map<local_ordinal_type,
00744                       global_ordinal_type,
00745                       node_type> map_type;
00747   typedef Tpetra::Import<local_ordinal_type,
00748                          global_ordinal_type,
00749                          node_type> import_type;
00751   typedef Tpetra::MultiVector<scalar_type,
00752                               local_ordinal_type,
00753                               global_ordinal_type,
00754                               node_type> MV;
00756   typedef Preconditioner<scalar_type,
00757                          local_ordinal_type,
00758                          global_ordinal_type,
00759                          node_type> prec_type;
00760 
00762   AdditiveSchwarz (const AdditiveSchwarz& RHS);
00763 
00765   void setup ();
00766 
00769   bool hasInnerPrecName () const;
00770 
00771 
00772   // mfh 28 Jan 2014: Re-enable in next commit to Ifpack2_AdditiveSchwarz_def.hpp.
00773 #if 0
00774 
00775 
00776 
00777 
00778 
00779 
00780 
00781 
00782 
00783 
00784 
00785 
00786 
00787 
00788 
00789 
00790 
00791 
00792 
00793 
00794 
00795 
00796 
00797 
00798 
00799 
00800 
00801 
00802 
00803 
00804   bool isCustomPrecName (const std::string& prec) const;
00805 #endif // 0
00806 
00808   std::string innerPrecName () const;
00809 
00812   void removeInnerPrecName ();
00813 
00819   std::pair<Teuchos::ParameterList, bool> innerPrecParams () const;
00820 
00823   void removeInnerPrecParams ();
00824 
00826   static std::string defaultInnerPrecName ();
00827 
00831   Teuchos::RCP<const row_matrix_type> Matrix_;
00832 
00834   Teuchos::RCP<OverlappingRowMatrix<row_matrix_type> > OverlappingMatrix_;
00835 
00837   Teuchos::RCP<ReorderFilter<row_matrix_type> > ReorderedLocalizedMatrix_;
00838 
00840   Teuchos::RCP<row_matrix_type> innerMatrix_;
00841 
00843   bool IsInitialized_;
00845   bool IsComputed_;
00847   bool IsOverlapping_;
00849   int OverlapLevel_;
00850 
00856   Teuchos::ParameterList List_;
00857 
00859   mutable Teuchos::RCP<const Teuchos::ParameterList> validParams_;
00860 
00862   Tpetra::CombineMode CombineMode_;
00864   magnitude_type Condest_;
00866   bool ComputeCondest_;
00868   bool UseReordering_;
00870   std::string ReorderingAlgorithm_;
00872   bool UseSubdomain_;
00874   bool FilterSingletons_;
00876   Teuchos::RCP<SingletonFilter<row_matrix_type> > SingletonMatrix_;
00877 
00879   int NumInitialize_;
00881   int NumCompute_;
00883   mutable int NumApply_;
00885   double InitializeTime_;
00887   double ComputeTime_;
00889   mutable double ApplyTime_;
00891   double InitializeFlops_;
00893   double ComputeFlops_;
00895   mutable double ApplyFlops_;
00897   Teuchos::RCP<prec_type> Inverse_;
00899   Teuchos::RCP<const map_type> localMap_;
00900 
00907   mutable Teuchos::RCP<const import_type> DistributedImporter_;
00908 }; // class AdditiveSchwarz
00909 
00910 }// end namespace
00911 
00912 #endif // IFPACK2_ADDITIVESCHWARZ_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends