Ifpack2 Templated Preconditioning Package  Version 1.0
Ifpack2_AdditiveSchwarz_decl.hpp
Go to the documentation of this file.
1 /*@HEADER
2 // ***********************************************************************
3 //
4 // Ifpack2: Tempated Object-Oriented Algebraic Preconditioner Package
5 // Copyright (2009) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 //@HEADER
41 */
42 
51 
52 #ifndef IFPACK2_ADDITIVESCHWARZ_DECL_HPP
53 #define IFPACK2_ADDITIVESCHWARZ_DECL_HPP
54 
55 #include "Ifpack2_ConfigDefs.hpp"
59 #include "Tpetra_Map.hpp"
60 #include "Tpetra_MultiVector.hpp"
61 #include "Tpetra_RowMatrix.hpp"
62 #include <type_traits>
63 
64 namespace Trilinos {
65 namespace Details {
66 template<class MV, class OP, class NormType>
67 class LinearSolver; // forward declaration
68 } // namespace Details
69 } // namespace Trilinos
70 
71 
72 namespace Ifpack2 {
73 
275 template<class MatrixType,
276  class LocalInverseType =
277  Preconditioner<typename MatrixType::scalar_type,
278  typename MatrixType::local_ordinal_type,
279  typename MatrixType::global_ordinal_type,
280  typename MatrixType::node_type> >
282  virtual public Preconditioner<typename MatrixType::scalar_type,
283  typename MatrixType::local_ordinal_type,
284  typename MatrixType::global_ordinal_type,
285  typename MatrixType::node_type>,
286  virtual public Details::CanChangeMatrix<Tpetra::RowMatrix<typename MatrixType::scalar_type,
287  typename MatrixType::local_ordinal_type,
288  typename MatrixType::global_ordinal_type,
289  typename MatrixType::node_type> >,
290  virtual public Details::NestedPreconditioner<Preconditioner<typename MatrixType::scalar_type,
291  typename MatrixType::local_ordinal_type,
292  typename MatrixType::global_ordinal_type,
293  typename MatrixType::node_type> >
294 {
295 public:
296  static_assert(std::is_same<LocalInverseType,
297  Preconditioner<typename MatrixType::scalar_type,
298  typename MatrixType::local_ordinal_type,
299  typename MatrixType::global_ordinal_type,
300  typename MatrixType::node_type> >::value, "Ifpack2::AdditiveSchwarz: You are not allowed to use nondefault values for the LocalInverseType template parameter. Please stop specifying this explicitly. The default template parameter is perfectly fine.");
301 
302  static_assert(std::is_same<MatrixType,
303  Tpetra::RowMatrix<typename MatrixType::scalar_type,
304  typename MatrixType::local_ordinal_type,
305  typename MatrixType::global_ordinal_type,
306  typename MatrixType::node_type> >::value, "Ifpack2::AdditiveSchwarz: Please use MatrixType = Tpetra::RowMatrix instead of MatrixType = Tpetra::CrsMatrix. Don't worry, AdditiveSchwarz's constructor can take either type of matrix; it does a dynamic cast if necessary inside. Restricting the set of allowed types here will improve build times and reduce library and executable sizes.");
307 
309 
310 
312  typedef typename MatrixType::scalar_type scalar_type;
313 
315  typedef typename MatrixType::local_ordinal_type local_ordinal_type;
316 
318  typedef typename MatrixType::global_ordinal_type global_ordinal_type;
319 
321  typedef typename MatrixType::node_type node_type;
322 
324  typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
325 
327  typedef Tpetra::RowMatrix<scalar_type,
328  local_ordinal_type,
329  global_ordinal_type,
330  node_type> row_matrix_type;
331 
333  // \name Constructors and destructor
335 
339  AdditiveSchwarz (const Teuchos::RCP<const row_matrix_type>& A);
340 
350  AdditiveSchwarz (const Teuchos::RCP<const row_matrix_type>& A,
351  const int overlapLevel);
352 
354  virtual ~AdditiveSchwarz();
355 
357 
359 
361  virtual Teuchos::RCP<const Tpetra::Map<local_ordinal_type,global_ordinal_type,node_type> > getDomainMap() const;
362 
364  virtual Teuchos::RCP<const Tpetra::Map<local_ordinal_type,global_ordinal_type,node_type> > getRangeMap() const;
365 
367  virtual void
368  apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &X,
369  Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &Y,
370  Teuchos::ETransp mode = Teuchos::NO_TRANS,
371  scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
372  scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
373 
375 
377 
412  virtual void
413  setInnerPreconditioner (const Teuchos::RCP<Preconditioner<scalar_type,
414  local_ordinal_type,
415  global_ordinal_type,
416  node_type> >& innerPrec);
417 
419 
421 
444  virtual void
445  setMatrix (const Teuchos::RCP<const row_matrix_type>& A);
447 
449  virtual Teuchos::RCP<const row_matrix_type> getMatrix() const;
450 
618  virtual void setParameters (const Teuchos::ParameterList& plist);
619 
643  void
644  setParameterList (const Teuchos::RCP<Teuchos::ParameterList>& plist);
645 
650  Teuchos::RCP<const Teuchos::ParameterList> getValidParameters () const;
651 
653  virtual void initialize();
654 
656  virtual bool isInitialized() const;
657 
659  virtual void compute();
660 
662  virtual bool isComputed() const;
663 
665  virtual int getNumInitialize() const;
666 
668  virtual int getNumCompute() const;
669 
671  virtual int getNumApply() const;
672 
674  virtual double getInitializeTime() const;
675 
677  virtual double getComputeTime() const;
678 
680  virtual double getApplyTime() const;
681 
683 
684 
686  std::string description() const;
687 
689  void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const;
690 
692 
694  virtual std::ostream& print(std::ostream& os) const;
695 
697  virtual int getOverlapLevel() const;
698 
699 
700 private:
702  typedef Tpetra::Map<local_ordinal_type,
703  global_ordinal_type,
704  node_type> map_type;
706  typedef Tpetra::Import<local_ordinal_type,
707  global_ordinal_type,
708  node_type> import_type;
710  typedef Tpetra::MultiVector<scalar_type,
711  local_ordinal_type,
712  global_ordinal_type,
713  node_type> MV;
715  typedef Tpetra::Operator<scalar_type,
716  local_ordinal_type,
717  global_ordinal_type,
718  node_type> OP;
720  typedef Preconditioner<scalar_type,
721  local_ordinal_type,
722  global_ordinal_type,
723  node_type> prec_type;
724 
726  typedef Trilinos::Details::LinearSolver<MV, OP, typename MV::mag_type> inner_solver_type;
727 
729  AdditiveSchwarz (const AdditiveSchwarz& RHS);
730 
732  void setup ();
733 
735  void localApply(MV &OverlappingX, MV &OverlappingY) const;
736 
739  bool hasInnerPrecName () const;
740 
741 
743  std::string innerPrecName () const;
744 
747  void removeInnerPrecName ();
748 
754  std::pair<Teuchos::ParameterList, bool> innerPrecParams () const;
755 
758  void removeInnerPrecParams ();
759 
761  static std::string defaultInnerPrecName ();
762 
766  Teuchos::RCP<const row_matrix_type> Matrix_;
767 
771  Teuchos::RCP<row_matrix_type> OverlappingMatrix_;
772 
774  Teuchos::RCP<row_matrix_type> ReorderedLocalizedMatrix_;
775 
777  Teuchos::RCP<row_matrix_type> innerMatrix_;
778 
780  bool IsInitialized_;
782  bool IsComputed_;
784  bool IsOverlapping_;
786  int OverlapLevel_;
787 
793  Teuchos::ParameterList List_;
794 
796  mutable Teuchos::RCP<const Teuchos::ParameterList> validParams_;
797 
799  Tpetra::CombineMode CombineMode_;
801  bool UseReordering_;
803  std::string ReorderingAlgorithm_;
805  bool FilterSingletons_;
807  Teuchos::RCP<row_matrix_type> SingletonMatrix_;
809  int NumIterations_;
811  bool ZeroStartingSolution_;
812 
814  int NumInitialize_;
816  int NumCompute_;
818  mutable int NumApply_;
820  double InitializeTime_;
822  double ComputeTime_;
824  mutable double ApplyTime_;
826  double InitializeFlops_;
828  double ComputeFlops_;
830  mutable double ApplyFlops_;
832  Teuchos::RCP<inner_solver_type> Inverse_;
834  Teuchos::RCP<const map_type> localMap_;
835 
842  mutable Teuchos::RCP<const import_type> DistributedImporter_;
843 }; // class AdditiveSchwarz
844 
845 }// end namespace
846 
847 #endif // IFPACK2_ADDITIVESCHWARZ_DECL_HPP
Mix-in interface for preconditioners that can change their matrix after construction.
Definition: Ifpack2_Details_CanChangeMatrix.hpp:93
Declaration of interface for nested preconditioners.
Mix-in interface for nested preconditioners.
Definition: Ifpack2_Details_NestedPreconditioner.hpp:97
MatrixType::node_type node_type
The Node type used by the input MatrixType.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:321
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
The type of the magnitude (absolute value) of a matrix entry.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:324
Ifpack2 implementation details.
MatrixType::global_ordinal_type global_ordinal_type
The type of global indices in the input MatrixType.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:318
MatrixType::scalar_type scalar_type
The type of the entries of the input MatrixType.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:312
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:64
Interface for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:107
Declaration of interface for preconditioners that can change their matrix after construction.
Tpetra::RowMatrix< scalar_type, local_ordinal_type, global_ordinal_type, node_type > row_matrix_type
The Tpetra::RowMatrix specialization matching MatrixType.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:330
Additive Schwarz domain decomposition for Tpetra sparse matrices.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:281
Preconditioners and smoothers for Tpetra sparse matrices.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:72
void getValidParameters(Teuchos::ParameterList &params)
Fills a list which contains all the parameters possibly used by Ifpack2.
Definition: Ifpack2_Parameters.cpp:50
MatrixType::local_ordinal_type local_ordinal_type
The type of local indices in the input MatrixType.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:315