46#ifndef MUELU_SMOOTHERFACTORY_DEF_HPP
47#define MUELU_SMOOTHERFACTORY_DEF_HPP
53#include "MueLu_SmootherPrototype.hpp"
58 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
63 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
65 RCP<SmootherPrototype> postSmootherPrototype) {
69 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
75 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
77 RCP<SmootherPrototype> postSmootherPrototype) {
83 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
85 RCP<ParameterList> validParamList = rcp(
new ParameterList());
87 validParamList->set<
bool>(
"keep smoother data",
false,
"Keep constructed smoothers for later reuse");
89 validParamList->set< RCP<SmootherPrototype> >(
"PreSmoother data", null,
"Pre-smoother data for reuse");
90 validParamList->set< RCP<SmootherPrototype> >(
"PostSmoother data", null,
"Post-smoother data for reuse");
92 return validParamList;
95 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
103 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
105 RCP<SmootherPrototype>& postSmootherPrototype)
const {
110 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
119 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
124 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
148 RCP<SmootherPrototype> preSmoother, postSmoother;
149 ParameterList preSmootherParams, postSmootherParams;
153 if (currentLevel.
IsAvailable(
"PreSmoother data",
this))
154 preSmoother = currentLevel.
Get<RCP<SmootherPrototype> >(
"PreSmoother data",
this);
159 if (!currentLevel.
GetComm().is_null())
160 oldRank = preSmoother->SetProcRankVerbose(currentLevel.
GetComm()->getRank());
162 preSmoother->Setup(currentLevel);
163 preSmootherParams = preSmoother->GetParameterList();
166 preSmoother->SetProcRankVerbose(oldRank);
168 currentLevel.
Set<RCP<SmootherBase> >(
"PreSmoother", preSmoother,
this);
170 if (pL.get<
bool>(
"keep smoother data"))
171 Set(currentLevel,
"PreSmoother data", preSmoother);
178 postSmoother = preSmoother;
206 if (currentLevel.
IsAvailable(
"PostSmoother data",
this)) {
207 postSmoother = currentLevel.
Get<RCP<SmootherPrototype> >(
"PostSmoother data",
this);
216 if (!currentLevel.
GetComm().is_null())
219 postSmoother->Setup(currentLevel);
220 postSmootherParams = postSmoother->GetParameterList();
223 postSmoother->SetProcRankVerbose(oldRank);
226 currentLevel.
Set<RCP<SmootherBase> >(
"PostSmoother", postSmoother,
this);
228 if (pL.get<
bool>(
"keep smoother data"))
229 Set(currentLevel,
"PostSmoother data", postSmoother);
232 ParameterList& paramList =
const_cast<ParameterList&
>(this->
GetParameterList());
233 if (postSmoother == preSmoother && !preSmoother.is_null()) {
234 paramList.sublist(
"smoother",
false) = preSmoother->GetParameterList();
237 if (!preSmoother.is_null())
238 paramList.sublist(
"presmoother",
false) = preSmootherParams;
240 if (!postSmoother.is_null())
241 paramList.sublist(
"postsmoother",
false) = postSmootherParams;
246 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
248 std::ostringstream out;
252 out <<
"{pre = " << preStr <<
", post = "<< postStr <<
"}";
256 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
261 out0 <<
"PreSmoother : ";
263 out0 <<
"null" << std::endl;
265 Teuchos::OSTab tab2(out);
269 out0 <<
"PostSmoother: ";
273 Teuchos::OSTab tab2(out);
275 out0 <<
"PostSmoother is different than PreSmoother (not the same object)" << std::endl;
279 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.
void Set(Level &level, const std::string &varName, const T &data) const
Class that holds all level-specific information.
bool IsAvailable(const std::string &ename, const FactoryBase *factory=NoFactory::get()) const
Test whether a need's value has been saved.
RCP< const Teuchos::Comm< int > > GetComm() const
T & Get(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access)....
void Set(const std::string &ename, const T &entry, const FactoryBase *factory=NoFactory::get())
virtual const Teuchos::ParameterList & GetParameterList() const
void GetSmootherPrototypes(RCP< SmootherPrototype > &preSmootherPrototype, RCP< SmootherPrototype > &postSmootherPrototype) const
Get smoother prototypes.
RCP< SmootherPrototype > preSmootherPrototype_
void CheckPrototypes() const
void SetSmootherPrototypes(RCP< SmootherPrototype > preAndPostSmootherPrototype)
Set smoother prototypes.
RCP< const ParameterList > GetValidParameterList() const
Input.
std::string description() const
Return a simple one-line description of this object.
SmootherFactory(RCP< SmootherPrototype > preAndPostSmootherPrototype=Teuchos::null)
Constructor.
void DeclareInput(Level ¤tLevel) const
Specifies the data that this class needs, and the factories that generate that data.
void BuildSmoother(Level ¤tLevel, const PreOrPost preOrPost=BOTH) const
void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
RCP< SmootherPrototype > postSmootherPrototype_
void Build(Level ¤tLevel) const
Creates pre and post smoothers.
int GetProcRankVerbose() const
Get proc rank used for printing. Do not use this information for any other purpose....
Namespace for MueLu classes and methods.
@ Debug
Print additional debugging information.
@ Parameters0
Print class parameters.