10 #ifndef MUELU_HIERARCHY_DEF_HPP
11 #define MUELU_HIERARCHY_DEF_HPP
19 #include <Xpetra_MultiVectorFactory.hpp>
25 #include "MueLu_FactoryManager.hpp"
26 #include "MueLu_HierarchyUtils.hpp"
27 #include "MueLu_TopRAPFactory.hpp"
28 #include "MueLu_TopSmootherFactory.hpp"
31 #include "MueLu_PerfUtils.hpp"
32 #include "MueLu_PFactory.hpp"
33 #include "MueLu_SmootherFactory.hpp"
40 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
42 : maxCoarseSize_(GetDefaultMaxCoarseSize())
43 , implicitTranspose_(GetDefaultImplicitTranspose())
44 , fuseProlongationAndUpdate_(GetDefaultFuseProlongationAndUpdate())
45 , doPRrebalance_(GetDefaultPRrebalance())
46 , doPRViaCopyrebalance_(false)
47 , isPreconditioner_(true)
48 , Cycle_(GetDefaultCycle())
49 , WCycleStartLevel_(0)
50 , scalingFactor_(Teuchos::ScalarTraits<double>::one())
52 , isDumpingEnabled_(false)
55 , sizeOfAllocatedLevelMultiVectors_(0) {
59 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
63 Levels_[0]->setObjectLabel(label);
66 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
68 : maxCoarseSize_(GetDefaultMaxCoarseSize())
69 , implicitTranspose_(GetDefaultImplicitTranspose())
70 , fuseProlongationAndUpdate_(GetDefaultFuseProlongationAndUpdate())
71 , doPRrebalance_(GetDefaultPRrebalance())
72 , doPRViaCopyrebalance_(false)
73 , isPreconditioner_(true)
74 , Cycle_(GetDefaultCycle())
75 , WCycleStartLevel_(0)
76 , scalingFactor_(Teuchos::ScalarTraits<double>::one())
77 , isDumpingEnabled_(false)
80 , sizeOfAllocatedLevelMultiVectors_(0) {
81 lib_ = A->getDomainMap()->lib();
89 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
93 Levels_[0]->setObjectLabel(label);
96 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
99 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
101 int levelID = LastLevelID() + 1;
104 GetOStream(
Warnings1) <<
"Hierarchy::AddLevel(): Level with ID=" << level->
GetLevelID() <<
" have been added at the end of the hierarchy\n but its ID have been redefined"
105 <<
" because last level ID of the hierarchy was " << LastLevelID() <<
"." << std::endl;
107 Levels_.push_back(level);
111 level->
SetPreviousLevel((levelID == 0) ? Teuchos::null : Levels_[LastLevelID() - 1]);
115 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
117 RCP<Level> newLevel = Levels_[LastLevelID()]->Build();
119 this->AddLevel(newLevel);
122 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
125 "MueLu::Hierarchy::GetLevel(): invalid input parameter value: LevelID = " << levelID);
126 return Levels_[levelID];
129 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
131 return Levels_.size();
134 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
136 RCP<Operator> A = Levels_[0]->template Get<RCP<Operator>>(
"A");
139 int numLevels = GetNumLevels();
143 return numGlobalLevels;
146 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
148 double totalNnz = 0, lev0Nnz = 1;
149 for (
int i = 0; i < GetNumLevels(); ++i) {
151 "Operator complexity cannot be calculated because A is unavailable on level " << i);
152 RCP<Operator> A = Levels_[i]->template Get<RCP<Operator>>(
"A");
158 GetOStream(
Warnings0) <<
"Some level operators are not matrices, operator complexity calculation aborted" << std::endl;
162 totalNnz += as<double>(Am->getGlobalNumEntries());
166 return totalNnz / lev0Nnz;
169 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
171 double node_sc = 0, global_sc = 0;
175 if (GetNumLevels() <= 0)
return -1.0;
176 if (!Levels_[0]->IsAvailable(
"A"))
return -1.0;
178 RCP<Operator> A = Levels_[0]->template Get<RCP<Operator>>(
"A");
182 a0_nnz = as<double>(Am->getGlobalNumEntries());
185 for (
int i = 0; i < GetNumLevels(); ++i) {
187 if (!Levels_[i]->IsAvailable(
"PreSmoother"))
continue;
188 RCP<SmootherBase> S = Levels_[i]->template Get<RCP<SmootherBase>>(
"PreSmoother");
191 if (level_sc == INVALID) {
196 node_sc += as<double>(level_sc);
207 return global_sc / a0_nnz;
211 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
214 "MueLu::Hierarchy::CheckLevel(): wrong underlying linear algebra library.");
216 "MueLu::Hierarchy::CheckLevel(): wrong level ID");
218 "MueLu::Hierarchy::Setup(): wrong level parent");
221 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
223 for (
int i = 0; i < GetNumLevels(); ++i) {
231 xpImporter->setDistributorParameters(matvecParams);
234 xpExporter->setDistributorParameters(matvecParams);
241 xpImporter->setDistributorParameters(matvecParams);
244 xpExporter->setDistributorParameters(matvecParams);
250 xpImporter->setDistributorParameters(matvecParams);
253 xpExporter->setDistributorParameters(matvecParams);
258 xpImporter->setDistributorParameters(matvecParams);
265 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
274 "MueLu::Hierarchy:Setup(): level " << coarseLevelID <<
" (specified by coarseLevelID argument) "
275 "must be built before calling this function.");
277 Level& level = *Levels_[coarseLevelID];
279 bool useStackedTimer = !Teuchos::TimeMonitor::stackedTimerNameIsDefault();
283 if (!useStackedTimer)
284 m1 =
rcp(
new TimeMonitor(*
this, label + this->ShortClassName() +
": " +
"Setup (total)"));
289 "MueLu::Hierarchy::Setup(): argument coarseLevelManager cannot be null");
294 if (levelManagers_.size() < coarseLevelID + 1)
295 levelManagers_.resize(coarseLevelID + 1);
296 levelManagers_[coarseLevelID] = coarseLevelManager;
298 bool isFinestLevel = (fineLevelManager.
is_null());
299 bool isLastLevel = (nextLevelManager.
is_null());
312 oldRank = SetProcRankVerbose(comm->getRank());
316 lib_ = domainMap->lib();
323 Level& prevLevel = *Levels_[coarseLevelID - 1];
324 oldRank = SetProcRankVerbose(prevLevel.
GetComm()->getRank());
327 CheckLevel(level, coarseLevelID);
334 if (isFinestLevel && Levels_[coarseLevelID]->IsAvailable(
"Coordinates"))
335 ReplaceCoordinateMap(*Levels_[coarseLevelID]);
340 if (isDumpingEnabled_ && (dumpLevel_ == 0 || dumpLevel_ == -1) && coarseLevelID == 1)
346 int nextLevelID = coarseLevelID + 1;
349 if (isLastLevel ==
false) {
351 if (nextLevelID > LastLevelID())
353 CheckLevel(*Levels_[nextLevelID], nextLevelID);
357 Levels_[nextLevelID]->Request(TopRAPFactory(coarseLevelManager, nextLevelManager));
387 coarseFact =
rcp(
new TopSmootherFactory(coarseLevelManager,
"CoarseSolver"));
396 TopRAPFactory coarseRAPFactory(fineLevelManager, coarseLevelManager);
400 }
else if (!isFinestLevel) {
405 bool setLastLevelviaMaxCoarseSize =
false;
412 level.
SetComm(Ac->getDomainMap()->getComm());
415 bool isOrigLastLevel = isLastLevel;
427 if (!Acm.
is_null() && Acm->getGlobalNumRows() <= maxCoarseSize_) {
429 GetOStream(
Runtime0) <<
"Max coarse size (<= " << maxCoarseSize_ <<
") achieved" << std::endl;
431 if (Acm->getGlobalNumRows() != 0) setLastLevelviaMaxCoarseSize =
true;
435 if (!Ac.
is_null() && !isFinestLevel) {
436 RCP<Operator> A = Levels_[coarseLevelID - 1]->template Get<RCP<Operator>>(
"A");
439 const double maxCoarse2FineRatio = 0.8;
440 if (!Acm.
is_null() && !Am.is_null() && Acm->getGlobalNumRows() > maxCoarse2FineRatio * Am->getGlobalNumRows()) {
448 GetOStream(
Warnings0) <<
"Aggregation stagnated. Please check your matrix and/or adjust your configuration file."
449 <<
"Possible fixes:\n"
450 <<
" - reduce the maximum number of levels\n"
451 <<
" - enable repartitioning\n"
452 <<
" - increase the minimum coarse size." << std::endl;
457 if (!isOrigLastLevel) {
462 coarseFact =
rcp(
new TopSmootherFactory(coarseLevelManager,
"CoarseSolver"));
469 coarseFact->
Build(level);
480 smootherFact->
Build(level);
485 if (isLastLevel ==
true) {
486 int actualNumLevels = nextLevelID;
487 if (isOrigLastLevel ==
false) {
490 Levels_[nextLevelID]->Release(TopRAPFactory(coarseLevelManager, nextLevelManager));
496 if (!setLastLevelviaMaxCoarseSize) {
497 if (Levels_[nextLevelID - 1]->IsAvailable(
"P")) {
498 if (Levels_[nextLevelID - 1]->
template Get<
RCP<Matrix>>(
"P") == Teuchos::null) actualNumLevels = nextLevelID - 1;
500 actualNumLevels = nextLevelID - 1;
503 if (actualNumLevels == nextLevelID - 1) {
505 Levels_[nextLevelID - 2]->Release(*smootherFact);
507 if (Levels_[nextLevelID - 2]->IsAvailable(
"PreSmoother")) Levels_[nextLevelID - 2]->RemoveKeepFlag(
"PreSmoother",
NoFactory::get());
508 if (Levels_[nextLevelID - 2]->IsAvailable(
"PostSmoother")) Levels_[nextLevelID - 2]->RemoveKeepFlag(
"PostSmoother",
NoFactory::get());
510 coarseFact =
rcp(
new TopSmootherFactory(coarseLevelManager,
"CoarseSolver"));
511 Levels_[nextLevelID - 2]->Request(*coarseFact);
513 coarseFact->
Build(*(Levels_[nextLevelID - 2]));
514 Levels_[nextLevelID - 2]->Release(*coarseFact);
516 Levels_.resize(actualNumLevels);
520 if (isDumpingEnabled_ && ((dumpLevel_ > 0 && coarseLevelID == dumpLevel_) || dumpLevel_ == -1))
521 DumpCurrentGraph(coarseLevelID);
523 if (!isFinestLevel) {
527 level.
Release(coarseRAPFactory);
531 SetProcRankVerbose(oldRank);
536 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
538 int numLevels = Levels_.size();
540 "Hierarchy::SetupRe: " << Levels_.size() <<
" levels, but " << levelManagers_.size() <<
" level factory managers");
542 const int startLevel = 0;
545 #ifdef HAVE_MUELU_DEBUG
547 for (
int i = 0; i < numLevels; i++)
548 levelManagers_[i]->ResetDebugData();
553 for (levelID = startLevel; levelID < numLevels;) {
554 bool r = Setup(levelID,
555 (levelID != 0 ? levelManagers_[levelID - 1] : Teuchos::null),
556 levelManagers_[levelID],
557 (levelID + 1 != numLevels ? levelManagers_[levelID + 1] : Teuchos::null));
563 Levels_.resize(levelID);
564 levelManagers_.resize(levelID);
566 int sizeOfVecs = sizeOfAllocatedLevelMultiVectors_;
568 AllocateLevelMultiVectors(sizeOfVecs,
true);
575 CheckForEmptySmoothersAndCoarseSolve();
578 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
587 "MueLu::Hierarchy::Setup(): fine level (" << startLevel <<
") does not exist");
590 "Constructing non-positive (" << numDesiredLevels <<
") number of levels does not make sense.");
593 TEUCHOS_TEST_FOR_EXCEPTION(!Levels_[startLevel]->IsAvailable(
"A"), Exceptions::RuntimeError,
594 "MueLu::Hierarchy::Setup(): fine level (" << startLevel <<
") has no matrix A! "
595 "Set fine level matrix A using Level.Set()");
597 RCP<Operator> A = Levels_[startLevel]->template Get<RCP<Operator>>(
"A");
598 lib_ = A->getDomainMap()->lib();
605 params->
set(
"printLoadBalancingInfo",
true);
606 params->
set(
"printCommInfo",
true);
610 GetOStream(
Warnings1) <<
"Fine level operator is not a matrix, statistics are not available" << std::endl;
616 const int lastLevel = startLevel + numDesiredLevels - 1;
617 GetOStream(
Runtime0) <<
"Setup loop: startLevel = " << startLevel <<
", lastLevel = " << lastLevel
618 <<
" (stop if numLevels = " << numDesiredLevels <<
" or Ac.size() < " << maxCoarseSize_ <<
")" << std::endl;
622 if (numDesiredLevels == 1) {
624 Setup(startLevel, Teuchos::null, rcpmanager, Teuchos::null);
627 bool bIsLastLevel = Setup(startLevel, Teuchos::null, rcpmanager, rcpmanager);
628 if (bIsLastLevel ==
false) {
629 for (iLevel = startLevel + 1; iLevel < lastLevel; iLevel++) {
630 bIsLastLevel = Setup(iLevel, rcpmanager, rcpmanager, rcpmanager);
631 if (bIsLastLevel ==
true)
634 if (bIsLastLevel ==
false)
635 Setup(lastLevel, rcpmanager, rcpmanager, Teuchos::null);
640 TEUCHOS_TEST_FOR_EXCEPTION(iLevel != Levels_.size() - 1, Exceptions::RuntimeError,
641 "MueLu::Hierarchy::Setup(): number of level");
649 CheckForEmptySmoothersAndCoarseSolve();
652 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
654 for (
LO levelNo = 0; levelNo < GetNumLevels(); ++levelNo) {
655 auto level = Levels_[levelNo];
656 if ((level->IsAvailable(
"A") && !level->template Get<RCP<Operator>>(
"A").
is_null()) && (!level->IsAvailable(
"PreSmoother")) && (!level->IsAvailable(
"PostSmoother"))) {
657 GetOStream(
Warnings1) <<
"No " << (levelNo == as<LO>(Levels_.size()) - 1 ?
"coarse grid solver" :
"smoother") <<
" on level " << level->GetLevelID() << std::endl;
662 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
664 if (startLevel < GetNumLevels())
665 GetOStream(
Runtime0) <<
"Clearing old data (if any)" << std::endl;
667 for (
int iLevel = startLevel; iLevel < GetNumLevels(); iLevel++)
668 Levels_[iLevel]->Clear();
671 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
673 GetOStream(
Runtime0) <<
"Clearing old data (expert)" << std::endl;
674 for (
int iLevel = 0; iLevel < GetNumLevels(); iLevel++)
675 Levels_[iLevel]->ExpertClear();
678 #if defined(HAVE_MUELU_EXPERIMENTAL) && defined(HAVE_MUELU_ADDITIVE_VARIANT)
679 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
681 bool InitialGuessIsZero,
LO startLevel) {
682 LO nIts = conv.maxIts_;
683 MagnitudeType tol = conv.tol_;
685 std::string prefix = this->ShortClassName() +
": ";
686 std::string levelSuffix =
" (level=" +
toString(startLevel) +
")";
687 std::string levelSuffix1 =
" (level=" +
toString(startLevel + 1) +
")";
689 using namespace Teuchos;
713 SC one = STS::one(), zero = STS::zero();
715 bool zeroGuess = InitialGuessIsZero;
726 bool emptyCoarseSolve =
true;
727 RCP<MultiVector> coarseX_prolonged = MultiVectorFactory::Build(X.getMap(), X.getNumVectors(),
true);
731 if (Levels_.size() > 1) {
733 if (Coarse->IsAvailable(
"Importer"))
742 coarseRhs = MultiVectorFactory::Build(R->getRangeMap(), B.getNumVectors(),
true);
751 if (doPRrebalance_ || importer.is_null()) {
752 coarseX = MultiVectorFactory::Build(coarseRhs->getMap(), X.getNumVectors(),
true);
759 RCP<MultiVector> coarseTmp = MultiVectorFactory::Build(importer->getTargetMap(), coarseRhs->getNumVectors());
761 coarseRhs.
swap(coarseTmp);
763 coarseX = MultiVectorFactory::Build(importer->getTargetMap(), X.getNumVectors(),
true);
766 if (Coarse->IsAvailable(
"PreSmoother"))
768 if (Coarse->IsAvailable(
"PostSmoother"))
774 MagnitudeType prevNorm = STS::magnitude(STS::one()), curNorm = STS::magnitude(STS::one());
777 for (
LO i = 1; i <= nIts; i++) {
778 #ifdef HAVE_MUELU_DEBUG
779 if (A->getDomainMap()->isCompatible(*(X.getMap())) ==
false) {
780 std::ostringstream ss;
781 ss <<
"Level " << startLevel <<
": level A's domain map is not compatible with X";
782 throw Exceptions::Incompatible(ss.str());
785 if (A->getRangeMap()->isCompatible(*(B.getMap())) ==
false) {
786 std::ostringstream ss;
787 ss <<
"Level " << startLevel <<
": level A's range map is not compatible with B";
788 throw Exceptions::Incompatible(ss.str());
793 bool emptyFineSolve =
true;
796 fineX = MultiVectorFactory::Build(X.getMap(), X.getNumVectors(),
true);
805 if (Fine->IsAvailable(
"PreSmoother")) {
808 preSmoo->Apply(*fineX, B, zeroGuess);
810 emptyFineSolve =
false;
812 if (Fine->IsAvailable(
"PostSmoother")) {
815 postSmoo->Apply(*fineX, B, zeroGuess);
818 emptyFineSolve =
false;
820 if (emptyFineSolve ==
true) {
822 fineX->update(one, B, zero);
825 if (Levels_.size() > 1) {
827 if (Coarse->IsAvailable(
"PreSmoother")) {
829 preSmoo_coarse->Apply(*coarseX, *coarseRhs, zeroGuess);
831 emptyCoarseSolve =
false;
833 if (Coarse->IsAvailable(
"PostSmoother")) {
835 postSmoo_coarse->Apply(*coarseX, *coarseRhs, zeroGuess);
837 emptyCoarseSolve =
false;
839 if (emptyCoarseSolve ==
true) {
841 coarseX->update(one, *coarseRhs, zero);
848 if (!doPRrebalance_ && !importer.is_null()) {
853 RCP<MultiVector> coarseTmp = MultiVectorFactory::Build(importer->getSourceMap(), coarseX->getNumVectors());
855 coarseX.
swap(coarseTmp);
864 X.update(1.0, *fineX, 1.0, *coarseX_prolonged, 0.0);
875 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
877 bool InitialGuessIsZero,
LO startLevel) {
896 std::string prefix = label + this->ShortClassName() +
": ";
897 std::string levelSuffix =
" (level=" +
toString(startLevel) +
")";
898 std::string levelSuffix1 =
" (level=" +
toString(startLevel + 1) +
")";
900 bool useStackedTimer = !Teuchos::TimeMonitor::stackedTimerNameIsDefault();
906 else if (!useStackedTimer)
909 std::string iterateLevelTimeLabel = prefix +
"Solve" + levelSuffix;
912 bool zeroGuess = InitialGuessIsZero;
915 using namespace Teuchos;
929 const BlockedMultiVector* Bblocked =
dynamic_cast<const BlockedMultiVector*
>(&B);
930 if (residual_.size() > startLevel &&
931 ((Bblocked && !Bblocked->isSameSize(*residual_[startLevel])) ||
932 (!Bblocked && !residual_[startLevel]->isSameSize(B))))
933 DeleteLevelMultiVectors();
934 AllocateLevelMultiVectors(X.getNumVectors());
940 if (IsCalculationOfResidualRequired(startLevel, conv)) {
943 return convergenceStatus;
946 SC one = STS::one(), zero = STS::zero();
947 for (
LO iteration = 1; iteration <= nIts; iteration++) {
948 #ifdef HAVE_MUELU_DEBUG
950 if (A->getDomainMap()->isCompatible(*(X.getMap())) ==
false) {
951 std::ostringstream ss;
952 ss <<
"Level " << startLevel <<
": level A's domain map is not compatible with X";
956 if (A->getRangeMap()->isCompatible(*(B.getMap())) ==
false) {
957 std::ostringstream ss;
958 ss <<
"Level " << startLevel <<
": level A's range map is not compatible with B";
964 if (startLevel == as<LO>(Levels_.size()) - 1) {
968 bool emptySolve =
true;
971 if (Fine->IsAvailable(
"PreSmoother")) {
974 preSmoo->Apply(X, B, zeroGuess);
979 if (Fine->IsAvailable(
"PostSmoother")) {
982 postSmoo->Apply(X, B, zeroGuess);
987 if (emptySolve ==
true) {
989 X.update(one, B, zero);
998 if (!useStackedTimer)
1002 if (Fine->IsAvailable(
"PreSmoother")) {
1004 preSmoo->Apply(X, B, zeroGuess);
1012 if (!useStackedTimer)
1022 residual = residual_[startLevel];
1026 if (Coarse->IsAvailable(
"Pbar"))
1034 if (!useStackedTimer)
1037 coarseRhs = coarseRhs_[startLevel];
1039 if (implicitTranspose_) {
1049 if (Coarse->IsAvailable(
"Importer"))
1052 coarseX = coarseX_[startLevel];
1053 if (!doPRrebalance_ && !importer.
is_null()) {
1055 if (!useStackedTimer)
1062 coarseRhs.
swap(coarseTmp);
1071 coarseRhs->replaceMap(Ac->getRangeMap());
1072 coarseX->replaceMap(Ac->getDomainMap());
1075 iterateLevelTime = Teuchos::null;
1077 Iterate(*coarseRhs, *coarseX, 1,
true, startLevel + 1);
1079 if (Cycle_ ==
WCYCLE && WCycleStartLevel_ >= startLevel)
1080 Iterate(*coarseRhs, *coarseX, 1,
false, startLevel + 1);
1083 iterateLevelTime =
rcp(
new TimeMonitor(*
this, iterateLevelTimeLabel));
1085 coarseX->replaceMap(origXMap);
1086 coarseRhs->replaceMap(origRhsMap);
1089 if (!doPRrebalance_ && !importer.
is_null()) {
1091 if (!useStackedTimer)
1098 coarseX.
swap(coarseTmp);
1104 if (!useStackedTimer)
1111 if (fuseProlongationAndUpdate_) {
1116 X.update(scalingFactor_, *correction, one);
1123 if (!useStackedTimer)
1127 if (Fine->IsAvailable(
"PostSmoother")) {
1129 postSmoo->Apply(X, B,
false);
1135 if (IsCalculationOfResidualRequired(startLevel, conv)) {
1136 ConvergenceStatus convergenceStatus = ComputeResidualAndPrintHistory(*A, X, B, iteration, startLevel, conv, prevNorm);
1138 return convergenceStatus;
1145 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1147 LO startLevel = (start != -1 ? start : 0);
1148 LO endLevel = (end != -1 ? end : Levels_.size() - 1);
1151 "MueLu::Hierarchy::Write : startLevel must be <= endLevel");
1154 "MueLu::Hierarchy::Write bad start or end level");
1156 for (
LO i = startLevel; i < endLevel + 1; i++) {
1157 RCP<Matrix> A = rcp_dynamic_cast<Matrix>(Levels_[i]->template Get<RCP<Operator>>(
"A")), P, R;
1159 P = rcp_dynamic_cast<Matrix>(Levels_[i]->template Get<RCP<Operator>>(
"P"));
1160 if (!implicitTranspose_)
1161 R = rcp_dynamic_cast<Matrix>(Levels_[i]->template Get<RCP<Operator>>(
"R"));
1174 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1176 for (
Array<
RCP<Level>>::iterator it = Levels_.begin(); it != Levels_.end(); ++it)
1177 (*it)->Keep(ename, factory);
1180 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1182 for (
Array<
RCP<Level>>::iterator it = Levels_.begin(); it != Levels_.end(); ++it)
1183 (*it)->Delete(ename, factory);
1186 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1188 for (
Array<
RCP<Level>>::iterator it = Levels_.begin(); it != Levels_.end(); ++it)
1189 (*it)->AddKeepFlag(ename, factory, keep);
1192 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1194 for (
Array<
RCP<Level>>::iterator it = Levels_.begin(); it != Levels_.end(); ++it)
1195 (*it)->RemoveKeepFlag(ename, factory, keep);
1198 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1200 if (description_.empty()) {
1201 std::ostringstream out;
1203 out <<
"{#levels = " << GetGlobalNumLevels() <<
", complexity = " << GetOperatorComplexity() <<
"}";
1204 description_ = out.str();
1206 return description_;
1209 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1214 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1216 RCP<Operator> A0 = Levels_[0]->template Get<RCP<Operator>>(
"A");
1219 int numLevels = GetNumLevels();
1220 RCP<Operator> Ac = Levels_[numLevels - 1]->template Get<RCP<Operator>>(
"A");
1227 int root = comm->getRank();
1230 int smartData = numLevels * comm->getSize() + comm->getRank(), maxSmartData;
1232 root = maxSmartData % comm->getSize();
1236 double smoother_comp = -1.0;
1238 smoother_comp = GetSmootherComplexity();
1242 std::vector<Xpetra::global_size_t> nnzPerLevel;
1243 std::vector<Xpetra::global_size_t> rowsPerLevel;
1244 std::vector<int> numProcsPerLevel;
1245 bool someOpsNotMatrices =
false;
1247 for (
int i = 0; i < numLevels; i++) {
1249 "Operator A is not available on level " << i);
1251 RCP<Operator> A = Levels_[i]->template Get<RCP<Operator>>(
"A");
1253 "Operator A on level " << i <<
" is null.");
1257 someOpsNotMatrices =
true;
1258 nnzPerLevel.push_back(INVALID);
1259 rowsPerLevel.push_back(A->getDomainMap()->getGlobalNumElements());
1260 numProcsPerLevel.push_back(A->getDomainMap()->getComm()->getSize());
1262 LO storageblocksize = Am->GetStorageBlockSize();
1264 nnzPerLevel.push_back(nnz);
1265 rowsPerLevel.push_back(Am->getGlobalNumRows() * storageblocksize);
1266 numProcsPerLevel.push_back(Am->getRowMap()->getComm()->getSize());
1269 if (someOpsNotMatrices)
1270 GetOStream(
Warnings0) <<
"Some level operators are not matrices, statistics calculation are incomplete" << std::endl;
1273 std::string label = Levels_[0]->getObjectLabel();
1274 std::ostringstream oss;
1275 oss << std::setfill(
' ');
1276 oss <<
"\n--------------------------------------------------------------------------------\n";
1277 oss <<
"--- Multigrid Summary " << std::setw(28) << std::left << label <<
"---\n";
1278 oss <<
"--------------------------------------------------------------------------------" << std::endl;
1281 oss <<
"Number of levels = " << numLevels << std::endl;
1282 oss <<
"Operator complexity = " << std::setprecision(2) << std::setiosflags(std::ios::fixed);
1283 if (!someOpsNotMatrices)
1284 oss << GetOperatorComplexity() << std::endl;
1286 oss <<
"not available (Some operators in hierarchy are not matrices.)" << std::endl;
1288 if (smoother_comp != -1.0) {
1289 oss <<
"Smoother complexity = " << std::setprecision(2) << std::setiosflags(std::ios::fixed)
1290 << smoother_comp << std::endl;
1295 oss <<
"Cycle type = V" << std::endl;
1298 oss <<
"Cycle type = W" << std::endl;
1299 if (WCycleStartLevel_ > 0)
1300 oss <<
"Cycle start level = " << WCycleStartLevel_ << std::endl;
1313 for (
size_t i = 0; i < nnzPerLevel.size(); ++i) {
1314 tt = nnzPerLevel[i];
1324 tt = numProcsPerLevel[0];
1330 oss <<
"level " << std::setw(rowspacer) <<
" rows " << std::setw(nnzspacer) <<
" nnz "
1331 <<
" nnz/row" << std::setw(npspacer) <<
" c ratio"
1332 <<
" procs" << std::endl;
1333 for (
size_t i = 0; i < nnzPerLevel.size(); ++i) {
1334 oss <<
" " << i <<
" ";
1335 oss << std::setw(rowspacer) << rowsPerLevel[i];
1336 if (nnzPerLevel[i] != INVALID) {
1337 oss << std::setw(nnzspacer) << nnzPerLevel[i];
1338 oss << std::setprecision(2) << std::setiosflags(std::ios::fixed);
1339 oss << std::setw(9) << as<double>(nnzPerLevel[i]) / rowsPerLevel[i];
1341 oss << std::setw(nnzspacer) <<
"Operator";
1342 oss << std::setprecision(2) << std::setiosflags(std::ios::fixed);
1343 oss << std::setw(9) <<
" ";
1346 oss << std::setw(9) << as<double>(rowsPerLevel[i - 1]) / rowsPerLevel[i];
1348 oss << std::setw(9) <<
" ";
1349 oss <<
" " << std::setw(npspacer) << numProcsPerLevel[i] << std::endl;
1352 for (
int i = 0; i < GetNumLevels(); ++i) {
1354 if (Levels_[i]->IsAvailable(
"PreSmoother"))
1356 if (Levels_[i]->IsAvailable(
"PostSmoother"))
1359 if (preSmoo != null && preSmoo == postSmoo)
1360 oss <<
"Smoother (level " << i <<
") both : " << preSmoo->
description() << std::endl;
1362 oss <<
"Smoother (level " << i <<
") pre : "
1363 << (preSmoo != null ? preSmoo->
description() :
"no smoother") << std::endl;
1364 oss <<
"Smoother (level " << i <<
") post : "
1365 << (postSmoo != null ? postSmoo->
description() :
"no smoother") << std::endl;
1377 MPI_Comm rawComm = (*mpiComm->getRawMpiComm())();
1379 int strLength = outstr.size();
1380 MPI_Bcast(&strLength, 1, MPI_INT, root, rawComm);
1381 if (comm->getRank() != root)
1382 outstr.resize(strLength);
1383 MPI_Bcast(&outstr[0], strLength, MPI_CHAR, root, rawComm);
1390 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1393 for (
int i = 0; i < GetNumLevels(); ++i)
1394 Levels_[i]->print(out, verbLevel);
1397 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1399 isPreconditioner_ = flag;
1402 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1404 if (GetProcRankVerbose() != 0)
1406 #if defined(HAVE_MUELU_BOOST) && defined(HAVE_MUELU_BOOST_FOR_REAL) && defined(BOOST_VERSION) && (BOOST_VERSION >= 104400)
1411 dp.property(
"label", boost::get(boost::vertex_name, graph));
1412 dp.property(
"id", boost::get(boost::vertex_index, graph));
1413 dp.property(
"label", boost::get(boost::edge_name, graph));
1414 dp.property(
"color", boost::get(boost::edge_color, graph));
1417 std::map<const FactoryBase*, BoostVertex> vindices;
1418 typedef std::map<std::pair<BoostVertex, BoostVertex>, std::string> emap;
1421 static int call_id = 0;
1423 RCP<Operator> A = Levels_[0]->template Get<RCP<Operator>>(
"A");
1424 int rank = A->getDomainMap()->getComm()->getRank();
1427 for (
int i = currLevel; i <= currLevel + 1 && i < GetNumLevels(); i++) {
1429 Levels_[i]->UpdateGraph(vindices, edges, dp, graph);
1431 for (emap::const_iterator eit = edges.begin(); eit != edges.end(); eit++) {
1432 std::pair<BoostEdge, bool> boost_edge = boost::add_edge(eit->first.first, eit->first.second, graph);
1435 if (eit->second == std::string(
"Graph"))
1436 boost::put(
"label", dp, boost_edge.first, std::string(
"Graph_"));
1438 boost::put(
"label", dp, boost_edge.first, eit->second);
1440 boost::put(
"color", dp, boost_edge.first, std::string(
"red"));
1442 boost::put(
"color", dp, boost_edge.first, std::string(
"blue"));
1446 std::ofstream out(dumpFile_.c_str() + std::string(
"_") + std::to_string(currLevel) + std::string(
"_") + std::to_string(call_id) + std::string(
"_") + std::to_string(rank) + std::string(
".dot"));
1447 boost::write_graphviz_dp(out, graph, dp, std::string(
"id"));
1451 GetOStream(
Errors) <<
"Dependency graph output requires boost and MueLu_ENABLE_Boost_for_real" << std::endl;
1456 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1461 GetOStream(
Runtime1) <<
"Hierarchy::ReplaceCoordinateMap: operator is not a matrix, skipping..." << std::endl;
1464 if (Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(A) != Teuchos::null) {
1465 GetOStream(
Runtime1) <<
"Hierarchy::ReplaceCoordinateMap: operator is a BlockedCrsMatrix, skipping..." << std::endl;
1473 if (A->getRowMap()->isSameAs(*(coords->getMap()))) {
1474 GetOStream(
Runtime1) <<
"Hierarchy::ReplaceCoordinateMap: matrix and coordinates maps are same, skipping..." << std::endl;
1478 if (A->IsView(
"stridedMaps") && rcp_dynamic_cast<
const StridedMap>(A->getRowMap(
"stridedMaps")) != Teuchos::null) {
1479 RCP<const StridedMap> stridedRowMap = rcp_dynamic_cast<
const StridedMap>(A->getRowMap(
"stridedMaps"));
1483 Exceptions::RuntimeError,
"Hierarchy::ReplaceCoordinateMap: nontrivial maps (block id = " << stridedRowMap->getStridedBlockId() <<
", offset = " << stridedRowMap->getOffset() <<
")");
1486 GetOStream(
Runtime1) <<
"Replacing coordinate map" << std::endl;
1489 size_t blkSize = A->GetFixedBlockSize() / A->GetStorageBlockSize();
1495 GO indexBase = dofMap->getIndexBase();
1496 size_t numLocalDOFs = dofMap->getLocalNumElements();
1498 "Hierarchy::ReplaceCoordinateMap: block size (" << blkSize <<
") is incompatible with the number of local dofs in a row map (" << numLocalDOFs);
1501 Array<GO> nodeGIDs(numLocalDOFs / blkSize);
1502 for (
size_t i = 0; i < numLocalDOFs; i += blkSize)
1503 nodeGIDs[i / blkSize] = (GIDs[i] - indexBase) / blkSize + indexBase;
1506 nodeMap = MapFactory::Build(dofMap->lib(), INVALID, nodeGIDs(), indexBase, dofMap->getComm());
1512 if (coords->getLocalLength() != A->getRowMap()->getLocalNumElements()) {
1513 GetOStream(
Warnings) <<
"Coordinate vector does not match row map of matrix A!" << std::endl;
1519 std::vector<ArrayRCP<const typename Teuchos::ScalarTraits<Scalar>::coordinateType>> coordData;
1520 for (
size_t i = 0; i < coords->getNumVectors(); i++) {
1521 coordData.
push_back(coords->getData(i));
1522 coordDataView.
push_back(coordData[i]());
1526 level.
Set(
"Coordinates", newCoords);
1529 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1531 int N = Levels_.size();
1532 if (((sizeOfAllocatedLevelMultiVectors_ == numvecs && residual_.size() == N) || numvecs <= 0) && !forceMapCheck)
return;
1535 if (residual_.size() != N) {
1536 DeleteLevelMultiVectors();
1538 residual_.resize(N);
1539 coarseRhs_.resize(N);
1541 coarseImport_.resize(N);
1542 coarseExport_.resize(N);
1543 correction_.resize(N);
1546 for (
int i = 0; i < N; i++) {
1547 RCP<Operator> A = Levels_[i]->template Get<RCP<Operator>>(
"A");
1553 if (!A_as_blocked.
is_null()) {
1554 Adm = A_as_blocked->getFullDomainMap();
1557 if (residual_[i].
is_null() || !residual_[i]->getMap()->isSameAs(*Arm))
1559 residual_[i] = MultiVectorFactory::Build(Arm, numvecs,
true);
1560 if (correction_[i].
is_null() || !correction_[i]->getMap()->isSameAs(*Adm))
1561 correction_[i] = MultiVectorFactory::Build(Adm, numvecs,
false);
1566 if (implicitTranspose_) {
1567 RCP<Operator> P = Levels_[i + 1]->template Get<RCP<Operator>>(
"P");
1570 if (coarseRhs_[i].
is_null() || !coarseRhs_[i]->getMap()->isSameAs(*map))
1571 coarseRhs_[i] = MultiVectorFactory::Build(map, numvecs,
true);
1574 RCP<Operator> R = Levels_[i + 1]->template Get<RCP<Operator>>(
"R");
1577 if (coarseRhs_[i].
is_null() || !coarseRhs_[i]->getMap()->isSameAs(*map))
1578 coarseRhs_[i] = MultiVectorFactory::Build(map, numvecs,
true);
1583 if (Levels_[i + 1]->IsAvailable(
"Importer"))
1584 importer = Levels_[i + 1]->template Get<RCP<const Import>>(
"Importer");
1585 if (doPRrebalance_ || importer.
is_null()) {
1587 if (coarseX_[i].
is_null() || !coarseX_[i]->getMap()->isSameAs(*map))
1588 coarseX_[i] = MultiVectorFactory::Build(map, numvecs,
true);
1591 map = importer->getTargetMap();
1592 if (coarseImport_[i].
is_null() || !coarseImport_[i]->getMap()->isSameAs(*map)) {
1593 coarseImport_[i] = MultiVectorFactory::Build(map, numvecs,
false);
1594 coarseX_[i] = MultiVectorFactory::Build(map, numvecs,
false);
1596 map = importer->getSourceMap();
1597 if (coarseExport_[i].
is_null() || !coarseExport_[i]->getMap()->isSameAs(*map))
1598 coarseExport_[i] = MultiVectorFactory::Build(map, numvecs,
false);
1602 sizeOfAllocatedLevelMultiVectors_ = numvecs;
1605 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1607 if (sizeOfAllocatedLevelMultiVectors_ == 0)
return;
1608 residual_.resize(0);
1609 coarseRhs_.resize(0);
1611 coarseImport_.resize(0);
1612 coarseExport_.resize(0);
1613 correction_.resize(0);
1614 sizeOfAllocatedLevelMultiVectors_ = 0;
1617 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1619 const LO startLevel,
const ConvData& conv)
const {
1620 return (startLevel == 0 && !isPreconditioner_ && (IsPrint(
Statistics1) || conv.
tol_ > 0));
1623 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1630 for (
LO k = 0; k < residualNorm.
size(); k++)
1631 if (residualNorm[k] >= convergenceTolerance)
1640 return convergenceStatus;
1643 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1647 << std::setiosflags(std::ios::left)
1648 << std::setprecision(3) << std::setw(4) << iteration
1650 << std::setprecision(10) << residualNorm
1654 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1656 const Operator& A,
const MultiVector& X,
const MultiVector& B,
const LO iteration,
1662 rate_ = currentResidualNorm / previousResidualNorm;
1663 previousResidualNorm = currentResidualNorm;
1666 PrintResidualHistory(iteration, residualNorm);
1668 return IsConverged(residualNorm, conv.
tol_);
1673 #endif // MUELU_HIERARCHY_DEF_HPP
Important warning messages (one line)
void Build(Level &level) const
Build an object with this factory.
void IsPreconditioner(const bool flag)
High level timing information (use Teuchos::TimeMonitor::summarize() to print)
virtual std::string getObjectLabel() const
T & Get(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access). Usage: Level->Get< RCP<Matrix> >("A", factory) if factory == NULL => use default factory.
bool is_null(const boost::shared_ptr< T > &p)
RCP< Level > & GetLevel(const int levelID=0)
Retrieve a certain level from hierarchy.
std::string toString(const T &what)
Little helper function to convert non-string types to strings.
Hierarchy()
Default constructor.
virtual size_t getNodeSmootherComplexity() const =0
Compute a rough estimate of the cost to apply this smoother on this MPI rank. Return Teuchos::Ordinal...
void DeleteLevelMultiVectors()
void Release(const FactoryBase &factory)
Decrement the storage counter for all the inputs of a factory.
void AddLevel(const RCP< Level > &level)
Add a level at the end of the hierarchy.
void CheckForEmptySmoothersAndCoarseSolve()
void PrintResidualHistory(const LO iteration, const Teuchos::Array< MagnitudeType > &residualNorm) const
Print residualNorm for this iteration to the screen.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
static void Write(const std::string &fileName, const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &M)
void DumpCurrentGraph(int level) const
void AddNewLevel()
Add a new level at the end of the hierarchy.
VerbLevel toMueLuVerbLevel(const Teuchos::EVerbosityLevel verbLevel)
Translate Teuchos verbosity level to MueLu verbosity level.
void swap(RCP< T > &r_ptr)
One-liner description of what is happening.
virtual void Clean() const
void Clear(int startLevel=0)
Clear impermanent data from previous setup.
void SetPreviousLevel(const RCP< Level > &previousLevel)
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Exception throws to report incompatible objects (like maps).
static void SetRandomSeed(const Teuchos::Comm< int > &comm)
Set seed for random number generator.
Integrates Teuchos::TimeMonitor with MueLu verbosity system.
static std::string name()
static const NoFactory * get()
ConvergenceStatus Iterate(const MultiVector &B, MultiVector &X, ConvData conv=ConvData(), bool InitialGuessIsZero=false, LO startLevel=0)
Apply the multigrid preconditioner.
void ReplaceCoordinateMap(Level &level)
void AddKeepFlag(const std::string &ename, const FactoryBase *factory=NoFactory::get(), KeepType keep=MueLu::Keep)
Call Level::AddKeepFlag for each level of the Hierarchy.
Print even more statistics.
void setlib(Xpetra::UnderlyingLib lib2)
void print(std::ostream &out=std::cout, const VerbLevel verbLevel=(MueLu::Parameters|MueLu::Statistics0)) const
Hierarchy::print is local hierarchy function, thus the statistics can be different from global ones...
double GetSmootherComplexity() const
Base class for factories (e.g., R, P, and A_coarse).
Print statistics that do not involve significant additional computation.
Xpetra::UnderlyingLib lib_
Epetra/Tpetra mode.
static RCP< MultiVector > Residual(const Xpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op, const MultiVector &X, const MultiVector &RHS)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void Write(const LO &start=-1, const LO &end=-1, const std::string &suffix="")
Print matrices in the multigrid hierarchy to file.
Class that holds all level-specific information.
std::string description() const
Return a simple one-line description of this object.
Class that provides default factories within Needs class.
void RemoveKeepFlag(const std::string &ename, const FactoryBase *factory, KeepType keep=MueLu::All)
Call Level::RemoveKeepFlag for each level of the Hierarchy.
void CheckLevel(Level &level, int levelID)
Helper function.
Xpetra::UnderlyingLib lib()
virtual void setObjectLabel(const std::string &objectLabel)
void AllocateLevelMultiVectors(int numvecs, bool forceMapCheck=false)
static std::string PrintMatrixInfo(const Matrix &A, const std::string &msgTag, RCP< const Teuchos::ParameterList > params=Teuchos::null)
void Set(const std::string &ename, const T &entry, const FactoryBase *factory=NoFactory::get())
void SetMatvecParams(RCP< ParameterList > matvecParams)
void Build(Level &fineLevel, Level &coarseLevel) const
Build an object with this factory.
int GetGlobalNumLevels() const
void push_back(const value_type &x)
RCP< Level > & GetPreviousLevel()
Previous level.
static Teuchos::Array< Magnitude > ResidualNorm(const Xpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op, const MultiVector &X, const MultiVector &RHS)
Data struct for defining stopping criteria of multigrid iteration.
void SetLevelID(int levelID)
Set level number.
STS::magnitudeType MagnitudeType
void Delete(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Call Level::Delete(ename, factory) for each level of the Hierarchy.
Timer to be used in non-factories.
Array< RCP< Level > > Levels_
Container for Level objects.
bool IsCalculationOfResidualRequired(const LO startLevel, const ConvData &conv) const
Decide if the residual needs to be computed.
int GetLevelID() const
Return level number.
Print class parameters (more parameters, more verbose)
virtual ~Hierarchy()
Destructor.
void residual(const Operator< SC, LO, GO, NO > &Aop, const MultiVector< SC, LO, GO, NO > &X_in, const MultiVector< SC, LO, GO, NO > &B_in, MultiVector< SC, LO, GO, NO > &R_in)
Exception throws to report errors in the internal logical of the program.
An exception safe way to call the method 'Level::SetFactoryManager()'.
void SetComm(RCP< const Teuchos::Comm< int > > const &comm)
void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the Hierarchy with some verbosity level to a FancyOStream object.
Print all warning messages.
Description of what is happening (more verbose)
void Keep(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Call Level::Keep(ename, factory) for each level of the Hierarchy.
ConvergenceStatus IsConverged(const Teuchos::Array< MagnitudeType > &residualNorm, const MagnitudeType convergenceTolerance) const
Decide if the multigrid iteration is converged.
double GetOperatorComplexity() const
bool Setup(int coarseLevelID, const RCP< const FactoryManagerBase > fineLevelManager, const RCP< const FactoryManagerBase > coarseLevelManager, const RCP< const FactoryManagerBase > nextLevelManager=Teuchos::null)
Multi-level setup phase: build a new level of the hierarchy.
RCP< const Teuchos::Comm< int > > GetComm() const
ConvergenceStatus ComputeResidualAndPrintHistory(const Operator &A, const MultiVector &X, const MultiVector &B, const LO iteration, const LO startLevel, const ConvData &conv, MagnitudeType &previousResidualNorm)
Compute the residual norm and print it depending on the verbosity level.
virtual std::string description() const
Return a simple one-line description of this object.
Provides methods to build a multigrid hierarchy and apply multigrid cycles.
std::string toString(const T &t)
bool IsAvailable(const std::string &ename, const FactoryBase *factory=NoFactory::get()) const
Test whether a need's value has been saved.
void Request(const FactoryBase &factory)
Increment the storage counter for all the inputs of a factory.