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
20
22#include "MueLu_Ifpack2Smoother.hpp"
23
24#if defined(HAVE_MUELU_BELOS)
26#endif
27
28#if defined(HAVE_MUELU_STRATIMIKOS)
30#endif
31
32// Note: TrilinosSmoother is a SmootherPrototype that cannot be turned into a smoother using Setup().
33// When this prototype is cloned using Copy(), the clone is an Ifpack or an Ifpack2 smoother.
34// The clone can be used as a smoother after calling Setup().
35
36namespace MueLu {
37
46template <class Scalar = SmootherPrototype<>::scalar_type,
50class TrilinosSmoother : public SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
51#undef MUELU_TRILINOSSMOOTHER_SHORT
53
54 public:
56
57
70 TrilinosSmoother(const std::string& type = "", const Teuchos::ParameterList& paramList = Teuchos::ParameterList(), const LO& overlap = 0);
71
73 virtual ~TrilinosSmoother() {}
74
76
78
79
80 void DeclareInput(Level& currentLevel) const;
81
83
85
86
88 void Setup(Level& currentLevel);
89
91 void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const;
92
94
96 void SetFactory(const std::string& varName, const RCP<const FactoryBase>& factory);
97
99 RCP<SmootherPrototype> Copy() const;
100
101#ifndef _MSC_VER
103 template <class Scalar2, class LocalOrdinal2, class GlobalOrdinal2, class Node2>
104 friend class TrilinosSmoother;
105#endif
106
108 // As a temporary solution.
109 // See https://software.sandia.gov/bugzilla/show_bug.cgi?id=5283#c5 for what I proposed to do
110 static std::string Ifpack2ToIfpack1Type(const std::string& type);
111
113 // As a temporary solution.
114 // See https://software.sandia.gov/bugzilla/show_bug.cgi?id=5283#c5 for what I proposed to do
115 /* TODO:
116 ifpackList.set("type", "Chebyshev");
117 ifpackList.set("chebyshev: degree", (int) 1);
118 ifpackList.set("chebyshev: max eigenvalue", (double) 2.0);
119 ifpackList.set("chebyshev: min eigenvalue", (double) 1.0);
120 ifpackList.set("chebyshev: zero starting solution", false);
121 */
122 static Teuchos::ParameterList Ifpack2ToIfpack1Param(const Teuchos::ParameterList& ifpack2List);
123
125
126
128 std::string description() const;
129
131 // using MueLu::Describable::describe; // overloading, not hiding
132 // void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const {
133 void print(Teuchos::FancyOStream& out, const VerbLevel verbLevel = Default) const;
134
136 RCP<SmootherPrototype> getSmoother() { return s_; }
137
139 size_t getNodeSmootherComplexity() const { return s_->getNodeSmootherComplexity(); }
140
142
143 private:
145 std::string type_;
146
149
151 RCP<FactoryBase> AFact_;
152
153 //
154 // Underlying Smoother
155 //
156
158 RCP<SmootherPrototype> sTpetra_, sBelos_, sStratimikos_;
159 mutable RCP<SmootherPrototype> s_;
160
161 // Records for the case if something goes wrong
164
165}; // class TrilinosSmoother
166
167} // namespace MueLu
168
169#define MUELU_TRILINOSSMOOTHER_SHORT
170#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.
RCP< SmootherPrototype > Copy() const
When this prototype is cloned using Copy(), the clone is an Ifpack or an Ifpack2 smoother.
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.
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.
RCP< SmootherPrototype > sTpetra_
Smoother.
Namespace for MueLu classes and methods.