MueLu Version of the Day
Loading...
Searching...
No Matches
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
16#include <Teuchos_ParameterList.hpp>
17#include <Xpetra_Matrix_fwd.hpp>
18
21
22#include "MueLu_SmootherPrototype.hpp"
23#include "MueLu_Exceptions.hpp"
24
25#include "MueLu_Level_fwd.hpp"
28
29namespace MueLu {
30
39template <class Node = typename SmootherPrototype<double, int, int>::node_type>
40class 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
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
113 RCP<SmootherPrototype> Copy() const;
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
143 RCP<Matrix> A_;
144
146 RCP<Epetra_LinearProblem> linearProblem_;
147
149 RCP<Amesos_BaseSolver> prec_;
150
151}; // class AmesosSmoother
152
154// when <Scalar, LocalOrdinal, GlobalOrdinal> == <double, int, int>. Otherwise, an exception is thrown.
156template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
157RCP<MueLu::SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
158GetAmesosSmoother(const std::string& /* type */ = "", const Teuchos::ParameterList& /* paramList */ = Teuchos::ParameterList()) {
159 TEUCHOS_TEST_FOR_EXCEPTION(true, Exceptions::RuntimeError,
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)
166template <>
167inline RCP<MueLu::SmootherPrototype<double, int, int, Xpetra::EpetraNode> >
168GetAmesosSmoother<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
Class that encapsulates Amesos direct solvers.
std::string description() const
Return a simple one-line description of this object.
std::string type_
amesos-specific key phrase that denote smoother type
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
RCP< Matrix > A_
Matrix. Not used directly, but held inside of linearProblem_. So we have to keep an RCP pointer to it...
void Setup(Level &currentLevel)
Set up the direct solver. This creates the underlying Amesos solver object according to the parameter...
RCP< SmootherPrototype > Copy() const
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
RCP< Epetra_LinearProblem > linearProblem_
Problem that Amesos uses internally.
void DeclareInput(Level &currentLevel) const
Input.
void Apply(MultiVector &X, const MultiVector &B, bool=false) const
Apply the direct solver.
virtual ~AmesosSmoother()
Destructor.
RCP< Amesos_BaseSolver > prec_
pointer to Amesos solver object
Exception throws to report errors in the internal logical of the program.
Class that holds all level-specific information.
Base class for smoother prototypes.
Namespace for MueLu classes and methods.
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.