MueLu Version of the Day
Loading...
Searching...
No Matches
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
13#include <Teuchos_ParameterList.hpp>
14
15#include <Xpetra_BlockedCrsMatrix_fwd.hpp>
16#include <Xpetra_CrsMatrixWrap_fwd.hpp>
17#include <Xpetra_Matrix_fwd.hpp>
18#include <Xpetra_MultiVectorFactory_fwd.hpp>
19#ifdef HAVE_XPETRA_TPETRA // needed for clone()
20#include <Xpetra_TpetraCrsMatrix_fwd.hpp>
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"
38
39namespace MueLu {
40
51template <class Scalar = SmootherPrototype<>::scalar_type,
55class Ifpack2Smoother : public SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
56#undef MUELU_IFPACK2SMOOTHER_SHORT
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
147 RCP<SmootherPrototype> Copy() const;
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
165 RCP<Ifpack2::Preconditioner<Scalar, LocalOrdinal, GlobalOrdinal, Node> > getPreconditioner() { return prec_; }
166
168 size_t getNodeSmootherComplexity() const;
169
170 private:
171 void SetPrecParameters(const Teuchos::ParameterList& list = Teuchos::ParameterList()) const;
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
194 RCP<Ifpack2::Preconditioner<Scalar, LocalOrdinal, GlobalOrdinal, Node> > prec_;
195
197 RCP<Operator> A_;
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
206template <>
207class 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;
211 typedef Xpetra::EpetraNode Node;
212#undef MUELU_AMESOS2SMOOTHER_SHORT
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
239 size_t cplx = 0;
240 return cplx;
241 };
242
243 private:
244 void SetPrecParameters(const Teuchos::ParameterList& list = Teuchos::ParameterList()) const {}
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
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode
#define MUELU_TPETRA_ETI_EXCEPTION(cl, obj, go)
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
MueLu::DefaultNode Node
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply smoother.
Ifpack2Smoother(const std::string &type, const Teuchos::ParameterList &paramList=Teuchos::ParameterList(), const LocalOrdinal &overlap=0)
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.
void SetPrecParameters(const Teuchos::ParameterList &list=Teuchos::ParameterList()) const
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Class that encapsulates Ifpack2 smoothers.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
RCP< Ifpack2::Preconditioner< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getPreconditioner()
For diagnostic purposes.
void SetupSchwarz(Level &currentLevel)
void Setup(Level &currentLevel)
Set up the smoother.
Scalar SetupChebyshevEigenvalues(Level &currentLevel, const std::string &matrixName, const std::string &label, Teuchos::ParameterList &paramList) const
void SetupAggregate(Level &currentLevel)
void SetupBlockRelaxation(Level &currentLevel)
void SetupChebyshev(Level &currentLevel)
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
void SetParameterList(const Teuchos::ParameterList &paramList)
Set parameters from a parameter list and return with default values.
RCP< SmootherPrototype > Copy() const
std::string description() const
Return a simple one-line description of this object.
void SetupHiptmair(Level &currentLevel)
LO overlap_
overlap when using the smoother in additive Schwarz mode
RCP< Ifpack2::Preconditioner< Scalar, LocalOrdinal, GlobalOrdinal, Node > > prec_
pointer to Ifpack2 preconditioner object
void SetPrecParameters(const Teuchos::ParameterList &list=Teuchos::ParameterList()) const
void SetupTopological(Level &currentLevel)
std::string type_
ifpack2-specific key phrase that denote smoother type
friend class Ifpack2Smoother
Constructor.
void DeclareInput(Level &currentLevel) const
Input.
RCP< Operator > A_
matrix, used in apply if solving residual equation
void SetupLineSmoothing(Level &currentLevel)
void SetupGeneric(Level &currentLevel)
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply the preconditioner.
Class that holds all level-specific information.
Base class for smoother prototypes.
Namespace for MueLu classes and methods.