MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_BelosSmoother_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_BELOSSMOOTHER_DECL_HPP
11 #define MUELU_BELOSSMOOTHER_DECL_HPP
12 
14 
15 #include <Xpetra_Matrix_fwd.hpp>
17 
18 #include "MueLu_ConfigDefs.hpp"
19 
20 #if defined(HAVE_MUELU_BELOS)
21 
23 
24 #ifdef HAVE_XPETRA_TPETRA
25 #include "BelosTpetraAdapter.hpp"
26 #include <Tpetra_Operator.hpp>
27 #include <Tpetra_MultiVector.hpp>
28 #endif
29 
30 #include "MueLu_Level_fwd.hpp"
31 #include "MueLu_SmootherPrototype.hpp"
32 #include "MueLu_Utilities_fwd.hpp"
33 
34 #include <BelosSolverManager.hpp>
35 
36 namespace MueLu {
37 
48 template <class Scalar = SmootherPrototype<>::scalar_type,
49  class LocalOrdinal = typename SmootherPrototype<Scalar>::local_ordinal_type,
50  class GlobalOrdinal = typename SmootherPrototype<Scalar, LocalOrdinal>::global_ordinal_type,
51  class Node = typename SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal>::node_type>
52 class BelosSmoother : public SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
53 #undef MUELU_BELOSSMOOTHER_SHORT
54 #include "MueLu_UseShortNames.hpp"
55 
56  public:
58 
59  // TODO: update doc for Belos.
69 #ifndef _MSC_VER
70  // Avoid error C3772: invalid friend template declaration
71  template <class Scalar2, class LocalOrdinal2, class GlobalOrdinal2, class Node2>
72  friend class BelosSmoother;
73 #endif
74 
75  BelosSmoother(const std::string type, const Teuchos::ParameterList& paramList = Teuchos::ParameterList());
76 
78  virtual ~BelosSmoother() = default;
79 
81 
82  void SetParameterList(const Teuchos::ParameterList& paramList);
83 
85 
86 
87  void DeclareInput(Level& currentLevel) const;
88 
90 
92 
93 
99  void Setup(Level& currentLevel);
100 
109  void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const;
110 
112 
114 
115 
117 
119 
121 
122 
124  std::string description() const;
125 
127  // using MueLu::Describable::describe; // overloading, not hiding
128  // void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const
129  void print(Teuchos::FancyOStream& out, const VerbLevel verbLevel = Default) const;
130 
132 
134  // RCP<Ifpack2::Preconditioner<Scalar,LocalOrdinal,GlobalOrdinal,Node> > getPreconditioner(){return prec_;}
135 
137  size_t getNodeSmootherComplexity() const;
138 
139  private:
140  void SetupBelos(Level& currentLevel);
141 
142  private:
143  std::string type_;
144 
149 
152 
153 }; // class BelosSmoother
154 
155 #ifdef HAVE_MUELU_EPETRA
156 
157 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
158  (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
159 // Stub specialization for missing Epetra template args
160 template <>
161 class BelosSmoother<double, int, int, Xpetra::EpetraNode> : public SmootherPrototype<double, int, int, Xpetra::EpetraNode> {
162  typedef double Scalar;
163  typedef int LocalOrdinal;
164  typedef int GlobalOrdinal;
166 #undef MUELU_BELOSSMOOTHER_SHORT
167 #include "MueLu_UseShortNames.hpp"
168 
169  public:
170 #ifndef _MSC_VER
171  // Avoid error C3772: invalid friend template declaration
172  template <class Scalar2, class LocalOrdinal2, class GlobalOrdinal2, class Node2>
173  friend class BelosSmoother;
174 #endif
175 
176  BelosSmoother(const std::string& type, const Teuchos::ParameterList& paramList = Teuchos::ParameterList(), const LocalOrdinal& overlap = 0) {
177  MUELU_TPETRA_ETI_EXCEPTION("BelosSmoother<double,int,int,EpetraNode>", "BelosSmoother<double,int,int,EpetraNode>", "int");
178  };
179 
180  virtual ~BelosSmoother() {}
181 
182  void SetParameterList(const Teuchos::ParameterList& paramList) {}
183  void DeclareInput(Level& currentLevel) const {}
184  void Setup(Level& currentLevel) {}
185  void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const {}
186  RCP<SmootherPrototype> Copy() const { return Teuchos::null; }
187 
188  std::string description() const { return std::string(""); }
189  void print(Teuchos::FancyOStream& out, const VerbLevel verbLevel = Default) const {}
190 
192  size_t getNodeSmootherComplexity() const {
193  size_t cplx = 0;
194  return cplx;
195  };
196 };
197 #endif
198 
199 #endif // HAVE_MUELU_EPETRA
200 
201 } // namespace MueLu
202 
203 #define MUELU_BELOSSMOOTHER_SHORT
204 #endif // HAVE_MUELU_BELOS
205 #endif // MUELU_BELOSSMOOTHER_DECL_HPP
virtual ~BelosSmoother()=default
Destructor.
BelosSmoother(const std::string &type, const Teuchos::ParameterList &paramList=Teuchos::ParameterList(), const LocalOrdinal &overlap=0)
MueLu::DefaultLocalOrdinal LocalOrdinal
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
RCP< Matrix > A_
matrix, used in apply if solving residual equation
Class that encapsulates Belos smoothers.
Base class for smoother prototypes.
void Setup(Level &currentLevel)
Set up the smoother.
Tpetra::Operator< SC, LO, GO, NO > tOP
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
MueLu::DefaultNode Node
size_t getNodeSmootherComplexity() const
For diagnostic purposes.
RCP< SmootherPrototype > Copy() const
RCP< Belos::SolverManager< Scalar, tMV, tOP > > tSolver_
RCP< Belos::LinearProblem< Scalar, tMV, tOP > > tBelosProblem_
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Class that holds all level-specific information.
Definition: MueLu_Level.hpp:63
#define MUELU_TPETRA_ETI_EXCEPTION(cl, obj, go)
void SetupBelos(Level &currentLevel)
friend class BelosSmoother
Constructor.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply the preconditioner.
void SetParameterList(const Teuchos::ParameterList &paramList)
Set parameters from a parameter list and return with default values.
Tpetra::MultiVector< SC, LO, GO, NO > tMV
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply smoother.
void SetParameterList(const Teuchos::ParameterList &paramList)
Set parameters from a parameter list and return with default values.
void DeclareInput(Level &currentLevel) const
Input.
std::string description() const
Return a simple one-line description of this object.
std::string description() const
Return a simple one-line description of this object.