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
28 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
30 : hasDeclaredInput_(false) {}
32 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
35 validParamList->
set<std::string>(
"Provides",
"",
"A comma-separated list of objects provided on the coarse level by the TwoLevelMatlabFactory");
36 validParamList->
set<std::string>(
"Needs Fine",
"",
"A comma-separated list of objects needed on the fine level by the TwoLevelMatlabFactory");
37 validParamList->
set<std::string>(
"Needs Coarse",
"",
"A comma-separated list of objects needed on the coarse level by the TwoLevelMatlabFactory");
38 validParamList->
set<std::string>(
"Function",
"",
"The name of the Matlab MEX function to call for Build()");
39 return validParamList;
42 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
47 const std::string str_nf = pL.get<std::string>(
"Needs Fine");
48 const std::string str_nc = pL.get<std::string>(
"Needs Coarse");
51 for (
auto fineNeed : needsFine_) {
53 this->Input(fineLevel, fineNeed);
55 for (
auto coarseNeed : needsCoarse_) {
57 this->Input(coarseLevel, coarseNeed);
59 hasDeclaredInput_ =
true;
62 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
70 string needsFine = pL.
get<
string>(
"Needs Fine");
71 string needsCoarse = pL.
get<
string>(
"Needs Coarse");
72 vector<RCP<MuemexArg>> InputArgs = processNeeds<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
this, needsFine, fineLevel);
73 vector<RCP<MuemexArg>> InputArgsCoarse = processNeeds<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
this, needsCoarse, coarseLevel);
75 InputArgs.reserve(InputArgs.size() + InputArgsCoarse.size());
76 InputArgs.insert(InputArgs.begin(), InputArgsCoarse.begin(), InputArgsCoarse.end());
79 string provides = pL.
get<
string>(
"Provides");
82 string matlabFunction = pL.
get<
string>(
"Function");
83 if (!matlabFunction.length())
84 throw runtime_error(
"Invalid matlab function name");
85 vector<RCP<MuemexArg>> mexOutput =
callMatlab(matlabFunction, numProvides, InputArgs);
86 processProvides<Scalar, LocalOrdinal, GlobalOrdinal, Node>(mexOutput,
this, provides, coarseLevel);
89 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
91 std::ostringstream out;
93 out <<
"TwoLevelMatlabFactory[" << pL.
get<std::string>(
"Function") <<
"]";
99 #define MUELU_TWOLEVELMATLABFACTORY_SHORT
100 #endif // HAVE_MUELU_MATLAB
102 #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.