8#ifndef PACKAGES_MUELU_SRC_MUECENTRAL_MUELU_TOPSMOOTHERFACTORY_DEF_HPP_
9#define PACKAGES_MUELU_SRC_MUECENTRAL_MUELU_TOPSMOOTHERFACTORY_DEF_HPP_
18#include "MueLu_SmootherFactory.hpp"
19#include "MueLu_SmootherPrototype.hpp"
24 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
26 TEUCHOS_TEST_FOR_EXCEPTION(varName !=
"CoarseSolver" && varName !=
"Smoother",
Exceptions::RuntimeError,
"varName should be either \"CoarseSolver\" or \"Smoother\"");
28 if (varName ==
"CoarseSolver") {
32 RCP<const FactoryBase> coarseSolverFactory = parentFactoryManager->GetFactory(
"CoarseSolver");
33 RCP<const SmootherFactory> coarseSmootherFactory = Teuchos::rcp_dynamic_cast<const SmootherFactory>(coarseSolverFactory);
34 if (coarseSmootherFactory != Teuchos::null) {
35 RCP<SmootherPrototype> preProto;
36 RCP<SmootherPrototype> postProto;
37 coarseSmootherFactory->GetSmootherPrototypes(preProto, postProto);
39 if (preProto == postProto)
40 preSmootherFact_ = parentFactoryManager->GetFactory(
"CoarseSolver");
43 if(preProto != Teuchos::null)
44 preSmootherFact_ = parentFactoryManager->GetFactory(
"CoarseSolver");
45 if(postProto != Teuchos::null)
46 postSmootherFact_ = parentFactoryManager->GetFactory(
"CoarseSolver");
50 preSmootherFact_ = parentFactoryManager->GetFactory(
"CoarseSolver");
53 preSmootherFact_ = parentFactoryManager->GetFactory(
"PreSmoother");
54 postSmootherFact_ = parentFactoryManager->GetFactory(
"PostSmoother");
58 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
61 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
63 if (preSmootherFact_ != Teuchos::null)
64 level.
DeclareInput(
"PreSmoother", preSmootherFact_.get());
65 if (postSmootherFact_ != Teuchos::null)
66 level.
DeclareInput(
"PostSmoother", postSmootherFact_.get());
69 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
71 if (preSmootherFact_.is_null() && postSmootherFact_.is_null())
82 if (!preSmootherFact_.is_null()) {
85 RCP<const SmootherFactory> s = rcp_dynamic_cast<const SmootherFactory>(preSmootherFact_);
87 RCP<SmootherPrototype> pre, post;
88 s->GetSmootherPrototypes(pre, post);
96 RCP<SmootherBase> Pre = level.
Get<RCP<SmootherBase> >(
"PreSmoother", preSmootherFact_.get());
105 if (!postSmootherFact_.is_null()) {
108 RCP<const SmootherFactory> s = rcp_dynamic_cast<const SmootherFactory>(postSmootherFact_);
110 RCP<SmootherPrototype> pre, post;
111 s->GetSmootherPrototypes(pre, post);
119 RCP<SmootherBase> Post = level.
Get<RCP<SmootherBase> >(
"PostSmoother", postSmootherFact_.get());
Exception throws to report errors in the internal logical of the program.
Class that holds all level-specific information.
void DeclareInput(const std::string &ename, const FactoryBase *factory, const FactoryBase *requestedBy=NoFactory::get())
Callback from FactoryBase::CallDeclareInput() and FactoryBase::DeclareInput()
void RemoveKeepFlag(const std::string &ename, const FactoryBase *factory, KeepType keep=MueLu::All)
void AddKeepFlag(const std::string &ename, const FactoryBase *factory=NoFactory::get(), KeepType keep=MueLu::Keep)
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())
static const NoFactory * get()
TopSmootherFactory(RCP< const FactoryManagerBase > parentFactoryManager, const std::string &varName)
void Build(Level &level) const
Build an object with this factory.
virtual ~TopSmootherFactory()
void DeclareInput(Level &level) const
Specifies the data that this class needs, and the factories that generate that data.
Namespace for MueLu classes and methods.
@ Final
Keep data only for this run. Used to keep data useful for Hierarchy::Iterate(). Data will be deleted ...
@ UserData
User data are always kept. This flag is set automatically when Level::Set("data", data) is used....