MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_TrilinosSmoother_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // MueLu: A package for multigrid based preconditioning
4 //
5 // Copyright 2012 NTESS and the MueLu contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef MUELU_TRILINOSSMOOTHER_DECL_HPP
11 #define MUELU_TRILINOSSMOOTHER_DECL_HPP
12 
14 
15 #include "MueLu_ConfigDefs.hpp"
17 #include "MueLu_SmootherPrototype.hpp"
18 
21 
22 #if defined(HAVE_MUELU_IFPACK2)
24 #include "MueLu_Ifpack2Smoother.hpp"
25 #endif
26 
27 #if defined(HAVE_MUELU_BELOS)
29 #endif
30 
31 #if defined(HAVE_MUELU_STRATIMIKOS)
33 #endif
34 
35 // Note: TrilinosSmoother is a SmootherPrototype that cannot be turned into a smoother using Setup().
36 // When this prototype is cloned using Copy(), the clone is an Ifpack or an Ifpack2 smoother.
37 // The clone can be used as a smoother after calling Setup().
38 
39 namespace MueLu {
40 
49 template <class Scalar = SmootherPrototype<>::scalar_type,
50  class LocalOrdinal = typename SmootherPrototype<Scalar>::local_ordinal_type,
51  class GlobalOrdinal = typename SmootherPrototype<Scalar, LocalOrdinal>::global_ordinal_type,
52  class Node = typename SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal>::node_type>
53 class TrilinosSmoother : public SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
54 #undef MUELU_TRILINOSSMOOTHER_SHORT
55 #include "MueLu_UseShortNames.hpp"
56 
57  public:
59 
60 
73  TrilinosSmoother(const std::string& type = "", const Teuchos::ParameterList& paramList = Teuchos::ParameterList(), const LO& overlap = 0);
74 
76  virtual ~TrilinosSmoother() {}
77 
79 
81 
82 
83  void DeclareInput(Level& currentLevel) const;
84 
86 
88 
89 
91  void Setup(Level& currentLevel);
92 
94  void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const;
95 
97 
99  void SetFactory(const std::string& varName, const RCP<const FactoryBase>& factory);
100 
103 
104 #ifndef _MSC_VER
105  template <class Scalar2, class LocalOrdinal2, class GlobalOrdinal2, class Node2>
107  friend class TrilinosSmoother;
108 #endif
109 
111  // As a temporary solution.
112  // See https://software.sandia.gov/bugzilla/show_bug.cgi?id=5283#c5 for what I proposed to do
113  static std::string Ifpack2ToIfpack1Type(const std::string& type);
114 
116  // As a temporary solution.
117  // See https://software.sandia.gov/bugzilla/show_bug.cgi?id=5283#c5 for what I proposed to do
118  /* TODO:
119  ifpackList.set("type", "Chebyshev");
120  ifpackList.set("chebyshev: degree", (int) 1);
121  ifpackList.set("chebyshev: max eigenvalue", (double) 2.0);
122  ifpackList.set("chebyshev: min eigenvalue", (double) 1.0);
123  ifpackList.set("chebyshev: zero starting solution", false);
124  */
126 
128 
129 
131  std::string description() const;
132 
134  // using MueLu::Describable::describe; // overloading, not hiding
135  // void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const {
136  void print(Teuchos::FancyOStream& out, const VerbLevel verbLevel = Default) const;
137 
140 
142  size_t getNodeSmootherComplexity() const { return s_->getNodeSmootherComplexity(); }
143 
145 
146  private:
148  std::string type_;
149 
152 
155 
156  //
157  // Underlying Smoother
158  //
159 
163 
164  // Records for the case if something goes wrong
167 
168 }; // class TrilinosSmoother
169 
170 } // namespace MueLu
171 
172 #define MUELU_TRILINOSSMOOTHER_SHORT
173 #endif // MUELU_TRILINOSSMOOTHER_DECL_HPP
MueLu::DefaultLocalOrdinal LocalOrdinal
std::string description() const
Return a simple one-line description of this object.
RCP< SmootherPrototype > sStratimikos_
virtual ~TrilinosSmoother()
Destructor.
Class that encapsulates external library smoothers.
static std::string Ifpack2ToIfpack1Type(const std::string &type)
Convert an Ifpack2 preconditioner name to Ifpack.
static Teuchos::ParameterList Ifpack2ToIfpack1Param(const Teuchos::ParameterList &ifpack2List)
Convert an Ifpack2 parameter list to Ifpack.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
Base class for smoother prototypes.
LocalOrdinal LO
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
TrilinosSmoother cannot be applied. Apply() always returns a RuntimeError exception.
void Setup(Level &currentLevel)
TrilinosSmoother cannot be turned into a smoother using Setup(). Setup() always returns a RuntimeErro...
MueLu::DefaultNode Node
friend class TrilinosSmoother
Friend declaration required for clone() functionality.
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Class that holds all level-specific information.
Definition: MueLu_Level.hpp:63
std::string type_
ifpack1/2-specific key phrase that denote smoother type
RCP< FactoryBase > AFact_
A Factory.
RCP< SmootherPrototype > Copy() const
When this prototype is cloned using Copy(), the clone is an Ifpack or an Ifpack2 smoother.
void DeclareInput(Level &currentLevel) const
Input.
RCP< SmootherPrototype > sEpetra_
Smoother.
LO overlap_
overlap when using the smoother in additive Schwarz mode
RCP< SmootherPrototype > getSmoother()
For diagnostic purposes.
void SetFactory(const std::string &varName, const RCP< const FactoryBase > &factory)
Custom SetFactory.