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#include "MueLu_NotayAggregationFactory.hpp"
84#include "MueLu_NullspaceFactory.hpp"
85#include "MueLu_PatternFactory.hpp"
86#include "MueLu_ReplicatePFactory.hpp"
87#include "MueLu_PgPFactory.hpp"
88#include "MueLu_RAPFactory.hpp"
89#include "MueLu_RAPShiftFactory.hpp"
90#include "MueLu_RebalanceAcFactory.hpp"
91#include "MueLu_RebalanceTransferFactory.hpp"
92#include "MueLu_RepartitionFactory.hpp"
93#include "MueLu_ReitzingerPFactory.hpp"
94#include "MueLu_SaPFactory.hpp"
95#include "MueLu_ScaledNullspaceFactory.hpp"
96#include "MueLu_SemiCoarsenPFactory.hpp"
97#include "MueLu_SmootherFactory.hpp"
98#include "MueLu_SmooVecCoalesceDropFactory.hpp"
99#include "MueLu_TentativePFactory.hpp"
100#include "MueLu_TogglePFactory.hpp"
101#include "MueLu_ToggleCoordinatesTransferFactory.hpp"
102#include "MueLu_TransPFactory.hpp"
103#include "MueLu_UncoupledAggregationFactory.hpp"
104#include "MueLu_HybridAggregationFactory.hpp"
105#include "MueLu_ZoltanInterface.hpp"
106#include "MueLu_Zoltan2Interface.hpp"
107#include "MueLu_NodePartitionInterface.hpp"
108#include "MueLu_LowPrecisionFactory.hpp"
110#include "MueLu_CoalesceDropFactory_kokkos.hpp"
111#include "MueLu_CoarseMapFactory_kokkos.hpp"
112#include "MueLu_CoordinatesTransferFactory_kokkos.hpp"
113#include "MueLu_NullspaceFactory_kokkos.hpp"
114#include "MueLu_SaPFactory_kokkos.hpp"
115#include "MueLu_SemiCoarsenPFactory_kokkos.hpp"
116#include "MueLu_TentativePFactory_kokkos.hpp"
117#include "MueLu_UncoupledAggregationFactory_kokkos.hpp"
119#ifdef HAVE_MUELU_MATLAB
120#include "../matlab/src/MueLu_MatlabSmoother_decl.hpp"
121#include "../matlab/src/MueLu_MatlabSmoother_def.hpp"
122#include "../matlab/src/MueLu_TwoLevelMatlabFactory_decl.hpp"
123#include "../matlab/src/MueLu_TwoLevelMatlabFactory_def.hpp"
124#include "../matlab/src/MueLu_SingleLevelMatlabFactory_decl.hpp"
125#include "../matlab/src/MueLu_SingleLevelMatlabFactory_def.hpp"
128#ifdef HAVE_MUELU_INTREPID2
129#include "MueLu_IntrepidPCoarsenFactory.hpp"
132#include <unordered_set>
136 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
138 RCP<Teuchos::TimeMonitor> tM = rcp(
new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer(std::string(
"MueLu: ParameterListInterpreter (ParameterList)"))));
139 if(facadeFact == Teuchos::null)
140 facadeFact_ = Teuchos::rcp(
new FacadeClassFactory());
142 facadeFact_ = facadeFact;
144 if (paramList.isParameter(
"xml parameter file")) {
145 std::string filename = paramList.get(
"xml parameter file",
"");
146 if (filename.length() != 0) {
147 TEUCHOS_TEST_FOR_EXCEPTION(comm.is_null(), Exceptions::RuntimeError,
"xml parameter file requires a valid comm");
149 ParameterList paramList2 = paramList;
150 Teuchos::updateParametersFromXmlFileAndBroadcast(filename, Teuchos::Ptr<Teuchos::ParameterList>(¶mList2), *comm);
151 SetParameterList(paramList2);
154 SetParameterList(paramList);
158 SetParameterList(paramList);
162 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
164 RCP<Teuchos::TimeMonitor> tM = rcp(
new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer(std::string(
"MueLu: ParameterListInterpreter (XML)"))));
165 if(facadeFact == Teuchos::null)
170 ParameterList paramList;
171 Teuchos::updateParametersFromXmlFileAndBroadcast(xmlFileName, Teuchos::Ptr<ParameterList>(¶mList), comm);
175 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
179 scalingFactor_= Teuchos::ScalarTraits<double>::one();
183 if (paramList.isSublist(
"Hierarchy")) {
184 SetFactoryParameterList(paramList);
186 }
else if (paramList.isParameter(
"MueLu preconditioner") ==
true) {
187 this->GetOStream(
Runtime0) <<
"Use facade class: " << paramList.get<std::string>(
"MueLu preconditioner") << std::endl;
188 Teuchos::RCP<ParameterList> pp = facadeFact_->SetParameterList(paramList);
189 SetFactoryParameterList(*pp);
193 ParameterList serialList, nonSerialList;
196 Validate(serialList);
197 SetEasyParameterList(paramList);
205 static inline bool areSame(
const ParameterList& list1,
const ParameterList& list2);
210#define MUELU_SET_VAR_2LIST(paramList, defaultList, paramName, paramType, varName) \
212 if (paramList.isParameter(paramName)) varName = paramList.get<paramType>(paramName); \
213 else if (defaultList.isParameter(paramName)) varName = defaultList.get<paramType>(paramName); \
214 else varName = MasterList::getDefault<paramType>(paramName);
216#define MUELU_TEST_AND_SET_VAR(paramList, paramName, paramType, varName) \
217 (paramList.isParameter(paramName) ? varName = paramList.get<paramType>(paramName), true : false)
221#define MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, paramName, paramType, listWrite) \
223 if (paramList .isParameter(paramName)) listWrite.set(paramName, paramList .get<paramType>(paramName)); \
224 else if (defaultList.isParameter(paramName)) listWrite.set(paramName, defaultList.get<paramType>(paramName)); \
226 catch(Teuchos::Exceptions::InvalidParameterType&) { \
227 TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(true, Teuchos::Exceptions::InvalidParameterType, \
228 "Error: parameter \"" << paramName << "\" must be of type " << Teuchos::TypeNameTraits<paramType>::name()); \
231#define MUELU_TEST_PARAM_2LIST(paramList, defaultList, paramName, paramType, cmpValue) \
233 paramList.isParameter(paramName) ? paramList .get<paramType>(paramName) : ( \
234 defaultList.isParameter(paramName) ? defaultList.get<paramType>(paramName) : \
235 MasterList::getDefault<paramType>(paramName) ) ) )
237#define MUELU_KOKKOS_FACTORY(varName, oldFactory, newFactory) \
238 RCP<Factory> varName; \
239 if (!useKokkos_) varName = rcp(new oldFactory()); \
240 else varName = rcp(new newFactory());
241#define MUELU_KOKKOS_FACTORY_NO_DECL(varName, oldFactory, newFactory) \
242 if (!useKokkos_) varName = rcp(new oldFactory()); \
243 else varName = rcp(new newFactory());
245 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
248 ParameterList paramList;
250 MUELU_SET_VAR_2LIST(constParamList, constParamList,
"problem: type", std::string, problemType);
251 if (problemType !=
"unknown") {
253 paramList.setParameters(constParamList);
257 paramList = constParamList;
261# ifdef HAVE_MUELU_SERIAL
262 if (
typeid(
Node).name() ==
typeid(Kokkos::Compat::KokkosSerialWrapperNode).name())
265# ifdef HAVE_MUELU_OPENMP
266 if (
typeid(
Node).name() ==
typeid(Kokkos::Compat::KokkosOpenMPWrapperNode).name())
269# ifdef HAVE_MUELU_CUDA
270 if (
typeid(
Node).name() ==
typeid(Kokkos::Compat::KokkosCudaWrapperNode).name())
273# ifdef HAVE_MUELU_HIP
274 if (
typeid(
Node).name() ==
typeid(Kokkos::Compat::KokkosHIPWrapperNode).name())
285 if (paramList.isParameter(
"cycle type")) {
286 std::map<std::string, CycleType> cycleMap;
290 auto cycleType = paramList.get<std::string>(
"cycle type");
292 "Invalid cycle type: \"" << cycleType <<
"\"");
293 Cycle_ = cycleMap[cycleType];
296 if (paramList.isParameter(
"W cycle start level")) {
297 WCycleStartLevel_ = paramList.get<
int>(
"W cycle start level");
300 if (paramList.isParameter(
"coarse grid correction scaling factor"))
301 scalingFactor_ = paramList.get<
double>(
"coarse grid correction scaling factor");
303 this->maxCoarseSize_ = paramList.get<
int> (
"coarse: max size", MasterList::getDefault<int>(
"coarse: max size"));
304 this->numDesiredLevel_ = paramList.get<
int> (
"max levels", MasterList::getDefault<int>(
"max levels"));
305 blockSize_ = paramList.get<
int> (
"number of equations", MasterList::getDefault<int>(
"number of equations"));
311 if(paramList.isParameter(
"save data"))
312 this->dataToSave_ = Teuchos::getArrayFromStringParameter<std::string>(paramList,
"save data");
315 if (paramList.isSublist(
"export data")) {
316 ParameterList printList = paramList.sublist(
"export data");
319 if (printList.isParameter(
"Nullspace"))
320 this->nullspaceToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"Nullspace");
321 if (printList.isParameter(
"Coordinates"))
322 this->coordinatesToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"Coordinates");
323 if (printList.isParameter(
"Aggregates"))
324 this->aggregatesToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"Aggregates");
325 if (printList.isParameter(
"pcoarsen: element to node map"))
326 this->elementToNodeMapsToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"pcoarsen: element to node map");
329 for(
auto iter = printList.begin(); iter != printList.end(); iter++) {
330 const std::string & name = printList.name(iter);
332 if(name ==
"Nullspace" || name ==
"Coordinates" || name ==
"Aggregates" || name ==
"pcoarsen: element to node map")
335 this->matricesToPrint_[name] = Teuchos::getArrayFromStringParameter<int>(printList, name);
348 if (outputFilename !=
"")
358 useCoordinates_ =
false;
359 useBlockNumber_ =
false;
360 if (
MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"distance laplacian") ||
363 useCoordinates_ =
true;
364 }
else if(
MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal distance laplacian")) {
365 useCoordinates_ =
true;
366 useBlockNumber_ =
true;
367 }
else if(
MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal") ||
368 MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal classical") ||
369 MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal signed classical") ||
370 MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal colored signed classical") ||
371 MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"signed classical")) {
372 useBlockNumber_ =
true;
373 }
else if(paramList.isSublist(
"smoother: params")) {
374 const auto smooParamList = paramList.sublist(
"smoother: params");
375 if(smooParamList.isParameter(
"partitioner: type") &&
376 (smooParamList.get<std::string>(
"partitioner: type") ==
"line")) {
377 useCoordinates_ =
true;
380 for (
int levelID = 0; levelID < this->numDesiredLevel_; levelID++) {
381 std::string levelStr =
"level " +
toString(levelID);
383 if (paramList.isSublist(levelStr)) {
384 const ParameterList& levelList = paramList.sublist(levelStr);
386 if (
MUELU_TEST_PARAM_2LIST(levelList, paramList,
"aggregation: drop scheme", std::string,
"distance laplacian") ||
389 useCoordinates_ =
true;
391 else if (
MUELU_TEST_PARAM_2LIST(levelList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal distance laplacian")) {
392 useCoordinates_ =
true;
393 useBlockNumber_ =
true;
395 else if (
MUELU_TEST_PARAM_2LIST(levelList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal") ||
396 MUELU_TEST_PARAM_2LIST(levelList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal classical") ||
397 MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal signed classical") ||
398 MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal colored signed classical") ||
399 MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"signed classical")) {
400 useBlockNumber_ =
true;
411 }
else 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 (void)
MUELU_TEST_AND_SET_VAR(paramList,
"fuse prolongation and update",
bool, this->fuseProlongationAndUpdate_);
464 (void)
MUELU_TEST_AND_SET_VAR(paramList,
"nullspace: suppress dimension check",
bool, this->suppressNullspaceDimensionCheck_);
466 if (paramList.isSublist(
"matvec params"))
467 this->matvecParams_ = Teuchos::parameterList(paramList.sublist(
"matvec params"));
472 defaultManager->SetVerbLevel(this->verbosity_);
473 defaultManager->SetKokkosRefactor(useKokkos_);
476 std::vector<keep_pair> keeps0;
477 UpdateFactoryManager(paramList, ParameterList(), *defaultManager, 0, keeps0);
483 for (
int levelID = 0; levelID < this->numDesiredLevel_; levelID++) {
489 RCP<FactoryManager> levelManager = rcp(
new FactoryManager(*defaultManager));
490 levelManager->SetVerbLevel(defaultManager->GetVerbLevel());
492 std::vector<keep_pair> keeps;
493 if (paramList.isSublist(
"level " +
toString(levelID))) {
495 ParameterList& levelList = paramList.sublist(
"level " +
toString(levelID),
true);
496 UpdateFactoryManager(levelList, paramList, *levelManager, levelID, keeps);
499 ParameterList levelList;
500 UpdateFactoryManager(levelList, paramList, *levelManager, levelID, keeps);
503 this->keep_[levelID] = keeps;
504 this->AddFactoryManager(levelID, 1, levelManager);
515 this->GetOStream(
static_cast<MsgType>(
Runtime1), 0) << paramList << std::endl;
519 ParameterList unusedParamList;
522 for (ParameterList::ConstIterator it = paramList.begin(); it != paramList.end(); it++) {
523 const ParameterEntry& entry = paramList.entry(it);
525 if (!entry.isList() && !entry.isUsed())
526 unusedParamList.setEntry(paramList.name(it), entry);
530 for (
int levelID = 0; levelID < this->numDesiredLevel_; levelID++) {
531 std::string levelStr =
"level " +
toString(levelID);
533 if (paramList.isSublist(levelStr)) {
534 const ParameterList& levelList = paramList.sublist(levelStr);
536 for (ParameterList::ConstIterator itr = levelList.begin(); itr != levelList.end(); ++itr) {
537 const ParameterEntry& entry = levelList.entry(itr);
539 if (!entry.isList() && !entry.isUsed())
540 unusedParamList.sublist(levelStr).setEntry(levelList.name(itr), entry);
545 if (unusedParamList.numParams() > 0) {
546 std::ostringstream unusedParamsStream;
548 unusedParamList.print(unusedParamsStream, indent);
550 this->GetOStream(
Warnings1) <<
"The following parameters were not used:\n" << unusedParamsStream.str() << std::endl;
562 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
565 int levelID, std::vector<keep_pair>& keeps)
const
570 using strings = std::unordered_set<std::string>;
573 if (paramList.numParams() == 0 && defaultList.numParams() > 0)
574 paramList = ParameterList(defaultList);
577 TEUCHOS_TEST_FOR_EXCEPTION(strings({
"none",
"tP",
"RP",
"emin",
"RAP",
"full",
"S"}).count(reuseType) == 0,
580 MUELU_SET_VAR_2LIST(paramList, defaultList,
"multigrid algorithm", std::string, multigridAlgo);
581 TEUCHOS_TEST_FOR_EXCEPTION(strings({
"unsmoothed",
"sa",
"pg",
"emin",
"matlab",
"pcoarsen",
"classical",
"smoothed reitzinger",
"unsmoothed reitzinger",
"replicate"}).count(multigridAlgo) == 0,
582 Exceptions::RuntimeError,
"Unknown \"multigrid algorithm\" value: \"" << multigridAlgo <<
"\". Please consult User's Guide.");
583#ifndef HAVE_MUELU_MATLAB
585 "Cannot use matlab for multigrid algorithm - MueLu was not configured with MATLAB support.");
587#ifndef HAVE_MUELU_INTREPID2
589 "Cannot use IntrepidPCoarsen prolongator factory - MueLu was not configured with Intrepid support.");
594 if (reuseType ==
"none" || reuseType ==
"S" || reuseType ==
"RP" || reuseType ==
"RAP") {
597 }
else if (reuseType ==
"tP" && (multigridAlgo !=
"sa" && multigridAlgo !=
"unsmoothed")) {
599 this->GetOStream(
Warnings0) <<
"Ignoring \"tP\" reuse option as it is only compatible with \"sa\", "
600 "or \"unsmoothed\" multigrid algorithms" << std::endl;
602 }
else if (reuseType ==
"emin" && multigridAlgo !=
"emin") {
604 this->GetOStream(
Warnings0) <<
"Ignoring \"emin\" reuse option it is only compatible with "
605 "\"emin\" multigrid algorithm" << std::endl;
610 bool have_userP =
false;
611 if (paramList.isParameter(
"P") && !paramList.get<RCP<Matrix> >(
"P").is_null())
615 UpdateFactoryManager_CoarseSolvers(paramList, defaultList, manager, levelID, keeps);
618 UpdateFactoryManager_Smoothers(paramList, defaultList, manager, levelID, keeps);
622 UpdateFactoryManager_BlockNumber(paramList, defaultList, manager, levelID, keeps);
625 if(multigridAlgo ==
"unsmoothed reitzinger" || multigridAlgo ==
"smoothed reitzinger")
626 UpdateFactoryManager_Reitzinger(paramList, defaultList, manager, levelID, keeps);
628 UpdateFactoryManager_Aggregation_TentativeP(paramList, defaultList, manager, levelID, keeps);
631 RCP<Factory> nullSpaceFactory;
632 UpdateFactoryManager_Nullspace(paramList, defaultList, manager, levelID, keeps, nullSpaceFactory);
643 }
else if (multigridAlgo ==
"unsmoothed" || multigridAlgo ==
"unsmoothed reitzinger") {
647 }
else if (multigridAlgo ==
"classical") {
651 }
else if (multigridAlgo ==
"sa" || multigridAlgo ==
"smoothed reitzinger") {
653 UpdateFactoryManager_SA(paramList, defaultList, manager, levelID, keeps);
655 }
else if (multigridAlgo ==
"emin") {
657 UpdateFactoryManager_Emin(paramList, defaultList, manager, levelID, keeps);
659 }
else if (multigridAlgo ==
"replicate") {
660 UpdateFactoryManager_Replicate(paramList, defaultList, manager, levelID, keeps);
662 }
else if (multigridAlgo ==
"pg") {
664 UpdateFactoryManager_PG(paramList, defaultList, manager, levelID, keeps);
666 }
else if (multigridAlgo ==
"matlab") {
668 UpdateFactoryManager_Matlab(paramList, defaultList, manager, levelID, keeps);
670 }
else if (multigridAlgo ==
"pcoarsen") {
672 UpdateFactoryManager_PCoarsen(paramList, defaultList, manager, levelID, keeps);
676 UpdateFactoryManager_SemiCoarsen(paramList, defaultList, manager, levelID, keeps);
679 UpdateFactoryManager_Restriction(paramList, defaultList, manager, levelID, keeps);
682 UpdateFactoryManager_RAP(paramList, defaultList, manager, levelID, keeps);
685 UpdateFactoryManager_LocalOrdinalTransfer(
"BlockNumber",multigridAlgo,paramList,defaultList,manager,levelID,keeps);
689 UpdateFactoryManager_Coordinates(paramList, defaultList, manager, levelID, keeps);
692 if ((reuseType ==
"RP" || reuseType ==
"RAP" || reuseType ==
"full") && levelID)
695 if (reuseType ==
"RP" && levelID) {
697 if (!this->implicitTranspose_)
700 if ((reuseType ==
"tP" || reuseType ==
"RP" || reuseType ==
"emin") && useCoordinates_ && levelID)
704 UpdateFactoryManager_Repartition(paramList, defaultList, manager, levelID, keeps, nullSpaceFactory);
707 UpdateFactoryManager_LowPrecision(paramList, defaultList, manager, levelID, keeps);
710 if ((reuseType ==
"RAP" || reuseType ==
"full") && levelID) {
712 if (!this->implicitTranspose_)
725 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
728 FactoryManager& manager,
int levelID, std::vector<keep_pair>& keeps)
const
730 MUELU_SET_VAR_2LIST(paramList, defaultList,
"multigrid algorithm", std::string, multigridAlgo);
732 bool useMaxAbsDiagonalScaling =
false;
733 if (defaultList.isParameter(
"sa: use rowsumabs diagonal scaling"))
734 useMaxAbsDiagonalScaling = defaultList.get<
bool>(
"sa: use rowsumabs diagonal scaling");
738 bool isCustomSmoother =
739 paramList.isParameter(
"smoother: pre or post") ||
740 paramList.isParameter(
"smoother: type") || paramList.isParameter(
"smoother: pre type") || paramList.isParameter(
"smoother: post type") ||
741 paramList.isSublist (
"smoother: params") || paramList.isSublist (
"smoother: pre params") || paramList.isSublist (
"smoother: post params") ||
742 paramList.isParameter(
"smoother: sweeps") || paramList.isParameter(
"smoother: pre sweeps") || paramList.isParameter(
"smoother: post sweeps") ||
743 paramList.isParameter(
"smoother: overlap") || paramList.isParameter(
"smoother: pre overlap") || paramList.isParameter(
"smoother: post overlap");
747 manager.
SetFactory(
"Smoother", Teuchos::null);
749 }
else if (isCustomSmoother) {
753 #define TEST_MUTUALLY_EXCLUSIVE(arg1,arg2) \
754 TEUCHOS_TEST_FOR_EXCEPTION(paramList.isParameter(#arg1) && paramList.isParameter(#arg2), \
755 Exceptions::InvalidArgument, "You cannot specify both \""#arg1"\" and \""#arg2"\"");
756 #define TEST_MUTUALLY_EXCLUSIVE_S(arg1,arg2) \
757 TEUCHOS_TEST_FOR_EXCEPTION(paramList.isSublist(#arg1) && paramList.isSublist(#arg2), \
758 Exceptions::InvalidArgument, "You cannot specify both \""#arg1"\" and \""#arg2"\"");
768 TEUCHOS_TEST_FOR_EXCEPTION(
PreOrPost ==
"both" && (paramList.isParameter(
"smoother: pre type") != paramList.isParameter(
"smoother: post type")),
773 ParameterList defaultSmootherParams;
774 defaultSmootherParams.set(
"relaxation: type",
"Symmetric Gauss-Seidel");
775 defaultSmootherParams.set(
"relaxation: sweeps", Teuchos::OrdinalTraits<LO>::one());
776 defaultSmootherParams.set(
"relaxation: damping factor", Teuchos::ScalarTraits<Scalar>::one());
778 RCP<SmootherFactory> preSmoother = Teuchos::null, postSmoother = Teuchos::null;
779 std::string preSmootherType, postSmootherType;
780 ParameterList preSmootherParams, postSmootherParams;
782 if (paramList.isParameter(
"smoother: overlap"))
783 overlap = paramList.get<
int>(
"smoother: overlap");
786 if (paramList.isParameter(
"smoother: pre type")) {
787 preSmootherType = paramList.get<std::string>(
"smoother: pre type");
789 MUELU_SET_VAR_2LIST(paramList, defaultList,
"smoother: type", std::string, preSmootherTypeTmp);
790 preSmootherType = preSmootherTypeTmp;
792 if (paramList.isParameter(
"smoother: pre overlap"))
793 overlap = paramList.get<
int>(
"smoother: pre overlap");
795 if (paramList.isSublist(
"smoother: pre params"))
796 preSmootherParams = paramList.sublist(
"smoother: pre params");
797 else if (paramList.isSublist(
"smoother: params"))
798 preSmootherParams = paramList.sublist(
"smoother: params");
799 else if (defaultList.isSublist(
"smoother: params"))
800 preSmootherParams = defaultList.sublist(
"smoother: params");
801 else if (preSmootherType ==
"RELAXATION")
802 preSmootherParams = defaultSmootherParams;
804 if (preSmootherType ==
"CHEBYSHEV" && useMaxAbsDiagonalScaling)
805 preSmootherParams.set(
"chebyshev: use rowsumabs diagonal scaling",
true);
807 #ifdef HAVE_MUELU_INTREPID2
809 if (multigridAlgo ==
"pcoarsen" && preSmootherType ==
"TOPOLOGICAL" &&
810 defaultList.isParameter(
"pcoarsen: schedule") && defaultList.isParameter(
"pcoarsen: element")) {
813 auto pcoarsen_schedule = Teuchos::getArrayFromStringParameter<int>(defaultList,
"pcoarsen: schedule");
814 auto pcoarsen_element = defaultList.get<std::string>(
"pcoarsen: element");
816 if (levelID < (
int)pcoarsen_schedule.size()) {
818 auto lo = pcoarsen_element + std::to_string(pcoarsen_schedule[levelID]);
819 preSmootherParams.set(
"pcoarsen: hi basis", lo);
824 #ifdef HAVE_MUELU_MATLAB
825 if (preSmootherType ==
"matlab")
833 if (paramList.isParameter(
"smoother: post type"))
834 postSmootherType = paramList.get<std::string>(
"smoother: post type");
836 MUELU_SET_VAR_2LIST(paramList, defaultList,
"smoother: type", std::string, postSmootherTypeTmp);
837 postSmootherType = postSmootherTypeTmp;
840 if (paramList.isSublist(
"smoother: post params"))
841 postSmootherParams = paramList.sublist(
"smoother: post params");
842 else if (paramList.isSublist(
"smoother: params"))
843 postSmootherParams = paramList.sublist(
"smoother: params");
844 else if (defaultList.isSublist(
"smoother: params"))
845 postSmootherParams = defaultList.sublist(
"smoother: params");
846 else if (postSmootherType ==
"RELAXATION")
847 postSmootherParams = defaultSmootherParams;
848 if (paramList.isParameter(
"smoother: post overlap"))
849 overlap = paramList.get<
int>(
"smoother: post overlap");
851 if (postSmootherType ==
"CHEBYSHEV" && useMaxAbsDiagonalScaling)
852 postSmootherParams.set(
"chebyshev: use rowsumabs diagonal scaling",
true);
854 if (postSmootherType == preSmootherType &&
areSame(preSmootherParams, postSmootherParams))
855 postSmoother = preSmoother;
857 #ifdef HAVE_MUELU_INTREPID2
859 if (multigridAlgo ==
"pcoarsen" && preSmootherType ==
"TOPOLOGICAL" &&
860 defaultList.isParameter(
"pcoarsen: schedule") && defaultList.isParameter(
"pcoarsen: element")) {
863 auto pcoarsen_schedule = Teuchos::getArrayFromStringParameter<int>(defaultList,
"pcoarsen: schedule");
864 auto pcoarsen_element = defaultList.get<std::string>(
"pcoarsen: element");
866 if (levelID < (
int)pcoarsen_schedule.size()) {
868 auto lo = pcoarsen_element + std::to_string(pcoarsen_schedule[levelID]);
869 postSmootherParams.set(
"pcoarsen: hi basis", lo);
874 #ifdef HAVE_MUELU_MATLAB
875 if (postSmootherType ==
"matlab")
883 if (preSmoother == postSmoother)
886 manager.
SetFactory(
"PreSmoother", preSmoother);
887 manager.
SetFactory(
"PostSmoother", postSmoother);
894 bool reuseSmoothers = (reuseType ==
"S" || reuseType !=
"none");
895 if (reuseSmoothers) {
896 auto preSmootherFactory = rcp_const_cast<Factory>(rcp_dynamic_cast<const Factory>(manager.
GetFactory(
"PreSmoother")));
898 if (preSmootherFactory != Teuchos::null) {
899 ParameterList postSmootherFactoryParams;
900 postSmootherFactoryParams.set(
"keep smoother data",
true);
901 preSmootherFactory->SetParameterList(postSmootherFactoryParams);
903 keeps.push_back(
keep_pair(
"PreSmoother data", preSmootherFactory.get()));
906 auto postSmootherFactory = rcp_const_cast<Factory>(rcp_dynamic_cast<const Factory>(manager.
GetFactory(
"PostSmoother")));
907 if (postSmootherFactory != Teuchos::null) {
908 ParameterList postSmootherFactoryParams;
909 postSmootherFactoryParams.set(
"keep smoother data",
true);
910 postSmootherFactory->SetParameterList(postSmootherFactoryParams);
912 keeps.push_back(
keep_pair(
"PostSmoother data", postSmootherFactory.get()));
915 auto coarseFactory = rcp_const_cast<Factory>(rcp_dynamic_cast<const Factory>(manager.
GetFactory(
"CoarseSolver")));
916 if (coarseFactory != Teuchos::null) {
917 ParameterList coarseFactoryParams;
918 coarseFactoryParams.set(
"keep smoother data",
true);
919 coarseFactory->SetParameterList(coarseFactoryParams);
921 keeps.push_back(
keep_pair(
"PreSmoother data", coarseFactory.get()));
925 if ((reuseType ==
"RAP" && levelID) || (reuseType ==
"full")) {
944 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
950 bool isCustomCoarseSolver =
951 paramList.isParameter(
"coarse: type") ||
952 paramList.isParameter(
"coarse: params");
954 manager.
SetFactory(
"CoarseSolver", Teuchos::null);
956 }
else if (isCustomCoarseSolver) {
963 if (paramList.isParameter(
"coarse: overlap"))
964 overlap = paramList.get<
int>(
"coarse: overlap");
966 ParameterList coarseParams;
967 if (paramList.isSublist(
"coarse: params"))
968 coarseParams = paramList.sublist(
"coarse: params");
969 else if (defaultList.isSublist(
"coarse: params"))
970 coarseParams = defaultList.sublist(
"coarse: params");
972 using strings = std::unordered_set<std::string>;
974 RCP<SmootherPrototype> coarseSmoother;
978 if (strings({
"RELAXATION",
"CHEBYSHEV",
"ILUT",
"ILU",
"RILUK",
"SCHWARZ",
"Amesos",
979 "BLOCK RELAXATION",
"BLOCK_RELAXATION",
"BLOCKRELAXATION" ,
980 "SPARSE BLOCK RELAXATION",
"SPARSE_BLOCK_RELAXATION",
"SPARSEBLOCKRELAXATION",
981 "LINESMOOTHING_BANDEDRELAXATION",
"LINESMOOTHING_BANDED_RELAXATION",
"LINESMOOTHING_BANDED RELAXATION",
982 "LINESMOOTHING_TRIDIRELAXATION",
"LINESMOOTHING_TRIDI_RELAXATION",
"LINESMOOTHING_TRIDI RELAXATION",
983 "LINESMOOTHING_TRIDIAGONALRELAXATION",
"LINESMOOTHING_TRIDIAGONAL_RELAXATION",
"LINESMOOTHING_TRIDIAGONAL RELAXATION",
984 "TOPOLOGICAL",
"FAST_ILU",
"FAST_IC",
"FAST_ILDL"}).count(coarseType)) {
985 coarseSmoother = rcp(
new TrilinosSmoother(coarseType, coarseParams, overlap));
987 #ifdef HAVE_MUELU_MATLAB
988 if (coarseType ==
"matlab")
992 coarseSmoother = rcp(
new DirectSolver(coarseType, coarseParams));
1003 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1006 FactoryManager& manager,
int levelID, std::vector<keep_pair>& keeps)
const
1008 ParameterList rParams;
1015 rFactory->SetParameterList(rParams);
1023 rFactory->SetFactory(
"D0", this->GetFactoryManager(levelID-1)->GetFactory(
"D0"));
1036 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1039 FactoryManager& manager,
int levelID, std::vector<keep_pair>& keeps)
const
1041 using strings = std::unordered_set<std::string>;
1046 TEUCHOS_TEST_FOR_EXCEPTION(!strings({
"uncoupled",
"coupled",
"brick",
"matlab",
"notay",
"classical"}).count(aggType),
1051 RCP<AmalgamationFactory> amalgFact;
1052 if(aggType ==
"classical") {
1054 manager.
SetFactory(
"UnAmalgamationInfo",amalgFact);
1058 RCP<Factory> dropFactory;
1061 #ifdef HAVE_MUELU_MATLAB
1063 ParameterList socParams = paramList.sublist(
"strength-of-connection: params");
1064 dropFactory->SetParameterList(socParams);
1066 throw std::runtime_error(
"Cannot use MATLAB evolutionary strength-of-connection - MueLu was not configured with MATLAB support.");
1068 }
else if (
MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"unsupported vector smoothing")) {
1070 ParameterList dropParams;
1076 dropFactory->SetParameterList(dropParams);
1080 ParameterList dropParams;
1081 if (!rcp_dynamic_cast<CoalesceDropFactory>(dropFactory).is_null())
1082 dropParams.set(
"lightweight wrap",
true);
1100 if(!amalgFact.is_null())
1101 dropFactory->SetFactory(
"UnAmalgamationInfo", manager.
GetFactory(
"UnAmalgamationInfo"));
1103 if(dropParams.isParameter(
"aggregation: drop scheme")) {
1104 std::string drop_scheme = dropParams.get<std::string>(
"aggregation: drop scheme");
1105 if(drop_scheme ==
"block diagonal colored signed classical")
1106 manager.
SetFactory(
"Coloring Graph",dropFactory);
1107 if (drop_scheme.find(
"block diagonal") != std::string::npos || drop_scheme ==
"signed classical") {
1109 dropFactory->SetFactory(
"BlockNumber", this->GetFactoryManager(levelID-1)->GetFactory(
"BlockNumber"));
1111 dropFactory->SetFactory(
"BlockNumber", manager.
GetFactory(
"BlockNumber"));
1115 dropFactory->SetParameterList(dropParams);
1121 #ifndef HAVE_MUELU_MATLAB
1122 if (aggType ==
"matlab")
1123 throw std::runtime_error(
"Cannot use MATLAB aggregation - MueLu was not configured with MATLAB support.");
1125 RCP<Factory> aggFactory;
1126 if (aggType ==
"uncoupled") {
1128 ParameterList aggParams;
1150 aggFactory->SetParameterList(aggParams);
1152 aggFactory->SetFactory(
"DofsPerNode", manager.
GetFactory(
"Graph"));
1153 aggFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1156 }
else if (aggType ==
"coupled") {
1158 aggFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1160 }
else if (aggType ==
"brick") {
1162 ParameterList aggParams;
1169 aggFactory->SetParameterList(aggParams);
1173 manager.
SetFactory(
"DofsPerNode", aggFactory);
1179 aggFactory->SetFactory(
"Coordinates", this->GetFactoryManager(levelID-1)->GetFactory(
"Coordinates"));
1182 else if (aggType ==
"classical") {
1185 ParameterList mapParams;
1189 ParameterList tempParams;
1191 std::string drop_algo = tempParams.get<std::string>(
"aggregation: drop scheme");
1192 if(drop_algo ==
"block diagonal colored signed classical") {
1193 mapParams.set(
"aggregation: coloring: use color graph",
true);
1194 mapFact->SetFactory(
"Coloring Graph", manager.
GetFactory(
"Coloring Graph"));
1197 mapFact->SetParameterList(mapParams);
1198 mapFact->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1199 mapFact->SetFactory(
"UnAmalgamationInfo", manager.
GetFactory(
"UnAmalgamationInfo"));
1206 ParameterList aggParams;
1209 aggFactory->SetParameterList(aggParams);
1210 aggFactory->SetFactory(
"FC Splitting",manager.
GetFactory(
"FC Splitting"));
1211 aggFactory->SetFactory(
"CoarseMap",manager.
GetFactory(
"CoarseMap"));
1212 aggFactory->SetFactory(
"DofsPerNode", manager.
GetFactory(
"Graph"));
1213 aggFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1215 if (drop_algo.find(
"block diagonal") != std::string::npos || drop_algo ==
"signed classical") {
1217 aggFactory->SetFactory(
"BlockNumber", this->GetFactoryManager(levelID-1)->GetFactory(
"BlockNumber"));
1219 aggFactory->SetFactory(
"BlockNumber", manager.
GetFactory(
"BlockNumber"));
1227 if (reuseType ==
"tP" && levelID) {
1229 keeps.push_back(
keep_pair(
"Ptent",aggFactory.get()));
1233 else if (aggType ==
"notay") {
1235 ParameterList aggParams;
1241 aggFactory->SetParameterList(aggParams);
1242 aggFactory->SetFactory(
"DofsPerNode", manager.
GetFactory(
"Graph"));
1243 aggFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1245#ifdef HAVE_MUELU_MATLAB
1246 else if(aggType ==
"matlab") {
1247 ParameterList aggParams = paramList.sublist(
"aggregation: params");
1249 aggFactory->SetParameterList(aggParams);
1255 manager.
SetFactory(
"Aggregates", aggFactory);
1259 coarseMap->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1263 if (
MUELU_TEST_PARAM_2LIST(paramList, defaultList,
"aggregation: compute aggregate qualities",
bool,
true)) {
1265 ParameterList aggQualityParams;
1274 aggQualityFact->SetParameterList(aggQualityParams);
1275 manager.
SetFactory(
"AggregateQualities", aggQualityFact);
1277 assert(aggType ==
"uncoupled");
1278 aggFactory->SetFactory(
"AggregateQualities", aggQualityFact);
1284 ParameterList ptentParams;
1285 if (paramList.isSublist(
"matrixmatrix: kernel params"))
1286 ptentParams.sublist(
"matrixmatrix: kernel params",
false) = paramList.sublist(
"matrixmatrix: kernel params");
1287 if (defaultList.isSublist(
"matrixmatrix: kernel params"))
1288 ptentParams.sublist(
"matrixmatrix: kernel params",
false) = defaultList.sublist(
"matrixmatrix: kernel params");
1291 Ptent->SetParameterList(ptentParams);
1292 Ptent->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1293 Ptent->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1296 if (reuseType ==
"tP" && levelID) {
1297 keeps.push_back(
keep_pair(
"Nullspace", Ptent.get()));
1298 keeps.push_back(
keep_pair(
"P", Ptent.get()));
1305 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1308 int levelID, std::vector<keep_pair>& keeps)
const
1310 if (paramList.isParameter(
"A") && !paramList.get<RCP<Matrix> >(
"A").is_null()) {
1316 ParameterList RAPparams;
1318 RCP<RAPFactory> RAP;
1319 RCP<RAPShiftFactory> RAPs;
1322 std::string alg = paramList.get(
"rap: algorithm",
"galerkin");
1323 if (alg ==
"shift" || alg ==
"non-galerkin") {
1337 if (paramList.isSublist(
"matrixmatrix: kernel params"))
1338 RAPparams.sublist(
"matrixmatrix: kernel params",
false) = paramList.sublist(
"matrixmatrix: kernel params");
1339 if (defaultList.isSublist(
"matrixmatrix: kernel params"))
1340 RAPparams.sublist(
"matrixmatrix: kernel params",
false) = defaultList.sublist(
"matrixmatrix: kernel params");
1347 if (!paramList.isParameter(
"rap: triple product") &&
1348 paramList.isType<std::string>(
"multigrid algorithm") &&
1349 paramList.get<std::string>(
"multigrid algorithm") ==
"unsmoothed")
1350 paramList.set(
"rap: triple product",
true);
1355 if (paramList.isParameter(
"aggregation: allow empty prolongator columns")) {
1356 RAPparams.set(
"CheckMainDiagonal", paramList.get<
bool>(
"aggregation: allow empty prolongator columns"));
1357 RAPparams.set(
"RepairMainDiagonal", paramList.get<
bool>(
"aggregation: allow empty prolongator columns"));
1359 else if (defaultList.isParameter(
"aggregation: allow empty prolongator columns")) {
1360 RAPparams.set(
"CheckMainDiagonal", defaultList.get<
bool>(
"aggregation: allow empty prolongator columns"));
1361 RAPparams.set(
"RepairMainDiagonal", defaultList.get<
bool>(
"aggregation: allow empty prolongator columns"));
1364 }
catch (Teuchos::Exceptions::InvalidParameterType&) {
1365 TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(
true, Teuchos::Exceptions::InvalidParameterType,
1366 "Error: parameter \"aggregation: allow empty prolongator columns\" must be of type " << Teuchos::TypeNameTraits<bool>::name());
1369 if (!RAP.is_null()) {
1370 RAP->SetParameterList(RAPparams);
1371 RAP->SetFactory(
"P", manager.
GetFactory(
"P"));
1373 RAPs->SetParameterList(RAPparams);
1374 RAPs->SetFactory(
"P", manager.
GetFactory(
"P"));
1377 if (!this->implicitTranspose_) {
1379 RAP->SetFactory(
"R", manager.
GetFactory(
"R"));
1381 RAPs->SetFactory(
"R", manager.
GetFactory(
"R"));
1384 if (
MUELU_TEST_PARAM_2LIST(paramList, defaultList,
"aggregation: export visualization data",
bool,
true)) {
1386 ParameterList aggExportParams;
1394 aggExport->SetParameterList(aggExportParams);
1395 aggExport->SetFactory(
"DofsPerNode", manager.
GetFactory(
"DofsPerNode"));
1398 RAP->AddTransferFactory(aggExport);
1400 RAPs->AddTransferFactory(aggExport);
1408 MUELU_SET_VAR_2LIST(paramList, defaultList,
"sa: use filtered matrix",
bool, useFiltering);
1409 bool filteringChangesMatrix = useFiltering && !
MUELU_TEST_PARAM_2LIST(paramList, defaultList,
"aggregation: drop tol",
double, 0);
1411 if (reuseType ==
"RP" || (reuseType ==
"tP" && !filteringChangesMatrix)) {
1412 if (!RAP.is_null()) {
1413 keeps.push_back(
keep_pair(
"AP reuse data", RAP.get()));
1414 keeps.push_back(
keep_pair(
"RAP reuse data", RAP.get()));
1417 keeps.push_back(
keep_pair(
"AP reuse data", RAPs.get()));
1418 keeps.push_back(
keep_pair(
"RAP reuse data", RAPs.get()));
1426 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1431 bool have_userCO =
false;
1432 if (paramList.isParameter(
"Coordinates") && !paramList.get<RCP<MultiVector> >(
"Coordinates").is_null())
1435 if (useCoordinates_) {
1441 coords->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1442 coords->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1445 auto RAP = rcp_const_cast<RAPFactory>(rcp_dynamic_cast<const RAPFactory>(manager.
GetFactory(
"A")));
1446 if (!RAP.is_null()) {
1447 RAP->AddTransferFactory(manager.
GetFactory(
"Coordinates"));
1449 auto RAPs = rcp_const_cast<RAPShiftFactory>(rcp_dynamic_cast<const RAPShiftFactory>(manager.
GetFactory(
"A")));
1450 RAPs->AddTransferFactory(manager.
GetFactory(
"Coordinates"));
1459 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1462 FactoryManager& manager,
int levelID, std::vector<keep_pair>& )
const
1466 if (useBlockNumber_ && (levelID > 0)) {
1467 auto RAP = rcp_const_cast<RAPFactory>(rcp_dynamic_cast<const RAPFactory>(manager.
GetFactory(
"A")));
1468 auto RAPs = rcp_const_cast<RAPShiftFactory>(rcp_dynamic_cast<const RAPShiftFactory>(manager.
GetFactory(
"A")));
1469 if (!RAP.is_null() || !RAPs.is_null()) {
1471 if(multigridAlgo ==
"classical")
1472 fact->SetFactory(
"P Graph", manager.
GetFactory(
"P Graph"));
1474 fact->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1475 fact->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1477 fact->SetFactory(VarName, this->GetFactoryManager(levelID-1)->GetFactory(VarName));
1482 RAP->AddTransferFactory(manager.
GetFactory(VarName));
1484 RAPs->AddTransferFactory(manager.
GetFactory(VarName));
1493 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1496 FactoryManager& manager,
int levelID , std::vector<keep_pair>& keeps)
const
1498 if(useBlockNumber_) {
1499 ParameterList myParams;
1502 fact->SetParameterList(myParams);
1512 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1515 int levelID, std::vector<keep_pair>& )
const
1517 MUELU_SET_VAR_2LIST(paramList, defaultList,
"multigrid algorithm", std::string, multigridAlgo);
1518 bool have_userR =
false;
1519 if (paramList.isParameter(
"R") && !paramList.get<RCP<Matrix> >(
"R").is_null())
1524 if (!this->implicitTranspose_) {
1527 if (isSymmetric ==
false && (multigridAlgo ==
"unsmoothed" || multigridAlgo ==
"emin")) {
1529 "Switching \"problem: symmetric\" parameter to symmetric as multigrid algorithm. " <<
1530 multigridAlgo <<
" is primarily supposed to be used for symmetric problems.\n\n" <<
1531 "Please note: if you are using \"unsmoothed\" transfer operators the \"problem: symmetric\" parameter " <<
1532 "has no real mathematical meaning, i.e. you can use it for non-symmetric\n" <<
1533 "problems, too. With \"problem: symmetric\"=\"symmetric\" you can use implicit transpose for building " <<
1534 "the restriction operators which may drastically reduce the amount of consumed memory." << std::endl;
1538 "Petrov-Galerkin smoothed transfer operators are only allowed for non-symmetric problems: Set \"problem: symmetric\" to false!\n" \
1539 "While PG smoothed transfer operators generally would also work for symmetric problems this is an unusual use case. " \
1540 "You can use the factory-based xml interface though if you need PG-AMG for symmetric problems.");
1557 if (paramList.isParameter(
"restriction: scale nullspace") && paramList.get<
bool>(
"restriction: scale nullspace")) {
1559 Teuchos::ParameterList tentPlist;
1560 tentPlist.set(
"Nullspace name",
"Scaled Nullspace");
1561 tentPFactory->SetParameterList(tentPlist);
1562 tentPFactory->SetFactory(
"Aggregates",manager.
GetFactory(
"Aggregates"));
1563 tentPFactory->SetFactory(
"CoarseMap",manager.
GetFactory(
"CoarseMap"));
1566 R->SetFactory(
"P",tentPFactory);
1575 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1578 int levelID, std::vector<keep_pair>& keeps, RCP<Factory> & nullSpaceFactory)
const
1585 MUELU_SET_VAR_2LIST(paramList, defaultList,
"repartition: use subcommunicators in place",
bool, enableInPlace);
1622 "Reuse types \"tP\" and \"PR\" require \"repartition: rebalance P and R\" set to \"false\"");
1627 MUELU_SET_VAR_2LIST(paramList, defaultList,
"repartition: partitioner", std::string, partName);
1629 "Invalid partitioner name: \"" << partName <<
"\". Valid options: \"zoltan\", \"zoltan2\"");
1631#ifndef HAVE_MUELU_ZOLTAN
1632 bool switched =
false;
1633 if (partName ==
"zoltan") {
1634 this->GetOStream(
Warnings0) <<
"Zoltan interface is not available, trying to switch to Zoltan2" << std::endl;
1635 partName =
"zoltan2";
1639# ifndef HAVE_MUELU_ZOLTAN2
1640 bool switched =
false;
1643#ifndef HAVE_MUELU_ZOLTAN2
1644 if (partName ==
"zoltan2" && !switched) {
1645 this->GetOStream(
Warnings0) <<
"Zoltan2 interface is not available, trying to switch to Zoltan" << std::endl;
1646 partName =
"zoltan";
1650 MUELU_SET_VAR_2LIST(paramList, defaultList,
"repartition: node repartition level",
int,nodeRepartitionLevel);
1654 ParameterList repartheurParams;
1662 repartheurFactory->SetParameterList(repartheurParams);
1663 repartheurFactory->SetFactory(
"A", manager.
GetFactory(
"A"));
1664 manager.
SetFactory(
"number of partitions", repartheurFactory);
1665 manager.
SetFactory(
"repartition: heuristic target rows per process", repartheurFactory);
1668 RCP<Factory> partitioner;
1669 if (levelID == nodeRepartitionLevel) {
1673 ParameterList partParams;
1675 partitioner->SetParameterList(partParams);
1676 partitioner->SetFactory(
"Node Comm", manager.
GetFactory(
"Node Comm"));
1681 else if (partName ==
"zoltan") {
1682#ifdef HAVE_MUELU_ZOLTAN
1688 }
else if (partName ==
"zoltan2") {
1689#ifdef HAVE_MUELU_ZOLTAN2
1691 ParameterList partParams;
1692 RCP<const ParameterList> partpartParams = rcp(
new ParameterList(paramList.sublist(
"repartition: params",
false)));
1693 partParams.set(
"ParameterList", partpartParams);
1694 partitioner->SetParameterList(partParams);
1695 partitioner->SetFactory(
"repartition: heuristic target rows per process",
1696 manager.
GetFactory(
"repartition: heuristic target rows per process"));
1702 partitioner->SetFactory(
"A", manager.
GetFactory(
"A"));
1703 partitioner->SetFactory(
"number of partitions", manager.
GetFactory(
"number of partitions"));
1704 if (useCoordinates_)
1705 partitioner->SetFactory(
"Coordinates", manager.
GetFactory(
"Coordinates"));
1706 manager.
SetFactory(
"Partition", partitioner);
1710 ParameterList repartParams;
1714 repartFactory->SetParameterList(repartParams);
1715 repartFactory->SetFactory(
"A", manager.
GetFactory(
"A"));
1716 repartFactory->SetFactory(
"number of partitions", manager.
GetFactory(
"number of partitions"));
1717 repartFactory->SetFactory(
"Partition", manager.
GetFactory(
"Partition"));
1718 manager.
SetFactory(
"Importer", repartFactory);
1719 if (reuseType !=
"none" && reuseType !=
"S" && levelID)
1728 ParameterList rebAcParams;
1731 newA->SetParameterList(rebAcParams);
1732 newA->SetFactory(
"A", manager.
GetFactory(
"A"));
1733 newA->SetFactory(
"InPlaceMap", manager.
GetFactory(
"InPlaceMap"));
1739 ParameterList rebAcParams;
1741 newA->SetParameterList(rebAcParams);
1742 newA->SetFactory(
"A", manager.
GetFactory(
"A"));
1743 newA->SetFactory(
"Importer", manager.
GetFactory(
"Importer"));
1748 ParameterList newPparams;
1749 newPparams.set(
"type",
"Interpolation");
1750 if (changedPRrebalance_)
1751 newPparams.set(
"repartition: rebalance P and R", this->doPRrebalance_);
1753 newP-> SetParameterList(newPparams);
1754 newP-> SetFactory(
"Importer", manager.
GetFactory(
"Importer"));
1755 newP-> SetFactory(
"P", manager.
GetFactory(
"P"));
1756 if (!paramList.isParameter(
"semicoarsen: number of levels"))
1757 newP->SetFactory(
"Nullspace", manager.
GetFactory(
"Ptent"));
1759 newP->SetFactory(
"Nullspace", manager.
GetFactory(
"P"));
1760 if (useCoordinates_)
1761 newP-> SetFactory(
"Coordinates", manager.
GetFactory(
"Coordinates"));
1763 if (useCoordinates_)
1765 if (useBlockNumber_ && (levelID > 0)) {
1766 newP->SetFactory(
"BlockNumber", manager.
GetFactory(
"BlockNumber"));
1772 ParameterList newRparams;
1773 newRparams.set(
"type",
"Restriction");
1775 if (changedPRrebalance_)
1776 newRparams.set(
"repartition: rebalance P and R", this->doPRrebalance_);
1777 if (changedImplicitTranspose_)
1778 newRparams.set(
"transpose: use implicit", this->implicitTranspose_);
1779 newR-> SetParameterList(newRparams);
1780 newR-> SetFactory(
"Importer", manager.
GetFactory(
"Importer"));
1781 if (!this->implicitTranspose_) {
1782 newR->SetFactory(
"R", manager.
GetFactory(
"R"));
1793 ParameterList newNullparams;
1795 nullSpaceFactory->SetFactory(
"Nullspace", newP);
1796 nullSpaceFactory->SetParameterList(newNullparams);
1799 paramList.set(
"repartition: enable",
false);
1800 this->GetOStream(
Warnings0) <<
"No repartitioning available for a serial run\n";
1808 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1811 int levelID, std::vector<keep_pair>& keeps)
const
1813 MUELU_SET_VAR_2LIST(paramList, defaultList,
"transfers: half precision",
bool, enableLowPrecision);
1815 if (enableLowPrecision) {
1818 ParameterList newPparams;
1819 newPparams.set(
"matrix key",
"P");
1820 newP-> SetParameterList(newPparams);
1821 newP-> SetFactory(
"P", manager.
GetFactory(
"P"));
1824 if (!this->implicitTranspose_) {
1827 ParameterList newRparams;
1828 newRparams.set(
"matrix key",
"R");
1829 newR-> SetParameterList(newRparams);
1830 newR-> SetFactory(
"R", manager.
GetFactory(
"R"));
1839 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1842 int , std::vector<keep_pair>& , RCP<Factory> & nullSpaceFactory)
const
1847 bool have_userNS =
false;
1848 if (paramList.isParameter(
"Nullspace") && !paramList.get<RCP<MultiVector> >(
"Nullspace").is_null())
1852 ParameterList newNullparams;
1854 nullSpace->SetParameterList(newNullparams);
1855 nullSpace->SetFactory(
"Nullspace", manager.
GetFactory(
"Ptent"));
1858 nullSpaceFactory = nullSpace;
1860 if (paramList.isParameter(
"restriction: scale nullspace") && paramList.get<
bool>(
"restriction: scale nullspace")) {
1862 scaledNSfactory->SetFactory(
"Nullspace",nullSpaceFactory);
1863 manager.
SetFactory(
"Scaled Nullspace",scaledNSfactory);
1871 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1874 int , std::vector<keep_pair>& )
const
1877 RCP<Factory> semicoarsenFactory = Teuchos::null;
1878 if (paramList.isParameter(
"semicoarsen: number of levels") &&
1879 paramList.get<
int>(
"semicoarsen: number of levels") > 0) {
1881 ParameterList togglePParams;
1882 ParameterList semicoarsenPParams;
1883 ParameterList linedetectionParams;
1896 linedetectionFactory->SetParameterList(linedetectionParams);
1897 semicoarsenFactory ->SetParameterList(semicoarsenPParams);
1898 togglePFactory ->SetParameterList(togglePParams);
1900 togglePFactory->AddCoarseNullspaceFactory (semicoarsenFactory);
1901 togglePFactory->AddProlongatorFactory (semicoarsenFactory);
1902 togglePFactory->AddPtentFactory (semicoarsenFactory);
1903 togglePFactory->AddCoarseNullspaceFactory (manager.
GetFactory(
"Ptent"));
1904 togglePFactory->AddProlongatorFactory (manager.
GetFactory(
"P"));
1905 togglePFactory->AddPtentFactory (manager.
GetFactory(
"Ptent"));
1907 manager.
SetFactory(
"CoarseNumZLayers", linedetectionFactory);
1908 manager.
SetFactory(
"LineDetection_Layers", linedetectionFactory);
1909 manager.
SetFactory(
"LineDetection_VertLineIds", linedetectionFactory);
1913 manager.
SetFactory(
"Nullspace", togglePFactory);
1916 if (paramList.isParameter(
"semicoarsen: number of levels")) {
1918 tf->SetFactory(
"Chosen P", manager.
GetFactory(
"P"));
1919 tf->AddCoordTransferFactory(semicoarsenFactory);
1922 coords->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1923 coords->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1924 tf->AddCoordTransferFactory(coords);
1933 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1936 int levelID, std::vector<keep_pair>& keeps)
const
1938#ifdef HAVE_MUELU_INTREPID2
1940 if (defaultList.isParameter(
"pcoarsen: schedule") && defaultList.isParameter(
"pcoarsen: element")) {
1943 auto pcoarsen_schedule = Teuchos::getArrayFromStringParameter<int>(defaultList,
"pcoarsen: schedule");
1944 auto pcoarsen_element = defaultList.get<std::string>(
"pcoarsen: element");
1946 if (levelID >= (
int)pcoarsen_schedule.size()) {
1949 UpdateFactoryManager_SA(paramList, defaultList, manager, levelID, keeps);
1953 ParameterList Pparams;
1955 std::string lo = pcoarsen_element + std::to_string(pcoarsen_schedule[levelID]);
1956 std::string hi = (levelID ? pcoarsen_element + std::to_string(pcoarsen_schedule[levelID-1]) : lo);
1957 Pparams.set(
"pcoarsen: hi basis", hi);
1958 Pparams.set(
"pcoarsen: lo basis", lo);
1959 P->SetParameterList(Pparams);
1968 ParameterList Pparams;
1972 P->SetParameterList(Pparams);
1985 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1990 ParameterList Pparams;
1991 if (paramList.isSublist(
"matrixmatrix: kernel params"))
1992 Pparams.sublist(
"matrixmatrix: kernel params",
false) = paramList.sublist(
"matrixmatrix: kernel params");
1993 if (defaultList.isSublist(
"matrixmatrix: kernel params"))
1994 Pparams.sublist(
"matrixmatrix: kernel params",
false) = defaultList.sublist(
"matrixmatrix: kernel params");
2006 P->SetParameterList(Pparams);
2010 MUELU_SET_VAR_2LIST(paramList, defaultList,
"sa: use filtered matrix",
bool, useFiltering);
2018 ParameterList fParams;
2027 filterFactory->SetParameterList(fParams);
2028 filterFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
2029 filterFactory->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
2030 filterFactory->SetFactory(
"UnAmalgamationInfo", manager.
GetFactory(
"UnAmalgamationInfo"));
2032 filterFactory->SetFactory(
"Filtering", manager.
GetFactory(
"Graph"));
2034 P->SetFactory(
"A", filterFactory);
2037 P->SetFactory(
"A", manager.
GetFactory(
"Graph"));
2041 P->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
2044 bool filteringChangesMatrix = useFiltering && !
MUELU_TEST_PARAM_2LIST(paramList, defaultList,
"aggregation: drop tol",
double, 0);
2046 if (reuseType ==
"tP" && !filteringChangesMatrix)
2047 keeps.push_back(
keep_pair(
"AP reuse data", P.get()));
2053 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2056 int , std::vector<keep_pair>& )
const
2061 "Invalid pattern name: \"" << patternType <<
"\". Valid options: \"AkPtent\"");
2064 ParameterList patternParams;
2066 patternFactory->SetParameterList(patternParams);
2067 patternFactory->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
2068 manager.
SetFactory(
"Ppattern", patternFactory);
2072 constraintFactory->SetFactory(
"Ppattern", manager.
GetFactory(
"Ppattern"));
2073 constraintFactory->SetFactory(
"CoarseNullspace", manager.
GetFactory(
"Ptent"));
2074 manager.
SetFactory(
"Constraint", constraintFactory);
2079 MUELU_SET_VAR_2LIST(paramList, defaultList,
"emin: use filtered matrix",
bool, useFiltering);
2087 ParameterList fParams;
2096 filterFactory->SetParameterList(fParams);
2097 filterFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
2098 filterFactory->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
2099 filterFactory->SetFactory(
"UnAmalgamationInfo", manager.
GetFactory(
"UnAmalgamationInfo"));
2101 filterFactory->SetFactory(
"Filtering", manager.
GetFactory(
"Graph"));
2103 P->SetFactory(
"A", filterFactory);
2106 P->SetFactory(
"A", manager.
GetFactory(
"Graph"));
2111 ParameterList Pparams;
2114 if (reuseType ==
"emin") {
2116 Pparams.set(
"Keep P0",
true);
2117 Pparams.set(
"Keep Constraint0",
true);
2119 P->SetParameterList(Pparams);
2120 P->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
2121 P->SetFactory(
"Constraint", manager.
GetFactory(
"Constraint"));
2128 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2131 int , std::vector<keep_pair>& )
const
2134 "Implicit transpose not supported with Petrov-Galerkin smoothed transfer operators: Set \"transpose: use implicit\" to false!\n" \
2135 "Petrov-Galerkin transfer operator smoothing for non-symmetric problems requires a separate handling of the restriction operator which " \
2136 "does not allow the usage of implicit transpose easily.");
2140 P->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
2147 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2153 ParameterList Pparams;
2156 P->SetParameterList(Pparams);
2165 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2168 int , std::vector<keep_pair>& )
const {
2169#ifdef HAVE_MUELU_MATLAB
2170 ParameterList Pparams = paramList.sublist(
"transfer: params");
2172 P->SetParameterList(Pparams);
2173 P->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
2181#undef MUELU_SET_VAR_2LIST
2182#undef MUELU_TEST_AND_SET_VAR
2183#undef MUELU_TEST_AND_SET_PARAM_2LIST
2184#undef MUELU_TEST_PARAM_2LIST
2185#undef MUELU_KOKKOS_FACTORY
2189 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2191 ParameterList paramList = constParamList;
2194 const int maxLevels = 100;
2197 std::vector<ParameterList> paramLists;
2198 for (
int levelID = 0; levelID < maxLevels; levelID++) {
2199 std::string sublistName =
"level " +
toString(levelID);
2200 if (paramList.isSublist(sublistName)) {
2201 paramLists.push_back(paramList.sublist(sublistName));
2203 paramList.remove(sublistName);
2206 paramLists.push_back(paramList);
2208#ifdef HAVE_MUELU_MATLAB
2210 for (
size_t i = 0; i < paramLists.size(); i++) {
2211 std::vector<std::string> customVars;
2213 for(Teuchos::ParameterList::ConstIterator it = paramLists[i].begin(); it != paramLists[i].end(); it++) {
2214 std::string paramName = paramLists[i].name(it);
2217 customVars.push_back(paramName);
2221 for (
size_t j = 0; j < customVars.size(); j++)
2222 paramLists[i].remove(customVars[j],
false);
2226 const int maxDepth = 0;
2227 for (
size_t i = 0; i < paramLists.size(); i++) {
2230 paramLists[i].validateParameters(validList, maxDepth);
2232 }
catch (
const Teuchos::Exceptions::InvalidParameterName& e) {
2233 std::string eString = e.what();
2236 size_t nameStart = eString.find_first_of(
'"') + 1;
2237 size_t nameEnd = eString.find_first_of(
'"', nameStart);
2238 std::string name = eString.substr(nameStart, nameEnd - nameStart);
2240 size_t bestScore = 100;
2241 std::string bestName =
"";
2242 for (ParameterList::ConstIterator it = validList.begin(); it != validList.end(); it++) {
2243 const std::string& pName = validList.name(it);
2244 this->GetOStream(
Runtime1) <<
"| " << pName;
2245 size_t score =
LevenshteinDistance(name.c_str(), name.length(), pName.c_str(), pName.length());
2246 this->GetOStream(
Runtime1) <<
" -> " << score << std::endl;
2247 if (score < bestScore) {
2252 if (bestScore < 10 && bestName !=
"") {
2253 TEUCHOS_TEST_FOR_EXCEPTION(
true, Teuchos::Exceptions::InvalidParameterName,
2254 eString <<
"The parameter name \"" + name +
"\" is not valid. Did you mean \"" + bestName <<
"\"?\n");
2257 TEUCHOS_TEST_FOR_EXCEPTION(
true, Teuchos::Exceptions::InvalidParameterName,
2258 eString <<
"The parameter name \"" + name +
"\" is not valid.\n");
2267 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2272 ParameterList paramList = constParamList;
2279 if (paramList.isSublist(
"Matrix")) {
2280 blockSize_ = paramList.sublist(
"Matrix").get<
int>(
"PDE equations", MasterList::getDefault<int>(
"number of equations"));
2281 dofOffset_ = paramList.sublist(
"Matrix").get<
GlobalOrdinal>(
"DOF offset", 0);
2285 if (factFact_ == Teuchos::null)
2297 if (paramList.isSublist(
"Factories"))
2298 this->BuildFactoryMap(paramList.sublist(
"Factories"), factoryMap, factoryMap, factoryManagers);
2312 if (paramList.isSublist(
"Hierarchy")) {
2313 ParameterList hieraList = paramList.sublist(
"Hierarchy");
2316 if (hieraList.isParameter(
"max levels")) {
2317 this->numDesiredLevel_ = hieraList.get<
int>(
"max levels");
2318 hieraList.remove(
"max levels");
2321 if (hieraList.isParameter(
"coarse: max size")) {
2322 this->maxCoarseSize_ = hieraList.get<
int>(
"coarse: max size");
2323 hieraList.remove(
"coarse: max size");
2326 if (hieraList.isParameter(
"repartition: rebalance P and R")) {
2327 this->doPRrebalance_ = hieraList.get<
bool>(
"repartition: rebalance P and R");
2328 hieraList.remove(
"repartition: rebalance P and R");
2331 if (hieraList.isParameter(
"transpose: use implicit")) {
2332 this->implicitTranspose_ = hieraList.get<
bool>(
"transpose: use implicit");
2333 hieraList.remove(
"transpose: use implicit");
2336 if (hieraList.isParameter(
"fuse prolongation and update")) {
2337 this->fuseProlongationAndUpdate_ = hieraList.get<
bool>(
"fuse prolongation and update");
2338 hieraList.remove(
"fuse prolongation and update");
2341 if (hieraList.isParameter(
"nullspace: suppress dimension check")) {
2342 this->suppressNullspaceDimensionCheck_ = hieraList.get<
bool>(
"nullspace: suppress dimension check");
2343 hieraList.remove(
"nullspace: suppress dimension check");
2346 if (hieraList.isParameter(
"number of vectors")) {
2347 this->numDesiredLevel_ = hieraList.get<
int>(
"number of vectors");
2348 hieraList.remove(
"number of vectors");
2351 if (hieraList.isSublist(
"matvec params"))
2352 this->matvecParams_ = Teuchos::parameterList(hieraList.sublist(
"matvec params"));
2355 if (hieraList.isParameter(
"coarse grid correction scaling factor")) {
2356 this->scalingFactor_ = hieraList.get<
double>(
"coarse grid correction scaling factor");
2357 hieraList.remove(
"coarse grid correction scaling factor");
2361 if (hieraList.isParameter(
"cycle type")) {
2362 std::map<std::string, CycleType> cycleMap;
2366 std::string cycleType = hieraList.get<std::string>(
"cycle type");
2367 TEUCHOS_TEST_FOR_EXCEPTION(cycleMap.count(cycleType) == 0,
Exceptions::RuntimeError,
"Invalid cycle type: \"" << cycleType <<
"\"");
2368 this->Cycle_ = cycleMap[cycleType];
2371 if (hieraList.isParameter(
"W cycle start level")) {
2372 this->WCycleStartLevel_ = hieraList.get<
int>(
"W cycle start level");
2375 if (hieraList.isParameter(
"verbosity")) {
2376 std::string vl = hieraList.get<std::string>(
"verbosity");
2377 hieraList.remove(
"verbosity");
2381 if (hieraList.isParameter(
"output filename"))
2384 if (hieraList.isParameter(
"dependencyOutputLevel"))
2385 this->graphOutputLevel_ = hieraList.get<
int>(
"dependencyOutputLevel");
2388 if (hieraList.isParameter(
"reuse"))
2391 if (hieraList.isSublist(
"DataToWrite")) {
2394 ParameterList foo = hieraList.sublist(
"DataToWrite");
2395 std::string dataName =
"Matrices";
2396 if (foo.isParameter(dataName))
2397 this->matricesToPrint_[
"A"] = Teuchos::getArrayFromStringParameter<int>(foo, dataName);
2398 dataName =
"Prolongators";
2399 if (foo.isParameter(dataName))
2400 this->matricesToPrint_[
"P"] = Teuchos::getArrayFromStringParameter<int>(foo, dataName);
2401 dataName =
"Restrictors";
2402 if (foo.isParameter(dataName))
2403 this->matricesToPrint_[
"R"] = Teuchos::getArrayFromStringParameter<int>(foo, dataName);
2405 if (foo.isParameter(dataName))
2406 this->matricesToPrint_[
"D0"] = Teuchos::getArrayFromStringParameter<int>(foo, dataName);
2410 for (ParameterList::ConstIterator param = hieraList.begin(); param != hieraList.end(); ++param) {
2411 const std::string & paramName = hieraList.name(param);
2413 if (paramName !=
"DataToWrite" && hieraList.isSublist(paramName)) {
2414 ParameterList levelList = hieraList.sublist(paramName);
2416 int startLevel = 0;
if(levelList.isParameter(
"startLevel")) { startLevel = levelList.get<
int>(
"startLevel"); levelList.remove(
"startLevel"); }
2417 int numDesiredLevel = 1;
if(levelList.isParameter(
"numDesiredLevel")) { numDesiredLevel = levelList.get<
int>(
"numDesiredLevel"); levelList.remove(
"numDesiredLevel"); }
2430 BuildFactoryMap(levelList, factoryMap, levelFactoryMap, factoryManagers);
2432 RCP<FactoryManager> m = rcp(
new FactoryManager(levelFactoryMap));
2433 if (hieraList.isParameter(
"use kokkos refactor"))
2434 m->SetKokkosRefactor(hieraList.get<
bool>(
"use kokkos refactor"));
2436 if (startLevel >= 0)
2437 this->AddFactoryManager(startLevel, numDesiredLevel, m);
2439 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::ParameterListInterpreter():: invalid level id");
2569 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2572 for (ParameterList::ConstIterator param = paramList.begin(); param != paramList.end(); ++param) {
2573 const std::string & paramName = paramList.name(param);
2574 const Teuchos::ParameterEntry & paramValue = paramList.entry(param);
2578 if (paramValue.isList()) {
2579 ParameterList paramList1 = Teuchos::getValue<ParameterList>(paramValue);
2580 if (paramList1.isParameter(
"factory")) {
2583 "MueLu::ParameterListInterpreter(): It seems that in the parameter lists for defining " << paramName <<
2584 " there is both a 'factory' and 'dependency for' parameter. This is not allowed. Please remove the 'dependency for' parameter.");
2586 factoryMapOut[paramName] = factFact_->BuildFactory(paramValue, factoryMapIn, factoryManagers);
2588 }
else if (paramList1.isParameter(
"dependency for")) {
2590 "MueLu::ParameterListInterpreter(): It seems that in the parameter lists for defining " << paramName <<
2591 " there is both a 'factory' and 'dependency for' parameter. This is not allowed.");
2593 std::string factoryName = paramList1.get<std::string>(
"dependency for");
2595 RCP<const FactoryBase> factbase = factoryMapIn.find(factoryName )->second;
2597 "MueLu::ParameterListInterpreter(): could not find factory " + factoryName +
" in factory map. Did you define it before?");
2599 RCP<const Factory> factoryconst = Teuchos::rcp_dynamic_cast<const Factory>(factbase);
2600 RCP< Factory> factory = Teuchos::rcp_const_cast<Factory>(factoryconst);
2603 RCP<const ParameterList> validParamList = factory->GetValidParameterList();
2604 for (ParameterList::ConstIterator vparam = validParamList->begin(); vparam != validParamList->end(); ++vparam) {
2605 const std::string& pName = validParamList->name(vparam);
2607 if (!paramList1.isParameter(pName)) {
2612 if (validParamList->isType< RCP<const FactoryBase> >(pName)) {
2614 RCP<const FactoryBase> generatingFact = factFact_->BuildFactory(paramList1.getEntry(pName), factoryMapIn, factoryManagers);
2615 factory->SetFactory(pName, generatingFact.create_weak());
2617 }
else if (validParamList->isType<RCP<const ParameterList> >(pName)) {
2618 if (pName ==
"ParameterList") {
2623 RCP<const ParameterList> subList = Teuchos::sublist(rcp(
new ParameterList(paramList1)), pName);
2624 factory->SetParameter(pName, ParameterEntry(subList));
2627 factory->SetParameter(pName, paramList1.getEntry(pName));
2631 }
else if (paramList1.isParameter(
"group")) {
2633 std::string groupType = paramList1.get<std::string>(
"group");
2635 "group must be of type \"FactoryManager\".");
2637 ParameterList groupList = paramList1;
2638 groupList.remove(
"group");
2640 bool setKokkosRefactor =
false;
2641 bool kokkosRefactor = useKokkos_;
2642 if (groupList.isParameter(
"use kokkos refactor")) {
2643 kokkosRefactor = groupList.get<
bool>(
"use kokkos refactor");
2644 groupList.remove(
"use kokkos refactor");
2645 setKokkosRefactor =
true;
2649 BuildFactoryMap(groupList, factoryMapIn, groupFactoryMap, factoryManagers);
2653 RCP<FactoryManager> m = rcp(
new FactoryManager(groupFactoryMap));
2654 if (setKokkosRefactor)
2655 m->SetKokkosRefactor(kokkosRefactor);
2656 factoryManagers[paramName] = m;
2659 this->GetOStream(
Warnings0) <<
"Could not interpret parameter list " << paramList1 << std::endl;
2661 "XML Parameter list must either be of type \"factory\" or of type \"group\".");
2665 factoryMapOut[paramName] = factFact_->BuildFactory(paramValue, factoryMapIn, factoryManagers);
2673 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2676 Matrix& A =
dynamic_cast<Matrix&
>(Op);
2677 if (A.IsFixedBlockSizeSet() && (A.GetFixedBlockSize() != blockSize_))
2678 this->GetOStream(
Warnings0) <<
"Setting matrix block size to " << blockSize_ <<
" (value of the parameter in the list) "
2679 <<
"instead of " << A.GetFixedBlockSize() <<
" (provided matrix)." << std::endl
2680 <<
"You may want to check \"number of equations\" (or \"PDE equations\" for factory style list) parameter." << std::endl;
2682 A.SetFixedBlockSize(blockSize_, dofOffset_);
2684#ifdef HAVE_MUELU_DEBUG
2685 MatrixUtils::checkLocalRowMapMatchesColMap(A);
2688 }
catch (std::bad_cast&) {
2689 this->GetOStream(
Warnings0) <<
"Skipping setting block size as the operator is not a matrix" << std::endl;
2693 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2701 static bool compare(
const ParameterList& list1,
const ParameterList& list2) {
2704 for (ParameterList::ConstIterator it = list1.begin(); it != list1.end(); it++) {
2705 const std::string& name = it->first;
2706 const Teuchos::ParameterEntry& entry1 = it->second;
2708 const Teuchos::ParameterEntry *entry2 = list2.getEntryPtr(name);
2711 if (entry1.isList() && entry2->isList()) {
2712 compare(Teuchos::getValue<ParameterList>(entry1), Teuchos::getValue<ParameterList>(*entry2));
2715 if (entry1.getAny(
false) != entry2->getAny(
false))
2722 static inline bool areSame(
const ParameterList& list1,
const ParameterList& list2) {
2728#define MUELU_PARAMETERLISTINTERPRETER_SHORT
#define MUELU_TEST_AND_SET_VAR(paramList, paramName, paramType, varName)
#define MUELU_SET_VAR_2LIST(paramList, defaultList, paramName, paramType, varName)
#define TEST_MUTUALLY_EXCLUSIVE_S(arg1, arg2)
#define MUELU_KOKKOS_FACTORY_NO_DECL(varName, oldFactory, newFactory)
#define MUELU_TEST_PARAM_2LIST(paramList, defaultList, paramName, paramType, cmpValue)
#define MUELU_KOKKOS_FACTORY(varName, oldFactory, newFactory)
#define TEST_MUTUALLY_EXCLUSIVE(arg1, arg2)
#define MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, paramName, paramType, listWrite)
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
An factory which assigns each aggregate a quality estimate. Originally developed by Napov and Notay i...
Factory to export aggregation info or visualize aggregates using VTK.
AmalgamationFactory for subblocks of strided map based amalgamation data.
Factory for generating F/C-splitting and a coarse level map. Used by ClassicalPFactory.
Factory for creating a graph based on a given matrix.
Factory for creating a graph based on a given matrix.
Factory for generating coarse level map. Used by TentativePFactory.
Factory for building the constraint operator.
Class for transferring coordinates from a finer level to a coarser one.
Factory for coarsening a graph with uncoupled aggregation.
Class that encapsulates direct solvers. Autoselection of AmesosSmoother or Amesos2Smoother according ...
Factory for building Energy Minimization prolongators.
Exception throws to report invalid user entry.
Exception throws to report errors in the internal logical of the program.
Factory that can generate other factories from.
This class specifies the default factory that should generate some data on a Level if the data does n...
void SetFactory(const std::string &varName, const RCP< const FactoryBase > &factory)
Set Factory.
const RCP< const FactoryBase > GetFactory(const std::string &varName) const
Get factory associated with a particular data name.
const RCP< FactoryBase > GetFactoryNonConst(const std::string &varName)
Get factory associated with a particular data name (NONCONST version)
static void DisableMultipleCheckGlobally()
static void EnableTimerSync()
Factory for building filtered matrices using filtered graphs.
Factory for building restriction operators using a prolongator factory.
virtual void SetupHierarchy(Hierarchy &H) const
Setup Hierarchy object.
Provides methods to build a multigrid hierarchy and apply multigrid cycles.
static CycleType GetDefaultCycle()
void SetCycleStartLevel(int cycleStart)
static int GetDefaultCycleStartLevel()
void SetCycle(CycleType Cycle)
Supports VCYCLE and WCYCLE types.
void SetProlongatorScalingFactor(double scalingFactor)
Specify damping factor alpha such that x = x + alpha*P*c, where c is the coarse grid correction.
Class for generating an initial LocalOrdinal-type BlockNumber vector, based on an input paraemter for...
Factory for building transfer operators based on coarsening in polynomial degree, following the Intre...
Factory for building line detection information.
Class for transferring a vector of local ordinals from a finer level to a coarser one,...
Factory for converting matrices to half precision operators.
static Teuchos::RCP< Teuchos::ParameterList > GetProblemSpecificList(std::string const &problemType)
Return default parameter settings for the specified problem type.
static Teuchos::RCP< const Teuchos::ParameterList > List()
Return a "master" list of all valid parameters and their default values.
static const RCP< const NoFactory > getRCP()
Static Get() functions.
Partitioning within a node only.
Factory for generating nullspace.
void UpdateFactoryManager_SA(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
void UpdateFactoryManager_Nullspace(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps, RCP< Factory > &nullSpaceFactory) const
void UpdateFactoryManager_Reitzinger(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
void UpdateFactoryManager_Smoothers(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
void UpdateFactoryManager_Aggregation_TentativeP(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
void SetEasyParameterList(const Teuchos::ParameterList ¶mList)
void UpdateFactoryManager_Coordinates(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
void BuildFactoryMap(const Teuchos::ParameterList ¶mList, const FactoryMap &factoryMapIn, FactoryMap &factoryMapOut, FactoryManagerMap &factoryManagers) const
Interpret "Factories" sublist.
void UpdateFactoryManager_Restriction(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 UpdateFactoryManager_Replicate(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
void UpdateFactoryManager_LowPrecision(ParameterList ¶mList, const ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
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.
ParameterListInterpreter()
Empty constructor.
std::pair< std::string, const FactoryBase * > keep_pair
void UpdateFactoryManager_PG(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.
void Validate(const Teuchos::ParameterList ¶mList) const
void UpdateFactoryManager_Emin(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
void UpdateFactoryManager_Matlab(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
std::map< std::string, RCP< FactoryManagerBase > > FactoryManagerMap
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
void UpdateFactoryManager_SemiCoarsen(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
void UpdateFactoryManager_BlockNumber(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
void UpdateFactoryManager(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
std::map< std::string, RCP< const FactoryBase > > FactoryMap
void SetupHierarchy(Hierarchy &H) const
Call the SetupHierarchy routine from the HiearchyManager object.
void SetFactoryParameterList(const Teuchos::ParameterList ¶mList)
Factory interpreter stuff.
void UpdateFactoryManager_CoarseSolvers(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
void UpdateFactoryManager_Repartition(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps, RCP< Factory > &nullSpaceFactory) const
Factory for building nonzero patterns for energy minimization.
Factory for building Petrov-Galerkin Smoothed Aggregation prolongators.
Factory for building coarse matrices.
Factory for building coarse grid matrices, when the matrix is of the form K+a*M. Useful when you want...
Factory for building coarse matrices.
Applies permutation to grid transfer operators.
Factory for building tentative prolongator.
Factory for building permutation matrix that can be be used to shuffle data (matrices,...
Factory for determing the number of partitions for rebalancing.
Prolongator factory that replicates 'Psubblock' matrix to create new prolongator suitable for PDE sys...
Factory for building Smoothed Aggregation prolongators.
Factory for building Smoothed Aggregation prolongators.
Factory for generating a very special nullspace.
Prolongator factory performing semi-coarsening.
Prolongator factory performing semi-coarsening.
Factory for interacting with Matlab.
Factory for creating a graph base on a given matrix.
Generic Smoother Factory for generating the smoothers of the MG hierarchy.
Factory for building tentative prolongator.
Class for transferring coordinates from a finer level to a coarser one.
Prolongator factory which allows switching between two different prolongator strategies.
Factory for building restriction operators.
Class that encapsulates external library smoothers.
Factory for interacting with Matlab.
Factory for building uncoupled aggregates.
static VerbLevel GetDefaultVerbLevel()
Get the default (global) verbosity level.
static void SetDefaultVerbLevel(const VerbLevel defaultVerbLevel)
Set the default (global) verbosity level.
static void SetMueLuOFileStream(const std::string &filename)
Interface to Zoltan2 library.
Interface to Zoltan library.
Namespace for MueLu classes and methods.
bool IsParamMuemexVariable(const std::string &name)
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.
@ Warnings0
Important warning messages (one line)
@ Runtime0
One-liner description of what is happening.
@ Runtime1
Description of what is happening (more verbose)
@ Warnings1
Additional warnings.
size_t LevenshteinDistance(const char *s, size_t len_s, const char *t, size_t len_t)
MsgType toVerbLevel(const std::string &verbLevelStr)
static bool areSame(const ParameterList &list1, const ParameterList &list2)
Helper functions to compare two paramter lists.
static bool compare(const ParameterList &list1, const ParameterList &list2)
std::string toString(const T &what)
Little helper function to convert non-string types to strings.