MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_Ifpack2Smoother_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_IFPACK2SMOOTHER_DECL_HPP
47#define MUELU_IFPACK2SMOOTHER_DECL_HPP
48
49#include <Teuchos_ParameterList.hpp>
50
51#include <Xpetra_BlockedCrsMatrix_fwd.hpp>
52#include <Xpetra_CrsMatrixWrap.hpp>
53#include <Xpetra_Matrix_fwd.hpp>
54#include <Xpetra_Matrix.hpp>
55#include <Xpetra_MultiVectorFactory_fwd.hpp>
56#ifdef HAVE_XPETRA_TPETRA // needed for clone()
57#include <Xpetra_TpetraCrsMatrix.hpp>
58#endif
59
60#include "MueLu_ConfigDefs.hpp"
62
63#if defined(HAVE_MUELU_TPETRA) && defined(HAVE_MUELU_IFPACK2)
64
65#include <Tpetra_CrsMatrix.hpp>
66
67#include <Ifpack2_Factory_decl.hpp>
68#include <Ifpack2_Factory_def.hpp>
70
73#include "MueLu_Level_fwd.hpp"
74#include "MueLu_SmootherPrototype.hpp"
77
78namespace MueLu {
79
90 template <class Scalar = SmootherPrototype<>::scalar_type,
94 class Ifpack2Smoother : public SmootherPrototype<Scalar,LocalOrdinal,GlobalOrdinal,Node> {
95#undef MUELU_IFPACK2SMOOTHER_SHORT
97
98 public:
99
101
102 //TODO: update doc for Ifpack2. Right now, it's a copy of the doc of IfpackSmoother
138#ifndef _MSC_VER
139 // Avoid error C3772: invalid friend template declaration
140 template<class Scalar2, class LocalOrdinal2, class GlobalOrdinal2, class Node2>
141 friend class Ifpack2Smoother;
142#endif
143
144 Ifpack2Smoother(const std::string& type, const Teuchos::ParameterList& paramList = Teuchos::ParameterList(), const LO& overlap = 0); //TODO: empty paramList valid for Ifpack??
145
147 virtual ~Ifpack2Smoother() { }
148
150
151 void SetParameterList(const Teuchos::ParameterList& paramList);
152
154
155
156 void DeclareInput(Level &currentLevel) const;
157
159
161
162
170 void Setup(Level &currentLevel);
171
180 void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const;
181
183
185
186
187 RCP<SmootherPrototype> Copy() const;
188
190
192
193
195 std::string description() const;
196
198 //using MueLu::Describable::describe; // overloading, not hiding
199 //void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const
200 void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const;
201
203
205 RCP<Ifpack2::Preconditioner<Scalar,LocalOrdinal,GlobalOrdinal,Node> > getPreconditioner(){return prec_;}
206
208 size_t getNodeSmootherComplexity() const;
209
210 private:
211 void SetPrecParameters(const Teuchos::ParameterList& list = Teuchos::ParameterList()) const;
212
213 void SetupSchwarz (Level& currentLevel);
214 void SetupChebyshev (Level& currentLevel);
215 void SetupLineSmoothing (Level& currentLevel);
216 void SetupBlockRelaxation (Level& currentLevel);
217 void SetupTopological (Level& currentLevel);
218 void SetupAggregate (Level& currentLevel);
219 void SetupHiptmair (Level& currentLevel);
220 void SetupGeneric (Level& currentLevel);
221 Scalar SetupChebyshevEigenvalues(Level & currentLevel, const std::string & matrixName, const std::string & label, Teuchos::ParameterList & paramList) const;
222 private:
223
226
228 std::string type_;
229
232
234 RCP<Ifpack2::Preconditioner<Scalar,LocalOrdinal,GlobalOrdinal,Node> > prec_;
235
237 RCP<Operator> A_;
238
239 }; // class Ifpack2Smoother
240
241#ifdef HAVE_MUELU_EPETRA
242
243# if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
244 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
245 // Stub specialization for missing Epetra template args
246 template<>
247 class Ifpack2Smoother<double,int,int,Xpetra::EpetraNode> : public SmootherPrototype<double,int,int,Xpetra::EpetraNode> {
248 typedef double Scalar;
249 typedef int LocalOrdinal;
250 typedef int GlobalOrdinal;
251 typedef Xpetra::EpetraNode Node;
252#undef MUELU_AMESOS2SMOOTHER_SHORT
254
255 public:
256#ifndef _MSC_VER
257 // Avoid error C3772: invalid friend template declaration
258 template<class Scalar2, class LocalOrdinal2, class GlobalOrdinal2, class Node2>
259 friend class Ifpack2Smoother;
260#endif
261
262 Ifpack2Smoother(const std::string& type, const Teuchos::ParameterList& paramList = Teuchos::ParameterList(), const LocalOrdinal& overlap = 0) {
263 MUELU_TPETRA_ETI_EXCEPTION("Ifpack2Smoother<double,int,int,EpetraNode>","Ifpack2Smoother<double,int,int,EpetraNode>","int");
264 };
265
266 virtual ~Ifpack2Smoother() { }
267
268 void SetParameterList(const Teuchos::ParameterList& paramList) {}
269 void DeclareInput(Level &currentLevel) const {}
270 void Setup(Level &currentLevel) {}
271 void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const {}
272 RCP<SmootherPrototype> Copy() const { return Teuchos::null;}
273
274 std::string description() const { return std::string(""); }
275 void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const {}
276
278 size_t getNodeSmootherComplexity() const {size_t cplx=0; return cplx;};
279
280 private:
281 void SetPrecParameters(const Teuchos::ParameterList& list = Teuchos::ParameterList()) const {}
282 };
283# endif
284
285#endif // HAVE_MUELU_EPETRA
286
287} // namespace MueLu
288
289#define MUELU_IFPACK2SMOOTHER_SHORT
290#endif // HAVE_MUELU_TPETRA && HAVE_MUELU_IFPACK2
291#endif // MUELU_IFPACK2SMOOTHER_DECL_HPP
Kokkos::Compat::KokkosSerialWrapperNode EpetraNode
#define MUELU_TPETRA_ETI_EXCEPTION(cl, obj, go)
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
MueLu::DefaultNode Node
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply smoother.
Ifpack2Smoother(const std::string &type, const Teuchos::ParameterList &paramList=Teuchos::ParameterList(), const LocalOrdinal &overlap=0)
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.
void SetPrecParameters(const Teuchos::ParameterList &list=Teuchos::ParameterList()) const
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Class that encapsulates Ifpack2 smoothers.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
RCP< Ifpack2::Preconditioner< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getPreconditioner()
For diagnostic purposes.
void SetupSchwarz(Level &currentLevel)
void Setup(Level &currentLevel)
Set up the smoother.
Scalar SetupChebyshevEigenvalues(Level &currentLevel, const std::string &matrixName, const std::string &label, Teuchos::ParameterList &paramList) const
void SetupAggregate(Level &currentLevel)
void SetupBlockRelaxation(Level &currentLevel)
void SetupChebyshev(Level &currentLevel)
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
void SetParameterList(const Teuchos::ParameterList &paramList)
Set parameters from a parameter list and return with default values.
RCP< SmootherPrototype > Copy() const
std::string description() const
Return a simple one-line description of this object.
void SetupHiptmair(Level &currentLevel)
LO overlap_
overlap when using the smoother in additive Schwarz mode
void SetPrecParameters(const Teuchos::ParameterList &list=Teuchos::ParameterList()) const
void SetupTopological(Level &currentLevel)
RCP< Ifpack2::Preconditioner< Scalar, LocalOrdinal, GlobalOrdinal, Node > > prec_
pointer to Ifpack2 preconditioner object
std::string type_
ifpack2-specific key phrase that denote smoother type
friend class Ifpack2Smoother
Constructor.
void DeclareInput(Level &currentLevel) const
Input.
RCP< Operator > A_
matrix, used in apply if solving residual equation
void SetupLineSmoothing(Level &currentLevel)
void SetupGeneric(Level &currentLevel)
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply the preconditioner.
Class that holds all level-specific information.
Definition: MueLu_Level.hpp:99
Base class for smoother prototypes.
Namespace for MueLu classes and methods.