MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_Amesos2Smoother_decl.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_AMESOS2SMOOTHER_DECL_HPP
11#define MUELU_AMESOS2SMOOTHER_DECL_HPP
12
13#include "MueLu_ConfigDefs.hpp"
14#if defined(HAVE_MUELU_AMESOS2)
15
16#include <Teuchos_ParameterList.hpp>
17#include <Teuchos_SerialDenseMatrix.hpp>
18#include <Teuchos_LAPACK.hpp>
19
21
22#include "MueLu_SmootherPrototype.hpp"
25
26namespace Amesos2 {
27template <class OP, class MV>
28class Solver;
29}
30
31namespace MueLu {
32
33template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
35 public:
36 Projection(RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>& Nullspace);
37
38 void projectOut(Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& X);
39
40 Teuchos::RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>> Nullspace_;
41
42 private:
43 Teuchos::RCP<const Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>> localMap_;
44};
45
55template <class Scalar = SmootherPrototype<>::scalar_type,
59class Amesos2Smoother : public SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
60#undef MUELU_AMESOS2SMOOTHER_SHORT
62
63 public:
65
66
71 Amesos2Smoother(const std::string& type = "", const Teuchos::ParameterList& paramList = Teuchos::ParameterList());
72
74 virtual ~Amesos2Smoother();
75
76 RCP<const ParameterList> GetValidParameterList() const;
77
79
81
82
83 void DeclareInput(Level& currentLevel) const;
84
86
88
89
94 void Setup(Level& currentLevel);
95
102 void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const;
104
105 RCP<SmootherPrototype> Copy() const;
106
108
109
111 std::string description() const;
112
114 // using MueLu::Describable::describe; // overloading, not hiding
115 void print(Teuchos::FancyOStream& out, const VerbLevel verbLevel = Default) const;
116
118 size_t getNodeSmootherComplexity() const;
119
121
122 private:
123 typedef Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> Tpetra_CrsMatrix;
124 typedef Tpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> Tpetra_MultiVector;
125
127 std::string type_;
128
130 RCP<Amesos2::Solver<Tpetra_CrsMatrix, Tpetra_MultiVector>> prec_;
131
133 RCP<MultiVector> X_, B_;
134
135 RCP<Projection<Scalar, LocalOrdinal, GlobalOrdinal, Node>> projection_;
136
137}; // class Amesos2Smoother
138
139#ifdef HAVE_MUELU_EPETRA
140
141#if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
142 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
143// Stub specialization for missing Epetra template args
144template <>
145class Amesos2Smoother<double, int, int, Xpetra::EpetraNode> : public SmootherPrototype<double, int, int, Xpetra::EpetraNode> {
146 typedef double Scalar;
147 typedef int LocalOrdinal;
148 typedef int GlobalOrdinal;
149 typedef Xpetra::EpetraNode Node;
150#undef MUELU_AMESOS2SMOOTHER_SHORT
152
153 public:
154 Amesos2Smoother(const std::string& type = "", const Teuchos::ParameterList& paramList = Teuchos::ParameterList()) {
155 MUELU_TPETRA_ETI_EXCEPTION("Amesos2Smoother<double,int,int,EpetraNode>", "Amesos2Smoother<double,int,int,EpetraNode>", "int");
156 }
157 virtual ~Amesos2Smoother(){};
158 void DeclareInput(Level& currentLevel) const {};
159 void Setup(Level& currentLevel){};
160 void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const {};
161
162 RCP<SmootherPrototype> Copy() const { return Teuchos::null; };
163
164 std::string description() const { return std::string(""); };
165 void print(Teuchos::FancyOStream& out, const VerbLevel verbLevel = Default) const {};
166
169 size_t cplx = 0;
170 return cplx;
171 };
172};
173#endif
174#endif // HAVE_MUELU_EPETRA
175
176} // namespace MueLu
177
178#define MUELU_AMESOS2SMOOTHER_SHORT
179#endif // HAVE_MUELU_AMESOS2
180#endif // MUELU_AMESOS2SMOOTHER_DECL_HPP
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode
#define MUELU_TPETRA_ETI_EXCEPTION(cl, obj, go)
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultGlobalOrdinal GlobalOrdinal
MueLu::DefaultNode Node
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply smoother.
std::string description() const
Return a simple one-line description of this object.
Amesos2Smoother(const std::string &type="", const Teuchos::ParameterList &paramList=Teuchos::ParameterList())
Class that encapsulates Amesos2 direct solvers.
void DeclareInput(Level &currentLevel) const
Input.
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
std::string type_
amesos2-specific key phrase that denote smoother type
RCP< SmootherPrototype > Copy() const
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.
Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > Tpetra_CrsMatrix
RCP< Projection< Scalar, LocalOrdinal, GlobalOrdinal, Node > > projection_
RCP< Amesos2::Solver< Tpetra_CrsMatrix, Tpetra_MultiVector > > prec_
pointer to Amesos2 solver object
Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > Tpetra_MultiVector
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
void Setup(Level &currentLevel)
Set up the direct solver. This creates the underlying Amesos2 solver object according to the paramete...
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply the direct solver. Solves the linear system AX=B using the constructed solver.
Class that holds all level-specific information.
void projectOut(Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X)
Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > localMap_
Teuchos::RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Nullspace_
Base class for smoother prototypes.
Namespace for MueLu classes and methods.