53 #ifndef MUELU_INDEFBLOCKEDDIAGONALSMOOTHER_DEF_HPP_
54 #define MUELU_INDEFBLOCKEDDIAGONALSMOOTHER_DEF_HPP_
56 #include "Teuchos_ArrayViewDecl.hpp"
70 #include "MueLu_Utilities.hpp"
72 #include "MueLu_HierarchyUtils.hpp"
74 #include "MueLu_SubBlockAFactory.hpp"
77 #include "MueLu_SchurComplementFactory.hpp"
78 #include "MueLu_DirectSolver.hpp"
79 #include "MueLu_SmootherFactory.hpp"
80 #include "MueLu_FactoryManager.hpp"
84 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
86 : type_(
"IndefiniteBlockDiagonalSmoother"), A_(
Teuchos::null)
90 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
93 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
97 validParamList->
set<
RCP<const FactoryBase> >(
"A", Teuchos::null,
"Generating factory of the matrix A (must be a 2x2 block matrix)");
98 validParamList->
set< Scalar > (
"Damping factor", 1.0,
"Damping/Scaling factor");
99 validParamList->
set< LocalOrdinal > (
"Sweeps", 1,
"Number of SIMPLE sweeps (default = 1)");
102 return validParamList;
106 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
110 size_t myPos = Teuchos::as<size_t>(pos);
112 if (myPos < FactManager_.size()) {
114 FactManager_.at(myPos) = FactManager;
115 }
else if( myPos == FactManager_.size()) {
117 FactManager_.push_back(FactManager);
120 *out <<
"Warning: cannot add new FactoryManager at proper position " << pos <<
". The FactoryManager is just appended to the end. Check this!" << std::endl;
123 FactManager_.push_back(FactManager);
127 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
129 currentLevel.
DeclareInput(
"A",this->GetFactory(
"A").get());
131 TEUCHOS_TEST_FOR_EXCEPTION(FactManager_.size() != 2,
Exceptions::RuntimeError,
"MueLu::IndefBlockedDiagonalSmoother::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\"!");
134 std::vector<Teuchos::RCP<const FactoryManagerBase> >::const_iterator it;
135 for(it = FactManager_.begin(); it!=FactManager_.end(); ++it) {
139 currentLevel.
DeclareInput(
"PreSmoother",(*it)->GetFactory(
"Smoother").get());
144 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
146 FactoryMonitor m(*
this,
"Setup for indefinite blocked diagonal smoother", currentLevel);
149 this->GetOStream(
Warnings0) <<
"MueLu::IndefBlockedDiagonalSmoother::Setup(): Setup() has already been called";
152 A_ = Factory::Get<RCP<Matrix> > (currentLevel,
"A");
158 rangeMapExtractor_ = bA->getRangeMapExtractor();
159 domainMapExtractor_ = bA->getDomainMapExtractor();
211 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
222 LocalOrdinal nSweeps = pL.
get<LocalOrdinal>(
"Sweeps");
223 Scalar omega = pL.
get<Scalar>(
"Damping factor");
225 bool bRangeThyraMode = rangeMapExtractor_->getThyraMode();
226 bool bDomainThyraMode = domainMapExtractor_->getThyraMode();
233 bool bCopyResultX =
false;
239 if(bX.is_null() ==
true) {
251 bX = Teuchos::rcp_dynamic_cast<BlockedMultiVector>(rcpX);
252 bB = Teuchos::rcp_dynamic_cast<const BlockedMultiVector>(rcpB);
261 if(bX->getBlockedMap()->getNumMaps() != bA->getDomainMapExtractor()->NumMaps()) {
267 if(bB->getBlockedMap()->getNumMaps() != bA->getRangeMapExtractor()->NumMaps()) {
279 RCP<MultiVector> residual = MultiVectorFactory::Build(rcpB->getMap(), rcpB->getNumVectors());
285 RCP<MultiVector> xtilde = MultiVectorFactory::Build(rcpX->getMap(), rcpX->getNumVectors());
291 for (LocalOrdinal run = 0; run < nSweeps; ++run) {
293 residual->update(one,*rcpB,zero);
304 bxtilde->putScalar(zero);
305 velPredictSmoo_->Apply(*xtilde1,*r1);
309 schurCompSmoo_->Apply(*xtilde2,*r2);
312 rcpX->update(omega,*bxtilde,one);
319 x1->update(omega,*xtilde1,one);
320 x2->update(omega,*xtilde2,one);
323 domainMapExtractor_->InsertVector(x1, 0, rcpX, bDomainThyraMode);
324 domainMapExtractor_->InsertVector(x2, 1, rcpX, bDomainThyraMode);
328 if (bCopyResultX ==
true) {
330 X.update(one, *Xmerged, zero);
334 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
340 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
342 std::ostringstream out;
344 out <<
"{type = " << type_ <<
"}";
348 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
353 out0 <<
"Prec. type: " << type_ << std::endl;
356 if (verbLevel &
Debug) {
360 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>