MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
50 
53 #include <Xpetra_Matrix_fwd.hpp>
55 #ifdef HAVE_XPETRA_TPETRA // needed for clone()
57 #endif
58 
59 #include "MueLu_ConfigDefs.hpp"
61 
62 #if defined(HAVE_MUELU_IFPACK2)
63 
64 #include <Tpetra_CrsMatrix.hpp>
65 
66 #include <Ifpack2_Factory_decl.hpp>
67 #include <Ifpack2_Factory_def.hpp>
69 
70 #include "MueLu_Level_fwd.hpp"
71 #include "MueLu_SmootherPrototype.hpp"
72 #include "MueLu_Utilities_fwd.hpp"
73 #include "MueLu_Aggregates_fwd.hpp"
74 
75 namespace MueLu {
76 
87 template <class Scalar = SmootherPrototype<>::scalar_type,
88  class LocalOrdinal = typename SmootherPrototype<Scalar>::local_ordinal_type,
89  class GlobalOrdinal = typename SmootherPrototype<Scalar, LocalOrdinal>::global_ordinal_type,
90  class Node = typename SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal>::node_type>
91 class Ifpack2Smoother : public SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
92 #undef MUELU_IFPACK2SMOOTHER_SHORT
93 #include "MueLu_UseShortNames.hpp"
94 
95  public:
97 
98  // TODO: update doc for Ifpack2. Right now, it's a copy of the doc of IfpackSmoother
134 #ifndef _MSC_VER
135  // Avoid error C3772: invalid friend template declaration
136  template <class Scalar2, class LocalOrdinal2, class GlobalOrdinal2, class Node2>
137  friend class Ifpack2Smoother;
138 #endif
139 
140  Ifpack2Smoother(const std::string& type, const Teuchos::ParameterList& paramList = Teuchos::ParameterList(), const LO& overlap = 0); // TODO: empty paramList valid for Ifpack??
141 
143  virtual ~Ifpack2Smoother() {}
144 
146 
147  void SetParameterList(const Teuchos::ParameterList& paramList);
148 
150 
151 
152  void DeclareInput(Level& currentLevel) const;
153 
155 
157 
158 
166  void Setup(Level& currentLevel);
167 
176  void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const;
177 
179 
181 
182 
184 
186 
188 
189 
191  std::string description() const;
192 
194  // using MueLu::Describable::describe; // overloading, not hiding
195  // void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const
196  void print(Teuchos::FancyOStream& out, const VerbLevel verbLevel = Default) const;
197 
199 
202 
204  size_t getNodeSmootherComplexity() const;
205 
206  private:
208 
209  void SetupSchwarz(Level& currentLevel);
210  void SetupChebyshev(Level& currentLevel);
211  void SetupLineSmoothing(Level& currentLevel);
212  void SetupBlockRelaxation(Level& currentLevel);
213  void SetupTopological(Level& currentLevel);
214  void SetupAggregate(Level& currentLevel);
215  void SetupHiptmair(Level& currentLevel);
216  void SetupGeneric(Level& currentLevel);
217  Scalar SetupChebyshevEigenvalues(Level& currentLevel, const std::string& matrixName, const std::string& label, Teuchos::ParameterList& paramList) const;
218 
219  private:
222 
224  std::string type_;
225 
228 
231 
234 
235 }; // class Ifpack2Smoother
236 
237 #ifdef HAVE_MUELU_EPETRA
238 
239 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
240  (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
241 // Stub specialization for missing Epetra template args
242 template <>
243 class Ifpack2Smoother<double, int, int, Xpetra::EpetraNode> : public SmootherPrototype<double, int, int, Xpetra::EpetraNode> {
244  typedef double Scalar;
245  typedef int LocalOrdinal;
246  typedef int GlobalOrdinal;
248 #undef MUELU_AMESOS2SMOOTHER_SHORT
249 #include "MueLu_UseShortNames.hpp"
250 
251  public:
252 #ifndef _MSC_VER
253  // Avoid error C3772: invalid friend template declaration
254  template <class Scalar2, class LocalOrdinal2, class GlobalOrdinal2, class Node2>
255  friend class Ifpack2Smoother;
256 #endif
257 
258  Ifpack2Smoother(const std::string& type, const Teuchos::ParameterList& paramList = Teuchos::ParameterList(), const LocalOrdinal& overlap = 0) {
259  MUELU_TPETRA_ETI_EXCEPTION("Ifpack2Smoother<double,int,int,EpetraNode>", "Ifpack2Smoother<double,int,int,EpetraNode>", "int");
260  };
261 
262  virtual ~Ifpack2Smoother() {}
263 
264  void SetParameterList(const Teuchos::ParameterList& paramList) {}
265  void DeclareInput(Level& currentLevel) const {}
266  void Setup(Level& currentLevel) {}
267  void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const {}
268  RCP<SmootherPrototype> Copy() const { return Teuchos::null; }
269 
270  std::string description() const { return std::string(""); }
271  void print(Teuchos::FancyOStream& out, const VerbLevel verbLevel = Default) const {}
272 
274  size_t getNodeSmootherComplexity() const {
275  size_t cplx = 0;
276  return cplx;
277  };
278 
279  private:
281 };
282 #endif
283 
284 #endif // HAVE_MUELU_EPETRA
285 
286 } // namespace MueLu
287 
288 #define MUELU_IFPACK2SMOOTHER_SHORT
289 #endif // HAVE_MUELU_IFPACK2
290 #endif // MUELU_IFPACK2SMOOTHER_DECL_HPP
Ifpack2Smoother(const std::string &type, const Teuchos::ParameterList &paramList=Teuchos::ParameterList(), const LocalOrdinal &overlap=0)
void DeclareInput(Level &currentLevel) const
Input.
void SetupGeneric(Level &currentLevel)
MueLu::DefaultLocalOrdinal LocalOrdinal
friend class Ifpack2Smoother
Constructor.
Base class for smoother prototypes.
LocalOrdinal LO
void SetParameterList(const Teuchos::ParameterList &paramList)
Set parameters from a parameter list and return with default values.
LO overlap_
overlap when using the smoother in additive Schwarz mode
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
MueLu::DefaultNode Node
void SetParameterList(const Teuchos::ParameterList &paramList)
Set parameters from a parameter list and return with default values.
RCP< Operator > A_
matrix, used in apply if solving residual equation
std::string type_
ifpack2-specific key phrase that denote smoother type
void SetupBlockRelaxation(Level &currentLevel)
void SetupSchwarz(Level &currentLevel)
void SetupLineSmoothing(Level &currentLevel)
std::string description() const
Return a simple one-line description of this object.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
RCP< SmootherPrototype > Copy() const
Class that holds all level-specific information.
Definition: MueLu_Level.hpp:99
void Setup(Level &currentLevel)
Set up the smoother.
RCP< Ifpack2::Preconditioner< Scalar, LocalOrdinal, GlobalOrdinal, Node > > prec_
pointer to Ifpack2 preconditioner object
void SetupHiptmair(Level &currentLevel)
void SetupTopological(Level &currentLevel)
#define MUELU_TPETRA_ETI_EXCEPTION(cl, obj, go)
std::string description() const
Return a simple one-line description of this object.
RCP< Ifpack2::Preconditioner< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getPreconditioner()
For diagnostic purposes.
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
void SetPrecParameters(const Teuchos::ParameterList &list=Teuchos::ParameterList()) const
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply smoother.
void SetPrecParameters(const Teuchos::ParameterList &list=Teuchos::ParameterList()) const
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
virtual ~Ifpack2Smoother()
Destructor.
void SetupAggregate(Level &currentLevel)
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply the preconditioner.
void SetupChebyshev(Level &currentLevel)
Class that encapsulates Ifpack2 smoothers.
Scalar SetupChebyshevEigenvalues(Level &currentLevel, const std::string &matrixName, const std::string &label, Teuchos::ParameterList &paramList) const