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
23#include "MueLu_Ifpack2Smoother.hpp"
24
25#if defined(HAVE_MUELU_BELOS)
27#endif
28
29#if defined(HAVE_MUELU_STRATIMIKOS)
31#endif
32
33// Note: TrilinosSmoother is a SmootherPrototype that cannot be turned into a smoother using Setup().
34// When this prototype is cloned using Copy(), the clone is an Ifpack or an Ifpack2 smoother.
35// The clone can be used as a smoother after calling Setup().
36
37namespace MueLu {
38
47template <class Scalar = SmootherPrototype<>::scalar_type,
51class TrilinosSmoother : public SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
52#undef MUELU_TRILINOSSMOOTHER_SHORT
54
55 public:
57
58
71 TrilinosSmoother(const std::string& type = "", const Teuchos::ParameterList& paramList = Teuchos::ParameterList(), const LO& overlap = 0);
72
74 virtual ~TrilinosSmoother() {}
75
77
79
80
81 void DeclareInput(Level& currentLevel) const;
82
84
86
87
89 void Setup(Level& currentLevel);
90
92 void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const;
93
95
97 void SetFactory(const std::string& varName, const RCP<const FactoryBase>& factory);
98
100 RCP<SmootherPrototype> Copy() const;
101
102#ifndef _MSC_VER
104 template <class Scalar2, class LocalOrdinal2, class GlobalOrdinal2, class Node2>
105 friend class TrilinosSmoother;
106#endif
107
109 // As a temporary solution.
110 // See https://software.sandia.gov/bugzilla/show_bug.cgi?id=5283#c5 for what I proposed to do
111 static std::string Ifpack2ToIfpack1Type(const std::string& type);
112
114 // As a temporary solution.
115 // See https://software.sandia.gov/bugzilla/show_bug.cgi?id=5283#c5 for what I proposed to do
116 /* TODO:
117 ifpackList.set("type", "Chebyshev");
118 ifpackList.set("chebyshev: degree", (int) 1);
119 ifpackList.set("chebyshev: max eigenvalue", (double) 2.0);
120 ifpackList.set("chebyshev: min eigenvalue", (double) 1.0);
121 ifpackList.set("chebyshev: zero starting solution", false);
122 */
123 static Teuchos::ParameterList Ifpack2ToIfpack1Param(const Teuchos::ParameterList& ifpack2List);
124
126
127
129 std::string description() const;
130
132 // using MueLu::Describable::describe; // overloading, not hiding
133 // void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const {
134 void print(Teuchos::FancyOStream& out, const VerbLevel verbLevel = Default) const;
135
137 RCP<SmootherPrototype> getSmoother() { return s_; }
138
140 size_t getNodeSmootherComplexity() const { return s_->getNodeSmootherComplexity(); }
141
143
144 private:
146 std::string type_;
147
150
152 RCP<FactoryBase> AFact_;
153
154 //
155 // Underlying Smoother
156 //
157
159 RCP<SmootherPrototype> sEpetra_, sTpetra_, sBelos_, sStratimikos_;
160 mutable RCP<SmootherPrototype> s_;
161
162 // Records for the case if something goes wrong
165
166}; // class TrilinosSmoother
167
168} // namespace MueLu
169
170#define MUELU_TRILINOSSMOOTHER_SHORT
171#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.
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.