53 #ifndef MUELU_BLOCKEDGAUSSSEIDELSMOOTHER_DEF_HPP_
54 #define MUELU_BLOCKEDGAUSSSEIDELSMOOTHER_DEF_HPP_
56 #include "Teuchos_ArrayViewDecl.hpp"
70 #include "MueLu_Utilities.hpp"
72 #include "MueLu_HierarchyUtils.hpp"
77 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
79 : type_(
"blocked GaussSeidel"), A_(
Teuchos::null)
84 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
87 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
92 validParamList->
set< Scalar > (
"Damping factor", 1.0,
"Damping/Scaling factor in BGS");
93 validParamList->
set< LocalOrdinal > (
"Sweeps", 1,
"Number of BGS sweeps (default = 1)");
95 return validParamList;
98 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
102 size_t myPos = Teuchos::as<size_t>(pos);
104 if (myPos < FactManager_.size()) {
106 FactManager_.at(myPos) = FactManager;
107 }
else if( myPos == FactManager_.size()) {
109 FactManager_.push_back(FactManager);
112 *out <<
"Warning: cannot add new FactoryManager at proper position " << pos <<
". The FactoryManager is just appended to the end. Check this!" << std::endl;
115 FactManager_.push_back(FactManager);
119 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
123 currentLevel.
DeclareInput(
"A",this->GetFactory(
"A").get());
126 std::vector<Teuchos::RCP<const FactoryManagerBase> >::const_iterator it;
127 for(it = FactManager_.begin(); it!=FactManager_.end(); ++it) {
131 currentLevel.
DeclareInput(
"PreSmoother",(*it)->GetFactory(
"Smoother").get());
134 currentLevel.
DeclareInput(
"A",(*it)->GetFactory(
"A").get());
140 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
146 FactoryMonitor m(*
this,
"Setup blocked Gauss-Seidel Smoother", currentLevel);
150 A_ = Factory::Get< RCP<Matrix> >(currentLevel,
"A");
155 TEUCHOS_TEST_FOR_EXCEPTION(bA->Rows() != FactManager_.size(),
Exceptions::RuntimeError,
"MueLu::BlockedGaussSeidelSmoother::Setup: number of block rows of A is " << bA->Rows() <<
" and does not match number of SubFactoryManagers " << FactManager_.size() <<
". error.");
156 TEUCHOS_TEST_FOR_EXCEPTION(bA->Cols() != FactManager_.size(),
Exceptions::RuntimeError,
"MueLu::BlockedGaussSeidelSmoother::Setup: number of block cols of A is " << bA->Cols() <<
" and does not match number of SubFactoryManagers " << FactManager_.size() <<
". error.");
159 rangeMapExtractor_ = bA->getRangeMapExtractor();
160 domainMapExtractor_ = bA->getDomainMapExtractor();
163 std::vector<Teuchos::RCP<const FactoryManagerBase> >::const_iterator it;
164 for(it = FactManager_.begin(); it!=FactManager_.end(); ++it) {
169 Inverse_.push_back(Smoo);
173 bIsBlockedOperator_.push_back(Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(Aii)!=Teuchos::null);
179 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
184 #if 0 // def HAVE_MUELU_DEBUG
191 if(rcpBDebugB.
is_null() ==
false) {
198 if(rcpBDebugX.
is_null() ==
false) {
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()) {
297 RCP<MultiVector> residual = MultiVectorFactory::Build(rcpB->getMap(), rcpB->getNumVectors());
298 RCP<MultiVector> tempres = MultiVectorFactory::Build(rcpB->getMap(), rcpB->getNumVectors());
302 LocalOrdinal nSweeps = pL.get<LocalOrdinal>(
"Sweeps");
303 Scalar omega = pL.get<Scalar>(
"Damping factor");
306 for (LocalOrdinal run = 0; run < nSweeps; ++run) {
309 for(
size_t i = 0; i<Inverse_.size(); i++) {
313 residual->update(1.0,*rcpB,0.0);
314 if(InitialGuessIsZero ==
false || i > 0 || run > 0)
319 bool bRangeThyraMode = rangeMapExtractor_->getThyraMode();
320 bool bDomainThyraMode = domainMapExtractor_->getThyraMode();
326 Inverse_.at(i)->Apply(*tXi, *ri,
false);
329 Xi->update(omega,*tXi,1.0);
332 domainMapExtractor_->InsertVector(Xi, i, rcpX, bDomainThyraMode);
336 if (bCopyResultX ==
true) {
338 X.update(one, *Xmerged, zero);
342 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
347 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
349 std::ostringstream out;
351 out <<
"{type = " << type_ <<
"}";
355 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
361 LocalOrdinal nSweeps = pL.
get<LocalOrdinal>(
"Sweeps");
362 Scalar omega = pL.
get<Scalar>(
"Damping factor");
365 out0 <<
"Prec. type: " << type_ <<
" Sweeps: " << nSweeps <<
" damping: " << omega << std::endl;
368 if (verbLevel &
Debug) {
372 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>