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,
Exceptions::Incompatible,
"MueLu_CreateXpetraPreconditioner: Must supply M 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>
269 ParameterList paramList;
271 projectMinv_ =
false;
272 projectMinvA_ =
true;
273 if (constParamList.isSublist(
"project auxiliary matrices")) {
274 auto projectList = constParamList.sublist(
"project auxiliary matrices");
275 if (projectList.isParameter(
"M")) {
277 projectMinvA_ =
false;
279 if (projectList.isParameter(
"Minv")) {
281 projectMinvA_ =
false;
283 if (projectList.isParameter(
"MinvA")) {
284 projectMinvA_ =
true;
288 projectMinv_ =
false;
289 projectMinvA_ =
true;
292template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
295 ParameterList paramList;
297 auto problemType = set_var_2list<std::string>(constParamList, constParamList,
"problem: type");
298 if (problemType !=
"unknown") {
300 paramList.setParameters(constParamList);
304 paramList = constParamList;
308 useKokkos_ = !Node::is_serial;
309 (void)test_and_set_var<bool>(paramList,
"use kokkos refactor", useKokkos_);
312 auto syncTimers = set_var_2list<bool>(paramList, paramList,
"synchronize factory timers");
317 if (paramList.isParameter(
"cycle type")) {
318 std::map<std::string, CycleType> cycleMap;
322 auto cycleType = paramList.get<std::string>(
"cycle type");
324 "Invalid cycle type: \"" << cycleType <<
"\"");
325 Cycle_ = cycleMap[cycleType];
328 if (paramList.isParameter(
"W cycle start level")) {
329 WCycleStartLevel_ = paramList.get<
int>(
"W cycle start level");
332 if (paramList.isParameter(
"hierarchy label")) {
333 this->hierarchyLabel_ = paramList.get<std::string>(
"hierarchy label");
336 if (paramList.isParameter(
"coarse grid correction scaling factor"))
337 scalingFactor_ = paramList.get<
double>(
"coarse grid correction scaling factor");
339 this->maxCoarseSize_ = paramList.get<
int>(
"coarse: max size", MasterList::getDefault<int>(
"coarse: max size"));
340 this->numDesiredLevel_ = paramList.get<
int>(
"max levels", MasterList::getDefault<int>(
"max levels"));
341 blockSize_ = paramList.get<
int>(
"number of equations", MasterList::getDefault<int>(
"number of equations"));
343 (void)test_and_set_var<int>(paramList,
"debug: graph level", this->graphOutputLevel_);
346 if (paramList.isParameter(
"keep data"))
347 this->dataToKeep_ = Teuchos::getArrayFromStringParameter<std::string>(paramList,
"keep data");
350 if (paramList.isSublist(
"export data")) {
351 ParameterList printList = paramList.sublist(
"export data");
354 if (printList.isParameter(
"Nullspace"))
355 this->nullspaceToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"Nullspace");
356 if (printList.isParameter(
"Coordinates"))
357 this->coordinatesToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"Coordinates");
358 if (printList.isParameter(
"Material"))
359 this->materialToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"Material");
360 if (printList.isParameter(
"Aggregates"))
361 this->aggregatesToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"Aggregates");
362 if (printList.isParameter(
"pcoarsen: element to node map"))
363 this->elementToNodeMapsToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"pcoarsen: element to node map");
366 for (
auto iter = printList.begin(); iter != printList.end(); iter++) {
367 const std::string& name = printList.name(iter);
369 if (name ==
"Nullspace" || name ==
"Coordinates" || name ==
"Material" || name ==
"Aggregates" || name ==
"pcoarsen: element to node map")
372 this->matricesToPrint_[name] = Teuchos::getArrayFromStringParameter<int>(printList, name);
379 auto verbosityLevel = set_var_2list<std::string>(paramList, paramList,
"verbosity");
384 auto outputFilename = set_var_2list<std::string>(paramList, paramList,
"output filename");
385 if (outputFilename !=
"")
395 useCoordinates_ =
false;
396 useBlockNumber_ =
false;
397 if (test_param_2list<std::string>(paramList, paramList,
"aggregation: strength-of-connection: matrix",
"distance laplacian"))
398 useCoordinates_ =
true;
399 if (test_param_2list<bool>(paramList, paramList,
"aggregation: use blocking",
true))
400 useBlockNumber_ =
true;
401 if (test_param_2list<std::string>(paramList, paramList,
"aggregation: drop scheme",
"distance laplacian") ||
402 test_param_2list<std::string>(paramList, paramList,
"aggregation: type",
"brick") ||
403 test_param_2list<bool>(paramList, paramList,
"aggregation: export visualization data",
true)) {
404 useCoordinates_ =
true;
405 }
else if (test_param_2list<std::string>(paramList, paramList,
"aggregation: drop scheme",
"block diagonal distance laplacian")) {
406 useCoordinates_ =
true;
407 useBlockNumber_ =
true;
408 }
else if (test_param_2list<std::string>(paramList, paramList,
"aggregation: drop scheme",
"block diagonal") ||
409 test_param_2list<std::string>(paramList, paramList,
"aggregation: drop scheme",
"block diagonal classical") ||
410 test_param_2list<std::string>(paramList, paramList,
"aggregation: drop scheme",
"block diagonal signed classical") ||
411 test_param_2list<std::string>(paramList, paramList,
"aggregation: drop scheme",
"block diagonal colored signed classical") ||
412 test_param_2list<std::string>(paramList, paramList,
"aggregation: drop scheme",
"signed classical")) {
413 useBlockNumber_ =
true;
414 }
else if (paramList.isSublist(
"smoother: params")) {
415 const auto smooParamList = paramList.sublist(
"smoother: params");
416 if (smooParamList.isParameter(
"partitioner: type") &&
417 (smooParamList.get<std::string>(
"partitioner: type") ==
"line")) {
418 useCoordinates_ =
true;
421 for (
int levelID = 0; levelID < this->numDesiredLevel_; levelID++) {
422 std::string levelStr =
"level " +
toString(levelID);
424 if (paramList.isSublist(levelStr)) {
425 const ParameterList& levelList = paramList.sublist(levelStr);
427 if (test_param_2list<std::string>(levelList, paramList,
"aggregation: drop scheme",
"distance laplacian") ||
428 test_param_2list<std::string>(levelList, paramList,
"aggregation: type",
"brick") ||
429 test_param_2list<bool>(levelList, paramList,
"aggregation: export visualization data",
true)) {
430 useCoordinates_ =
true;
431 }
else if (test_param_2list<std::string>(levelList, paramList,
"aggregation: drop scheme",
"block diagonal distance laplacian")) {
432 useCoordinates_ =
true;
433 useBlockNumber_ =
true;
434 }
else if (test_param_2list<std::string>(levelList, paramList,
"aggregation: drop scheme",
"block diagonal") ||
435 test_param_2list<std::string>(levelList, paramList,
"aggregation: drop scheme",
"block diagonal classical") ||
436 test_param_2list<std::string>(levelList, paramList,
"aggregation: drop scheme",
"block diagonal signed classical") ||
437 test_param_2list<std::string>(levelList, paramList,
"aggregation: drop scheme",
"block diagonal colored signed classical") ||
438 test_param_2list<std::string>(levelList, paramList,
"aggregation: drop scheme",
"signed classical")) {
439 useBlockNumber_ =
true;
445 useMaterial_ =
false;
446 if (test_param_2list<std::string>(paramList, paramList,
"aggregation: distance laplacian metric",
"material")) {
450 if (test_param_2list<bool>(paramList, paramList,
"repartition: enable",
true)) {
452 if (test_param_2list<bool>(paramList, paramList,
"repartition: use subcommunicators",
true) &&
453 test_param_2list<bool>(paramList, paramList,
"repartition: use subcommunicators in place",
true)) {
455 }
else if (!paramList.isSublist(
"repartition: params")) {
456 useCoordinates_ =
true;
458 const ParameterList& repParams = paramList.sublist(
"repartition: params");
459 if (repParams.isType<std::string>(
"algorithm")) {
460 const std::string algo = repParams.get<std::string>(
"algorithm");
461 if (algo ==
"multijagged" || algo ==
"rcb") {
462 useCoordinates_ =
true;
465 useCoordinates_ =
true;
469 for (
int levelID = 0; levelID < this->numDesiredLevel_; levelID++) {
470 std::string levelStr =
"level " +
toString(levelID);
472 if (paramList.isSublist(levelStr)) {
473 const ParameterList& levelList = paramList.sublist(levelStr);
475 if (test_param_2list<bool>(levelList, paramList,
"repartition: enable",
true)) {
476 if (!levelList.isSublist(
"repartition: params")) {
477 useCoordinates_ =
true;
480 const ParameterList& repParams = levelList.sublist(
"repartition: params");
481 if (repParams.isType<std::string>(
"algorithm")) {
482 const std::string algo = repParams.get<std::string>(
"algorithm");
483 if (algo ==
"multijagged" || algo ==
"rcb") {
484 useCoordinates_ =
true;
488 useCoordinates_ =
true;
497 changedPRrebalance_ =
false;
498 changedPRViaCopyrebalance_ =
false;
499 if (test_param_2list<bool>(paramList, paramList,
"repartition: enable",
true)) {
500 changedPRrebalance_ = test_and_set_var<bool>(paramList,
"repartition: rebalance P and R", this->doPRrebalance_);
501 changedPRViaCopyrebalance_ = test_and_set_var<bool>(paramList,
"repartition: explicit via new copy rebalance P and R", this->doPRViaCopyrebalance_);
505 changedImplicitTranspose_ = test_and_set_var<bool>(paramList,
"transpose: use implicit", this->implicitTranspose_);
508 (void)test_and_set_var<bool>(paramList,
"fuse prolongation and update", this->fuseProlongationAndUpdate_);
511 (void)test_and_set_var<bool>(paramList,
"nullspace: suppress dimension check", this->suppressNullspaceDimensionCheck_);
513 if (paramList.isSublist(
"matvec params"))
514 this->matvecParams_ = Teuchos::parameterList(paramList.sublist(
"matvec params"));
519 defaultManager->SetVerbLevel(this->verbosity_);
520 defaultManager->SetKokkosRefactor(useKokkos_);
523 std::vector<keep_pair> keeps0;
524 UpdateFactoryManager(paramList, ParameterList(), *defaultManager, 0 , keeps0);
530 for (
int levelID = 0; levelID < this->numDesiredLevel_; levelID++) {
536 RCP<FactoryManager> levelManager = rcp(
new FactoryManager(*defaultManager));
537 levelManager->SetVerbLevel(defaultManager->GetVerbLevel());
539 std::vector<keep_pair> keeps;
540 if (paramList.isSublist(
"level " +
toString(levelID))) {
542 ParameterList& levelList = paramList.sublist(
"level " +
toString(levelID),
true );
543 UpdateFactoryManager(levelList, paramList, *levelManager, levelID, keeps);
546 ParameterList levelList;
547 UpdateFactoryManager(levelList, paramList, *levelManager, levelID, keeps);
550 this->keep_[levelID] = keeps;
551 this->AddFactoryManager(levelID, 1, levelManager);
560 if (test_param_2list<bool>(paramList, paramList,
"print initial parameters",
true))
561 this->GetOStream(
static_cast<MsgType>(
Runtime1), 0) << paramList << std::endl;
563 if (test_param_2list<bool>(paramList, paramList,
"print unused parameters",
true)) {
565 ParameterList unusedParamList;
568 for (ParameterList::ConstIterator it = paramList.begin(); it != paramList.end(); it++) {
569 const ParameterEntry& entry = paramList.entry(it);
571 if (!entry.isList() && !entry.isUsed())
572 unusedParamList.setEntry(paramList.name(it), entry);
576 for (
int levelID = 0; levelID < this->numDesiredLevel_; levelID++) {
577 std::string levelStr =
"level " +
toString(levelID);
579 if (paramList.isSublist(levelStr)) {
580 const ParameterList& levelList = paramList.sublist(levelStr);
582 for (ParameterList::ConstIterator itr = levelList.begin(); itr != levelList.end(); ++itr) {
583 const ParameterEntry& entry = levelList.entry(itr);
585 if (!entry.isList() && !entry.isUsed())
586 unusedParamList.sublist(levelStr).setEntry(levelList.name(itr), entry);
591 if (unusedParamList.numParams() > 0) {
592 std::ostringstream unusedParamsStream;
594 unusedParamList.print(unusedParamsStream, indent);
596 this->GetOStream(
Warnings1) <<
"The following parameters were not used:\n"
597 << unusedParamsStream.str() << std::endl;
607template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
610 int levelID, std::vector<keep_pair>& keeps)
const {
614 using strings = std::unordered_set<std::string>;
617 if (paramList.numParams() == 0 && defaultList.numParams() > 0)
618 paramList = ParameterList(defaultList);
620 auto reuseType = set_var_2list<std::string>(paramList, defaultList,
"reuse: type");
621 TEUCHOS_TEST_FOR_EXCEPTION(strings({
"none",
"tP",
"RP",
"emin",
"RAP",
"full",
"S"}).count(reuseType) == 0,
624 auto multigridAlgo = set_var_2list<std::string>(paramList, defaultList,
"multigrid algorithm");
625 TEUCHOS_TEST_FOR_EXCEPTION(strings({
"unsmoothed",
"sa",
"pg",
"emin",
"matlab",
"pcoarsen",
"classical",
"smoothed reitzinger",
"unsmoothed reitzinger",
"emin reitzinger",
"replicate",
"combine"}).count(multigridAlgo) == 0,
626 Exceptions::RuntimeError,
"Unknown \"multigrid algorithm\" value: \"" << multigridAlgo <<
"\". Please consult User's Guide.");
627#ifndef HAVE_MUELU_MATLAB
629 "Cannot use matlab for multigrid algorithm - MueLu was not configured with MATLAB support.");
631#ifndef HAVE_MUELU_INTREPID2
633 "Cannot use IntrepidPCoarsen prolongator factory - MueLu was not configured with Intrepid support.");
638 if (reuseType ==
"none" || reuseType ==
"S" || reuseType ==
"RP" || reuseType ==
"RAP") {
641 }
else if (reuseType ==
"tP" && (multigridAlgo !=
"sa" && multigridAlgo !=
"unsmoothed")) {
643 this->GetOStream(
Warnings0) <<
"Ignoring \"tP\" reuse option as it is only compatible with \"sa\", "
644 "or \"unsmoothed\" multigrid algorithms"
647 }
else if (reuseType ==
"emin" && multigridAlgo !=
"emin") {
649 this->GetOStream(
Warnings0) <<
"Ignoring \"emin\" reuse option it is only compatible with "
650 "\"emin\" multigrid algorithm"
656 bool have_userP =
false;
657 if (paramList.isParameter(
"P") && !paramList.get<RCP<Matrix>>(
"P").is_null())
661 UpdateFactoryManager_CoarseSolvers(paramList, defaultList, manager, levelID, keeps);
664 UpdateFactoryManager_Smoothers(paramList, defaultList, manager, levelID, keeps);
668 UpdateFactoryManager_BlockNumber(paramList, defaultList, manager, levelID, keeps);
671 if (multigridAlgo ==
"unsmoothed reitzinger" || multigridAlgo ==
"smoothed reitzinger")
672 UpdateFactoryManager_Reitzinger(paramList, defaultList, manager, levelID, keeps);
673 else if (multigridAlgo ==
"emin reitzinger")
674 UpdateFactoryManager_EminReitzinger(paramList, defaultList, manager, levelID, keeps);
676 UpdateFactoryManager_Aggregation_TentativeP(paramList, defaultList, manager, levelID, keeps);
679 RCP<Factory> nullSpaceFactory;
680 UpdateFactoryManager_Nullspace(paramList, defaultList, manager, levelID, keeps, nullSpaceFactory);
691 }
else if (multigridAlgo ==
"unsmoothed" || multigridAlgo ==
"unsmoothed reitzinger") {
695 }
else if (multigridAlgo ==
"classical") {
699 }
else if (multigridAlgo ==
"sa" || multigridAlgo ==
"smoothed reitzinger") {
701 UpdateFactoryManager_SA(multigridAlgo, paramList, defaultList, manager, levelID, keeps);
703 }
else if (multigridAlgo ==
"emin") {
705 UpdateFactoryManager_Emin(paramList, defaultList, manager, levelID, keeps);
707 }
else if (multigridAlgo ==
"emin reitzinger") {
710 }
else if (multigridAlgo ==
"replicate") {
711 UpdateFactoryManager_Replicate(paramList, defaultList, manager, levelID, keeps);
713 }
else if (multigridAlgo ==
"combine") {
714 UpdateFactoryManager_Combine(paramList, defaultList, manager, levelID, keeps);
716 }
else if (multigridAlgo ==
"pg") {
718 UpdateFactoryManager_PG(paramList, defaultList, manager, levelID, keeps);
720 }
else if (multigridAlgo ==
"matlab") {
722 UpdateFactoryManager_Matlab(paramList, defaultList, manager, levelID, keeps);
724 }
else if (multigridAlgo ==
"pcoarsen") {
726 UpdateFactoryManager_PCoarsen(paramList, defaultList, manager, levelID, keeps);
730 UpdateFactoryManager_SemiCoarsen(paramList, defaultList, manager, levelID, keeps);
733 UpdateFactoryManager_Restriction(paramList, defaultList, manager, levelID, keeps);
736 UpdateFactoryManager_RAP(paramList, defaultList, manager, levelID, keeps);
738 if (multigridAlgo ==
"smoothed reitzinger") {
740 auto saDampingFactor = set_var_2list<double>(paramList, defaultList,
"sa: damping factor");
741 if (saDampingFactor != 0.0)
742 UpdateFactoryManager_MatrixTransfer(
"CurlCurl", paramList, defaultList, manager, levelID, keeps);
746 UpdateFactoryManager_LocalOrdinalTransfer(
"BlockNumber", multigridAlgo, paramList, defaultList, manager, levelID, keeps);
749 UpdateFactoryManager_Coordinates(paramList, defaultList, manager, levelID, keeps);
752 UpdateFactoryManager_Material(paramList, defaultList, manager, levelID, keeps);
755 if ((reuseType ==
"RP" || reuseType ==
"RAP" || reuseType ==
"full") && levelID)
758 if (reuseType ==
"RP" && levelID) {
760 if (!this->implicitTranspose_)
763 if ((reuseType ==
"tP" || reuseType ==
"RP" || reuseType ==
"emin") && useCoordinates_ && levelID)
767 UpdateFactoryManager_Repartition(paramList, defaultList, manager, levelID, keeps, nullSpaceFactory);
770 auto socMatrix = set_var_2list<std::string>(paramList, defaultList,
"aggregation: strength-of-connection: matrix");
771 if (socMatrix ==
"MinvA") {
780 std::string MinvFactory =
"CoalesceDrop";
781 std::string MinvAFactory =
"CoalesceDrop";
782 if (paramList.isSublist(
"project auxiliary matrices")) {
783 auto projectList = paramList.sublist(
"project auxiliary matrices");
784 if (projectList.isParameter(
"M")) {
785 TEUCHOS_TEST_FOR_EXCEPTION(projectList.get(
"M",
"") !=
"NoFactory",
Exceptions::InvalidArgument,
"Must specify \"NoFactory\" when projecting M");
787 if (projectList.isParameter(
"Minv")) {
788 MinvFactory = projectList.get(
"Minv",
"");
789 TEUCHOS_TEST_FOR_EXCEPTION((MinvFactory !=
"NoFactory") && (MinvFactory !=
"CoalesceDrop"),
Exceptions::InvalidArgument,
"Must specify \"NoFactory\" or \"CoalesceDrop\"");
791 if (projectList.isParameter(
"MinvA")) {
792 MinvAFactory = projectList.get(
"MinvA",
"");
793 TEUCHOS_TEST_FOR_EXCEPTION((MinvAFactory !=
"NoFactory") && (MinvAFactory !=
"CoalesceDrop"),
Exceptions::InvalidArgument,
"Must specify \"NoFactory\" or \"CoalesceDrop\"");
806 if (projectM_) UpdateFactoryManager_MatrixTransfer(
"M", paramList, defaultList, manager, levelID, keeps);
808 if (!projectM_ && !projectMinv_ && (MinvAFactory ==
"CoalesceDrop") && projectMinvA_ && (levelID == 0)) {
813 if ((levelID > 0) || (MinvAFactory ==
"NoFactory"))
814 UpdateFactoryManager_MatrixTransfer(
"MinvA", paramList, defaultList, manager, levelID, keeps);
821 if ((levelID > 0) || (MinvFactory ==
"NoFactory"))
822 UpdateFactoryManager_MatrixTransfer(
"Minv", paramList, defaultList, manager, levelID, keeps);
831 UpdateFactoryManager_LowPrecision(paramList, defaultList, manager, levelID, keeps);
834 if ((reuseType ==
"RAP" || reuseType ==
"full") && levelID) {
836 if (!this->implicitTranspose_)
849template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
852 FactoryManager& manager,
int levelID, std::vector<keep_pair>& keeps)
const {
853 auto multigridAlgo = set_var_2list<std::string>(paramList, defaultList,
"multigrid algorithm");
854 auto reuseType = set_var_2list<std::string>(paramList, defaultList,
"reuse: type");
855 auto useMaxAbsDiagonalScaling = set_var_2list<bool>(paramList, defaultList,
"sa: use rowsumabs diagonal scaling");
859 bool isCustomSmoother =
860 paramList.isParameter(
"smoother: pre or post") ||
861 paramList.isParameter(
"smoother: type") || paramList.isParameter(
"smoother: pre type") || paramList.isParameter(
"smoother: post type") ||
862 paramList.isSublist(
"smoother: params") || paramList.isSublist(
"smoother: pre params") || paramList.isSublist(
"smoother: post params") ||
863 paramList.isParameter(
"smoother: sweeps") || paramList.isParameter(
"smoother: pre sweeps") || paramList.isParameter(
"smoother: post sweeps") ||
864 paramList.isParameter(
"smoother: overlap") || paramList.isParameter(
"smoother: pre overlap") || paramList.isParameter(
"smoother: post overlap");
866 auto PreOrPost = set_var_2list<std::string>(paramList, defaultList,
"smoother: pre or post");
868 manager.
SetFactory(
"Smoother", Teuchos::null);
870 }
else if (isCustomSmoother) {
874#define TEST_MUTUALLY_EXCLUSIVE(arg1, arg2) \
875 TEUCHOS_TEST_FOR_EXCEPTION(paramList.isParameter(#arg1) && paramList.isParameter(#arg2), \
876 Exceptions::InvalidArgument, "You cannot specify both \"" #arg1 "\" and \"" #arg2 "\"");
877#define TEST_MUTUALLY_EXCLUSIVE_S(arg1, arg2) \
878 TEUCHOS_TEST_FOR_EXCEPTION(paramList.isSublist(#arg1) && paramList.isSublist(#arg2), \
879 Exceptions::InvalidArgument, "You cannot specify both \"" #arg1 "\" and \"" #arg2 "\"");
889 TEUCHOS_TEST_FOR_EXCEPTION(
PreOrPost ==
"both" && (paramList.isParameter(
"smoother: pre type") != paramList.isParameter(
"smoother: post type")),
894 ParameterList defaultSmootherParams;
895 defaultSmootherParams.set(
"relaxation: type",
"Symmetric Gauss-Seidel");
896 defaultSmootherParams.set(
"relaxation: sweeps", Teuchos::OrdinalTraits<LO>::one());
897 defaultSmootherParams.set(
"relaxation: damping factor", Teuchos::ScalarTraits<Scalar>::one());
899 RCP<SmootherFactory> preSmoother = Teuchos::null, postSmoother = Teuchos::null;
900 std::string preSmootherType, postSmootherType;
901 ParameterList preSmootherParams, postSmootherParams;
903 auto setChebyshevSettings = [&](
const std::string& smootherType, Teuchos::ParameterList& smootherParams) {
904 auto upperCaseSmootherType = smootherType;
905 std::transform(smootherType.begin(), smootherType.end(), upperCaseSmootherType.begin(), ::toupper);
906 if (upperCaseSmootherType !=
"CHEBYSHEV")
return;
908 if (smootherParams.isParameter(
"chebyshev: use rowsumabs diagonal scaling")) {
909 bool useMaxAbsDiagonalScalingCheby = smootherParams.get<
bool>(
"chebyshev: use rowsumabs diagonal scaling");
910 TEUCHOS_TEST_FOR_EXCEPTION(useMaxAbsDiagonalScaling != useMaxAbsDiagonalScalingCheby,
911 Exceptions::RuntimeError,
"'chebyshev: use rowsumabs diagonal scaling' (" << std::boolalpha << useMaxAbsDiagonalScalingCheby <<
") must match 'sa: use rowsumabs diagonal scaling' (" << std::boolalpha << useMaxAbsDiagonalScaling <<
")\n");
913 if (useMaxAbsDiagonalScaling)
914 smootherParams.set(
"chebyshev: use rowsumabs diagonal scaling", useMaxAbsDiagonalScaling);
918 if (paramList.isParameter(
"smoother: overlap"))
919 overlap = paramList.get<
int>(
"smoother: overlap");
922 if (paramList.isParameter(
"smoother: pre type")) {
923 preSmootherType = paramList.get<std::string>(
"smoother: pre type");
925 auto preSmootherTypeTmp = set_var_2list<std::string>(paramList, defaultList,
"smoother: type");
926 preSmootherType = preSmootherTypeTmp;
928 if (paramList.isParameter(
"smoother: pre overlap"))
929 overlap = paramList.get<
int>(
"smoother: pre overlap");
931 if (paramList.isSublist(
"smoother: pre params"))
932 preSmootherParams = paramList.sublist(
"smoother: pre params");
933 else if (paramList.isSublist(
"smoother: params"))
934 preSmootherParams = paramList.sublist(
"smoother: params");
935 else if (defaultList.isSublist(
"smoother: params"))
936 preSmootherParams = defaultList.sublist(
"smoother: params");
937 else if (preSmootherType ==
"RELAXATION")
938 preSmootherParams = defaultSmootherParams;
940 setChebyshevSettings(preSmootherType, preSmootherParams);
942#if defined(HAVE_MUELU_INTREPID2) && defined(HAVE_MUELU_EXPERIMENTAL)
944 if (multigridAlgo ==
"pcoarsen" && preSmootherType ==
"TOPOLOGICAL" &&
945 defaultList.isParameter(
"pcoarsen: schedule") && defaultList.isParameter(
"pcoarsen: element")) {
948 auto pcoarsen_schedule = Teuchos::getArrayFromStringParameter<int>(defaultList,
"pcoarsen: schedule");
949 auto pcoarsen_element = defaultList.get<std::string>(
"pcoarsen: element");
951 if (levelID < (
int)pcoarsen_schedule.size()) {
953 auto lo = pcoarsen_element + std::to_string(pcoarsen_schedule[levelID]);
954 preSmootherParams.set(
"pcoarsen: hi basis", lo);
959#ifdef HAVE_MUELU_MATLAB
960 if (preSmootherType ==
"matlab")
964#ifdef HAVE_MUELU_TEKO
965 if (preSmootherType ==
"teko")
973 if (paramList.isParameter(
"smoother: post type"))
974 postSmootherType = paramList.get<std::string>(
"smoother: post type");
976 auto postSmootherTypeTmp = set_var_2list<std::string>(paramList, defaultList,
"smoother: type");
977 postSmootherType = postSmootherTypeTmp;
980 if (paramList.isSublist(
"smoother: post params"))
981 postSmootherParams = paramList.sublist(
"smoother: post params");
982 else if (paramList.isSublist(
"smoother: params"))
983 postSmootherParams = paramList.sublist(
"smoother: params");
984 else if (defaultList.isSublist(
"smoother: params"))
985 postSmootherParams = defaultList.sublist(
"smoother: params");
986 else if (postSmootherType ==
"RELAXATION")
987 postSmootherParams = defaultSmootherParams;
988 if (paramList.isParameter(
"smoother: post overlap"))
989 overlap = paramList.get<
int>(
"smoother: post overlap");
991 setChebyshevSettings(postSmootherType, postSmootherParams);
993 if (postSmootherType == preSmootherType &&
areSame(preSmootherParams, postSmootherParams))
994 postSmoother = preSmoother;
996#if defined(HAVE_MUELU_INTREPID2) && defined(HAVE_MUELU_EXPERIMENTAL)
998 if (multigridAlgo ==
"pcoarsen" && preSmootherType ==
"TOPOLOGICAL" &&
999 defaultList.isParameter(
"pcoarsen: schedule") && defaultList.isParameter(
"pcoarsen: element")) {
1002 auto pcoarsen_schedule = Teuchos::getArrayFromStringParameter<int>(defaultList,
"pcoarsen: schedule");
1003 auto pcoarsen_element = defaultList.get<std::string>(
"pcoarsen: element");
1005 if (levelID < (
int)pcoarsen_schedule.size()) {
1007 auto lo = pcoarsen_element + std::to_string(pcoarsen_schedule[levelID]);
1008 postSmootherParams.set(
"pcoarsen: hi basis", lo);
1013#ifdef HAVE_MUELU_MATLAB
1014 if (postSmootherType ==
"matlab")
1018#ifdef HAVE_MUELU_TEKO
1019 if (postSmootherType ==
"teko")
1027 if (preSmoother == postSmoother)
1030 manager.
SetFactory(
"PreSmoother", preSmoother);
1031 manager.
SetFactory(
"PostSmoother", postSmoother);
1038 bool reuseSmoothers = (reuseType ==
"S" || reuseType !=
"none");
1039 if (reuseSmoothers) {
1040 auto preSmootherFactory = rcp_const_cast<Factory>(rcp_dynamic_cast<const Factory>(manager.
GetFactory(
"PreSmoother")));
1042 if (preSmootherFactory != Teuchos::null) {
1043 ParameterList postSmootherFactoryParams;
1044 postSmootherFactoryParams.set(
"keep smoother data",
true);
1045 preSmootherFactory->SetParameterList(postSmootherFactoryParams);
1047 keeps.push_back(
keep_pair(
"PreSmoother data", preSmootherFactory.get()));
1050 auto postSmootherFactory = rcp_const_cast<Factory>(rcp_dynamic_cast<const Factory>(manager.
GetFactory(
"PostSmoother")));
1051 if (postSmootherFactory != Teuchos::null) {
1052 ParameterList postSmootherFactoryParams;
1053 postSmootherFactoryParams.set(
"keep smoother data",
true);
1054 postSmootherFactory->SetParameterList(postSmootherFactoryParams);
1056 keeps.push_back(
keep_pair(
"PostSmoother data", postSmootherFactory.get()));
1059 auto coarseFactory = rcp_const_cast<Factory>(rcp_dynamic_cast<const Factory>(manager.
GetFactory(
"CoarseSolver")));
1060 if (coarseFactory != Teuchos::null) {
1061 ParameterList coarseFactoryParams;
1062 coarseFactoryParams.set(
"keep smoother data",
true);
1063 coarseFactory->SetParameterList(coarseFactoryParams);
1065 keeps.push_back(
keep_pair(
"PreSmoother data", coarseFactory.get()));
1069 if ((reuseType ==
"RAP" && levelID) || (reuseType ==
"full")) {
1088template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1093 bool isCustomCoarseSolver =
1094 paramList.isParameter(
"coarse: type") ||
1095 paramList.isParameter(
"coarse: params");
1096 if (test_param_2list<std::string>(paramList, defaultList,
"coarse: type",
"none")) {
1097 manager.
SetFactory(
"CoarseSolver", Teuchos::null);
1099 }
else if (isCustomCoarseSolver) {
1103 auto coarseType = set_var_2list<std::string>(paramList, defaultList,
"coarse: type");
1106 if (paramList.isParameter(
"coarse: overlap"))
1107 overlap = paramList.get<
int>(
"coarse: overlap");
1109 ParameterList coarseParams;
1110 if (paramList.isSublist(
"coarse: params"))
1111 coarseParams = paramList.sublist(
"coarse: params");
1112 else if (defaultList.isSublist(
"coarse: params"))
1113 coarseParams = defaultList.sublist(
"coarse: params");
1115 using strings = std::unordered_set<std::string>;
1117 RCP<SmootherPrototype> coarseSmoother;
1121 if (strings({
"RELAXATION",
"CHEBYSHEV",
"ILUT",
"ILU",
"RILUK",
"SCHWARZ",
"Amesos",
1122 "BLOCK RELAXATION",
"BLOCK_RELAXATION",
"BLOCKRELAXATION",
1123 "SPARSE BLOCK RELAXATION",
"SPARSE_BLOCK_RELAXATION",
"SPARSEBLOCKRELAXATION",
1124 "LINESMOOTHING_BANDEDRELAXATION",
"LINESMOOTHING_BANDED_RELAXATION",
"LINESMOOTHING_BANDED RELAXATION",
1125 "LINESMOOTHING_TRIDIRELAXATION",
"LINESMOOTHING_TRIDI_RELAXATION",
"LINESMOOTHING_TRIDI RELAXATION",
1126 "LINESMOOTHING_TRIDIAGONALRELAXATION",
"LINESMOOTHING_TRIDIAGONAL_RELAXATION",
"LINESMOOTHING_TRIDIAGONAL RELAXATION",
1127 "TOPOLOGICAL",
"FAST_ILU",
"FAST_IC",
"FAST_ILDL",
"HIPTMAIR"})
1128 .count(coarseType)) {
1129 coarseSmoother = rcp(
new TrilinosSmoother(coarseType, coarseParams, overlap));
1131#ifdef HAVE_MUELU_MATLAB
1132 if (coarseType ==
"matlab")
1136#ifdef HAVE_MUELU_TEKO
1137 if (coarseType ==
"teko")
1141 coarseSmoother = rcp(
new DirectSolver(coarseType, coarseParams));
1151template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1154 FactoryManager& manager,
int levelID, std::vector<keep_pair>& )
const {
1155 ParameterList rParams;
1156 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: enable", rParams);
1157 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: use subcommunicators", rParams);
1158 test_and_set_param_2list<bool>(paramList, defaultList,
"tentative: constant column sums", rParams);
1159 test_and_set_param_2list<bool>(paramList, defaultList,
"tentative: calculate qr", rParams);
1162 rFactory->SetParameterList(rParams);
1170 rFactory->SetFactory(
"D0", this->GetFactoryManager(levelID - 1)->GetFactory(
"D0"));
1182template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1185 int levelID, std::vector<keep_pair>& )
const {
1186 ParameterList rParams;
1187 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: enable", rParams);
1188 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: use subcommunicators", rParams);
1189 test_and_set_param_2list<bool>(paramList, defaultList,
"tentative: constant column sums", rParams);
1190 test_and_set_param_2list<bool>(paramList, defaultList,
"tentative: calculate qr", rParams);
1193 rFactory->SetParameterList(rParams);
1201 rFactory->SetFactory(
"D0", this->GetFactoryManager(levelID - 1)->GetFactory(
"D0"));
1209 auto reuseType = set_var_2list<std::string>(paramList, defaultList,
"reuse: type");
1213 manager.
SetFactory(
"Ppattern", patternFactory);
1217 ParameterList constraintParams;
1218 constraintFactory->SetFactory(
"Ppattern", manager.
GetFactory(
"Ppattern"));
1219 test_and_set_param_2list<std::string>(paramList, defaultList,
"emin: least squares solver type", constraintParams);
1220 constraintParams.set(
"emin: constraint type",
"maxwell");
1221 constraintFactory->SetParameterList(constraintParams);
1222 manager.
SetFactory(
"Constraint", constraintFactory);
1228 ParameterList Pparams;
1229 test_and_set_param_2list<int>(paramList, defaultList,
"emin: num iterations", Pparams);
1230 test_and_set_param_2list<std::string>(paramList, defaultList,
"emin: iterative method", Pparams);
1231 if (reuseType ==
"emin") {
1232 test_and_set_param_2list<int>(paramList, defaultList,
"emin: num reuse iterations", Pparams);
1233 Pparams.set(
"Keep P0",
true);
1234 Pparams.set(
"Keep Constraint0",
true);
1236 P->SetParameterList(Pparams);
1237 P->SetFactory(
"P", constraintFactory);
1238 P->SetFactory(
"Constraint", constraintFactory);
1245template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1248 FactoryManager& manager,
int levelID, std::vector<keep_pair>& keeps)
const {
1249 using strings = std::unordered_set<std::string>;
1251 auto reuseType = set_var_2list<std::string>(paramList, defaultList,
"reuse: type");
1253 auto aggType = set_var_2list<std::string>(paramList, defaultList,
"aggregation: type");
1254 TEUCHOS_TEST_FOR_EXCEPTION(!strings({
"uncoupled",
"coupled",
"brick",
"matlab",
"notay",
"classical"}).count(aggType),
1258 RCP<AmalgamationFactory> amalgFact;
1259 if (aggType ==
"classical") {
1261 manager.
SetFactory(
"UnAmalgamationInfo", amalgFact);
1265 RCP<Factory> dropFactory;
1267 if (test_param_2list<std::string>(paramList, paramList,
"aggregation: drop scheme",
"matlab")) {
1268#ifdef HAVE_MUELU_MATLAB
1270 ParameterList socParams = paramList.sublist(
"strength-of-connection: params");
1271 dropFactory->SetParameterList(socParams);
1273 throw std::runtime_error(
"Cannot use MATLAB evolutionary strength-of-connection - MueLu was not configured with MATLAB support.");
1275 }
else if (test_param_2list<std::string>(paramList, paramList,
"aggregation: drop scheme",
"unsupported vector smoothing")) {
1277 ParameterList dropParams;
1278 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: drop scheme", dropParams);
1279 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: block diagonal: interleaved blocksize", dropParams);
1280 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: number of random vectors", dropParams);
1281 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: number of times to pre or post smooth", dropParams);
1282 test_and_set_param_2list<Teuchos::Array<double>>(paramList, defaultList,
"aggregation: penalty parameters", dropParams);
1283 dropFactory->SetParameterList(dropParams);
1286 ParameterList dropParams;
1287 if (!rcp_dynamic_cast<CoalesceDropFactory>(dropFactory).is_null())
1288 dropParams.set(
"lightweight wrap",
true);
1289 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: drop scheme", dropParams);
1290 test_and_set_param_2list<double>(paramList, defaultList,
"aggregation: row sum drop tol", dropParams);
1291 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: block diagonal: interleaved blocksize", dropParams);
1292 test_and_set_param_2list<double>(paramList, defaultList,
"aggregation: drop tol", dropParams);
1293 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: use ml scaling of drop tol", dropParams);
1295 test_and_set_param_2list<double>(paramList, defaultList,
"aggregation: Dirichlet threshold", dropParams);
1296 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: greedy Dirichlet", dropParams);
1298 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: distance laplacian metric", dropParams);
1299#ifdef HAVE_MUELU_COALESCEDROP_ALLOW_OLD_PARAMETERS
1300 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: distance laplacian algo", dropParams);
1301 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: classical algo", dropParams);
1303 test_and_set_param_2list<Teuchos::Array<double>>(paramList, defaultList,
"aggregation: distance laplacian directional weights", dropParams);
1304 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: coloring: localize color graph", dropParams);
1305 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: dropping may create Dirichlet", dropParams);
1307 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: use blocking", dropParams);
1308 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: symmetrize graph after dropping", dropParams);
1309 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: strength-of-connection: matrix", dropParams);
1310 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: strength-of-connection: measure", dropParams);
1311 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: use lumping", dropParams);
1312 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: reuse graph", dropParams);
1313 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: reuse eigenvalue", dropParams);
1314 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: use root stencil", dropParams);
1315 test_and_set_param_2list<double>(paramList, defaultList,
"filtered matrix: Dirichlet threshold", dropParams);
1316 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: use spread lumping", dropParams);
1317 test_and_set_param_2list<std::string>(paramList, defaultList,
"filtered matrix: lumping choice", dropParams);
1318 test_and_set_param_2list<double>(paramList, defaultList,
"filtered matrix: spread lumping diag dom growth factor", dropParams);
1319 test_and_set_param_2list<double>(paramList, defaultList,
"filtered matrix: spread lumping diag dom cap", dropParams);
1320 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: count negative diagonals", dropParams);
1323#ifdef HAVE_MUELU_COALESCEDROP_ALLOW_OLD_PARAMETERS
1324 if (!dropParams.isParameter(
"aggregation: drop scheme") ||
1325 (dropParams.isParameter(
"aggregation: drop scheme") &&
1326 ((dropParams.get<std::string>(
"aggregation: drop scheme") !=
"point-wise") && (dropParams.get<std::string>(
"aggregation: drop scheme") !=
"cut-drop")))) {
1327 Teuchos::ParameterList dropParamsWithDefaults(dropParams);
1329 test_and_set_var_from_masterlist<std::string>(dropParamsWithDefaults,
"aggregation: drop scheme");
1330 test_and_set_var_from_masterlist<std::string>(dropParamsWithDefaults,
"aggregation: strength-of-connection: matrix");
1331 test_and_set_var_from_masterlist<std::string>(dropParamsWithDefaults,
"aggregation: strength-of-connection: measure");
1332 test_and_set_var_from_masterlist<bool>(dropParamsWithDefaults,
"aggregation: use blocking");
1335 TEUCHOS_TEST_FOR_EXCEPTION(dropParams.isParameter(
"aggregation: strength-of-connection: matrix") ||
1336 dropParams.isParameter(
"aggregation: strength-of-connection: measure") ||
1337 dropParams.isParameter(
"aggregation: use blocking"),
1338 Teuchos::Exceptions::InvalidParameterType,
1339 "The inputs contain a mix of old and new dropping parameters:\n\n"
1340 << dropParams <<
"\n\nKeep in mind that defaults are set for old parameters, so this gets interpreted as\n\n"
1341 << dropParamsWithDefaults);
1345 if (!amalgFact.is_null())
1346 dropFactory->SetFactory(
"UnAmalgamationInfo", manager.
GetFactory(
"UnAmalgamationInfo"));
1348 if (dropParams.isParameter(
"aggregation: drop scheme")) {
1349 std::string drop_scheme = dropParams.get<std::string>(
"aggregation: drop scheme");
1350 if (drop_scheme ==
"block diagonal colored signed classical")
1351 manager.
SetFactory(
"Coloring Graph", dropFactory);
1352 if ((test_param_2list<bool>(dropParams, defaultList,
"aggregation: use blocking",
true)) ||
1353 (drop_scheme.find(
"block diagonal") != std::string::npos || drop_scheme ==
"signed classical")) {
1355 dropFactory->SetFactory(
"BlockNumber", this->GetFactoryManager(levelID - 1)->GetFactory(
"BlockNumber"));
1357 dropFactory->SetFactory(
"BlockNumber", manager.
GetFactory(
"BlockNumber"));
1361 if (useKokkos_ && (levelID > 0)) {
1362 if (dropParams.isParameter(
"aggregation: strength-of-connection: matrix") && dropParams.get<std::string>(
"aggregation: strength-of-connection: matrix") ==
"MinvA") {
1363 if (projectM_) dropFactory->SetFactory(
"M", this->GetFactoryManager(levelID - 1)->GetFactory(
"M"));
1364 if (projectMinv_) dropFactory->SetFactory(
"Minv", this->GetFactoryManager(levelID - 1)->GetFactory(
"Minv"));
1365 if (projectMinvA_) dropFactory->SetFactory(
"MinvA", this->GetFactoryManager(levelID - 1)->GetFactory(
"MinvA"));
1369 auto socMatrix = set_var_2list<std::string>(paramList, defaultList,
"aggregation: strength-of-connection: matrix");
1370 if ((socMatrix ==
"MinvA") && (paramList.isSublist(
"project auxiliary matrices"))) {
1371 auto projectList = paramList.sublist(
"project auxiliary matrices");
1372 dropParams.set(
"project auxiliary matrices", projectList);
1374 dropFactory->SetParameterList(dropParams);
1379#ifndef HAVE_MUELU_MATLAB
1380 if (aggType ==
"matlab")
1381 throw std::runtime_error(
"Cannot use MATLAB aggregation - MueLu was not configured with MATLAB support.");
1383 RCP<Factory> aggFactory;
1384 if (aggType ==
"uncoupled") {
1386 ParameterList aggParams;
1387 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: ordering", aggParams);
1388 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: min agg size", aggParams);
1389 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: max agg size", aggParams);
1390 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: max selected neighbors", aggParams);
1391 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: backend", aggParams);
1392 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: phase 1 algorithm", aggParams);
1393 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: deterministic", aggParams);
1394 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: coloring algorithm", aggParams);
1395 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: enable phase 1", aggParams);
1396 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: enable phase 2a", aggParams);
1397 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: enable phase 2b", aggParams);
1398 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: enable phase 3", aggParams);
1399 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: match ML phase1", aggParams);
1400 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: match ML phase2a", aggParams);
1401 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: match ML phase2b", aggParams);
1402 test_and_set_param_2list<double>(paramList, defaultList,
"aggregation: phase2a agg factor", aggParams);
1403 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: preserve Dirichlet points", aggParams);
1404 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: error on nodes with no on-rank neighbors", aggParams);
1405 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: phase3 avoid singletons", aggParams);
1406 aggFactory->SetParameterList(aggParams);
1408 aggFactory->SetFactory(
"DofsPerNode", manager.
GetFactory(
"Graph"));
1409 aggFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1412 if (test_param_2list<std::string>(paramList, defaultList,
"aggregation: coloring algorithm",
"mis2 aggregation") ||
1413 test_param_2list<std::string>(paramList, defaultList,
"aggregation: coloring algorithm",
"mis2 coarsening")) {
1414 if (test_param_2list<bool>(paramList, defaultList,
"aggregation: symmetrize graph after dropping",
false))
1415 TEUCHOS_TEST_FOR_EXCEPTION(
true,
1417 "MIS2 algorithms require the use of a symmetrized graph. Please set \"aggregation: symmetrize graph after dropping\" to \"true\".");
1419 }
else if (aggType ==
"brick") {
1421 ParameterList aggParams;
1422 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: brick x size", aggParams);
1423 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: brick y size", aggParams);
1424 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: brick z size", aggParams);
1425 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: brick x Dirichlet", aggParams);
1426 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: brick y Dirichlet", aggParams);
1427 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: brick z Dirichlet", aggParams);
1428 aggFactory->SetParameterList(aggParams);
1432 manager.
SetFactory(
"DofsPerNode", aggFactory);
1438 aggFactory->SetFactory(
"Coordinates", this->GetFactoryManager(levelID - 1)->GetFactory(
"Coordinates"));
1440 }
else if (aggType ==
"classical") {
1443 ParameterList mapParams;
1444 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: deterministic", mapParams);
1445 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: coloring algorithm", mapParams);
1447 ParameterList tempParams;
1448 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: drop scheme", tempParams);
1449 std::string drop_algo = tempParams.get<std::string>(
"aggregation: drop scheme");
1450 if (drop_algo ==
"block diagonal colored signed classical") {
1451 mapParams.set(
"aggregation: coloring: use color graph",
true);
1452 mapFact->SetFactory(
"Coloring Graph", manager.
GetFactory(
"Coloring Graph"));
1454 mapFact->SetParameterList(mapParams);
1455 mapFact->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1456 mapFact->SetFactory(
"UnAmalgamationInfo", manager.
GetFactory(
"UnAmalgamationInfo"));
1462 ParameterList aggParams;
1463 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: classical scheme", aggParams);
1464 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: drop scheme", aggParams);
1465 aggFactory->SetParameterList(aggParams);
1466 aggFactory->SetFactory(
"FC Splitting", manager.
GetFactory(
"FC Splitting"));
1467 aggFactory->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1468 aggFactory->SetFactory(
"DofsPerNode", manager.
GetFactory(
"Graph"));
1469 aggFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1471 if (drop_algo.find(
"block diagonal") != std::string::npos || drop_algo ==
"signed classical") {
1473 aggFactory->SetFactory(
"BlockNumber", this->GetFactoryManager(levelID - 1)->GetFactory(
"BlockNumber"));
1475 aggFactory->SetFactory(
"BlockNumber", manager.
GetFactory(
"BlockNumber"));
1482 if (reuseType ==
"tP" && levelID) {
1484 keeps.push_back(
keep_pair(
"Ptent", aggFactory.get()));
1487 }
else if (aggType ==
"notay") {
1489 ParameterList aggParams;
1490 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: pairwise: size", aggParams);
1491 test_and_set_param_2list<double>(paramList, defaultList,
"aggregation: pairwise: tie threshold", aggParams);
1492 test_and_set_param_2list<double>(paramList, defaultList,
"aggregation: Dirichlet threshold", aggParams);
1493 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: ordering", aggParams);
1494 aggFactory->SetParameterList(aggParams);
1495 aggFactory->SetFactory(
"DofsPerNode", manager.
GetFactory(
"Graph"));
1496 aggFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1498#ifdef HAVE_MUELU_MATLAB
1499 else if (aggType ==
"matlab") {
1500 ParameterList aggParams = paramList.sublist(
"aggregation: params");
1502 aggFactory->SetParameterList(aggParams);
1506 manager.
SetFactory(
"Aggregates", aggFactory);
1510 coarseMap->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1515 ParameterList ptentParams;
1516 if (paramList.isSublist(
"matrixmatrix: kernel params"))
1517 ptentParams.sublist(
"matrixmatrix: kernel params",
false) = paramList.sublist(
"matrixmatrix: kernel params");
1518 if (defaultList.isSublist(
"matrixmatrix: kernel params"))
1519 ptentParams.sublist(
"matrixmatrix: kernel params",
false) = defaultList.sublist(
"matrixmatrix: kernel params");
1520 test_and_set_param_2list<bool>(paramList, defaultList,
"tentative: calculate qr", ptentParams);
1521 test_and_set_param_2list<bool>(paramList, defaultList,
"tentative: build coarse coordinates", ptentParams);
1522 test_and_set_param_2list<bool>(paramList, defaultList,
"sa: keep tentative prolongator", ptentParams);
1523 Ptent->SetParameterList(ptentParams);
1524 Ptent->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1525 Ptent->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1528 if (reuseType ==
"tP" && levelID) {
1529 keeps.push_back(
keep_pair(
"Nullspace", Ptent.get()));
1530 keeps.push_back(
keep_pair(
"P", Ptent.get()));
1537template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1540 int , std::vector<keep_pair>& keeps)
const {
1541 if (paramList.isParameter(
"A") && !paramList.get<RCP<Matrix>>(
"A").is_null()) {
1547 ParameterList RAPparams;
1549 RCP<RAPFactory> RAP;
1550 RCP<RAPShiftFactory> RAPs;
1553 std::string alg = paramList.get(
"rap: algorithm",
"galerkin");
1554 if (alg ==
"shift" || alg ==
"non-galerkin") {
1556 test_and_set_param_2list<double>(paramList, defaultList,
"rap: shift", RAPparams);
1557 test_and_set_param_2list<bool>(paramList, defaultList,
"rap: shift diagonal M", RAPparams);
1558 test_and_set_param_2list<bool>(paramList, defaultList,
"rap: shift low storage", RAPparams);
1559 test_and_set_param_2list<Teuchos::Array<double>>(paramList, defaultList,
"rap: shift array", RAPparams);
1560 test_and_set_param_2list<Teuchos::Array<double>>(paramList, defaultList,
"rap: cfl array", RAPparams);
1566 test_and_set_param_2list<Teuchos::Array<double>>(paramList, defaultList,
"rap: relative diagonal floor", RAPparams);
1568 if (paramList.isSublist(
"matrixmatrix: kernel params"))
1569 RAPparams.sublist(
"matrixmatrix: kernel params",
false) = paramList.sublist(
"matrixmatrix: kernel params");
1570 if (defaultList.isSublist(
"matrixmatrix: kernel params"))
1571 RAPparams.sublist(
"matrixmatrix: kernel params",
false) = defaultList.sublist(
"matrixmatrix: kernel params");
1572 test_and_set_param_2list<bool>(paramList, defaultList,
"transpose: use implicit", RAPparams);
1573 test_and_set_param_2list<bool>(paramList, defaultList,
"rap: fix zero diagonals", RAPparams);
1574 test_and_set_param_2list<double>(paramList, defaultList,
"rap: fix zero diagonals threshold", RAPparams);
1575 test_and_set_param_2list<Scalar>(paramList, defaultList,
"rap: fix zero diagonals replacement", RAPparams);
1578 if (!paramList.isParameter(
"rap: triple product") &&
1579 paramList.isType<std::string>(
"multigrid algorithm") &&
1580 paramList.get<std::string>(
"multigrid algorithm") ==
"unsmoothed")
1581 paramList.set(
"rap: triple product",
true);
1583 test_and_set_param_2list<bool>(paramList, defaultList,
"rap: triple product", RAPparams);
1586 if (paramList.isParameter(
"aggregation: allow empty prolongator columns")) {
1587 RAPparams.set(
"CheckMainDiagonal", paramList.get<
bool>(
"aggregation: allow empty prolongator columns"));
1588 RAPparams.set(
"RepairMainDiagonal", paramList.get<
bool>(
"aggregation: allow empty prolongator columns"));
1589 }
else if (defaultList.isParameter(
"aggregation: allow empty prolongator columns")) {
1590 RAPparams.set(
"CheckMainDiagonal", defaultList.get<
bool>(
"aggregation: allow empty prolongator columns"));
1591 RAPparams.set(
"RepairMainDiagonal", defaultList.get<
bool>(
"aggregation: allow empty prolongator columns"));
1594 }
catch (Teuchos::Exceptions::InvalidParameterType&) {
1595 TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(
true, Teuchos::Exceptions::InvalidParameterType,
1596 "Error: parameter \"aggregation: allow empty prolongator columns\" must be of type " << Teuchos::TypeNameTraits<bool>::name());
1599 if (!RAP.is_null()) {
1600 RAP->SetParameterList(RAPparams);
1601 RAP->SetFactory(
"P", manager.
GetFactory(
"P"));
1603 RAPs->SetParameterList(RAPparams);
1604 RAPs->SetFactory(
"P", manager.
GetFactory(
"P"));
1607 if (!this->implicitTranspose_) {
1609 RAP->SetFactory(
"R", manager.
GetFactory(
"R"));
1611 RAPs->SetFactory(
"R", manager.
GetFactory(
"R"));
1615 if (test_param_2list<bool>(paramList, defaultList,
"matrix: compute analysis",
true)) {
1619 RAP->AddTransferFactory(matrixAnalysisFact);
1621 RAPs->AddTransferFactory(matrixAnalysisFact);
1625 if (test_param_2list<bool>(paramList, defaultList,
"aggregation: compute aggregate qualities",
true)) {
1627 ParameterList aggQualityParams;
1628 test_and_set_param_2list<double>(paramList, defaultList,
"aggregate qualities: good aggregate threshold", aggQualityParams);
1629 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregate qualities: file output", aggQualityParams);
1630 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregate qualities: file base", aggQualityParams);
1631 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregate qualities: check symmetry", aggQualityParams);
1632 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregate qualities: algorithm", aggQualityParams);
1633 test_and_set_param_2list<double>(paramList, defaultList,
"aggregate qualities: zero threshold", aggQualityParams);
1634 test_and_set_param_2list<Teuchos::Array<double>>(paramList, defaultList,
"aggregate qualities: percentiles", aggQualityParams);
1635 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregate qualities: mode", aggQualityParams);
1636 aggQualityFact->SetParameterList(aggQualityParams);
1637 aggQualityFact->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1638 aggQualityFact->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1639 manager.
SetFactory(
"AggregateQualities", aggQualityFact);
1642 RAP->AddTransferFactory(aggQualityFact);
1644 RAPs->AddTransferFactory(aggQualityFact);
1647 if (test_param_2list<bool>(paramList, defaultList,
"aggregation: export visualization data",
true)) {
1649 ParameterList aggExportParams;
1650 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: output filename", aggExportParams);
1651 test_and_set_param_2list<std::string>(paramList, defaultList,
"aggregation: output file: agg style", aggExportParams);
1652 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: output file: iter", aggExportParams);
1653 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: output file: time step", aggExportParams);
1654 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: output file: fine graph edges", aggExportParams);
1655 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: output file: coarse graph edges", aggExportParams);
1656 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: output file: build colormap", aggExportParams);
1657 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: output file: aggregate qualities", aggExportParams);
1658 test_and_set_param_2list<bool>(paramList, defaultList,
"aggregation: output file: material", aggExportParams);
1659 aggExport->SetParameterList(aggExportParams);
1660 aggExport->SetFactory(
"AggregateQualities", manager.
GetFactory(
"AggregateQualities"));
1661 aggExport->SetFactory(
"DofsPerNode", manager.
GetFactory(
"DofsPerNode"));
1662 aggExport->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1663 aggExport->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1666 RAP->AddTransferFactory(aggExport);
1668 RAPs->AddTransferFactory(aggExport);
1675 auto reuseType = set_var_2list<std::string>(paramList, defaultList,
"reuse: type");
1676 auto useFiltering = set_var_2list<bool>(paramList, defaultList,
"sa: use filtered matrix");
1677 bool filteringChangesMatrix = useFiltering && !test_param_2list<double>(paramList, defaultList,
"aggregation: drop tol", 0);
1679 if (reuseType ==
"RP" || (reuseType ==
"tP" && !filteringChangesMatrix)) {
1680 if (!RAP.is_null()) {
1681 keeps.push_back(
keep_pair(
"AP reuse data", RAP.get()));
1682 keeps.push_back(
keep_pair(
"RAP reuse data", RAP.get()));
1685 keeps.push_back(
keep_pair(
"AP reuse data", RAPs.get()));
1686 keeps.push_back(
keep_pair(
"RAP reuse data", RAPs.get()));
1694template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1698 bool have_userCO =
false;
1699 if (paramList.isParameter(
"Coordinates") && !paramList.get<RCP<MultiVector>>(
"Coordinates").is_null())
1702 if (useCoordinates_) {
1708 coords->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1709 coords->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1712 auto RAP = rcp_const_cast<RAPFactory>(rcp_dynamic_cast<const RAPFactory>(manager.
GetFactory(
"A")));
1713 if (!RAP.is_null()) {
1714 RAP->AddTransferFactory(manager.
GetFactory(
"Coordinates"));
1716 auto RAPs = rcp_const_cast<RAPShiftFactory>(rcp_dynamic_cast<const RAPShiftFactory>(manager.
GetFactory(
"A")));
1717 RAPs->AddTransferFactory(manager.
GetFactory(
"Coordinates"));
1726template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1730 bool have_userMaterial =
false;
1731 if (paramList.isParameter(
"Material") && !paramList.get<RCP<MultiVector>>(
"Material").is_null())
1732 have_userMaterial =
true;
1735 if (have_userMaterial) {
1739 ParameterList materialTransferParameters;
1740 materialTransferParameters.set(
"Vector name",
"Material");
1741 materialTransferParameters.set(
"Transfer name",
"Aggregates");
1742 materialTransferParameters.set(
"Normalize",
true);
1743 materialTransfer->SetParameterList(materialTransferParameters);
1744 materialTransfer->SetFactory(
"Transfer factory", manager.
GetFactory(
"Aggregates"));
1745 materialTransfer->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1746 manager.
SetFactory(
"Material", materialTransfer);
1748 auto RAP = rcp_const_cast<RAPFactory>(rcp_dynamic_cast<const RAPFactory>(manager.
GetFactory(
"A")));
1749 if (!RAP.is_null()) {
1750 RAP->AddTransferFactory(manager.
GetFactory(
"Material"));
1752 auto RAPs = rcp_const_cast<RAPShiftFactory>(rcp_dynamic_cast<const RAPShiftFactory>(manager.
GetFactory(
"A")));
1753 RAPs->AddTransferFactory(manager.
GetFactory(
"Material"));
1762template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1765 FactoryManager& manager,
int levelID, std::vector<keep_pair>& )
const {
1768 if (useBlockNumber_ && (levelID > 0)) {
1769 auto RAP = rcp_const_cast<RAPFactory>(rcp_dynamic_cast<const RAPFactory>(manager.
GetFactory(
"A")));
1770 auto RAPs = rcp_const_cast<RAPShiftFactory>(rcp_dynamic_cast<const RAPShiftFactory>(manager.
GetFactory(
"A")));
1771 if (!RAP.is_null() || !RAPs.is_null()) {
1773 if (multigridAlgo ==
"classical")
1774 fact->SetFactory(
"P Graph", manager.
GetFactory(
"P Graph"));
1776 fact->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1777 fact->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1779 fact->SetFactory(VarName, this->GetFactoryManager(levelID - 1)->GetFactory(VarName));
1784 RAP->AddTransferFactory(manager.
GetFactory(VarName));
1786 RAPs->AddTransferFactory(manager.
GetFactory(VarName));
1794template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1797 FactoryManager& manager,
int levelID, std::vector<keep_pair>& )
const {
1802 else if (levelID > 0) {
1804 auto RebalAc = rcp_const_cast<RebalanceAcFactory>(rcp_dynamic_cast<const RebalanceAcFactory>(Afact));
1805 RCP<RAPFactory> RAP;
1806 RCP<RAPShiftFactory> RAPs;
1807 if (!RebalAc.is_null()) {
1808 auto Afact2 = RebalAc->GetFactory(
"A");
1809 RAP = rcp_const_cast<RAPFactory>(rcp_dynamic_cast<const RAPFactory>(Afact2));
1810 RAPs = rcp_const_cast<RAPShiftFactory>(rcp_dynamic_cast<const RAPShiftFactory>(Afact2));
1812 RAP = rcp_const_cast<RAPFactory>(rcp_dynamic_cast<const RAPFactory>(Afact));
1813 RAPs = rcp_const_cast<RAPShiftFactory>(rcp_dynamic_cast<const RAPShiftFactory>(Afact));
1816 if (!RAP.is_null() || !RAPs.is_null()) {
1819 ParameterList transferParameters;
1820 transferParameters.set(
"Matrix name", VarName);
1821 transferParameters.set(
"transpose: use implicit", this->implicitTranspose_);
1822 mtf->SetParameterList(transferParameters);
1824 if (!RAP.is_null()) {
1825 mtf->SetFactory(
"P", RAP->GetFactory(
"P"));
1826 if (!this->implicitTranspose_)
1827 mtf->SetFactory(
"R", RAP->GetFactory(
"R"));
1828 RAP->AddTransferFactory(mtf);
1830 mtf->SetFactory(
"P", RAPs->GetFactory(
"P"));
1831 if (!this->implicitTranspose_)
1832 mtf->SetFactory(
"R", RAPs->GetFactory(
"R"));
1833 RAPs->AddTransferFactory(mtf);
1836 auto enableRepart = set_var_2list<bool>(paramList, defaultList,
"repartition: enable");
1837 if (!enableRepart) {
1841 Teuchos::ParameterList rebalParams;
1842 rebalParams.set(
"Matrix name", VarName);
1843 auto useSubCommInPlace = set_var_2list<bool>(paramList, defaultList,
"repartition: use subcommunicators in place");
1844 rebalParams.set(
"repartition: use subcommunicators in place", useSubCommInPlace);
1845 if (useSubCommInPlace) {
1846 auto inPlaceMapFact = manager.
GetFactory(
"InPlaceMap");
1847 rebalFact->SetFactory(
"InPlaceMap", inPlaceMapFact);
1849 TEUCHOS_ASSERT(!RebalAc.is_null());
1850 RCP<const FactoryBase> importerFact;
1851 importerFact = RebalAc->GetFactory(
"Importer");
1852 rebalFact->SetFactory(
"Importer", importerFact);
1853 RebalAc->AddRebalanceFactory(rebalFact);
1856 rebalFact->SetParameterList(rebalParams);
1857 rebalFact->SetFactory(
"A", mtf);
1868template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1872 if (useBlockNumber_) {
1873 ParameterList myParams;
1875 test_and_set_param_2list<int>(paramList, defaultList,
"aggregation: block diagonal: interleaved blocksize", myParams);
1876 fact->SetParameterList(myParams);
1884template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1887 int , std::vector<keep_pair>& )
const {
1888 auto multigridAlgo = set_var_2list<std::string>(paramList, defaultList,
"multigrid algorithm");
1889 bool have_userR =
false;
1890 if (paramList.isParameter(
"R") && !paramList.get<RCP<Matrix>>(
"R").is_null())
1895 if (!this->implicitTranspose_) {
1896 auto isSymmetric = set_var_2list<bool>(paramList, defaultList,
"problem: symmetric");
1898 if (isSymmetric ==
false && (multigridAlgo ==
"unsmoothed" || multigridAlgo ==
"emin")) {
1899 this->GetOStream(
Warnings0) <<
"Switching \"problem: symmetric\" parameter to symmetric as multigrid algorithm. " << multigridAlgo <<
" is primarily supposed to be used for symmetric problems.\n\n"
1900 <<
"Please note: if you are using \"unsmoothed\" transfer operators the \"problem: symmetric\" parameter "
1901 <<
"has no real mathematical meaning, i.e. you can use it for non-symmetric\n"
1902 <<
"problems, too. With \"problem: symmetric\"=\"symmetric\" you can use implicit transpose for building "
1903 <<
"the restriction operators which may drastically reduce the amount of consumed memory." << std::endl;
1907 "Petrov-Galerkin smoothed transfer operators are only allowed for non-symmetric problems: Set \"problem: symmetric\" to false!\n"
1908 "While PG smoothed transfer operators generally would also work for symmetric problems this is an unusual use case. "
1909 "You can use the factory-based xml interface though if you need PG-AMG for symmetric problems.");
1928 if (paramList.isParameter(
"restriction: scale nullspace") && paramList.get<
bool>(
"restriction: scale nullspace")) {
1930 Teuchos::ParameterList tentPlist;
1931 tentPlist.set(
"Nullspace name",
"Scaled Nullspace");
1932 tentPFactory->SetParameterList(tentPlist);
1933 tentPFactory->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1934 tentPFactory->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1937 R->SetFactory(
"P", tentPFactory);
1944template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1947 int levelID, std::vector<keep_pair>& keeps, RCP<Factory>& nullSpaceFactory)
const {
1949 auto reuseType = set_var_2list<std::string>(paramList, defaultList,
"reuse: type");
1950 auto enableRepart = set_var_2list<bool>(paramList, defaultList,
"repartition: enable");
1952#if defined(HAVE_MPI) && (defined(HAVE_MUELU_ZOLTAN) || defined(HAVE_MUELU_ZOLTAN2))
1953 auto enableInPlace = set_var_2list<bool>(paramList, defaultList,
"repartition: use subcommunicators in place");
1990 "Reuse types \"tP\" and \"PR\" require \"repartition: rebalance P and R\" set to \"false\"");
1995 auto partName = set_var_2list<std::string>(paramList, defaultList,
"repartition: partitioner");
1997 "Invalid partitioner name: \"" << partName <<
"\". Valid options: \"zoltan\", \"zoltan2\"");
1999#ifndef HAVE_MUELU_ZOLTAN
2000 bool switched =
false;
2001 if (partName ==
"zoltan") {
2002 this->GetOStream(
Warnings0) <<
"Zoltan interface is not available, trying to switch to Zoltan2" << std::endl;
2003 partName =
"zoltan2";
2007#ifndef HAVE_MUELU_ZOLTAN2
2008 bool switched =
false;
2012#ifndef HAVE_MUELU_ZOLTAN2
2013 if (partName ==
"zoltan2" && !switched) {
2014 this->GetOStream(
Warnings0) <<
"Zoltan2 interface is not available, trying to switch to Zoltan" << std::endl;
2015 partName =
"zoltan";
2019 auto nodeRepartitionLevel = set_var_2list<int>(paramList, defaultList,
"repartition: node repartition level");
2023 ParameterList repartheurParams;
2024 test_and_set_param_2list<int>(paramList, defaultList,
"repartition: node repartition level", repartheurParams);
2025 test_and_set_param_2list<int>(paramList, defaultList,
"repartition: start level", repartheurParams);
2026 test_and_set_param_2list<int>(paramList, defaultList,
"repartition: min rows per proc", repartheurParams);
2027 test_and_set_param_2list<int>(paramList, defaultList,
"repartition: target rows per proc", repartheurParams);
2028 test_and_set_param_2list<int>(paramList, defaultList,
"repartition: min rows per thread", repartheurParams);
2029 test_and_set_param_2list<int>(paramList, defaultList,
"repartition: target rows per thread", repartheurParams);
2030 test_and_set_param_2list<double>(paramList, defaultList,
"repartition: max imbalance", repartheurParams);
2031 test_and_set_param_2list<int>(paramList, defaultList,
"repartition: put on single proc", repartheurParams);
2032 repartheurFactory->SetParameterList(repartheurParams);
2033 repartheurFactory->SetFactory(
"A", manager.
GetFactory(
"A"));
2034 manager.
SetFactory(
"number of partitions", repartheurFactory);
2035 manager.
SetFactory(
"repartition: heuristic target rows per process", repartheurFactory);
2038 RCP<Factory> partitioner;
2039 if (levelID == nodeRepartitionLevel) {
2042 ParameterList partParams;
2043 test_and_set_param_2list<int>(paramList, defaultList,
"repartition: node id", partParams);
2044 partitioner->SetParameterList(partParams);
2045 partitioner->SetFactory(
"Node Comm", manager.
GetFactory(
"Node Comm"));
2046 }
else if (partName ==
"zoltan") {
2047#ifdef HAVE_MUELU_ZOLTAN
2053 }
else if (partName ==
"zoltan2") {
2054#ifdef HAVE_MUELU_ZOLTAN2
2056 ParameterList partParams;
2057 RCP<const ParameterList> partpartParams = rcp(
new ParameterList(paramList.sublist(
"repartition: params",
false)));
2058 partParams.set(
"ParameterList", partpartParams);
2059 partitioner->SetParameterList(partParams);
2060 partitioner->SetFactory(
"repartition: heuristic target rows per process",
2061 manager.
GetFactory(
"repartition: heuristic target rows per process"));
2067 partitioner->SetFactory(
"A", manager.
GetFactory(
"A"));
2068 partitioner->SetFactory(
"number of partitions", manager.
GetFactory(
"number of partitions"));
2069 if (useCoordinates_)
2070 partitioner->SetFactory(
"Coordinates", manager.
GetFactory(
"Coordinates"));
2071 manager.
SetFactory(
"Partition", partitioner);
2075 ParameterList repartParams;
2076 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: print partition distribution", repartParams);
2077 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: remap parts", repartParams);
2078 test_and_set_param_2list<int>(paramList, defaultList,
"repartition: remap num values", repartParams);
2079 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: save importer", repartParams);
2080 repartFactory->SetParameterList(repartParams);
2081 repartFactory->SetFactory(
"A", manager.
GetFactory(
"A"));
2082 repartFactory->SetFactory(
"number of partitions", manager.
GetFactory(
"number of partitions"));
2083 repartFactory->SetFactory(
"Partition", manager.
GetFactory(
"Partition"));
2084 manager.
SetFactory(
"Importer", repartFactory);
2085 if (reuseType !=
"none" && reuseType !=
"S" && levelID)
2088 if (enableInPlace) {
2093 ParameterList rebAcParams;
2094 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: use subcommunicators", rebAcParams);
2095 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: use subcommunicators in place", rebAcParams);
2096 newA->SetParameterList(rebAcParams);
2097 newA->SetFactory(
"A", manager.
GetFactory(
"A"));
2098 newA->SetFactory(
"InPlaceMap", manager.
GetFactory(
"InPlaceMap"));
2103 ParameterList rebAcParams;
2104 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: use subcommunicators", rebAcParams);
2105 newA->SetParameterList(rebAcParams);
2106 newA->SetFactory(
"A", manager.
GetFactory(
"A"));
2107 newA->SetFactory(
"Importer", manager.
GetFactory(
"Importer"));
2112 ParameterList newPparams;
2113 newPparams.set(
"type",
"Interpolation");
2114 if (changedPRrebalance_)
2115 newPparams.set(
"repartition: rebalance P and R", this->doPRrebalance_);
2116 if (changedPRViaCopyrebalance_)
2117 newPparams.set(
"repartition: explicit via new copy rebalance P and R",
true);
2118 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: use subcommunicators", newPparams);
2119 test_and_set_param_2list<std::string>(paramList, defaultList,
"repartition: send type", newPparams);
2120 newP->SetParameterList(newPparams);
2121 newP->SetFactory(
"Importer", manager.
GetFactory(
"Importer"));
2122 newP->SetFactory(
"P", manager.
GetFactory(
"P"));
2124 if (!paramList.isParameter(
"semicoarsen: number of levels"))
2125 newP->SetFactory(
"Nullspace", manager.
GetFactory(
"Ptent"));
2127 newP->SetFactory(
"Nullspace", manager.
GetFactory(
"P"));
2128 if (useCoordinates_) {
2129 newP->SetFactory(
"Coordinates", manager.
GetFactory(
"Coordinates"));
2133 newP->SetFactory(
"Material", manager.
GetFactory(
"Material"));
2136 if (useBlockNumber_ && (levelID > 0)) {
2137 newP->SetFactory(
"BlockNumber", manager.
GetFactory(
"BlockNumber"));
2143 ParameterList newRparams;
2144 newRparams.set(
"type",
"Restriction");
2145 test_and_set_param_2list<bool>(paramList, defaultList,
"repartition: use subcommunicators", newRparams);
2146 test_and_set_param_2list<std::string>(paramList, defaultList,
"repartition: send type", newRparams);
2147 if (changedPRrebalance_)
2148 newRparams.set(
"repartition: rebalance P and R", this->doPRrebalance_);
2149 if (changedPRViaCopyrebalance_)
2150 newPparams.set(
"repartition: explicit via new copy rebalance P and R",
true);
2151 if (changedImplicitTranspose_)
2152 newRparams.set(
"transpose: use implicit", this->implicitTranspose_);
2153 newR->SetParameterList(newRparams);
2154 newR->SetFactory(
"Importer", manager.
GetFactory(
"Importer"));
2155 if (!this->implicitTranspose_) {
2156 newR->SetFactory(
"R", manager.
GetFactory(
"R"));
2167 ParameterList newNullparams;
2168 test_and_set_param_2list<bool>(paramList, defaultList,
"nullspace: calculate rotations", newNullparams);
2169 nullSpaceFactory->SetFactory(
"Nullspace", newP);
2170 nullSpaceFactory->SetParameterList(newNullparams);
2173 paramList.set(
"repartition: enable",
false);
2175 this->GetOStream(
Warnings0) <<
"No repartitioning available for a serial run\n";
2177 this->GetOStream(
Warnings0) <<
"Zoltan/Zoltan2 are unavailable for repartitioning\n";
2186template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2189 int , std::vector<keep_pair>& )
const {
2190 auto enableLowPrecision = set_var_2list<bool>(paramList, defaultList,
"transfers: half precision");
2192 if (enableLowPrecision) {
2195 ParameterList newPparams;
2196 newPparams.set(
"matrix key",
"P");
2197 newP->SetParameterList(newPparams);
2198 newP->SetFactory(
"P", manager.
GetFactory(
"P"));
2201 if (!this->implicitTranspose_) {
2204 ParameterList newRparams;
2205 newRparams.set(
"matrix key",
"R");
2206 newR->SetParameterList(newRparams);
2207 newR->SetFactory(
"R", manager.
GetFactory(
"R"));
2216template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2219 int , std::vector<keep_pair>& , RCP<Factory>& nullSpaceFactory)
const {
2223 bool have_userNS =
false;
2224 if (paramList.isParameter(
"Nullspace") && !paramList.get<RCP<MultiVector>>(
"Nullspace").is_null())
2228 ParameterList newNullparams;
2229 test_and_set_param_2list<bool>(paramList, defaultList,
"nullspace: calculate rotations", newNullparams);
2230 nullSpace->SetParameterList(newNullparams);
2231 nullSpace->SetFactory(
"Nullspace", manager.
GetFactory(
"Ptent"));
2234 nullSpaceFactory = nullSpace;
2236 if (paramList.isParameter(
"restriction: scale nullspace") && paramList.get<
bool>(
"restriction: scale nullspace")) {
2238 scaledNSfactory->SetFactory(
"Nullspace", nullSpaceFactory);
2239 manager.
SetFactory(
"Scaled Nullspace", scaledNSfactory);
2246template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2249 int , std::vector<keep_pair>& )
const {
2251 RCP<Factory> semicoarsenFactory = Teuchos::null;
2252 if (paramList.isParameter(
"semicoarsen: number of levels") &&
2253 paramList.get<
int>(
"semicoarsen: number of levels") > 0) {
2254 ParameterList togglePParams;
2255 ParameterList semicoarsenPParams;
2256 ParameterList linedetectionParams;
2257 test_and_set_param_2list<int>(paramList, defaultList,
"semicoarsen: number of levels", togglePParams);
2258 test_and_set_param_2list<int>(paramList, defaultList,
"semicoarsen: coarsen rate", semicoarsenPParams);
2259 test_and_set_param_2list<bool>(paramList, defaultList,
"semicoarsen: piecewise constant", semicoarsenPParams);
2260 test_and_set_param_2list<bool>(paramList, defaultList,
"semicoarsen: piecewise linear", semicoarsenPParams);
2261 test_and_set_param_2list<bool>(paramList, defaultList,
"semicoarsen: calculate nonsym restriction", semicoarsenPParams);
2262 test_and_set_param_2list<std::string>(paramList, defaultList,
"linedetection: orientation", linedetectionParams);
2263 test_and_set_param_2list<int>(paramList, defaultList,
"linedetection: num layers", linedetectionParams);
2269 linedetectionFactory->SetParameterList(linedetectionParams);
2270 semicoarsenFactory->SetParameterList(semicoarsenPParams);
2271 togglePFactory->SetParameterList(togglePParams);
2273 togglePFactory->AddCoarseNullspaceFactory(semicoarsenFactory);
2274 togglePFactory->AddProlongatorFactory(semicoarsenFactory);
2275 togglePFactory->AddPtentFactory(semicoarsenFactory);
2276 togglePFactory->AddCoarseNullspaceFactory(manager.
GetFactory(
"Ptent"));
2277 togglePFactory->AddProlongatorFactory(manager.
GetFactory(
"P"));
2278 togglePFactory->AddPtentFactory(manager.
GetFactory(
"Ptent"));
2280 manager.
SetFactory(
"CoarseNumZLayers", linedetectionFactory);
2281 manager.
SetFactory(
"LineDetection_Layers", linedetectionFactory);
2282 manager.
SetFactory(
"LineDetection_VertLineIds", linedetectionFactory);
2286 manager.
SetFactory(
"Nullspace", togglePFactory);
2289 if (paramList.isParameter(
"semicoarsen: number of levels") &&
2290 paramList.get<
int>(
"semicoarsen: number of levels") > 0) {
2292 tf->SetFactory(
"Chosen P", manager.
GetFactory(
"P"));
2293 tf->AddCoordTransferFactory(semicoarsenFactory);
2296 coords->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
2297 coords->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
2298 tf->AddCoordTransferFactory(coords);
2306template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2309 int levelID, std::vector<keep_pair>& keeps)
const {
2310#if defined(HAVE_MUELU_INTREPID2) && defined(HAVE_MUELU_EXPERIMENTAL)
2312 if (defaultList.isParameter(
"pcoarsen: schedule") && defaultList.isParameter(
"pcoarsen: element")) {
2315 auto pcoarsen_schedule = Teuchos::getArrayFromStringParameter<int>(defaultList,
"pcoarsen: schedule");
2316 auto pcoarsen_element = defaultList.get<std::string>(
"pcoarsen: element");
2318 if (levelID >= (
int)pcoarsen_schedule.size()) {
2321 std::string multigridAlgo =
"SA";
2322 UpdateFactoryManager_SA(multigridAlgo, paramList, defaultList, manager, levelID, keeps);
2326 ParameterList Pparams;
2328 std::string lo = pcoarsen_element + std::to_string(pcoarsen_schedule[levelID]);
2329 std::string hi = (levelID ? pcoarsen_element + std::to_string(pcoarsen_schedule[levelID - 1]) : lo);
2330 Pparams.set(
"pcoarsen: hi basis", hi);
2331 Pparams.set(
"pcoarsen: lo basis", lo);
2332 P->SetParameterList(Pparams);
2341 ParameterList Pparams;
2343 test_and_set_param_2list<std::string>(paramList, defaultList,
"pcoarsen: hi basis", Pparams);
2344 test_and_set_param_2list<std::string>(paramList, defaultList,
"pcoarsen: lo basis", Pparams);
2345 P->SetParameterList(Pparams);
2358template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2360 UpdateFactoryManager_SA(std::string& multigridAlgo, ParameterList& paramList,
const ParameterList& defaultList,
FactoryManager& manager,
int levelID, std::vector<keep_pair>& keeps)
const {
2363 ParameterList Pparams;
2364 if (paramList.isSublist(
"matrixmatrix: kernel params"))
2365 Pparams.sublist(
"matrixmatrix: kernel params",
false) = paramList.sublist(
"matrixmatrix: kernel params");
2366 if (defaultList.isSublist(
"matrixmatrix: kernel params"))
2367 Pparams.sublist(
"matrixmatrix: kernel params",
false) = defaultList.sublist(
"matrixmatrix: kernel params");
2368 test_and_set_param_2list<double>(paramList, defaultList,
"sa: damping factor", Pparams);
2369 test_and_set_param_2list<double>(paramList, defaultList,
"sa: nodal damping factor", Pparams);
2370 test_and_set_param_2list<bool>(paramList, defaultList,
"sa: calculate eigenvalue estimate", Pparams);
2371 test_and_set_param_2list<double>(paramList, defaultList,
"sa: max eigenvalue", Pparams);
2372 test_and_set_param_2list<int>(paramList, defaultList,
"sa: eigenvalue estimate num iterations", Pparams);
2373 test_and_set_param_2list<double>(paramList, defaultList,
"sa: diagonal replacement tolerance", Pparams);
2374 test_and_set_param_2list<bool>(paramList, defaultList,
"sa: use rowsumabs diagonal scaling", Pparams);
2375 test_and_set_param_2list<double>(paramList, defaultList,
"sa: rowsumabs diagonal replacement tolerance", Pparams);
2376 test_and_set_param_2list<double>(paramList, defaultList,
"sa: rowsumabs diagonal replacement value", Pparams);
2377 test_and_set_param_2list<bool>(paramList, defaultList,
"sa: rowsumabs use automatic diagonal tolerance", Pparams);
2378 test_and_set_param_2list<bool>(paramList, defaultList,
"sa: enforce constraints", Pparams);
2380 test_and_set_param_2list<bool>(paramList, defaultList,
"tentative: calculate qr", Pparams);
2382 if ((multigridAlgo ==
"smoothed reitzinger") && (levelID > 0)) {
2383 Pparams.set(
"sa: maxwell1 smoothing",
true);
2384 if (!Pparams.isType<
double>(
"sa: damping factor") || (Pparams.get<
double>(
"sa: damping factor") != 0.0))
2385 P->SetFactory(
"CurlCurl", this->GetFactoryManager(levelID - 1)->GetFactory(
"CurlCurl"));
2388 P->SetParameterList(Pparams);
2391 auto useFiltering = set_var_2list<bool>(paramList, defaultList,
"sa: use filtered matrix");
2399 ParameterList fParams;
2400 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: use lumping", fParams);
2401 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: reuse graph", fParams);
2402 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: reuse eigenvalue", fParams);
2403 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: use root stencil", fParams);
2404 test_and_set_param_2list<double>(paramList, defaultList,
"filtered matrix: Dirichlet threshold", fParams);
2405 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: use spread lumping", fParams);
2407 test_and_set_param_2list<double>(paramList, defaultList,
"filtered matrix: spread lumping diag dom growth factor", fParams);
2408 test_and_set_param_2list<double>(paramList, defaultList,
"filtered matrix: spread lumping diag dom cap", fParams);
2409 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: count negative diagonals", fParams);
2410 filterFactory->SetParameterList(fParams);
2411 filterFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
2412 filterFactory->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
2413 filterFactory->SetFactory(
"UnAmalgamationInfo", manager.
GetFactory(
"UnAmalgamationInfo"));
2415 filterFactory->SetFactory(
"Filtering", manager.
GetFactory(
"Graph"));
2417 P->SetFactory(
"A", filterFactory);
2420 P->SetFactory(
"A", manager.
GetFactory(
"Graph"));
2424 P->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
2427 bool filteringChangesMatrix = useFiltering && !test_param_2list<double>(paramList, defaultList,
"aggregation: drop tol", 0);
2428 auto reuseType = set_var_2list<std::string>(paramList, defaultList,
"reuse: type");
2429 if (reuseType ==
"tP" && !filteringChangesMatrix)
2430 keeps.push_back(
keep_pair(
"AP reuse data", P.get()));
2436template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2439 int , std::vector<keep_pair>& )
const {
2440 auto patternType = set_var_2list<std::string>(paramList, defaultList,
"emin: pattern");
2441 auto reuseType = set_var_2list<std::string>(paramList, defaultList,
"reuse: type");
2443 "Invalid pattern name: \"" << patternType <<
"\". Valid options: \"AkPtent\"");
2446 ParameterList patternParams;
2447 test_and_set_param_2list<int>(paramList, defaultList,
"emin: pattern order", patternParams);
2448 patternFactory->SetParameterList(patternParams);
2449 patternFactory->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
2452 auto useFiltering = set_var_2list<bool>(paramList, defaultList,
"emin: use filtered matrix");
2460 ParameterList fParams;
2461 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: use lumping", fParams);
2462 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: reuse graph", fParams);
2463 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: reuse eigenvalue", fParams);
2464 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: use root stencil", fParams);
2465 test_and_set_param_2list<double>(paramList, defaultList,
"filtered matrix: Dirichlet threshold", fParams);
2466 test_and_set_param_2list<bool>(paramList, defaultList,
"filtered matrix: use spread lumping", fParams);
2467 test_and_set_param_2list<std::string>(paramList, defaultList,
"filtered matrix: lumping choice", fParams);
2468 test_and_set_param_2list<double>(paramList, defaultList,
"filtered matrix: spread lumping diag dom growth factor", fParams);
2469 test_and_set_param_2list<double>(paramList, defaultList,
"filtered matrix: spread lumping diag dom cap", fParams);
2470 filterFactory->SetParameterList(fParams);
2471 filterFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
2472 filterFactory->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
2473 filterFactory->SetFactory(
"UnAmalgamationInfo", manager.
GetFactory(
"UnAmalgamationInfo"));
2475 filterFactory->SetFactory(
"Filtering", manager.
GetFactory(
"Graph"));
2477 patternFactory->SetFactory(
"A", filterFactory);
2480 patternFactory->SetFactory(
"A", manager.
GetFactory(
"Graph"));
2484 manager.
SetFactory(
"Ppattern", patternFactory);
2488 Teuchos::ParameterList constraintParams;
2489 test_and_set_param_2list<std::string>(paramList, defaultList,
"emin: least squares solver type", constraintParams);
2490 constraintParams.set(
"emin: constraint type",
"nullspace");
2491 constraintFactory->SetFactory(
"Ppattern", manager.
GetFactory(
"Ppattern"));
2492 constraintFactory->SetFactory(
"CoarseNullspace", manager.
GetFactory(
"Ptent"));
2493 manager.
SetFactory(
"Constraint", constraintFactory);
2496 ParameterList Pparams;
2497 test_and_set_param_2list<int>(paramList, defaultList,
"emin: num iterations", Pparams);
2498 test_and_set_param_2list<std::string>(paramList, defaultList,
"emin: iterative method", Pparams);
2499 if (reuseType ==
"emin") {
2500 test_and_set_param_2list<int>(paramList, defaultList,
"emin: num reuse iterations", Pparams);
2501 Pparams.set(
"Keep P0",
true);
2502 Pparams.set(
"Keep Constraint0",
true);
2507 P->SetParameterList(Pparams);
2508 P->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
2509 P->SetFactory(
"Constraint", manager.
GetFactory(
"Constraint"));
2516template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2519 int , std::vector<keep_pair>& )
const {
2521 "Implicit transpose not supported with Petrov-Galerkin smoothed transfer operators: Set \"transpose: use implicit\" to false!\n"
2522 "Petrov-Galerkin transfer operator smoothing for non-symmetric problems requires a separate handling of the restriction operator which "
2523 "does not allow the usage of implicit transpose easily.");
2527 P->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
2534template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2539 ParameterList Pparams;
2540 test_and_set_param_2list<int>(paramList, defaultList,
"replicate: npdes", Pparams);
2542 P->SetParameterList(Pparams);
2549template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2554 ParameterList Pparams;
2555 test_and_set_param_2list<int>(paramList, defaultList,
"combine: numBlks", Pparams);
2556 test_and_set_param_2list<bool>(paramList, defaultList,
"combine: useMaxLevels", Pparams);
2558 P->SetParameterList(Pparams);
2565template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2568 int , std::vector<keep_pair>& )
const {
2569#ifdef HAVE_MUELU_MATLAB
2570 ParameterList Pparams = paramList.sublist(
"transfer: params");
2572 P->SetParameterList(Pparams);
2573 P->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
2581#undef MUELU_KOKKOS_FACTORY
2585template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2587 ParameterList paramList = constParamList;
2590 const int maxLevels = 100;
2593 std::vector<ParameterList> paramLists;
2594 for (
int levelID = 0; levelID < maxLevels; levelID++) {
2595 std::string sublistName =
"level " +
toString(levelID);
2596 if (paramList.isSublist(sublistName)) {
2597 paramLists.push_back(paramList.sublist(sublistName));
2599 paramList.remove(sublistName);
2602 paramLists.push_back(paramList);
2604#ifdef HAVE_MUELU_MATLAB
2606 for (
size_t i = 0; i < paramLists.size(); i++) {
2607 std::vector<std::string> customVars;
2609 for (Teuchos::ParameterList::ConstIterator it = paramLists[i].begin(); it != paramLists[i].end(); it++) {
2610 std::string paramName = paramLists[i].name(it);
2613 customVars.push_back(paramName);
2617 for (
size_t j = 0; j < customVars.size(); j++)
2618 paramLists[i].remove(customVars[j],
false);
2622 const int maxDepth = 0;
2623 for (
size_t i = 0; i < paramLists.size(); i++) {
2626 paramLists[i].validateParameters(validList, maxDepth);
2628 }
catch (
const Teuchos::Exceptions::InvalidParameterName& e) {
2629 std::string eString = e.what();
2632 size_t nameStart = eString.find_first_of(
'"') + 1;
2633 size_t nameEnd = eString.find_first_of(
'"', nameStart);
2634 std::string name = eString.substr(nameStart, nameEnd - nameStart);
2636 size_t bestScore = 100;
2637 std::string bestName =
"";
2638 for (ParameterList::ConstIterator it = validList.begin(); it != validList.end(); it++) {
2639 const std::string& pName = validList.name(it);
2640 this->GetOStream(
Runtime1) <<
"| " << pName;
2641 size_t score =
LevenshteinDistance(name.c_str(), name.length(), pName.c_str(), pName.length());
2642 this->GetOStream(
Runtime1) <<
" -> " << score << std::endl;
2643 if (score < bestScore) {
2648 if (bestScore < 10 && bestName !=
"") {
2649 TEUCHOS_TEST_FOR_EXCEPTION(
true, Teuchos::Exceptions::InvalidParameterName,
2650 eString <<
"The parameter name \"" + name +
"\" is not valid. Did you mean \"" + bestName <<
"\"?\n");
2653 TEUCHOS_TEST_FOR_EXCEPTION(
true, Teuchos::Exceptions::InvalidParameterName,
2654 eString <<
"The parameter name \"" + name +
"\" is not valid.\n");
2663template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2668 ParameterList paramList = constParamList;
2675 if (paramList.isSublist(
"Matrix")) {
2676 blockSize_ = paramList.sublist(
"Matrix").get<
int>(
"PDE equations", MasterList::getDefault<int>(
"number of equations"));
2677 dofOffset_ = paramList.sublist(
"Matrix").get<
GlobalOrdinal>(
"DOF offset", 0);
2681 if (factFact_ == Teuchos::null)
2693 if (paramList.isSublist(
"Factories"))
2694 this->BuildFactoryMap(paramList.sublist(
"Factories"), factoryMap, factoryMap, factoryManagers);
2708 if (paramList.isSublist(
"Hierarchy")) {
2709 ParameterList hieraList = paramList.sublist(
"Hierarchy");
2712 if (hieraList.isParameter(
"max levels")) {
2713 this->numDesiredLevel_ = hieraList.get<
int>(
"max levels");
2714 hieraList.remove(
"max levels");
2717 if (hieraList.isParameter(
"coarse: max size")) {
2718 this->maxCoarseSize_ = hieraList.get<
int>(
"coarse: max size");
2719 hieraList.remove(
"coarse: max size");
2722 if (hieraList.isParameter(
"repartition: rebalance P and R")) {
2723 this->doPRrebalance_ = hieraList.get<
bool>(
"repartition: rebalance P and R");
2724 hieraList.remove(
"repartition: rebalance P and R");
2727 if (hieraList.isParameter(
"transpose: use implicit")) {
2728 this->implicitTranspose_ = hieraList.get<
bool>(
"transpose: use implicit");
2729 hieraList.remove(
"transpose: use implicit");
2732 if (hieraList.isParameter(
"fuse prolongation and update")) {
2733 this->fuseProlongationAndUpdate_ = hieraList.get<
bool>(
"fuse prolongation and update");
2734 hieraList.remove(
"fuse prolongation and update");
2737 if (hieraList.isParameter(
"nullspace: suppress dimension check")) {
2738 this->suppressNullspaceDimensionCheck_ = hieraList.get<
bool>(
"nullspace: suppress dimension check");
2739 hieraList.remove(
"nullspace: suppress dimension check");
2742 if (hieraList.isParameter(
"number of vectors")) {
2743 this->sizeOfMultiVectors_ = hieraList.get<
int>(
"number of vectors");
2744 hieraList.remove(
"number of vectors");
2747 if (hieraList.isSublist(
"matvec params"))
2748 this->matvecParams_ = Teuchos::parameterList(hieraList.sublist(
"matvec params"));
2750 if (hieraList.isParameter(
"coarse grid correction scaling factor")) {
2751 this->scalingFactor_ = hieraList.get<
double>(
"coarse grid correction scaling factor");
2752 hieraList.remove(
"coarse grid correction scaling factor");
2756 if (hieraList.isParameter(
"cycle type")) {
2757 std::map<std::string, CycleType> cycleMap;
2761 std::string cycleType = hieraList.get<std::string>(
"cycle type");
2762 TEUCHOS_TEST_FOR_EXCEPTION(cycleMap.count(cycleType) == 0,
Exceptions::RuntimeError,
"Invalid cycle type: \"" << cycleType <<
"\"");
2763 this->Cycle_ = cycleMap[cycleType];
2766 if (hieraList.isParameter(
"W cycle start level")) {
2767 this->WCycleStartLevel_ = hieraList.get<
int>(
"W cycle start level");
2770 if (hieraList.isParameter(
"hierarchy label")) {
2771 this->hierarchyLabel_ = hieraList.get<std::string>(
"hierarchy label");
2774 if (hieraList.isParameter(
"verbosity")) {
2775 std::string vl = hieraList.get<std::string>(
"verbosity");
2776 hieraList.remove(
"verbosity");
2780 if (hieraList.isParameter(
"output filename"))
2783 if (hieraList.isParameter(
"dependencyOutputLevel"))
2784 this->graphOutputLevel_ = hieraList.get<
int>(
"dependencyOutputLevel");
2787 if (hieraList.isParameter(
"reuse"))
2790 if (hieraList.isSublist(
"DataToWrite")) {
2793 ParameterList foo = hieraList.sublist(
"DataToWrite");
2794 std::string dataName =
"Matrices";
2795 if (foo.isParameter(dataName))
2796 this->matricesToPrint_[
"A"] = Teuchos::getArrayFromStringParameter<int>(foo, dataName);
2797 dataName =
"Prolongators";
2798 if (foo.isParameter(dataName))
2799 this->matricesToPrint_[
"P"] = Teuchos::getArrayFromStringParameter<int>(foo, dataName);
2800 dataName =
"Restrictors";
2801 if (foo.isParameter(dataName))
2802 this->matricesToPrint_[
"R"] = Teuchos::getArrayFromStringParameter<int>(foo, dataName);
2804 if (foo.isParameter(dataName))
2805 this->matricesToPrint_[
"D0"] = Teuchos::getArrayFromStringParameter<int>(foo, dataName);
2809 for (ParameterList::ConstIterator param = hieraList.begin(); param != hieraList.end(); ++param) {
2810 const std::string& paramName = hieraList.name(param);
2812 if (paramName !=
"DataToWrite" && hieraList.isSublist(paramName)) {
2813 ParameterList levelList = hieraList.sublist(paramName);
2816 if (levelList.isParameter(
"startLevel")) {
2817 startLevel = levelList.get<
int>(
"startLevel");
2818 levelList.remove(
"startLevel");
2820 int numDesiredLevel = 1;
2821 if (levelList.isParameter(
"numDesiredLevel")) {
2822 numDesiredLevel = levelList.get<
int>(
"numDesiredLevel");
2823 levelList.remove(
"numDesiredLevel");
2837 BuildFactoryMap(levelList, factoryMap, levelFactoryMap, factoryManagers);
2839 RCP<FactoryManager> m = rcp(
new FactoryManager(levelFactoryMap));
2840 if (hieraList.isParameter(
"use kokkos refactor"))
2841 m->SetKokkosRefactor(hieraList.get<
bool>(
"use kokkos refactor"));
2843 if (startLevel >= 0)
2844 this->AddFactoryManager(startLevel, numDesiredLevel, m);
2846 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::ParameterListInterpreter():: invalid level id");
2975template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2978 for (ParameterList::ConstIterator param = paramList.begin(); param != paramList.end(); ++param) {
2979 const std::string& paramName = paramList.name(param);
2980 const Teuchos::ParameterEntry& paramValue = paramList.entry(param);
2984 if (paramValue.isList()) {
2985 ParameterList paramList1 = Teuchos::getValue<ParameterList>(paramValue);
2986 if (paramList1.isParameter(
"factory")) {
2989 "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.");
2991 factoryMapOut[paramName] = factFact_->BuildFactory(paramValue, factoryMapIn, factoryManagers);
2993 }
else if (paramList1.isParameter(
"dependency for")) {
2995 "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.");
2997 std::string factoryName = paramList1.get<std::string>(
"dependency for");
2999 RCP<const FactoryBase> factbase = factoryMapIn.find(factoryName )->second;
3001 "MueLu::ParameterListInterpreter(): could not find factory " + factoryName +
" in factory map. Did you define it before?");
3003 RCP<const Factory> factoryconst = Teuchos::rcp_dynamic_cast<const Factory>(factbase);
3004 RCP<Factory> factory = Teuchos::rcp_const_cast<Factory>(factoryconst);
3007 RCP<const ParameterList> validParamList = factory->GetValidParameterList();
3008 for (ParameterList::ConstIterator vparam = validParamList->begin(); vparam != validParamList->end(); ++vparam) {
3009 const std::string& pName = validParamList->name(vparam);
3011 if (!paramList1.isParameter(pName)) {
3016 if (validParamList->isType<RCP<const FactoryBase>>(pName)) {
3018 RCP<const FactoryBase> generatingFact = factFact_->BuildFactory(paramList1.getEntry(pName), factoryMapIn, factoryManagers);
3019 factory->SetFactory(pName, generatingFact.create_weak());
3021 }
else if (validParamList->isType<RCP<const ParameterList>>(pName)) {
3022 if (pName ==
"ParameterList") {
3027 RCP<const ParameterList> subList = Teuchos::sublist(rcp(
new ParameterList(paramList1)), pName);
3028 factory->SetParameter(pName, ParameterEntry(subList));
3031 factory->SetParameter(pName, paramList1.getEntry(pName));
3035 }
else if (paramList1.isParameter(
"group")) {
3037 std::string groupType = paramList1.get<std::string>(
"group");
3039 "group must be of type \"FactoryManager\".");
3041 ParameterList groupList = paramList1;
3042 groupList.remove(
"group");
3044 bool setKokkosRefactor =
false;
3045 bool kokkosRefactor = useKokkos_;
3046 if (groupList.isParameter(
"use kokkos refactor")) {
3047 kokkosRefactor = groupList.get<
bool>(
"use kokkos refactor");
3048 groupList.remove(
"use kokkos refactor");
3049 setKokkosRefactor =
true;
3053 BuildFactoryMap(groupList, factoryMapIn, groupFactoryMap, factoryManagers);
3057 RCP<FactoryManager> m = rcp(
new FactoryManager(groupFactoryMap));
3058 if (setKokkosRefactor)
3059 m->SetKokkosRefactor(kokkosRefactor);
3060 factoryManagers[paramName] = m;
3063 this->GetOStream(
Warnings0) <<
"Could not interpret parameter list " << paramList1 << std::endl;
3065 "XML Parameter list must either be of type \"factory\" or of type \"group\".");
3069 factoryMapOut[paramName] = factFact_->BuildFactory(paramValue, factoryMapIn, factoryManagers);
3077template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
3080 Matrix& A =
dynamic_cast<Matrix&
>(Op);
3081 if (A.IsFixedBlockSizeSet() && (A.GetFixedBlockSize() != blockSize_))
3082 this->GetOStream(
Warnings0) <<
"Setting matrix block size to " << blockSize_ <<
" (value of the parameter in the list) "
3083 <<
"instead of " << A.GetFixedBlockSize() <<
" (provided matrix)." << std::endl
3084 <<
"You may want to check \"number of equations\" (or \"PDE equations\" for factory style list) parameter." << std::endl;
3086 if ((blockSize_ != 1) || (dofOffset_ != 0))
3087 A.SetFixedBlockSize(blockSize_, dofOffset_);
3090 MatrixUtils::checkLocalRowMapMatchesColMap(A);
3092 }
catch (std::bad_cast&) {
3093 this->GetOStream(
Warnings0) <<
"Skipping setting block size as the operator is not a matrix" << std::endl;
3097template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
3106static bool compare(
const ParameterList& list1,
const ParameterList& list2) {
3109 for (ParameterList::ConstIterator it = list1.begin(); it != list1.end(); it++) {
3110 const std::string& name = it->first;
3111 const Teuchos::ParameterEntry& entry1 = it->second;
3113 const Teuchos::ParameterEntry* entry2 = list2.getEntryPtr(name);
3116 if (entry1.isList() && entry2->isList()) {
3117 compare(Teuchos::getValue<ParameterList>(entry1), Teuchos::getValue<ParameterList>(*entry2));
3120 if (entry1.getAny(
false) != entry2->getAny(
false))
3127static inline bool areSame(
const ParameterList& list1,
const ParameterList& list2) {
3133#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
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
void UpdateFactoryManager_SemiCoarsen(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
void UpdateFactoryManager_BlockNumber(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
void UpdateFactoryManager(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
std::map< std::string, RCP< const FactoryBase > > FactoryMap
void SetupHierarchy(Hierarchy &H) const
Call the SetupHierarchy routine from the HiearchyManager object.
void SetFactoryParameterList(const Teuchos::ParameterList ¶mList)
Factory interpreter stuff.
void UpdateFactoryManager_CoarseSolvers(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
void UpdateFactoryManager_Repartition(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps, RCP< Factory > &nullSpaceFactory) const
Factory for building nonzero patterns for energy minimization.
Factory for building Petrov-Galerkin Smoothed Aggregation prolongators.
Factory for building coarse matrices.
Factory for building coarse grid matrices, when the matrix is of the form K+a*M. Useful when you want...
Factory for building coarse matrices.
Applies permutation to grid transfer operators.
Factory for building tentative prolongator.
Factory for building permutation matrix that can be be used to shuffle data (matrices,...
Factory for determing the number of partitions for rebalancing.
Prolongator factory that replicates 'Psubblock' matrix to create new prolongator suitable for PDE sys...
Factory for building Smoothed Aggregation prolongators.
Factory for 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)