MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_Ifpack2Smoother_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_IFPACK2SMOOTHER_DECL_HPP
11 #define MUELU_IFPACK2SMOOTHER_DECL_HPP
12 
14 
17 #include <Xpetra_Matrix_fwd.hpp>
19 #ifdef HAVE_XPETRA_TPETRA // needed for clone()
21 #endif
22 
23 #include "MueLu_ConfigDefs.hpp"
25 
26 #if defined(HAVE_MUELU_IFPACK2)
27 
28 #include <Tpetra_CrsMatrix.hpp>
29 
30 #include <Ifpack2_Factory_decl.hpp>
31 #include <Ifpack2_Factory_def.hpp>
33 
34 #include "MueLu_Level_fwd.hpp"
35 #include "MueLu_SmootherPrototype.hpp"
36 #include "MueLu_Utilities_fwd.hpp"
37 #include "MueLu_Aggregates_fwd.hpp"
38 
39 namespace MueLu {
40 
51 template <class Scalar = SmootherPrototype<>::scalar_type,
52  class LocalOrdinal = typename SmootherPrototype<Scalar>::local_ordinal_type,
53  class GlobalOrdinal = typename SmootherPrototype<Scalar, LocalOrdinal>::global_ordinal_type,
54  class Node = typename SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal>::node_type>
55 class Ifpack2Smoother : public SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
56 #undef MUELU_IFPACK2SMOOTHER_SHORT
57 #include "MueLu_UseShortNames.hpp"
58 
59  public:
61 
62  // TODO: update doc for Ifpack2. Right now, it's a copy of the doc of IfpackSmoother
98 #ifndef _MSC_VER
99  // Avoid error C3772: invalid friend template declaration
100  template <class Scalar2, class LocalOrdinal2, class GlobalOrdinal2, class Node2>
101  friend class Ifpack2Smoother;
102 #endif
103 
104  Ifpack2Smoother(const std::string& type, const Teuchos::ParameterList& paramList = Teuchos::ParameterList(), const LO& overlap = 0); // TODO: empty paramList valid for Ifpack??
105 
107  virtual ~Ifpack2Smoother() {}
108 
110 
111  void SetParameterList(const Teuchos::ParameterList& paramList);
112 
114 
115 
116  void DeclareInput(Level& currentLevel) const;
117 
119 
121 
122 
130  void Setup(Level& currentLevel);
131 
140  void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const;
141 
143 
145 
146 
148 
150 
152 
153 
155  std::string description() const;
156 
158  // using MueLu::Describable::describe; // overloading, not hiding
159  // void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const
160  void print(Teuchos::FancyOStream& out, const VerbLevel verbLevel = Default) const;
161 
163 
166 
168  size_t getNodeSmootherComplexity() const;
169 
170  private:
172 
173  void SetupSchwarz(Level& currentLevel);
174  void SetupChebyshev(Level& currentLevel);
175  void SetupLineSmoothing(Level& currentLevel);
176  void SetupBlockRelaxation(Level& currentLevel);
177  void SetupTopological(Level& currentLevel);
178  void SetupAggregate(Level& currentLevel);
179  void SetupHiptmair(Level& currentLevel);
180  void SetupGeneric(Level& currentLevel);
181  Scalar SetupChebyshevEigenvalues(Level& currentLevel, const std::string& matrixName, const std::string& label, Teuchos::ParameterList& paramList) const;
182 
183  private:
186 
188  std::string type_;
189 
192 
195 
198 
199 }; // class Ifpack2Smoother
200 
201 #ifdef HAVE_MUELU_EPETRA
202 
203 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
204  (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
205 // Stub specialization for missing Epetra template args
206 template <>
207 class Ifpack2Smoother<double, int, int, Xpetra::EpetraNode> : public SmootherPrototype<double, int, int, Xpetra::EpetraNode> {
208  typedef double Scalar;
209  typedef int LocalOrdinal;
210  typedef int GlobalOrdinal;
212 #undef MUELU_AMESOS2SMOOTHER_SHORT
213 #include "MueLu_UseShortNames.hpp"
214 
215  public:
216 #ifndef _MSC_VER
217  // Avoid error C3772: invalid friend template declaration
218  template <class Scalar2, class LocalOrdinal2, class GlobalOrdinal2, class Node2>
219  friend class Ifpack2Smoother;
220 #endif
221 
222  Ifpack2Smoother(const std::string& type, const Teuchos::ParameterList& paramList = Teuchos::ParameterList(), const LocalOrdinal& overlap = 0) {
223  MUELU_TPETRA_ETI_EXCEPTION("Ifpack2Smoother<double,int,int,EpetraNode>", "Ifpack2Smoother<double,int,int,EpetraNode>", "int");
224  };
225 
226  virtual ~Ifpack2Smoother() {}
227 
228  void SetParameterList(const Teuchos::ParameterList& paramList) {}
229  void DeclareInput(Level& currentLevel) const {}
230  void Setup(Level& currentLevel) {}
231  void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const {}
232  RCP<SmootherPrototype> Copy() const { return Teuchos::null; }
233 
234  std::string description() const { return std::string(""); }
235  void print(Teuchos::FancyOStream& out, const VerbLevel verbLevel = Default) const {}
236 
238  size_t getNodeSmootherComplexity() const {
239  size_t cplx = 0;
240  return cplx;
241  };
242 
243  private:
245 };
246 #endif
247 
248 #endif // HAVE_MUELU_EPETRA
249 
250 } // namespace MueLu
251 
252 #define MUELU_IFPACK2SMOOTHER_SHORT
253 #endif // HAVE_MUELU_IFPACK2
254 #endif // MUELU_IFPACK2SMOOTHER_DECL_HPP
Ifpack2Smoother(const std::string &type, const Teuchos::ParameterList &paramList=Teuchos::ParameterList(), const LocalOrdinal &overlap=0)
void DeclareInput(Level &currentLevel) const
Input.
void SetupGeneric(Level &currentLevel)
MueLu::DefaultLocalOrdinal LocalOrdinal
friend class Ifpack2Smoother
Constructor.
Base class for smoother prototypes.
LocalOrdinal LO
void SetParameterList(const Teuchos::ParameterList &paramList)
Set parameters from a parameter list and return with default values.
LO overlap_
overlap when using the smoother in additive Schwarz mode
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
MueLu::DefaultNode Node
void SetParameterList(const Teuchos::ParameterList &paramList)
Set parameters from a parameter list and return with default values.
RCP< Operator > A_
matrix, used in apply if solving residual equation
std::string type_
ifpack2-specific key phrase that denote smoother type
void SetupBlockRelaxation(Level &currentLevel)
void SetupSchwarz(Level &currentLevel)
void SetupLineSmoothing(Level &currentLevel)
std::string description() const
Return a simple one-line description of this object.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
RCP< SmootherPrototype > Copy() const
Class that holds all level-specific information.
Definition: MueLu_Level.hpp:63
void Setup(Level &currentLevel)
Set up the smoother.
RCP< Ifpack2::Preconditioner< Scalar, LocalOrdinal, GlobalOrdinal, Node > > prec_
pointer to Ifpack2 preconditioner object
void SetupHiptmair(Level &currentLevel)
void SetupTopological(Level &currentLevel)
#define MUELU_TPETRA_ETI_EXCEPTION(cl, obj, go)
std::string description() const
Return a simple one-line description of this object.
RCP< Ifpack2::Preconditioner< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getPreconditioner()
For diagnostic purposes.
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
void SetPrecParameters(const Teuchos::ParameterList &list=Teuchos::ParameterList()) const
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply smoother.
void SetPrecParameters(const Teuchos::ParameterList &list=Teuchos::ParameterList()) const
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
virtual ~Ifpack2Smoother()
Destructor.
void SetupAggregate(Level &currentLevel)
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply the preconditioner.
void SetupChebyshev(Level &currentLevel)
Class that encapsulates Ifpack2 smoothers.
Scalar SetupChebyshevEigenvalues(Level &currentLevel, const std::string &matrixName, const std::string &label, Teuchos::ParameterList &paramList) const