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>
64 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
66 RCP<SmootherPrototype> postSmootherPrototype) {
70 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
76 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
78 RCP<SmootherPrototype> postSmootherPrototype) {
84 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
86 RCP<ParameterList> validParamList = rcp(
new ParameterList());
88 validParamList->set<
bool>(
"keep smoother data",
false,
"Keep constructed smoothers for later reuse");
90 validParamList->set< RCP<SmootherPrototype> >(
"PreSmoother data", null,
"Pre-smoother data for reuse");
91 validParamList->set< RCP<SmootherPrototype> >(
"PostSmoother data", null,
"Post-smoother data for reuse");
93 return validParamList;
96 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
104 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
106 RCP<SmootherPrototype>& postSmootherPrototype)
const {
111 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
120 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
125 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
149 RCP<SmootherPrototype> preSmoother, postSmoother;
150 ParameterList preSmootherParams, postSmootherParams;
154 if (currentLevel.
IsAvailable(
"PreSmoother data",
this))
155 preSmoother = currentLevel.
Get<RCP<SmootherPrototype> >(
"PreSmoother data",
this);
160 if (!currentLevel.
GetComm().is_null())
161 oldRank = preSmoother->SetProcRankVerbose(currentLevel.
GetComm()->getRank());
163 preSmoother->Setup(currentLevel);
164 preSmootherParams = preSmoother->GetParameterList();
167 preSmoother->SetProcRankVerbose(oldRank);
169 currentLevel.
Set<RCP<SmootherBase> >(
"PreSmoother", preSmoother,
this);
171 if (pL.get<
bool>(
"keep smoother data"))
172 Set(currentLevel,
"PreSmoother data", preSmoother);
179 postSmoother = preSmoother;
207 if (currentLevel.
IsAvailable(
"PostSmoother data",
this)) {
208 postSmoother = currentLevel.
Get<RCP<SmootherPrototype> >(
"PostSmoother data",
this);
217 if (!currentLevel.
GetComm().is_null())
220 postSmoother->Setup(currentLevel);
221 postSmootherParams = postSmoother->GetParameterList();
224 postSmoother->SetProcRankVerbose(oldRank);
227 currentLevel.
Set<RCP<SmootherBase> >(
"PostSmoother", postSmoother,
this);
229 if (pL.get<
bool>(
"keep smoother data"))
230 Set(currentLevel,
"PostSmoother data", postSmoother);
233 ParameterList& paramList =
const_cast<ParameterList&
>(this->
GetParameterList());
234 if (postSmoother == preSmoother && !preSmoother.is_null()) {
235 paramList.sublist(
"smoother",
false) = preSmoother->GetParameterList();
238 if (!preSmoother.is_null())
239 paramList.sublist(
"presmoother",
false) = preSmootherParams;
241 if (!postSmoother.is_null())
242 paramList.sublist(
"postsmoother",
false) = postSmootherParams;
247 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
249 std::ostringstream out;
253 out <<
"{pre = " << preStr <<
", post = "<< postStr <<
"}";
257 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
262 out0 <<
"PreSmoother : ";
264 out0 <<
"null" << std::endl;
266 Teuchos::OSTab tab2(out);
270 out0 <<
"PostSmoother: ";
274 Teuchos::OSTab tab2(out);
276 out0 <<
"PostSmoother is different than PreSmoother (not the same object)" << std::endl;
280 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.