MueLu Version of the Day
Loading...
Searching...
No Matches
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
13#include <Teuchos_ParameterList.hpp>
14
15#include <Xpetra_Matrix_fwd.hpp>
16#include <Xpetra_MultiVectorFactory_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"
33
34#include <BelosSolverManager.hpp>
35
36namespace MueLu {
37
48template <class Scalar = SmootherPrototype<>::scalar_type,
52class BelosSmoother : public SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
53#undef MUELU_BELOSSMOOTHER_SHORT
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
116 RCP<SmootherPrototype> Copy() const;
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
145 typedef Tpetra::MultiVector<SC, LO, GO, NO> tMV;
146 typedef Tpetra::Operator<SC, LO, GO, NO> tOP;
147 RCP<Belos::LinearProblem<Scalar, tMV, tOP> > tBelosProblem_;
148 RCP<Belos::SolverManager<Scalar, tMV, tOP> > tSolver_;
149
151 RCP<Matrix> A_;
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
160template <>
161class 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;
165 typedef Xpetra::EpetraNode Node;
166#undef MUELU_BELOSSMOOTHER_SHORT
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
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
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode
#define MUELU_TPETRA_ETI_EXCEPTION(cl, obj, go)
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultGlobalOrdinal GlobalOrdinal
MueLu::DefaultNode Node
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
BelosSmoother(const std::string &type, const Teuchos::ParameterList &paramList=Teuchos::ParameterList(), const LocalOrdinal &overlap=0)
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.
std::string description() const
Return a simple one-line description of this object.
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
Class that encapsulates Belos smoothers.
Tpetra::MultiVector< SC, LO, GO, NO > tMV
RCP< Belos::SolverManager< Scalar, tMV, tOP > > tSolver_
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply the preconditioner.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
friend class BelosSmoother
Constructor.
RCP< Belos::LinearProblem< Scalar, tMV, tOP > > tBelosProblem_
RCP< Matrix > A_
matrix, used in apply if solving residual equation
Tpetra::Operator< SC, LO, GO, NO > tOP
void SetParameterList(const Teuchos::ParameterList &paramList)
Set parameters from a parameter list and return with default values.
void DeclareInput(Level &currentLevel) const
Input.
void SetupBelos(Level &currentLevel)
virtual ~BelosSmoother()=default
Destructor.
std::string description() const
Return a simple one-line description of this object.
size_t getNodeSmootherComplexity() const
For diagnostic purposes.
void Setup(Level &currentLevel)
Set up the smoother.
RCP< SmootherPrototype > Copy() const
Class that holds all level-specific information.
Base class for smoother prototypes.
Namespace for MueLu classes and methods.