10 #ifndef MUELU_SMOOTHERFACTORY_DEF_HPP
11 #define MUELU_SMOOTHERFACTORY_DEF_HPP
17 #include "MueLu_SmootherPrototype.hpp"
21 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
24 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
26 SetSmootherPrototypes(preAndPostSmootherPrototype);
29 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
32 SetSmootherPrototypes(preSmootherPrototype, postSmootherPrototype);
35 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
37 preSmootherPrototype_ = postSmootherPrototype_ = preAndPostSmootherPrototype;
41 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
44 preSmootherPrototype_ = preSmootherPrototype;
45 postSmootherPrototype_ = postSmootherPrototype;
49 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
53 validParamList->
set<
bool>(
"keep smoother data",
false,
"Keep constructed smoothers for later reuse");
58 return validParamList;
61 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
69 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
72 preSmootherPrototype = preSmootherPrototype_;
73 postSmootherPrototype = postSmootherPrototype_;
76 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
78 if (preSmootherPrototype_ != Teuchos::null)
79 preSmootherPrototype_->DeclareInput(currentLevel);
81 if ((postSmootherPrototype_ != Teuchos::null) && (preSmootherPrototype_ != postSmootherPrototype_))
82 postSmootherPrototype_->DeclareInput(currentLevel);
85 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
87 return BuildSmoother(currentLevel,
BOTH);
90 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
117 if ((preOrPost &
PRE) && !preSmootherPrototype_.is_null()) {
118 if (currentLevel.
IsAvailable(
"PreSmoother data",
this))
121 preSmoother = preSmootherPrototype_->
Copy();
127 preSmoother->
Setup(currentLevel);
135 if (pL.
get<
bool>(
"keep smoother data"))
136 Set(currentLevel,
"PreSmoother data", preSmoother);
139 if ((preOrPost &
POST) && !postSmootherPrototype_.is_null()) {
140 if (preOrPost ==
BOTH && preSmootherPrototype_ == postSmootherPrototype_) {
143 postSmoother = preSmoother;
170 if (currentLevel.
IsAvailable(
"PostSmoother data",
this)) {
176 postSmoother = postSmootherPrototype_->
Copy();
183 postSmoother->
Setup(currentLevel);
192 if (pL.
get<
bool>(
"keep smoother data"))
193 Set(currentLevel,
"PostSmoother data", postSmoother);
197 if (postSmoother == preSmoother && !preSmoother.
is_null()) {
202 paramList.
sublist(
"presmoother",
false) = preSmootherParams;
205 paramList.
sublist(
"postsmoother",
false) = postSmootherParams;
210 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
212 std::ostringstream out;
214 std::string preStr = (preSmootherPrototype_ == Teuchos::null) ?
"null" : preSmootherPrototype_->description();
215 std::string postStr = (preSmootherPrototype_ == postSmootherPrototype_) ?
"pre" : ((postSmootherPrototype_ == Teuchos::null) ?
"null" : postSmootherPrototype_->description());
216 out <<
"{pre = " << preStr <<
", post = " << postStr <<
"}";
220 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
225 out0 <<
"PreSmoother : ";
226 if (preSmootherPrototype_.is_null()) {
227 out0 <<
"null" << std::endl;
230 preSmootherPrototype_->describe(out, verbLevel);
233 out0 <<
"PostSmoother: ";
234 if (postSmootherPrototype_ == preSmootherPrototype_) {
235 out0 <<
"same as PreSmoother" << std::endl;
236 }
else if (postSmootherPrototype_ == Teuchos::null) {
237 out0 <<
"null" << std::endl;
240 postSmootherPrototype_->describe(out, verbLevel);
241 out0 <<
"PostSmoother is different than PreSmoother (not the same object)" << std::endl;
245 if (verbLevel &
Debug) {
246 if (preSmootherPrototype_ != Teuchos::null || postSmootherPrototype_ != Teuchos::null) {
247 out0 <<
"-" << std::endl;
249 if (preSmootherPrototype_ != Teuchos::null) {
250 out0 <<
"RCP<preSmootherPrototype_> : " << preSmootherPrototype_ << std::endl;
252 if (postSmootherPrototype_ != Teuchos::null) {
253 out0 <<
"RCP<postSmootherPrototype_>: " << postSmootherPrototype_ << std::endl;
266 #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)
#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.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
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.
virtual ~SmootherFactory()
#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.