MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_AmesosSmoother.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_AMESOSSMOOTHER_HPP
11 #define MUELU_AMESOSSMOOTHER_HPP
12 
13 #include "MueLu_ConfigDefs.hpp"
14 #if defined(HAVE_MUELU_EPETRA) && defined(HAVE_MUELU_AMESOS)
15 
17 #include <Xpetra_Matrix_fwd.hpp>
18 
20 class Amesos_BaseSolver;
21 
22 #include "MueLu_SmootherPrototype.hpp"
23 #include "MueLu_Exceptions.hpp"
24 
25 #include "MueLu_Level_fwd.hpp"
27 #include "MueLu_Utilities_fwd.hpp"
28 
29 namespace MueLu {
30 
39 template <class Node = typename SmootherPrototype<double, int, int>::node_type>
40 class AmesosSmoother : public SmootherPrototype<double, int, int, Node> {
41  typedef double Scalar;
42  typedef int LocalOrdinal;
43  typedef int GlobalOrdinal;
44 
45 #undef MUELU_AMESOSSMOOTHER_SHORT
46 #include "MueLu_UseShortNames.hpp"
47 
48  public:
50 
51 
78  AmesosSmoother(const std::string& type = "", const Teuchos::ParameterList& paramList = Teuchos::ParameterList());
79 
81  virtual ~AmesosSmoother(){};
82 
84 
86 
87 
88  void DeclareInput(Level& currentLevel) const;
89 
91 
93 
94 
99  void Setup(Level& currentLevel);
100 
109  void Apply(MultiVector& X, const MultiVector& B, bool /* InitialGuessIsZero */ = false) const;
110 
112 
114 
116 
117 
119  std::string description() const;
120 
122  // using MueLu::Describable::describe; // overloading, not hiding
123  void print(Teuchos::FancyOStream& out, const VerbLevel verbLevel = Default) const;
124 
126  size_t getNodeSmootherComplexity() const;
127 
129 
130  private:
131  // Important note:
132  // linearProblem_ must be destroyed before A_, because destructor of linearProblem_ is using A_.
133  // In C++, destructor of member objects are called in the reverse order they appear within the declaration for the class.
134  // ==18029== Invalid read of size 8
135  // ==18029== at 0xC0780A: Epetra_LinearProblem::GetMatrix() const (Epetra_LinearProblem.h:173)
136  // ==18029== by 0xC5EC27: Amesos_Superlu::PrintTiming() const (Amesos_Superlu.cpp:664)
137  // ==18029== by 0xC628C6: Amesos_Superlu::~Amesos_Superlu() (Amesos_Superlu.cpp:108)
138 
140  std::string type_;
141 
144 
147 
150 
151 }; // class AmesosSmoother
152 
154 // when <Scalar, LocalOrdinal, GlobalOrdinal> == <double, int, int>. Otherwise, an exception is thrown.
156 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
158 GetAmesosSmoother(const std::string& /* type */ = "", const Teuchos::ParameterList& /* paramList */ = Teuchos::ParameterList()) {
160  "AmesosSmoother cannot be used with Scalar != double, LocalOrdinal != int, GlobalOrdinal != int");
161  TEUCHOS_UNREACHABLE_RETURN(Teuchos::null);
162 }
163 
164 // specialization for Epetra
165 #if defined(HAVE_MUELU_SERIAL)
166 template <>
167 inline RCP<MueLu::SmootherPrototype<double, int, int, Xpetra::EpetraNode> >
168 GetAmesosSmoother<double, int, int, Xpetra::EpetraNode>(const std::string& type, const Teuchos::ParameterList& paramList) {
169  return rcp(new MueLu::AmesosSmoother<Xpetra::EpetraNode>(type, paramList));
170 }
171 #endif // HAVE_MUELU_SERIAL
172 
173 } // namespace MueLu
174 
175 #define MUELU_AMESOSSMOOTHER_SHORT
176 
177 #endif // HAVE_MUELU_AMESOS
178 #endif // MUELU_AMESOSSMOOTHER_HPP
void Apply(MultiVector &X, const MultiVector &B, bool=false) const
Apply the direct solver.
RCP< Epetra_LinearProblem > linearProblem_
Problem that Amesos uses internally.
AmesosSmoother(const std::string &type="", const Teuchos::ParameterList &paramList=Teuchos::ParameterList())
Constructor.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
std::string description() const
Return a simple one-line description of this object.
RCP< Matrix > A_
Matrix. Not used directly, but held inside of linearProblem_. So we have to keep an RCP pointer to it...
Base class for smoother prototypes.
void Setup(Level &currentLevel)
Set up the direct solver. This creates the underlying Amesos solver object according to the parameter...
std::string type_
amesos-specific key phrase that denote smoother type
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Class that holds all level-specific information.
Definition: MueLu_Level.hpp:63
virtual ~AmesosSmoother()
Destructor.
RCP< SmootherPrototype > Copy() const
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
RCP< Amesos_BaseSolver > prec_
pointer to Amesos solver object
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
Exception throws to report errors in the internal logical of the program.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
RCP< MueLu::SmootherPrototype< Scalar, LocalOrdinal, GlobalOrdinal, Node > > GetAmesosSmoother(const std::string &="", const Teuchos::ParameterList &=Teuchos::ParameterList())
Non-member templated function GetAmesosSmoother() returns a new AmesosSmoother object.
void DeclareInput(Level &currentLevel) const
Input.
Class that encapsulates Amesos direct solvers.