46 #ifndef MUELU_SMOOTHERFACTORY_DEF_HPP
47 #define MUELU_SMOOTHERFACTORY_DEF_HPP
53 #include "MueLu_SmootherPrototype.hpp"
57 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
59 SetSmootherPrototypes(preAndPostSmootherPrototype);
62 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
65 SetSmootherPrototypes(preSmootherPrototype, postSmootherPrototype);
68 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
70 preSmootherPrototype_ = postSmootherPrototype_ = preAndPostSmootherPrototype;
74 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
77 preSmootherPrototype_ = preSmootherPrototype;
78 postSmootherPrototype_ = postSmootherPrototype;
82 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
86 validParamList->
set<
bool>(
"keep smoother data",
false,
"Keep constructed smoothers for later reuse");
91 return validParamList;
94 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
102 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
105 preSmootherPrototype = preSmootherPrototype_;
106 postSmootherPrototype = postSmootherPrototype_;
109 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
111 if (preSmootherPrototype_ != Teuchos::null)
112 preSmootherPrototype_->DeclareInput(currentLevel);
114 if ((postSmootherPrototype_ != Teuchos::null) && (preSmootherPrototype_ != postSmootherPrototype_))
115 postSmootherPrototype_->DeclareInput(currentLevel);
118 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
120 return BuildSmoother(currentLevel,
BOTH);
123 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
150 if ((preOrPost &
PRE) && !preSmootherPrototype_.is_null()) {
151 if (currentLevel.
IsAvailable(
"PreSmoother data",
this))
154 preSmoother = preSmootherPrototype_->
Copy();
160 preSmoother->
Setup(currentLevel);
168 if (pL.
get<
bool>(
"keep smoother data"))
169 Set(currentLevel,
"PreSmoother data", preSmoother);
172 if ((preOrPost &
POST) && !postSmootherPrototype_.is_null()) {
173 if (preOrPost ==
BOTH && preSmootherPrototype_ == postSmootherPrototype_) {
176 postSmoother = preSmoother;
203 if (currentLevel.
IsAvailable(
"PostSmoother data",
this)) {
209 postSmoother = postSmootherPrototype_->
Copy();
216 postSmoother->
Setup(currentLevel);
225 if (pL.
get<
bool>(
"keep smoother data"))
226 Set(currentLevel,
"PostSmoother data", postSmoother);
230 if (postSmoother == preSmoother && !preSmoother.
is_null()) {
235 paramList.
sublist(
"presmoother",
false) = preSmootherParams;
238 paramList.
sublist(
"postsmoother",
false) = postSmootherParams;
243 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
245 std::ostringstream out;
247 std::string preStr = (preSmootherPrototype_ == Teuchos::null) ?
"null" : preSmootherPrototype_->description();
248 std::string postStr = (preSmootherPrototype_ == postSmootherPrototype_) ?
"pre" : ((postSmootherPrototype_ == Teuchos::null) ?
"null" : postSmootherPrototype_->description());
249 out <<
"{pre = " << preStr <<
", post = " << postStr <<
"}";
253 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
258 out0 <<
"PreSmoother : ";
259 if (preSmootherPrototype_.is_null()) {
260 out0 <<
"null" << std::endl;
263 preSmootherPrototype_->describe(out, verbLevel);
266 out0 <<
"PostSmoother: ";
267 if (postSmootherPrototype_ == preSmootherPrototype_) {
268 out0 <<
"same as PreSmoother" << std::endl;
269 }
else if (postSmootherPrototype_ == Teuchos::null) {
270 out0 <<
"null" << std::endl;
273 postSmootherPrototype_->describe(out, verbLevel);
274 out0 <<
"PostSmoother is different than PreSmoother (not the same object)" << std::endl;
278 if (verbLevel &
Debug) {
279 if (preSmootherPrototype_ != Teuchos::null || postSmootherPrototype_ != Teuchos::null) {
280 out0 <<
"-" << std::endl;
282 if (preSmootherPrototype_ != Teuchos::null) {
283 out0 <<
"RCP<preSmootherPrototype_> : " << preSmootherPrototype_ << std::endl;
285 if (postSmootherPrototype_ != Teuchos::null) {
286 out0 <<
"RCP<postSmootherPrototype_>: " << postSmootherPrototype_ << std::endl;
299 #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.