47 #ifndef MUELU_MATLABSMOOTHER_DEF_HPP
48 #define MUELU_MATLABSMOOTHER_DEF_HPP
51 #if defined(HAVE_MUELU_TPETRA) && defined(HAVE_MUELU_MATLAB)
57 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
60 SetParameterList(paramList);
63 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
67 ParameterList& pL = const_cast<ParameterList&>(this->GetParameterList());
68 setupFunction_ = pL.get(
"Setup Function",
"");
69 solveFunction_ = pL.get(
"Solve Function",
"");
70 solveDataSize_ = pL.get(
"Number of Solver Args", 0);
73 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
77 this->Input(currentLevel,
"A");
78 ParameterList& pL = const_cast<ParameterList&>(this->GetParameterList());
79 needsSetup_ = pL.get<
string>(
"Needs");
81 for(
size_t i = 0; i < needsList.size(); i++)
84 this->Input(currentLevel, needsList[i]);
88 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
93 if (this->IsSetup() ==
true)
94 this->GetOStream(
Warnings0) <<
"MueLu::MatlabSmoother::Setup(): Setup() has already been called";
95 vector<RCP<MuemexArg>> InputArgs = processNeeds<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
this, needsSetup_, currentLevel);
96 A_ = Factory::Get<RCP<Matrix>>(currentLevel,
"A");
97 RCP<MuemexArg> AmatArg = rcp_implicit_cast<MuemexArg>(rcp(
new MuemexData<RCP<Matrix>>(A_)));
99 InputArgs.insert(InputArgs.begin(), AmatArg);
101 if(!setupFunction_.length())
102 throw runtime_error(
"Invalid matlab function name");
103 solveData_=
callMatlab(setupFunction_, solveDataSize_, InputArgs);
104 this->GetOStream(
Statistics1) << description() << endl;
108 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
115 vector<RCP<MuemexArg>> InputArgs;
116 InputArgs.push_back(rcp(
new MuemexData<RCP<Matrix>>(A_)));
118 RCP<MultiVector> Xrcp(&X,
false);
119 MultiVector* BPtrNonConst = (MultiVector*) &B;
120 RCP<MultiVector> Brcp = rcp<MultiVector>(BPtrNonConst,
false);
121 RCP<MuemexData<RCP<MultiVector>>> XData = rcp(
new MuemexData<RCP<MultiVector>>(Xrcp));
122 RCP<MuemexData<RCP<MultiVector>>> BData = rcp(
new MuemexData<RCP<MultiVector>>(Brcp));
123 InputArgs.push_back(XData);
124 InputArgs.push_back(BData);
125 for(
size_t i = 0; i < solveData_.size(); i++)
126 InputArgs.push_back(solveData_[i]);
127 if(!solveFunction_.length())
throw std::runtime_error(
"Invalid matlab function name");
128 vector<Teuchos::RCP<MuemexArg>> mexOutput =
callMatlab(solveFunction_, 1, InputArgs);
130 X = *(mydata->getData());
133 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
137 smoother->SetParameterList(this->GetParameterList());
141 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
143 std::ostringstream out;
145 out <<
"Matlab Smoother("<<setupFunction_<<
"/"<<solveFunction_<<
")";
152 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
157 out <<
"Matlab Smoother("<<setupFunction_<<
"/"<<solveFunction_<<
")";
160 out0 <<
"Parameter list: " << std::endl;
161 Teuchos::OSTab tab2(out);
162 out << this->GetParameterList();
165 if (verbLevel &
Debug) {
193 #endif // HAVE_MUELU_TPETRA && HAVE_MUELU_MATLAB
194 #endif // MUELU_MATLABSMOOTHER_DEF_HPP