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 // 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 
00264 template<class MatrixType,
00265          class LocalInverseType =
00266          Preconditioner<typename MatrixType::scalar_type,
00267                         typename MatrixType::local_ordinal_type,
00268                         typename MatrixType::global_ordinal_type,
00269                         typename MatrixType::node_type> >
00270 class AdditiveSchwarz :
00271     virtual public Preconditioner<typename MatrixType::scalar_type,
00272                                   typename MatrixType::local_ordinal_type,
00273                                   typename MatrixType::global_ordinal_type,
00274                                   typename MatrixType::node_type>,
00275     virtual public Details::CanChangeMatrix<Tpetra::RowMatrix<typename MatrixType::scalar_type,
00276                                                               typename MatrixType::local_ordinal_type,
00277                                                               typename MatrixType::global_ordinal_type,
00278                                                               typename MatrixType::node_type> >,
00279     virtual public Details::NestedPreconditioner<Preconditioner<typename MatrixType::scalar_type,
00280                                                                 typename MatrixType::local_ordinal_type,
00281                                                                 typename MatrixType::global_ordinal_type,
00282                                                                 typename MatrixType::node_type> >
00283 {
00284 public:
00286 
00287 
00289   typedef typename MatrixType::scalar_type scalar_type;
00290 
00292   typedef typename MatrixType::local_ordinal_type local_ordinal_type;
00293 
00295   typedef typename MatrixType::global_ordinal_type global_ordinal_type;
00296 
00298   typedef typename MatrixType::node_type node_type;
00299 
00301   typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
00302 
00309   typedef Tpetra::RowMatrix<scalar_type,
00310                             local_ordinal_type,
00311                             global_ordinal_type,
00312                             node_type> row_matrix_type;
00313 
00315   // \name Deprecated typedefs
00317 
00319   TEUCHOS_DEPRECATED typedef typename MatrixType::scalar_type         Scalar;
00320 
00322   TEUCHOS_DEPRECATED typedef typename MatrixType::local_ordinal_type  LocalOrdinal;
00323 
00325   TEUCHOS_DEPRECATED typedef typename MatrixType::global_ordinal_type GlobalOrdinal;
00326 
00328   TEUCHOS_DEPRECATED typedef typename MatrixType::node_type           Node;
00329 
00331   TEUCHOS_DEPRECATED typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitudeType;
00332 
00334   TEUCHOS_DEPRECATED typedef typename Tpetra::RowMatrix<scalar_type,local_ordinal_type,global_ordinal_type,node_type>  LocalMatrixType;
00335 
00337   // \name Constructors and destructor
00339 
00343   AdditiveSchwarz (const Teuchos::RCP<const row_matrix_type>& A);
00344 
00354   AdditiveSchwarz (const Teuchos::RCP<const row_matrix_type>& A,
00355                    const int overlapLevel);
00356 
00358   virtual ~AdditiveSchwarz();
00359 
00361 
00362 
00363 
00365   virtual Teuchos::RCP<const Tpetra::Map<local_ordinal_type,global_ordinal_type,node_type> > getDomainMap() const;
00366 
00368   virtual Teuchos::RCP<const Tpetra::Map<local_ordinal_type,global_ordinal_type,node_type> > getRangeMap() const;
00369 
00371   virtual void
00372   apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &X,
00373          Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &Y,
00374          Teuchos::ETransp mode = Teuchos::NO_TRANS,
00375          scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
00376          scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
00377 
00379 
00380 
00381 
00416   virtual void
00417   setInnerPreconditioner (const Teuchos::RCP<Preconditioner<scalar_type,
00418                                                             local_ordinal_type,
00419                                                             global_ordinal_type,
00420                                                             node_type> >& innerPrec);
00421 
00423 
00424 
00425 
00448   virtual void
00449   setMatrix (const Teuchos::RCP<const row_matrix_type>& A);
00451 
00453   virtual Teuchos::RCP<const row_matrix_type> getMatrix() const;
00454 
00602 
00603 
00629   virtual void setParameters (const Teuchos::ParameterList& plist);
00630 
00654   void
00655   setParameterList (const Teuchos::RCP<Teuchos::ParameterList>& plist);
00656 
00661   Teuchos::RCP<const Teuchos::ParameterList> getValidParameters () const;
00662 
00664   virtual void initialize();
00665 
00667   virtual bool isInitialized() const;
00668 
00670   virtual void compute();
00671 
00673   virtual bool isComputed() const;
00674 
00684   virtual magnitude_type TEUCHOS_DEPRECATED
00685   computeCondEst (CondestType CT = Ifpack2::Cheap,
00686                   local_ordinal_type MaxIters = 1550,
00687                   magnitude_type Tol = 1e-9,
00688                   const Teuchos::Ptr<const row_matrix_type> &Matrix = Teuchos::null);
00689 
00693   virtual magnitude_type TEUCHOS_DEPRECATED getCondEst() const;
00694 
00696   virtual int getNumInitialize() const;
00697 
00699   virtual int getNumCompute() const;
00700 
00702   virtual int getNumApply() const;
00703 
00705   virtual double getInitializeTime() const;
00706 
00708   virtual double getComputeTime() const;
00709 
00711   virtual double getApplyTime() const;
00712 
00714 
00715 
00717   std::string description() const;
00718 
00720   void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const;
00721 
00723 
00725   virtual std::ostream& print(std::ostream& os) const;
00726 
00728   virtual int getOverlapLevel() const;
00729 
00730 
00731 private:
00733   typedef Tpetra::Map<local_ordinal_type,
00734                       global_ordinal_type,
00735                       node_type> map_type;
00737   typedef Tpetra::Import<local_ordinal_type,
00738                          global_ordinal_type,
00739                          node_type> import_type;
00741   typedef Tpetra::MultiVector<scalar_type,
00742                               local_ordinal_type,
00743                               global_ordinal_type,
00744                               node_type> MV;
00746   typedef Preconditioner<scalar_type,
00747                          local_ordinal_type,
00748                          global_ordinal_type,
00749                          node_type> prec_type;
00750 
00752   AdditiveSchwarz (const AdditiveSchwarz& RHS);
00753 
00755   void setup ();
00756 
00759   bool hasInnerPrecName () const;
00760 
00761 
00762   // mfh 28 Jan 2014: Re-enable in next commit to Ifpack2_AdditiveSchwarz_def.hpp.
00763 #if 0
00764 
00765 
00766 
00767 
00768 
00769 
00770 
00771 
00772 
00773 
00774 
00775 
00776 
00777 
00778 
00779 
00780 
00781 
00782 
00783 
00784 
00785 
00786 
00787 
00788 
00789 
00790 
00791 
00792 
00793 
00794   bool isCustomPrecName (const std::string& prec) const;
00795 #endif // 0
00796 
00798   std::string innerPrecName () const;
00799 
00802   void removeInnerPrecName ();
00803 
00809   std::pair<Teuchos::ParameterList, bool> innerPrecParams () const;
00810 
00813   void removeInnerPrecParams ();
00814 
00816   static std::string defaultInnerPrecName ();
00817 
00821   Teuchos::RCP<const row_matrix_type> Matrix_;
00822 
00824   Teuchos::RCP<OverlappingRowMatrix<row_matrix_type> > OverlappingMatrix_;
00825 
00827   Teuchos::RCP<ReorderFilter<row_matrix_type> > ReorderedLocalizedMatrix_;
00828 
00830   Teuchos::RCP<row_matrix_type> innerMatrix_;
00831 
00833   bool IsInitialized_;
00835   bool IsComputed_;
00837   bool IsOverlapping_;
00839   int OverlapLevel_;
00840 
00846   Teuchos::ParameterList List_;
00847 
00849   mutable Teuchos::RCP<const Teuchos::ParameterList> validParams_;
00850 
00852   Tpetra::CombineMode CombineMode_;
00854   magnitude_type Condest_;
00856   bool ComputeCondest_;
00858   bool UseReordering_;
00860   std::string ReorderingAlgorithm_;
00862   bool UseSubdomain_;
00864   bool FilterSingletons_;
00866   Teuchos::RCP<SingletonFilter<row_matrix_type> > SingletonMatrix_;
00867 
00869   int NumInitialize_;
00871   int NumCompute_;
00873   mutable int NumApply_;
00875   double InitializeTime_;
00877   double ComputeTime_;
00879   mutable double ApplyTime_;
00881   double InitializeFlops_;
00883   double ComputeFlops_;
00885   mutable double ApplyFlops_;
00887   Teuchos::RCP<prec_type> Inverse_;
00889   Teuchos::RCP<const map_type> localMap_;
00890 
00897   mutable Teuchos::RCP<const import_type> DistributedImporter_;
00898 }; // class AdditiveSchwarz
00899 
00900 }// end namespace
00901 
00902 #endif // IFPACK2_ADDITIVESCHWARZ_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends