10 #ifndef MUELU_TWOLEVELMATLABFACTORY_DEF_HPP
11 #define MUELU_TWOLEVELMATLABFACTORY_DEF_HPP
16 #include "MueLu_Aggregates.hpp"
17 #include "MueLu_AmalgamationInfo.hpp"
23 #ifdef HAVE_MUELU_MATLAB
27 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
29 : hasDeclaredInput_(false) {}
31 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
34 validParamList->
set<std::string>(
"Provides",
"",
"A comma-separated list of objects provided on the coarse level by the TwoLevelMatlabFactory");
35 validParamList->
set<std::string>(
"Needs Fine",
"",
"A comma-separated list of objects needed on the fine level by the TwoLevelMatlabFactory");
36 validParamList->
set<std::string>(
"Needs Coarse",
"",
"A comma-separated list of objects needed on the coarse level by the TwoLevelMatlabFactory");
37 validParamList->
set<std::string>(
"Function",
"",
"The name of the Matlab MEX function to call for Build()");
38 return validParamList;
41 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
46 const std::string str_nf = pL.get<std::string>(
"Needs Fine");
47 const std::string str_nc = pL.get<std::string>(
"Needs Coarse");
50 for (
auto fineNeed : needsFine_) {
52 this->Input(fineLevel, fineNeed);
54 for (
auto coarseNeed : needsCoarse_) {
56 this->Input(coarseLevel, coarseNeed);
58 hasDeclaredInput_ =
true;
61 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
69 string needsFine = pL.
get<
string>(
"Needs Fine");
70 string needsCoarse = pL.
get<
string>(
"Needs Coarse");
71 vector<RCP<MuemexArg>> InputArgs = processNeeds<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
this, needsFine, fineLevel);
72 vector<RCP<MuemexArg>> InputArgsCoarse = processNeeds<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
this, needsCoarse, coarseLevel);
74 InputArgs.reserve(InputArgs.size() + InputArgsCoarse.size());
75 InputArgs.insert(InputArgs.begin(), InputArgsCoarse.begin(), InputArgsCoarse.end());
78 string provides = pL.
get<
string>(
"Provides");
81 string matlabFunction = pL.
get<
string>(
"Function");
82 if (!matlabFunction.length())
83 throw runtime_error(
"Invalid matlab function name");
84 vector<RCP<MuemexArg>> mexOutput =
callMatlab(matlabFunction, numProvides, InputArgs);
85 processProvides<Scalar, LocalOrdinal, GlobalOrdinal, Node>(mexOutput,
this, provides, coarseLevel);
88 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
90 std::ostringstream out;
92 out <<
"TwoLevelMatlabFactory[" << pL.
get<std::string>(
"Function") <<
"]";
98 #endif // HAVE_MUELU_MATLAB
100 #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)
Timer to be used in factories. Similar to Monitor but with additional timers.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
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.