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>
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