MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
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 
23 namespace MueLu {
24 
34 template <class Scalar = SmootherPrototype<>::scalar_type,
35  class LocalOrdinal = typename SmootherPrototype<Scalar>::local_ordinal_type,
36  class GlobalOrdinal = typename SmootherPrototype<Scalar, LocalOrdinal>::global_ordinal_type,
37  class Node = typename SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal>::node_type>
38 class MatlabSmoother : public SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
39 #undef MUELU_MATLABSMOOTHER_SHORT
40 #include "MueLu_UseShortNames.hpp"
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 
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 
102 
104 
106  template <typename 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 
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 
146 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
147 template <typename Node2>
150  const ParameterList& paramList = this->GetParameterList();
151 
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
void SetParameterList(const Teuchos::ParameterList &paramList)
Set parameters from a parameter list and return with default values.
void DeclareInput(Level &currentLevel) const
Input.
MueLu::DefaultLocalOrdinal LocalOrdinal
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply the preconditioner.
RCP< SmootherPrototype > Copy() const
size_t solveDataSize_
Amount of solve data (besides A, LHS &amp; RHS)
std::vector< Teuchos::RCP< MuemexArg > > solveData_
List of data generated by setup which will be sent to solve after &quot;A&quot;, &quot;LHS&quot; and &quot;RHS&quot;.
void Setup(Level &currentLevel)
Set up the smoother.
MueLu::DefaultNode Node
RCP< Matrix > A_
Matrix, (maybe) used in apply.
virtual ~MatlabSmoother()
Destructor.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Class that holds all level-specific information.
Definition: MueLu_Level.hpp:63
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
std::string setupFunction_
Matlab setup function.
friend class MatlabSmoother
Constructor.
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.
std::string solveFunction_
Matlab solve function.
Class that encapsulates Matlab smoothers.
std::string description() const
Return a simple one-line description of this object.
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 &quot;A&quot;, in order.