10#ifndef MUELU_TWOLEVELMATLABFACTORY_DEF_HPP
11#define MUELU_TWOLEVELMATLABFACTORY_DEF_HPP
12#include <Xpetra_Matrix.hpp>
13#include <Xpetra_MultiVector.hpp>
16#include "MueLu_Aggregates.hpp"
17#include "MueLu_AmalgamationInfo.hpp"
23#ifdef HAVE_MUELU_MATLAB
27template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
31template <
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;
41template <
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");
52 this->
Input(fineLevel, fineNeed);
56 this->
Input(coarseLevel, coarseNeed);
61template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
69 string needsFine = pL.get<
string>(
"Needs Fine");
70 string needsCoarse = pL.get<
string>(
"Needs Coarse");
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);
88template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
90 std::ostringstream out;
92 out <<
"TwoLevelMatlabFactory[" << pL.get<std::string>(
"Function") <<
"]";
Timer to be used in factories. Similar to Monitor but with additional timers.
void Input(Level &level, const std::string &varName) const
Class that holds all level-specific information.
virtual const Teuchos::ParameterList & GetParameterList() const
std::string description() const
@ name Description
std::vector< std::string > needsCoarse_
List of arguments to the MATLAB function, in order. These args must correspond to MueLu "Needs" objec...
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
void Build(Level &fineLevel, Level &coarseLevel) const
Build an object with this factory.
std::vector< std::string > needsFine_
List of arguments to the MATLAB function, in order. These args must correspond to MueLu "Needs" objec...
void DeclareInput(Level &fineLevel, Level &coarseLevel) const
Input.
Namespace for MueLu classes and methods.
bool IsParamMuemexVariable(const std::string &name)
Teuchos::RCP< Teuchos::ParameterList > getInputParamList()
std::vector< RCP< MuemexArg > > callMatlab(std::string function, int numOutputs, std::vector< RCP< MuemexArg > > args)
std::vector< Teuchos::RCP< MuemexArg > > processNeeds(const Factory *factory, std::string &needsParam, Level &lvl)
void processProvides(std::vector< Teuchos::RCP< MuemexArg > > &mexOutput, const Factory *factory, std::string &providesParam, Level &lvl)
std::vector< std::string > tokenizeList(const std::string ¶ms)