46 #ifndef MUELU_TWOLEVELMATLABFACTORY_DEF_HPP
47 #define MUELU_TWOLEVELMATLABFACTORY_DEF_HPP
52 #include "MueLu_Aggregates.hpp"
53 #include "MueLu_AmalgamationInfo.hpp"
59 #ifdef HAVE_MUELU_MATLAB
64 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
66 : hasDeclaredInput_(false) {}
68 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
71 validParamList->
set<std::string>(
"Provides",
"",
"A comma-separated list of objects provided on the coarse level by the TwoLevelMatlabFactory");
72 validParamList->
set<std::string>(
"Needs Fine",
"",
"A comma-separated list of objects needed on the fine level by the TwoLevelMatlabFactory");
73 validParamList->
set<std::string>(
"Needs Coarse",
"",
"A comma-separated list of objects needed on the coarse level by the TwoLevelMatlabFactory");
74 validParamList->
set<std::string>(
"Function",
"",
"The name of the Matlab MEX function to call for Build()");
75 return validParamList;
78 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
83 const std::string str_nf = pL.get<std::string>(
"Needs Fine");
84 const std::string str_nc = pL.get<std::string>(
"Needs Coarse");
87 for (
auto fineNeed : needsFine_) {
89 this->Input(fineLevel, fineNeed);
91 for (
auto coarseNeed : needsCoarse_) {
93 this->Input(coarseLevel, coarseNeed);
95 hasDeclaredInput_ =
true;
98 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
106 string needsFine = pL.
get<
string>(
"Needs Fine");
107 string needsCoarse = pL.
get<
string>(
"Needs Coarse");
108 vector<RCP<MuemexArg>> InputArgs = processNeeds<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
this, needsFine, fineLevel);
109 vector<RCP<MuemexArg>> InputArgsCoarse = processNeeds<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
this, needsCoarse, coarseLevel);
111 InputArgs.reserve(InputArgs.size() + InputArgsCoarse.size());
112 InputArgs.insert(InputArgs.begin(), InputArgsCoarse.begin(), InputArgsCoarse.end());
115 string provides = pL.
get<
string>(
"Provides");
118 string matlabFunction = pL.
get<
string>(
"Function");
119 if (!matlabFunction.length())
120 throw runtime_error(
"Invalid matlab function name");
121 vector<RCP<MuemexArg>> mexOutput =
callMatlab(matlabFunction, numProvides, InputArgs);
122 processProvides<Scalar, LocalOrdinal, GlobalOrdinal, Node>(mexOutput,
this, provides, coarseLevel);
125 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
127 std::ostringstream out;
129 out <<
"TwoLevelMatlabFactory[" << pL.
get<std::string>(
"Function") <<
"]";
135 #define MUELU_TWOLEVELMATLABFACTORY_SHORT
136 #endif // HAVE_MUELU_MATLAB
138 #endif // MUELU_TWOLEVELMATLABFACTORY_DEF_HPP
std::vector< std::string > tokenizeList(const std::string ¶ms)
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
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.
bool IsParamMuemexVariable(const std::string &name)
void DeclareInput(Level &fineLevel, Level &coarseLevel) const
Input.
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.
std::string description() const
@ name Description
void Build(Level &fineLevel, Level &coarseLevel) const
Build an object with this factory.