MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_TrilinosSmoother_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_TRILINOSSMOOTHER_DECL_HPP
11#define MUELU_TRILINOSSMOOTHER_DECL_HPP
12
13#include <Teuchos_ParameterList.hpp>
14
15#include "MueLu_ConfigDefs.hpp"
17#include "MueLu_SmootherPrototype.hpp"
18
21
22#if defined(HAVE_MUELU_IFPACK2)
24#include "MueLu_Ifpack2Smoother.hpp"
25#endif
26
27#if defined(HAVE_MUELU_BELOS)
29#endif
30
31#if defined(HAVE_MUELU_STRATIMIKOS)
33#endif
34
35// Note: TrilinosSmoother is a SmootherPrototype that cannot be turned into a smoother using Setup().
36// When this prototype is cloned using Copy(), the clone is an Ifpack or an Ifpack2 smoother.
37// The clone can be used as a smoother after calling Setup().
38
39namespace MueLu {
40
49template <class Scalar = SmootherPrototype<>::scalar_type,
53class TrilinosSmoother : public SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
54#undef MUELU_TRILINOSSMOOTHER_SHORT
56
57 public:
59
60
73 TrilinosSmoother(const std::string& type = "", const Teuchos::ParameterList& paramList = Teuchos::ParameterList(), const LO& overlap = 0);
74
76 virtual ~TrilinosSmoother() {}
77
79
81
82
83 void DeclareInput(Level& currentLevel) const;
84
86
88
89
91 void Setup(Level& currentLevel);
92
94 void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const;
95
97
99 void SetFactory(const std::string& varName, const RCP<const FactoryBase>& factory);
100
102 RCP<SmootherPrototype> Copy() const;
103
104#ifndef _MSC_VER
106 template <class Scalar2, class LocalOrdinal2, class GlobalOrdinal2, class Node2>
107 friend class TrilinosSmoother;
108#endif
109
111 // As a temporary solution.
112 // See https://software.sandia.gov/bugzilla/show_bug.cgi?id=5283#c5 for what I proposed to do
113 static std::string Ifpack2ToIfpack1Type(const std::string& type);
114
116 // As a temporary solution.
117 // See https://software.sandia.gov/bugzilla/show_bug.cgi?id=5283#c5 for what I proposed to do
118 /* TODO:
119 ifpackList.set("type", "Chebyshev");
120 ifpackList.set("chebyshev: degree", (int) 1);
121 ifpackList.set("chebyshev: max eigenvalue", (double) 2.0);
122 ifpackList.set("chebyshev: min eigenvalue", (double) 1.0);
123 ifpackList.set("chebyshev: zero starting solution", false);
124 */
125 static Teuchos::ParameterList Ifpack2ToIfpack1Param(const Teuchos::ParameterList& ifpack2List);
126
128
129
131 std::string description() const;
132
134 // using MueLu::Describable::describe; // overloading, not hiding
135 // void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const {
136 void print(Teuchos::FancyOStream& out, const VerbLevel verbLevel = Default) const;
137
139 RCP<SmootherPrototype> getSmoother() { return s_; }
140
142 size_t getNodeSmootherComplexity() const { return s_->getNodeSmootherComplexity(); }
143
145
146 private:
148 std::string type_;
149
152
154 RCP<FactoryBase> AFact_;
155
156 //
157 // Underlying Smoother
158 //
159
161 RCP<SmootherPrototype> sEpetra_, sTpetra_, sBelos_, sStratimikos_;
162 mutable RCP<SmootherPrototype> s_;
163
164 // Records for the case if something goes wrong
167
168}; // class TrilinosSmoother
169
170} // namespace MueLu
171
172#define MUELU_TRILINOSSMOOTHER_SHORT
173#endif // MUELU_TRILINOSSMOOTHER_DECL_HPP
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultGlobalOrdinal GlobalOrdinal
MueLu::DefaultNode Node
Class that holds all level-specific information.
Base class for smoother prototypes.
Class that encapsulates external library smoothers.
void Setup(Level &currentLevel)
TrilinosSmoother cannot be turned into a smoother using Setup(). Setup() always returns a RuntimeErro...
RCP< SmootherPrototype > getSmoother()
For diagnostic purposes.
LO overlap_
overlap when using the smoother in additive Schwarz mode
static Teuchos::ParameterList Ifpack2ToIfpack1Param(const Teuchos::ParameterList &ifpack2List)
Convert an Ifpack2 parameter list to Ifpack.
static std::string Ifpack2ToIfpack1Type(const std::string &type)
Convert an Ifpack2 preconditioner name to Ifpack.
std::string type_
ifpack1/2-specific key phrase that denote smoother type
friend class TrilinosSmoother
Friend declaration required for clone() functionality.
void DeclareInput(Level &currentLevel) const
Input.
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
RCP< SmootherPrototype > sEpetra_
Smoother.
void SetFactory(const std::string &varName, const RCP< const FactoryBase > &factory)
Custom SetFactory.
RCP< SmootherPrototype > sStratimikos_
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
TrilinosSmoother cannot be applied. Apply() always returns a RuntimeError exception.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
RCP< FactoryBase > AFact_
A Factory.
std::string description() const
Return a simple one-line description of this object.
Namespace for MueLu classes and methods.