11 #ifndef MUELU_MATLABSMOOTHER_DEF_HPP
12 #define MUELU_MATLABSMOOTHER_DEF_HPP
15 #if defined(HAVE_MUELU_MATLAB)
20 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
22 SetParameterList(paramList);
25 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
29 setupFunction_ = pL.
get(
"Setup Function",
"");
30 solveFunction_ = pL.
get(
"Solve Function",
"");
31 solveDataSize_ = pL.
get(
"Number of Solver Args", 0);
34 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
37 this->Input(currentLevel,
"A");
39 needsSetup_ = pL.
get<
string>(
"Needs");
41 for (
size_t i = 0; i < needsList.size(); i++) {
43 this->Input(currentLevel, needsList[i]);
47 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
51 if (this->IsSetup() ==
true)
52 this->GetOStream(
Warnings0) <<
"MueLu::MatlabSmoother::Setup(): Setup() has already been called";
53 vector<RCP<MuemexArg>> InputArgs = processNeeds<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
this, needsSetup_, currentLevel);
54 A_ = Factory::Get<RCP<Matrix>>(currentLevel,
"A");
57 InputArgs.insert(InputArgs.begin(), AmatArg);
59 if (!setupFunction_.length())
60 throw runtime_error(
"Invalid matlab function name");
61 solveData_ =
callMatlab(setupFunction_, solveDataSize_, InputArgs);
62 this->GetOStream(
Statistics1) << description() << endl;
66 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
69 "MueLu::MatlabSmoother::Apply(): Setup() has not been called");
70 using namespace Teuchos;
72 if (InitialGuessIsZero)
75 vector<RCP<MuemexArg>> InputArgs;
79 MultiVector* BPtrNonConst = (MultiVector*)&B;
83 InputArgs.push_back(XData);
84 InputArgs.push_back(BData);
85 for (
size_t i = 0; i < solveData_.size(); i++)
86 InputArgs.push_back(solveData_[i]);
87 if (!solveFunction_.length())
throw std::runtime_error(
"Invalid matlab function name");
88 vector<Teuchos::RCP<MuemexArg>> mexOutput =
callMatlab(solveFunction_, 1, InputArgs);
90 X = *(mydata->getData());
93 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
96 smoother->SetParameterList(this->GetParameterList());
100 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
102 std::ostringstream out;
104 out <<
"Matlab Smoother(" << setupFunction_ <<
"/" << solveFunction_ <<
")";
111 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
116 out <<
"Matlab Smoother(" << setupFunction_ <<
"/" << solveFunction_ <<
")";
119 out0 <<
"Parameter list: " << std::endl;
121 out << this->GetParameterList();
124 if (verbLevel &
Debug) {
150 #endif // HAVE_MUELU_MATLAB
151 #endif // MUELU_MATLABSMOOTHER_DEF_HPP
Important warning messages (one line)
void SetParameterList(const Teuchos::ParameterList ¶mList)
Set parameters from a parameter list and return with default values.
void DeclareInput(Level ¤tLevel) const
Input.
std::vector< std::string > tokenizeList(const std::string ¶ms)
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply the preconditioner.
RCP< SmootherPrototype > Copy() const
std::vector< RCP< MuemexArg > > callMatlab(std::string function, int numOutputs, std::vector< RCP< MuemexArg > > args)
T & get(const std::string &name, T def_value)
Timer to be used in factories. Similar to Monitor but with additional timers.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void Setup(Level ¤tLevel)
Set up the smoother.
Print additional debugging information.
bool IsParamMuemexVariable(const std::string &name)
virtual void SetParameterList(const Teuchos::ParameterList ¶mList)
Set parameters from a parameter list and return with default values.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Class that holds all level-specific information.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
bool IsSetup() const
Get the state of a smoother prototype.
#define MUELU_DESCRIBE
Helper macro for implementing Describable::describe() for BaseClass objects.
friend class MatlabSmoother
Constructor.
Class that encapsulates Matlab smoothers.
std::string description() const
Return a simple one-line description of this object.
Print class parameters (more parameters, more verbose)
Exception throws to report errors in the internal logical of the program.
virtual std::string description() const
Return a simple one-line description of this object.
std::string toString(const T &t)