MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_BelosSmoother_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_BELOSSMOOTHER_DECL_HPP
47#define MUELU_BELOSSMOOTHER_DECL_HPP
48
49#include <Teuchos_ParameterList.hpp>
50
51#include <Xpetra_Matrix_fwd.hpp>
52#include <Xpetra_MultiVectorFactory_fwd.hpp>
53
54#include "MueLu_ConfigDefs.hpp"
55
56#if defined(HAVE_MUELU_BELOS)
57
59
60#ifdef HAVE_XPETRA_TPETRA
61#include "BelosTpetraAdapter.hpp"
62#include <Tpetra_Operator.hpp>
63#include <Tpetra_MultiVector.hpp>
64#endif
65
66#include "MueLu_Level_fwd.hpp"
67#include "MueLu_SmootherPrototype.hpp"
69
70#include <BelosSolverManager.hpp>
71
72
73namespace MueLu {
74
84
85 template <class Scalar = SmootherPrototype<>::scalar_type,
89 class BelosSmoother : public SmootherPrototype<Scalar,LocalOrdinal,GlobalOrdinal,Node> {
90#undef MUELU_BELOSSMOOTHER_SHORT
92
93 public:
94
96
97 //TODO: update doc for Belos.
106
107#ifndef _MSC_VER
108 // Avoid error C3772: invalid friend template declaration
109 template<class Scalar2, class LocalOrdinal2, class GlobalOrdinal2, class Node2>
110 friend class BelosSmoother;
111#endif
112
113 BelosSmoother(const std::string type, const Teuchos::ParameterList& paramList = Teuchos::ParameterList());
114
116 virtual ~BelosSmoother() = default;
117
119
120 void SetParameterList(const Teuchos::ParameterList& paramList);
121
123
124
125 void DeclareInput(Level &currentLevel) const;
126
128
130
131
137 void Setup(Level &currentLevel);
138
147 void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const;
148
150
152
153
154 RCP<SmootherPrototype> Copy() const;
155
157
159
160
162 std::string description() const;
163
165 //using MueLu::Describable::describe; // overloading, not hiding
166 //void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const
167 void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const;
168
170
172 // RCP<Ifpack2::Preconditioner<Scalar,LocalOrdinal,GlobalOrdinal,Node> > getPreconditioner(){return prec_;}
173
175 size_t getNodeSmootherComplexity() const;
176
177 private:
178 void SetupBelos (Level& currentLevel);
179
180 private:
181
182 std::string type_;
183
184 typedef Tpetra::MultiVector<SC, LO, GO, NO> tMV;
185 typedef Tpetra::Operator<SC, LO, GO, NO> tOP;
186 RCP<Belos::LinearProblem<Scalar, tMV, tOP> > tBelosProblem_;
187 RCP<Belos::SolverManager<Scalar, tMV, tOP> > tSolver_;
188
190 RCP<Matrix> A_;
191
192 }; // class BelosSmoother
193
194
195 #ifdef HAVE_MUELU_EPETRA
196
197# if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
198 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
199 // Stub specialization for missing Epetra template args
200 template<>
201 class BelosSmoother<double,int,int,Xpetra::EpetraNode> : public SmootherPrototype<double,int,int,Xpetra::EpetraNode> {
202 typedef double Scalar;
203 typedef int LocalOrdinal;
204 typedef int GlobalOrdinal;
205 typedef Xpetra::EpetraNode Node;
206#undef MUELU_BELOSSMOOTHER_SHORT
208
209 public:
210#ifndef _MSC_VER
211 // Avoid error C3772: invalid friend template declaration
212 template<class Scalar2, class LocalOrdinal2, class GlobalOrdinal2, class Node2>
213 friend class BelosSmoother;
214#endif
215
216 BelosSmoother(const std::string& type, const Teuchos::ParameterList& paramList = Teuchos::ParameterList(), const LocalOrdinal& overlap = 0) {
217 MUELU_TPETRA_ETI_EXCEPTION("BelosSmoother<double,int,int,EpetraNode>","BelosSmoother<double,int,int,EpetraNode>","int");
218 };
219
220 virtual ~BelosSmoother() { }
221
222 void SetParameterList(const Teuchos::ParameterList& paramList) {}
223 void DeclareInput(Level &currentLevel) const {}
224 void Setup(Level &currentLevel) {}
225 void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const {}
226 RCP<SmootherPrototype> Copy() const { return Teuchos::null;}
227
228 std::string description() const { return std::string(""); }
229 void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const {}
230
232 size_t getNodeSmootherComplexity() const {size_t cplx=0; return cplx;};
233
234 };
235# endif
236
237#endif // HAVE_MUELU_EPETRA
238
239
240} // namespace MueLu
241
242#define MUELU_BELOSSMOOTHER_SHORT
243#endif // HAVE_MUELU_BELOS
244#endif // MUELU_BELOSSMOOTHER_DECL_HPP
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode
#define MUELU_TPETRA_ETI_EXCEPTION(cl, obj, go)
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultGlobalOrdinal GlobalOrdinal
MueLu::DefaultNode Node
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
BelosSmoother(const std::string &type, const Teuchos::ParameterList &paramList=Teuchos::ParameterList(), const LocalOrdinal &overlap=0)
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply smoother.
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.
Tpetra::MultiVector< SC, LO, GO, NO > tMV
RCP< Belos::SolverManager< Scalar, tMV, tOP > > tSolver_
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply the preconditioner.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
friend class BelosSmoother
Constructor.
RCP< Belos::LinearProblem< Scalar, tMV, tOP > > tBelosProblem_
RCP< Matrix > A_
matrix, used in apply if solving residual equation
Tpetra::Operator< SC, LO, GO, NO > tOP
void SetParameterList(const Teuchos::ParameterList &paramList)
Set parameters from a parameter list and return with default values.
void DeclareInput(Level &currentLevel) const
Input.
void SetupBelos(Level &currentLevel)
virtual ~BelosSmoother()=default
Destructor.
std::string description() const
Return a simple one-line description of this object.
size_t getNodeSmootherComplexity() const
For diagnostic purposes.
void Setup(Level &currentLevel)
Set up the smoother.
RCP< SmootherPrototype > Copy() const
Class that holds all level-specific information.
SmootherPrototype()
@nameConstructors/Destructors.
Namespace for MueLu classes and methods.