MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_TrilinosSmoother_decl.hpp
Go to the documentation of this file.
1// @HEADER
2//
3// ***********************************************************************
4//
5// MueLu: A package for multigrid based preconditioning
6// Copyright 2012 Sandia Corporation
7//
8// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9// the U.S. Government retains certain rights in this software.
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17//
18// 2. Redistributions in binary form must reproduce the above copyright
19// notice, this list of conditions and the following disclaimer in the
20// documentation and/or other materials provided with the distribution.
21//
22// 3. Neither the name of the Corporation nor the names of the
23// contributors may be used to endorse or promote products derived from
24// this software without specific prior written permission.
25//
26// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37//
38// Questions? Contact
39// Jonathan Hu (jhu@sandia.gov)
40// Andrey Prokopenko (aprokop@sandia.gov)
41// Ray Tuminaro (rstumin@sandia.gov)
42//
43// ***********************************************************************
44//
45// @HEADER
46#ifndef MUELU_TRILINOSSMOOTHER_DECL_HPP
47#define MUELU_TRILINOSSMOOTHER_DECL_HPP
48
49#include <Teuchos_ParameterList.hpp>
50
51#include <Xpetra_Matrix_fwd.hpp>
52
53#include "MueLu_ConfigDefs.hpp"
55#include "MueLu_SmootherPrototype.hpp"
56
59
60#if defined(HAVE_MUELU_IFPACK2)
62#include "MueLu_Ifpack2Smoother.hpp"
63#endif
64
65#if defined(HAVE_MUELU_BELOS)
67#endif
68
69#if defined(HAVE_MUELU_STRATIMIKOS) && defined(HAVE_MUELU_TPETRA)
71#endif
72
73// Note: TrilinosSmoother is a SmootherPrototype that cannot be turned into a smoother using Setup().
74// When this prototype is cloned using Copy(), the clone is an Ifpack or an Ifpack2 smoother.
75// The clone can be used as a smoother after calling Setup().
76
77namespace MueLu {
78
87 template <class Scalar = SmootherPrototype<>::scalar_type,
91 class TrilinosSmoother : public SmootherPrototype<Scalar,LocalOrdinal,GlobalOrdinal,Node> {
92#undef MUELU_TRILINOSSMOOTHER_SHORT
94
95 public:
96
98
99
112 TrilinosSmoother(const std::string& type = "", const Teuchos::ParameterList& paramList = Teuchos::ParameterList(), const LO& overlap = 0);
113
115 virtual ~TrilinosSmoother() { }
116
118
120
121
122 void DeclareInput(Level& currentLevel) const;
123
125
127
128
130 void Setup(Level& currentLevel);
131
133 void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const;
134
136
138 void SetFactory(const std::string& varName, const RCP<const FactoryBase>& factory);
139
141 RCP<SmootherPrototype> Copy() const;
142
143#ifndef _MSC_VER
145 template<class Scalar2, class LocalOrdinal2, class GlobalOrdinal2, class Node2>
146 friend class TrilinosSmoother;
147#endif
148
150 // As a temporary solution.
151 // See https://software.sandia.gov/bugzilla/show_bug.cgi?id=5283#c5 for what I proposed to do
152 static std::string Ifpack2ToIfpack1Type(const std::string& type);
153
155 // As a temporary solution.
156 // See https://software.sandia.gov/bugzilla/show_bug.cgi?id=5283#c5 for what I proposed to do
157 /* TODO:
158 ifpackList.set("type", "Chebyshev");
159 ifpackList.set("chebyshev: degree", (int) 1);
160 ifpackList.set("chebyshev: max eigenvalue", (double) 2.0);
161 ifpackList.set("chebyshev: min eigenvalue", (double) 1.0);
162 ifpackList.set("chebyshev: zero starting solution", false);
163 */
164 static Teuchos::ParameterList Ifpack2ToIfpack1Param(const Teuchos::ParameterList& ifpack2List);
165
167
168
170 std::string description() const;
171
173 //using MueLu::Describable::describe; // overloading, not hiding
174 //void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const {
175 void print(Teuchos::FancyOStream& out, const VerbLevel verbLevel = Default) const;
176
178 RCP<SmootherPrototype> getSmoother() {return s_;}
179
181 size_t getNodeSmootherComplexity() const {return s_->getNodeSmootherComplexity();}
182
184
185 private:
186
188 std::string type_;
189
192
194 RCP<FactoryBase> AFact_;
195
196 //
197 // Underlying Smoother
198 //
199
201 RCP<SmootherPrototype> sEpetra_, sTpetra_, sBelos_, sStratimikos_;
202 mutable
203 RCP<SmootherPrototype> s_;
204
205 // Records for the case if something goes wrong
208
209 }; // class TrilinosSmoother
210
211} // namespace MueLu
212
213#define MUELU_TRILINOSSMOOTHER_SHORT
214#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.