53 #ifndef MUELU_UZAWASMOOTHER_DEF_HPP_
54 #define MUELU_UZAWASMOOTHER_DEF_HPP_
56 #include "Teuchos_ArrayViewDecl.hpp"
69 #include "MueLu_Utilities.hpp"
71 #include "MueLu_HierarchyUtils.hpp"
73 #include "MueLu_SubBlockAFactory.hpp"
76 #include "MueLu_SchurComplementFactory.hpp"
77 #include "MueLu_DirectSolver.hpp"
78 #include "MueLu_SmootherFactory.hpp"
79 #include "MueLu_FactoryManager.hpp"
83 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
85 : type_(
"Uzawa"), A_(
Teuchos::null)
89 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
92 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
97 validParamList->
set< Scalar > (
"Damping factor", 1.0,
"Damping/Scaling factor in SIMPLE");
98 validParamList->
set< LocalOrdinal > (
"Sweeps", 1,
"Number of SIMPLE sweeps (default = 1)");
100 return validParamList;
104 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
108 size_t myPos = Teuchos::as<size_t>(pos);
110 if (myPos < FactManager_.size()) {
112 FactManager_.at(myPos) = FactManager;
113 }
else if( myPos == FactManager_.size()) {
115 FactManager_.push_back(FactManager);
118 *out <<
"Warning: cannot add new FactoryManager at proper position " << pos <<
". The FactoryManager is just appended to the end. Check this!" << std::endl;
121 FactManager_.push_back(FactManager);
127 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
129 AddFactoryManager(FactManager, 0);
132 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
134 AddFactoryManager(FactManager, 1);
137 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
139 currentLevel.
DeclareInput(
"A",this->GetFactory(
"A").get());
141 TEUCHOS_TEST_FOR_EXCEPTION(FactManager_.size() != 2,
Exceptions::RuntimeError,
"MueLu::UzawaSmoother::DeclareInput: You have to declare two FactoryManagers with a \"Smoother\" object: One for predicting the primary variable and one for the SchurComplement system. The smoother for the SchurComplement system needs a SchurComplementFactory as input for variable \"A\". make sure that you use the same proper damping factors for omega both in the SchurComplementFactory and in the SIMPLE smoother!");
144 std::vector<Teuchos::RCP<const FactoryManagerBase> >::const_iterator it;
145 for(it = FactManager_.begin(); it!=FactManager_.end(); ++it) {
149 currentLevel.
DeclareInput(
"PreSmoother",(*it)->GetFactory(
"Smoother").get());
153 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
156 FactoryMonitor m(*
this,
"Setup blocked Uzawa Smoother", currentLevel);
159 this->GetOStream(
Warnings0) <<
"MueLu::UzawaSmoother::Setup(): Setup() has already been called";
162 A_ = Factory::Get<RCP<Matrix> > (currentLevel,
"A");
168 rangeMapExtractor_ = bA->getRangeMapExtractor();
169 domainMapExtractor_ = bA->getDomainMapExtractor();
172 F_ = bA->getMatrix(0, 0);
173 G_ = bA->getMatrix(0, 1);
174 D_ = bA->getMatrix(1, 0);
175 Z_ = bA->getMatrix(1, 1);
193 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
202 bool bRangeThyraMode = rangeMapExtractor_->getThyraMode();
203 bool bDomainThyraMode = domainMapExtractor_->getThyraMode();
207 LocalOrdinal nSweeps = pL.
get<LocalOrdinal>(
"Sweeps");
208 Scalar omega = pL.
get<Scalar>(
"Damping factor");
215 bool bCopyResultX =
false;
221 if(bX.is_null() ==
true) {
233 bX = Teuchos::rcp_dynamic_cast<BlockedMultiVector>(rcpX);
234 bB = Teuchos::rcp_dynamic_cast<const BlockedMultiVector>(rcpB);
243 if(bX->getBlockedMap()->getNumMaps() != bA->getDomainMapExtractor()->NumMaps()) {
249 if(bB->getBlockedMap()->getNumMaps() != bA->getRangeMapExtractor()->NumMaps()) {
261 RCP<MultiVector> residual = MultiVectorFactory::Build(rcpB->getMap(), rcpB->getNumVectors());
267 RCP<MultiVector> xtilde = MultiVectorFactory::Build(rcpX->getMap(), rcpX->getNumVectors());
273 for (LocalOrdinal run = 0; run < nSweeps; ++run) {
275 residual->update(one,*rcpB,zero);
280 bxtilde->putScalar(zero);
281 velPredictSmoo_->Apply(*xtilde1,*r1);
285 RCP<MultiVector> schurCompRHS = MultiVectorFactory::Build(r2->getMap(),rcpB->getNumVectors());
286 D_->apply(*xtilde1,*schurCompRHS);
287 schurCompRHS->update(one,*r2,-one);
291 schurCompSmoo_->Apply(*xtilde2,*schurCompRHS);
293 rcpX->update(omega,*bxtilde,one);
296 if (bCopyResultX ==
true) {
298 X.update(one, *Xmerged, zero);
302 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
308 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
310 std::ostringstream out;
312 out <<
"{type = " << type_ <<
"}";
316 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
321 out0 <<
"Prec. type: " << type_ << std::endl;
324 if (verbLevel &
Debug) {
329 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>