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>
61 SetSmootherPrototypes(preAndPostSmootherPrototype);
64 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
66 RCP<SmootherPrototype> postSmootherPrototype) {
67 SetSmootherPrototypes(preSmootherPrototype, postSmootherPrototype);
70 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
72 preSmootherPrototype_ = postSmootherPrototype_ = preAndPostSmootherPrototype;
76 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
78 RCP<SmootherPrototype> postSmootherPrototype) {
79 preSmootherPrototype_ = preSmootherPrototype;
80 postSmootherPrototype_ = postSmootherPrototype;
84 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
86 TEUCHOS_TEST_FOR_EXCEPTION(preSmootherPrototype_ != Teuchos::null && preSmootherPrototype_->IsSetup() ==
true,
88 TEUCHOS_TEST_FOR_EXCEPTION(postSmootherPrototype_ != Teuchos::null && postSmootherPrototype_->IsSetup() ==
true,
92 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
94 RCP<SmootherPrototype>& postSmootherPrototype)
const {
95 preSmootherPrototype = preSmootherPrototype_;
96 postSmootherPrototype = postSmootherPrototype_;
99 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
101 if (preSmootherPrototype_ != Teuchos::null)
102 preSmootherPrototype_->DeclareInput(currentLevel);
104 if ((postSmootherPrototype_ != Teuchos::null) && (preSmootherPrototype_ != postSmootherPrototype_))
105 postSmootherPrototype_->DeclareInput(currentLevel);
108 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
110 return BuildSmoother(currentLevel,
BOTH);
113 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
135 RCP<SmootherPrototype> preSmoother, postSmoother;
136 ParameterList preSmootherParams, postSmootherParams;
138 if ((preOrPost &
PRE) && !preSmootherPrototype_.is_null()) {
139 preSmoother = preSmootherPrototype_->Copy();
142 if (!currentLevel.
GetComm().is_null())
143 oldRank = preSmoother->SetProcRankVerbose(currentLevel.
GetComm()->getRank());
145 preSmoother->Setup(currentLevel);
146 preSmootherParams = preSmoother->GetParameterList();
149 preSmoother->SetProcRankVerbose(oldRank);
151 currentLevel.
Set<RCP<SmootherBase> >(
"PreSmoother", preSmoother,
this);
154 if ((preOrPost &
POST) && !postSmootherPrototype_.is_null()) {
155 if (preOrPost ==
BOTH && preSmootherPrototype_ == postSmootherPrototype_) {
158 postSmoother = preSmoother;
187 postSmoother = postSmootherPrototype_->Copy();
190 if (!currentLevel.
GetComm().is_null())
191 oldRank = postSmoother->SetProcRankVerbose(GetProcRankVerbose());
193 postSmoother->Setup(currentLevel);
196 postSmoother->SetProcRankVerbose(oldRank);
198 postSmootherParams = postSmoother->GetParameterList();
200 currentLevel.
Set<RCP<SmootherBase> >(
"PostSmoother", postSmoother,
this);
203 ParameterList& paramList =
const_cast<ParameterList&
>(this->GetParameterList());
204 if (postSmoother == preSmoother && !preSmoother.is_null()) {
205 paramList = preSmoother->GetParameterList();
208 if (!preSmoother.is_null()) {
209 ParameterList& preList = paramList.sublist(
"presmoother",
false);
210 preList = preSmootherParams;
213 if (!postSmoother.is_null()) {
214 ParameterList& postList = paramList.sublist(
"postsmoother",
false);
215 postList = postSmootherParams;
221 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
223 std::ostringstream out;
225 std::string preStr = (preSmootherPrototype_ == Teuchos::null) ?
"null" : preSmootherPrototype_->description();
226 std::string postStr = (preSmootherPrototype_ == postSmootherPrototype_) ?
"pre" : ( (postSmootherPrototype_ == Teuchos::null) ?
"null" : postSmootherPrototype_->description() );
227 out <<
"{pre = " << preStr <<
", post = "<< postStr <<
"}";
231 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
236 out0 <<
"PreSmoother : ";
237 if (preSmootherPrototype_.is_null()) {
238 out0 <<
"null" << std::endl;
240 Teuchos::OSTab tab2(out);
241 preSmootherPrototype_->describe(out, verbLevel);
244 out0 <<
"PostSmoother: ";
245 if (postSmootherPrototype_ == preSmootherPrototype_) { out0 <<
"same as PreSmoother" << std::endl; }
246 else if (postSmootherPrototype_ == Teuchos::null) { out0 <<
"null" << std::endl; }
248 Teuchos::OSTab tab2(out);
249 postSmootherPrototype_->describe(out, verbLevel);
250 out0 <<
"PostSmoother is different than PreSmoother (not the same object)" << std::endl;
254 if (verbLevel &
Debug) {
255 if (preSmootherPrototype_ != Teuchos::null || postSmootherPrototype_ != Teuchos::null) { out0 <<
"-" << std::endl; }
256 if (preSmootherPrototype_ != Teuchos::null) { out0 <<
"RCP<preSmootherPrototype_> : " << preSmootherPrototype_ << std::endl; }
257 if (postSmootherPrototype_ != Teuchos::null) { out0 <<
"RCP<postSmootherPrototype_>: " << postSmootherPrototype_ << std::endl; }
270 #endif // MUELU_SMOOTHERFACTORY_DEF_HPP SmootherFactory(RCP< SmootherPrototype > preAndPostSmootherPrototype=Teuchos::null)
Constructor.
Print additional debugging information.
Namespace for MueLu classes and methods.
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.
void SetSmootherPrototypes(RCP< SmootherPrototype > preAndPostSmootherPrototype)
Set smoother prototypes.
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.
void GetSmootherPrototypes(RCP< SmootherPrototype > &preSmootherPrototype, RCP< SmootherPrototype > &postSmootherPrototype) const
Get smoother prototypes.
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.
void DeclareInput(Level ¤tLevel) const
Input.