45 #ifndef MUELU_PARAMETERLISTINTERPRETER_DEF_HPP 46 #define MUELU_PARAMETERLISTINTERPRETER_DEF_HPP 48 #include <Teuchos_XMLParameterListHelpers.hpp> 50 #include <Xpetra_Matrix.hpp> 51 #include <Xpetra_MatrixUtils.hpp> 59 #include "MueLu_Hierarchy.hpp" 60 #include "MueLu_FactoryManager.hpp" 62 #include "MueLu_AggregationExportFactory.hpp" 63 #include "MueLu_AggregateQualityEstimateFactory.hpp" 64 #include "MueLu_BrickAggregationFactory.hpp" 65 #include "MueLu_ClassicalMapFactory.hpp" 66 #include "MueLu_ClassicalPFactory.hpp" 67 #include "MueLu_CoalesceDropFactory.hpp" 68 #include "MueLu_CoarseMapFactory.hpp" 69 #include "MueLu_ConstraintFactory.hpp" 70 #include "MueLu_CoordinatesTransferFactory.hpp" 71 #include "MueLu_CoupledAggregationFactory.hpp" 72 #include "MueLu_DirectSolver.hpp" 73 #include "MueLu_EminPFactory.hpp" 75 #include "MueLu_FacadeClassFactory.hpp" 76 #include "MueLu_FactoryFactory.hpp" 77 #include "MueLu_FilteredAFactory.hpp" 78 #include "MueLu_GenericRFactory.hpp" 79 #include "MueLu_InitialBlockNumberFactory.hpp" 80 #include "MueLu_LineDetectionFactory.hpp" 81 #include "MueLu_LocalOrdinalTransferFactory.hpp" 83 #ifdef HAVE_MUELU_KOKKOS_REFACTOR 84 #include "MueLu_NotayAggregationFactory.hpp" 86 #include "MueLu_NullspaceFactory.hpp" 87 #include "MueLu_PatternFactory.hpp" 88 #include "MueLu_PgPFactory.hpp" 89 #include "MueLu_RAPFactory.hpp" 90 #include "MueLu_RAPShiftFactory.hpp" 91 #include "MueLu_RebalanceAcFactory.hpp" 92 #include "MueLu_RebalanceTransferFactory.hpp" 93 #include "MueLu_RepartitionFactory.hpp" 94 #include "MueLu_ReitzingerPFactory.hpp" 95 #include "MueLu_SaPFactory.hpp" 96 #include "MueLu_ScaledNullspaceFactory.hpp" 97 #include "MueLu_SemiCoarsenPFactory.hpp" 98 #include "MueLu_SmootherFactory.hpp" 99 #include "MueLu_SmooVecCoalesceDropFactory.hpp" 100 #include "MueLu_TentativePFactory.hpp" 101 #include "MueLu_TogglePFactory.hpp" 102 #include "MueLu_ToggleCoordinatesTransferFactory.hpp" 103 #include "MueLu_TransPFactory.hpp" 104 #include "MueLu_UncoupledAggregationFactory.hpp" 105 #include "MueLu_HybridAggregationFactory.hpp" 106 #include "MueLu_ZoltanInterface.hpp" 107 #include "MueLu_Zoltan2Interface.hpp" 108 #include "MueLu_NodePartitionInterface.hpp" 110 #ifdef HAVE_MUELU_KOKKOS_REFACTOR 111 #include "MueLu_CoalesceDropFactory_kokkos.hpp" 112 #include "MueLu_CoarseMapFactory_kokkos.hpp" 113 #include "MueLu_CoordinatesTransferFactory_kokkos.hpp" 114 #include "MueLu_NullspaceFactory_kokkos.hpp" 115 #include "MueLu_SaPFactory_kokkos.hpp" 116 #include "MueLu_SemiCoarsenPFactory_kokkos.hpp" 117 #include "MueLu_TentativePFactory_kokkos.hpp" 118 #include "MueLu_UncoupledAggregationFactory_kokkos.hpp" 121 #ifdef HAVE_MUELU_MATLAB 122 #include "../matlab/src/MueLu_MatlabSmoother_decl.hpp" 123 #include "../matlab/src/MueLu_MatlabSmoother_def.hpp" 124 #include "../matlab/src/MueLu_TwoLevelMatlabFactory_decl.hpp" 125 #include "../matlab/src/MueLu_TwoLevelMatlabFactory_def.hpp" 126 #include "../matlab/src/MueLu_SingleLevelMatlabFactory_decl.hpp" 127 #include "../matlab/src/MueLu_SingleLevelMatlabFactory_def.hpp" 130 #ifdef HAVE_MUELU_INTREPID2 131 #include "MueLu_IntrepidPCoarsenFactory.hpp" 134 #include <unordered_set> 138 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
140 RCP<Teuchos::TimeMonitor> tM = rcp(
new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer(std::string(
"MueLu: ParameterListInterpreter (ParameterList)"))));
141 if(facadeFact == Teuchos::null)
142 facadeFact_ = Teuchos::rcp(
new FacadeClassFactory());
144 facadeFact_ = facadeFact;
146 if (paramList.isParameter(
"xml parameter file")) {
147 std::string filename = paramList.get(
"xml parameter file",
"");
148 if (filename.length() != 0) {
149 TEUCHOS_TEST_FOR_EXCEPTION(comm.is_null(), Exceptions::RuntimeError,
"xml parameter file requires a valid comm");
151 ParameterList paramList2 = paramList;
152 Teuchos::updateParametersFromXmlFileAndBroadcast(filename, Teuchos::Ptr<Teuchos::ParameterList>(¶mList2), *comm);
153 SetParameterList(paramList2);
156 SetParameterList(paramList);
160 SetParameterList(paramList);
164 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
166 RCP<Teuchos::TimeMonitor> tM = rcp(
new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer(std::string(
"MueLu: ParameterListInterpreter (XML)"))));
167 if(facadeFact == Teuchos::null)
172 ParameterList paramList;
173 Teuchos::updateParametersFromXmlFileAndBroadcast(xmlFileName, Teuchos::Ptr<ParameterList>(¶mList), comm);
177 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
181 scalingFactor_= Teuchos::ScalarTraits<double>::one();
185 if (paramList.isSublist(
"Hierarchy")) {
186 SetFactoryParameterList(paramList);
188 }
else if (paramList.isParameter(
"MueLu preconditioner") ==
true) {
189 this->GetOStream(
Runtime0) <<
"Use facade class: " << paramList.get<std::string>(
"MueLu preconditioner") << std::endl;
190 Teuchos::RCP<ParameterList> pp = facadeFact_->SetParameterList(paramList);
191 SetFactoryParameterList(*pp);
195 ParameterList serialList, nonSerialList;
198 Validate(serialList);
199 SetEasyParameterList(paramList);
207 static inline bool areSame(
const ParameterList& list1,
const ParameterList& list2);
212 #define MUELU_SET_VAR_2LIST(paramList, defaultList, paramName, paramType, varName) \ 214 if (paramList.isParameter(paramName)) varName = paramList.get<paramType>(paramName); \ 215 else if (defaultList.isParameter(paramName)) varName = defaultList.get<paramType>(paramName); \ 216 else varName = MasterList::getDefault<paramType>(paramName); 218 #define MUELU_TEST_AND_SET_VAR(paramList, paramName, paramType, varName) \ 219 (paramList.isParameter(paramName) ? varName = paramList.get<paramType>(paramName), true : false) 223 #define MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, paramName, paramType, listWrite) \ 225 if (paramList .isParameter(paramName)) listWrite.set(paramName, paramList .get<paramType>(paramName)); \ 226 else if (defaultList.isParameter(paramName)) listWrite.set(paramName, defaultList.get<paramType>(paramName)); \ 228 catch(Teuchos::Exceptions::InvalidParameterType&) { \ 229 TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(true, Teuchos::Exceptions::InvalidParameterType, \ 230 "Error: parameter \"" << paramName << "\" must be of type " << Teuchos::TypeNameTraits<paramType>::name()); \ 233 #define MUELU_TEST_PARAM_2LIST(paramList, defaultList, paramName, paramType, cmpValue) \ 235 paramList.isParameter(paramName) ? paramList .get<paramType>(paramName) : ( \ 236 defaultList.isParameter(paramName) ? defaultList.get<paramType>(paramName) : \ 237 MasterList::getDefault<paramType>(paramName) ) ) ) 239 #ifndef HAVE_MUELU_KOKKOS_REFACTOR 240 #define MUELU_KOKKOS_FACTORY(varName, oldFactory, newFactory) \ 241 RCP<Factory> varName = rcp(new oldFactory()); 242 #define MUELU_KOKKOS_FACTORY_NO_DECL(varName, oldFactory, newFactory) \ 243 varName = rcp(new oldFactory()); 245 #define MUELU_KOKKOS_FACTORY(varName, oldFactory, newFactory) \ 246 RCP<Factory> varName; \ 247 if (!useKokkos_) varName = rcp(new oldFactory()); \ 248 else varName = rcp(new newFactory()); 249 #define MUELU_KOKKOS_FACTORY_NO_DECL(varName, oldFactory, newFactory) \ 250 if (!useKokkos_) varName = rcp(new oldFactory()); \ 251 else varName = rcp(new newFactory()); 254 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
257 ParameterList paramList;
259 MUELU_SET_VAR_2LIST(constParamList, constParamList,
"problem: type", std::string, problemType);
260 if (problemType !=
"unknown") {
262 paramList.setParameters(constParamList);
266 paramList = constParamList;
270 #if !defined(HAVE_MUELU_KOKKOS_REFACTOR) 273 # ifdef HAVE_MUELU_SERIAL 274 if (
typeid(
Node).name() ==
typeid(Kokkos::Compat::KokkosSerialWrapperNode).name())
277 # ifdef HAVE_MUELU_OPENMP 278 if (
typeid(
Node).name() ==
typeid(Kokkos::Compat::KokkosOpenMPWrapperNode).name())
281 # ifdef HAVE_MUELU_CUDA 282 if (
typeid(
Node).name() ==
typeid(Kokkos::Compat::KokkosCudaWrapperNode).name())
285 # ifdef HAVE_MUELU_HIP 286 if (
typeid(
Node).name() ==
typeid(Kokkos::Compat::KokkosHIPWrapperNode).name())
298 if (paramList.isParameter(
"cycle type")) {
299 std::map<std::string, CycleType> cycleMap;
303 auto cycleType = paramList.get<std::string>(
"cycle type");
305 "Invalid cycle type: \"" << cycleType <<
"\"");
306 Cycle_ = cycleMap[cycleType];
309 if (paramList.isParameter(
"W cycle start level")) {
310 WCycleStartLevel_ = paramList.get<
int>(
"W cycle start level");
313 if (paramList.isParameter(
"coarse grid correction scaling factor"))
314 scalingFactor_ = paramList.get<
double>(
"coarse grid correction scaling factor");
316 this->maxCoarseSize_ = paramList.get<
int> (
"coarse: max size", MasterList::getDefault<int>(
"coarse: max size"));
317 this->numDesiredLevel_ = paramList.get<
int> (
"max levels", MasterList::getDefault<int>(
"max levels"));
318 blockSize_ = paramList.get<
int> (
"number of equations", MasterList::getDefault<int>(
"number of equations"));
324 if (paramList.isSublist(
"export data")) {
325 ParameterList printList = paramList.sublist(
"export data");
327 if (printList.isParameter(
"A"))
328 this->matricesToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"A");
329 if (printList.isParameter(
"P"))
330 this->prolongatorsToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"P");
331 if (printList.isParameter(
"R"))
332 this->restrictorsToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"R");
333 if (printList.isParameter(
"Nullspace"))
334 this->nullspaceToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"Nullspace");
335 if (printList.isParameter(
"Coordinates"))
336 this->coordinatesToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"Coordinates");
337 if (printList.isParameter(
"Aggregates"))
338 this->aggregatesToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"Aggregates");
339 if (printList.isParameter(
"pcoarsen: element to node map"))
340 this->elementToNodeMapsToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"pcoarsen: element to node map");
352 if (outputFilename !=
"")
362 useCoordinates_ =
false;
363 useBlockNumber_ =
false;
364 if (
MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"distance laplacian") ||
367 useCoordinates_ =
true;
368 }
else if(
MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal distance laplacian")) {
369 useCoordinates_ =
true;
370 useBlockNumber_ =
true;
371 }
else if(
MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal") ||
372 MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal classical") ||
373 MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal signed classical") ||
374 MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal colored signed classical") ||
375 MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"signed classical")) {
376 useBlockNumber_ =
true;
377 }
else if(paramList.isSublist(
"smoother: params")) {
378 const auto smooParamList = paramList.sublist(
"smoother: params");
379 if(smooParamList.isParameter(
"partitioner: type") &&
380 (smooParamList.get<std::string>(
"partitioner: type") ==
"line")) {
381 useCoordinates_ =
true;
384 for (
int levelID = 0; levelID < this->numDesiredLevel_; levelID++) {
385 std::string levelStr =
"level " +
toString(levelID);
387 if (paramList.isSublist(levelStr)) {
388 const ParameterList& levelList = paramList.sublist(levelStr);
390 if (
MUELU_TEST_PARAM_2LIST(levelList, paramList,
"aggregation: drop scheme", std::string,
"distance laplacian") ||
393 useCoordinates_ =
true;
395 else if (
MUELU_TEST_PARAM_2LIST(levelList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal distance laplacian")) {
396 useCoordinates_ =
true;
397 useBlockNumber_ =
true;
399 else if (
MUELU_TEST_PARAM_2LIST(levelList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal") ||
400 MUELU_TEST_PARAM_2LIST(levelList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal classical") ||
401 MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal signed classical") ||
402 MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal colored signed classical") ||
403 MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"signed classical")) {
404 useBlockNumber_ =
true;
411 if (!paramList.isSublist(
"repartition: params")) {
412 useCoordinates_ =
true;
414 const ParameterList& repParams = paramList.sublist(
"repartition: params");
415 if (repParams.isType<std::string>(
"algorithm")) {
416 const std::string algo = repParams.get<std::string>(
"algorithm");
417 if (algo ==
"multijagged" || algo ==
"rcb") {
418 useCoordinates_ =
true;
421 useCoordinates_ =
true;
425 for (
int levelID = 0; levelID < this->numDesiredLevel_; levelID++) {
426 std::string levelStr =
"level " +
toString(levelID);
428 if (paramList.isSublist(levelStr)) {
429 const ParameterList& levelList = paramList.sublist(levelStr);
432 if (!levelList.isSublist(
"repartition: params")) {
433 useCoordinates_ =
true;
436 const ParameterList& repParams = levelList.sublist(
"repartition: params");
437 if (repParams.isType<std::string>(
"algorithm")) {
438 const std::string algo = repParams.get<std::string>(
"algorithm");
439 if (algo ==
"multijagged" || algo ==
"rcb"){
440 useCoordinates_ =
true;
444 useCoordinates_ =
true;
453 changedPRrebalance_ =
false;
455 changedPRrebalance_ =
MUELU_TEST_AND_SET_VAR(paramList,
"repartition: rebalance P and R",
bool, this->doPRrebalance_);
458 changedImplicitTranspose_ =
MUELU_TEST_AND_SET_VAR(paramList,
"transpose: use implicit",
bool, this->implicitTranspose_);
461 MUELU_TEST_AND_SET_VAR(paramList,
"fuse prolongation and update",
bool, this->fuseProlongationAndUpdate_);
463 if (paramList.isSublist(
"matvec params"))
464 this->matvecParams_ = Teuchos::parameterList(paramList.sublist(
"matvec params"));
469 defaultManager->SetVerbLevel(this->verbosity_);
470 defaultManager->SetKokkosRefactor(useKokkos_);
473 std::vector<keep_pair> keeps0;
474 UpdateFactoryManager(paramList, ParameterList(), *defaultManager, 0, keeps0);
480 for (
int levelID = 0; levelID < this->numDesiredLevel_; levelID++) {
486 RCP<FactoryManager> levelManager = rcp(
new FactoryManager(*defaultManager));
487 levelManager->SetVerbLevel(defaultManager->GetVerbLevel());
489 std::vector<keep_pair> keeps;
490 if (paramList.isSublist(
"level " +
toString(levelID))) {
492 ParameterList& levelList = paramList.sublist(
"level " +
toString(levelID),
true);
493 UpdateFactoryManager(levelList, paramList, *levelManager, levelID, keeps);
496 ParameterList levelList;
497 UpdateFactoryManager(levelList, paramList, *levelManager, levelID, keeps);
500 this->keep_[levelID] = keeps;
501 this->AddFactoryManager(levelID, 1, levelManager);
512 this->GetOStream(static_cast<MsgType>(
Runtime1), 0) << paramList << std::endl;
516 ParameterList unusedParamList;
519 for (ParameterList::ConstIterator it = paramList.begin(); it != paramList.end(); it++) {
520 const ParameterEntry& entry = paramList.entry(it);
522 if (!entry.isList() && !entry.isUsed())
523 unusedParamList.setEntry(paramList.name(it), entry);
527 for (
int levelID = 0; levelID < this->numDesiredLevel_; levelID++) {
528 std::string levelStr =
"level " +
toString(levelID);
530 if (paramList.isSublist(levelStr)) {
531 const ParameterList& levelList = paramList.sublist(levelStr);
533 for (ParameterList::ConstIterator itr = levelList.begin(); itr != levelList.end(); ++itr) {
534 const ParameterEntry& entry = levelList.entry(itr);
536 if (!entry.isList() && !entry.isUsed())
537 unusedParamList.sublist(levelStr).setEntry(levelList.name(itr), entry);
542 if (unusedParamList.numParams() > 0) {
543 std::ostringstream unusedParamsStream;
545 unusedParamList.print(unusedParamsStream, indent);
547 this->GetOStream(
Warnings1) <<
"The following parameters were not used:\n" << unusedParamsStream.str() << std::endl;
559 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
562 int levelID, std::vector<keep_pair>& keeps)
const 567 using strings = std::unordered_set<std::string>;
570 if (paramList.numParams() == 0 && defaultList.numParams() > 0)
571 paramList = ParameterList(defaultList);
574 TEUCHOS_TEST_FOR_EXCEPTION(strings({
"none",
"tP",
"RP",
"emin",
"RAP",
"full",
"S"}).count(reuseType) == 0,
577 MUELU_SET_VAR_2LIST(paramList, defaultList,
"multigrid algorithm", std::string, multigridAlgo);
578 TEUCHOS_TEST_FOR_EXCEPTION(strings({
"unsmoothed",
"sa",
"pg",
"emin",
"matlab",
"pcoarsen",
"classical",
"smoothed reitzinger",
"unsmoothed reitzinger"}).count(multigridAlgo) == 0,
579 Exceptions::RuntimeError,
"Unknown \"multigrid algorithm\" value: \"" << multigridAlgo <<
"\". Please consult User's Guide.");
580 #ifndef HAVE_MUELU_MATLAB 582 "Cannot use matlab for multigrid algorithm - MueLu was not configured with MATLAB support.");
584 #ifndef HAVE_MUELU_INTREPID2 586 "Cannot use IntrepidPCoarsen prolongator factory - MueLu was not configured with Intrepid support.");
591 if (reuseType ==
"none" || reuseType ==
"S" || reuseType ==
"RP" || reuseType ==
"RAP") {
594 }
else if (reuseType ==
"tP" && (multigridAlgo !=
"sa" && multigridAlgo !=
"unsmoothed")) {
596 this->GetOStream(
Warnings0) <<
"Ignoring \"tP\" reuse option as it is only compatible with \"sa\", " 597 "or \"unsmoothed\" multigrid algorithms" << std::endl;
599 }
else if (reuseType ==
"emin" && multigridAlgo !=
"emin") {
601 this->GetOStream(
Warnings0) <<
"Ignoring \"emin\" reuse option it is only compatible with " 602 "\"emin\" multigrid algorithm" << std::endl;
607 bool have_userP =
false;
608 if (paramList.isParameter(
"P") && !paramList.get<RCP<Matrix> >(
"P").is_null())
612 UpdateFactoryManager_CoarseSolvers(paramList, defaultList, manager, levelID, keeps);
615 UpdateFactoryManager_Smoothers(paramList, defaultList, manager, levelID, keeps);
619 UpdateFactoryManager_BlockNumber(paramList, defaultList, manager, levelID, keeps);
622 if(multigridAlgo ==
"unsmoothed reitzinger" || multigridAlgo ==
"smoothed reitzinger")
623 UpdateFactoryManager_Reitzinger(paramList, defaultList, manager, levelID, keeps);
625 UpdateFactoryManager_Aggregation_TentativeP(paramList, defaultList, manager, levelID, keeps);
628 RCP<Factory> nullSpaceFactory;
629 UpdateFactoryManager_Nullspace(paramList, defaultList, manager, levelID, keeps, nullSpaceFactory);
640 }
else if (multigridAlgo ==
"unsmoothed" || multigridAlgo ==
"unsmoothed reitzinger") {
644 }
else if (multigridAlgo ==
"classical") {
648 }
else if (multigridAlgo ==
"sa" || multigridAlgo ==
"smoothed reitzinger") {
650 UpdateFactoryManager_SA(paramList, defaultList, manager, levelID, keeps);
652 }
else if (multigridAlgo ==
"emin") {
654 UpdateFactoryManager_Emin(paramList, defaultList, manager, levelID, keeps);
656 }
else if (multigridAlgo ==
"pg") {
658 UpdateFactoryManager_PG(paramList, defaultList, manager, levelID, keeps);
660 }
else if (multigridAlgo ==
"matlab") {
662 UpdateFactoryManager_Matlab(paramList, defaultList, manager, levelID, keeps);
664 }
else if (multigridAlgo ==
"pcoarsen") {
666 UpdateFactoryManager_PCoarsen(paramList, defaultList, manager, levelID, keeps);
670 UpdateFactoryManager_SemiCoarsen(paramList, defaultList, manager, levelID, keeps);
673 UpdateFactoryManager_Restriction(paramList, defaultList, manager, levelID, keeps);
676 UpdateFactoryManager_RAP(paramList, defaultList, manager, levelID, keeps);
679 UpdateFactoryManager_LocalOrdinalTransfer(
"BlockNumber",multigridAlgo,paramList,defaultList,manager,levelID,keeps);
683 UpdateFactoryManager_Coordinates(paramList, defaultList, manager, levelID, keeps);
686 if ((reuseType ==
"RP" || reuseType ==
"RAP" || reuseType ==
"full") && levelID)
689 if (reuseType ==
"RP" && levelID) {
691 if (!this->implicitTranspose_)
694 if ((reuseType ==
"tP" || reuseType ==
"RP" || reuseType ==
"emin") && useCoordinates_ && levelID)
698 UpdateFactoryManager_Repartition(paramList, defaultList, manager, levelID, keeps, nullSpaceFactory);
701 if ((reuseType ==
"RAP" || reuseType ==
"full") && levelID) {
703 if (!this->implicitTranspose_)
716 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
719 FactoryManager& manager,
int levelID, std::vector<keep_pair>& keeps)
const 721 MUELU_SET_VAR_2LIST(paramList, defaultList,
"multigrid algorithm", std::string, multigridAlgo);
723 bool useMaxAbsDiagonalScaling =
false;
724 if (defaultList.isParameter(
"sa: use rowsumabs diagonal scaling"))
725 useMaxAbsDiagonalScaling = defaultList.get<
bool>(
"sa: use rowsumabs diagonal scaling");
726 double chebyReplaceTol = -Teuchos::ScalarTraits<double>::one();
727 if (defaultList.isParameter(
"sa: rowsumabs diagonal replacement tolerance"))
728 chebyReplaceTol = defaultList.get<
double>(
"sa: rowsumabs diagonal replacement tolerance");
732 bool isCustomSmoother =
733 paramList.isParameter(
"smoother: pre or post") ||
734 paramList.isParameter(
"smoother: type") || paramList.isParameter(
"smoother: pre type") || paramList.isParameter(
"smoother: post type") ||
735 paramList.isSublist (
"smoother: params") || paramList.isSublist (
"smoother: pre params") || paramList.isSublist (
"smoother: post params") ||
736 paramList.isParameter(
"smoother: sweeps") || paramList.isParameter(
"smoother: pre sweeps") || paramList.isParameter(
"smoother: post sweeps") ||
737 paramList.isParameter(
"smoother: overlap") || paramList.isParameter(
"smoother: pre overlap") || paramList.isParameter(
"smoother: post overlap");
741 manager.
SetFactory(
"Smoother", Teuchos::null);
743 }
else if (isCustomSmoother) {
747 #define TEST_MUTUALLY_EXCLUSIVE(arg1,arg2) \ 748 TEUCHOS_TEST_FOR_EXCEPTION(paramList.isParameter(#arg1) && paramList.isParameter(#arg2), \ 749 Exceptions::InvalidArgument, "You cannot specify both \""#arg1"\" and \""#arg2"\""); 750 #define TEST_MUTUALLY_EXCLUSIVE_S(arg1,arg2) \ 751 TEUCHOS_TEST_FOR_EXCEPTION(paramList.isSublist(#arg1) && paramList.isSublist(#arg2), \ 752 Exceptions::InvalidArgument, "You cannot specify both \""#arg1"\" and \""#arg2"\""); 762 TEUCHOS_TEST_FOR_EXCEPTION(
PreOrPost ==
"both" && (paramList.isParameter(
"smoother: pre type") != paramList.isParameter(
"smoother: post type")),
767 ParameterList defaultSmootherParams;
768 defaultSmootherParams.set(
"relaxation: type",
"Symmetric Gauss-Seidel");
769 defaultSmootherParams.set(
"relaxation: sweeps", Teuchos::OrdinalTraits<LO>::one());
770 defaultSmootherParams.set(
"relaxation: damping factor", Teuchos::ScalarTraits<Scalar>::one());
772 RCP<SmootherFactory> preSmoother = Teuchos::null, postSmoother = Teuchos::null;
773 std::string preSmootherType, postSmootherType;
774 ParameterList preSmootherParams, postSmootherParams;
776 if (paramList.isParameter(
"smoother: overlap"))
777 overlap = paramList.get<
int>(
"smoother: overlap");
780 if (paramList.isParameter(
"smoother: pre type")) {
781 preSmootherType = paramList.get<std::string>(
"smoother: pre type");
783 MUELU_SET_VAR_2LIST(paramList, defaultList,
"smoother: type", std::string, preSmootherTypeTmp);
784 preSmootherType = preSmootherTypeTmp;
786 if (paramList.isParameter(
"smoother: pre overlap"))
787 overlap = paramList.get<
int>(
"smoother: pre overlap");
789 if (paramList.isSublist(
"smoother: pre params"))
790 preSmootherParams = paramList.sublist(
"smoother: pre params");
791 else if (paramList.isSublist(
"smoother: params"))
792 preSmootherParams = paramList.sublist(
"smoother: params");
793 else if (defaultList.isSublist(
"smoother: params"))
794 preSmootherParams = defaultList.sublist(
"smoother: params");
795 else if (preSmootherType ==
"RELAXATION")
796 preSmootherParams = defaultSmootherParams;
798 if (preSmootherType ==
"CHEBYSHEV" && useMaxAbsDiagonalScaling)
799 preSmootherParams.set(
"chebyshev: use rowsumabs diagonal scaling",
true);
800 if (preSmootherType ==
"CHEBYSHEV" && chebyReplaceTol != -Teuchos::ScalarTraits<double>::one())
801 preSmootherParams.set(
"chebyshev: rowsumabs diagonal replacement tolerance",chebyReplaceTol);
802 if (preSmootherType ==
"CHEBYSHEV" && defaultList.isParameter(
"sa: rowsumabs diagonal replacement value"))
803 preSmootherParams.set(
"chebyshev: rowsumabs diagonal replacement value", defaultList.get<
double>(
"sa: rowsumabs diagonal replacement value"));
805 #ifdef HAVE_MUELU_INTREPID2 807 if (multigridAlgo ==
"pcoarsen" && preSmootherType ==
"TOPOLOGICAL" &&
808 defaultList.isParameter(
"pcoarsen: schedule") && defaultList.isParameter(
"pcoarsen: element")) {
811 auto pcoarsen_schedule = Teuchos::getArrayFromStringParameter<int>(defaultList,
"pcoarsen: schedule");
812 auto pcoarsen_element = defaultList.get<std::string>(
"pcoarsen: element");
814 if (levelID < (
int)pcoarsen_schedule.size()) {
816 auto lo = pcoarsen_element + std::to_string(pcoarsen_schedule[levelID]);
817 preSmootherParams.set(
"pcoarsen: hi basis", lo);
822 #ifdef HAVE_MUELU_MATLAB 823 if (preSmootherType ==
"matlab")
831 if (paramList.isParameter(
"smoother: post type"))
832 postSmootherType = paramList.get<std::string>(
"smoother: post type");
834 MUELU_SET_VAR_2LIST(paramList, defaultList,
"smoother: type", std::string, postSmootherTypeTmp);
835 postSmootherType = postSmootherTypeTmp;
838 if (paramList.isSublist(
"smoother: post params"))
839 postSmootherParams = paramList.sublist(
"smoother: post params");
840 else if (paramList.isSublist(
"smoother: params"))
841 postSmootherParams = paramList.sublist(
"smoother: params");
842 else if (defaultList.isSublist(
"smoother: params"))
843 postSmootherParams = defaultList.sublist(
"smoother: params");
844 else if (postSmootherType ==
"RELAXATION")
845 postSmootherParams = defaultSmootherParams;
846 if (paramList.isParameter(
"smoother: post overlap"))
847 overlap = paramList.get<
int>(
"smoother: post overlap");
849 if (postSmootherType ==
"CHEBYSHEV" && useMaxAbsDiagonalScaling)
850 postSmootherParams.set(
"chebyshev: use rowsumabs diagonal scaling",
true);
852 if (postSmootherType == preSmootherType &&
areSame(preSmootherParams, postSmootherParams))
853 postSmoother = preSmoother;
855 #ifdef HAVE_MUELU_INTREPID2 857 if (multigridAlgo ==
"pcoarsen" && preSmootherType ==
"TOPOLOGICAL" &&
858 defaultList.isParameter(
"pcoarsen: schedule") && defaultList.isParameter(
"pcoarsen: element")) {
861 auto pcoarsen_schedule = Teuchos::getArrayFromStringParameter<int>(defaultList,
"pcoarsen: schedule");
862 auto pcoarsen_element = defaultList.get<std::string>(
"pcoarsen: element");
864 if (levelID < (
int)pcoarsen_schedule.size()) {
866 auto lo = pcoarsen_element + std::to_string(pcoarsen_schedule[levelID]);
867 postSmootherParams.set(
"pcoarsen: hi basis", lo);
872 #ifdef HAVE_MUELU_MATLAB 873 if (postSmootherType ==
"matlab")
881 if (preSmoother == postSmoother)
884 manager.
SetFactory(
"PreSmoother", preSmoother);
885 manager.
SetFactory(
"PostSmoother", postSmoother);
892 bool reuseSmoothers = (reuseType ==
"S" || reuseType !=
"none");
893 if (reuseSmoothers) {
894 auto preSmootherFactory = rcp_const_cast<
Factory>(rcp_dynamic_cast<
const Factory>(manager.
GetFactory(
"PreSmoother")));
896 if (preSmootherFactory != Teuchos::null) {
897 ParameterList postSmootherFactoryParams;
898 postSmootherFactoryParams.set(
"keep smoother data",
true);
899 preSmootherFactory->SetParameterList(postSmootherFactoryParams);
901 keeps.push_back(
keep_pair(
"PreSmoother data", preSmootherFactory.get()));
904 auto postSmootherFactory = rcp_const_cast<
Factory>(rcp_dynamic_cast<
const Factory>(manager.
GetFactory(
"PostSmoother")));
905 if (postSmootherFactory != Teuchos::null) {
906 ParameterList postSmootherFactoryParams;
907 postSmootherFactoryParams.set(
"keep smoother data",
true);
908 postSmootherFactory->SetParameterList(postSmootherFactoryParams);
910 keeps.push_back(
keep_pair(
"PostSmoother data", postSmootherFactory.get()));
914 if (coarseFactory != Teuchos::null) {
915 ParameterList coarseFactoryParams;
916 coarseFactoryParams.set(
"keep smoother data",
true);
917 coarseFactory->SetParameterList(coarseFactoryParams);
919 keeps.push_back(
keep_pair(
"PreSmoother data", coarseFactory.get()));
923 if ((reuseType ==
"RAP" && levelID) || (reuseType ==
"full")) {
942 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
948 bool isCustomCoarseSolver =
949 paramList.isParameter(
"coarse: type") ||
950 paramList.isParameter(
"coarse: params");
952 this->GetOStream(
Warnings0) <<
"No coarse grid solver" << std::endl;
953 manager.
SetFactory(
"CoarseSolver", Teuchos::null);
955 }
else if (isCustomCoarseSolver) {
962 if (paramList.isParameter(
"coarse: overlap"))
963 overlap = paramList.get<
int>(
"coarse: overlap");
965 ParameterList coarseParams;
966 if (paramList.isSublist(
"coarse: params"))
967 coarseParams = paramList.sublist(
"coarse: params");
968 else if (defaultList.isSublist(
"coarse: params"))
969 coarseParams = defaultList.sublist(
"coarse: params");
971 using strings = std::unordered_set<std::string>;
973 RCP<SmootherPrototype> coarseSmoother;
977 if (strings({
"RELAXATION",
"CHEBYSHEV",
"ILUT",
"ILU",
"RILUK",
"SCHWARZ",
"Amesos",
978 "BLOCK RELAXATION",
"BLOCK_RELAXATION",
"BLOCKRELAXATION" ,
979 "SPARSE BLOCK RELAXATION",
"SPARSE_BLOCK_RELAXATION",
"SPARSEBLOCKRELAXATION",
980 "LINESMOOTHING_BANDEDRELAXATION",
"LINESMOOTHING_BANDED_RELAXATION",
"LINESMOOTHING_BANDED RELAXATION",
981 "LINESMOOTHING_TRIDIRELAXATION",
"LINESMOOTHING_TRIDI_RELAXATION",
"LINESMOOTHING_TRIDI RELAXATION",
982 "LINESMOOTHING_TRIDIAGONALRELAXATION",
"LINESMOOTHING_TRIDIAGONAL_RELAXATION",
"LINESMOOTHING_TRIDIAGONAL RELAXATION",
983 "TOPOLOGICAL",
"FAST_ILU",
"FAST_IC",
"FAST_ILDL"}).count(coarseType)) {
984 coarseSmoother = rcp(
new TrilinosSmoother(coarseType, coarseParams, overlap));
986 #ifdef HAVE_MUELU_MATLAB 987 if (coarseType ==
"matlab")
991 coarseSmoother = rcp(
new DirectSolver(coarseType, coarseParams));
1002 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1005 FactoryManager& manager,
int levelID, std::vector<keep_pair>& keeps)
const 1014 rFactory->SetFactory(
"D0", this->GetFactoryManager(levelID-1)->GetFactory(
"D0"));
1026 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1029 FactoryManager& manager,
int levelID, std::vector<keep_pair>& keeps)
const 1031 using strings = std::unordered_set<std::string>;
1036 TEUCHOS_TEST_FOR_EXCEPTION(!strings({
"uncoupled",
"coupled",
"brick",
"matlab",
"notay",
"classical"}).count(aggType),
1041 RCP<AmalgamationFactory> amalgFact;
1042 if(aggType ==
"classical") {
1044 manager.
SetFactory(
"UnAmalgamationInfo",amalgFact);
1048 RCP<Factory> dropFactory;
1051 #ifdef HAVE_MUELU_MATLAB 1053 ParameterList socParams = paramList.sublist(
"strength-of-connection: params");
1054 dropFactory->SetParameterList(socParams);
1056 throw std::runtime_error(
"Cannot use MATLAB evolutionary strength-of-connection - MueLu was not configured with MATLAB support.");
1058 }
else if (
MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"unsupported vector smoothing")) {
1060 ParameterList dropParams;
1066 dropFactory->SetParameterList(dropParams);
1070 ParameterList dropParams;
1071 dropParams.set(
"lightweight wrap",
true);
1088 if(!amalgFact.is_null())
1089 dropFactory->SetFactory(
"UnAmalgamationInfo", manager.
GetFactory(
"UnAmalgamationInfo"));
1091 if(dropParams.isParameter(
"aggregation: drop scheme")) {
1092 std::string drop_scheme = dropParams.get<std::string>(
"aggregation: drop scheme");
1093 if(drop_scheme ==
"block diagonal colored signed classical")
1094 manager.
SetFactory(
"Coloring Graph",dropFactory);
1095 if (drop_scheme.find(
"block diagonal") != std::string::npos || drop_scheme ==
"signed classical") {
1097 dropFactory->SetFactory(
"BlockNumber", this->GetFactoryManager(levelID-1)->GetFactory(
"BlockNumber"));
1099 dropFactory->SetFactory(
"BlockNumber", manager.
GetFactory(
"BlockNumber"));
1103 dropFactory->SetParameterList(dropParams);
1109 #ifndef HAVE_MUELU_MATLAB 1110 if (aggType ==
"matlab")
1111 throw std::runtime_error(
"Cannot use MATLAB aggregation - MueLu was not configured with MATLAB support.");
1113 RCP<Factory> aggFactory;
1114 if (aggType ==
"uncoupled") {
1116 ParameterList aggParams;
1138 aggFactory->SetParameterList(aggParams);
1140 aggFactory->SetFactory(
"DofsPerNode", manager.
GetFactory(
"Graph"));
1141 aggFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1144 }
else if (aggType ==
"coupled") {
1146 aggFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1148 }
else if (aggType ==
"brick") {
1150 ParameterList aggParams;
1157 aggFactory->SetParameterList(aggParams);
1163 aggFactory->SetFactory(
"Coordinates", this->GetFactoryManager(levelID-1)->GetFactory(
"Coordinates"));
1166 else if (aggType ==
"classical") {
1169 ParameterList mapParams;
1173 ParameterList tempParams;
1175 std::string drop_algo = tempParams.get<std::string>(
"aggregation: drop scheme");
1176 if(drop_algo ==
"block diagonal colored signed classical") {
1177 mapParams.set(
"aggregation: coloring: use color graph",
true);
1178 mapFact->SetFactory(
"Coloring Graph", manager.
GetFactory(
"Coloring Graph"));
1181 mapFact->SetParameterList(mapParams);
1182 mapFact->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1183 mapFact->SetFactory(
"UnAmalgamationInfo", manager.
GetFactory(
"UnAmalgamationInfo"));
1190 ParameterList aggParams;
1193 aggFactory->SetParameterList(aggParams);
1194 aggFactory->SetFactory(
"FC Splitting",manager.
GetFactory(
"FC Splitting"));
1195 aggFactory->SetFactory(
"CoarseMap",manager.
GetFactory(
"CoarseMap"));
1196 aggFactory->SetFactory(
"DofsPerNode", manager.
GetFactory(
"Graph"));
1197 aggFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1199 if (drop_algo.find(
"block diagonal") != std::string::npos || drop_algo ==
"signed classical") {
1201 aggFactory->SetFactory(
"BlockNumber", this->GetFactoryManager(levelID-1)->GetFactory(
"BlockNumber"));
1203 aggFactory->SetFactory(
"BlockNumber", manager.
GetFactory(
"BlockNumber"));
1211 if (reuseType ==
"tP" && levelID) {
1213 keeps.push_back(
keep_pair(
"Ptent",aggFactory.get()));
1217 #ifdef HAVE_MUELU_KOKKOS_REFACTOR 1218 else if (aggType ==
"notay") {
1219 aggFactory = rcp(
new NotayAggregationFactory());
1220 ParameterList aggParams;
1226 aggFactory->SetParameterList(aggParams);
1227 aggFactory->SetFactory(
"DofsPerNode", manager.
GetFactory(
"Graph"));
1228 aggFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1231 #ifdef HAVE_MUELU_MATLAB 1232 else if(aggType ==
"matlab") {
1233 ParameterList aggParams = paramList.sublist(
"aggregation: params");
1235 aggFactory->SetParameterList(aggParams);
1241 manager.
SetFactory(
"Aggregates", aggFactory);
1245 coarseMap->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1249 if (
MUELU_TEST_PARAM_2LIST(paramList, defaultList,
"aggregation: compute aggregate qualities",
bool,
true)) {
1251 ParameterList aggQualityParams;
1260 aggQualityFact->SetParameterList(aggQualityParams);
1261 manager.
SetFactory(
"AggregateQualities", aggQualityFact);
1263 assert(aggType ==
"uncoupled");
1264 aggFactory->SetFactory(
"AggregateQualities", aggQualityFact);
1270 ParameterList ptentParams;
1271 if (paramList.isSublist(
"matrixmatrix: kernel params"))
1272 ptentParams.sublist(
"matrixmatrix: kernel params",
false) = paramList.sublist(
"matrixmatrix: kernel params");
1273 if (defaultList.isSublist(
"matrixmatrix: kernel params"))
1274 ptentParams.sublist(
"matrixmatrix: kernel params",
false) = defaultList.sublist(
"matrixmatrix: kernel params");
1277 Ptent->SetParameterList(ptentParams);
1278 Ptent->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1279 Ptent->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1282 if (reuseType ==
"tP" && levelID) {
1283 keeps.push_back(
keep_pair(
"Nullspace", Ptent.get()));
1284 keeps.push_back(
keep_pair(
"P", Ptent.get()));
1291 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1294 int levelID, std::vector<keep_pair>& keeps)
const 1296 if (paramList.isParameter(
"A") && !paramList.get<RCP<Matrix> >(
"A").is_null()) {
1302 ParameterList RAPparams;
1304 RCP<RAPFactory> RAP;
1305 RCP<RAPShiftFactory> RAPs;
1308 std::string alg = paramList.get(
"rap: algorithm",
"galerkin");
1309 if (alg ==
"shift" || alg ==
"non-galerkin") {
1323 if (paramList.isSublist(
"matrixmatrix: kernel params"))
1324 RAPparams.sublist(
"matrixmatrix: kernel params",
false) = paramList.sublist(
"matrixmatrix: kernel params");
1325 if (defaultList.isSublist(
"matrixmatrix: kernel params"))
1326 RAPparams.sublist(
"matrixmatrix: kernel params",
false) = defaultList.sublist(
"matrixmatrix: kernel params");
1333 if (!paramList.isParameter(
"rap: triple product") &&
1334 paramList.isType<std::string>(
"multigrid algorithm") &&
1335 paramList.get<std::string>(
"multigrid algorithm") ==
"unsmoothed")
1336 paramList.set(
"rap: triple product",
true);
1341 if (paramList.isParameter(
"aggregation: allow empty prolongator columns")) {
1342 RAPparams.set(
"CheckMainDiagonal", paramList.get<
bool>(
"aggregation: allow empty prolongator columns"));
1343 RAPparams.set(
"RepairMainDiagonal", paramList.get<
bool>(
"aggregation: allow empty prolongator columns"));
1345 else if (defaultList.isParameter(
"aggregation: allow empty prolongator columns")) {
1346 RAPparams.set(
"CheckMainDiagonal", defaultList.get<
bool>(
"aggregation: allow empty prolongator columns"));
1347 RAPparams.set(
"RepairMainDiagonal", defaultList.get<
bool>(
"aggregation: allow empty prolongator columns"));
1350 }
catch (Teuchos::Exceptions::InvalidParameterType&) {
1351 TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(
true, Teuchos::Exceptions::InvalidParameterType,
1352 "Error: parameter \"aggregation: allow empty prolongator columns\" must be of type " << Teuchos::TypeNameTraits<bool>::name());
1355 if (!RAP.is_null()) {
1356 RAP->SetParameterList(RAPparams);
1357 RAP->SetFactory(
"P", manager.
GetFactory(
"P"));
1359 RAPs->SetParameterList(RAPparams);
1360 RAPs->SetFactory(
"P", manager.
GetFactory(
"P"));
1363 if (!this->implicitTranspose_) {
1365 RAP->SetFactory(
"R", manager.
GetFactory(
"R"));
1367 RAPs->SetFactory(
"R", manager.
GetFactory(
"R"));
1370 if (
MUELU_TEST_PARAM_2LIST(paramList, defaultList,
"aggregation: export visualization data",
bool,
true)) {
1372 ParameterList aggExportParams;
1380 aggExport->SetParameterList(aggExportParams);
1381 aggExport->SetFactory(
"DofsPerNode", manager.
GetFactory(
"DofsPerNode"));
1384 RAP->AddTransferFactory(aggExport);
1386 RAPs->AddTransferFactory(aggExport);
1394 MUELU_SET_VAR_2LIST(paramList, defaultList,
"sa: use filtered matrix",
bool, useFiltering);
1395 bool filteringChangesMatrix = useFiltering && !
MUELU_TEST_PARAM_2LIST(paramList, defaultList,
"aggregation: drop tol",
double, 0);
1397 if (reuseType ==
"RP" || (reuseType ==
"tP" && !filteringChangesMatrix)) {
1398 if (!RAP.is_null()) {
1399 keeps.push_back(
keep_pair(
"AP reuse data", RAP.get()));
1400 keeps.push_back(
keep_pair(
"RAP reuse data", RAP.get()));
1403 keeps.push_back(
keep_pair(
"AP reuse data", RAPs.get()));
1404 keeps.push_back(
keep_pair(
"RAP reuse data", RAPs.get()));
1412 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1417 bool have_userCO =
false;
1418 if (paramList.isParameter(
"Coordinates") && !paramList.get<RCP<MultiVector> >(
"Coordinates").is_null())
1421 if (useCoordinates_) {
1427 coords->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1428 coords->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1432 if (!RAP.is_null()) {
1433 RAP->AddTransferFactory(manager.
GetFactory(
"Coordinates"));
1436 RAPs->AddTransferFactory(manager.
GetFactory(
"Coordinates"));
1445 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1448 FactoryManager& manager,
int levelID, std::vector<keep_pair>& )
const 1452 if (useBlockNumber_ && (levelID > 0)) {
1455 if (!RAP.is_null() || !RAPs.is_null()) {
1457 if(multigridAlgo ==
"classical")
1458 fact->SetFactory(
"P Graph", manager.
GetFactory(
"P Graph"));
1460 fact->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1461 fact->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1463 fact->SetFactory(VarName, this->GetFactoryManager(levelID-1)->GetFactory(VarName));
1468 RAP->AddTransferFactory(manager.
GetFactory(VarName));
1470 RAPs->AddTransferFactory(manager.
GetFactory(VarName));
1479 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1482 FactoryManager& manager,
int levelID , std::vector<keep_pair>& keeps)
const 1484 if(useBlockNumber_) {
1485 ParameterList myParams;
1488 fact->SetParameterList(myParams);
1498 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1501 int levelID, std::vector<keep_pair>& )
const 1503 MUELU_SET_VAR_2LIST(paramList, defaultList,
"multigrid algorithm", std::string, multigridAlgo);
1504 bool have_userR =
false;
1505 if (paramList.isParameter(
"R") && !paramList.get<RCP<Matrix> >(
"R").is_null())
1510 if (!this->implicitTranspose_) {
1513 if (isSymmetric ==
false && (multigridAlgo ==
"unsmoothed" || multigridAlgo ==
"emin")) {
1515 "Switching \"problem: symmetric\" parameter to symmetric as multigrid algorithm. " <<
1516 multigridAlgo <<
" is primarily supposed to be used for symmetric problems.\n\n" <<
1517 "Please note: if you are using \"unsmoothed\" transfer operators the \"problem: symmetric\" parameter " <<
1518 "has no real mathematical meaning, i.e. you can use it for non-symmetric\n" <<
1519 "problems, too. With \"problem: symmetric\"=\"symmetric\" you can use implicit transpose for building " <<
1520 "the restriction operators which may drastically reduce the amount of consumed memory." << std::endl;
1524 "Petrov-Galerkin smoothed transfer operators are only allowed for non-symmetric problems: Set \"problem: symmetric\" to false!\n" \
1525 "While PG smoothed transfer operators generally would also work for symmetric problems this is an unusual use case. " \
1526 "You can use the factory-based xml interface though if you need PG-AMG for symmetric problems.");
1543 if (paramList.isParameter(
"restriction: scale nullspace") && paramList.get<
bool>(
"restriction: scale nullspace")) {
1545 Teuchos::ParameterList tentPlist;
1546 tentPlist.set(
"Nullspace name",
"Scaled Nullspace");
1547 tentPFactory->SetParameterList(tentPlist);
1548 tentPFactory->SetFactory(
"Aggregates",manager.
GetFactory(
"Aggregates"));
1549 tentPFactory->SetFactory(
"CoarseMap",manager.
GetFactory(
"CoarseMap"));
1552 R->SetFactory(
"P",tentPFactory);
1561 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1564 int levelID, std::vector<keep_pair>& keeps, RCP<Factory> & nullSpaceFactory)
const 1608 "Reuse types \"tP\" and \"PR\" require \"repartition: rebalance P and R\" set to \"false\"");
1613 MUELU_SET_VAR_2LIST(paramList, defaultList,
"repartition: partitioner", std::string, partName);
1615 "Invalid partitioner name: \"" << partName <<
"\". Valid options: \"zoltan\", \"zoltan2\"");
1617 #ifndef HAVE_MUELU_ZOLTAN 1618 bool switched =
false;
1619 if (partName ==
"zoltan") {
1620 this->GetOStream(
Warnings0) <<
"Zoltan interface is not available, trying to switch to Zoltan2" << std::endl;
1621 partName =
"zoltan2";
1625 # ifndef HAVE_MUELU_ZOLTAN2 1626 bool switched =
false;
1629 #ifndef HAVE_MUELU_ZOLTAN2 1630 if (partName ==
"zoltan2" && !switched) {
1631 this->GetOStream(
Warnings0) <<
"Zoltan2 interface is not available, trying to switch to Zoltan" << std::endl;
1632 partName =
"zoltan";
1636 MUELU_SET_VAR_2LIST(paramList, defaultList,
"repartition: node repartition level",
int,nodeRepartitionLevel);
1640 ParameterList repartheurParams;
1648 repartheurFactory->SetParameterList(repartheurParams);
1649 repartheurFactory->SetFactory(
"A", manager.
GetFactory(
"A"));
1650 manager.
SetFactory(
"number of partitions", repartheurFactory);
1651 manager.
SetFactory(
"repartition: heuristic target rows per process", repartheurFactory);
1654 RCP<Factory> partitioner;
1655 if (levelID == nodeRepartitionLevel) {
1659 ParameterList partParams;
1661 partitioner->SetParameterList(partParams);
1662 partitioner->SetFactory(
"Node Comm", manager.
GetFactory(
"Node Comm"));
1667 else if (partName ==
"zoltan") {
1668 #ifdef HAVE_MUELU_ZOLTAN 1674 }
else if (partName ==
"zoltan2") {
1675 #ifdef HAVE_MUELU_ZOLTAN2 1677 ParameterList partParams;
1678 RCP<const ParameterList> partpartParams = rcp(
new ParameterList(paramList.sublist(
"repartition: params",
false)));
1679 partParams.set(
"ParameterList", partpartParams);
1680 partitioner->SetParameterList(partParams);
1681 partitioner->SetFactory(
"repartition: heuristic target rows per process",
1682 manager.
GetFactory(
"repartition: heuristic target rows per process"));
1688 partitioner->SetFactory(
"A", manager.
GetFactory(
"A"));
1689 partitioner->SetFactory(
"number of partitions", manager.
GetFactory(
"number of partitions"));
1690 if (useCoordinates_)
1691 partitioner->SetFactory(
"Coordinates", manager.
GetFactory(
"Coordinates"));
1692 manager.
SetFactory(
"Partition", partitioner);
1696 ParameterList repartParams;
1700 repartFactory->SetParameterList(repartParams);
1701 repartFactory->SetFactory(
"A", manager.
GetFactory(
"A"));
1702 repartFactory->SetFactory(
"number of partitions", manager.
GetFactory(
"number of partitions"));
1703 repartFactory->SetFactory(
"Partition", manager.
GetFactory(
"Partition"));
1704 manager.
SetFactory(
"Importer", repartFactory);
1705 if (reuseType !=
"none" && reuseType !=
"S" && levelID)
1710 ParameterList rebAcParams;
1712 newA->SetParameterList(rebAcParams);
1713 newA->SetFactory(
"A", manager.
GetFactory(
"A"));
1714 newA->SetFactory(
"Importer", manager.
GetFactory(
"Importer"));
1719 ParameterList newPparams;
1720 newPparams.set(
"type",
"Interpolation");
1721 if (changedPRrebalance_)
1722 newPparams.set(
"repartition: rebalance P and R", this->doPRrebalance_);
1724 newP-> SetParameterList(newPparams);
1725 newP-> SetFactory(
"Importer", manager.
GetFactory(
"Importer"));
1726 newP-> SetFactory(
"P", manager.
GetFactory(
"P"));
1727 if (!paramList.isParameter(
"semicoarsen: number of levels"))
1728 newP->SetFactory(
"Nullspace", manager.
GetFactory(
"Ptent"));
1730 newP->SetFactory(
"Nullspace", manager.
GetFactory(
"P"));
1731 if (useCoordinates_)
1732 newP-> SetFactory(
"Coordinates", manager.
GetFactory(
"Coordinates"));
1734 if (useCoordinates_)
1736 if (useBlockNumber_ && (levelID > 0)) {
1737 newP->SetFactory(
"BlockNumber", manager.
GetFactory(
"BlockNumber"));
1743 ParameterList newRparams;
1744 newRparams.set(
"type",
"Restriction");
1746 if (changedPRrebalance_)
1747 newRparams.set(
"repartition: rebalance P and R", this->doPRrebalance_);
1748 if (changedImplicitTranspose_)
1749 newRparams.set(
"transpose: use implicit", this->implicitTranspose_);
1750 newR-> SetParameterList(newRparams);
1751 newR-> SetFactory(
"Importer", manager.
GetFactory(
"Importer"));
1752 if (!this->implicitTranspose_) {
1753 newR->SetFactory(
"R", manager.
GetFactory(
"R"));
1764 nullSpaceFactory->SetFactory(
"Nullspace", newP);
1766 paramList.set(
"repartition: enable",
false);
1767 this->GetOStream(
Warnings0) <<
"No repartitioning available for a serial run\n";
1775 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1778 int , std::vector<keep_pair>& , RCP<Factory> & nullSpaceFactory)
const 1783 bool have_userNS =
false;
1784 if (paramList.isParameter(
"Nullspace") && !paramList.get<RCP<MultiVector> >(
"Nullspace").is_null())
1788 nullSpace->SetFactory(
"Nullspace", manager.
GetFactory(
"Ptent"));
1791 nullSpaceFactory = nullSpace;
1793 if (paramList.isParameter(
"restriction: scale nullspace") && paramList.get<
bool>(
"restriction: scale nullspace")) {
1795 scaledNSfactory->SetFactory(
"Nullspace",nullSpaceFactory);
1796 manager.
SetFactory(
"Scaled Nullspace",scaledNSfactory);
1804 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1807 int , std::vector<keep_pair>& )
const 1810 RCP<Factory> semicoarsenFactory = Teuchos::null;
1811 if (paramList.isParameter(
"semicoarsen: number of levels") &&
1812 paramList.get<
int>(
"semicoarsen: number of levels") > 0) {
1814 ParameterList togglePParams;
1815 ParameterList semicoarsenPParams;
1816 ParameterList linedetectionParams;
1827 linedetectionFactory->SetParameterList(linedetectionParams);
1828 semicoarsenFactory ->SetParameterList(semicoarsenPParams);
1829 togglePFactory ->SetParameterList(togglePParams);
1831 togglePFactory->AddCoarseNullspaceFactory (semicoarsenFactory);
1832 togglePFactory->AddProlongatorFactory (semicoarsenFactory);
1833 togglePFactory->AddPtentFactory (semicoarsenFactory);
1834 togglePFactory->AddCoarseNullspaceFactory (manager.
GetFactory(
"Ptent"));
1835 togglePFactory->AddProlongatorFactory (manager.
GetFactory(
"P"));
1836 togglePFactory->AddPtentFactory (manager.
GetFactory(
"Ptent"));
1838 manager.
SetFactory(
"CoarseNumZLayers", linedetectionFactory);
1839 manager.
SetFactory(
"LineDetection_Layers", linedetectionFactory);
1840 manager.
SetFactory(
"LineDetection_VertLineIds", linedetectionFactory);
1844 manager.
SetFactory(
"Nullspace", togglePFactory);
1847 if (paramList.isParameter(
"semicoarsen: number of levels")) {
1849 tf->SetFactory(
"Chosen P", manager.
GetFactory(
"P"));
1850 tf->AddCoordTransferFactory(semicoarsenFactory);
1853 coords->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1854 coords->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1855 tf->AddCoordTransferFactory(coords);
1864 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1867 int levelID, std::vector<keep_pair>& keeps)
const 1869 #ifdef HAVE_MUELU_INTREPID2 1871 if (defaultList.isParameter(
"pcoarsen: schedule") && defaultList.isParameter(
"pcoarsen: element")) {
1874 auto pcoarsen_schedule = Teuchos::getArrayFromStringParameter<int>(defaultList,
"pcoarsen: schedule");
1875 auto pcoarsen_element = defaultList.get<std::string>(
"pcoarsen: element");
1877 if (levelID >= (
int)pcoarsen_schedule.size()) {
1880 UpdateFactoryManager_SA(paramList, defaultList, manager, levelID, keeps);
1884 ParameterList Pparams;
1886 std::string lo = pcoarsen_element + std::to_string(pcoarsen_schedule[levelID]);
1887 std::string hi = (levelID ? pcoarsen_element + std::to_string(pcoarsen_schedule[levelID-1]) : lo);
1888 Pparams.set(
"pcoarsen: hi basis", hi);
1889 Pparams.set(
"pcoarsen: lo basis", lo);
1890 P->SetParameterList(Pparams);
1899 ParameterList Pparams;
1903 P->SetParameterList(Pparams);
1916 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1921 ParameterList Pparams;
1922 if (paramList.isSublist(
"matrixmatrix: kernel params"))
1923 Pparams.sublist(
"matrixmatrix: kernel params",
false) = paramList.sublist(
"matrixmatrix: kernel params");
1924 if (defaultList.isSublist(
"matrixmatrix: kernel params"))
1925 Pparams.sublist(
"matrixmatrix: kernel params",
false) = defaultList.sublist(
"matrixmatrix: kernel params");
1936 P->SetParameterList(Pparams);
1940 MUELU_SET_VAR_2LIST(paramList, defaultList,
"sa: use filtered matrix",
bool, useFiltering);
1948 ParameterList fParams;
1957 filterFactory->SetParameterList(fParams);
1958 filterFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1959 filterFactory->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1960 filterFactory->SetFactory(
"UnAmalgamationInfo", manager.
GetFactory(
"UnAmalgamationInfo"));
1962 filterFactory->SetFactory(
"Filtering", manager.
GetFactory(
"Graph"));
1964 P->SetFactory(
"A", filterFactory);
1967 P->SetFactory(
"A", manager.
GetFactory(
"Graph"));
1971 P->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
1974 bool filteringChangesMatrix = useFiltering && !
MUELU_TEST_PARAM_2LIST(paramList, defaultList,
"aggregation: drop tol",
double, 0);
1976 if (reuseType ==
"tP" && !filteringChangesMatrix)
1977 keeps.push_back(
keep_pair(
"AP reuse data", P.get()));
1983 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1986 int , std::vector<keep_pair>& )
const 1991 "Invalid pattern name: \"" << patternType <<
"\". Valid options: \"AkPtent\"");
1994 ParameterList patternParams;
1996 patternFactory->SetParameterList(patternParams);
1997 patternFactory->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
1998 manager.
SetFactory(
"Ppattern", patternFactory);
2002 constraintFactory->SetFactory(
"Ppattern", manager.
GetFactory(
"Ppattern"));
2003 constraintFactory->SetFactory(
"CoarseNullspace", manager.
GetFactory(
"Ptent"));
2004 manager.
SetFactory(
"Constraint", constraintFactory);
2009 MUELU_SET_VAR_2LIST(paramList, defaultList,
"emin: use filtered matrix",
bool, useFiltering);
2017 ParameterList fParams;
2026 filterFactory->SetParameterList(fParams);
2027 filterFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
2028 filterFactory->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
2029 filterFactory->SetFactory(
"UnAmalgamationInfo", manager.
GetFactory(
"UnAmalgamationInfo"));
2031 filterFactory->SetFactory(
"Filtering", manager.
GetFactory(
"Graph"));
2033 P->SetFactory(
"A", filterFactory);
2036 P->SetFactory(
"A", manager.
GetFactory(
"Graph"));
2041 ParameterList Pparams;
2044 if (reuseType ==
"emin") {
2046 Pparams.set(
"Keep P0",
true);
2047 Pparams.set(
"Keep Constraint0",
true);
2049 P->SetParameterList(Pparams);
2050 P->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
2051 P->SetFactory(
"Constraint", manager.
GetFactory(
"Constraint"));
2058 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2061 int , std::vector<keep_pair>& )
const 2064 "Implicit transpose not supported with Petrov-Galerkin smoothed transfer operators: Set \"transpose: use implicit\" to false!\n" \
2065 "Petrov-Galerkin transfer operator smoothing for non-symmetric problems requires a separate handling of the restriction operator which " \
2066 "does not allow the usage of implicit transpose easily.");
2070 P->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
2078 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2081 int , std::vector<keep_pair>& )
const {
2082 #ifdef HAVE_MUELU_MATLAB 2083 ParameterList Pparams = paramList.sublist(
"transfer: params");
2085 P->SetParameterList(Pparams);
2086 P->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
2094 #undef MUELU_SET_VAR_2LIST 2095 #undef MUELU_TEST_AND_SET_VAR 2096 #undef MUELU_TEST_AND_SET_PARAM_2LIST 2097 #undef MUELU_TEST_PARAM_2LIST 2098 #undef MUELU_KOKKOS_FACTORY 2102 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2104 ParameterList paramList = constParamList;
2107 const int maxLevels = 100;
2110 std::vector<ParameterList> paramLists;
2111 for (
int levelID = 0; levelID < maxLevels; levelID++) {
2112 std::string sublistName =
"level " +
toString(levelID);
2113 if (paramList.isSublist(sublistName)) {
2114 paramLists.push_back(paramList.sublist(sublistName));
2116 paramList.remove(sublistName);
2119 paramLists.push_back(paramList);
2121 #ifdef HAVE_MUELU_MATLAB 2123 for (
size_t i = 0; i < paramLists.size(); i++) {
2124 std::vector<std::string> customVars;
2126 for(Teuchos::ParameterList::ConstIterator it = paramLists[i].begin(); it != paramLists[i].end(); it++) {
2127 std::string paramName = paramLists[i].name(it);
2130 customVars.push_back(paramName);
2134 for (
size_t j = 0; j < customVars.size(); j++)
2135 paramLists[i].
remove(customVars[j],
false);
2139 const int maxDepth = 0;
2140 for (
size_t i = 0; i < paramLists.size(); i++) {
2143 paramLists[i].validateParameters(validList, maxDepth);
2145 }
catch (
const Teuchos::Exceptions::InvalidParameterName& e) {
2146 std::string eString = e.what();
2149 size_t nameStart = eString.find_first_of(
'"') + 1;
2150 size_t nameEnd = eString.find_first_of(
'"', nameStart);
2151 std::string name = eString.substr(nameStart, nameEnd - nameStart);
2153 size_t bestScore = 100;
2154 std::string bestName =
"";
2155 for (ParameterList::ConstIterator it = validList.begin(); it != validList.end(); it++) {
2156 const std::string& pName = validList.name(it);
2157 this->GetOStream(
Runtime1) <<
"| " << pName;
2158 size_t score =
LevenshteinDistance(name.c_str(), name.length(), pName.c_str(), pName.length());
2159 this->GetOStream(
Runtime1) <<
" -> " << score << std::endl;
2160 if (score < bestScore) {
2165 if (bestScore < 10 && bestName !=
"") {
2166 TEUCHOS_TEST_FOR_EXCEPTION(
true, Teuchos::Exceptions::InvalidParameterName,
2167 eString <<
"The parameter name \"" + name +
"\" is not valid. Did you mean \"" + bestName <<
"\"?\n");
2170 TEUCHOS_TEST_FOR_EXCEPTION(
true, Teuchos::Exceptions::InvalidParameterName,
2171 eString <<
"The parameter name \"" + name +
"\" is not valid.\n");
2180 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2185 ParameterList paramList = constParamList;
2192 if (paramList.isSublist(
"Matrix")) {
2193 blockSize_ = paramList.sublist(
"Matrix").get<
int>(
"PDE equations", MasterList::getDefault<int>(
"number of equations"));
2194 dofOffset_ = paramList.sublist(
"Matrix").get<
GlobalOrdinal>(
"DOF offset", 0);
2198 if (factFact_ == Teuchos::null)
2210 if (paramList.isSublist(
"Factories"))
2211 this->BuildFactoryMap(paramList.sublist(
"Factories"), factoryMap, factoryMap, factoryManagers);
2225 if (paramList.isSublist(
"Hierarchy")) {
2226 ParameterList hieraList = paramList.sublist(
"Hierarchy");
2229 if (hieraList.isParameter(
"max levels")) {
2230 this->numDesiredLevel_ = hieraList.get<
int>(
"max levels");
2231 hieraList.remove(
"max levels");
2234 if (hieraList.isParameter(
"coarse: max size")) {
2235 this->maxCoarseSize_ = hieraList.get<
int>(
"coarse: max size");
2236 hieraList.remove(
"coarse: max size");
2239 if (hieraList.isParameter(
"repartition: rebalance P and R")) {
2240 this->doPRrebalance_ = hieraList.get<
bool>(
"repartition: rebalance P and R");
2241 hieraList.remove(
"repartition: rebalance P and R");
2244 if (hieraList.isParameter(
"transpose: use implicit")) {
2245 this->implicitTranspose_ = hieraList.get<
bool>(
"transpose: use implicit");
2246 hieraList.remove(
"transpose: use implicit");
2249 if (hieraList.isParameter(
"fuse prolongation and update")) {
2250 this->fuseProlongationAndUpdate_ = hieraList.get<
bool>(
"fuse prolongation and update");
2251 hieraList.remove(
"fuse prolongation and update");
2254 if (hieraList.isParameter(
"number of vectors")) {
2255 this->numDesiredLevel_ = hieraList.get<
int>(
"number of vectors");
2256 hieraList.remove(
"number of vectors");
2259 if (hieraList.isSublist(
"matvec params"))
2260 this->matvecParams_ = Teuchos::parameterList(hieraList.sublist(
"matvec params"));
2263 if (hieraList.isParameter(
"coarse grid correction scaling factor")) {
2264 this->scalingFactor_ = hieraList.get<
double>(
"coarse grid correction scaling factor");
2265 hieraList.remove(
"coarse grid correction scaling factor");
2269 if (hieraList.isParameter(
"cycle type")) {
2270 std::map<std::string, CycleType> cycleMap;
2274 std::string cycleType = hieraList.get<std::string>(
"cycle type");
2275 TEUCHOS_TEST_FOR_EXCEPTION(cycleMap.count(cycleType) == 0,
Exceptions::RuntimeError,
"Invalid cycle type: \"" << cycleType <<
"\"");
2276 this->Cycle_ = cycleMap[cycleType];
2279 if (hieraList.isParameter(
"W cycle start level")) {
2280 this->WCycleStartLevel_ = hieraList.get<
int>(
"W cycle start level");
2283 if (hieraList.isParameter(
"verbosity")) {
2284 std::string vl = hieraList.get<std::string>(
"verbosity");
2285 hieraList.remove(
"verbosity");
2289 if (hieraList.isParameter(
"output filename"))
2292 if (hieraList.isParameter(
"dependencyOutputLevel"))
2293 this->graphOutputLevel_ = hieraList.get<
int>(
"dependencyOutputLevel");
2296 if (hieraList.isParameter(
"reuse"))
2299 if (hieraList.isSublist(
"DataToWrite")) {
2302 ParameterList foo = hieraList.sublist(
"DataToWrite");
2303 std::string dataName =
"Matrices";
2304 if (foo.isParameter(dataName))
2305 this->matricesToPrint_ = Teuchos::getArrayFromStringParameter<int>(foo, dataName);
2306 dataName =
"Prolongators";
2307 if (foo.isParameter(dataName))
2308 this->prolongatorsToPrint_ = Teuchos::getArrayFromStringParameter<int>(foo, dataName);
2309 dataName =
"Restrictors";
2310 if (foo.isParameter(dataName))
2311 this->restrictorsToPrint_ = Teuchos::getArrayFromStringParameter<int>(foo, dataName);
2315 for (ParameterList::ConstIterator param = hieraList.begin(); param != hieraList.end(); ++param) {
2316 const std::string & paramName = hieraList.name(param);
2318 if (paramName !=
"DataToWrite" && hieraList.isSublist(paramName)) {
2319 ParameterList levelList = hieraList.sublist(paramName);
2321 int startLevel = 0;
if(levelList.isParameter(
"startLevel")) { startLevel = levelList.get<
int>(
"startLevel"); levelList.remove(
"startLevel"); }
2322 int numDesiredLevel = 1;
if(levelList.isParameter(
"numDesiredLevel")) { numDesiredLevel = levelList.get<
int>(
"numDesiredLevel"); levelList.remove(
"numDesiredLevel"); }
2335 BuildFactoryMap(levelList, factoryMap, levelFactoryMap, factoryManagers);
2337 RCP<FactoryManager> m = rcp(
new FactoryManager(levelFactoryMap));
2338 if (hieraList.isParameter(
"use kokkos refactor"))
2339 m->SetKokkosRefactor(hieraList.get<
bool>(
"use kokkos refactor"));
2341 if (startLevel >= 0)
2342 this->AddFactoryManager(startLevel, numDesiredLevel, m);
2344 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::ParameterListInterpreter():: invalid level id");
2474 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2477 for (ParameterList::ConstIterator param = paramList.begin(); param != paramList.end(); ++param) {
2478 const std::string & paramName = paramList.name(param);
2479 const Teuchos::ParameterEntry & paramValue = paramList.entry(param);
2483 if (paramValue.isList()) {
2484 ParameterList paramList1 = Teuchos::getValue<ParameterList>(paramValue);
2485 if (paramList1.isParameter(
"factory")) {
2488 "MueLu::ParameterListInterpreter(): It seems that in the parameter lists for defining " << paramName <<
2489 " there is both a 'factory' and 'dependency for' parameter. This is not allowed. Please remove the 'dependency for' parameter.");
2491 factoryMapOut[paramName] = factFact_->BuildFactory(paramValue, factoryMapIn, factoryManagers);
2493 }
else if (paramList1.isParameter(
"dependency for")) {
2495 "MueLu::ParameterListInterpreter(): It seems that in the parameter lists for defining " << paramName <<
2496 " there is both a 'factory' and 'dependency for' parameter. This is not allowed.");
2498 std::string factoryName = paramList1.get<std::string>(
"dependency for");
2500 RCP<const FactoryBase> factbase = factoryMapIn.find(factoryName )->second;
2502 "MueLu::ParameterListInterpreter(): could not find factory " + factoryName +
" in factory map. Did you define it before?");
2504 RCP<const Factory> factoryconst = Teuchos::rcp_dynamic_cast<
const Factory>(factbase);
2505 RCP< Factory> factory = Teuchos::rcp_const_cast<
Factory>(factoryconst);
2509 for (ParameterList::ConstIterator vparam = validParamList->begin(); vparam != validParamList->end(); ++vparam) {
2510 const std::string& pName = validParamList->name(vparam);
2512 if (!paramList1.isParameter(pName)) {
2517 if (validParamList->isType< RCP<const FactoryBase> >(pName)) {
2519 RCP<const FactoryBase> generatingFact = factFact_->BuildFactory(paramList1.getEntry(pName), factoryMapIn, factoryManagers);
2520 factory->SetFactory(pName, generatingFact.create_weak());
2522 }
else if (validParamList->isType<RCP<const ParameterList> >(pName)) {
2523 if (pName ==
"ParameterList") {
2528 RCP<const ParameterList> subList = Teuchos::sublist(rcp(
new ParameterList(paramList1)), pName);
2529 factory->SetParameter(pName, ParameterEntry(subList));
2532 factory->SetParameter(pName, paramList1.getEntry(pName));
2536 }
else if (paramList1.isParameter(
"group")) {
2538 std::string groupType = paramList1.get<std::string>(
"group");
2540 "group must be of type \"FactoryManager\".");
2542 ParameterList groupList = paramList1;
2543 groupList.remove(
"group");
2545 bool setKokkosRefactor =
false;
2546 bool kokkosRefactor = useKokkos_;
2547 if (groupList.isParameter(
"use kokkos refactor")) {
2548 kokkosRefactor = groupList.get<
bool>(
"use kokkos refactor");
2549 groupList.remove(
"use kokkos refactor");
2550 setKokkosRefactor =
true;
2554 BuildFactoryMap(groupList, factoryMapIn, groupFactoryMap, factoryManagers);
2558 RCP<FactoryManager> m = rcp(
new FactoryManager(groupFactoryMap));
2559 if (setKokkosRefactor)
2560 m->SetKokkosRefactor(kokkosRefactor);
2561 factoryManagers[paramName] = m;
2564 this->GetOStream(
Warnings0) <<
"Could not interpret parameter list " << paramList1 << std::endl;
2566 "XML Parameter list must either be of type \"factory\" or of type \"group\".");
2570 factoryMapOut[paramName] = factFact_->BuildFactory(paramValue, factoryMapIn, factoryManagers);
2578 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2581 Matrix& A =
dynamic_cast<Matrix&
>(Op);
2582 if (A.IsFixedBlockSizeSet() && (A.GetFixedBlockSize() != blockSize_))
2583 this->GetOStream(
Warnings0) <<
"Setting matrix block size to " << blockSize_ <<
" (value of the parameter in the list) " 2584 <<
"instead of " << A.GetFixedBlockSize() <<
" (provided matrix)." << std::endl
2585 <<
"You may want to check \"number of equations\" (or \"PDE equations\" for factory style list) parameter." << std::endl;
2587 A.SetFixedBlockSize(blockSize_, dofOffset_);
2589 #ifdef HAVE_MUELU_DEBUG 2590 MatrixUtils::checkLocalRowMapMatchesColMap(A);
2591 #endif // HAVE_MUELU_DEBUG 2593 }
catch (std::bad_cast&) {
2594 this->GetOStream(
Warnings0) <<
"Skipping setting block size as the operator is not a matrix" << std::endl;
2598 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2606 static bool compare(
const ParameterList& list1,
const ParameterList& list2) {
2609 for (ParameterList::ConstIterator it = list1.begin(); it != list1.end(); it++) {
2610 const std::string& name = it->first;
2611 const Teuchos::ParameterEntry& entry1 = it->second;
2613 const Teuchos::ParameterEntry *entry2 = list2.getEntryPtr(name);
2616 if (entry1.isList() && entry2->isList()) {
2617 compare(Teuchos::getValue<ParameterList>(entry1), Teuchos::getValue<ParameterList>(*entry2));
2620 if (entry1.getAny(
false) != entry2->getAny(
false))
2627 static inline bool areSame(
const ParameterList& list1,
const ParameterList& list2) {
2633 #define MUELU_PARAMETERLISTINTERPRETER_SHORT Important warning messages (one line)
Generic Smoother Factory for generating the smoothers of the MG hierarchy.
virtual RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
This class specifies the default factory that should generate some data on a Level if the data does n...
static void SetMueLuOFileStream(const std::string &filename)
Factory for determing the number of partitions for rebalancing.
#define MUELU_KOKKOS_FACTORY_NO_DECL(varName, oldFactory, newFactory)
Factory for generating coarse level map. Used by TentativePFactory.
std::string toString(const T &what)
Little helper function to convert non-string types to strings.
Factory for building transfer operators based on coarsening in polynomial degree, following the Intre...
Factory for building coarse grid matrices, when the matrix is of the form K+a*M. Useful when you want...
Class for generating an initial LocalOrdinal-type BlockNumber vector, based on an input paraemter for...
Factory that can generate other factories from.
void UpdateFactoryManager_CoarseSolvers(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
static void SetDefaultVerbLevel(const VerbLevel defaultVerbLevel)
Set the default (global) verbosity level.
void UpdateFactoryManager_Smoothers(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
Class that encapsulates external library smoothers.
size_t LevenshteinDistance(const char *s, size_t len_s, const char *t, size_t len_t)
static void DisableMultipleCheckGlobally()
#define MUELU_TEST_AND_SET_VAR(paramList, paramName, paramType, varName)
Factory for building permutation matrix that can be be used to shuffle data (matrices, vectors) among processes.
Class for transferring a vector of local ordinals from a finer level to a coarser one...
One-liner description of what is happening.
ParameterListInterpreter()
Empty constructor.
void BuildFactoryMap(const Teuchos::ParameterList ¶mList, const FactoryMap &factoryMapIn, FactoryMap &factoryMapOut, FactoryManagerMap &factoryManagers) const
Interpret "Factories" sublist.
void UpdateFactoryManager_SA(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
virtual void SetupOperator(Operator &A) const
Setup Operator object.
void SetCycle(CycleType Cycle)
Supports VCYCLE and WCYCLE types.
Namespace for MueLu classes and methods.
#define MUELU_KOKKOS_FACTORY(varName, oldFactory, newFactory)
Interface to Zoltan library.This interface provides access to partitioning methods in Zoltan...
bool IsParamMuemexVariable(const std::string &name)
Factory for creating a graph base on a given matrix.
void UpdateFactoryManager_Repartition(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps, RCP< Factory > &nullSpaceFactory) const
static VerbLevel GetDefaultVerbLevel()
Get the default (global) verbosity level.
void UpdateFactoryManager_Aggregation_TentativeP(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
std::map< std::string, RCP< FactoryManagerBase > > FactoryManagerMap
std::map< std::string, RCP< const FactoryBase > > FactoryMap
void UpdateFactoryManager_PG(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
void UpdateFactoryManager_RAP(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
Factory for building tentative prolongator.
#define TEST_MUTUALLY_EXCLUSIVE(arg1, arg2)
MsgType toVerbLevel(const std::string &verbLevelStr)
Class that encapsulates direct solvers. Autoselection of AmesosSmoother or Amesos2Smoother according ...
Factory for coarsening a graph with uncoupled aggregation.
virtual void SetupHierarchy(Hierarchy &H) const
Setup Hierarchy object.
Prolongator factory performing semi-coarsening.
Factory for building restriction operators using a prolongator factory.
void UpdateFactoryManager_PCoarsen(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
Teuchos::RCP< MueLu::FacadeClassFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node > > facadeFact_
FacadeClass factory.
void UpdateFactoryManager_BlockNumber(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
#define MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, paramName, paramType, listWrite)
static bool compare(const ParameterList &list1, const ParameterList &list2)
static CycleType GetDefaultCycle()
MueLu::DefaultScalar Scalar
void UpdateFactoryManager(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
MueLu::DefaultGlobalOrdinal GlobalOrdinal
void SetCycleStartLevel(int cycleStart)
Factory for interacting with Matlab.
Factory for interacting with Matlab.
Factory for building line detection information.
void UpdateFactoryManager_Nullspace(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps, RCP< Factory > &nullSpaceFactory) const
void Validate(const Teuchos::ParameterList ¶mList) const
void SetFactoryParameterList(const Teuchos::ParameterList ¶mList)
Factory interpreter stuff.
Factory to export aggregation info or visualize aggregates using VTK.
Prolongator factory which allows switching between two different prolongator strategies.
Interface to Zoltan2 library.This interface provides access to partitioning methods in Zoltan2...
void UpdateFactoryManager_SemiCoarsen(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
AmalgamationFactory for subblocks of strided map based amalgamation data.
Factory for building the constraint operator.
void UpdateFactoryManager_Emin(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
Applies permutation to grid transfer operators.
void SetFactory(const std::string &varName, const RCP< const FactoryBase > &factory)
Set Factory.
const RCP< FactoryBase > GetFactoryNonConst(const std::string &varName)
Get factory associated with a particular data name (NONCONST version)
const RCP< const FactoryBase > GetFactory(const std::string &varName) const
Get factory associated with a particular data name.
Factory for generating a very special nullspace.
static void EnableTimerSync()
void UpdateFactoryManager_Reitzinger(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
void SetupHierarchy(Hierarchy &H) const
Call the SetupHierarchy routine from the HiearchyManager object.
Factory for creating a graph based on a given matrix.
Class that encapsulates Matlab smoothers.
Partitioning within a node onlyThis interface provides partitioning within a node.
Factory for generating F/C-splitting and a coarse level map. Used by ClassicalPFactory.
void UpdateFactoryManager_Coordinates(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
void SetParameterList(const Teuchos::ParameterList ¶mList)
Set parameter list for Parameter list interpreter.
Class for transferring coordinates from a finer level to a coarser one.
void UpdateFactoryManager_LocalOrdinalTransfer(const std::string &VarName, const std::string &multigridAlgo, Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
Factory for building nonzero patterns for energy minimization.
static Teuchos::RCP< Teuchos::ParameterList > GetProblemSpecificList(std::string const &problemType)
Return default parameter settings for the specified problem type.
Factory for building tentative prolongator.
void UpdateFactoryManager_Matlab(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
Class for transferring coordinates from a finer level to a coarser one.
Factory for building restriction operators.
Factory for building Energy Minimization prolongators.
void UpdateFactoryManager_Restriction(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
static bool areSame(const ParameterList &list1, const ParameterList &list2)
Helper functions to compare two paramter lists.
#define TEST_MUTUALLY_EXCLUSIVE_S(arg1, arg2)
static int GetDefaultCycleStartLevel()
void SetProlongatorScalingFactor(double scalingFactor)
Specify damping factor alpha such that x = x + alpha*P*c, where c is the coarse grid correction...
#define MUELU_TEST_PARAM_2LIST(paramList, defaultList, paramName, paramType, cmpValue)
Factory for building coarse matrices.
Exception throws to report errors in the internal logical of the program.
Factory for building filtered matrices using filtered graphs.
std::pair< std::string, const FactoryBase * > keep_pair
Description of what is happening (more verbose)
Factory for building coarse matrices.
Factory for building Petrov-Galerkin Smoothed Aggregation prolongators.
An factory which assigns each aggregate a quality estimate. Originally developed by Napov and Notay i...
Factory for building Smoothed Aggregation prolongators.
Factory for building uncoupled aggregates.
static Teuchos::RCP< const Teuchos::ParameterList > List()
Return a "master" list of all valid parameters and their default values.
Prolongator factory performing semi-coarsening.
#define MUELU_SET_VAR_2LIST(paramList, defaultList, paramName, paramType, varName)
void SetEasyParameterList(const Teuchos::ParameterList ¶mList)
Provides methods to build a multigrid hierarchy and apply multigrid cycles.
Factory for generating nullspace.
long ExtractNonSerializableData(const Teuchos::ParameterList &inList, Teuchos::ParameterList &serialList, Teuchos::ParameterList &nonSerialList)
Extract non-serializable data from level-specific sublists and move it to a separate parameter list...
Exception throws to report invalid user entry.
static const RCP< const NoFactory > getRCP()
Static Get() functions.