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
26 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
28 : hasDeclaredInput_(false) {}
30 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
33 validParamList->
set<std::string>(
"Provides",
"",
"A comma-separated list of objects provided by the SingleLevelMatlabFactory");
34 validParamList->
set<std::string>(
"Needs",
"",
"A comma-separated list of objects needed by the SingleLevelMatlabFactory");
35 validParamList->
set<std::string>(
"Function",
"",
"The name of the Matlab MEX function to call for Build()");
36 return validParamList;
39 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
44 for (
size_t i = 0; i < needs_.size(); i++) {
46 this->Input(currentLevel, needs_[i]);
48 hasDeclaredInput_ =
true;
51 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
59 string needsList = pL.
get<
string>(
"Needs");
60 vector<RCP<MuemexArg>> InputArgs = processNeeds<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
this, needsList, currentLevel);
61 string providesList = pL.
get<std::string>(
"Provides");
64 string matlabFunction = pL.
get<std::string>(
"Function");
65 if (!matlabFunction.length())
66 throw std::runtime_error(
"Invalid matlab function name");
67 vector<Teuchos::RCP<MuemexArg>> mexOutput =
callMatlab(matlabFunction, numProvides, InputArgs);
69 processProvides<Scalar, LocalOrdinal, GlobalOrdinal, Node>(mexOutput,
this, providesList, currentLevel);
72 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
74 std::ostringstream out;
76 out <<
"SingleLevelMatlabFactory[" << pL.
get<std::string>(
"Function") <<
"]";
82 #define MUELU_SINGLELEVELMATLABFACTORY_SHORT
83 #endif // HAVE_MUELU_MATLAB
85 #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()