46 #ifndef MUELU_SINGLELEVELMATLABFACTORY_DEF_HPP
47 #define MUELU_SINGLELEVELMATLABFACTORY_DEF_HPP
48 #include <Xpetra_Matrix.hpp>
49 #include <Xpetra_MultiVector.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>
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>
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;
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 Build(Level ¤tLevel) const
Build an object with this factory.
std::string description() const
@ name Description
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()
std::vector< RCP< MuemexArg > > callMatlab(std::string function, int numOutputs, std::vector< RCP< MuemexArg >> args)