MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_MatlabSmoother_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_MATLABSMOOTHER_DECL_HPP
11#define MUELU_MATLABSMOOTHER_DECL_HPP
12
13#include <Teuchos_ParameterList.hpp>
14#include <Xpetra_Matrix_fwd.hpp>
15#include "MueLu_ConfigDefs.hpp"
16
17#if defined(HAVE_MUELU_MATLAB)
18#include <Tpetra_CrsMatrix.hpp>
19#include "MueLu_SmootherPrototype.hpp"
22
23namespace MueLu {
24
34template <class Scalar = SmootherPrototype<>::scalar_type,
38class MatlabSmoother : public SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
39#undef MUELU_MATLABSMOOTHER_SHORT
41
42 public:
44
45 // TODO: update doc for Matlab.
52#ifndef _MSC_VER
53 // Avoid error C3772: invalid friend template declaration
54 template <class Scalar2, class LocalOrdinal2, class GlobalOrdinal2, class Node2>
55 friend class MatlabSmoother;
56#endif
57
58 MatlabSmoother(const Teuchos::ParameterList& paramList = Teuchos::ParameterList());
59
61 virtual ~MatlabSmoother() {}
62
64
65 void SetParameterList(const Teuchos::ParameterList& paramList);
66
68
69
70 void DeclareInput(Level& currentLevel) const;
71
73
75
76
84 void Setup(Level& currentLevel);
85
94 void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const;
95
97
99
100
101 RCP<SmootherPrototype> Copy() const;
102
104
106 template <typename Node2>
107 RCP<MueLu::MatlabSmoother<Scalar, LocalOrdinal, GlobalOrdinal, Node2> >
108 clone(const RCP<Node2>& node2, const Teuchos::RCP<const Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node2> >& A_newnode) const;
109
111
112
114 std::string description() const;
115
117 // using MueLu::Describable::describe; // overloading, not hiding
118 // void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const
119 void print(Teuchos::FancyOStream& out, const VerbLevel verbLevel = Default) const;
120
121 size_t getNodeSmootherComplexity() const { return Teuchos::OrdinalTraits<size_t>::invalid(); }
122
124
125 private:
127 mutable std::string needsSetup_;
128
131
133 std::vector<Teuchos::RCP<MuemexArg> > solveData_;
134
136 std::string setupFunction_;
137
139 std::string solveFunction_;
140
142 mutable RCP<Matrix> A_;
143
144}; // class MatlabSmoother
145
146template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
147template <typename Node2>
148RCP<MueLu::MatlabSmoother<Scalar, LocalOrdinal, GlobalOrdinal, Node2> >
149MatlabSmoother<Scalar, LocalOrdinal, GlobalOrdinal, Node>::clone(const RCP<Node2>& node2, const RCP<const Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node2> >& A_newnode) const {
150 const ParameterList& paramList = this->GetParameterList();
151
152 RCP<MatlabSmoother<Scalar, LocalOrdinal, GlobalOrdinal, Node2> > cloneSmoother =
154
155 cloneSmoother->needsSetup_ = needsSetup_;
156 cloneSmoother->setupFunction_ = setupFunction_;
157 cloneSmoother->solveFunction_ = solveFunction_;
158 cloneSmoother->A_ = A_;
159
160 for (size_t i = 0; i < solveData_.size(); i++)
161 cloneSmoother->solveData_->push_back(solveData_[i]);
162 cloneSmoother->SetParameterList(paramList);
163 cloneSmoother->IsSetup(this->IsSetup());
164 return cloneSmoother;
165}
166
167} // namespace MueLu
168
169#define MUELU_MATLABSMOOTHER_SHORT
170#endif // HAVE_MUELU_MATLAB
171#endif // MUELU_MATLABSMOOTHER_DECL_HPP
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultGlobalOrdinal GlobalOrdinal
MueLu::DefaultNode Node
Class that holds all level-specific information.
Class that encapsulates Matlab smoothers.
virtual ~MatlabSmoother()
Destructor.
std::string solveFunction_
Matlab solve function.
void DeclareInput(Level &currentLevel) const
Input.
size_t getNodeSmootherComplexity() const
Compute a rough estimate of the cost to apply this smoother on this MPI rank. Return Teuchos::Ordinal...
std::string needsSetup_
List of arguments to the MATLAB setup function besides "A", in order.
RCP< MueLu::MatlabSmoother< Scalar, LocalOrdinal, GlobalOrdinal, Node2 > > clone(const RCP< Node2 > &node2, const Teuchos::RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node2 > > &A_newnode) const
Clone the smoother to a different node type.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
void Setup(Level &currentLevel)
Set up the smoother.
size_t solveDataSize_
Amount of solve data (besides A, LHS & RHS)
RCP< SmootherPrototype > Copy() const
RCP< Matrix > A_
Matrix, (maybe) used in apply.
friend class MatlabSmoother
Constructor.
std::vector< Teuchos::RCP< MuemexArg > > solveData_
List of data generated by setup which will be sent to solve after "A", "LHS" and "RHS".
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply the preconditioner.
std::string setupFunction_
Matlab setup function.
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.
Base class for smoother prototypes.
Namespace for MueLu classes and methods.