9#ifndef MUELU_MATLABSMOOTHER_DEF_HPP
10#define MUELU_MATLABSMOOTHER_DEF_HPP
14#if defined(HAVE_MUELU_MATLAB)
19template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
24template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
33template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
36 this->
Input(currentLevel,
"A");
40 for (
size_t i = 0; i < needsList.size(); i++) {
42 this->
Input(currentLevel, needsList[i]);
46template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
51 this->
GetOStream(
Warnings0) <<
"MueLu::MatlabSmoother::Setup(): Setup() has already been called";
54 RCP<MuemexArg> AmatArg = rcp_implicit_cast<MuemexArg>(rcp(
new MuemexData<RCP<Matrix>>(
A_)));
56 InputArgs.insert(InputArgs.begin(), AmatArg);
59 throw runtime_error(
"Invalid matlab function name");
65template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
68 "MueLu::MatlabSmoother::Apply(): Setup() has not been called");
71 if (InitialGuessIsZero)
74 vector<RCP<MuemexArg>> InputArgs;
75 InputArgs.push_back(rcp(
new MuemexData<RCP<Matrix>>(
A_)));
77 RCP<MultiVector> Xrcp(&X,
false);
78 MultiVector* BPtrNonConst = (MultiVector*)&B;
79 RCP<MultiVector> Brcp = rcp<MultiVector>(BPtrNonConst,
false);
80 RCP<MuemexData<RCP<MultiVector>>> XData = rcp(
new MuemexData<RCP<MultiVector>>(Xrcp));
81 RCP<MuemexData<RCP<MultiVector>>> BData = rcp(
new MuemexData<RCP<MultiVector>>(Brcp));
82 InputArgs.push_back(XData);
83 InputArgs.push_back(BData);
86 if (!
solveFunction_.length())
throw std::runtime_error(
"Invalid matlab function name");
88 RCP<MuemexData<RCP<MultiVector>>> mydata = Teuchos::rcp_static_cast<MuemexData<RCP<MultiVector>>>(mexOutput[0]);
89 X = *(mydata->getData());
92template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
99template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
101 std::ostringstream out;
110template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
118 out0 <<
"Parameter list: " << std::endl;
119 Teuchos::OSTab tab2(out);
123 if (verbLevel &
Debug) {
#define MUELU_DESCRIBE
Helper macro for implementing Describable::describe() for BaseClass objects.
virtual std::string description() const
Return a simple one-line description of this object.
Exception throws to report errors in the internal logical of the program.
Timer to be used in factories. Similar to Monitor but with additional timers.
void Input(Level &level, const std::string &varName) const
T Get(Level &level, const std::string &varName) const
Class that holds all level-specific information.
std::string solveFunction_
Matlab solve function.
void DeclareInput(Level ¤tLevel) const
Input.
std::string needsSetup_
List of arguments to the MATLAB setup function besides "A", in order.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
void Setup(Level ¤tLevel)
Set up the smoother.
size_t solveDataSize_
Amount of solve data (besides A, LHS & RHS).
RCP< SmootherPrototype > Copy() const
RCP< Matrix > A_
Matrix, (maybe) used in apply.
friend class MatlabSmoother
Constructor.
std::vector< Teuchos::RCP< MuemexArg > > solveData_
List of data generated by setup which will be sent to solve after "A", "LHS" and "RHS".
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply the preconditioner.
std::string setupFunction_
Matlab setup function.
void SetParameterList(const Teuchos::ParameterList ¶mList)
Set parameters from a parameter list and return with default values.
std::string description() const
Return a simple one-line description of this object.
virtual const Teuchos::ParameterList & GetParameterList() const
virtual void SetParameterList(const Teuchos::ParameterList ¶mList)=0
Set parameters from a parameter list and return with default values.
bool IsSetup() const
Get the state of a smoother prototype.
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
Namespace for MueLu classes and methods.
bool IsParamMuemexVariable(const std::string &name)
@ Warnings0
Important warning messages (one line).
@ Debug
Print additional debugging information.
@ Statistics1
Print more statistics.
@ Parameters0
Print class parameters.
@ Parameters1
Print class parameters (more parameters, more verbose).
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)
std::vector< std::string > tokenizeList(const std::string ¶ms)