46 #ifndef MUELU_MERGEDSMOOTHER_DEF_HPP 47 #define MUELU_MERGEDSMOOTHER_DEF_HPP 54 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
56 : smootherList_(smootherList), reverseOrder_(false), verbose_(verbose) {
62 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
64 : reverseOrder_(src.reverseOrder_), verbose_(src.verbose_) {
69 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
72 for (
typename ArrayView<RCP<SmootherPrototype> >::iterator it = smootherList_.begin(); it != smootherList_.end(); it++)
73 (*it)->SetFactory(varName, factory);
77 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
79 for (
typename ArrayView<RCP<SmootherPrototype> >::iterator it = smootherList_.begin(); it != smootherList_.end(); ++it)
80 (*it)->DeclareInput(currentLevel);
83 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
86 this->GetOStream(
Warnings0) <<
"MueLu::MergedSmoother::Setup(): Setup() has already been called";
88 for (
typename ArrayView<RCP<SmootherPrototype> >::iterator it = smootherList_.begin(); it != smootherList_.end(); ++it) {
93 std::string msg =
"MueLu::MergedSmoother<>::Setup(): Runtime Error.\n One of the underlying smoother throwed the following exception: \n"; msg += e.what();
101 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
105 typedef typename ArrayRCP<RCP<SmootherPrototype> >::size_type sz_t;
106 sz_t n = smootherList_.size(), c = (reverseOrder_ ? n-1 : 0);
107 char d = (reverseOrder_ ? -1 : 1);
109 for (sz_t i = 0; i < n; i++)
112 smootherList_[c + d*Teuchos::as<char>(i)]->Apply(X, B, InitialGuessIsZero);
115 InitialGuessIsZero =
false;
118 std::string msg =
"MueLu::MergedSmoother<>::Apply(): Runtime Error. One of the underlying smoothers throws the following exception: \n"; msg += e.what();
123 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
128 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
130 RCP<MergedSmoother> srcMergedSmoother = rcp_dynamic_cast<
MergedSmoother>(src);
135 const ArrayRCP<const RCP<SmootherPrototype> >& srcSmootherList = srcMergedSmoother->GetSmootherList();
136 const ArrayRCP<const RCP<SmootherPrototype> >& thisSmootherList = smootherList_;
138 "MueLu::MergedSmoother<>:CopyParameters(): thisSmootherList == Teuchos::null");
149 reuse = reuse && (thisSmootherList.size() == srcSmootherList.size());
153 for (
typename ArrayRCP<RCP<SmootherPrototype> >::size_type i = 0; i < srcSmootherList.size(); i++) {
157 "MueLu::MergedSmoother<>:CopyParameters(): internal logic error");
171 for (
typename ArrayRCP<RCP<SmootherPrototype> >::size_type i = 0; i < srcSmootherList.size(); i++) {
172 if (srcSmootherList[i] != Teuchos::null) {
173 TEUCHOS_TEST_FOR_EXCEPTION(srcSmootherList[i] == Teuchos::null,
MueLu::Exceptions::RuntimeError,
"MueLu::MergedSmoother<>:CopyParameters(): internal logic error");
176 isSetup = isSetup && thisSmootherList[i]->IsSetup();
183 smootherList_ = Teuchos::null;
184 smootherList_ = SmootherListDeepCopy(srcSmootherList);
191 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
192 RCP<MueLu::SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
199 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
200 ArrayRCP<RCP<MueLu::SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal, Node> > >
204 ArrayRCP<RCP<SmootherPrototype> > newSmootherList(srcSmootherList.size());
206 for (
typename ArrayRCP<RCP<SmootherPrototype> >::size_type i = 0; i < srcSmootherList.size(); i++)
207 newSmootherList[i] = srcSmootherList[i]->
Copy();
209 return newSmootherList;
214 #endif // MUELU_MERGEDSMOOTHER_DEF_HPP Important warning messages (one line)
ArrayRCP< RCP< SmootherPrototype > > smootherList_
RCP< SmootherPrototype > Copy() const
Copy method (performs a deep copy of input object)
bool IsSetup() const
Get the state of a smoother prototype.
Namespace for MueLu classes and methods.
void CopyParameters(RCP< SmootherPrototype > src)
void DeclareInput(Level ¤tLevel) const
Input.
Class that holds all level-specific information.
Exception throws when you call an unimplemented method of MueLu.
ArrayRCP< RCP< SmootherPrototype > > SmootherListDeepCopy(const ArrayRCP< const RCP< SmootherPrototype > > &srcSmootherList)
bool GetReverseOrder() const
void SetFactory(const std::string &varName, const RCP< const FactoryBase > &factory)
Custom SetFactory.
MergedSmoother(ArrayRCP< RCP< SmootherPrototype > > &smootherList, bool verbose=false)
Constructor.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Exception throws to report errors in the internal logical of the program.
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply.
const ArrayRCP< const RCP< SmootherPrototype > > GetSmootherList() const
void Setup(Level &level)
Set up.