10#ifndef MUELU_PARAMETERLISTINTERPRETER_DEF_HPP
11#define MUELU_PARAMETERLISTINTERPRETER_DEF_HPP
13#include <Teuchos_XMLParameterListHelpers.hpp>
15#include <Xpetra_Matrix.hpp>
16#include <Xpetra_MatrixUtils.hpp>
24#include "MueLu_Hierarchy.hpp"
25#include "MueLu_FactoryManager.hpp"
27#include "MueLu_AggregationExportFactory.hpp"
28#include "MueLu_AggregateQualityEstimateFactory.hpp"
29#include "MueLu_AmalgamationFactory.hpp"
30#include "MueLu_BrickAggregationFactory.hpp"
31#include "MueLu_ClassicalMapFactory.hpp"
32#include "MueLu_ClassicalPFactory.hpp"
33#include "MueLu_CoalesceDropFactory.hpp"
34#include "MueLu_CoarseMapFactory.hpp"
35#include "MueLu_ConstraintFactory.hpp"
36#include "MueLu_CoordinatesTransferFactory.hpp"
37#include "MueLu_DirectSolver.hpp"
38#include "MueLu_EdgeProlongatorPatternFactory.hpp"
39#include "MueLu_EminPFactory.hpp"
41#include "MueLu_FacadeClassFactory.hpp"
42#include "MueLu_FactoryFactory.hpp"
43#include "MueLu_FilteredAFactory.hpp"
44#include "MueLu_GenericRFactory.hpp"
45#include "MueLu_InitialBlockNumberFactory.hpp"
46#include "MueLu_LineDetectionFactory.hpp"
47#include "MueLu_LocalOrdinalTransferFactory.hpp"
48#include "MueLu_MatrixAnalysisFactory.hpp"
49#include "MueLu_MatrixTransferFactory.hpp"
50#include "MueLu_MultiVectorTransferFactory.hpp"
51#include "MueLu_NotayAggregationFactory.hpp"
52#include "MueLu_NullspaceFactory.hpp"
53#include "MueLu_PatternFactory.hpp"
54#include "MueLu_ReplicatePFactory.hpp"
55#include "MueLu_CombinePFactory.hpp"
56#include "MueLu_PgPFactory.hpp"
57#include "MueLu_RAPFactory.hpp"
58#include "MueLu_RAPShiftFactory.hpp"
59#include "MueLu_RebalanceAcFactory.hpp"
60#include "MueLu_RebalanceTransferFactory.hpp"
61#include "MueLu_RepartitionFactory.hpp"
62#include "MueLu_RepartitionHeuristicFactory.hpp"
63#include "MueLu_ReitzingerPFactory.hpp"
64#include "MueLu_SaPFactory.hpp"
65#include "MueLu_ScaledNullspaceFactory.hpp"
66#include "MueLu_SemiCoarsenPFactory.hpp"
67#include "MueLu_SmootherFactory.hpp"
68#include "MueLu_SmooVecCoalesceDropFactory.hpp"
69#include "MueLu_TentativePFactory.hpp"
70#include "MueLu_TogglePFactory.hpp"
71#include "MueLu_ToggleCoordinatesTransferFactory.hpp"
72#include "MueLu_TransPFactory.hpp"
73#include "MueLu_UncoupledAggregationFactory.hpp"
74#include "MueLu_ZoltanInterface.hpp"
75#include "MueLu_Zoltan2Interface.hpp"
76#include "MueLu_NodePartitionInterface.hpp"
77#include "MueLu_LowPrecisionFactory.hpp"
79#include "MueLu_CoalesceDropFactory_kokkos.hpp"
80#include "MueLu_SemiCoarsenPFactory_kokkos.hpp"
81#include "MueLu_TentativePFactory_kokkos.hpp"
82#include "Teuchos_Assert.hpp"
84#ifdef HAVE_MUELU_MATLAB
85#include "../matlab/src/MueLu_MatlabSmoother_decl.hpp"
86#include "../matlab/src/MueLu_MatlabSmoother_def.hpp"
87#include "../matlab/src/MueLu_TwoLevelMatlabFactory_decl.hpp"
88#include "../matlab/src/MueLu_TwoLevelMatlabFactory_def.hpp"
89#include "../matlab/src/MueLu_SingleLevelMatlabFactory_decl.hpp"
90#include "../matlab/src/MueLu_SingleLevelMatlabFactory_def.hpp"
98#if defined(HAVE_MUELU_INTREPID2) && defined(HAVE_MUELU_EXPERIMENTAL)
99#include "MueLu_IntrepidPCoarsenFactory.hpp"
104#include <unordered_set>
108template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
110 : factFact_(factFact) {
111 SetMinvAProjectionVariables(paramList);
112 RCP<Teuchos::TimeMonitor> tM = rcp(
new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer(std::string(
"MueLu: ParameterListInterpreter (ParameterList)"))));
113 if (facadeFact == Teuchos::null)
114 facadeFact_ = Teuchos::rcp(
new FacadeClassFactory());
116 facadeFact_ = facadeFact;
118 if (paramList.isParameter(
"xml parameter file")) {
119 std::string filename = paramList.get(
"xml parameter file",
"");
120 if (filename.length() != 0) {
121 TEUCHOS_TEST_FOR_EXCEPTION(comm.is_null(), Exceptions::RuntimeError,
"xml parameter file requires a valid comm");
123 ParameterList paramList2 = paramList;
124 Teuchos::updateParametersFromXmlFileAndBroadcast(filename, Teuchos::Ptr<Teuchos::ParameterList>(¶mList2), *comm);
125 SetParameterList(paramList2);
128 SetParameterList(paramList);
132 SetParameterList(paramList);
136template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
138 : factFact_(factFact) {
139 RCP<Teuchos::TimeMonitor> tM = rcp(
new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer(std::string(
"MueLu: ParameterListInterpreter (XML)"))));
140 if (facadeFact == Teuchos::null)
145 ParameterList paramList;
146 Teuchos::updateParametersFromXmlFileAndBroadcast(xmlFileName, Teuchos::Ptr<ParameterList>(¶mList), comm);
151template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
154template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
158 scalingFactor_ = Teuchos::ScalarTraits<double>::one();
161 hierarchyLabel_ =
"";
163 if (paramList.isSublist(
"Hierarchy")) {
164 SetFactoryParameterList(paramList);
166 }
else if (paramList.isParameter(
"MueLu preconditioner") ==
true) {
167 this->GetOStream(
Runtime0) <<
"Use facade class: " << paramList.get<std::string>(
"MueLu preconditioner") << std::endl;
168 Teuchos::RCP<ParameterList> pp = facadeFact_->SetParameterList(paramList);
169 SetFactoryParameterList(*pp);
173 ParameterList serialList, nonSerialList;
176 Validate(serialList);
177 SetEasyParameterList(paramList);
179 if (paramList.isParameter(
"aggregation: strength-of-connection: matrix") && (paramList.get<std::string>(
"aggregation: strength-of-connection: matrix") ==
"MinvA") && paramList.isSublist(
"user data")) {
182 bool Minv_Supplied =
false, M_Supplied =
false, MinvA_Supplied =
false;
183 const Teuchos::ParameterList& userList = paramList.sublist(
"user data");
184 if (userList.isParameter(
"M")) M_Supplied =
true;
185 if (userList.isParameter(
"Minv")) Minv_Supplied =
true;
186 if (userList.isParameter(
"MinvA")) MinvA_Supplied =
true;
188 if (paramList.isSublist(
"project auxiliary matrices")) {
189 auto projectList = paramList.sublist(
"project auxiliary matrices");
190 TEUCHOS_TEST_FOR_EXCEPTION(projectList.isParameter(
"M") && !M_Supplied,
Exceptions::Incompatible,
"MueLu_CreateXpetraPreconditioner: Must supply M as it is listed in the project auxiliary matrices sublist");
191 TEUCHOS_TEST_FOR_EXCEPTION(projectList.isParameter(
"Minv") && (projectList.get(
"Minv",
"") ==
"NoFactory") && !Minv_Supplied,
Exceptions::Incompatible,
192 "MueLu_CreateXpetraPreconditioner: Must supply Minv as NoFactory is listed as supplier of Minv in the project auxiliary matrices sublist");
193 TEUCHOS_TEST_FOR_EXCEPTION(projectList.isParameter(
"MinvA") && (projectList.get(
"MinvA",
"") ==
"NoFactory") && !MinvA_Supplied,
Exceptions::Incompatible,
194 "MueLu_CreateXpetraPreconditioner: Must supply MinvA as NoFactory is listed as supplier of MinvA in the project auxiliary matrices sublist");
196 TEUCHOS_TEST_FOR_EXCEPTION(!M_Supplied && !Minv_Supplied,
Exceptions::Incompatible,
"MueLu_CreateXpetraPreconditioner: Must supply M or Minv when 'aggregation: strength-of-connection: matrix'= MinvA and sublist('project auxiliary matrices') not supplied.");
205static inline bool areSame(
const ParameterList& list1,
const ParameterList& list2);
210template <
class paramType>
211static inline paramType
set_var_2list(
const Teuchos::ParameterList& paramList,
const Teuchos::ParameterList& defaultList,
const std::string& paramName) {
212 if (paramList.isParameter(paramName))
213 return paramList.get<paramType>(paramName);
214 else if (defaultList.isParameter(paramName))
215 return defaultList.get<paramType>(paramName);
217 return MasterList::getDefault<paramType>(paramName);
220template <
class paramType>
221static inline bool test_and_set_var(
const Teuchos::ParameterList& paramList,
const std::string& paramName, paramType& varName) {
222 if (paramList.isParameter(paramName)) {
223 varName = paramList.get<paramType>(paramName);
229template <
class paramType>
230static inline void test_and_set_param_2list(
const Teuchos::ParameterList& paramList,
const Teuchos::ParameterList& defaultList,
const std::string& paramName, Teuchos::ParameterList& listWrite) {
232 if (paramList.isParameter(paramName))
233 listWrite.set(paramName, paramList.get<paramType>(paramName));
234 else if (defaultList.isParameter(paramName))
235 listWrite.set(paramName, defaultList.get<paramType>(paramName));
236 }
catch (Teuchos::Exceptions::InvalidParameterType&) {
237 TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(
true, Teuchos::Exceptions::InvalidParameterType,
238 "Error: parameter \"" << paramName <<
"\" must be of type " << Teuchos::TypeNameTraits<paramType>::name());
242template <
class paramType>
244 if (!paramList.isParameter(paramName)) {
245 paramList.set(paramName, MasterList::getDefault<paramType>(paramName));
249template <
class paramType>
250static inline bool test_param_2list(
const Teuchos::ParameterList& paramList,
const Teuchos::ParameterList& defaultList,
const std::string& paramName,
const paramType& cmpValue) {
251 return (cmpValue == set_var_2list<paramType>(paramList, defaultList, paramName));
254#define MUELU_KOKKOS_FACTORY(varName, oldFactory, newFactory) \
255 RCP<Factory> varName; \
257 varName = rcp(new oldFactory()); \
259 varName = rcp(new newFactory());
260#define MUELU_KOKKOS_FACTORY_NO_DECL(varName, oldFactory, newFactory) \
262 varName = rcp(new oldFactory()); \
264 varName = rcp(new newFactory());
266template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
268 needCoordinates(
const Teuchos::ParameterList& paramList, Teuchos::RCP<const Teuchos::ParameterList> defaultList,
int maxLevel) {
269 if (defaultList.is_null())
270 defaultList = Teuchos::rcpFromRef(paramList);
272 bool useCoordinates_ =
false;
274 if (paramList.isSublist(
"Hierarchy")) {
275 useCoordinates_ =
true;
278 if (test_param_2list<std::string>(paramList, *defaultList,
"aggregation: strength-of-connection: matrix",
"distance laplacian"))
279 useCoordinates_ =
true;
280 if (test_param_2list<std::string>(paramList, *defaultList,
"aggregation: drop scheme",
"distance laplacian") ||
281 test_param_2list<std::string>(paramList, *defaultList,
"aggregation: type",
"brick") ||
282 test_param_2list<bool>(paramList, *defaultList,
"aggregation: export visualization data",
true)) {
283 useCoordinates_ =
true;
284 }
else if (test_param_2list<std::string>(paramList, *defaultList,
"aggregation: drop scheme",
"block diagonal distance laplacian")) {
285 useCoordinates_ =
true;
289 if (test_param_2list<bool>(paramList, *defaultList,
"nullspace: calculate rotations",
true))
290 useCoordinates_ =
true;
293 if (paramList.isSublist(
"smoother: params")) {
294 const auto smooParamList = paramList.sublist(
"smoother: params");
295 if (smooParamList.isParameter(
"partitioner: type") &&
296 (smooParamList.get<std::string>(
"partitioner: type") ==
"line")) {
297 useCoordinates_ =
true;
302 if (test_param_2list<bool>(paramList, *defaultList,
"repartition: enable",
true)) {
304 if (test_param_2list<bool>(paramList, *defaultList,
"repartition: use subcommunicators",
true) &&
305 test_param_2list<bool>(paramList, *defaultList,
"repartition: use subcommunicators in place",
true)) {
307 }
else if (!paramList.isSublist(
"repartition: params")) {
308 useCoordinates_ =
true;
310 const ParameterList& repParams = paramList.sublist(
"repartition: params");
311 if (repParams.isType<std::string>(
"algorithm")) {
312 const std::string algo = repParams.get<std::string>(
"algorithm");
313 if (algo ==
"multijagged" || algo ==
"rcb") {
314 useCoordinates_ =
true;
317 useCoordinates_ =
true;
323 if ((!useCoordinates_) && (maxLevel > 0)) {
324 for (
int levelID = 0; levelID < maxLevel; levelID++) {
325 std::string levelStr =
"level " +
toString(levelID);
327 if (paramList.isSublist(levelStr)) {
328 const ParameterList& levelList = paramList.sublist(levelStr);
330 useCoordinates_ |= needCoordinates(levelList, Teuchos::rcpFromRef(paramList), 0);
336 return useCoordinates_;
339template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
341 if (defaultList.is_null())
342 defaultList = Teuchos::rcpFromRef(paramList);
344 bool useBlockNumber_ =
false;
346 if (paramList.isSublist(
"Hierarchy")) {
347 useBlockNumber_ =
true;
349 if (test_param_2list<bool>(paramList, *defaultList,
"aggregation: use blocking",
true))
350 useBlockNumber_ =
true;
351 if (test_param_2list<std::string>(paramList, *defaultList,
"aggregation: drop scheme",
"block diagonal distance laplacian")) {
352 useBlockNumber_ =
true;
353 }
else if (test_param_2list<std::string>(paramList, *defaultList,
"aggregation: drop scheme",
"block diagonal") ||
354 test_param_2list<std::string>(paramList, *defaultList,
"aggregation: drop scheme",
"block diagonal classical") ||
355 test_param_2list<std::string>(paramList, *defaultList,
"aggregation: drop scheme",
"block diagonal signed classical") ||
356 test_param_2list<std::string>(paramList, *defaultList,
"aggregation: drop scheme",
"block diagonal colored signed classical") ||
357 test_param_2list<std::string>(paramList, *defaultList,
"aggregation: drop scheme",
"signed classical")) {
358 useBlockNumber_ =
true;
362 if ((!useBlockNumber_) && (maxLevel > 0)) {
363 for (
int levelID = 0; levelID < maxLevel; levelID++) {
364 std::string levelStr =
"level " +
toString(levelID);
366 if (paramList.isSublist(levelStr)) {
367 const ParameterList& levelList = paramList.sublist(levelStr);
369 useBlockNumber_ |= needBlockNumber(levelList, Teuchos::rcpFromRef(paramList), 0);
375 return useBlockNumber_;
378template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
380 needMaterial(
const Teuchos::ParameterList& paramList, Teuchos::RCP<const Teuchos::ParameterList> defaultList,
int maxLevel) {
381 if (defaultList.is_null())
382 defaultList = Teuchos::rcpFromRef(paramList);
384 bool useMaterial_ =
false;
386 if (paramList.isSublist(
"Hierarchy")) {
390 if (test_param_2list<std::string>(paramList, *defaultList,
"aggregation: distance laplacian metric",
"material")) {
395 if ((!useMaterial_) && (maxLevel > 0)) {
396 for (
int levelID = 0; levelID < maxLevel; levelID++) {
397 std::string levelStr =
"level " +
toString(levelID);
399 if (paramList.isSublist(levelStr)) {
400 const ParameterList& levelList = paramList.sublist(levelStr);
402 useMaterial_ |= needMaterial(levelList, Teuchos::rcpFromRef(paramList), 0);
411template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
413 needMass(
const Teuchos::ParameterList& paramList, Teuchos::RCP<const Teuchos::ParameterList> defaultList,
int maxLevel) {
414 if (defaultList.is_null())
415 defaultList = Teuchos::rcpFromRef(paramList);
417 bool useMass_ =
false;
419 if (paramList.isSublist(
"Hierarchy")) {
423 if (test_param_2list<std::string>(paramList, *defaultList,
"aggregation: strength-of-connection: matrix",
"MinvA")) {
428 if ((!useMass_) && (maxLevel > 0)) {
429 for (
int levelID = 0; levelID < maxLevel; levelID++) {
430 std::string levelStr =
"level " +
toString(levelID);
432 if (paramList.isSublist(levelStr)) {
433 const ParameterList& levelList = paramList.sublist(levelStr);
435 useMass_ |= needMass(levelList, Teuchos::rcpFromRef(paramList), 0);
444template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
446 requiredAndOptionalUserData(
const Teuchos::ParameterList& paramList, Teuchos::RCP<const Teuchos::ParameterList> defaultList,
int maxLevel) {
447 std::set<std::string> requiredUserData;
448 if (needCoordinates(paramList, Teuchos::null, maxLevel))
449 requiredUserData.insert(
"Coordinates");
450 if (needBlockNumber(paramList, Teuchos::null, maxLevel))
451 requiredUserData.insert(
"BlockNumber");
452 if (needMaterial(paramList, Teuchos::null, maxLevel))
453 requiredUserData.insert(
"Material");
455 std::set<std::string> optionalUserData;
456 optionalUserData.insert(
"Nullspace");
457 optionalUserData.insert(
"M");
458 optionalUserData.insert(
"Minv");
459 optionalUserData.insert(
"MinvA");
461 optionalUserData.insert(
"pcoarsen: element to node map");
462 optionalUserData.insert(
"Node Comm");
463 optionalUserData.insert(
"DualNodeID2PrimalNodeID");
464 optionalUserData.insert(
"Primal interface DOF map");
465 optionalUserData.insert(
"dropMap1");
466 optionalUserData.insert(
"dropMap2");
468 return std::make_pair(requiredUserData, optionalUserData);
471template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
474 ParameterList paramList;
476 projectMinv_ =
false;
477 projectMinvA_ =
true;
478 if (constParamList.isSublist(
"project auxiliary matrices")) {
479 auto projectList = constParamList.sublist(
"project auxiliary matrices");
481 if (projectList.isParameter(
"M")) {
483 projectMinv_ =
false;
484 projectMinvA_ =
false;
486 if (projectList.isParameter(
"Minv")) {
489 projectMinvA_ =
false;
491 if (projectList.isParameter(
"MinvA")) {
492 projectMinvA_ =
true;
498 projectMinv_ =
false;
499 projectMinvA_ =
true;
502template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
505 ParameterList paramList;
507 auto problemType = set_var_2list<std::string>(constParamList, constParamList,
"problem: type");
508 if (problemType !=
"unknown") {
510 paramList.setParameters(constParamList);
514 paramList = constParamList;
518 useKokkos_ = !Node::is_serial;
519 (void)test_and_set_var<bool>(paramList,
"use kokkos refactor", useKokkos_);
522 auto syncTimers = set_var_2list<bool>(paramList, paramList,
"synchronize factory timers");
527 if (paramList.isParameter(
"cycle type")) {
528 std::map<std::string, CycleType> cycleMap;
532 auto cycleType = paramList.get<std::string>(
"cycle type");
534 "Invalid cycle type: \"" << cycleType <<
"\"");
535 Cycle_ = cycleMap[cycleType];
538 if (paramList.isParameter(
"W cycle start level")) {
539 WCycleStartLevel_ = paramList.get<
int>(
"W cycle start level");
542 if (paramList.isParameter(
"hierarchy label")) {
543 this->hierarchyLabel_ = paramList.get<std::string>(
"hierarchy label");
546 if (paramList.isParameter(
"coarse grid correction scaling factor"))
547 scalingFactor_ = paramList.get<
double>(
"coarse grid correction scaling factor");
549 this->maxCoarseSize_ = paramList.get<
int>(
"coarse: max size", MasterList::getDefault<int>(
"coarse: max size"));
550 this->numDesiredLevel_ = paramList.get<
int>(
"max levels", MasterList::getDefault<int>(
"max levels"));
551 blockSize_ = paramList.get<
int>(
"number of equations", MasterList::getDefault<int>(
"number of equations"));
553 (void)test_and_set_var<int>(paramList,
"debug: graph level", this->graphOutputLevel_);
556 if (paramList.isParameter(
"keep data"))
557 this->dataToKeep_ = Teuchos::getArrayFromStringParameter<std::string>(paramList,
"keep data");
560 if (paramList.isSublist(
"export data")) {
561 ParameterList printList = paramList.sublist(
"export data");
564 if (printList.isParameter(
"Nullspace"))
565 this->nullspaceToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"Nullspace");
566 if (printList.isParameter(
"Coordinates"))
567 this->coordinatesToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"Coordinates");
568 if (printList.isParameter(
"Material"))
569 this->materialToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"Material");
570 if (printList.isParameter(
"Aggregates"))
571 this->aggregatesToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"Aggregates");
572 if (printList.isParameter(
"pcoarsen: element to node map"))
573 this->elementToNodeMapsToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"pcoarsen: element to node map");
576 for (
auto iter = printList.begin(); iter != printList.end(); iter++) {
577 const std::string& name = printList.name(iter);
579 if (name ==
"Nullspace" || name ==
"Coordinates" || name ==
"Material" || name ==
"Aggregates" || name ==
"pcoarsen: element to node map")
582 this->matricesToPrint_[name] = Teuchos::getArrayFromStringParameter<int>(printList, name);
589 auto verbosityLevel = set_var_2list<std::string>(paramList, paramList,
"verbosity");
594 auto outputFilename = set_var_2list<std::string>(paramList, paramList,
"output filename");
595 if (outputFilename !=
"")
605 useCoordinates_ = needCoordinates(paramList, Teuchos::null, this->numDesiredLevel_);
606 useBlockNumber_ = needBlockNumber(paramList, Teuchos::null, this->numDesiredLevel_);
607 useMaterial_ = needMaterial(paramList, Teuchos::null, this->numDesiredLevel_);
610 changedPRrebalance_ =
false;
611 changedPRViaCopyrebalance_ =
false;
612 if (test_param_2list<bool>(paramList, paramList,
"repartition: enable",
true)) {
613 changedPRrebalance_ = test_and_set_var<bool>(paramList,
"repartition: rebalance P and R", this->doPRrebalance_);
614 changedPRViaCopyrebalance_ = test_and_set_var<bool>(paramList,
"repartition: explicit via new copy rebalance P and R", this->doPRViaCopyrebalance_);
618 changedImplicitTranspose_ = test_and_set_var<bool>(paramList,
"transpose: use implicit", this->implicitTranspose_);
621 (void)test_and_set_var<bool>(paramList,
"fuse prolongation and update", this->fuseProlongationAndUpdate_);
624 (void)test_and_set_var<bool>(paramList,
"nullspace: suppress dimension check", this->suppressNullspaceDimensionCheck_);
626 if (paramList.isSublist(
"matvec params"))
627 this->matvecParams_ = Teuchos::parameterList(paramList.sublist(
"matvec params"));
632 defaultManager->SetVerbLevel(this->verbosity_);
633 defaultManager->SetKokkosRefactor(useKokkos_);
636 std::vector<keep_pair> keeps0;
637 UpdateFactoryManager(paramList, ParameterList(), *defaultManager, 0 , keeps0);
643 for (
int levelID = 0; levelID < this->numDesiredLevel_; levelID++) {
649 RCP<FactoryManager> levelManager = rcp(
new FactoryManager(*defaultManager));
650 levelManager->SetVerbLevel(defaultManager->GetVerbLevel());
652 std::vector<keep_pair> keeps;
653 if (paramList.isSublist(
"level " +
toString(levelID))) {
655 ParameterList& levelList = paramList.sublist(
"level " +
toString(levelID),
true );
656 UpdateFactoryManager(levelList, paramList, *levelManager, levelID, keeps);
659 ParameterList levelList;
660 UpdateFactoryManager(levelList, paramList, *levelManager, levelID, keeps);
663 this->keep_[levelID] = keeps;
664 this->AddFactoryManager(levelID, 1, levelManager);
673 if (test_param_2list<bool>(paramList, paramList,
"print initial parameters",
true))
674 this->GetOStream(
static_cast<MsgType>(
Runtime1), 0) << paramList << std::endl;
676 if (test_param_2list<bool>(paramList, paramList,
"print unused parameters",
true)) {
678 ParameterList unusedParamList;
681 for (ParameterList::ConstIterator it = paramList.begin(); it != paramList.end(); it++) {
682 const ParameterEntry& entry = paramList.entry(it);
684 if (!entry.isList() && !entry.isUsed())
685 unusedParamList.setEntry(paramList.name(it), entry);
689 for (
int levelID = 0; levelID < this->numDesiredLevel_; levelID++) {
690 std::string levelStr =
"level " +
toString(levelID);
692 if (paramList.isSublist(levelStr)) {
693 const ParameterList& levelList = paramList.sublist(levelStr);
695 for (ParameterList::ConstIterator itr = levelList.begin(); itr != levelList.end(); ++itr) {
696 const ParameterEntry& entry = levelList.entry(itr);
698 if (!entry.isList() && !entry.isUsed())
699 unusedParamList.sublist(levelStr).setEntry(levelList.name(itr), entry);
704 if (unusedParamList.numParams() > 0) {
705 std::ostringstream unusedParamsStream;
707 unusedParamList.print(unusedParamsStream, indent);
709 this->GetOStream(
Warnings1) <<
"The following parameters were not used:\n"
710 << unusedParamsStream.str() << std::endl;
720template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
723 int levelID, std::vector<keep_pair>& keeps)
const {
727 using strings = std::unordered_set<std::string>;
730 if (paramList.numParams() == 0 && defaultList.numParams() > 0)
731 paramList = ParameterList(defaultList);
733 auto reuseType = set_var_2list<std::string>(paramList, defaultList,
"reuse: type");
734 TEUCHOS_TEST_FOR_EXCEPTION(strings({
"none",
"tP",
"RP",
"emin",
"RAP",
"full",
"S"}).count(reuseType) == 0,
737 auto multigridAlgo = set_var_2list<std::string>(paramList, defaultList,
"multigrid algorithm");
738 TEUCHOS_TEST_FOR_EXCEPTION(strings({
"unsmoothed",
"sa",
"pg",
"emin",
"matlab",
"pcoarsen",
"classical",
"smoothed reitzinger",
"unsmoothed reitzinger",
"emin reitzinger",
"replicate",
"combine"}).count(multigridAlgo) == 0,
739 Exceptions::RuntimeError,
"Unknown \"multigrid algorithm\" value: \"" << multigridAlgo <<
"\". Please consult User's Guide.");
740#ifndef HAVE_MUELU_MATLAB
742 "Cannot use matlab for multigrid algorithm - MueLu was not configured with MATLAB support.");
744#ifndef HAVE_MUELU_INTREPID2
746 "Cannot use IntrepidPCoarsen prolongator factory - MueLu was not configured with Intrepid support.");
751 if (reuseType ==
"none" || reuseType ==
"S" || reuseType ==
"RP" || reuseType ==
"RAP") {
754 }
else if (reuseType ==
"tP" && (multigridAlgo !=
"sa" && multigridAlgo !=
"unsmoothed")) {
756 this->GetOStream(
Warnings0) <<
"Ignoring \"tP\" reuse option as it is only compatible with \"sa\", "
757 "or \"unsmoothed\" multigrid algorithms"
760 }
else if (reuseType ==
"emin" && multigridAlgo !=
"emin") {
762 this->GetOStream(
Warnings0) <<
"Ignoring \"emin\" reuse option it is only compatible with "
763 "\"emin\" multigrid algorithm"
769 bool have_userP =
false;
770 if (paramList.isParameter(
"P") && !paramList.get<RCP<Matrix>>(
"P").is_null())
774 UpdateFactoryManager_CoarseSolvers(paramList, defaultList, manager, levelID, keeps);
777 UpdateFactoryManager_Smoothers(paramList, defaultList, manager, levelID, keeps);
781 UpdateFactoryManager_BlockNumber(paramList, defaultList, manager, levelID, keeps);
784 if (multigridAlgo ==
"unsmoothed reitzinger" || multigridAlgo ==
"smoothed reitzinger")
785 UpdateFactoryManager_Reitzinger(paramList, defaultList, manager, levelID, keeps);
786 else if (multigridAlgo ==
"emin reitzinger")
787 UpdateFactoryManager_EminReitzinger(paramList, defaultList, manager, levelID, keeps);
789 UpdateFactoryManager_Aggregation_TentativeP(paramList, defaultList, manager, levelID, keeps);
792 RCP<Factory> nullSpaceFactory;
793 UpdateFactoryManager_Nullspace(paramList, defaultList, manager, levelID, keeps, nullSpaceFactory);
804 }
else if (multigridAlgo ==
"unsmoothed" || multigridAlgo ==
"unsmoothed reitzinger") {
808 }
else if (multigridAlgo ==
"classical") {
812 }
else if (multigridAlgo ==
"sa" || multigridAlgo ==
"smoothed reitzinger") {
814 UpdateFactoryManager_SA(multigridAlgo, paramList, defaultList, manager, levelID, keeps);
816 }
else if (multigridAlgo ==
"emin") {
818 UpdateFactoryManager_Emin(paramList, defaultList, manager, levelID, keeps);
820 }
else if (multigridAlgo ==
"emin reitzinger") {
823 }
else if (multigridAlgo ==
"replicate") {
824 UpdateFactoryManager_Replicate(paramList, defaultList, manager, levelID, keeps);
826 }
else if (multigridAlgo ==
"combine") {
827 UpdateFactoryManager_Combine(paramList, defaultList, manager, levelID, keeps);
829 }
else if (multigridAlgo ==
"pg") {
831 UpdateFactoryManager_PG(paramList, defaultList, manager, levelID, keeps);
833 }
else if (multigridAlgo ==
"matlab") {
835 UpdateFactoryManager_Matlab(paramList, defaultList, manager, levelID, keeps);
837 }
else if (multigridAlgo ==
"pcoarsen") {
839 UpdateFactoryManager_PCoarsen(paramList, defaultList, manager, levelID, keeps);
843 UpdateFactoryManager_SemiCoarsen(paramList, defaultList, manager, levelID, keeps);
846 UpdateFactoryManager_Restriction(paramList, defaultList, manager, levelID, keeps);
849 UpdateFactoryManager_RAP(paramList, defaultList, manager, levelID, keeps);
851 if (multigridAlgo ==
"smoothed reitzinger") {
853 auto saDampingFactor = set_var_2list<double>(paramList, defaultList,
"sa: damping factor");
854 if (saDampingFactor != 0.0)
855 UpdateFactoryManager_MatrixTransfer(
"CurlCurl", paramList, defaultList, manager, levelID, keeps);
859 UpdateFactoryManager_LocalOrdinalTransfer(
"BlockNumber", multigridAlgo, paramList, defaultList, manager, levelID, keeps);
862 UpdateFactoryManager_Coordinates(paramList, defaultList, manager, levelID, keeps);
865 UpdateFactoryManager_Material(paramList, defaultList, manager, levelID, keeps);
868 if ((reuseType ==
"RP" || reuseType ==
"RAP" || reuseType ==
"full") && levelID)
871 if (reuseType ==
"RP" && levelID) {
873 if (!this->implicitTranspose_)
876 if ((reuseType ==
"tP" || reuseType ==
"RP" || reuseType ==
"emin") && useCoordinates_ && levelID)
880 UpdateFactoryManager_Repartition(paramList, defaultList, manager, levelID, keeps, nullSpaceFactory);
883 auto socMatrix = set_var_2list<std::string>(paramList, defaultList,
"aggregation: strength-of-connection: matrix");
884 if (socMatrix ==
"MinvA") {
893 std::string MinvFactory =
"CoalesceDrop";
894 std::string MinvAFactory =
"CoalesceDrop";
895 if (paramList.isSublist(
"project auxiliary matrices")) {
896 auto projectList = paramList.sublist(
"project auxiliary matrices");
897 if (projectList.isParameter(
"M")) {
898 TEUCHOS_TEST_FOR_EXCEPTION(projectList.get(
"M",
"") !=
"NoFactory",
Exceptions::InvalidArgument,
"Must specify \"NoFactory\" when projecting M");
900 if (projectList.isParameter(
"Minv")) {
901 MinvFactory = projectList.get(
"Minv",
"");
902 TEUCHOS_TEST_FOR_EXCEPTION((MinvFactory !=
"NoFactory") && (MinvFactory !=
"CoalesceDrop"),
Exceptions::InvalidArgument,
"Must specify \"NoFactory\" or \"CoalesceDrop\"");
904 if (projectList.isParameter(
"MinvA")) {
905 MinvAFactory = projectList.get(
"MinvA",
"");
906 TEUCHOS_TEST_FOR_EXCEPTION((MinvAFactory !=
"NoFactory") && (MinvAFactory !=
"CoalesceDrop"),
Exceptions::InvalidArgument,
"Must specify \"NoFactory\" or \"CoalesceDrop\"");
919 if (projectM_) UpdateFactoryManager_MatrixTransfer(
"M", paramList, defaultList, manager, levelID, keeps);
921 if (!projectM_ && !projectMinv_ && (MinvAFactory ==
"CoalesceDrop") && projectMinvA_ && (levelID == 0)) {
926 if ((levelID > 0) || (MinvAFactory ==
"NoFactory"))
927 UpdateFactoryManager_MatrixTransfer(
"MinvA", paramList, defaultList, manager, levelID, keeps);
934 if ((levelID > 0) || (MinvFactory ==
"NoFactory"))
935 UpdateFactoryManager_MatrixTransfer(
"Minv", paramList, defaultList, manager, levelID, keeps);
944 UpdateFactoryManager_LowPrecision(paramList, defaultList, manager, levelID, keeps);
947 if ((reuseType ==
"RAP" || reuseType ==
"full") && levelID) {
949 if (!this->implicitTranspose_)
962template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
965 FactoryManager& manager,
int levelID, std::vector<keep_pair>& keeps)
const {
966 auto multigridAlgo = set_var_2list<std::string>(paramList, defaultList,
"multigrid algorithm");
967 auto reuseType = set_var_2list<std::string>(paramList, defaultList,
"reuse: type");
968 auto useMaxAbsDiagonalScaling = set_var_2list<bool>(paramList, defaultList,
"sa: use rowsumabs diagonal scaling");
972 bool isCustomSmoother =
973 paramList.isParameter(
"smoother: pre or post") ||
974 paramList.isParameter(
"smoother: type") || paramList.isParameter(
"smoother: pre type") || paramList.isParameter(
"smoother: post type") ||
975 paramList.isSublist(
"smoother: params") || paramList.isSublist(
"smoother: pre params") || paramList.isSublist(
"smoother: post params") ||
976 paramList.isParameter(
"smoother: sweeps") || paramList.isParameter(
"smoother: pre sweeps") || paramList.isParameter(
"smoother: post sweeps") ||
977 paramList.isParameter(
"smoother: overlap") || paramList.isParameter(
"smoother: pre overlap") || paramList.isParameter(
"smoother: post overlap");
979 auto PreOrPost = set_var_2list<std::string>(paramList, defaultList,
"smoother: pre or post");
981 manager.
SetFactory(
"Smoother", Teuchos::null);
983 }
else if (isCustomSmoother) {
987#define TEST_MUTUALLY_EXCLUSIVE(arg1, arg2) \
988 TEUCHOS_TEST_FOR_EXCEPTION(paramList.isParameter(#arg1) && paramList.isParameter(#arg2), \
989 Exceptions::InvalidArgument, "You cannot specify both \"" #arg1 "\" and \"" #arg2 "\"");
990#define TEST_MUTUALLY_EXCLUSIVE_S(arg1, arg2) \
991 TEUCHOS_TEST_FOR_EXCEPTION(paramList.isSublist(#arg1) && paramList.isSublist(#arg2), \
992 Exceptions::InvalidArgument, "You cannot specify both \"" #arg1 "\" and \"" #arg2 "\"");
1002 TEUCHOS_TEST_FOR_EXCEPTION(
PreOrPost ==
"both" && (paramList.isParameter(
"smoother: pre type") != paramList.isParameter(
"smoother: post type")),
1007 ParameterList defaultSmootherParams;
1008 defaultSmootherParams.set(
"relaxation: type",
"Symmetric Gauss-Seidel");
1009 defaultSmootherParams.set(
"relaxation: sweeps", Teuchos::OrdinalTraits<LO>::one());
1010 defaultSmootherParams.set(
"relaxation: damping factor", Teuchos::ScalarTraits<Scalar>::one());
1012 RCP<SmootherFactory> preSmoother = Teuchos::null, postSmoother = Teuchos::null;
1013 std::string preSmootherType, postSmootherType;
1014 ParameterList preSmootherParams, postSmootherParams;
1016 auto setChebyshevSettings = [&](
const std::string& smootherType, Teuchos::ParameterList& smootherParams) {
1017 auto upperCaseSmootherType = smootherType;
1018 std::transform(smootherType.begin(), smootherType.end(), upperCaseSmootherType.begin(), ::toupper);
1019 if (upperCaseSmootherType !=
"CHEBYSHEV")
return;
1021 if (smootherParams.isParameter(
"chebyshev: use rowsumabs diagonal scaling")) {
1022 bool useMaxAbsDiagonalScalingCheby = smootherParams.get<
bool>(
"chebyshev: use rowsumabs diagonal scaling");
1023 TEUCHOS_TEST_FOR_EXCEPTION(useMaxAbsDiagonalScaling != useMaxAbsDiagonalScalingCheby,
1024 Exceptions::RuntimeError,
"'chebyshev: use rowsumabs diagonal scaling' (" << std::boolalpha << useMaxAbsDiagonalScalingCheby <<
") must match 'sa: use rowsumabs diagonal scaling' (" << std::boolalpha << useMaxAbsDiagonalScaling <<
")\n");
1026 if (useMaxAbsDiagonalScaling)
1027 smootherParams.set(
"chebyshev: use rowsumabs diagonal scaling", useMaxAbsDiagonalScaling);
1031 if (paramList.isParameter(
"smoother: overlap"))
1032 overlap = paramList.get<
int>(
"smoother: overlap");
1035 if (paramList.isParameter(
"smoother: pre type")) {
1036 preSmootherType = paramList.get<std::string>(
"smoother: pre type");
1038 auto preSmootherTypeTmp = set_var_2list<std::string>(paramList, defaultList,
"smoother: type");
1039 preSmootherType = preSmootherTypeTmp;
1041 if (paramList.isParameter(
"smoother: pre overlap"))
1042 overlap = paramList.get<
int>(
"smoother: pre overlap");
1044 if (paramList.isSublist(
"smoother: pre params"))
1045 preSmootherParams = paramList.sublist(
"smoother: pre params");
1046 else if (paramList.isSublist(
"smoother: params"))
1047 preSmootherParams = paramList.sublist(
"smoother: params");
1048 else if (defaultList.isSublist(
"smoother: params"))
1049 preSmootherParams = defaultList.sublist(
"smoother: params");
1050 else if (preSmootherType ==
"RELAXATION")
1051 preSmootherParams = defaultSmootherParams;
1053 setChebyshevSettings(preSmootherType, preSmootherParams);
1055#if defined(HAVE_MUELU_INTREPID2) && defined(HAVE_MUELU_EXPERIMENTAL)
1057 if (multigridAlgo ==
"pcoarsen" && preSmootherType ==
"TOPOLOGICAL" &&
1058 defaultList.isParameter(
"pcoarsen: schedule") && defaultList.isParameter(
"pcoarsen: element")) {
1061 auto pcoarsen_schedule = Teuchos::getArrayFromStringParameter<int>(defaultList,
"pcoarsen: schedule");
1062 auto pcoarsen_element = defaultList.get<std::string>(
"pcoarsen: element");
1064 if (levelID < (
int)pcoarsen_schedule.size()) {
1066 auto lo = pcoarsen_element + std::to_string(pcoarsen_schedule[levelID]);
1067 preSmootherParams.set(
"pcoarsen: hi basis", lo);
1072#ifdef HAVE_MUELU_MATLAB
1073 if (preSmootherType ==
"matlab")
1077#ifdef HAVE_MUELU_TEKO
1078 if (preSmootherType ==
"teko")
1086 if (paramList.isParameter(
"smoother: post type"))
1087 postSmootherType = paramList.get<std::string>(
"smoother: post type");
1089 auto postSmootherTypeTmp = set_var_2list<std::string>(paramList, defaultList,
"smoother: type");
1090 postSmootherType = postSmootherTypeTmp;
1093 if (paramList.isSublist(
"smoother: post params"))
1094 postSmootherParams = paramList.sublist(
"smoother: post params");
1095 else if (paramList.isSublist(
"smoother: params"))
1096 postSmootherParams = paramList.sublist(
"smoother: params");
1097 else if (defaultList.isSublist(
"smoother: params"))
1098 postSmootherParams = defaultList.sublist(
"smoother: params");
1099 else if (postSmootherType ==
"RELAXATION")
1100 postSmootherParams = defaultSmootherParams;
1101 if (paramList.isParameter(
"smoother: post overlap"))
1102 overlap = paramList.get<
int>(
"smoother: post overlap");
1104 setChebyshevSettings(postSmootherType, postSmootherParams);
1106 if (postSmootherType == preSmootherType &&
areSame(preSmootherParams, postSmootherParams))
1107 postSmoother = preSmoother;
1109#if defined(HAVE_MUELU_INTREPID2) && defined(HAVE_MUELU_EXPERIMENTAL)
1111 if (multigridAlgo ==
"pcoarsen" && preSmootherType ==
"TOPOLOGICAL" &&
1112 defaultList.isParameter(
"pcoarsen: schedule") && defaultList.isParameter(
"pcoarsen: element")) {
1115 auto pcoarsen_schedule = Teuchos::getArrayFromStringParameter<int>(defaultList,
"pcoarsen: schedule");
1116 auto pcoarsen_element = defaultList.get<std::string>(
"pcoarsen: element");
1118 if (levelID < (
int)pcoarsen_schedule.size()) {
1120 auto lo = pcoarsen_element + std::to_string(pcoarsen_schedule[levelID]);
1121 postSmootherParams.set(
"pcoarsen: hi basis", lo);
1126#ifdef HAVE_MUELU_MATLAB
1127 if (postSmootherType ==
"matlab")
1131#ifdef HAVE_MUELU_TEKO
1132 if (postSmootherType ==
"teko")
1140 if (preSmoother == postSmoother)
1143 manager.
SetFactory(
"PreSmoother", preSmoother);
1144 manager.
SetFactory(
"PostSmoother", postSmoother);
1151 bool reuseSmoothers = (reuseType ==
"S" || reuseType !=
"none");
1152 if (reuseSmoothers) {
1153 auto preSmootherFactory = rcp_const_cast<Factory>(rcp_dynamic_cast<const Factory>(manager.
GetFactory(
"PreSmoother")));
1155 if (preSmootherFactory != Teuchos::null) {
1156 ParameterList postSmootherFactoryParams;
1157 postSmootherFactoryParams.set(
"keep smoother data",
true);
1158 preSmootherFactory->SetParameterList(postSmootherFactoryParams);
1160 keeps.push_back(
keep_pair(
"PreSmoother data", preSmootherFactory.get()));
1163 auto postSmootherFactory = rcp_const_cast<Factory>(rcp_dynamic_cast<const Factory>(manager.
GetFactory(
"PostSmoother")));
1164 if (postSmootherFactory != Teuchos::null) {
1165 ParameterList postSmootherFactoryParams;
1166 postSmootherFactoryParams.set(
"keep smoother data",
true);
1167 postSmootherFactory->SetParameterList(postSmootherFactoryParams);
1169 keeps.push_back(
keep_pair(
"PostSmoother data", postSmootherFactory.get()));
1172 auto coarseFactory = rcp_const_cast<Factory>(rcp_dynamic_cast<const Factory>(manager.
GetFactory(
"CoarseSolver")));
1173 if (coarseFactory != Teuchos::null) {
1174 ParameterList coarseFactoryParams;
1175 coarseFactoryParams.set(
"keep smoother data",
true);
1176 coarseFactory->SetParameterList(coarseFactoryParams);
1178 keeps.push_back(
keep_pair(
"PreSmoother data", coarseFactory.get()));
1182 if ((reuseType ==
"RAP" && levelID) || (reuseType ==
"full")) {
1201template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1206 bool isCustomCoarseSolver =
1207 paramList.isParameter(
"coarse: type") ||
1208 paramList.isParameter(
"coarse: params");
1209 if (test_param_2list<std::string>(paramList, defaultList,
"coarse: type",
"none")) {
1210 manager.
SetFactory(
"CoarseSolver", Teuchos::null);
1212 }
else if (isCustomCoarseSolver) {
1216 auto coarseType = set_var_2list<std::string>(paramList, defaultList,
"coarse: type");
1219 if (paramList.isParameter(
"coarse: overlap"))
1220 overlap = paramList.get<
int>(
"coarse: overlap");
1222 ParameterList coarseParams;
1223 if (paramList.isSublist(
"coarse: params"))
1224 coarseParams = paramList.sublist(
"coarse: params");
1225 else if (defaultList.isSublist(
"coarse: params"))
1226 coarseParams = defaultList.sublist(
"coarse: params");
1228 using strings = std::unordered_set<std::string>;
1230 RCP<SmootherPrototype> coarseSmoother;
1234 if (strings({
"RELAXATION",
"CHEBYSHEV",
"ILUT",
"ILU",
"RILUK",
"SCHWARZ",
"Amesos",
1235 "BLOCK RELAXATION",
"BLOCK_RELAXATION",
"BLOCKRELAXATION",
1236 "SPARSE BLOCK RELAXATION",
"SPARSE_BLOCK_RELAXATION",
"SPARSEBLOCKRELAXATION",
1237 "LINESMOOTHING_BANDEDRELAXATION",
"LINESMOOTHING_BANDED_RELAXATION",
"LINESMOOTHING_BANDED RELAXATION",
1238 "LINESMOOTHING_TRIDIRELAXATION",
"LINESMOOTHING_TRIDI_RELAXATION",
"LINESMOOTHING_TRIDI RELAXATION",
1239 "LINESMOOTHING_TRIDIAGONALRELAXATION",
"LINESMOOTHING_TRIDIAGONAL_RELAXATION",
"LINESMOOTHING_TRIDIAGONAL RELAXATION",
1240 "TOPOLOGICAL",
"FAST_ILU",
"FAST_IC",
"FAST_ILDL",
"HIPTMAIR"})
1241 .count(coarseType)) {
1242 coarseSmoother = rcp(
new TrilinosSmoother(coarseType, coarseParams, overlap));
1244#ifdef HAVE_MUELU_MATLAB
1245 if (coarseType ==
"matlab")
1249#ifdef HAVE_MUELU_TEKO
1250 if (coarseType ==
"teko")
1254 coarseSmoother = rcp(
new DirectSolver(coarseType, coarseParams));
1264template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1267 FactoryManager& manager,
int levelID, std::vector<keep_pair>& )
const {
1268 ParameterList rParams;
1269 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: enable", rParams);
1270 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: use subcommunicators", rParams);
1271 test_and_set_param_2list<bool>(paramList, defaultList,
"tentative: constant column sums", rParams);
1272 test_and_set_param_2list<bool>(paramList, defaultList,
"tentative: calculate qr", rParams);
1275 rFactory->SetParameterList(rParams);
1283 rFactory->SetFactory(
"D0", this->GetFactoryManager(levelID - 1)->GetFactory(
"D0"));
1295template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1298 int levelID, std::vector<keep_pair>& )
const {
1299 ParameterList rParams;
1300 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: enable", rParams);
1301 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: use subcommunicators", rParams);
1302 test_and_set_param_2list<bool>(paramList, defaultList,
"tentative: constant column sums", rParams);
1303 test_and_set_param_2list<bool>(paramList, defaultList,
"tentative: calculate qr", rParams);
1306 rFactory->SetParameterList(rParams);
1314 rFactory->SetFactory(
"D0", this->GetFactoryManager(levelID - 1)->GetFactory(
"D0"));
1322 auto reuseType = set_var_2list<std::string>(paramList, defaultList,
"reuse: type");
1326 manager.
SetFactory(
"Ppattern", patternFactory);
1330 ParameterList constraintParams;
1331 constraintFactory->SetFactory(
"Ppattern", manager.
GetFactory(
"Ppattern"));
1332 test_and_set_param_2list<std::string>(paramList, defaultList,
"emin: least squares solver type", constraintParams);
1333 constraintParams.set(
"emin: constraint type",
"maxwell");
1334 constraintFactory->SetParameterList(constraintParams);
1335 manager.
SetFactory(
"Constraint", constraintFactory);
1341 ParameterList Pparams;
1342 test_and_set_param_2list<int>(paramList, defaultList,
"emin: num iterations", Pparams);
1343 test_and_set_param_2list<std::string>(paramList, defaultList,
"emin: iterative method", Pparams);
1344 if (reuseType ==
"emin") {
1345 test_and_set_param_2list<int>(paramList, defaultList,
"emin: num reuse iterations", Pparams);
1346 Pparams.set(
"Keep P0",
true);
1347 Pparams.set(
"Keep Constraint0",
true);
1349 P->SetParameterList(Pparams);
1350 P->SetFactory(
"P", constraintFactory);
1351 P->SetFactory(
"Constraint", constraintFactory);
1358template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1361 FactoryManager& manager,
int levelID, std::vector<keep_pair>& keeps)
const {
1362 using strings = std::unordered_set<std::string>;
1364 auto reuseType = set_var_2list<std::string>(paramList, defaultList,
"reuse: type");
1366 auto aggType = set_var_2list<std::string>(paramList, defaultList,
"aggregation: type");
1367 TEUCHOS_TEST_FOR_EXCEPTION(!strings({
"uncoupled",
"coupled",
"brick",
"matlab",
"notay",
"classical"}).count(aggType),
1371 RCP<AmalgamationFactory> amalgFact;
1372 if (aggType ==
"classical") {
1374 manager.
SetFactory(
"UnAmalgamationInfo", amalgFact);
1378 RCP<Factory> dropFactory;
1380 if (test_param_2list<std::string>(paramList, paramList,
"aggregation: drop scheme",
"matlab")) {
1381#ifdef HAVE_MUELU_MATLAB
1383 ParameterList socParams = paramList.sublist(
"strength-of-connection: params");
1384 dropFactory->SetParameterList(socParams);
1386 throw std::runtime_error(
"Cannot use MATLAB evolutionary strength-of-connection - MueLu was not configured with MATLAB support.");
1388 }
else if (test_param_2list<std::string>(paramList, paramList,
"aggregation: drop scheme",
"unsupported vector smoothing")) {
1390 ParameterList dropParams;
1391 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: drop scheme", dropParams);
1392 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: block diagonal: interleaved blocksize", dropParams);
1393 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: number of random vectors", dropParams);
1394 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: number of times to pre or post smooth", dropParams);
1395 test_and_set_param_2list<Teuchos::Array<double>>(paramList, defaultList,
"aggregation: penalty parameters", dropParams);
1396 dropFactory->SetParameterList(dropParams);
1399 ParameterList dropParams;
1400 if (!rcp_dynamic_cast<CoalesceDropFactory>(dropFactory).is_null())
1401 dropParams.set(
"lightweight wrap",
true);
1402 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: drop scheme", dropParams);
1403 test_and_set_param_2list<double>(paramList, defaultList,
"aggregation: row sum drop tol", dropParams);
1404 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: block diagonal: interleaved blocksize", dropParams);
1405 test_and_set_param_2list<double>(paramList, defaultList,
"aggregation: drop tol", dropParams);
1406 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: use ml scaling of drop tol", dropParams);
1408 test_and_set_param_2list<double>(paramList, defaultList,
"aggregation: Dirichlet threshold", dropParams);
1409 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: greedy Dirichlet", dropParams);
1411 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: distance laplacian metric", dropParams);
1413 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: Minv scheme", dropParams);
1415#ifdef HAVE_MUELU_COALESCEDROP_ALLOW_OLD_PARAMETERS
1416 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: distance laplacian algo", dropParams);
1417 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: classical algo", dropParams);
1419 test_and_set_param_2list<Teuchos::Array<double>>(paramList, defaultList,
"aggregation: distance laplacian directional weights", dropParams);
1420 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: coloring: localize color graph", dropParams);
1421 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: dropping may create Dirichlet", dropParams);
1423 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: use blocking", dropParams);
1424 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: symmetrize graph after dropping", dropParams);
1425 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: strength-of-connection: matrix", dropParams);
1426 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: strength-of-connection: measure", dropParams);
1427 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: use lumping", dropParams);
1428 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: reuse graph", dropParams);
1429 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: reuse eigenvalue", dropParams);
1430 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: use root stencil", dropParams);
1431 test_and_set_param_2list<double>(paramList, defaultList,
"filtered matrix: Dirichlet threshold", dropParams);
1432 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: use spread lumping", dropParams);
1433 test_and_set_param_2list<std::string>(paramList, defaultList,
"filtered matrix: lumping choice", dropParams);
1434 test_and_set_param_2list<double>(paramList, defaultList,
"filtered matrix: spread lumping diag dom growth factor", dropParams);
1435 test_and_set_param_2list<double>(paramList, defaultList,
"filtered matrix: spread lumping diag dom cap", dropParams);
1436 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: count negative diagonals", dropParams);
1439#ifdef HAVE_MUELU_COALESCEDROP_ALLOW_OLD_PARAMETERS
1440 if (!dropParams.isParameter(
"aggregation: drop scheme") ||
1441 (dropParams.isParameter(
"aggregation: drop scheme") &&
1442 ((dropParams.get<std::string>(
"aggregation: drop scheme") !=
"point-wise") && (dropParams.get<std::string>(
"aggregation: drop scheme") !=
"cut-drop")))) {
1443 Teuchos::ParameterList dropParamsWithDefaults(dropParams);
1445 test_and_set_var_from_masterlist<std::string>(dropParamsWithDefaults,
"aggregation: drop scheme");
1446 test_and_set_var_from_masterlist<std::string>(dropParamsWithDefaults,
"aggregation: strength-of-connection: matrix");
1447 test_and_set_var_from_masterlist<std::string>(dropParamsWithDefaults,
"aggregation: strength-of-connection: measure");
1448 test_and_set_var_from_masterlist<bool>(dropParamsWithDefaults,
"aggregation: use blocking");
1451 TEUCHOS_TEST_FOR_EXCEPTION(dropParams.isParameter(
"aggregation: strength-of-connection: matrix") ||
1452 dropParams.isParameter(
"aggregation: strength-of-connection: measure") ||
1453 dropParams.isParameter(
"aggregation: use blocking"),
1454 Teuchos::Exceptions::InvalidParameterType,
1455 "The inputs contain a mix of old and new dropping parameters:\n\n"
1456 << dropParams <<
"\n\nKeep in mind that defaults are set for old parameters, so this gets interpreted as\n\n"
1457 << dropParamsWithDefaults);
1461 if (!amalgFact.is_null())
1462 dropFactory->SetFactory(
"UnAmalgamationInfo", manager.
GetFactory(
"UnAmalgamationInfo"));
1464 if (dropParams.isParameter(
"aggregation: drop scheme")) {
1465 std::string drop_scheme = dropParams.get<std::string>(
"aggregation: drop scheme");
1466 if (drop_scheme ==
"block diagonal colored signed classical")
1467 manager.
SetFactory(
"Coloring Graph", dropFactory);
1468 if ((test_param_2list<bool>(dropParams, defaultList,
"aggregation: use blocking",
true)) ||
1469 (drop_scheme.find(
"block diagonal") != std::string::npos || drop_scheme ==
"signed classical")) {
1471 dropFactory->SetFactory(
"BlockNumber", this->GetFactoryManager(levelID - 1)->GetFactory(
"BlockNumber"));
1473 dropFactory->SetFactory(
"BlockNumber", manager.
GetFactory(
"BlockNumber"));
1477 if (useKokkos_ && (levelID > 0)) {
1478 if (dropParams.isParameter(
"aggregation: strength-of-connection: matrix") && dropParams.get<std::string>(
"aggregation: strength-of-connection: matrix") ==
"MinvA") {
1479 if (projectM_) dropFactory->SetFactory(
"M", this->GetFactoryManager(levelID - 1)->GetFactory(
"M"));
1480 if (projectMinv_) dropFactory->SetFactory(
"Minv", this->GetFactoryManager(levelID - 1)->GetFactory(
"Minv"));
1481 if (projectMinvA_) dropFactory->SetFactory(
"MinvA", this->GetFactoryManager(levelID - 1)->GetFactory(
"MinvA"));
1485 auto socMatrix = set_var_2list<std::string>(paramList, defaultList,
"aggregation: strength-of-connection: matrix");
1486 if ((socMatrix ==
"MinvA") && (paramList.isSublist(
"project auxiliary matrices"))) {
1487 auto projectList = paramList.sublist(
"project auxiliary matrices");
1488 dropParams.set(
"project auxiliary matrices", projectList);
1490 dropFactory->SetParameterList(dropParams);
1495#ifndef HAVE_MUELU_MATLAB
1496 if (aggType ==
"matlab")
1497 throw std::runtime_error(
"Cannot use MATLAB aggregation - MueLu was not configured with MATLAB support.");
1499 RCP<Factory> aggFactory;
1500 if (aggType ==
"uncoupled") {
1502 ParameterList aggParams;
1503 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: ordering", aggParams);
1504 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: min agg size", aggParams);
1505 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: max agg size", aggParams);
1506 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: max selected neighbors", aggParams);
1507 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: backend", aggParams);
1508 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: phase 1 algorithm", aggParams);
1509 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: deterministic", aggParams);
1510 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: coloring algorithm", aggParams);
1511 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: enable phase 1", aggParams);
1512 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: enable phase 2a", aggParams);
1513 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: enable phase 2b", aggParams);
1514 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: enable phase 3", aggParams);
1515 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: match ML phase1", aggParams);
1516 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: match ML phase2a", aggParams);
1517 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: match ML phase2b", aggParams);
1518 test_and_set_param_2list<double>(paramList, defaultList,
"aggregation: phase2a agg factor", aggParams);
1519 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: preserve Dirichlet points", aggParams);
1520 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: error on nodes with no on-rank neighbors", aggParams);
1521 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: phase3 avoid singletons", aggParams);
1522 aggFactory->SetParameterList(aggParams);
1524 aggFactory->SetFactory(
"DofsPerNode", manager.
GetFactory(
"Graph"));
1525 aggFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1528 if (test_param_2list<std::string>(paramList, defaultList,
"aggregation: coloring algorithm",
"mis2 aggregation") ||
1529 test_param_2list<std::string>(paramList, defaultList,
"aggregation: coloring algorithm",
"mis2 coarsening")) {
1530 if (test_param_2list<bool>(paramList, defaultList,
"aggregation: symmetrize graph after dropping",
false))
1531 TEUCHOS_TEST_FOR_EXCEPTION(
true,
1533 "MIS2 algorithms require the use of a symmetrized graph. Please set \"aggregation: symmetrize graph after dropping\" to \"true\".");
1535 }
else if (aggType ==
"brick") {
1537 ParameterList aggParams;
1538 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: brick x size", aggParams);
1539 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: brick y size", aggParams);
1540 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: brick z size", aggParams);
1541 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: brick x Dirichlet", aggParams);
1542 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: brick y Dirichlet", aggParams);
1543 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: brick z Dirichlet", aggParams);
1544 aggFactory->SetParameterList(aggParams);
1548 manager.
SetFactory(
"DofsPerNode", aggFactory);
1554 aggFactory->SetFactory(
"Coordinates", this->GetFactoryManager(levelID - 1)->GetFactory(
"Coordinates"));
1556 }
else if (aggType ==
"classical") {
1559 ParameterList mapParams;
1560 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: deterministic", mapParams);
1561 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: coloring algorithm", mapParams);
1563 ParameterList tempParams;
1564 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: drop scheme", tempParams);
1565 std::string drop_algo = tempParams.get<std::string>(
"aggregation: drop scheme");
1566 if (drop_algo ==
"block diagonal colored signed classical") {
1567 mapParams.set(
"aggregation: coloring: use color graph",
true);
1568 mapFact->SetFactory(
"Coloring Graph", manager.
GetFactory(
"Coloring Graph"));
1570 mapFact->SetParameterList(mapParams);
1571 mapFact->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1572 mapFact->SetFactory(
"UnAmalgamationInfo", manager.
GetFactory(
"UnAmalgamationInfo"));
1578 ParameterList aggParams;
1579 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: classical scheme", aggParams);
1580 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: drop scheme", aggParams);
1581 aggFactory->SetParameterList(aggParams);
1582 aggFactory->SetFactory(
"FC Splitting", manager.
GetFactory(
"FC Splitting"));
1583 aggFactory->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1584 aggFactory->SetFactory(
"DofsPerNode", manager.
GetFactory(
"Graph"));
1585 aggFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1587 if (drop_algo.find(
"block diagonal") != std::string::npos || drop_algo ==
"signed classical") {
1589 aggFactory->SetFactory(
"BlockNumber", this->GetFactoryManager(levelID - 1)->GetFactory(
"BlockNumber"));
1591 aggFactory->SetFactory(
"BlockNumber", manager.
GetFactory(
"BlockNumber"));
1598 if (reuseType ==
"tP" && levelID) {
1600 keeps.push_back(
keep_pair(
"Ptent", aggFactory.get()));
1603 }
else if (aggType ==
"notay") {
1605 ParameterList aggParams;
1606 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: pairwise: size", aggParams);
1607 test_and_set_param_2list<double>(paramList, defaultList,
"aggregation: pairwise: tie threshold", aggParams);
1608 test_and_set_param_2list<double>(paramList, defaultList,
"aggregation: Dirichlet threshold", aggParams);
1609 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: ordering", aggParams);
1610 aggFactory->SetParameterList(aggParams);
1611 aggFactory->SetFactory(
"DofsPerNode", manager.
GetFactory(
"Graph"));
1612 aggFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1614#ifdef HAVE_MUELU_MATLAB
1615 else if (aggType ==
"matlab") {
1616 ParameterList aggParams = paramList.sublist(
"aggregation: params");
1618 aggFactory->SetParameterList(aggParams);
1622 manager.
SetFactory(
"Aggregates", aggFactory);
1626 coarseMap->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1631 ParameterList ptentParams;
1632 if (paramList.isSublist(
"matrixmatrix: kernel params"))
1633 ptentParams.sublist(
"matrixmatrix: kernel params",
false) = paramList.sublist(
"matrixmatrix: kernel params");
1634 if (defaultList.isSublist(
"matrixmatrix: kernel params"))
1635 ptentParams.sublist(
"matrixmatrix: kernel params",
false) = defaultList.sublist(
"matrixmatrix: kernel params");
1636 test_and_set_param_2list<bool>(paramList, defaultList,
"tentative: calculate qr", ptentParams);
1637 test_and_set_param_2list<bool>(paramList, defaultList,
"tentative: build coarse coordinates", ptentParams);
1638 test_and_set_param_2list<bool>(paramList, defaultList,
"sa: keep tentative prolongator", ptentParams);
1639 Ptent->SetParameterList(ptentParams);
1640 Ptent->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1641 Ptent->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1644 if (reuseType ==
"tP" && levelID) {
1645 keeps.push_back(
keep_pair(
"Nullspace", Ptent.get()));
1646 keeps.push_back(
keep_pair(
"P", Ptent.get()));
1653template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1656 int , std::vector<keep_pair>& keeps)
const {
1657 if (paramList.isParameter(
"A") && !paramList.get<RCP<Matrix>>(
"A").is_null()) {
1663 ParameterList RAPparams;
1665 RCP<RAPFactory> RAP;
1666 RCP<RAPShiftFactory> RAPs;
1669 std::string alg = paramList.get(
"rap: algorithm",
"galerkin");
1670 if (alg ==
"shift" || alg ==
"non-galerkin") {
1672 test_and_set_param_2list<double>(paramList, defaultList,
"rap: shift", RAPparams);
1673 test_and_set_param_2list<bool>(paramList, defaultList,
"rap: shift diagonal M", RAPparams);
1674 test_and_set_param_2list<bool>(paramList, defaultList,
"rap: shift low storage", RAPparams);
1675 test_and_set_param_2list<Teuchos::Array<double>>(paramList, defaultList,
"rap: shift array", RAPparams);
1676 test_and_set_param_2list<Teuchos::Array<double>>(paramList, defaultList,
"rap: cfl array", RAPparams);
1682 test_and_set_param_2list<Teuchos::Array<double>>(paramList, defaultList,
"rap: relative diagonal floor", RAPparams);
1684 if (paramList.isSublist(
"matrixmatrix: kernel params"))
1685 RAPparams.sublist(
"matrixmatrix: kernel params",
false) = paramList.sublist(
"matrixmatrix: kernel params");
1686 if (defaultList.isSublist(
"matrixmatrix: kernel params"))
1687 RAPparams.sublist(
"matrixmatrix: kernel params",
false) = defaultList.sublist(
"matrixmatrix: kernel params");
1688 test_and_set_param_2list<bool>(paramList, defaultList,
"transpose: use implicit", RAPparams);
1689 test_and_set_param_2list<bool>(paramList, defaultList,
"rap: fix zero diagonals", RAPparams);
1690 test_and_set_param_2list<double>(paramList, defaultList,
"rap: fix zero diagonals threshold", RAPparams);
1691 test_and_set_param_2list<Scalar>(paramList, defaultList,
"rap: fix zero diagonals replacement", RAPparams);
1694 if (!paramList.isParameter(
"rap: triple product") &&
1695 paramList.isType<std::string>(
"multigrid algorithm") &&
1696 paramList.get<std::string>(
"multigrid algorithm") ==
"unsmoothed")
1697 paramList.set(
"rap: triple product",
true);
1699 test_and_set_param_2list<bool>(paramList, defaultList,
"rap: triple product", RAPparams);
1702 if (paramList.isParameter(
"aggregation: allow empty prolongator columns")) {
1703 RAPparams.set(
"CheckMainDiagonal", paramList.get<
bool>(
"aggregation: allow empty prolongator columns"));
1704 RAPparams.set(
"RepairMainDiagonal", paramList.get<
bool>(
"aggregation: allow empty prolongator columns"));
1705 }
else if (defaultList.isParameter(
"aggregation: allow empty prolongator columns")) {
1706 RAPparams.set(
"CheckMainDiagonal", defaultList.get<
bool>(
"aggregation: allow empty prolongator columns"));
1707 RAPparams.set(
"RepairMainDiagonal", defaultList.get<
bool>(
"aggregation: allow empty prolongator columns"));
1710 }
catch (Teuchos::Exceptions::InvalidParameterType&) {
1711 TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(
true, Teuchos::Exceptions::InvalidParameterType,
1712 "Error: parameter \"aggregation: allow empty prolongator columns\" must be of type " << Teuchos::TypeNameTraits<bool>::name());
1715 if (!RAP.is_null()) {
1716 RAP->SetParameterList(RAPparams);
1717 RAP->SetFactory(
"P", manager.
GetFactory(
"P"));
1719 RAPs->SetParameterList(RAPparams);
1720 RAPs->SetFactory(
"P", manager.
GetFactory(
"P"));
1723 if (!this->implicitTranspose_) {
1725 RAP->SetFactory(
"R", manager.
GetFactory(
"R"));
1727 RAPs->SetFactory(
"R", manager.
GetFactory(
"R"));
1731 if (test_param_2list<bool>(paramList, defaultList,
"matrix: compute analysis",
true)) {
1735 RAP->AddTransferFactory(matrixAnalysisFact);
1737 RAPs->AddTransferFactory(matrixAnalysisFact);
1741 if (test_param_2list<bool>(paramList, defaultList,
"aggregation: compute aggregate qualities",
true)) {
1743 ParameterList aggQualityParams;
1744 test_and_set_param_2list<double>(paramList, defaultList,
"aggregate qualities: good aggregate threshold", aggQualityParams);
1745 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregate qualities: file output", aggQualityParams);
1746 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregate qualities: file base", aggQualityParams);
1747 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregate qualities: check symmetry", aggQualityParams);
1748 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregate qualities: algorithm", aggQualityParams);
1749 test_and_set_param_2list<double>(paramList, defaultList,
"aggregate qualities: zero threshold", aggQualityParams);
1750 test_and_set_param_2list<Teuchos::Array<double>>(paramList, defaultList,
"aggregate qualities: percentiles", aggQualityParams);
1751 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregate qualities: mode", aggQualityParams);
1752 aggQualityFact->SetParameterList(aggQualityParams);
1753 aggQualityFact->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1754 aggQualityFact->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1755 manager.
SetFactory(
"AggregateQualities", aggQualityFact);
1758 RAP->AddTransferFactory(aggQualityFact);
1760 RAPs->AddTransferFactory(aggQualityFact);
1763 if (test_param_2list<bool>(paramList, defaultList,
"aggregation: export visualization data",
true)) {
1765 ParameterList aggExportParams;
1766 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: output filename", aggExportParams);
1767 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: output file: agg style", aggExportParams);
1768 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: output file: iter", aggExportParams);
1769 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: output file: time step", aggExportParams);
1770 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: output file: fine graph edges", aggExportParams);
1771 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: output file: coarse graph edges", aggExportParams);
1772 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: output file: build colormap", aggExportParams);
1773 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: output file: aggregate qualities", aggExportParams);
1774 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: output file: material", aggExportParams);
1775 aggExport->SetParameterList(aggExportParams);
1776 aggExport->SetFactory(
"AggregateQualities", manager.
GetFactory(
"AggregateQualities"));
1777 aggExport->SetFactory(
"DofsPerNode", manager.
GetFactory(
"DofsPerNode"));
1778 aggExport->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1779 aggExport->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1782 RAP->AddTransferFactory(aggExport);
1784 RAPs->AddTransferFactory(aggExport);
1791 auto reuseType = set_var_2list<std::string>(paramList, defaultList,
"reuse: type");
1792 auto useFiltering = set_var_2list<bool>(paramList, defaultList,
"sa: use filtered matrix");
1793 bool filteringChangesMatrix = useFiltering && !test_param_2list<double>(paramList, defaultList,
"aggregation: drop tol", 0);
1795 if (reuseType ==
"RP" || (reuseType ==
"tP" && !filteringChangesMatrix)) {
1796 if (!RAP.is_null()) {
1797 keeps.push_back(
keep_pair(
"AP reuse data", RAP.get()));
1798 keeps.push_back(
keep_pair(
"RAP reuse data", RAP.get()));
1801 keeps.push_back(
keep_pair(
"AP reuse data", RAPs.get()));
1802 keeps.push_back(
keep_pair(
"RAP reuse data", RAPs.get()));
1810template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1814 bool have_userCO =
false;
1815 if (paramList.isParameter(
"Coordinates") && !paramList.get<RCP<MultiVector>>(
"Coordinates").is_null())
1818 if (useCoordinates_) {
1824 coords->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1825 coords->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1828 auto RAP = rcp_const_cast<RAPFactory>(rcp_dynamic_cast<const RAPFactory>(manager.
GetFactory(
"A")));
1829 if (!RAP.is_null()) {
1830 RAP->AddTransferFactory(manager.
GetFactory(
"Coordinates"));
1832 auto RAPs = rcp_const_cast<RAPShiftFactory>(rcp_dynamic_cast<const RAPShiftFactory>(manager.
GetFactory(
"A")));
1833 RAPs->AddTransferFactory(manager.
GetFactory(
"Coordinates"));
1842template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1846 bool have_userMaterial =
false;
1847 if (paramList.isParameter(
"Material") && !paramList.get<RCP<MultiVector>>(
"Material").is_null())
1848 have_userMaterial =
true;
1851 if (have_userMaterial) {
1855 ParameterList materialTransferParameters;
1856 materialTransferParameters.set(
"Vector name",
"Material");
1857 materialTransferParameters.set(
"Transfer name",
"Aggregates");
1858 materialTransferParameters.set(
"Normalize",
true);
1859 materialTransfer->SetParameterList(materialTransferParameters);
1860 materialTransfer->SetFactory(
"Transfer factory", manager.
GetFactory(
"Aggregates"));
1861 materialTransfer->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1862 manager.
SetFactory(
"Material", materialTransfer);
1864 auto RAP = rcp_const_cast<RAPFactory>(rcp_dynamic_cast<const RAPFactory>(manager.
GetFactory(
"A")));
1865 if (!RAP.is_null()) {
1866 RAP->AddTransferFactory(manager.
GetFactory(
"Material"));
1868 auto RAPs = rcp_const_cast<RAPShiftFactory>(rcp_dynamic_cast<const RAPShiftFactory>(manager.
GetFactory(
"A")));
1869 RAPs->AddTransferFactory(manager.
GetFactory(
"Material"));
1878template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1881 FactoryManager& manager,
int levelID, std::vector<keep_pair>& )
const {
1884 if (useBlockNumber_ && (levelID > 0)) {
1885 auto RAP = rcp_const_cast<RAPFactory>(rcp_dynamic_cast<const RAPFactory>(manager.
GetFactory(
"A")));
1886 auto RAPs = rcp_const_cast<RAPShiftFactory>(rcp_dynamic_cast<const RAPShiftFactory>(manager.
GetFactory(
"A")));
1887 if (!RAP.is_null() || !RAPs.is_null()) {
1889 if (multigridAlgo ==
"classical")
1890 fact->SetFactory(
"P Graph", manager.
GetFactory(
"P Graph"));
1892 fact->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1893 fact->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1895 fact->SetFactory(VarName, this->GetFactoryManager(levelID - 1)->GetFactory(VarName));
1900 RAP->AddTransferFactory(manager.
GetFactory(VarName));
1902 RAPs->AddTransferFactory(manager.
GetFactory(VarName));
1910template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1913 FactoryManager& manager,
int levelID, std::vector<keep_pair>& )
const {
1918 else if (levelID > 0) {
1920 auto RebalAc = rcp_const_cast<RebalanceAcFactory>(rcp_dynamic_cast<const RebalanceAcFactory>(Afact));
1921 RCP<RAPFactory> RAP;
1922 RCP<RAPShiftFactory> RAPs;
1923 if (!RebalAc.is_null()) {
1924 auto Afact2 = RebalAc->GetFactory(
"A");
1925 RAP = rcp_const_cast<RAPFactory>(rcp_dynamic_cast<const RAPFactory>(Afact2));
1926 RAPs = rcp_const_cast<RAPShiftFactory>(rcp_dynamic_cast<const RAPShiftFactory>(Afact2));
1928 RAP = rcp_const_cast<RAPFactory>(rcp_dynamic_cast<const RAPFactory>(Afact));
1929 RAPs = rcp_const_cast<RAPShiftFactory>(rcp_dynamic_cast<const RAPShiftFactory>(Afact));
1932 if (!RAP.is_null() || !RAPs.is_null()) {
1935 ParameterList transferParameters;
1936 transferParameters.set(
"Matrix name", VarName);
1937 transferParameters.set(
"transpose: use implicit", this->implicitTranspose_);
1938 mtf->SetParameterList(transferParameters);
1940 if (!RAP.is_null()) {
1941 mtf->SetFactory(
"P", RAP->GetFactory(
"P"));
1942 if (!this->implicitTranspose_)
1943 mtf->SetFactory(
"R", RAP->GetFactory(
"R"));
1944 RAP->AddTransferFactory(mtf);
1946 mtf->SetFactory(
"P", RAPs->GetFactory(
"P"));
1947 if (!this->implicitTranspose_)
1948 mtf->SetFactory(
"R", RAPs->GetFactory(
"R"));
1949 RAPs->AddTransferFactory(mtf);
1952 auto enableRepart = set_var_2list<bool>(paramList, defaultList,
"repartition: enable");
1953 if (!enableRepart) {
1957 Teuchos::ParameterList rebalParams;
1958 rebalParams.set(
"Matrix name", VarName);
1959 auto useSubCommInPlace = set_var_2list<bool>(paramList, defaultList,
"repartition: use subcommunicators in place");
1960 rebalParams.set(
"repartition: use subcommunicators in place", useSubCommInPlace);
1961 if (useSubCommInPlace) {
1962 auto inPlaceMapFact = manager.
GetFactory(
"InPlaceMap");
1963 rebalFact->SetFactory(
"InPlaceMap", inPlaceMapFact);
1965 TEUCHOS_ASSERT(!RebalAc.is_null());
1966 RCP<const FactoryBase> importerFact;
1967 importerFact = RebalAc->GetFactory(
"Importer");
1968 rebalFact->SetFactory(
"Importer", importerFact);
1969 RebalAc->AddRebalanceFactory(rebalFact);
1972 rebalFact->SetParameterList(rebalParams);
1973 rebalFact->SetFactory(
"A", mtf);
1984template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1988 if (useBlockNumber_) {
1989 ParameterList myParams;
1991 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: block diagonal: interleaved blocksize", myParams);
1992 fact->SetParameterList(myParams);
2000template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2003 int , std::vector<keep_pair>& )
const {
2004 auto multigridAlgo = set_var_2list<std::string>(paramList, defaultList,
"multigrid algorithm");
2005 bool have_userR =
false;
2006 if (paramList.isParameter(
"R") && !paramList.get<RCP<Matrix>>(
"R").is_null())
2011 if (!this->implicitTranspose_) {
2012 auto isSymmetric = set_var_2list<bool>(paramList, defaultList,
"problem: symmetric");
2014 if (isSymmetric ==
false && (multigridAlgo ==
"unsmoothed" || multigridAlgo ==
"emin")) {
2015 this->GetOStream(
Warnings0) <<
"Switching \"problem: symmetric\" parameter to symmetric as multigrid algorithm. " << multigridAlgo <<
" is primarily supposed to be used for symmetric problems.\n\n"
2016 <<
"Please note: if you are using \"unsmoothed\" transfer operators the \"problem: symmetric\" parameter "
2017 <<
"has no real mathematical meaning, i.e. you can use it for non-symmetric\n"
2018 <<
"problems, too. With \"problem: symmetric\"=\"symmetric\" you can use implicit transpose for building "
2019 <<
"the restriction operators which may drastically reduce the amount of consumed memory." << std::endl;
2023 "Petrov-Galerkin smoothed transfer operators are only allowed for non-symmetric problems: Set \"problem: symmetric\" to false!\n"
2024 "While PG smoothed transfer operators generally would also work for symmetric problems this is an unusual use case. "
2025 "You can use the factory-based xml interface though if you need PG-AMG for symmetric problems.");
2044 if (paramList.isParameter(
"restriction: scale nullspace") && paramList.get<
bool>(
"restriction: scale nullspace")) {
2046 Teuchos::ParameterList tentPlist;
2047 tentPlist.set(
"Nullspace name",
"Scaled Nullspace");
2048 tentPFactory->SetParameterList(tentPlist);
2049 tentPFactory->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
2050 tentPFactory->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
2053 R->SetFactory(
"P", tentPFactory);
2060template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2063 int levelID, std::vector<keep_pair>& keeps, RCP<Factory>& nullSpaceFactory)
const {
2065 auto reuseType = set_var_2list<std::string>(paramList, defaultList,
"reuse: type");
2066 auto enableRepart = set_var_2list<bool>(paramList, defaultList,
"repartition: enable");
2068#if defined(HAVE_MPI) && (defined(HAVE_MUELU_ZOLTAN) || defined(HAVE_MUELU_ZOLTAN2))
2069 auto enableInPlace = set_var_2list<bool>(paramList, defaultList,
"repartition: use subcommunicators in place");
2106 "Reuse types \"tP\" and \"PR\" require \"repartition: rebalance P and R\" set to \"false\"");
2111 auto partName = set_var_2list<std::string>(paramList, defaultList,
"repartition: partitioner");
2113 "Invalid partitioner name: \"" << partName <<
"\". Valid options: \"zoltan\", \"zoltan2\"");
2115#ifndef HAVE_MUELU_ZOLTAN
2116 bool switched =
false;
2117 if (partName ==
"zoltan") {
2118 this->GetOStream(
Warnings0) <<
"Zoltan interface is not available, trying to switch to Zoltan2" << std::endl;
2119 partName =
"zoltan2";
2123#ifndef HAVE_MUELU_ZOLTAN2
2124 bool switched =
false;
2128#ifndef HAVE_MUELU_ZOLTAN2
2129 if (partName ==
"zoltan2" && !switched) {
2130 this->GetOStream(
Warnings0) <<
"Zoltan2 interface is not available, trying to switch to Zoltan" << std::endl;
2131 partName =
"zoltan";
2135 auto nodeRepartitionLevel = set_var_2list<int>(paramList, defaultList,
"repartition: node repartition level");
2139 ParameterList repartheurParams;
2140 test_and_set_param_2list<int>(paramList, defaultList,
"repartition: node repartition level", repartheurParams);
2141 test_and_set_param_2list<int>(paramList, defaultList,
"repartition: start level", repartheurParams);
2142 test_and_set_param_2list<int>(paramList, defaultList,
"repartition: min rows per proc", repartheurParams);
2143 test_and_set_param_2list<int>(paramList, defaultList,
"repartition: target rows per proc", repartheurParams);
2144 test_and_set_param_2list<int>(paramList, defaultList,
"repartition: min rows per thread", repartheurParams);
2145 test_and_set_param_2list<int>(paramList, defaultList,
"repartition: target rows per thread", repartheurParams);
2146 test_and_set_param_2list<double>(paramList, defaultList,
"repartition: max imbalance", repartheurParams);
2147 test_and_set_param_2list<int>(paramList, defaultList,
"repartition: put on single proc", repartheurParams);
2148 repartheurFactory->SetParameterList(repartheurParams);
2149 repartheurFactory->SetFactory(
"A", manager.
GetFactory(
"A"));
2150 manager.
SetFactory(
"number of partitions", repartheurFactory);
2151 manager.
SetFactory(
"repartition: heuristic target rows per process", repartheurFactory);
2154 RCP<Factory> partitioner;
2155 if (levelID == nodeRepartitionLevel) {
2158 ParameterList partParams;
2159 test_and_set_param_2list<int>(paramList, defaultList,
"repartition: node id", partParams);
2160 partitioner->SetParameterList(partParams);
2161 partitioner->SetFactory(
"Node Comm", manager.
GetFactory(
"Node Comm"));
2162 }
else if (partName ==
"zoltan") {
2163#ifdef HAVE_MUELU_ZOLTAN
2169 }
else if (partName ==
"zoltan2") {
2170#ifdef HAVE_MUELU_ZOLTAN2
2172 ParameterList partParams;
2173 RCP<const ParameterList> partpartParams = rcp(
new ParameterList(paramList.sublist(
"repartition: params",
false)));
2174 partParams.set(
"ParameterList", partpartParams);
2175 partitioner->SetParameterList(partParams);
2176 partitioner->SetFactory(
"repartition: heuristic target rows per process",
2177 manager.
GetFactory(
"repartition: heuristic target rows per process"));
2183 partitioner->SetFactory(
"A", manager.
GetFactory(
"A"));
2184 partitioner->SetFactory(
"number of partitions", manager.
GetFactory(
"number of partitions"));
2185 if (useCoordinates_)
2186 partitioner->SetFactory(
"Coordinates", manager.
GetFactory(
"Coordinates"));
2187 manager.
SetFactory(
"Partition", partitioner);
2191 ParameterList repartParams;
2192 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: print partition distribution", repartParams);
2193 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: remap parts", repartParams);
2194 test_and_set_param_2list<int>(paramList, defaultList,
"repartition: remap num values", repartParams);
2195 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: save importer", repartParams);
2196 repartFactory->SetParameterList(repartParams);
2197 repartFactory->SetFactory(
"A", manager.
GetFactory(
"A"));
2198 repartFactory->SetFactory(
"number of partitions", manager.
GetFactory(
"number of partitions"));
2199 repartFactory->SetFactory(
"Partition", manager.
GetFactory(
"Partition"));
2200 manager.
SetFactory(
"Importer", repartFactory);
2201 if (reuseType !=
"none" && reuseType !=
"S" && levelID)
2204 if (enableInPlace) {
2209 ParameterList rebAcParams;
2210 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: use subcommunicators", rebAcParams);
2211 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: use subcommunicators in place", rebAcParams);
2212 newA->SetParameterList(rebAcParams);
2213 newA->SetFactory(
"A", manager.
GetFactory(
"A"));
2214 newA->SetFactory(
"InPlaceMap", manager.
GetFactory(
"InPlaceMap"));
2219 ParameterList rebAcParams;
2220 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: use subcommunicators", rebAcParams);
2221 newA->SetParameterList(rebAcParams);
2222 newA->SetFactory(
"A", manager.
GetFactory(
"A"));
2223 newA->SetFactory(
"Importer", manager.
GetFactory(
"Importer"));
2228 ParameterList newPparams;
2229 newPparams.set(
"type",
"Interpolation");
2230 if (changedPRrebalance_)
2231 newPparams.set(
"repartition: rebalance P and R", this->doPRrebalance_);
2232 if (changedPRViaCopyrebalance_)
2233 newPparams.set(
"repartition: explicit via new copy rebalance P and R",
true);
2234 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: use subcommunicators", newPparams);
2235 test_and_set_param_2list<std::string>(paramList, defaultList,
"repartition: send type", newPparams);
2236 newP->SetParameterList(newPparams);
2237 newP->SetFactory(
"Importer", manager.
GetFactory(
"Importer"));
2238 newP->SetFactory(
"P", manager.
GetFactory(
"P"));
2240 if (!paramList.isParameter(
"semicoarsen: number of levels"))
2241 newP->SetFactory(
"Nullspace", manager.
GetFactory(
"Ptent"));
2243 newP->SetFactory(
"Nullspace", manager.
GetFactory(
"P"));
2244 if (useCoordinates_) {
2245 newP->SetFactory(
"Coordinates", manager.
GetFactory(
"Coordinates"));
2249 newP->SetFactory(
"Material", manager.
GetFactory(
"Material"));
2252 if (useBlockNumber_ && (levelID > 0)) {
2253 newP->SetFactory(
"BlockNumber", manager.
GetFactory(
"BlockNumber"));
2259 ParameterList newRparams;
2260 newRparams.set(
"type",
"Restriction");
2261 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: use subcommunicators", newRparams);
2262 test_and_set_param_2list<std::string>(paramList, defaultList,
"repartition: send type", newRparams);
2263 if (changedPRrebalance_)
2264 newRparams.set(
"repartition: rebalance P and R", this->doPRrebalance_);
2265 if (changedPRViaCopyrebalance_)
2266 newPparams.set(
"repartition: explicit via new copy rebalance P and R",
true);
2267 if (changedImplicitTranspose_)
2268 newRparams.set(
"transpose: use implicit", this->implicitTranspose_);
2269 newR->SetParameterList(newRparams);
2270 newR->SetFactory(
"Importer", manager.
GetFactory(
"Importer"));
2271 if (!this->implicitTranspose_) {
2272 newR->SetFactory(
"R", manager.
GetFactory(
"R"));
2283 ParameterList newNullparams;
2284 test_and_set_param_2list<bool>(paramList, defaultList,
"nullspace: calculate rotations", newNullparams);
2285 nullSpaceFactory->SetFactory(
"Nullspace", newP);
2286 nullSpaceFactory->SetParameterList(newNullparams);
2289 paramList.set(
"repartition: enable",
false);
2291 this->GetOStream(
Warnings0) <<
"No repartitioning available for a serial run\n";
2293 this->GetOStream(
Warnings0) <<
"Zoltan/Zoltan2 are unavailable for repartitioning\n";
2302template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2305 int , std::vector<keep_pair>& )
const {
2306 auto enableLowPrecision = set_var_2list<bool>(paramList, defaultList,
"transfers: half precision");
2308 if (enableLowPrecision) {
2311 ParameterList newPparams;
2312 newPparams.set(
"matrix key",
"P");
2313 newP->SetParameterList(newPparams);
2314 newP->SetFactory(
"P", manager.
GetFactory(
"P"));
2317 if (!this->implicitTranspose_) {
2320 ParameterList newRparams;
2321 newRparams.set(
"matrix key",
"R");
2322 newR->SetParameterList(newRparams);
2323 newR->SetFactory(
"R", manager.
GetFactory(
"R"));
2332template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2335 int , std::vector<keep_pair>& , RCP<Factory>& nullSpaceFactory)
const {
2339 bool have_userNS =
false;
2340 if (paramList.isParameter(
"Nullspace") && !paramList.get<RCP<MultiVector>>(
"Nullspace").is_null())
2344 ParameterList newNullparams;
2345 test_and_set_param_2list<bool>(paramList, defaultList,
"nullspace: calculate rotations", newNullparams);
2346 nullSpace->SetParameterList(newNullparams);
2347 nullSpace->SetFactory(
"Nullspace", manager.
GetFactory(
"Ptent"));
2350 nullSpaceFactory = nullSpace;
2352 if (paramList.isParameter(
"restriction: scale nullspace") && paramList.get<
bool>(
"restriction: scale nullspace")) {
2354 scaledNSfactory->SetFactory(
"Nullspace", nullSpaceFactory);
2355 manager.
SetFactory(
"Scaled Nullspace", scaledNSfactory);
2362template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2365 int , std::vector<keep_pair>& )
const {
2367 RCP<Factory> semicoarsenFactory = Teuchos::null;
2368 if (paramList.isParameter(
"semicoarsen: number of levels") &&
2369 paramList.get<
int>(
"semicoarsen: number of levels") > 0) {
2370 ParameterList togglePParams;
2371 ParameterList semicoarsenPParams;
2372 ParameterList linedetectionParams;
2373 test_and_set_param_2list<int>(paramList, defaultList,
"semicoarsen: number of levels", togglePParams);
2374 test_and_set_param_2list<int>(paramList, defaultList,
"semicoarsen: coarsen rate", semicoarsenPParams);
2375 test_and_set_param_2list<bool>(paramList, defaultList,
"semicoarsen: piecewise constant", semicoarsenPParams);
2376 test_and_set_param_2list<bool>(paramList, defaultList,
"semicoarsen: piecewise linear", semicoarsenPParams);
2377 test_and_set_param_2list<bool>(paramList, defaultList,
"semicoarsen: calculate nonsym restriction", semicoarsenPParams);
2378 test_and_set_param_2list<std::string>(paramList, defaultList,
"linedetection: orientation", linedetectionParams);
2379 test_and_set_param_2list<int>(paramList, defaultList,
"linedetection: num layers", linedetectionParams);
2385 linedetectionFactory->SetParameterList(linedetectionParams);
2386 semicoarsenFactory->SetParameterList(semicoarsenPParams);
2387 togglePFactory->SetParameterList(togglePParams);
2389 togglePFactory->AddCoarseNullspaceFactory(semicoarsenFactory);
2390 togglePFactory->AddProlongatorFactory(semicoarsenFactory);
2391 togglePFactory->AddPtentFactory(semicoarsenFactory);
2392 togglePFactory->AddCoarseNullspaceFactory(manager.
GetFactory(
"Ptent"));
2393 togglePFactory->AddProlongatorFactory(manager.
GetFactory(
"P"));
2394 togglePFactory->AddPtentFactory(manager.
GetFactory(
"Ptent"));
2396 manager.
SetFactory(
"CoarseNumZLayers", linedetectionFactory);
2397 manager.
SetFactory(
"LineDetection_Layers", linedetectionFactory);
2398 manager.
SetFactory(
"LineDetection_VertLineIds", linedetectionFactory);
2402 manager.
SetFactory(
"Nullspace", togglePFactory);
2405 if (paramList.isParameter(
"semicoarsen: number of levels") &&
2406 paramList.get<
int>(
"semicoarsen: number of levels") > 0) {
2408 tf->SetFactory(
"Chosen P", manager.
GetFactory(
"P"));
2409 tf->AddCoordTransferFactory(semicoarsenFactory);
2412 coords->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
2413 coords->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
2414 tf->AddCoordTransferFactory(coords);
2422template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2425 int levelID, std::vector<keep_pair>& keeps)
const {
2426#if defined(HAVE_MUELU_INTREPID2) && defined(HAVE_MUELU_EXPERIMENTAL)
2428 if (defaultList.isParameter(
"pcoarsen: schedule") && defaultList.isParameter(
"pcoarsen: element")) {
2431 auto pcoarsen_schedule = Teuchos::getArrayFromStringParameter<int>(defaultList,
"pcoarsen: schedule");
2432 auto pcoarsen_element = defaultList.get<std::string>(
"pcoarsen: element");
2434 if (levelID >= (
int)pcoarsen_schedule.size()) {
2437 std::string multigridAlgo =
"SA";
2438 UpdateFactoryManager_SA(multigridAlgo, paramList, defaultList, manager, levelID, keeps);
2442 ParameterList Pparams;
2444 std::string lo = pcoarsen_element + std::to_string(pcoarsen_schedule[levelID]);
2445 std::string hi = (levelID ? pcoarsen_element + std::to_string(pcoarsen_schedule[levelID - 1]) : lo);
2446 Pparams.set(
"pcoarsen: hi basis", hi);
2447 Pparams.set(
"pcoarsen: lo basis", lo);
2448 P->SetParameterList(Pparams);
2457 ParameterList Pparams;
2459 test_and_set_param_2list<std::string>(paramList, defaultList,
"pcoarsen: hi basis", Pparams);
2460 test_and_set_param_2list<std::string>(paramList, defaultList,
"pcoarsen: lo basis", Pparams);
2461 P->SetParameterList(Pparams);
2474template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2476 UpdateFactoryManager_SA(std::string& multigridAlgo, ParameterList& paramList,
const ParameterList& defaultList,
FactoryManager& manager,
int levelID, std::vector<keep_pair>& keeps)
const {
2479 ParameterList Pparams;
2480 if (paramList.isSublist(
"matrixmatrix: kernel params"))
2481 Pparams.sublist(
"matrixmatrix: kernel params",
false) = paramList.sublist(
"matrixmatrix: kernel params");
2482 if (defaultList.isSublist(
"matrixmatrix: kernel params"))
2483 Pparams.sublist(
"matrixmatrix: kernel params",
false) = defaultList.sublist(
"matrixmatrix: kernel params");
2484 test_and_set_param_2list<double>(paramList, defaultList,
"sa: damping factor", Pparams);
2485 test_and_set_param_2list<double>(paramList, defaultList,
"sa: nodal damping factor", Pparams);
2486 test_and_set_param_2list<bool>(paramList, defaultList,
"sa: calculate eigenvalue estimate", Pparams);
2487 test_and_set_param_2list<double>(paramList, defaultList,
"sa: max eigenvalue", Pparams);
2488 test_and_set_param_2list<int>(paramList, defaultList,
"sa: eigenvalue estimate num iterations", Pparams);
2489 test_and_set_param_2list<double>(paramList, defaultList,
"sa: diagonal replacement tolerance", Pparams);
2490 test_and_set_param_2list<bool>(paramList, defaultList,
"sa: use rowsumabs diagonal scaling", Pparams);
2491 test_and_set_param_2list<double>(paramList, defaultList,
"sa: rowsumabs diagonal replacement tolerance", Pparams);
2492 test_and_set_param_2list<double>(paramList, defaultList,
"sa: rowsumabs diagonal replacement value", Pparams);
2493 test_and_set_param_2list<bool>(paramList, defaultList,
"sa: rowsumabs use automatic diagonal tolerance", Pparams);
2494 test_and_set_param_2list<bool>(paramList, defaultList,
"sa: enforce constraints", Pparams);
2496 test_and_set_param_2list<bool>(paramList, defaultList,
"tentative: calculate qr", Pparams);
2498 if ((multigridAlgo ==
"smoothed reitzinger") && (levelID > 0)) {
2499 Pparams.set(
"sa: maxwell1 smoothing",
true);
2500 if (!Pparams.isType<
double>(
"sa: damping factor") || (Pparams.get<
double>(
"sa: damping factor") != 0.0))
2501 P->SetFactory(
"CurlCurl", this->GetFactoryManager(levelID - 1)->GetFactory(
"CurlCurl"));
2504 P->SetParameterList(Pparams);
2507 auto useFiltering = set_var_2list<bool>(paramList, defaultList,
"sa: use filtered matrix");
2515 ParameterList fParams;
2516 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: use lumping", fParams);
2517 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: reuse graph", fParams);
2518 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: reuse eigenvalue", fParams);
2519 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: use root stencil", fParams);
2520 test_and_set_param_2list<double>(paramList, defaultList,
"filtered matrix: Dirichlet threshold", fParams);
2521 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: use spread lumping", fParams);
2523 test_and_set_param_2list<double>(paramList, defaultList,
"filtered matrix: spread lumping diag dom growth factor", fParams);
2524 test_and_set_param_2list<double>(paramList, defaultList,
"filtered matrix: spread lumping diag dom cap", fParams);
2525 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: count negative diagonals", fParams);
2526 filterFactory->SetParameterList(fParams);
2527 filterFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
2528 filterFactory->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
2529 filterFactory->SetFactory(
"UnAmalgamationInfo", manager.
GetFactory(
"UnAmalgamationInfo"));
2531 filterFactory->SetFactory(
"Filtering", manager.
GetFactory(
"Graph"));
2533 P->SetFactory(
"A", filterFactory);
2536 P->SetFactory(
"A", manager.
GetFactory(
"Graph"));
2540 P->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
2543 bool filteringChangesMatrix = useFiltering && !test_param_2list<double>(paramList, defaultList,
"aggregation: drop tol", 0);
2544 auto reuseType = set_var_2list<std::string>(paramList, defaultList,
"reuse: type");
2545 if (reuseType ==
"tP" && !filteringChangesMatrix)
2546 keeps.push_back(
keep_pair(
"AP reuse data", P.get()));
2552template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2555 int , std::vector<keep_pair>& )
const {
2556 auto patternType = set_var_2list<std::string>(paramList, defaultList,
"emin: pattern");
2557 auto reuseType = set_var_2list<std::string>(paramList, defaultList,
"reuse: type");
2559 "Invalid pattern name: \"" << patternType <<
"\". Valid options: \"AkPtent\"");
2562 ParameterList patternParams;
2563 test_and_set_param_2list<int>(paramList, defaultList,
"emin: pattern order", patternParams);
2564 patternFactory->SetParameterList(patternParams);
2565 patternFactory->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
2568 auto useFiltering = set_var_2list<bool>(paramList, defaultList,
"emin: use filtered matrix");
2576 ParameterList fParams;
2577 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: use lumping", fParams);
2578 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: reuse graph", fParams);
2579 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: reuse eigenvalue", fParams);
2580 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: use root stencil", fParams);
2581 test_and_set_param_2list<double>(paramList, defaultList,
"filtered matrix: Dirichlet threshold", fParams);
2582 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: use spread lumping", fParams);
2583 test_and_set_param_2list<std::string>(paramList, defaultList,
"filtered matrix: lumping choice", fParams);
2584 test_and_set_param_2list<double>(paramList, defaultList,
"filtered matrix: spread lumping diag dom growth factor", fParams);
2585 test_and_set_param_2list<double>(paramList, defaultList,
"filtered matrix: spread lumping diag dom cap", fParams);
2586 filterFactory->SetParameterList(fParams);
2587 filterFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
2588 filterFactory->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
2589 filterFactory->SetFactory(
"UnAmalgamationInfo", manager.
GetFactory(
"UnAmalgamationInfo"));
2591 filterFactory->SetFactory(
"Filtering", manager.
GetFactory(
"Graph"));
2593 patternFactory->SetFactory(
"A", filterFactory);
2596 patternFactory->SetFactory(
"A", manager.
GetFactory(
"Graph"));
2600 manager.
SetFactory(
"Ppattern", patternFactory);
2604 Teuchos::ParameterList constraintParams;
2605 test_and_set_param_2list<std::string>(paramList, defaultList,
"emin: least squares solver type", constraintParams);
2606 constraintParams.set(
"emin: constraint type",
"nullspace");
2607 constraintFactory->SetFactory(
"Ppattern", manager.
GetFactory(
"Ppattern"));
2608 constraintFactory->SetFactory(
"CoarseNullspace", manager.
GetFactory(
"Ptent"));
2609 manager.
SetFactory(
"Constraint", constraintFactory);
2612 ParameterList Pparams;
2613 test_and_set_param_2list<int>(paramList, defaultList,
"emin: num iterations", Pparams);
2614 test_and_set_param_2list<std::string>(paramList, defaultList,
"emin: iterative method", Pparams);
2615 if (reuseType ==
"emin") {
2616 test_and_set_param_2list<int>(paramList, defaultList,
"emin: num reuse iterations", Pparams);
2617 Pparams.set(
"Keep P0",
true);
2618 Pparams.set(
"Keep Constraint0",
true);
2623 P->SetParameterList(Pparams);
2624 P->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
2625 P->SetFactory(
"Constraint", manager.
GetFactory(
"Constraint"));
2632template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2635 int , std::vector<keep_pair>& )
const {
2637 "Implicit transpose not supported with Petrov-Galerkin smoothed transfer operators: Set \"transpose: use implicit\" to false!\n"
2638 "Petrov-Galerkin transfer operator smoothing for non-symmetric problems requires a separate handling of the restriction operator which "
2639 "does not allow the usage of implicit transpose easily.");
2643 P->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
2650template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2655 ParameterList Pparams;
2656 test_and_set_param_2list<int>(paramList, defaultList,
"replicate: npdes", Pparams);
2658 P->SetParameterList(Pparams);
2665template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2670 ParameterList Pparams;
2671 test_and_set_param_2list<int>(paramList, defaultList,
"combine: numBlks", Pparams);
2672 test_and_set_param_2list<bool>(paramList, defaultList,
"combine: useMaxLevels", Pparams);
2674 P->SetParameterList(Pparams);
2681template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2684 int , std::vector<keep_pair>& )
const {
2685#ifdef HAVE_MUELU_MATLAB
2686 ParameterList Pparams = paramList.sublist(
"transfer: params");
2688 P->SetParameterList(Pparams);
2689 P->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
2697#undef MUELU_KOKKOS_FACTORY
2701template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2703 ParameterList paramList = constParamList;
2706 const int maxLevels = 100;
2709 std::vector<ParameterList> paramLists;
2710 for (
int levelID = 0; levelID < maxLevels; levelID++) {
2711 std::string sublistName =
"level " +
toString(levelID);
2712 if (paramList.isSublist(sublistName)) {
2713 paramLists.push_back(paramList.sublist(sublistName));
2715 paramList.remove(sublistName);
2718 paramLists.push_back(paramList);
2720#ifdef HAVE_MUELU_MATLAB
2722 for (
size_t i = 0; i < paramLists.size(); i++) {
2723 std::vector<std::string> customVars;
2725 for (Teuchos::ParameterList::ConstIterator it = paramLists[i].begin(); it != paramLists[i].end(); it++) {
2726 std::string paramName = paramLists[i].name(it);
2729 customVars.push_back(paramName);
2733 for (
size_t j = 0; j < customVars.size(); j++)
2734 paramLists[i].remove(customVars[j],
false);
2738 const int maxDepth = 0;
2739 for (
size_t i = 0; i < paramLists.size(); i++) {
2742 paramLists[i].validateParameters(validList, maxDepth);
2744 }
catch (
const Teuchos::Exceptions::InvalidParameterName& e) {
2745 std::string eString = e.what();
2748 size_t nameStart = eString.find_first_of(
'"') + 1;
2749 size_t nameEnd = eString.find_first_of(
'"', nameStart);
2750 std::string name = eString.substr(nameStart, nameEnd - nameStart);
2752 size_t bestScore = 100;
2753 std::string bestName =
"";
2754 for (ParameterList::ConstIterator it = validList.begin(); it != validList.end(); it++) {
2755 const std::string& pName = validList.name(it);
2756 this->GetOStream(
Runtime1) <<
"| " << pName;
2757 size_t score =
LevenshteinDistance(name.c_str(), name.length(), pName.c_str(), pName.length());
2758 this->GetOStream(
Runtime1) <<
" -> " << score << std::endl;
2759 if (score < bestScore) {
2764 if (bestScore < 10 && bestName !=
"") {
2765 TEUCHOS_TEST_FOR_EXCEPTION(
true, Teuchos::Exceptions::InvalidParameterName,
2766 eString <<
"The parameter name \"" + name +
"\" is not valid. Did you mean \"" + bestName <<
"\"?\n");
2769 TEUCHOS_TEST_FOR_EXCEPTION(
true, Teuchos::Exceptions::InvalidParameterName,
2770 eString <<
"The parameter name \"" + name +
"\" is not valid.\n");
2779template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2784 ParameterList paramList = constParamList;
2791 if (paramList.isSublist(
"Matrix")) {
2792 blockSize_ = paramList.sublist(
"Matrix").get<
int>(
"PDE equations", MasterList::getDefault<int>(
"number of equations"));
2793 dofOffset_ = paramList.sublist(
"Matrix").get<
GlobalOrdinal>(
"DOF offset", 0);
2797 if (factFact_ == Teuchos::null)
2809 if (paramList.isSublist(
"Factories"))
2810 this->BuildFactoryMap(paramList.sublist(
"Factories"), factoryMap, factoryMap, factoryManagers);
2824 if (paramList.isSublist(
"Hierarchy")) {
2825 ParameterList hieraList = paramList.sublist(
"Hierarchy");
2828 if (hieraList.isParameter(
"max levels")) {
2829 this->numDesiredLevel_ = hieraList.get<
int>(
"max levels");
2830 hieraList.remove(
"max levels");
2833 if (hieraList.isParameter(
"coarse: max size")) {
2834 this->maxCoarseSize_ = hieraList.get<
int>(
"coarse: max size");
2835 hieraList.remove(
"coarse: max size");
2838 if (hieraList.isParameter(
"repartition: rebalance P and R")) {
2839 this->doPRrebalance_ = hieraList.get<
bool>(
"repartition: rebalance P and R");
2840 hieraList.remove(
"repartition: rebalance P and R");
2843 if (hieraList.isParameter(
"transpose: use implicit")) {
2844 this->implicitTranspose_ = hieraList.get<
bool>(
"transpose: use implicit");
2845 hieraList.remove(
"transpose: use implicit");
2848 if (hieraList.isParameter(
"fuse prolongation and update")) {
2849 this->fuseProlongationAndUpdate_ = hieraList.get<
bool>(
"fuse prolongation and update");
2850 hieraList.remove(
"fuse prolongation and update");
2853 if (hieraList.isParameter(
"nullspace: suppress dimension check")) {
2854 this->suppressNullspaceDimensionCheck_ = hieraList.get<
bool>(
"nullspace: suppress dimension check");
2855 hieraList.remove(
"nullspace: suppress dimension check");
2858 if (hieraList.isParameter(
"number of vectors")) {
2859 this->sizeOfMultiVectors_ = hieraList.get<
int>(
"number of vectors");
2860 hieraList.remove(
"number of vectors");
2863 if (hieraList.isSublist(
"matvec params"))
2864 this->matvecParams_ = Teuchos::parameterList(hieraList.sublist(
"matvec params"));
2866 if (hieraList.isParameter(
"coarse grid correction scaling factor")) {
2867 this->scalingFactor_ = hieraList.get<
double>(
"coarse grid correction scaling factor");
2868 hieraList.remove(
"coarse grid correction scaling factor");
2872 if (hieraList.isParameter(
"cycle type")) {
2873 std::map<std::string, CycleType> cycleMap;
2877 std::string cycleType = hieraList.get<std::string>(
"cycle type");
2878 TEUCHOS_TEST_FOR_EXCEPTION(cycleMap.count(cycleType) == 0,
Exceptions::RuntimeError,
"Invalid cycle type: \"" << cycleType <<
"\"");
2879 this->Cycle_ = cycleMap[cycleType];
2882 if (hieraList.isParameter(
"W cycle start level")) {
2883 this->WCycleStartLevel_ = hieraList.get<
int>(
"W cycle start level");
2886 if (hieraList.isParameter(
"hierarchy label")) {
2887 this->hierarchyLabel_ = hieraList.get<std::string>(
"hierarchy label");
2890 if (hieraList.isParameter(
"verbosity")) {
2891 std::string vl = hieraList.get<std::string>(
"verbosity");
2892 hieraList.remove(
"verbosity");
2896 if (hieraList.isParameter(
"output filename"))
2899 if (hieraList.isParameter(
"dependencyOutputLevel"))
2900 this->graphOutputLevel_ = hieraList.get<
int>(
"dependencyOutputLevel");
2903 if (hieraList.isParameter(
"reuse"))
2906 if (hieraList.isSublist(
"DataToWrite")) {
2909 ParameterList foo = hieraList.sublist(
"DataToWrite");
2910 std::string dataName =
"Matrices";
2911 if (foo.isParameter(dataName))
2912 this->matricesToPrint_[
"A"] = Teuchos::getArrayFromStringParameter<int>(foo, dataName);
2913 dataName =
"Prolongators";
2914 if (foo.isParameter(dataName))
2915 this->matricesToPrint_[
"P"] = Teuchos::getArrayFromStringParameter<int>(foo, dataName);
2916 dataName =
"Restrictors";
2917 if (foo.isParameter(dataName))
2918 this->matricesToPrint_[
"R"] = Teuchos::getArrayFromStringParameter<int>(foo, dataName);
2920 if (foo.isParameter(dataName))
2921 this->matricesToPrint_[
"D0"] = Teuchos::getArrayFromStringParameter<int>(foo, dataName);
2925 for (ParameterList::ConstIterator param = hieraList.begin(); param != hieraList.end(); ++param) {
2926 const std::string& paramName = hieraList.name(param);
2928 if (paramName !=
"DataToWrite" && hieraList.isSublist(paramName)) {
2929 ParameterList levelList = hieraList.sublist(paramName);
2932 if (levelList.isParameter(
"startLevel")) {
2933 startLevel = levelList.get<
int>(
"startLevel");
2934 levelList.remove(
"startLevel");
2936 int numDesiredLevel = 1;
2937 if (levelList.isParameter(
"numDesiredLevel")) {
2938 numDesiredLevel = levelList.get<
int>(
"numDesiredLevel");
2939 levelList.remove(
"numDesiredLevel");
2953 BuildFactoryMap(levelList, factoryMap, levelFactoryMap, factoryManagers);
2955 RCP<FactoryManager> m = rcp(
new FactoryManager(levelFactoryMap));
2956 if (hieraList.isParameter(
"use kokkos refactor"))
2957 m->SetKokkosRefactor(hieraList.get<
bool>(
"use kokkos refactor"));
2959 if (startLevel >= 0)
2960 this->AddFactoryManager(startLevel, numDesiredLevel, m);
2962 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::ParameterListInterpreter():: invalid level id");
3091template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
3094 for (ParameterList::ConstIterator param = paramList.begin(); param != paramList.end(); ++param) {
3095 const std::string& paramName = paramList.name(param);
3096 const Teuchos::ParameterEntry& paramValue = paramList.entry(param);
3100 if (paramValue.isList()) {
3101 ParameterList paramList1 = Teuchos::getValue<ParameterList>(paramValue);
3102 if (paramList1.isParameter(
"factory")) {
3105 "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.");
3107 factoryMapOut[paramName] = factFact_->BuildFactory(paramValue, factoryMapIn, factoryManagers);
3109 }
else if (paramList1.isParameter(
"dependency for")) {
3111 "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.");
3113 std::string factoryName = paramList1.get<std::string>(
"dependency for");
3115 RCP<const FactoryBase> factbase = factoryMapIn.find(factoryName )->second;
3117 "MueLu::ParameterListInterpreter(): could not find factory " + factoryName +
" in factory map. Did you define it before?");
3119 RCP<const Factory> factoryconst = Teuchos::rcp_dynamic_cast<const Factory>(factbase);
3120 RCP<Factory> factory = Teuchos::rcp_const_cast<Factory>(factoryconst);
3123 RCP<const ParameterList> validParamList = factory->GetValidParameterList();
3124 for (ParameterList::ConstIterator vparam = validParamList->begin(); vparam != validParamList->end(); ++vparam) {
3125 const std::string& pName = validParamList->name(vparam);
3127 if (!paramList1.isParameter(pName)) {
3132 if (validParamList->isType<RCP<const FactoryBase>>(pName)) {
3134 RCP<const FactoryBase> generatingFact = factFact_->BuildFactory(paramList1.getEntry(pName), factoryMapIn, factoryManagers);
3135 factory->SetFactory(pName, generatingFact.create_weak());
3137 }
else if (validParamList->isType<RCP<const ParameterList>>(pName)) {
3138 if (pName ==
"ParameterList") {
3143 RCP<const ParameterList> subList = Teuchos::sublist(rcp(
new ParameterList(paramList1)), pName);
3144 factory->SetParameter(pName, ParameterEntry(subList));
3147 factory->SetParameter(pName, paramList1.getEntry(pName));
3151 }
else if (paramList1.isParameter(
"group")) {
3153 std::string groupType = paramList1.get<std::string>(
"group");
3155 "group must be of type \"FactoryManager\".");
3157 ParameterList groupList = paramList1;
3158 groupList.remove(
"group");
3160 bool setKokkosRefactor =
false;
3161 bool kokkosRefactor = useKokkos_;
3162 if (groupList.isParameter(
"use kokkos refactor")) {
3163 kokkosRefactor = groupList.get<
bool>(
"use kokkos refactor");
3164 groupList.remove(
"use kokkos refactor");
3165 setKokkosRefactor =
true;
3169 BuildFactoryMap(groupList, factoryMapIn, groupFactoryMap, factoryManagers);
3173 RCP<FactoryManager> m = rcp(
new FactoryManager(groupFactoryMap));
3174 if (setKokkosRefactor)
3175 m->SetKokkosRefactor(kokkosRefactor);
3176 factoryManagers[paramName] = m;
3179 this->GetOStream(
Warnings0) <<
"Could not interpret parameter list " << paramList1 << std::endl;
3181 "XML Parameter list must either be of type \"factory\" or of type \"group\".");
3185 factoryMapOut[paramName] = factFact_->BuildFactory(paramValue, factoryMapIn, factoryManagers);
3193template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
3196 Matrix& A =
dynamic_cast<Matrix&
>(Op);
3197 if (A.IsFixedBlockSizeSet() && (A.GetFixedBlockSize() != blockSize_))
3198 this->GetOStream(
Warnings0) <<
"Setting matrix block size to " << blockSize_ <<
" (value of the parameter in the list) "
3199 <<
"instead of " << A.GetFixedBlockSize() <<
" (provided matrix)." << std::endl
3200 <<
"You may want to check \"number of equations\" (or \"PDE equations\" for factory style list) parameter." << std::endl;
3202 if ((blockSize_ != 1) || (dofOffset_ != 0))
3203 A.SetFixedBlockSize(blockSize_, dofOffset_);
3206 MatrixUtils::checkLocalRowMapMatchesColMap(A);
3208 }
catch (std::bad_cast&) {
3209 this->GetOStream(
Warnings0) <<
"Skipping setting block size as the operator is not a matrix" << std::endl;
3213template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
3222static bool compare(
const ParameterList& list1,
const ParameterList& list2) {
3225 for (ParameterList::ConstIterator it = list1.begin(); it != list1.end(); it++) {
3226 const std::string& name = it->first;
3227 const Teuchos::ParameterEntry& entry1 = it->second;
3229 const Teuchos::ParameterEntry* entry2 = list2.getEntryPtr(name);
3232 if (entry1.isList() && entry2->isList()) {
3233 compare(Teuchos::getValue<ParameterList>(entry1), Teuchos::getValue<ParameterList>(*entry2));
3236 if (entry1.getAny(
false) != entry2->getAny(
false))
3243static inline bool areSame(
const ParameterList& list1,
const ParameterList& list2) {
3249#define MUELU_PARAMETERLISTINTERPRETER_SHORT
#define TEST_MUTUALLY_EXCLUSIVE_S(arg1, arg2)
#define MUELU_KOKKOS_FACTORY_NO_DECL(varName, oldFactory, newFactory)
#define MUELU_KOKKOS_FACTORY(varName, oldFactory, newFactory)
#define TEST_MUTUALLY_EXCLUSIVE(arg1, arg2)
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.
static bool debug()
Whether MueLu is in debug mode.
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.
Prolongator factory that replicates 'Psubblock' matrix to create new prolongator suitable for PDE sys...
Factory for building the constraint operator.
Class for transferring coordinates from a finer level to a coarser one.
Class that encapsulates direct solvers. Autoselection of AmesosSmoother or Amesos2Smoother according ...
Factory for building Energy Minimization prolongators.
Exception throws to report incompatible objects (like maps).
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.
static void EnableTimerSync()
static void DisableMultipleCheckGlobally()
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)
Factory for building filtered matrices using filtered graphs.
Factory for building restriction operators using a prolongator factory.
Provides methods to build a multigrid hierarchy and apply multigrid cycles.
static CycleType GetDefaultCycle()
void SetCycleStartLevel(int cycleStart)
void SetLabel(const std::string &hierarchyLabel)
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.
virtual void SetupHierarchy(Hierarchy &H) const
Setup Hierarchy object.
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.
Class that encapsulates Matlab smoothers.
This class checks matrix properties of A on current level. This factory can be plugged in everywhere ...
Class for restricting a Matrix from a finer to a coarser level.
Class for restricting a MultiVector from a finer to a coarser level.
static const RCP< const NoFactory > getRCP()
Static Get() functions.
Partitioning within a node only.
Factory for generating nullspace.
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 SetMinvAProjectionVariables(const Teuchos::ParameterList ¶mList)
void UpdateFactoryManager_SA(std::string &multigridAlgo, 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_MatrixTransfer(const std::string &VarName, Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
void UpdateFactoryManager_EminReitzinger(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
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 UpdateFactoryManager_Material(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
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_Combine(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
static bool needMaterial(const Teuchos::ParameterList ¶mList, Teuchos::RCP< const Teuchos::ParameterList > defaultList=Teuchos::null, int maxLevel=0)
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
virtual ~ParameterListInterpreter()
Destructor.
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
static bool needMass(const Teuchos::ParameterList ¶mList, Teuchos::RCP< const Teuchos::ParameterList > defaultList=Teuchos::null, int maxLevel=0)
static bool needBlockNumber(const Teuchos::ParameterList ¶mList, Teuchos::RCP< const Teuchos::ParameterList > defaultList=Teuchos::null, int maxLevel=0)
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.
static bool needCoordinates(const Teuchos::ParameterList ¶mList, Teuchos::RCP< const Teuchos::ParameterList > defaultList=Teuchos::null, int maxLevel=0)
void UpdateFactoryManager_CoarseSolvers(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
static std::pair< std::set< std::string >, std::set< std::string > > requiredAndOptionalUserData(const Teuchos::ParameterList ¶mList, Teuchos::RCP< const Teuchos::ParameterList > defaultList=Teuchos::null, int maxLevel=0)
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 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.
Interface to block smoothers in Teko package.
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)
static bool test_and_set_var(const Teuchos::ParameterList ¶mList, const std::string ¶mName, paramType &varName)
MsgType toVerbLevel(const std::string &verbLevelStr)
static void test_and_set_param_2list(const Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, const std::string ¶mName, Teuchos::ParameterList &listWrite)
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)
static void test_and_set_var_from_masterlist(Teuchos::ParameterList ¶mList, const std::string ¶mName)
std::string toString(const T &what)
Little helper function to convert non-string types to strings.
static paramType set_var_2list(const Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, const std::string ¶mName)
static bool test_param_2list(const Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, const std::string ¶mName, const paramType &cmpValue)