46 #ifndef MUELU_SINGLELEVELMATLABFACTORY_DEF_HPP 47 #define MUELU_SINGLELEVELMATLABFACTORY_DEF_HPP 52 #include "MueLu_Aggregates.hpp" 53 #include "MueLu_AmalgamationInfo.hpp" 58 #ifdef HAVE_MUELU_MATLAB 63 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
65 : hasDeclaredInput_(false) { }
67 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
71 validParamList->set<std::string>(
"Provides" ,
"" ,
"A comma-separated list of objects provided by the SingleLevelMatlabFactory");
72 validParamList->set<std::string>(
"Needs" ,
"",
"A comma-separated list of objects needed by the SingleLevelMatlabFactory");
73 validParamList->set<std::string>(
"Function" ,
"" ,
"The name of the Matlab MEX function to call for Build()");
74 return validParamList;
77 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
80 const Teuchos::ParameterList& pL = GetParameterList();
83 for(
size_t i = 0; i < needs_.size(); i++)
86 this->Input(currentLevel, needs_[i]);
88 hasDeclaredInput_ =
true;
91 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
96 const Teuchos::ParameterList& pL = GetParameterList();
101 string needsList = pL.get<
string>(
"Needs");
102 vector<RCP<MuemexArg>> InputArgs = processNeeds<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
this, needsList, currentLevel);
103 string providesList = pL.get<std::string>(
"Provides");
106 string matlabFunction = pL.get<std::string>(
"Function");
107 if(!matlabFunction.length())
108 throw std::runtime_error(
"Invalid matlab function name");
109 vector<Teuchos::RCP<MuemexArg> > mexOutput =
callMatlab(matlabFunction, numProvides, InputArgs);
111 processProvides<Scalar, LocalOrdinal, GlobalOrdinal, Node>(mexOutput,
this, providesList, currentLevel);
114 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
116 std::ostringstream out;
117 const Teuchos::ParameterList& pL = GetParameterList();
118 out <<
"SingleLevelMatlabFactory["<<pL.get<std::string>(
"Function")<<
"]";
125 #define MUELU_SINGLELEVELMATLABFACTORY_SHORT 126 #endif // HAVE_MUELU_MATLAB 128 #endif // MUELU_SINGLELEVELMATLABFACTORY_DEF_HPP std::vector< std::string > tokenizeList(const std::string ¶ms)
void DeclareInput(Level ¤tLevel) const
Specifies the data that this class needs, and the factories that generate that data.
Timer to be used in factories. Similar to Monitor but with additional timers.
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
void Build(Level ¤tLevel) const
Build an object with this factory.
Namespace for MueLu classes and methods.
bool IsParamMuemexVariable(const std::string &name)
Teuchos::RCP< Teuchos::ParameterList > getInputParamList()
std::string description() const
@ name Description
Class that holds all level-specific information.
SingleLevelMatlabFactory()
std::vector< RCP< MuemexArg > > callMatlab(std::string function, int numOutputs, std::vector< RCP< MuemexArg >> args)