46 #ifndef MUELU_PARAMETERLISTINTERPRETER_DEF_HPP 47 #define MUELU_PARAMETERLISTINTERPRETER_DEF_HPP 49 #include <Teuchos_XMLParameterListHelpers.hpp> 51 #include <Xpetra_Matrix.hpp> 59 #include "MueLu_Hierarchy.hpp" 60 #include "MueLu_FactoryManager.hpp" 62 #include "MueLu_AggregationExportFactory.hpp" 63 #include "MueLu_BrickAggregationFactory.hpp" 64 #include "MueLu_CoalesceDropFactory.hpp" 65 #include "MueLu_CoarseMapFactory.hpp" 66 #include "MueLu_ConstraintFactory.hpp" 67 #include "MueLu_CoordinatesTransferFactory.hpp" 68 #include "MueLu_CoupledAggregationFactory.hpp" 69 #include "MueLu_DirectSolver.hpp" 70 #include "MueLu_EminPFactory.hpp" 72 #include "MueLu_FacadeClassFactory.hpp" 73 #include "MueLu_FactoryFactory.hpp" 74 #include "MueLu_FilteredAFactory.hpp" 75 #include "MueLu_GenericRFactory.hpp" 76 #include "MueLu_LineDetectionFactory.hpp" 78 #include "MueLu_NullspaceFactory.hpp" 79 #include "MueLu_PatternFactory.hpp" 80 #include "MueLu_PgPFactory.hpp" 81 #include "MueLu_RAPFactory.hpp" 82 #include "MueLu_RebalanceAcFactory.hpp" 83 #include "MueLu_RebalanceTransferFactory.hpp" 84 #include "MueLu_RepartitionFactory.hpp" 85 #include "MueLu_SaPFactory.hpp" 86 #include "MueLu_SemiCoarsenPFactory.hpp" 87 #include "MueLu_SmootherFactory.hpp" 88 #include "MueLu_TentativePFactory.hpp" 89 #include "MueLu_TogglePFactory.hpp" 90 #include "MueLu_ToggleCoordinatesTransferFactory.hpp" 91 #include "MueLu_TransPFactory.hpp" 92 #include "MueLu_UncoupledAggregationFactory.hpp" 93 #include "MueLu_ZoltanInterface.hpp" 94 #include "MueLu_Zoltan2Interface.hpp" 96 #ifdef HAVE_MUELU_KOKKOS_REFACTOR 97 #include "MueLu_CoalesceDropFactory_kokkos.hpp" 98 #include "MueLu_CoarseMapFactory_kokkos.hpp" 99 #include "MueLu_CoordinatesTransferFactory_kokkos.hpp" 100 #include "MueLu_FilteredAFactory_kokkos.hpp" 101 #include "MueLu_NullspaceFactory_kokkos.hpp" 102 #include "MueLu_SaPFactory_kokkos.hpp" 103 #include "MueLu_TentativePFactory_kokkos.hpp" 104 #include "MueLu_UncoupledAggregationFactory_kokkos.hpp" 107 #ifdef HAVE_MUELU_MATLAB 108 #include "../matlab/src/MueLu_MatlabSmoother_decl.hpp" 109 #include "../matlab/src/MueLu_MatlabSmoother_def.hpp" 110 #include "../matlab/src/MueLu_TwoLevelMatlabFactory_decl.hpp" 111 #include "../matlab/src/MueLu_TwoLevelMatlabFactory_def.hpp" 112 #include "../matlab/src/MueLu_SingleLevelMatlabFactory_decl.hpp" 113 #include "../matlab/src/MueLu_SingleLevelMatlabFactory_def.hpp" 116 #ifdef HAVE_MUELU_INTREPID2 117 #include "MueLu_IntrepidPCoarsenFactory.hpp" 122 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
124 if(facadeFact == Teuchos::null)
125 facadeFact_ = Teuchos::rcp(
new FacadeClassFactory());
127 facadeFact_ = facadeFact;
129 if (paramList.isParameter(
"xml parameter file")) {
130 std::string filename = paramList.get(
"xml parameter file",
"");
131 if (filename.length() != 0) {
132 TEUCHOS_TEST_FOR_EXCEPTION(comm.is_null(), Exceptions::RuntimeError,
"xml parameter file requires a valid comm");
134 ParameterList paramList2 = paramList;
135 Teuchos::updateParametersFromXmlFileAndBroadcast(filename, Teuchos::Ptr<Teuchos::ParameterList>(¶mList2), *comm);
136 SetParameterList(paramList2);
139 SetParameterList(paramList);
143 SetParameterList(paramList);
147 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
149 if(facadeFact == Teuchos::null)
154 ParameterList paramList;
155 Teuchos::updateParametersFromXmlFileAndBroadcast(xmlFileName, Teuchos::Ptr<ParameterList>(¶mList), comm);
159 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
166 if (paramList.isSublist(
"Hierarchy")) {
168 }
else if (paramList.isParameter(
"MueLu preconditioner") ==
true) {
169 this->
GetOStream(
Runtime0) <<
"Use facade class: " << paramList.get<std::string>(
"MueLu preconditioner") << std::endl;
170 Teuchos::RCP<ParameterList> pp =
facadeFact_->SetParameterList(paramList);
176 ParameterList serialList, nonSerialList;
188 static inline bool areSame(
const ParameterList& list1,
const ParameterList& list2);
193 #define MUELU_SET_VAR_2LIST(paramList, defaultList, paramName, paramType, varName) \ 195 if (paramList.isParameter(paramName)) varName = paramList.get<paramType>(paramName); \ 196 else if (defaultList.isParameter(paramName)) varName = defaultList.get<paramType>(paramName); \ 197 else varName = MasterList::getDefault<paramType>(paramName); 199 #define MUELU_TEST_AND_SET_VAR(paramList, paramName, paramType, varName) \ 200 (paramList.isParameter(paramName) ? varName = paramList.get<paramType>(paramName), true : false) 204 #define MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, paramName, paramType, listWrite) \ 206 if (paramList .isParameter(paramName)) listWrite.set(paramName, paramList .get<paramType>(paramName)); \ 207 else if (defaultList.isParameter(paramName)) listWrite.set(paramName, defaultList.get<paramType>(paramName)); \ 209 catch(Teuchos::Exceptions::InvalidParameterType) { \ 210 TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(true, Teuchos::Exceptions::InvalidParameterType, \ 211 "Error: parameter \"" << paramName << "\" must be of type " << Teuchos::TypeNameTraits<paramType>::name()); \ 214 #define MUELU_TEST_PARAM_2LIST(paramList, defaultList, paramName, paramType, cmpValue) \ 216 paramList.isParameter(paramName) ? paramList .get<paramType>(paramName) : ( \ 217 defaultList.isParameter(paramName) ? defaultList.get<paramType>(paramName) : \ 218 MasterList::getDefault<paramType>(paramName) ) ) ) 220 #ifndef HAVE_MUELU_KOKKOS_REFACTOR 221 #define MUELU_KOKKOS_FACTORY(varName, oldFactory, newFactory) \ 222 RCP<Factory> varName = rcp(new oldFactory()); 223 #define MUELU_KOKKOS_FACTORY_NO_DECL(varName, oldFactory, newFactory) \ 224 varName = rcp(new oldFactory()); 226 #define MUELU_KOKKOS_FACTORY(varName, oldFactory, newFactory) \ 227 RCP<Factory> varName; \ 228 if (!useKokkos_) varName = rcp(new oldFactory()); \ 229 else varName = rcp(new newFactory()); 230 #define MUELU_KOKKOS_FACTORY_NO_DECL(varName, oldFactory, newFactory) \ 231 if (!useKokkos_) varName = rcp(new oldFactory()); \ 232 else varName = rcp(new newFactory()); 235 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
237 ParameterList paramList;
239 MUELU_SET_VAR_2LIST(constParamList, constParamList,
"problem: type", std::string, problemType);
240 if (problemType !=
"unknown") {
242 paramList.setParameters(constParamList);
246 paramList = constParamList;
250 MUELU_SET_VAR_2LIST(constParamList,constParamList,
"use kokkos refactor",
bool, useKokkos);
254 if (paramList.isParameter(
"cycle type")) {
255 std::map<std::string,CycleType> cycleMap;
259 std::string cycleType = paramList.get<std::string>(
"cycle type");
260 TEUCHOS_TEST_FOR_EXCEPTION(cycleMap.count(cycleType) == 0,
Exceptions::RuntimeError,
"Invalid cycle type: \"" << cycleType <<
"\"");
261 Cycle_ = cycleMap[cycleType];
264 if (paramList.isParameter(
"coarse grid correction scaling factor")) {
265 scalingFactor_ = paramList.get<
double>(
"coarse grid correction scaling factor");
268 this->
maxCoarseSize_ = paramList.get<
int> (
"coarse: max size", MasterList::getDefault<int>(
"coarse: max size"));
269 this->
numDesiredLevel_ = paramList.get<
int> (
"max levels", MasterList::getDefault<int>(
"max levels"));
270 blockSize_ = paramList.get<
int> (
"number of equations", MasterList::getDefault<int>(
"number of equations"));
275 if (paramList.isSublist(
"export data")) {
276 ParameterList printList = paramList.sublist(
"export data");
278 if (printList.isParameter(
"A"))
279 this->
matricesToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"A");
280 if (printList.isParameter(
"P"))
282 if (printList.isParameter(
"R"))
284 if (printList.isParameter(
"Nullspace"))
285 this->
nullspaceToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"Nullspace");
286 if (printList.isParameter(
"Coordinates"))
287 this->
coordinatesToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"Coordinates");
288 if (printList.isParameter(
"pcoarsen: element to node map"))
295 std::map<std::string,MsgType> verbMap;
296 verbMap[
"none"] =
None;
297 verbMap[
"low"] =
Low;
298 verbMap[
"medium"] =
Medium;
299 verbMap[
"high"] =
High;
301 verbMap[
"test"] =
Test;
306 "Invalid verbosity level: \"" << verbosityLevel <<
"\"");
319 MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"distance laplacian") ||
326 std::string levelStr =
"level " +
toString(levelID);
328 if (paramList.isSublist(levelStr)) {
329 const ParameterList& levelList = paramList.sublist(levelStr);
332 MUELU_TEST_PARAM_2LIST(levelList, paramList,
"aggregation: drop scheme", std::string,
"distance laplacian") ||
353 defaultManager->SetVerbLevel(this->
verbosity_);
356 std::vector<keep_pair> keeps0;
366 RCP<FactoryManager> levelManager = rcp(
new FactoryManager(*defaultManager));
367 levelManager->SetVerbLevel(defaultManager->GetVerbLevel());
369 std::vector<keep_pair> keeps;
370 if (paramList.isSublist(
"level " +
toString(levelID))) {
372 ParameterList& levelList = paramList.sublist(
"level " +
toString(levelID),
true);
376 ParameterList levelList;
380 this->
keep_[levelID] = keeps;
392 ParameterList unusedParamList;
395 for (ParameterList::ConstIterator it = paramList.begin(); it != paramList.end(); it++) {
396 const ParameterEntry& entry = paramList.entry(it);
398 if (!entry.isList() && !entry.isUsed())
399 unusedParamList.setEntry(paramList.name(it), entry);
404 std::string levelStr =
"level " +
toString(levelID);
406 if (paramList.isSublist(levelStr)) {
407 const ParameterList& levelList = paramList.sublist(levelStr);
409 for (ParameterList::ConstIterator itr = levelList.begin(); itr != levelList.end(); ++itr) {
410 const ParameterEntry& entry = levelList.entry(itr);
412 if (!entry.isList() && !entry.isUsed())
413 unusedParamList.sublist(levelStr).setEntry(levelList.name(itr), entry);
418 if (unusedParamList.numParams() > 0) {
419 std::ostringstream unusedParamsStream;
421 unusedParamList.print(unusedParamsStream, indent);
423 this->
GetOStream(
Warnings1) <<
"The following parameters were not used:\n" << unusedParamsStream.str() << std::endl;
434 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
436 const ParameterList& defaultList,
FactoryManager& manager,
int levelID, std::vector<keep_pair>& keeps)
const {
441 if (paramList.numParams() == 0 && defaultList.numParams() > 0)
442 paramList = ParameterList(defaultList);
445 TEUCHOS_TEST_FOR_EXCEPTION(reuseType !=
"none" && reuseType !=
"tP" && reuseType !=
"RP" && reuseType !=
"emin" && reuseType !=
"RAP" && reuseType !=
"full" && reuseType !=
"S",
448 MUELU_SET_VAR_2LIST(paramList, defaultList,
"multigrid algorithm", std::string, multigridAlgo);
449 TEUCHOS_TEST_FOR_EXCEPTION(multigridAlgo !=
"unsmoothed" && multigridAlgo !=
"sa" && multigridAlgo !=
"pg" && multigridAlgo !=
"emin" && multigridAlgo !=
"matlab" && multigridAlgo !=
"pcoarsen",
450 Exceptions::RuntimeError,
"Unknown \"multigrid algorithm\" value: \"" << multigridAlgo <<
"\". Please consult User's Guide.");
451 #ifndef HAVE_MUELU_MATLAB 453 "Cannot use matlab for multigrid algorithm - MueLu was not configured with MATLAB support.");
455 #ifndef HAVE_MUELU_INTREPID2 457 "Cannot use IntrepidPCoarsen prolongator factory - MueLu was not configured with Intrepid support.");
462 if (reuseType ==
"none" || reuseType ==
"S" || reuseType ==
"RP" || reuseType ==
"RAP") {
465 }
else if (reuseType ==
"tP" && (multigridAlgo !=
"sa" && multigridAlgo !=
"unsmoothed")) {
467 this->
GetOStream(
Warnings0) <<
"Ignoring \"tP\" reuse option as it is only compatible with \"sa\", or \"unsmoothed\" multigrid algorithms" << std::endl;
469 }
else if (reuseType ==
"emin" && multigridAlgo !=
"emin") {
471 this->
GetOStream(
Warnings0) <<
"Ignoring \"emin\" reuse option it is only compatible with \"emin\" multigrid algorithm" << std::endl;
476 bool have_userP =
false;
477 if (paramList.isParameter(
"P") && !paramList.get<RCP<Matrix> > (
"P") .is_null()) have_userP =
true;
489 RCP<Factory> nullSpaceFactory;
495 TEUCHOS_TEST_FOR_EXCEPTION(multigridAlgo !=
"unsmoothed" && multigridAlgo !=
"sa" && multigridAlgo !=
"pg" && multigridAlgo !=
"emin" && multigridAlgo !=
"matlab" 496 && multigridAlgo !=
"pcoarsen",
Exceptions::RuntimeError,
"Unknown multigrid algorithm: \"" << multigridAlgo <<
"\". Please consult User's Guide.");
497 #ifndef HAVE_MUELU_MATLAB 499 "Cannot use MATLAB prolongator factory - MueLu was not configured with MATLAB support.");
501 #ifndef HAVE_MUELU_INTREPID2 503 "Cannot use IntrepidPCoarsen prolongator factory - MueLu was not configured with Intrepid support.");
508 }
else if (multigridAlgo ==
"unsmoothed") {
511 }
else if (multigridAlgo ==
"sa") {
514 }
else if (multigridAlgo ==
"emin") {
517 }
else if (multigridAlgo ==
"pg") {
520 }
else if(multigridAlgo ==
"matlab") {
523 }
else if(multigridAlgo ==
"pcoarsen") {
541 if ((reuseType ==
"RP" || reuseType ==
"RAP" || reuseType ==
"full") && levelID)
544 if (reuseType ==
"RP" && levelID) {
549 if ((reuseType ==
"tP" || reuseType ==
"RP" || reuseType ==
"emin") &&
useCoordinates_ && levelID)
556 if ((reuseType ==
"RAP" || reuseType ==
"full") && levelID) {
568 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
571 MUELU_SET_VAR_2LIST(paramList, defaultList,
"multigrid algorithm", std::string, multigridAlgo);
576 bool isCustomSmoother =
577 paramList.isParameter(
"smoother: pre or post") ||
578 paramList.isParameter(
"smoother: type") || paramList.isParameter(
"smoother: pre type") || paramList.isParameter(
"smoother: post type") ||
579 paramList.isSublist (
"smoother: params") || paramList.isSublist (
"smoother: pre params") || paramList.isSublist (
"smoother: post params") ||
580 paramList.isParameter(
"smoother: sweeps") || paramList.isParameter(
"smoother: pre sweeps") || paramList.isParameter(
"smoother: post sweeps") ||
581 paramList.isParameter(
"smoother: overlap") || paramList.isParameter(
"smoother: pre overlap") || paramList.isParameter(
"smoother: post overlap");
584 manager.
SetFactory(
"Smoother", Teuchos::null);
586 }
else if (isCustomSmoother) {
590 #define TEST_MUTUALLY_EXCLUSIVE(arg1,arg2) \ 591 TEUCHOS_TEST_FOR_EXCEPTION(paramList.isParameter(#arg1) && paramList.isParameter(#arg2), \ 592 Exceptions::InvalidArgument, "You cannot specify both \""#arg1"\" and \""#arg2"\""); 593 #define TEST_MUTUALLY_EXCLUSIVE_S(arg1,arg2) \ 594 TEUCHOS_TEST_FOR_EXCEPTION(paramList.isSublist(#arg1) && paramList.isSublist(#arg2), \ 595 Exceptions::InvalidArgument, "You cannot specify both \""#arg1"\" and \""#arg2"\""); 605 TEUCHOS_TEST_FOR_EXCEPTION(
PreOrPost ==
"both" && (paramList.isParameter(
"smoother: pre type") != paramList.isParameter(
"smoother: post type")),
610 ParameterList defaultSmootherParams;
611 defaultSmootherParams.set(
"relaxation: type",
"Symmetric Gauss-Seidel");
612 defaultSmootherParams.set(
"relaxation: sweeps", Teuchos::OrdinalTraits<LO>::one());
613 defaultSmootherParams.set(
"relaxation: damping factor", Teuchos::ScalarTraits<Scalar>::one());
615 RCP<SmootherFactory> preSmoother = Teuchos::null, postSmoother = Teuchos::null;
616 std::string preSmootherType, postSmootherType;
617 ParameterList preSmootherParams, postSmootherParams;
619 if (paramList.isParameter(
"smoother: overlap"))
620 overlap = paramList.get<
int>(
"smoother: overlap");
623 if (paramList.isParameter(
"smoother: pre type")) {
624 preSmootherType = paramList.get<std::string>(
"smoother: pre type");
626 MUELU_SET_VAR_2LIST(paramList, defaultList,
"smoother: type", std::string, preSmootherTypeTmp);
627 preSmootherType = preSmootherTypeTmp;
629 if (paramList.isParameter(
"smoother: pre overlap"))
630 overlap = paramList.get<
int>(
"smoother: pre overlap");
632 if (paramList.isSublist(
"smoother: pre params"))
633 preSmootherParams = paramList.sublist(
"smoother: pre params");
634 else if (paramList.isSublist(
"smoother: params"))
635 preSmootherParams = paramList.sublist(
"smoother: params");
636 else if (defaultList.isSublist(
"smoother: params"))
637 preSmootherParams = defaultList.sublist(
"smoother: params");
638 else if (preSmootherType ==
"RELAXATION")
639 preSmootherParams = defaultSmootherParams;
641 #ifdef HAVE_MUELU_INTREPID2 643 if(multigridAlgo ==
"pcoarsen" && preSmootherType ==
"TOPOLOGICAL" && defaultList.isParameter(
"pcoarsen: schedule") && defaultList.isParameter(
"pcoarsen: element")){
646 Teuchos::Array<int> pcoarsen_schedule = Teuchos::getArrayFromStringParameter<int>(defaultList,
"pcoarsen: schedule");
647 std::string pcoarsen_element = defaultList.get<std::string>(
"pcoarsen: element");
649 if(levelID < (
int)pcoarsen_schedule.size()) {
651 std::string lo = pcoarsen_element + std::to_string(pcoarsen_schedule[levelID]);
652 preSmootherParams.set(
"pcoarsen: hi basis",lo);
657 #ifdef HAVE_MUELU_MATLAB 658 if(preSmootherType ==
"matlab")
666 if (paramList.isParameter(
"smoother: post type"))
667 postSmootherType = paramList.get<std::string>(
"smoother: post type");
669 MUELU_SET_VAR_2LIST(paramList, defaultList,
"smoother: type", std::string, postSmootherTypeTmp);
670 postSmootherType = postSmootherTypeTmp;
673 if (paramList.isSublist(
"smoother: post params"))
674 postSmootherParams = paramList.sublist(
"smoother: post params");
675 else if (paramList.isSublist(
"smoother: params"))
676 postSmootherParams = paramList.sublist(
"smoother: params");
677 else if (defaultList.isSublist(
"smoother: params"))
678 postSmootherParams = defaultList.sublist(
"smoother: params");
679 else if (postSmootherType ==
"RELAXATION")
680 postSmootherParams = defaultSmootherParams;
681 if (paramList.isParameter(
"smoother: post overlap"))
682 overlap = paramList.get<
int>(
"smoother: post overlap");
684 if (postSmootherType == preSmootherType &&
areSame(preSmootherParams, postSmootherParams))
685 postSmoother = preSmoother;
688 #ifdef HAVE_MUELU_INTREPID2 690 if(multigridAlgo ==
"pcoarsen" && preSmootherType ==
"TOPOLOGICAL" && defaultList.isParameter(
"pcoarsen: schedule") && defaultList.isParameter(
"pcoarsen: element")){
693 Teuchos::Array<int> pcoarsen_schedule = Teuchos::getArrayFromStringParameter<int>(defaultList,
"pcoarsen: schedule");
694 std::string pcoarsen_element = defaultList.get<std::string>(
"pcoarsen: element");
696 if(levelID < (
int)pcoarsen_schedule.size()) {
698 std::string lo = pcoarsen_element + std::to_string(pcoarsen_schedule[levelID]);
699 postSmootherParams.set(
"pcoarsen: hi basis",lo);
704 #ifdef HAVE_MUELU_MATLAB 705 if(postSmootherType ==
"matlab")
714 if (preSmoother == postSmoother)
717 manager.
SetFactory(
"PreSmoother", preSmoother);
718 manager.
SetFactory(
"PostSmoother", postSmoother);
725 bool reuseSmoothers = (reuseType ==
"S" || reuseType !=
"none");
726 if (reuseSmoothers) {
727 RCP<Factory> preSmootherFactory = Teuchos::rcp_const_cast<
Factory>(Teuchos::rcp_dynamic_cast<
const Factory>(manager.
GetFactory(
"PreSmoother")));
728 if (preSmootherFactory != Teuchos::null) {
729 ParameterList postSmootherFactoryParams;
730 postSmootherFactoryParams.set(
"keep smoother data",
true);
731 preSmootherFactory->SetParameterList(postSmootherFactoryParams);
733 keeps.push_back(
keep_pair(
"PreSmoother data", preSmootherFactory.get()));
736 RCP<Factory> postSmootherFactory = Teuchos::rcp_const_cast<Factory>(Teuchos::rcp_dynamic_cast<
const Factory>(manager.
GetFactory(
"PostSmoother")));
737 if (postSmootherFactory != Teuchos::null) {
738 ParameterList postSmootherFactoryParams;
739 postSmootherFactoryParams.set(
"keep smoother data",
true);
740 postSmootherFactory->SetParameterList(postSmootherFactoryParams);
742 keeps.push_back(
keep_pair(
"PostSmoother data", postSmootherFactory.get()));
745 RCP<Factory> coarseFactory = Teuchos::rcp_const_cast<Factory>(Teuchos::rcp_dynamic_cast<
const Factory>(manager.
GetFactory(
"CoarseSolver")));
746 if (coarseFactory != Teuchos::null) {
747 ParameterList coarseFactoryParams;
748 coarseFactoryParams.set(
"keep smoother data",
true);
749 coarseFactory->SetParameterList(coarseFactoryParams);
751 keeps.push_back(
keep_pair(
"PreSmoother data", coarseFactory.get()));
755 if ((reuseType ==
"RAP" && levelID) || (reuseType ==
"full")) {
776 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
779 bool isCustomCoarseSolver =
780 paramList.isParameter(
"coarse: type") ||
781 paramList.isParameter(
"coarse: params");
784 manager.
SetFactory(
"CoarseSolver", Teuchos::null);
786 }
else if (isCustomCoarseSolver) {
793 if (paramList.isParameter(
"coarse: overlap"))
794 overlap = paramList.get<
int>(
"coarse: overlap");
796 ParameterList coarseParams;
797 if (paramList.isSublist(
"coarse: params"))
798 coarseParams = paramList.sublist(
"coarse: params");
799 else if (defaultList.isSublist(
"coarse: params"))
800 coarseParams = defaultList.sublist(
"coarse: params");
802 RCP<SmootherPrototype> coarseSmoother;
806 if (coarseType ==
"RELAXATION" || coarseType ==
"CHEBYSHEV" ||
807 coarseType ==
"ILUT" || coarseType ==
"ILU" || coarseType ==
"RILUK" || coarseType ==
"SCHWARZ" ||
808 coarseType ==
"Amesos" ||
809 coarseType ==
"BLOCK RELAXATION" || coarseType ==
"BLOCK_RELAXATION" || coarseType ==
"BLOCKRELAXATION" ||
810 coarseType ==
"SPARSE BLOCK RELAXATION" || coarseType ==
"SPARSE_BLOCK_RELAXATION" || coarseType ==
"SPARSEBLOCKRELAXATION" ||
811 coarseType ==
"LINESMOOTHING_BANDEDRELAXATION" || coarseType ==
"LINESMOOTHING_BANDED_RELAXATION" || coarseType ==
"LINESMOOTHING_BANDED RELAXATION" ||
812 coarseType ==
"TOPOLOGICAL")
813 coarseSmoother = rcp(
new TrilinosSmoother(coarseType, coarseParams, overlap));
815 #ifdef HAVE_MUELU_MATLAB 816 if (coarseType ==
"matlab")
820 coarseSmoother = rcp(
new DirectSolver(coarseType, coarseParams));
830 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
835 RCP<Factory> dropFactory;
838 #ifdef HAVE_MUELU_MATLAB 840 ParameterList socParams = paramList.sublist(
"strength-of-connection: params");
841 dropFactory->SetParameterList(socParams);
843 throw std::runtime_error(
"Cannot use MATLAB evolutionary strength-of-connection - MueLu was not configured with MATLAB support.");
847 ParameterList dropParams;
848 dropParams.set(
"lightweight wrap",
true);
852 dropFactory->SetParameterList(dropParams);
858 TEUCHOS_TEST_FOR_EXCEPTION(aggType !=
"uncoupled" && aggType !=
"coupled" && aggType !=
"brick" && aggType !=
"matlab",
860 #ifndef HAVE_MUELU_MATLAB 861 if(aggType ==
"matlab")
862 throw std::runtime_error(
"Cannot use MATLAB aggregation - MueLu was not configured with MATLAB support.");
864 RCP<Factory> aggFactory;
865 if (aggType ==
"uncoupled") {
867 ParameterList aggParams;
879 aggFactory->SetParameterList(aggParams);
881 aggFactory->SetFactory(
"DofsPerNode", manager.
GetFactory(
"Graph"));
882 aggFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
883 }
else if (aggType ==
"coupled") {
885 aggFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
886 }
else if (aggType ==
"brick") {
888 ParameterList aggParams;
892 aggFactory->SetParameterList(aggParams);
897 aggFactory->SetFactory(
"Coordinates", this->
GetFactoryManager(levelID-1)->GetFactory(
"Coordinates"));
900 #ifdef HAVE_MUELU_MATLAB 901 else if(aggType ==
"matlab") {
902 ParameterList aggParams = paramList.sublist(
"aggregation: params");
904 aggFactory->SetParameterList(aggParams);
911 coarseMap->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
916 ParameterList ptentParams;
917 if(paramList.isSublist(
"matrixmatrix: kernel params")) ptentParams.sublist(
"matrixmatrix: kernel params",
false)=paramList.sublist(
"matrixmatrix: kernel params");
918 if(defaultList.isSublist(
"matrixmatrix: kernel params")) ptentParams.sublist(
"matrixmatrix: kernel params",
false)=defaultList.sublist(
"matrixmatrix: kernel params");
920 Ptent->SetParameterList(ptentParams);
921 Ptent->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
922 Ptent->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
925 if (reuseType ==
"tP" && levelID) {
926 keeps.push_back(
keep_pair(
"Nullspace", Ptent.get()));
927 keeps.push_back(
keep_pair(
"P", Ptent.get()));
934 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
936 bool have_userA =
false;
937 if (paramList.isParameter(
"A") && !paramList.get<RCP<Matrix> > (
"A") .is_null()) have_userA =
true;
938 MUELU_SET_VAR_2LIST(paramList, defaultList,
"sa: use filtered matrix",
bool, useFiltering);
939 bool filteringChangesMatrix = useFiltering && !
MUELU_TEST_PARAM_2LIST(paramList, defaultList,
"aggregation: drop tol",
double, 0);
949 ParameterList RAPparams;
950 if(paramList.isSublist(
"matrixmatrix: kernel params")) RAPparams.sublist(
"matrixmatrix: kernel params",
false)=paramList.sublist(
"matrixmatrix: kernel params");
951 if(defaultList.isSublist(
"matrixmatrix: kernel params")) RAPparams.sublist(
"matrixmatrix: kernel params",
false)=defaultList.sublist(
"matrixmatrix: kernel params");
956 if (paramList .isParameter(
"aggregation: allow empty prolongator columns")) {
957 RAPparams.set(
"CheckMainDiagonal", paramList.get<
bool>(
"aggregation: allow empty prolongator columns"));
958 RAPparams.set(
"RepairMainDiagonal", paramList.get<
bool>(
"aggregation: allow empty prolongator columns"));
960 else if (defaultList.isParameter(
"aggregation: allow empty prolongator columns")) {
961 RAPparams.set(
"CheckMainDiagonal", defaultList.get<
bool>(
"aggregation: allow empty prolongator columns"));
962 RAPparams.set(
"RepairMainDiagonal", defaultList.get<
bool>(
"aggregation: allow empty prolongator columns"));
965 catch(Teuchos::Exceptions::InvalidParameterType) {
966 TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(
true, Teuchos::Exceptions::InvalidParameterType,
967 "Error: parameter \"aggregation: allow empty prolongator columns\" must be of type " << Teuchos::TypeNameTraits<bool>::name());
970 RAP->SetParameterList(RAPparams);
971 RAP->SetFactory(
"P", manager.
GetFactory(
"P"));
973 RAP->SetFactory(
"R", manager.
GetFactory(
"R"));
975 if (
MUELU_TEST_PARAM_2LIST(paramList, defaultList,
"aggregation: export visualization data",
bool,
true)) {
977 ParameterList aggExportParams;
985 aggExport->SetParameterList(aggExportParams);
986 aggExport->SetFactory(
"DofsPerNode", manager.
GetFactory(
"DofsPerNode"));
987 RAP->AddTransferFactory(aggExport);
991 if (reuseType ==
"RP" || (reuseType ==
"tP" && !filteringChangesMatrix)) {
992 keeps.push_back(
keep_pair(
"AP reuse data", RAP.get()));
993 keeps.push_back(
keep_pair(
"RAP reuse data", RAP.get()));
1001 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1003 bool have_userCO=
false;
1004 if (paramList.isParameter(
"Coordinates") && !paramList.get<RCP<MultiVector> >(
"Coordinates").is_null()) have_userCO =
true;
1012 coords->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1013 coords->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1017 RAP->AddTransferFactory(manager.
GetFactory(
"Coordinates"));
1025 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1027 MUELU_SET_VAR_2LIST(paramList, defaultList,
"multigrid algorithm", std::string, multigridAlgo);
1028 bool have_userR=
false;
1029 if (paramList.isParameter(
"R") && !paramList.get<RCP<Matrix> > (
"R") .is_null()) have_userR =
true;
1033 if (isSymmetric ==
false && (multigridAlgo ==
"unsmoothed" || multigridAlgo ==
"emin")) {
1034 this->
GetOStream(
Warnings0) <<
"Switching \"problem: symmetric\" parameter to symmetric as multigrid algorithm. " << multigridAlgo <<
" is primarily supposed to be used for symmetric problems." << std::endl << std::endl;
1035 this->
GetOStream(
Warnings0) <<
"Please note: if you are using \"unsmoothed\" transfer operators the \"problem: symmetric\" parameter has no real mathematical meaning, i.e. you can use it for non-symmetric" << std::endl;
1036 this->
GetOStream(
Warnings0) <<
"problems, too. With \"problem: symmetric\"=\"symmetric\" you can use implicit transpose for building the restriction operators which may drastically reduce the amount of consumed memory." << std::endl;
1040 "Petrov-Galerkin smoothed transfer operators are only allowed for non-symmetric problems: Set \"problem: symmetric\" to false!\n" \
1041 "While PG smoothed transfer operators generally would also work for symmetric problems this is an unusual use case. " \
1042 "You can use the factory-based xml interface though if you need PG-AMG for symmetric problems.");
1063 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1106 "Reuse types \"tP\" and \"PR\" require \"repartition: rebalance P and R\" set to \"false\"");
1111 MUELU_SET_VAR_2LIST(paramList, defaultList,
"repartition: partitioner", std::string, partName);
1113 "Invalid partitioner name: \"" << partName <<
"\". Valid options: \"zoltan\", \"zoltan2\"");
1117 ParameterList repartheurParams;
1121 repartheurFactory->SetParameterList(repartheurParams);
1122 repartheurFactory->SetFactory(
"A", manager.
GetFactory(
"A"));
1123 manager.
SetFactory(
"number of partitions", repartheurFactory);
1126 RCP<Factory> partitioner;
1127 if (partName ==
"zoltan") {
1128 #ifdef HAVE_MUELU_ZOLTAN 1134 }
else if (partName ==
"zoltan2") {
1135 #ifdef HAVE_MUELU_ZOLTAN2 1137 ParameterList partParams;
1138 RCP<const ParameterList> partpartParams = rcp(
new ParameterList(paramList.sublist(
"repartition: params",
false)));
1139 partParams.set(
"ParameterList", partpartParams);
1140 partitioner->SetParameterList(partParams);
1145 partitioner->SetFactory(
"A", manager.
GetFactory(
"A"));
1146 partitioner->SetFactory(
"number of partitions", manager.
GetFactory(
"number of partitions"));
1147 partitioner->SetFactory(
"Coordinates", manager.
GetFactory(
"Coordinates"));
1148 manager.
SetFactory(
"Partition", partitioner);
1152 ParameterList repartParams;
1156 repartFactory->SetParameterList(repartParams);
1157 repartFactory->SetFactory(
"A", manager.
GetFactory(
"A"));
1158 repartFactory->SetFactory(
"number of partitions", manager.
GetFactory(
"number of partitions"));
1159 repartFactory->SetFactory(
"Partition", manager.
GetFactory(
"Partition"));
1160 manager.
SetFactory(
"Importer", repartFactory);
1161 if (reuseType !=
"none" && reuseType !=
"S" && levelID)
1166 ParameterList rebAcParams;
1168 newA->SetParameterList(rebAcParams);
1169 newA->SetFactory(
"A", manager.
GetFactory(
"A"));
1170 newA->SetFactory(
"Importer", manager.
GetFactory(
"Importer"));
1175 ParameterList newPparams;
1176 newPparams.set(
"type",
"Interpolation");
1178 newPparams.set(
"repartition: rebalance P and R", this->
doPRrebalance_);
1181 newP-> SetFactory(
"Importer", manager.
GetFactory(
"Importer"));
1182 newP-> SetFactory(
"P", manager.
GetFactory(
"P"));
1183 if (!paramList.isParameter(
"semicoarsen: number of levels"))
1184 newP-> SetFactory(
"Nullspace", manager.
GetFactory(
"Ptent"));
1186 newP-> SetFactory(
"Nullspace", manager.
GetFactory(
"P"));
1187 newP-> SetFactory(
"Coordinates", manager.
GetFactory(
"Coordinates"));
1193 ParameterList newRparams;
1194 newRparams.set(
"type",
"Restriction");
1197 newRparams.set(
"repartition: rebalance P and R", this->
doPRrebalance_);
1201 newR-> SetFactory(
"Importer", manager.
GetFactory(
"Importer"));
1203 newR->SetFactory(
"R", manager.
GetFactory(
"R"));
1214 nullSpaceFactory->SetFactory(
"Nullspace", newP);
1221 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1225 bool have_userNS =
false;
1226 if (paramList.isParameter(
"Nullspace") && !paramList.get<RCP<MultiVector> >(
"Nullspace") .is_null()) have_userNS =
true;
1228 nullSpace->SetFactory(
"Nullspace", manager.
GetFactory(
"Ptent"));
1231 nullSpaceFactory = nullSpace;
1238 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1242 RCP<SemiCoarsenPFactory> semicoarsenFactory = Teuchos::null;
1243 if (paramList.isParameter(
"semicoarsen: number of levels") &&
1244 paramList.get<
int>(
"semicoarsen: number of levels") > 0) {
1246 ParameterList togglePParams;
1247 ParameterList semicoarsenPParams;
1248 ParameterList linedetectionParams;
1258 linedetectionFactory->SetParameterList(linedetectionParams);
1259 semicoarsenFactory->SetParameterList(semicoarsenPParams);
1260 togglePFactory->SetParameterList(togglePParams);
1261 togglePFactory->AddCoarseNullspaceFactory(semicoarsenFactory);
1262 togglePFactory->AddProlongatorFactory(semicoarsenFactory);
1263 togglePFactory->AddPtentFactory(semicoarsenFactory);
1264 togglePFactory->AddCoarseNullspaceFactory(manager.
GetFactory(
"Ptent"));
1265 togglePFactory->AddProlongatorFactory(manager.
GetFactory(
"P"));
1266 togglePFactory->AddPtentFactory(manager.
GetFactory(
"Ptent"));
1268 manager.
SetFactory(
"CoarseNumZLayers", linedetectionFactory);
1269 manager.
SetFactory(
"LineDetection_Layers", linedetectionFactory);
1270 manager.
SetFactory(
"LineDetection_VertLineIds", linedetectionFactory);
1274 manager.
SetFactory(
"Nullspace", togglePFactory);
1278 if (paramList.isParameter(
"semicoarsen: number of levels")) {
1280 tf->SetFactory(
"Chosen P", manager.
GetFactory(
"P"));
1281 tf->AddCoordTransferFactory(semicoarsenFactory);
1283 coords->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1284 coords->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1285 tf->AddCoordTransferFactory(coords);
1294 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1296 #ifdef HAVE_MUELU_INTREPID2 1298 if(defaultList.isParameter(
"pcoarsen: schedule") && defaultList.isParameter(
"pcoarsen: element")){
1301 Teuchos::Array<int> pcoarsen_schedule = Teuchos::getArrayFromStringParameter<int>(defaultList,
"pcoarsen: schedule");
1302 std::string pcoarsen_element = defaultList.get<std::string>(
"pcoarsen: element");
1304 if(levelID >= (
int)pcoarsen_schedule.size()) {
1311 ParameterList Pparams;
1314 std::string lo = pcoarsen_element + std::to_string(pcoarsen_schedule[levelID]);
1315 if(levelID!=0) hi = pcoarsen_element + std::to_string(pcoarsen_schedule[levelID-1]);
1317 Pparams.set(
"pcoarsen: hi basis",hi);
1318 Pparams.set(
"pcoarsen: lo basis",lo);
1319 P->SetParameterList(Pparams);
1327 ParameterList Pparams;
1331 P->SetParameterList(Pparams);
1344 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1346 MUELU_SET_VAR_2LIST(paramList, defaultList,
"sa: use filtered matrix",
bool, useFiltering);
1348 bool filteringChangesMatrix = useFiltering && !
MUELU_TEST_PARAM_2LIST(paramList, defaultList,
"aggregation: drop tol",
double, 0);
1352 ParameterList Pparams;
1353 if(paramList.isSublist(
"matrixmatrix: kernel params")) Pparams.sublist(
"matrixmatrix: kernel params",
false)=paramList.sublist(
"matrixmatrix: kernel params");
1354 if(defaultList.isSublist(
"matrixmatrix: kernel params")) Pparams.sublist(
"matrixmatrix: kernel params",
false)=defaultList.sublist(
"matrixmatrix: kernel params");
1356 P->SetParameterList(Pparams);
1361 ParameterList fParams;
1365 filterFactory->SetParameterList(fParams);
1366 filterFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1368 filterFactory->SetFactory(
"Filtering", manager.
GetFactory(
"Graph"));
1369 P->SetFactory(
"A", filterFactory);
1372 P->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
1375 if (reuseType ==
"tP" && !filteringChangesMatrix)
1376 keeps.push_back(
keep_pair(
"AP reuse data", P.get()));
1382 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1387 "Invalid pattern name: \"" << patternType <<
"\". Valid options: \"AkPtent\"");
1390 ParameterList patternParams;
1392 patternFactory->SetParameterList(patternParams);
1393 patternFactory->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
1394 manager.
SetFactory(
"Ppattern", patternFactory);
1398 constraintFactory->SetFactory(
"Ppattern", manager.
GetFactory(
"Ppattern"));
1399 constraintFactory->SetFactory(
"CoarseNullspace", manager.
GetFactory(
"Ptent"));
1400 manager.
SetFactory(
"Constraint", constraintFactory);
1404 ParameterList Pparams;
1407 if (reuseType ==
"emin") {
1409 Pparams.set(
"Keep P0",
true);
1410 Pparams.set(
"Keep Constraint0",
true);
1412 P->SetParameterList(Pparams);
1413 P->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
1414 P->SetFactory(
"Constraint", manager.
GetFactory(
"Constraint"));
1421 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1424 "Implicit transpose not supported with Petrov-Galerkin smoothed transfer operators: Set \"transpose: use implicit\" to false!\n" \
1425 "Petrov-Galerkin transfer operator smoothing for non-symmetric problems requires a separate handling of the restriction operator which " \
1426 "does not allow the usage of implicit transpose easily.");
1430 P->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
1438 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1440 #ifdef HAVE_MUELU_MATLAB 1441 ParameterList Pparams = paramList.sublist(
"transfer: params");
1443 P->SetParameterList(Pparams);
1444 P->SetFactory(
"P",manager.
GetFactory(
"Ptent"));
1451 #undef MUELU_SET_VAR_2LIST 1452 #undef MUELU_TEST_AND_SET_VAR 1453 #undef MUELU_TEST_AND_SET_PARAM_2LIST 1454 #undef MUELU_TEST_PARAM_2LIST 1458 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1460 ParameterList paramList = constParamList;
1463 const int maxLevels = 100;
1466 std::vector<ParameterList> paramLists;
1467 for (
int levelID = 0; levelID < maxLevels; levelID++) {
1468 std::string sublistName =
"level " +
toString(levelID);
1469 if (paramList.isSublist(sublistName)) {
1470 paramLists.push_back(paramList.sublist(sublistName));
1472 paramList.remove(sublistName);
1475 paramLists.push_back(paramList);
1478 #ifdef HAVE_MUELU_MATLAB 1479 for (
size_t i = 0; i < paramLists.size(); i++) {
1480 std::vector<std::string> customVars;
1482 for(Teuchos::ParameterList::ConstIterator it = paramLists[i].begin(); it != paramLists[i].end(); it++) {
1483 std::string paramName = paramLists[i].name(it);
1486 customVars.push_back(paramName);
1490 for (
size_t j = 0; j < customVars.size(); j++)
1491 paramLists[i].
remove(customVars[j],
false);
1495 const int maxDepth = 0;
1496 for (
size_t i = 0; i < paramLists.size(); i++) {
1499 paramLists[i].validateParameters(validList, maxDepth);
1501 }
catch (
const Teuchos::Exceptions::InvalidParameterName& e) {
1502 std::string eString = e.what();
1505 size_t nameStart = eString.find_first_of(
'"') + 1;
1506 size_t nameEnd = eString.find_first_of(
'"', nameStart);
1507 std::string name = eString.substr(nameStart, nameEnd - nameStart);
1509 int bestScore = 100;
1510 std::string bestName =
"";
1511 for (ParameterList::ConstIterator it = validList.begin(); it != validList.end(); it++) {
1512 const std::string& pName = validList.name(it);
1514 int score =
LevenshteinDistance(name.c_str(), name.length(), pName.c_str(), pName.length());
1516 if (score < bestScore) {
1521 if (bestScore < 10 && bestName !=
"") {
1522 TEUCHOS_TEST_FOR_EXCEPTION(
true, Teuchos::Exceptions::InvalidParameterName,
1523 eString <<
"The parameter name \"" + name +
"\" is not valid. Did you mean \"" + bestName <<
"\"?\n");
1526 TEUCHOS_TEST_FOR_EXCEPTION(
true, Teuchos::Exceptions::InvalidParameterName,
1527 eString <<
"The parameter name \"" + name +
"\" is not valid.\n");
1536 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1540 ParameterList paramList = constParamList;
1547 if (paramList.isSublist(
"Matrix")) {
1548 blockSize_ = paramList.sublist(
"Matrix").get<
int>(
"PDE equations", MasterList::getDefault<int>(
"number of equations"));
1549 dofOffset_ = paramList.sublist(
"Matrix").get<GlobalOrdinal>(
"DOF offset", 0);
1565 if (paramList.isSublist(
"Factories"))
1566 this->
BuildFactoryMap(paramList.sublist(
"Factories"), factoryMap, factoryMap, factoryManagers);
1580 if (paramList.isSublist(
"Hierarchy")) {
1581 ParameterList hieraList = paramList.sublist(
"Hierarchy");
1584 if (hieraList.isParameter(
"max levels")) {
1586 hieraList.remove(
"max levels");
1589 if (hieraList.isParameter(
"coarse: max size")) {
1591 hieraList.remove(
"coarse: max size");
1594 if (hieraList.isParameter(
"repartition: rebalance P and R")) {
1595 this->
doPRrebalance_ = hieraList.get<
bool>(
"repartition: rebalance P and R");
1596 hieraList.remove(
"repartition: rebalance P and R");
1599 if (hieraList.isParameter(
"transpose: use implicit")) {
1601 hieraList.remove(
"transpose: use implicit");
1604 if (hieraList.isParameter(
"coarse grid correction scaling factor")) {
1605 this->
scalingFactor_ = hieraList.get<
double>(
"coarse grid correction scaling factor");
1606 hieraList.remove(
"coarse grid correction scaling factor");
1610 if (hieraList.isParameter(
"cycle type")) {
1611 std::map<std::string,CycleType> cycleMap;
1615 std::string cycleType = hieraList.get<std::string>(
"cycle type");
1616 TEUCHOS_TEST_FOR_EXCEPTION(cycleMap.count(cycleType) == 0,
Exceptions::RuntimeError,
"Invalid cycle type: \"" << cycleType <<
"\"");
1617 this->
Cycle_ = cycleMap[cycleType];
1621 std::map<std::string,MsgType> verbMap;
1623 verbMap[
"Errors"] =
Errors;
1640 verbMap[
"Debug"] =
Debug;
1641 verbMap[
"Test"] =
Test;
1643 verbMap[
"None"] =
None;
1644 verbMap[
"Low"] =
Low;
1645 verbMap[
"Medium"] =
Medium;
1646 verbMap[
"High"] =
High;
1648 if (hieraList.isParameter(
"verbosity")) {
1649 std::string vl = hieraList.get<std::string>(
"verbosity");
1650 hieraList.remove(
"verbosity");
1652 if (verbMap.find(vl) != verbMap.end())
1655 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::ParameterListInterpreter():: invalid verbosity level");
1658 if (hieraList.isParameter(
"dependencyOutputLevel"))
1662 if (hieraList.isParameter(
"reuse"))
1665 if (hieraList.isSublist(
"DataToWrite")) {
1668 ParameterList foo = hieraList.sublist(
"DataToWrite");
1669 std::string dataName =
"Matrices";
1670 if (foo.isParameter(dataName))
1671 this->
matricesToPrint_ = Teuchos::getArrayFromStringParameter<int>(foo,dataName);
1672 dataName =
"Prolongators";
1673 if (foo.isParameter(dataName))
1675 dataName =
"Restrictors";
1676 if (foo.isParameter(dataName))
1681 for (ParameterList::ConstIterator param = hieraList.begin(); param != hieraList.end(); ++param) {
1682 const std::string & paramName = hieraList.name(param);
1684 if (paramName !=
"DataToWrite" && hieraList.isSublist(paramName)) {
1685 ParameterList levelList = hieraList.sublist(paramName);
1687 int startLevel = 0;
if(levelList.isParameter(
"startLevel")) { startLevel = levelList.get<
int>(
"startLevel"); levelList.remove(
"startLevel"); }
1688 int numDesiredLevel = 1;
if(levelList.isParameter(
"numDesiredLevel")) { numDesiredLevel = levelList.get<
int>(
"numDesiredLevel"); levelList.remove(
"numDesiredLevel"); }
1701 BuildFactoryMap(levelList, factoryMap, levelFactoryMap, factoryManagers);
1703 RCP<FactoryManagerBase> m = rcp(
new FactoryManager(levelFactoryMap));
1705 if (startLevel >= 0)
1708 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::ParameterListInterpreter():: invalid level id");
1838 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1841 for (ParameterList::ConstIterator param = paramList.begin(); param != paramList.end(); ++param) {
1842 const std::string & paramName = paramList.name(param);
1843 const Teuchos::ParameterEntry & paramValue = paramList.entry(param);
1847 if (paramValue.isList()) {
1848 ParameterList paramList1 = Teuchos::getValue<ParameterList>(paramValue);
1849 if (paramList1.isParameter(
"factory")) {
1851 TEUCHOS_TEST_FOR_EXCEPTION(paramList1.isParameter(
"dependency for") ==
true,
Exceptions::RuntimeError,
"MueLu::ParameterListInterpreter(): It seems that in the parameter lists for defining " << paramName <<
" there is both a 'factory' and 'dependency for' parameter. This is not allowed. Please remove the 'dependency for' parameter.");
1852 factoryMapOut[paramName] =
factFact_->BuildFactory(paramValue, factoryMapIn, factoryManagers);
1853 }
else if(paramList1.isParameter(
"dependency for")) {
1854 TEUCHOS_TEST_FOR_EXCEPTION(paramList1.isParameter(
"factory") ==
true,
Exceptions::RuntimeError,
"MueLu::ParameterListInterpreter(): It seems that in the parameter lists for defining " << paramName <<
" there is both a 'factory' and 'dependency for' parameter. This is not allowed.");
1855 std::string factoryName = paramList1.get<std::string>(
"dependency for");
1857 RCP<const FactoryBase> factbase = factoryMapIn.find(factoryName )->second;
1858 TEUCHOS_TEST_FOR_EXCEPTION(factbase.is_null() ==
true,
Exceptions::RuntimeError,
"MueLu::ParameterListInterpreter(): could not find factory " + factoryName +
" in factory map. Did you define it before?");
1859 RCP<const Factory> factoryconst = Teuchos::rcp_dynamic_cast<
const Factory>(factbase);
1860 RCP< Factory> factory = Teuchos::rcp_const_cast<
Factory>(factoryconst);
1864 for (ParameterList::ConstIterator vparam = validParamList->begin(); vparam != validParamList->end(); ++vparam) {
1865 const std::string& pName = validParamList->name(vparam);
1867 if (!paramList1.isParameter(pName)) {
1872 if (validParamList->isType< RCP<const FactoryBase> >(pName)) {
1874 RCP<const FactoryBase> generatingFact =
factFact_->BuildFactory(paramList1.getEntry(pName), factoryMapIn, factoryManagers);
1875 factory->SetFactory(pName, generatingFact.create_weak());
1876 }
else if (validParamList->isType<RCP<const ParameterList> >(pName)) {
1877 if (pName ==
"ParameterList") {
1882 RCP<const ParameterList> subList = Teuchos::sublist(rcp(
new ParameterList(paramList1)), pName);
1883 factory->SetParameter(pName, ParameterEntry(subList));
1886 factory->SetParameter(pName, paramList1.getEntry(pName));
1889 }
else if (paramList1.isParameter(
"group")) {
1891 std::string groupType = paramList1.get<std::string>(
"group");
1892 TEUCHOS_TEST_FOR_EXCEPTION(groupType!=
"FactoryManager",
Exceptions::RuntimeError,
"group must be of type \"FactoryManager\".");
1894 ParameterList groupList = paramList1;
1895 groupList.remove(
"group");
1898 BuildFactoryMap(groupList, factoryMapIn, groupFactoryMap, factoryManagers);
1902 RCP<FactoryManagerBase> m = rcp(
new FactoryManager(groupFactoryMap));
1904 factoryManagers[paramName] = m;
1907 this->
GetOStream(
Warnings0) <<
"Could not interpret parameter list " << paramList1 << std::endl;
1908 TEUCHOS_TEST_FOR_EXCEPTION(
false,
Exceptions::RuntimeError,
"XML Parameter list must either be of type \"factory\" or of type \"group\".");
1912 factoryMapOut[paramName] =
factFact_->BuildFactory(paramValue, factoryMapIn, factoryManagers);
1920 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1923 Matrix& A =
dynamic_cast<Matrix&
>(Op);
1926 <<
"instead of " << A.GetFixedBlockSize() <<
" (provided matrix)." << std::endl
1927 <<
"You may want to check \"number of equations\" (or \"PDE equations\" for factory style list) parameter." << std::endl;
1931 }
catch (std::bad_cast& e) {
1932 this->
GetOStream(
Warnings0) <<
"Skipping setting block size as the operator is not a matrix" << std::endl;
1936 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1943 static bool compare(
const ParameterList& list1,
const ParameterList& list2) {
1946 for (ParameterList::ConstIterator it = list1.begin(); it != list1.end(); it++) {
1947 const std::string& name = it->first;
1948 const Teuchos::ParameterEntry& entry1 = it->second;
1950 const Teuchos::ParameterEntry *entry2 = list2.getEntryPtr(name);
1953 if (entry1.isList() && entry2->isList()) {
1954 compare(Teuchos::getValue<ParameterList>(entry1), Teuchos::getValue<ParameterList>(*entry2));
1957 if (entry1.getAny(
false) != entry2->getAny(
false))
1964 static inline bool areSame(
const ParameterList& list1,
const ParameterList& list2) {
1970 #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...
Teuchos::Array< int > matricesToPrint_
High level timing information (use Teuchos::TimeMonitor::summarize() to print)
Factory for determing the number of partitions for rebalancing.
double scalingFactor_
prolongator scaling factor
#define MUELU_KOKKOS_FACTORY_NO_DECL(varName, oldFactory, newFactory)
Factory for generating coarse level map. Used by TentativePFactory.
bool changedPRrebalance_
Easy interpreter stuff.
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...
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
Factory that can generate other factories from.
int LevenshteinDistance(const char *s, size_t len_s, const char *t, size_t len_t)
void UpdateFactoryManager_CoarseSolvers(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
Print external lib objects.
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.
static void DisableMultipleCheckGlobally()
#define MUELU_TEST_AND_SET_VAR(paramList, paramName, paramType, varName)
Teuchos::Array< int > elementToNodeMapsToPrint_
Factory for building permutation matrix that can be be used to shuffle data (matrices, vectors) among processes.
Print additional debugging information.
void AddFactoryManager(int startLevel, int numDesiredLevel, RCP< FactoryManagerBase > manager)
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)
RCP< FactoryManagerBase > GetFactoryManager(int levelID) const
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
Print skeleton for the run, i.e. factory calls and used parameters.
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)
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.
int blockSize_
block size of matrix (fixed block size)
Important warning messages (more verbose)
Print statistics that do not involve significant additional computation.
Teuchos::RCP< FactoryFactory > factFact_
Internal factory for factories.
#define MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, paramName, paramType, listWrite)
static bool compare(const ParameterList &list1, const ParameterList &list2)
static CycleType GetDefaultCycle()
void UpdateFactoryManager(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
Teuchos::Array< int > nullspaceToPrint_
Detailed timing information (use Teuchos::TimeMonitor::summarize() to print)
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
bool changedImplicitTranspose_
void Validate(const Teuchos::ParameterList ¶mList) const
void SetFactoryParameterList(const Teuchos::ParameterList ¶mList)
Factory interpreter stuff.
std::pair< std::string, const FactoryBase * > keep_pair
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
By default, enabled timers appears in the teuchos time monitor summary. Use this option if you do not...
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.
Timers that are enabled (using Timings0/Timings1) will be printed during the execution.
GlobalOrdinal dofOffset_
global offset variable describing offset of DOFs in operator
void SetupHierarchy(Hierarchy &H) const
Call the SetupHierarchy routine from the HiearchyManager object.
Record timing information level by level. Must be used in combinaison with Timings0/Timings1.
Factory for creating a graph base on a given matrix.
Teuchos::Array< int > prolongatorsToPrint_
Class that encapsulates Matlab smoothers.
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.
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.
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
Teuchos::Array< int > coordinatesToPrint_
static bool areSame(const ParameterList &list1, const ParameterList &list2)
Helper functions to compare two paramter lists.
std::map< int, std::vector< keep_pair > > keep_
#define TEST_MUTUALLY_EXCLUSIVE_S(arg1, arg2)
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)
Print class parameters (more parameters, more verbose)
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.
Factory for building Smoothed Aggregation prolongators.
Xpetra::global_size_t maxCoarseSize_
Factory for building uncoupled aggregates.
static Teuchos::RCP< const Teuchos::ParameterList > List()
Return a "master" list of all valid parameters and their default values.
#define MUELU_SET_VAR_2LIST(paramList, defaultList, paramName, paramType, varName)
Teuchos::Array< int > restrictorsToPrint_
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)
Exception throws to report invalid user entry.
static const RCP< const NoFactory > getRCP()
Static Get() functions.
CycleType Cycle_
multigrid cycle type (V-cycle or W-cycle)