10 #ifndef MUELU_SINGLELEVELMATLABFACTORY_DEF_HPP
11 #define MUELU_SINGLELEVELMATLABFACTORY_DEF_HPP
16 #include "MueLu_Aggregates.hpp"
17 #include "MueLu_AmalgamationInfo.hpp"
21 #ifdef HAVE_MUELU_MATLAB
25 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
27 : hasDeclaredInput_(false) {}
29 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
32 validParamList->
set<std::string>(
"Provides",
"",
"A comma-separated list of objects provided by the SingleLevelMatlabFactory");
33 validParamList->
set<std::string>(
"Needs",
"",
"A comma-separated list of objects needed by the SingleLevelMatlabFactory");
34 validParamList->
set<std::string>(
"Function",
"",
"The name of the Matlab MEX function to call for Build()");
35 return validParamList;
38 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
43 for (
size_t i = 0; i < needs_.size(); i++) {
45 this->Input(currentLevel, needs_[i]);
47 hasDeclaredInput_ =
true;
50 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
58 string needsList = pL.
get<
string>(
"Needs");
59 vector<RCP<MuemexArg>> InputArgs = processNeeds<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
this, needsList, currentLevel);
60 string providesList = pL.
get<std::string>(
"Provides");
63 string matlabFunction = pL.
get<std::string>(
"Function");
64 if (!matlabFunction.length())
65 throw std::runtime_error(
"Invalid matlab function name");
66 vector<Teuchos::RCP<MuemexArg>> mexOutput =
callMatlab(matlabFunction, numProvides, InputArgs);
68 processProvides<Scalar, LocalOrdinal, GlobalOrdinal, Node>(mexOutput,
this, providesList, currentLevel);
71 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
73 std::ostringstream out;
75 out <<
"SingleLevelMatlabFactory[" << pL.
get<std::string>(
"Function") <<
"]";
81 #endif // HAVE_MUELU_MATLAB
83 #endif // MUELU_SINGLELEVELMATLABFACTORY_DEF_HPP
std::vector< std::string > tokenizeList(const std::string ¶ms)
void Build(Level ¤tLevel) const
Build an object with this factory.
std::string description() const
@ name Description
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.
void DeclareInput(Level ¤tLevel) const
Specifies the data that this class needs, and the factories that generate that data.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
bool IsParamMuemexVariable(const std::string &name)
Teuchos::RCP< Teuchos::ParameterList > getInputParamList()
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Class that holds all level-specific information.
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
SingleLevelMatlabFactory()