MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_IfpackSmoother.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_IFPACKSMOOTHER_HPP
11 #define MUELU_IFPACKSMOOTHER_HPP
12 
13 #include "MueLu_ConfigDefs.hpp"
14 #if defined(HAVE_MUELU_EPETRA) && defined(HAVE_MUELU_IFPACK)
15 
17 #include <Xpetra_Matrix.hpp>
19 
21 
22 #include "MueLu_SmootherPrototype.hpp"
23 #include "MueLu_Exceptions.hpp"
24 
25 #include "MueLu_Level_fwd.hpp"
27 #include "MueLu_Utilities_fwd.hpp"
28 #include "MueLu_Aggregates_fwd.hpp"
29 
30 namespace MueLu {
31 
40 template <class Node = typename SmootherPrototype<double, int, int>::node_type>
41 class IfpackSmoother : public MueLu::SmootherPrototype<double, int, int, Node> {
42  typedef double Scalar;
43  typedef int LocalOrdinal;
44  typedef int GlobalOrdinal;
45 #undef MUELU_IFPACKSMOOTHER_SHORT
46 #include "MueLu_UseShortNames.hpp"
47 
48  public:
50 
51 
86  IfpackSmoother(std::string const& type, Teuchos::ParameterList const& paramList = Teuchos::ParameterList(), LO const& overlap = 0); // TODO: empty paramList valid for Ifpack??
87 
89  virtual ~IfpackSmoother() {}
90 
92 
93  void SetParameterList(const Teuchos::ParameterList& paramList);
94 
96 
97 
98  void DeclareInput(Level& currentLevel) const;
99 
101 
103 
104 
110  void Setup(Level& currentLevel);
111 
120  void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const;
121 
123 
125 
126 
128 
130 
132 
133 
135  std::string description() const;
136 
138  // using MueLu::Describable::describe; // overloading, not hiding
139  // void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const
140  void print(Teuchos::FancyOStream& out, const VerbLevel verbLevel = Default) const;
141 
143  size_t getNodeSmootherComplexity() const;
144 
146 
147  private:
149 
150  void SetupAggregate(Level& currentLevel);
151 
152  private:
154  std::string type_;
155 
158 
161 
163  // Note: prec_ must be destroyed before A_, so declaration of prec_ appears after declaration of A_
165 
166 }; // class IfpackSmoother
167 
170 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
172 GetIfpackSmoother(const std::string& /* type */ = "",
173  const Teuchos::ParameterList& /* paramList */ = Teuchos::ParameterList(),
174  const LocalOrdinal& /* overlap */ = 0) {
175  TEUCHOS_TEST_FOR_EXCEPTION(true, Exceptions::RuntimeError, "IfpackSmoother cannot be used with Scalar != double, LocalOrdinal != int, GlobalOrdinal != int");
176  TEUCHOS_UNREACHABLE_RETURN(Teuchos::null);
177 }
178 
179 // Specialization for serial node (used for Epetra)
180 #if defined(HAVE_MUELU_EPETRA)
181 template <>
182 inline RCP<MueLu::SmootherPrototype<double, int, int, Xpetra::EpetraNode> >
183 GetIfpackSmoother<double, int, int, Xpetra::EpetraNode>(const std::string& type, const Teuchos::ParameterList& paramList, const int& overlap) {
184  return rcp(new MueLu::IfpackSmoother<Xpetra::EpetraNode>(type, paramList, overlap));
185 }
186 #endif
187 
188 } // namespace MueLu
189 
190 #define MUELU_IFPACKSMOOTHER_SHORT
191 #endif // HAVE_MUELU_EPETRA && HAVE_MUELU_IFPACK
192 #endif // MUELU_IFPACKSMOOTHER_HPP
void Setup(Level &currentLevel)
Set up the smoother.
RCP< SmootherPrototype > Copy() const
MueLu::DefaultLocalOrdinal LocalOrdinal
void SetPrecParameters(const Teuchos::ParameterList &list=Teuchos::ParameterList()) const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual ~IfpackSmoother()
Destructor.
Base class for smoother prototypes.
LocalOrdinal LO
IfpackSmoother(std::string const &type, Teuchos::ParameterList const &paramList=Teuchos::ParameterList(), LO const &overlap=0)
Constructor.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
RCP< MueLu::SmootherPrototype< Scalar, LocalOrdinal, GlobalOrdinal, Node > > GetIfpackSmoother(const std::string &="", const Teuchos::ParameterList &=Teuchos::ParameterList(), const LocalOrdinal &=0)
void DeclareInput(Level &currentLevel) const
Input.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
RCP< Ifpack_Preconditioner > prec_
pointer to Ifpack solver object
std::string type_
ifpack-specific key phrase that denote smoother type
Class that holds all level-specific information.
Definition: MueLu_Level.hpp:63
LO overlap_
overlap when using the smoother in additive Schwarz mode
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
RCP< Matrix > A_
Matrix. Not used directly, but held inside of prec_. So we have to keep an RCP pointer to it! ...
void SetParameterList(const Teuchos::ParameterList &paramList)
Set parameters from a parameter list and return with default values.
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
std::string description() const
Return a simple one-line description of this object.
void SetupAggregate(Level &currentLevel)
Exception throws to report errors in the internal logical of the program.
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply the preconditioner.
Class that encapsulates Ifpack smoothers.