46 #ifndef MUELU_SMOOTHERFACTORY_DEF_HPP
47 #define MUELU_SMOOTHERFACTORY_DEF_HPP
53 #include "MueLu_SmootherPrototype.hpp"
54 #include "MueLu_Ifpack2Smoother.hpp"
59 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
61 SetSmootherPrototypes(preAndPostSmootherPrototype);
64 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
67 SetSmootherPrototypes(preSmootherPrototype, postSmootherPrototype);
70 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
72 preSmootherPrototype_ = postSmootherPrototype_ = preAndPostSmootherPrototype;
76 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
79 preSmootherPrototype_ = preSmootherPrototype;
80 postSmootherPrototype_ = postSmootherPrototype;
84 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
88 validParamList->
set<
bool>(
"keep smoother data",
false,
"Keep constructed smoothers for later reuse");
93 return validParamList;
96 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
104 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
107 preSmootherPrototype = preSmootherPrototype_;
108 postSmootherPrototype = postSmootherPrototype_;
111 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
113 if (preSmootherPrototype_ != Teuchos::null)
114 preSmootherPrototype_->DeclareInput(currentLevel);
116 if ((postSmootherPrototype_ != Teuchos::null) && (preSmootherPrototype_ != postSmootherPrototype_))
117 postSmootherPrototype_->DeclareInput(currentLevel);
120 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
122 return BuildSmoother(currentLevel,
BOTH);
125 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
152 if ((preOrPost &
PRE) && !preSmootherPrototype_.is_null()) {
154 if (currentLevel.
IsAvailable(
"PreSmoother data",
this))
157 preSmoother = preSmootherPrototype_->
Copy();
163 preSmoother->
Setup(currentLevel);
171 if (pL.
get<
bool>(
"keep smoother data"))
172 Set(currentLevel,
"PreSmoother data", preSmoother);
175 if ((preOrPost &
POST) && !postSmootherPrototype_.is_null()) {
176 if (preOrPost ==
BOTH && preSmootherPrototype_ == postSmootherPrototype_) {
179 postSmoother = preSmoother;
207 if (currentLevel.
IsAvailable(
"PostSmoother data",
this)) {
213 postSmoother = postSmootherPrototype_->
Copy();
220 postSmoother->
Setup(currentLevel);
229 if (pL.
get<
bool>(
"keep smoother data"))
230 Set(currentLevel,
"PostSmoother data", preSmoother);
234 if (postSmoother == preSmoother && !preSmoother.
is_null()) {
239 paramList.
sublist(
"presmoother",
false) = preSmootherParams;
242 paramList.
sublist(
"postsmoother",
false) = postSmootherParams;
247 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
249 std::ostringstream out;
251 std::string preStr = (preSmootherPrototype_ == Teuchos::null) ?
"null" : preSmootherPrototype_->description();
252 std::string postStr = (preSmootherPrototype_ == postSmootherPrototype_) ?
"pre" : ( (postSmootherPrototype_ == Teuchos::null) ?
"null" : postSmootherPrototype_->description() );
253 out <<
"{pre = " << preStr <<
", post = "<< postStr <<
"}";
257 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
262 out0 <<
"PreSmoother : ";
263 if (preSmootherPrototype_.is_null()) {
264 out0 <<
"null" << std::endl;
267 preSmootherPrototype_->describe(out, verbLevel);
270 out0 <<
"PostSmoother: ";
271 if (postSmootherPrototype_ == preSmootherPrototype_) { out0 <<
"same as PreSmoother" << std::endl; }
272 else if (postSmootherPrototype_ == Teuchos::null) { out0 <<
"null" << std::endl; }
275 postSmootherPrototype_->describe(out, verbLevel);
276 out0 <<
"PostSmoother is different than PreSmoother (not the same object)" << std::endl;
280 if (verbLevel &
Debug) {
281 if (preSmootherPrototype_ != Teuchos::null || postSmootherPrototype_ != Teuchos::null) { out0 <<
"-" << std::endl; }
282 if (preSmootherPrototype_ != Teuchos::null) { out0 <<
"RCP<preSmootherPrototype_> : " << preSmootherPrototype_ << std::endl; }
283 if (postSmootherPrototype_ != Teuchos::null) { out0 <<
"RCP<postSmootherPrototype_>: " << postSmootherPrototype_ << std::endl; }
296 #endif // MUELU_SMOOTHERFACTORY_DEF_HPP
virtual const Teuchos::ParameterList & GetParameterList() const
SmootherFactory(RCP< SmootherPrototype > preAndPostSmootherPrototype=Teuchos::null)
Constructor.
T & Get(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access). Usage: Level->Get< RCP<Matrix> >("A", factory) if factory == NULL => use default factory.
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)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
RCP< const ParameterList > GetValidParameterList() const
Input.
virtual void Setup(Level &)=0
Print additional debugging information.
void BuildSmoother(Level ¤tLevel, const PreOrPost preOrPost=BOTH) const
void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
void CheckPrototypes() const
void Build(Level ¤tLevel) const
Creates pre and post smoothers.
virtual RCP< SmootherPrototype > Copy() const =0
void SetSmootherPrototypes(RCP< SmootherPrototype > preAndPostSmootherPrototype)
Set smoother prototypes.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Class that holds all level-specific information.
#define MUELU_DESCRIBE
Helper macro for implementing Describable::describe() for BaseClass objects.
void Set(const std::string &ename, const T &entry, const FactoryBase *factory=NoFactory::get())
std::string description() const
Return a simple one-line description of this object.
int SetProcRankVerbose(int procRank) const
Set proc rank used for printing.
void GetSmootherPrototypes(RCP< SmootherPrototype > &preSmootherPrototype, RCP< SmootherPrototype > &postSmootherPrototype) const
Get smoother prototypes.
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
Exception throws to report errors in the internal logical of the program.
RCP< const Teuchos::Comm< int > > GetComm() const
virtual std::string description() const
Return a simple one-line description of this object.
bool IsAvailable(const std::string &ename, const FactoryBase *factory=NoFactory::get()) const
Test whether a need's value has been saved.
void DeclareInput(Level ¤tLevel) const
Specifies the data that this class needs, and the factories that generate that data.