10#ifndef MUELU_SMOOTHERFACTORY_DEF_HPP
11#define MUELU_SMOOTHERFACTORY_DEF_HPP
17#include "MueLu_SmootherPrototype.hpp"
21template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
24template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
29template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
31 RCP<SmootherPrototype> postSmootherPrototype) {
35template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
41template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
43 RCP<SmootherPrototype> postSmootherPrototype) {
49template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
51 RCP<ParameterList> validParamList = rcp(
new ParameterList());
53 validParamList->set<
bool>(
"keep smoother data",
false,
"Keep constructed smoothers for later reuse");
55 validParamList->set<RCP<SmootherPrototype> >(
"PreSmoother data", null,
"Pre-smoother data for reuse");
56 validParamList->set<RCP<SmootherPrototype> >(
"PostSmoother data", null,
"Post-smoother data for reuse");
58 return validParamList;
61template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
69template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
71 RCP<SmootherPrototype>& postSmootherPrototype)
const {
76template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
85template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
90template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
114 RCP<SmootherPrototype> preSmoother, postSmoother;
115 ParameterList preSmootherParams, postSmootherParams;
118 if (currentLevel.
IsAvailable(
"PreSmoother data",
this))
119 preSmoother = currentLevel.
Get<RCP<SmootherPrototype> >(
"PreSmoother data",
this);
124 if (!currentLevel.
GetComm().is_null())
125 oldRank = preSmoother->SetProcRankVerbose(currentLevel.
GetComm()->getRank());
127 preSmoother->Setup(currentLevel);
128 preSmootherParams = preSmoother->GetParameterList();
131 preSmoother->SetProcRankVerbose(oldRank);
133 currentLevel.
Set<RCP<SmootherBase> >(
"PreSmoother", preSmoother,
this);
135 if (pL.get<
bool>(
"keep smoother data"))
136 Set(currentLevel,
"PreSmoother data", preSmoother);
143 postSmoother = preSmoother;
170 if (currentLevel.
IsAvailable(
"PostSmoother data",
this)) {
171 postSmoother = currentLevel.
Get<RCP<SmootherPrototype> >(
"PostSmoother data",
this);
180 if (!currentLevel.
GetComm().is_null())
183 postSmoother->Setup(currentLevel);
184 postSmootherParams = postSmoother->GetParameterList();
187 postSmoother->SetProcRankVerbose(oldRank);
190 currentLevel.
Set<RCP<SmootherBase> >(
"PostSmoother", postSmoother,
this);
192 if (pL.get<
bool>(
"keep smoother data"))
193 Set(currentLevel,
"PostSmoother data", postSmoother);
196 ParameterList& paramList =
const_cast<ParameterList&
>(this->
GetParameterList());
197 if (postSmoother == preSmoother && !preSmoother.is_null()) {
198 paramList.sublist(
"smoother",
false) = preSmoother->GetParameterList();
201 if (!preSmoother.is_null())
202 paramList.sublist(
"presmoother",
false) = preSmootherParams;
204 if (!postSmoother.is_null())
205 paramList.sublist(
"postsmoother",
false) = postSmootherParams;
210template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
212 std::ostringstream out;
216 out <<
"{pre = " << preStr <<
", post = " << postStr <<
"}";
220template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
225 out0 <<
"PreSmoother : ";
227 out0 <<
"null" << std::endl;
229 Teuchos::OSTab tab2(out);
233 out0 <<
"PostSmoother: ";
235 out0 <<
"same as PreSmoother" << std::endl;
237 out0 <<
"null" << std::endl;
239 Teuchos::OSTab tab2(out);
241 out0 <<
"PostSmoother is different than PreSmoother (not the same object)" << std::endl;
245 if (verbLevel &
Debug) {
247 out0 <<
"-" << std::endl;
#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
virtual ~SmootherFactory()
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.