46 #ifndef MUELU_SINGLELEVELMATLABFACTORY_DEF_HPP
47 #define MUELU_SINGLELEVELMATLABFACTORY_DEF_HPP
52 #include "MueLu_Aggregates.hpp"
53 #include "MueLu_AmalgamationInfo.hpp"
57 #ifdef HAVE_MUELU_MATLAB
62 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
64 : hasDeclaredInput_(false) {}
66 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
69 validParamList->
set<std::string>(
"Provides",
"",
"A comma-separated list of objects provided by the SingleLevelMatlabFactory");
70 validParamList->
set<std::string>(
"Needs",
"",
"A comma-separated list of objects needed by the SingleLevelMatlabFactory");
71 validParamList->
set<std::string>(
"Function",
"",
"The name of the Matlab MEX function to call for Build()");
72 return validParamList;
75 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
80 for (
size_t i = 0; i < needs_.size(); i++) {
82 this->Input(currentLevel, needs_[i]);
84 hasDeclaredInput_ =
true;
87 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
95 string needsList = pL.
get<
string>(
"Needs");
96 vector<RCP<MuemexArg>> InputArgs = processNeeds<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
this, needsList, currentLevel);
97 string providesList = pL.
get<std::string>(
"Provides");
100 string matlabFunction = pL.
get<std::string>(
"Function");
101 if (!matlabFunction.length())
102 throw std::runtime_error(
"Invalid matlab function name");
103 vector<Teuchos::RCP<MuemexArg>> mexOutput =
callMatlab(matlabFunction, numProvides, InputArgs);
105 processProvides<Scalar, LocalOrdinal, GlobalOrdinal, Node>(mexOutput,
this, providesList, currentLevel);
108 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
110 std::ostringstream out;
112 out <<
"SingleLevelMatlabFactory[" << pL.
get<std::string>(
"Function") <<
"]";
118 #define MUELU_SINGLELEVELMATLABFACTORY_SHORT
119 #endif // HAVE_MUELU_MATLAB
121 #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)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
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.
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()