10#ifndef MUELU_MERGEDSMOOTHER_DEF_HPP
11#define MUELU_MERGEDSMOOTHER_DEF_HPP
18template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
20 : smootherList_(smootherList)
21 , reverseOrder_(false)
28template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
30 : reverseOrder_(src.reverseOrder_)
31 , verbose_(src.verbose_) {
36template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
39 for (
typename ArrayView<RCP<SmootherPrototype> >::iterator it = smootherList_.begin(); it != smootherList_.end(); it++)
40 (*it)->SetFactory(varName, factory);
43template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
45 for (
typename ArrayView<RCP<SmootherPrototype> >::iterator it = smootherList_.begin(); it != smootherList_.end(); ++it)
46 (*it)->DeclareInput(currentLevel);
49template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
52 this->GetOStream(
Warnings0) <<
"MueLu::MergedSmoother::Setup(): Setup() has already been called";
54 for (
typename ArrayView<RCP<SmootherPrototype> >::iterator it = smootherList_.begin(); it != smootherList_.end(); ++it) {
59 std::string msg =
"MueLu::MergedSmoother<>::Setup(): Runtime Error.\n One of the underlying smoother throwed the following exception: \n";
68template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
72 typedef typename ArrayRCP<RCP<SmootherPrototype> >::size_type sz_t;
73 sz_t n = smootherList_.size(), c = (reverseOrder_ ? n - 1 : 0);
74 char d = (reverseOrder_ ? -1 : 1);
76 for (sz_t i = 0; i < n; i++)
79 smootherList_[c + d * Teuchos::as<char>(i)]->Apply(X, B, InitialGuessIsZero);
82 InitialGuessIsZero =
false;
85 std::string msg =
"MueLu::MergedSmoother<>::Apply(): Runtime Error. One of the underlying smoothers throws the following exception: \n";
91template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
96template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
98 RCP<MergedSmoother> srcMergedSmoother = rcp_dynamic_cast<MergedSmoother>(src);
100 reverseOrder_ = srcMergedSmoother->GetReverseOrder();
103 const ArrayRCP<const RCP<SmootherPrototype> >& srcSmootherList = srcMergedSmoother->GetSmootherList();
104 const ArrayRCP<const RCP<SmootherPrototype> >& thisSmootherList = smootherList_;
106 "MueLu::MergedSmoother<>:CopyParameters(): thisSmootherList == Teuchos::null");
117 reuse = reuse && (thisSmootherList.size() == srcSmootherList.size());
121 for (
typename ArrayRCP<RCP<SmootherPrototype> >::size_type i = 0; i < srcSmootherList.size(); i++) {
125 "MueLu::MergedSmoother<>:CopyParameters(): internal logic error");
139 for (
typename ArrayRCP<RCP<SmootherPrototype> >::size_type i = 0; i < srcSmootherList.size(); i++) {
140 if (srcSmootherList[i] != Teuchos::null) {
141 TEUCHOS_TEST_FOR_EXCEPTION(srcSmootherList[i] == Teuchos::null,
MueLu::Exceptions::RuntimeError,
"MueLu::MergedSmoother<>:CopyParameters(): internal logic error");
144 isSetup = isSetup && thisSmootherList[i]->IsSetup();
151 smootherList_ = Teuchos::null;
152 smootherList_ = SmootherListDeepCopy(srcSmootherList);
158template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
159RCP<MueLu::SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
165template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
166ArrayRCP<RCP<MueLu::SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal, Node> > >
169 ArrayRCP<RCP<SmootherPrototype> > newSmootherList(srcSmootherList.size());
171 for (
typename ArrayRCP<RCP<SmootherPrototype> >::size_type i = 0; i < srcSmootherList.size(); i++)
172 newSmootherList[i] = srcSmootherList[i]->
Copy();
174 return newSmootherList;
177template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
181 return Teuchos::OrdinalTraits<size_t>::invalid();
Exception throws when you call an unimplemented method of MueLu.
Exception throws to report errors in the internal logical of the program.
Class that holds all level-specific information.
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
RCP< SmootherPrototype > Copy() const
Copy method (performs a deep copy of input object)
void DeclareInput(Level ¤tLevel) const
Input.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
ArrayRCP< RCP< SmootherPrototype > > smootherList_
ArrayRCP< RCP< SmootherPrototype > > SmootherListDeepCopy(const ArrayRCP< const RCP< SmootherPrototype > > &srcSmootherList)
void Setup(Level &level)
Set up.
void SetFactory(const std::string &varName, const RCP< const FactoryBase > &factory)
Custom SetFactory.
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply.
MergedSmoother(ArrayRCP< RCP< SmootherPrototype > > &smootherList, bool verbose=false)
Constructor.
void CopyParameters(RCP< SmootherPrototype > src)
const ArrayRCP< const RCP< SmootherPrototype > > GetSmootherList() const
bool IsSetup() const
Get the state of a smoother prototype.
Namespace for MueLu classes and methods.
@ Warnings0
Important warning messages (one line)