47 #ifndef MUELU_HIERARCHY_DEF_HPP
48 #define MUELU_HIERARCHY_DEF_HPP
56 #include <Xpetra_MultiVectorFactory.hpp>
62 #include "MueLu_FactoryManager.hpp"
63 #include "MueLu_HierarchyUtils.hpp"
64 #include "MueLu_TopRAPFactory.hpp"
65 #include "MueLu_TopSmootherFactory.hpp"
68 #include "MueLu_PerfUtils.hpp"
69 #include "MueLu_PFactory.hpp"
70 #include "MueLu_SmootherFactory.hpp"
77 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
79 : maxCoarseSize_(GetDefaultMaxCoarseSize())
80 , implicitTranspose_(GetDefaultImplicitTranspose())
81 , fuseProlongationAndUpdate_(GetDefaultFuseProlongationAndUpdate())
82 , doPRrebalance_(GetDefaultPRrebalance())
83 , doPRViaCopyrebalance_(false)
84 , isPreconditioner_(true)
85 , Cycle_(GetDefaultCycle())
86 , WCycleStartLevel_(0)
87 , scalingFactor_(Teuchos::ScalarTraits<double>::one())
89 , isDumpingEnabled_(false)
92 , sizeOfAllocatedLevelMultiVectors_(0) {
96 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
100 Levels_[0]->setObjectLabel(label);
103 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
105 : maxCoarseSize_(GetDefaultMaxCoarseSize())
106 , implicitTranspose_(GetDefaultImplicitTranspose())
107 , fuseProlongationAndUpdate_(GetDefaultFuseProlongationAndUpdate())
108 , doPRrebalance_(GetDefaultPRrebalance())
109 , doPRViaCopyrebalance_(false)
110 , isPreconditioner_(true)
111 , Cycle_(GetDefaultCycle())
112 , WCycleStartLevel_(0)
113 , scalingFactor_(Teuchos::ScalarTraits<double>::one())
114 , isDumpingEnabled_(false)
117 , sizeOfAllocatedLevelMultiVectors_(0) {
118 lib_ = A->getDomainMap()->lib();
126 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
130 Levels_[0]->setObjectLabel(label);
133 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
135 int levelID = LastLevelID() + 1;
138 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"
139 <<
" because last level ID of the hierarchy was " << LastLevelID() <<
"." << std::endl;
141 Levels_.push_back(level);
145 level->
SetPreviousLevel((levelID == 0) ? Teuchos::null : Levels_[LastLevelID() - 1]);
149 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
151 RCP<Level> newLevel = Levels_[LastLevelID()]->Build();
153 this->AddLevel(newLevel);
156 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
159 "MueLu::Hierarchy::GetLevel(): invalid input parameter value: LevelID = " << levelID);
160 return Levels_[levelID];
163 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
165 return Levels_.size();
168 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
170 RCP<Operator> A = Levels_[0]->template Get<RCP<Operator> >(
"A");
173 int numLevels = GetNumLevels();
177 return numGlobalLevels;
180 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
182 double totalNnz = 0, lev0Nnz = 1;
183 for (
int i = 0; i < GetNumLevels(); ++i) {
185 "Operator complexity cannot be calculated because A is unavailable on level " << i);
186 RCP<Operator> A = Levels_[i]->template Get<RCP<Operator> >(
"A");
192 GetOStream(
Warnings0) <<
"Some level operators are not matrices, operator complexity calculation aborted" << std::endl;
196 totalNnz += as<double>(Am->getGlobalNumEntries());
200 return totalNnz / lev0Nnz;
203 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
205 double node_sc = 0, global_sc = 0;
209 if (GetNumLevels() <= 0)
return -1.0;
210 if (!Levels_[0]->IsAvailable(
"A"))
return -1.0;
212 RCP<Operator> A = Levels_[0]->template Get<RCP<Operator> >(
"A");
216 a0_nnz = as<double>(Am->getGlobalNumEntries());
219 for (
int i = 0; i < GetNumLevels(); ++i) {
221 if (!Levels_[i]->IsAvailable(
"PreSmoother"))
continue;
222 RCP<SmootherBase> S = Levels_[i]->template Get<RCP<SmootherBase> >(
"PreSmoother");
225 if (level_sc == INVALID) {
230 node_sc += as<double>(level_sc);
241 return global_sc / a0_nnz;
245 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
248 "MueLu::Hierarchy::CheckLevel(): wrong underlying linear algebra library.");
250 "MueLu::Hierarchy::CheckLevel(): wrong level ID");
252 "MueLu::Hierarchy::Setup(): wrong level parent");
255 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
257 for (
int i = 0; i < GetNumLevels(); ++i) {
265 xpImporter->setDistributorParameters(matvecParams);
268 xpExporter->setDistributorParameters(matvecParams);
275 xpImporter->setDistributorParameters(matvecParams);
278 xpExporter->setDistributorParameters(matvecParams);
284 xpImporter->setDistributorParameters(matvecParams);
287 xpExporter->setDistributorParameters(matvecParams);
292 xpImporter->setDistributorParameters(matvecParams);
299 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
308 "MueLu::Hierarchy:Setup(): level " << coarseLevelID <<
" (specified by coarseLevelID argument) "
309 "must be built before calling this function.");
311 Level& level = *Levels_[coarseLevelID];
314 TimeMonitor m1(*
this, label + this->ShortClassName() +
": " +
"Setup (total)");
319 "MueLu::Hierarchy::Setup(): argument coarseLevelManager cannot be null");
324 if (levelManagers_.size() < coarseLevelID + 1)
325 levelManagers_.resize(coarseLevelID + 1);
326 levelManagers_[coarseLevelID] = coarseLevelManager;
328 bool isFinestLevel = (fineLevelManager.
is_null());
329 bool isLastLevel = (nextLevelManager.
is_null());
342 oldRank = SetProcRankVerbose(comm->getRank());
346 lib_ = domainMap->lib();
353 Level& prevLevel = *Levels_[coarseLevelID - 1];
354 oldRank = SetProcRankVerbose(prevLevel.
GetComm()->getRank());
357 CheckLevel(level, coarseLevelID);
364 if (isFinestLevel && Levels_[coarseLevelID]->IsAvailable(
"Coordinates"))
365 ReplaceCoordinateMap(*Levels_[coarseLevelID]);
370 if (isDumpingEnabled_ && (dumpLevel_ == 0 || dumpLevel_ == -1) && coarseLevelID == 1)
376 int nextLevelID = coarseLevelID + 1;
379 if (isLastLevel ==
false) {
381 if (nextLevelID > LastLevelID())
383 CheckLevel(*Levels_[nextLevelID], nextLevelID);
387 Levels_[nextLevelID]->Request(TopRAPFactory(coarseLevelManager, nextLevelManager));
417 coarseFact =
rcp(
new TopSmootherFactory(coarseLevelManager,
"CoarseSolver"));
426 TopRAPFactory coarseRAPFactory(fineLevelManager, coarseLevelManager);
430 }
else if (!isFinestLevel) {
435 bool setLastLevelviaMaxCoarseSize =
false;
442 level.
SetComm(Ac->getDomainMap()->getComm());
445 bool isOrigLastLevel = isLastLevel;
457 if (!Acm.
is_null() && Acm->getGlobalNumRows() <= maxCoarseSize_) {
459 GetOStream(
Runtime0) <<
"Max coarse size (<= " << maxCoarseSize_ <<
") achieved" << std::endl;
461 if (Acm->getGlobalNumRows() != 0) setLastLevelviaMaxCoarseSize =
true;
465 if (!Ac.
is_null() && !isFinestLevel) {
466 RCP<Operator> A = Levels_[coarseLevelID - 1]->template Get<RCP<Operator> >(
"A");
469 const double maxCoarse2FineRatio = 0.8;
470 if (!Acm.
is_null() && !Am.is_null() && Acm->getGlobalNumRows() > maxCoarse2FineRatio * Am->getGlobalNumRows()) {
478 GetOStream(
Warnings0) <<
"Aggregation stagnated. Please check your matrix and/or adjust your configuration file."
479 <<
"Possible fixes:\n"
480 <<
" - reduce the maximum number of levels\n"
481 <<
" - enable repartitioning\n"
482 <<
" - increase the minimum coarse size." << std::endl;
487 if (!isOrigLastLevel) {
492 coarseFact =
rcp(
new TopSmootherFactory(coarseLevelManager,
"CoarseSolver"));
499 coarseFact->
Build(level);
510 smootherFact->
Build(level);
515 if (isLastLevel ==
true) {
516 int actualNumLevels = nextLevelID;
517 if (isOrigLastLevel ==
false) {
520 Levels_[nextLevelID]->Release(TopRAPFactory(coarseLevelManager, nextLevelManager));
526 if (!setLastLevelviaMaxCoarseSize) {
527 if (Levels_[nextLevelID - 1]->IsAvailable(
"P")) {
528 if (Levels_[nextLevelID - 1]->
template Get<
RCP<Matrix> >(
"P") == Teuchos::null) actualNumLevels = nextLevelID - 1;
530 actualNumLevels = nextLevelID - 1;
533 if (actualNumLevels == nextLevelID - 1) {
535 Levels_[nextLevelID - 2]->Release(*smootherFact);
537 if (Levels_[nextLevelID - 2]->IsAvailable(
"PreSmoother")) Levels_[nextLevelID - 2]->RemoveKeepFlag(
"PreSmoother",
NoFactory::get());
538 if (Levels_[nextLevelID - 2]->IsAvailable(
"PostSmoother")) Levels_[nextLevelID - 2]->RemoveKeepFlag(
"PostSmoother",
NoFactory::get());
540 coarseFact =
rcp(
new TopSmootherFactory(coarseLevelManager,
"CoarseSolver"));
541 Levels_[nextLevelID - 2]->Request(*coarseFact);
543 coarseFact->
Build(*(Levels_[nextLevelID - 2]));
544 Levels_[nextLevelID - 2]->Release(*coarseFact);
546 Levels_.resize(actualNumLevels);
550 if (isDumpingEnabled_ && ((dumpLevel_ > 0 && coarseLevelID == dumpLevel_) || dumpLevel_ == -1))
551 DumpCurrentGraph(coarseLevelID);
553 if (!isFinestLevel) {
557 level.
Release(coarseRAPFactory);
561 SetProcRankVerbose(oldRank);
566 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
568 int numLevels = Levels_.size();
570 "Hierarchy::SetupRe: " << Levels_.size() <<
" levels, but " << levelManagers_.size() <<
" level factory managers");
572 const int startLevel = 0;
575 #ifdef HAVE_MUELU_DEBUG
577 for (
int i = 0; i < numLevels; i++)
578 levelManagers_[i]->ResetDebugData();
583 for (levelID = startLevel; levelID < numLevels;) {
584 bool r = Setup(levelID,
585 (levelID != 0 ? levelManagers_[levelID - 1] : Teuchos::null),
586 levelManagers_[levelID],
587 (levelID + 1 != numLevels ? levelManagers_[levelID + 1] : Teuchos::null));
593 Levels_.resize(levelID);
594 levelManagers_.resize(levelID);
596 int sizeOfVecs = sizeOfAllocatedLevelMultiVectors_;
598 AllocateLevelMultiVectors(sizeOfVecs,
true);
605 CheckForEmptySmoothersAndCoarseSolve();
608 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
617 "MueLu::Hierarchy::Setup(): fine level (" << startLevel <<
") does not exist");
620 "Constructing non-positive (" << numDesiredLevels <<
") number of levels does not make sense.");
623 TEUCHOS_TEST_FOR_EXCEPTION(!Levels_[startLevel]->IsAvailable(
"A"), Exceptions::RuntimeError,
624 "MueLu::Hierarchy::Setup(): fine level (" << startLevel <<
") has no matrix A! "
625 "Set fine level matrix A using Level.Set()");
627 RCP<Operator> A = Levels_[startLevel]->template Get<RCP<Operator> >(
"A");
628 lib_ = A->getDomainMap()->lib();
635 params->
set(
"printLoadBalancingInfo",
true);
636 params->
set(
"printCommInfo",
true);
640 GetOStream(
Warnings1) <<
"Fine level operator is not a matrix, statistics are not available" << std::endl;
646 const int lastLevel = startLevel + numDesiredLevels - 1;
647 GetOStream(
Runtime0) <<
"Setup loop: startLevel = " << startLevel <<
", lastLevel = " << lastLevel
648 <<
" (stop if numLevels = " << numDesiredLevels <<
" or Ac.size() < " << maxCoarseSize_ <<
")" << std::endl;
652 if (numDesiredLevels == 1) {
654 Setup(startLevel, Teuchos::null, rcpmanager, Teuchos::null);
657 bool bIsLastLevel = Setup(startLevel, Teuchos::null, rcpmanager, rcpmanager);
658 if (bIsLastLevel ==
false) {
659 for (iLevel = startLevel + 1; iLevel < lastLevel; iLevel++) {
660 bIsLastLevel = Setup(iLevel, rcpmanager, rcpmanager, rcpmanager);
661 if (bIsLastLevel ==
true)
664 if (bIsLastLevel ==
false)
665 Setup(lastLevel, rcpmanager, rcpmanager, Teuchos::null);
670 TEUCHOS_TEST_FOR_EXCEPTION(iLevel != Levels_.size() - 1, Exceptions::RuntimeError,
671 "MueLu::Hierarchy::Setup(): number of level");
679 CheckForEmptySmoothersAndCoarseSolve();
682 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
684 for (
LO levelNo = 0; levelNo < as<LO>(Levels_.size()); ++levelNo) {
685 auto level = Levels_[levelNo];
686 if ((!level->IsAvailable(
"PreSmoother")) && (!level->IsAvailable(
"PostSmoother")))
687 GetOStream(
Warnings1) <<
"No " << (levelNo == as<LO>(Levels_.size()) - 1 ?
"coarse grid solver" :
"smoother") <<
" on level " << level->GetLevelID() << std::endl;
691 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
693 if (startLevel < GetNumLevels())
694 GetOStream(
Runtime0) <<
"Clearing old data (if any)" << std::endl;
696 for (
int iLevel = startLevel; iLevel < GetNumLevels(); iLevel++)
697 Levels_[iLevel]->Clear();
700 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
702 GetOStream(
Runtime0) <<
"Clearing old data (expert)" << std::endl;
703 for (
int iLevel = 0; iLevel < GetNumLevels(); iLevel++)
704 Levels_[iLevel]->ExpertClear();
707 #if defined(HAVE_MUELU_EXPERIMENTAL) && defined(HAVE_MUELU_ADDITIVE_VARIANT)
708 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
710 bool InitialGuessIsZero,
LO startLevel) {
711 LO nIts = conv.maxIts_;
712 MagnitudeType tol = conv.tol_;
714 std::string prefix = this->ShortClassName() +
": ";
715 std::string levelSuffix =
" (level=" +
toString(startLevel) +
")";
716 std::string levelSuffix1 =
" (level=" +
toString(startLevel + 1) +
")";
718 using namespace Teuchos;
742 SC one = STS::one(), zero = STS::zero();
744 bool zeroGuess = InitialGuessIsZero;
755 bool emptyCoarseSolve =
true;
756 RCP<MultiVector> coarseX_prolonged = MultiVectorFactory::Build(X.getMap(), X.getNumVectors(),
true);
760 if (Levels_.size() > 1) {
762 if (Coarse->IsAvailable(
"Importer"))
771 coarseRhs = MultiVectorFactory::Build(R->getRangeMap(), B.getNumVectors(),
true);
780 if (doPRrebalance_ || importer.is_null()) {
781 coarseX = MultiVectorFactory::Build(coarseRhs->getMap(), X.getNumVectors(),
true);
788 RCP<MultiVector> coarseTmp = MultiVectorFactory::Build(importer->getTargetMap(), coarseRhs->getNumVectors());
790 coarseRhs.
swap(coarseTmp);
792 coarseX = MultiVectorFactory::Build(importer->getTargetMap(), X.getNumVectors(),
true);
795 if (Coarse->IsAvailable(
"PreSmoother"))
797 if (Coarse->IsAvailable(
"PostSmoother"))
803 MagnitudeType prevNorm = STS::magnitude(STS::one()), curNorm = STS::magnitude(STS::one());
806 for (
LO i = 1; i <= nIts; i++) {
807 #ifdef HAVE_MUELU_DEBUG
808 if (A->getDomainMap()->isCompatible(*(X.getMap())) ==
false) {
809 std::ostringstream ss;
810 ss <<
"Level " << startLevel <<
": level A's domain map is not compatible with X";
811 throw Exceptions::Incompatible(ss.str());
814 if (A->getRangeMap()->isCompatible(*(B.getMap())) ==
false) {
815 std::ostringstream ss;
816 ss <<
"Level " << startLevel <<
": level A's range map is not compatible with B";
817 throw Exceptions::Incompatible(ss.str());
822 bool emptyFineSolve =
true;
825 fineX = MultiVectorFactory::Build(X.getMap(), X.getNumVectors(),
true);
834 if (Fine->IsAvailable(
"PreSmoother")) {
837 preSmoo->Apply(*fineX, B, zeroGuess);
839 emptyFineSolve =
false;
841 if (Fine->IsAvailable(
"PostSmoother")) {
844 postSmoo->Apply(*fineX, B, zeroGuess);
847 emptyFineSolve =
false;
849 if (emptyFineSolve ==
true) {
851 fineX->update(one, B, zero);
854 if (Levels_.size() > 1) {
856 if (Coarse->IsAvailable(
"PreSmoother")) {
858 preSmoo_coarse->Apply(*coarseX, *coarseRhs, zeroGuess);
860 emptyCoarseSolve =
false;
862 if (Coarse->IsAvailable(
"PostSmoother")) {
864 postSmoo_coarse->Apply(*coarseX, *coarseRhs, zeroGuess);
866 emptyCoarseSolve =
false;
868 if (emptyCoarseSolve ==
true) {
870 coarseX->update(one, *coarseRhs, zero);
877 if (!doPRrebalance_ && !importer.is_null()) {
882 RCP<MultiVector> coarseTmp = MultiVectorFactory::Build(importer->getSourceMap(), coarseX->getNumVectors());
884 coarseX.
swap(coarseTmp);
893 X.update(1.0, *fineX, 1.0, *coarseX_prolonged, 0.0);
904 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
906 bool InitialGuessIsZero,
LO startLevel) {
925 std::string prefix = label + this->ShortClassName() +
": ";
926 std::string levelSuffix =
" (level=" +
toString(startLevel) +
")";
927 std::string levelSuffix1 =
" (level=" +
toString(startLevel + 1) +
")";
935 else if (!useStackedTimer)
938 std::string iterateLevelTimeLabel = prefix +
"Solve" + levelSuffix;
941 bool zeroGuess = InitialGuessIsZero;
944 using namespace Teuchos;
958 const BlockedMultiVector* Bblocked =
dynamic_cast<const BlockedMultiVector*
>(&B);
959 if (residual_.size() > startLevel &&
960 ((Bblocked && !Bblocked->isSameSize(*residual_[startLevel])) ||
961 (!Bblocked && !residual_[startLevel]->isSameSize(B))))
962 DeleteLevelMultiVectors();
963 AllocateLevelMultiVectors(X.getNumVectors());
969 if (IsCalculationOfResidualRequired(startLevel, conv)) {
972 return convergenceStatus;
975 SC one = STS::one(), zero = STS::zero();
976 for (
LO iteration = 1; iteration <= nIts; iteration++) {
977 #ifdef HAVE_MUELU_DEBUG
979 if (A->getDomainMap()->isCompatible(*(X.getMap())) ==
false) {
980 std::ostringstream ss;
981 ss <<
"Level " << startLevel <<
": level A's domain map is not compatible with X";
985 if (A->getRangeMap()->isCompatible(*(B.getMap())) ==
false) {
986 std::ostringstream ss;
987 ss <<
"Level " << startLevel <<
": level A's range map is not compatible with B";
993 if (startLevel == as<LO>(Levels_.size()) - 1) {
997 bool emptySolve =
true;
1000 if (Fine->IsAvailable(
"PreSmoother")) {
1002 CompCoarse->start();
1003 preSmoo->Apply(X, B, zeroGuess);
1008 if (Fine->IsAvailable(
"PostSmoother")) {
1010 CompCoarse->start();
1011 postSmoo->Apply(X, B, zeroGuess);
1016 if (emptySolve ==
true) {
1018 X.update(one, B, zero);
1027 if (!useStackedTimer)
1031 if (Fine->IsAvailable(
"PreSmoother")) {
1033 preSmoo->Apply(X, B, zeroGuess);
1041 if (!useStackedTimer)
1051 residual = residual_[startLevel];
1055 if (Coarse->IsAvailable(
"Pbar"))
1063 if (!useStackedTimer)
1066 coarseRhs = coarseRhs_[startLevel];
1068 if (implicitTranspose_) {
1078 if (Coarse->IsAvailable(
"Importer"))
1081 coarseX = coarseX_[startLevel];
1082 if (!doPRrebalance_ && !importer.
is_null()) {
1084 if (!useStackedTimer)
1091 coarseRhs.
swap(coarseTmp);
1100 coarseRhs->replaceMap(Ac->getRangeMap());
1101 coarseX->replaceMap(Ac->getDomainMap());
1104 iterateLevelTime = Teuchos::null;
1106 Iterate(*coarseRhs, *coarseX, 1,
true, startLevel + 1);
1108 if (Cycle_ ==
WCYCLE && WCycleStartLevel_ >= startLevel)
1109 Iterate(*coarseRhs, *coarseX, 1,
false, startLevel + 1);
1112 iterateLevelTime =
rcp(
new TimeMonitor(*
this, iterateLevelTimeLabel));
1114 coarseX->replaceMap(origXMap);
1115 coarseRhs->replaceMap(origRhsMap);
1118 if (!doPRrebalance_ && !importer.
is_null()) {
1120 if (!useStackedTimer)
1127 coarseX.
swap(coarseTmp);
1133 if (!useStackedTimer)
1140 if (fuseProlongationAndUpdate_) {
1145 X.update(scalingFactor_, *correction, one);
1152 if (!useStackedTimer)
1156 if (Fine->IsAvailable(
"PostSmoother")) {
1158 postSmoo->Apply(X, B,
false);
1164 if (IsCalculationOfResidualRequired(startLevel, conv)) {
1165 ConvergenceStatus convergenceStatus = ComputeResidualAndPrintHistory(*A, X, B, iteration, startLevel, conv, prevNorm);
1167 return convergenceStatus;
1174 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1176 LO startLevel = (start != -1 ? start : 0);
1177 LO endLevel = (end != -1 ? end : Levels_.size() - 1);
1180 "MueLu::Hierarchy::Write : startLevel must be <= endLevel");
1183 "MueLu::Hierarchy::Write bad start or end level");
1185 for (
LO i = startLevel; i < endLevel + 1; i++) {
1186 RCP<Matrix> A = rcp_dynamic_cast<Matrix>(Levels_[i]->template Get<RCP<Operator> >(
"A")), P, R;
1188 P = rcp_dynamic_cast<Matrix>(Levels_[i]->template Get<RCP<Operator> >(
"P"));
1189 if (!implicitTranspose_)
1190 R = rcp_dynamic_cast<Matrix>(Levels_[i]->template Get<RCP<Operator> >(
"R"));
1203 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1205 for (
Array<
RCP<Level> >::iterator it = Levels_.begin(); it != Levels_.end(); ++it)
1206 (*it)->Keep(ename, factory);
1209 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1211 for (
Array<
RCP<Level> >::iterator it = Levels_.begin(); it != Levels_.end(); ++it)
1212 (*it)->Delete(ename, factory);
1215 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1217 for (
Array<
RCP<Level> >::iterator it = Levels_.begin(); it != Levels_.end(); ++it)
1218 (*it)->AddKeepFlag(ename, factory, keep);
1221 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1223 for (
Array<
RCP<Level> >::iterator it = Levels_.begin(); it != Levels_.end(); ++it)
1224 (*it)->RemoveKeepFlag(ename, factory, keep);
1227 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1229 if (description_.empty()) {
1230 std::ostringstream out;
1232 out <<
"{#levels = " << GetGlobalNumLevels() <<
", complexity = " << GetOperatorComplexity() <<
"}";
1233 description_ = out.str();
1235 return description_;
1238 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1243 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1245 RCP<Operator> A0 = Levels_[0]->template Get<RCP<Operator> >(
"A");
1248 int numLevels = GetNumLevels();
1249 RCP<Operator> Ac = Levels_[numLevels - 1]->template Get<RCP<Operator> >(
"A");
1256 int root = comm->getRank();
1259 int smartData = numLevels * comm->getSize() + comm->getRank(), maxSmartData;
1261 root = maxSmartData % comm->getSize();
1265 double smoother_comp = -1.0;
1267 smoother_comp = GetSmootherComplexity();
1271 std::vector<Xpetra::global_size_t> nnzPerLevel;
1272 std::vector<Xpetra::global_size_t> rowsPerLevel;
1273 std::vector<int> numProcsPerLevel;
1274 bool someOpsNotMatrices =
false;
1276 for (
int i = 0; i < numLevels; i++) {
1278 "Operator A is not available on level " << i);
1280 RCP<Operator> A = Levels_[i]->template Get<RCP<Operator> >(
"A");
1282 "Operator A on level " << i <<
" is null.");
1286 someOpsNotMatrices =
true;
1287 nnzPerLevel.push_back(INVALID);
1288 rowsPerLevel.push_back(A->getDomainMap()->getGlobalNumElements());
1289 numProcsPerLevel.push_back(A->getDomainMap()->getComm()->getSize());
1291 LO storageblocksize = Am->GetStorageBlockSize();
1293 nnzPerLevel.push_back(nnz);
1294 rowsPerLevel.push_back(Am->getGlobalNumRows() * storageblocksize);
1295 numProcsPerLevel.push_back(Am->getRowMap()->getComm()->getSize());
1298 if (someOpsNotMatrices)
1299 GetOStream(
Warnings0) <<
"Some level operators are not matrices, statistics calculation are incomplete" << std::endl;
1302 std::string label = Levels_[0]->getObjectLabel();
1303 std::ostringstream oss;
1304 oss << std::setfill(
' ');
1305 oss <<
"\n--------------------------------------------------------------------------------\n";
1306 oss <<
"--- Multigrid Summary " << std::setw(28) << std::left << label <<
"---\n";
1307 oss <<
"--------------------------------------------------------------------------------" << std::endl;
1310 oss <<
"Number of levels = " << numLevels << std::endl;
1311 oss <<
"Operator complexity = " << std::setprecision(2) << std::setiosflags(std::ios::fixed);
1312 if (!someOpsNotMatrices)
1313 oss << GetOperatorComplexity() << std::endl;
1315 oss <<
"not available (Some operators in hierarchy are not matrices.)" << std::endl;
1317 if (smoother_comp != -1.0) {
1318 oss <<
"Smoother complexity = " << std::setprecision(2) << std::setiosflags(std::ios::fixed)
1319 << smoother_comp << std::endl;
1324 oss <<
"Cycle type = V" << std::endl;
1327 oss <<
"Cycle type = W" << std::endl;
1328 if (WCycleStartLevel_ > 0)
1329 oss <<
"Cycle start level = " << WCycleStartLevel_ << std::endl;
1342 for (
size_t i = 0; i < nnzPerLevel.size(); ++i) {
1343 tt = nnzPerLevel[i];
1353 tt = numProcsPerLevel[0];
1359 oss <<
"level " << std::setw(rowspacer) <<
" rows " << std::setw(nnzspacer) <<
" nnz "
1360 <<
" nnz/row" << std::setw(npspacer) <<
" c ratio"
1361 <<
" procs" << std::endl;
1362 for (
size_t i = 0; i < nnzPerLevel.size(); ++i) {
1363 oss <<
" " << i <<
" ";
1364 oss << std::setw(rowspacer) << rowsPerLevel[i];
1365 if (nnzPerLevel[i] != INVALID) {
1366 oss << std::setw(nnzspacer) << nnzPerLevel[i];
1367 oss << std::setprecision(2) << std::setiosflags(std::ios::fixed);
1368 oss << std::setw(9) << as<double>(nnzPerLevel[i]) / rowsPerLevel[i];
1370 oss << std::setw(nnzspacer) <<
"Operator";
1371 oss << std::setprecision(2) << std::setiosflags(std::ios::fixed);
1372 oss << std::setw(9) <<
" ";
1375 oss << std::setw(9) << as<double>(rowsPerLevel[i - 1]) / rowsPerLevel[i];
1377 oss << std::setw(9) <<
" ";
1378 oss <<
" " << std::setw(npspacer) << numProcsPerLevel[i] << std::endl;
1381 for (
int i = 0; i < GetNumLevels(); ++i) {
1383 if (Levels_[i]->IsAvailable(
"PreSmoother"))
1385 if (Levels_[i]->IsAvailable(
"PostSmoother"))
1388 if (preSmoo != null && preSmoo == postSmoo)
1389 oss <<
"Smoother (level " << i <<
") both : " << preSmoo->
description() << std::endl;
1391 oss <<
"Smoother (level " << i <<
") pre : "
1392 << (preSmoo != null ? preSmoo->
description() :
"no smoother") << std::endl;
1393 oss <<
"Smoother (level " << i <<
") post : "
1394 << (postSmoo != null ? postSmoo->
description() :
"no smoother") << std::endl;
1406 MPI_Comm rawComm = (*mpiComm->getRawMpiComm())();
1408 int strLength = outstr.size();
1409 MPI_Bcast(&strLength, 1, MPI_INT, root, rawComm);
1410 if (comm->getRank() != root)
1411 outstr.resize(strLength);
1412 MPI_Bcast(&outstr[0], strLength, MPI_CHAR, root, rawComm);
1419 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1422 for (
int i = 0; i < GetNumLevels(); ++i)
1423 Levels_[i]->print(out, verbLevel);
1426 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1428 isPreconditioner_ = flag;
1431 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1433 if (GetProcRankVerbose() != 0)
1435 #if defined(HAVE_MUELU_BOOST) && defined(HAVE_MUELU_BOOST_FOR_REAL) && defined(BOOST_VERSION) && (BOOST_VERSION >= 104400)
1440 dp.property(
"label", boost::get(boost::vertex_name, graph));
1441 dp.property(
"id", boost::get(boost::vertex_index, graph));
1442 dp.property(
"label", boost::get(boost::edge_name, graph));
1443 dp.property(
"color", boost::get(boost::edge_color, graph));
1446 std::map<const FactoryBase*, BoostVertex> vindices;
1447 typedef std::map<std::pair<BoostVertex, BoostVertex>, std::string> emap;
1450 static int call_id = 0;
1452 RCP<Operator> A = Levels_[0]->template Get<RCP<Operator> >(
"A");
1453 int rank = A->getDomainMap()->getComm()->getRank();
1456 for (
int i = currLevel; i <= currLevel + 1 && i < GetNumLevels(); i++) {
1458 Levels_[i]->UpdateGraph(vindices, edges, dp, graph);
1460 for (emap::const_iterator eit = edges.begin(); eit != edges.end(); eit++) {
1461 std::pair<BoostEdge, bool> boost_edge = boost::add_edge(eit->first.first, eit->first.second, graph);
1464 if (eit->second == std::string(
"Graph"))
1465 boost::put(
"label", dp, boost_edge.first, std::string(
"Graph_"));
1467 boost::put(
"label", dp, boost_edge.first, eit->second);
1469 boost::put(
"color", dp, boost_edge.first, std::string(
"red"));
1471 boost::put(
"color", dp, boost_edge.first, std::string(
"blue"));
1475 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"));
1476 boost::write_graphviz_dp(out, graph, dp, std::string(
"id"));
1480 GetOStream(
Errors) <<
"Dependency graph output requires boost and MueLu_ENABLE_Boost_for_real" << std::endl;
1485 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1490 GetOStream(
Runtime1) <<
"Hierarchy::ReplaceCoordinateMap: operator is not a matrix, skipping..." << std::endl;
1493 if (Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(A) != Teuchos::null) {
1494 GetOStream(
Runtime1) <<
"Hierarchy::ReplaceCoordinateMap: operator is a BlockedCrsMatrix, skipping..." << std::endl;
1502 if (A->getRowMap()->isSameAs(*(coords->getMap()))) {
1503 GetOStream(
Runtime1) <<
"Hierarchy::ReplaceCoordinateMap: matrix and coordinates maps are same, skipping..." << std::endl;
1507 if (A->IsView(
"stridedMaps") && rcp_dynamic_cast<
const StridedMap>(A->getRowMap(
"stridedMaps")) != Teuchos::null) {
1508 RCP<const StridedMap> stridedRowMap = rcp_dynamic_cast<
const StridedMap>(A->getRowMap(
"stridedMaps"));
1512 Exceptions::RuntimeError,
"Hierarchy::ReplaceCoordinateMap: nontrivial maps (block id = " << stridedRowMap->getStridedBlockId() <<
", offset = " << stridedRowMap->getOffset() <<
")");
1515 GetOStream(
Runtime1) <<
"Replacing coordinate map" << std::endl;
1518 size_t blkSize = A->GetFixedBlockSize() / A->GetStorageBlockSize();
1524 GO indexBase = dofMap->getIndexBase();
1525 size_t numLocalDOFs = dofMap->getLocalNumElements();
1527 "Hierarchy::ReplaceCoordinateMap: block size (" << blkSize <<
") is incompatible with the number of local dofs in a row map (" << numLocalDOFs);
1530 Array<GO> nodeGIDs(numLocalDOFs / blkSize);
1531 for (
size_t i = 0; i < numLocalDOFs; i += blkSize)
1532 nodeGIDs[i / blkSize] = (GIDs[i] - indexBase) / blkSize + indexBase;
1535 nodeMap = MapFactory::Build(dofMap->lib(), INVALID, nodeGIDs(), indexBase, dofMap->getComm());
1541 if (coords->getLocalLength() != A->getRowMap()->getLocalNumElements()) {
1542 GetOStream(
Warnings) <<
"Coordinate vector does not match row map of matrix A!" << std::endl;
1548 std::vector<ArrayRCP<const typename Teuchos::ScalarTraits<Scalar>::coordinateType> > coordData;
1549 for (
size_t i = 0; i < coords->getNumVectors(); i++) {
1550 coordData.
push_back(coords->getData(i));
1551 coordDataView.
push_back(coordData[i]());
1555 level.
Set(
"Coordinates", newCoords);
1558 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1560 int N = Levels_.size();
1561 if (((sizeOfAllocatedLevelMultiVectors_ == numvecs && residual_.size() == N) || numvecs <= 0) && !forceMapCheck)
return;
1564 if (residual_.size() != N) {
1565 DeleteLevelMultiVectors();
1567 residual_.resize(N);
1568 coarseRhs_.resize(N);
1570 coarseImport_.resize(N);
1571 coarseExport_.resize(N);
1572 correction_.resize(N);
1575 for (
int i = 0; i < N; i++) {
1576 RCP<Operator> A = Levels_[i]->template Get<RCP<Operator> >(
"A");
1582 if (!A_as_blocked.
is_null()) {
1583 Adm = A_as_blocked->getFullDomainMap();
1586 if (residual_[i].
is_null() || !residual_[i]->getMap()->isSameAs(*Arm))
1588 residual_[i] = MultiVectorFactory::Build(Arm, numvecs,
true);
1589 if (correction_[i].
is_null() || !correction_[i]->getMap()->isSameAs(*Adm))
1590 correction_[i] = MultiVectorFactory::Build(Adm, numvecs,
false);
1595 if (implicitTranspose_) {
1596 RCP<Operator> P = Levels_[i + 1]->template Get<RCP<Operator> >(
"P");
1599 if (coarseRhs_[i].
is_null() || !coarseRhs_[i]->getMap()->isSameAs(*map))
1600 coarseRhs_[i] = MultiVectorFactory::Build(map, numvecs,
true);
1603 RCP<Operator> R = Levels_[i + 1]->template Get<RCP<Operator> >(
"R");
1606 if (coarseRhs_[i].
is_null() || !coarseRhs_[i]->getMap()->isSameAs(*map))
1607 coarseRhs_[i] = MultiVectorFactory::Build(map, numvecs,
true);
1612 if (Levels_[i + 1]->IsAvailable(
"Importer"))
1613 importer = Levels_[i + 1]->template Get<RCP<const Import> >(
"Importer");
1614 if (doPRrebalance_ || importer.
is_null()) {
1616 if (coarseX_[i].
is_null() || !coarseX_[i]->getMap()->isSameAs(*map))
1617 coarseX_[i] = MultiVectorFactory::Build(map, numvecs,
true);
1620 map = importer->getTargetMap();
1621 if (coarseImport_[i].
is_null() || !coarseImport_[i]->getMap()->isSameAs(*map)) {
1622 coarseImport_[i] = MultiVectorFactory::Build(map, numvecs,
false);
1623 coarseX_[i] = MultiVectorFactory::Build(map, numvecs,
false);
1625 map = importer->getSourceMap();
1626 if (coarseExport_[i].
is_null() || !coarseExport_[i]->getMap()->isSameAs(*map))
1627 coarseExport_[i] = MultiVectorFactory::Build(map, numvecs,
false);
1631 sizeOfAllocatedLevelMultiVectors_ = numvecs;
1634 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1636 if (sizeOfAllocatedLevelMultiVectors_ == 0)
return;
1637 residual_.resize(0);
1638 coarseRhs_.resize(0);
1640 coarseImport_.resize(0);
1641 coarseExport_.resize(0);
1642 correction_.resize(0);
1643 sizeOfAllocatedLevelMultiVectors_ = 0;
1646 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1648 const LO startLevel,
const ConvData& conv)
const {
1649 return (startLevel == 0 && !isPreconditioner_ && (IsPrint(
Statistics1) || conv.
tol_ > 0));
1652 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1659 for (
LO k = 0; k < residualNorm.
size(); k++)
1660 if (residualNorm[k] >= convergenceTolerance)
1669 return convergenceStatus;
1672 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1676 << std::setiosflags(std::ios::left)
1677 << std::setprecision(3) << std::setw(4) << iteration
1679 << std::setprecision(10) << residualNorm
1683 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1685 const Operator& A,
const MultiVector& X,
const MultiVector& B,
const LO iteration,
1691 rate_ = currentResidualNorm / previousResidualNorm;
1692 previousResidualNorm = currentResidualNorm;
1695 PrintResidualHistory(iteration, residualNorm);
1697 return IsConverged(residualNorm, conv.
tol_);
1702 #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)
RCP< Level > & GetPreviousLevel()
Previous level.
static Teuchos::RCP< Teuchos::StackedTimer > getStackedTimer()
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.
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
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)
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)
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)
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.