45#ifndef MUELU_PARAMETERLISTINTERPRETER_DEF_HPP
46#define MUELU_PARAMETERLISTINTERPRETER_DEF_HPP
48#include <Teuchos_XMLParameterListHelpers.hpp>
50#include <Xpetra_Matrix.hpp>
51#include <Xpetra_MatrixUtils.hpp>
59#include "MueLu_Hierarchy.hpp"
60#include "MueLu_FactoryManager.hpp"
62#include "MueLu_AggregationExportFactory.hpp"
63#include "MueLu_AggregateQualityEstimateFactory.hpp"
64#include "MueLu_BrickAggregationFactory.hpp"
65#include "MueLu_ClassicalMapFactory.hpp"
66#include "MueLu_ClassicalPFactory.hpp"
67#include "MueLu_CoalesceDropFactory.hpp"
68#include "MueLu_CoarseMapFactory.hpp"
69#include "MueLu_ConstraintFactory.hpp"
70#include "MueLu_CoordinatesTransferFactory.hpp"
71#include "MueLu_DirectSolver.hpp"
72#include "MueLu_EminPFactory.hpp"
74#include "MueLu_FacadeClassFactory.hpp"
75#include "MueLu_FactoryFactory.hpp"
76#include "MueLu_FilteredAFactory.hpp"
77#include "MueLu_GenericRFactory.hpp"
78#include "MueLu_InitialBlockNumberFactory.hpp"
79#include "MueLu_LineDetectionFactory.hpp"
80#include "MueLu_LocalOrdinalTransferFactory.hpp"
81#include "MueLu_NotayAggregationFactory.hpp"
82#include "MueLu_NullspaceFactory.hpp"
83#include "MueLu_PatternFactory.hpp"
84#include "MueLu_ReplicatePFactory.hpp"
85#include "MueLu_CombinePFactory.hpp"
86#include "MueLu_PgPFactory.hpp"
87#include "MueLu_RAPFactory.hpp"
88#include "MueLu_RAPShiftFactory.hpp"
89#include "MueLu_RebalanceAcFactory.hpp"
90#include "MueLu_RebalanceTransferFactory.hpp"
91#include "MueLu_RepartitionFactory.hpp"
92#include "MueLu_ReitzingerPFactory.hpp"
93#include "MueLu_SaPFactory.hpp"
94#include "MueLu_ScaledNullspaceFactory.hpp"
95#include "MueLu_SemiCoarsenPFactory.hpp"
96#include "MueLu_SmootherFactory.hpp"
97#include "MueLu_SmooVecCoalesceDropFactory.hpp"
98#include "MueLu_TentativePFactory.hpp"
99#include "MueLu_TogglePFactory.hpp"
100#include "MueLu_ToggleCoordinatesTransferFactory.hpp"
101#include "MueLu_TransPFactory.hpp"
102#include "MueLu_UncoupledAggregationFactory.hpp"
103#include "MueLu_ZoltanInterface.hpp"
104#include "MueLu_Zoltan2Interface.hpp"
105#include "MueLu_NodePartitionInterface.hpp"
106#include "MueLu_LowPrecisionFactory.hpp"
108#include "MueLu_CoalesceDropFactory_kokkos.hpp"
109#include "MueLu_NullspaceFactory_kokkos.hpp"
110#include "MueLu_SaPFactory_kokkos.hpp"
111#include "MueLu_SemiCoarsenPFactory_kokkos.hpp"
112#include "MueLu_TentativePFactory_kokkos.hpp"
113#include "MueLu_UncoupledAggregationFactory_kokkos.hpp"
115#ifdef HAVE_MUELU_MATLAB
116#include "../matlab/src/MueLu_MatlabSmoother_decl.hpp"
117#include "../matlab/src/MueLu_MatlabSmoother_def.hpp"
118#include "../matlab/src/MueLu_TwoLevelMatlabFactory_decl.hpp"
119#include "../matlab/src/MueLu_TwoLevelMatlabFactory_def.hpp"
120#include "../matlab/src/MueLu_SingleLevelMatlabFactory_decl.hpp"
121#include "../matlab/src/MueLu_SingleLevelMatlabFactory_def.hpp"
124#ifdef HAVE_MUELU_INTREPID2
125#include "MueLu_IntrepidPCoarsenFactory.hpp"
128#include <unordered_set>
132 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
134 RCP<Teuchos::TimeMonitor> tM = rcp(
new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer(std::string(
"MueLu: ParameterListInterpreter (ParameterList)"))));
135 if(facadeFact == Teuchos::null)
136 facadeFact_ = Teuchos::rcp(
new FacadeClassFactory());
138 facadeFact_ = facadeFact;
140 if (paramList.isParameter(
"xml parameter file")) {
141 std::string filename = paramList.get(
"xml parameter file",
"");
142 if (filename.length() != 0) {
143 TEUCHOS_TEST_FOR_EXCEPTION(comm.is_null(), Exceptions::RuntimeError,
"xml parameter file requires a valid comm");
145 ParameterList paramList2 = paramList;
146 Teuchos::updateParametersFromXmlFileAndBroadcast(filename, Teuchos::Ptr<Teuchos::ParameterList>(¶mList2), *comm);
147 SetParameterList(paramList2);
150 SetParameterList(paramList);
154 SetParameterList(paramList);
158 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
160 RCP<Teuchos::TimeMonitor> tM = rcp(
new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer(std::string(
"MueLu: ParameterListInterpreter (XML)"))));
161 if(facadeFact == Teuchos::null)
166 ParameterList paramList;
167 Teuchos::updateParametersFromXmlFileAndBroadcast(xmlFileName, Teuchos::Ptr<ParameterList>(¶mList), comm);
171 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
179 if (paramList.isSublist(
"Hierarchy")) {
182 }
else if (paramList.isParameter(
"MueLu preconditioner") ==
true) {
183 this->
GetOStream(
Runtime0) <<
"Use facade class: " << paramList.get<std::string>(
"MueLu preconditioner") << std::endl;
184 Teuchos::RCP<ParameterList> pp =
facadeFact_->SetParameterList(paramList);
189 ParameterList serialList, nonSerialList;
201 static inline bool areSame(
const ParameterList& list1,
const ParameterList& list2);
206#define MUELU_SET_VAR_2LIST(paramList, defaultList, paramName, paramType, varName) \
208 if (paramList.isParameter(paramName)) varName = paramList.get<paramType>(paramName); \
209 else if (defaultList.isParameter(paramName)) varName = defaultList.get<paramType>(paramName); \
210 else varName = MasterList::getDefault<paramType>(paramName);
212#define MUELU_TEST_AND_SET_VAR(paramList, paramName, paramType, varName) \
213 (paramList.isParameter(paramName) ? varName = paramList.get<paramType>(paramName), true : false)
217#define MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, paramName, paramType, listWrite) \
219 if (paramList .isParameter(paramName)) listWrite.set(paramName, paramList .get<paramType>(paramName)); \
220 else if (defaultList.isParameter(paramName)) listWrite.set(paramName, defaultList.get<paramType>(paramName)); \
222 catch(Teuchos::Exceptions::InvalidParameterType&) { \
223 TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(true, Teuchos::Exceptions::InvalidParameterType, \
224 "Error: parameter \"" << paramName << "\" must be of type " << Teuchos::TypeNameTraits<paramType>::name()); \
227#define MUELU_TEST_PARAM_2LIST(paramList, defaultList, paramName, paramType, cmpValue) \
229 paramList.isParameter(paramName) ? paramList .get<paramType>(paramName) : ( \
230 defaultList.isParameter(paramName) ? defaultList.get<paramType>(paramName) : \
231 MasterList::getDefault<paramType>(paramName) ) ) )
233#define MUELU_KOKKOS_FACTORY(varName, oldFactory, newFactory) \
234 RCP<Factory> varName; \
235 if (!useKokkos_) varName = rcp(new oldFactory()); \
236 else varName = rcp(new newFactory());
237#define MUELU_KOKKOS_FACTORY_NO_DECL(varName, oldFactory, newFactory) \
238 if (!useKokkos_) varName = rcp(new oldFactory()); \
239 else varName = rcp(new newFactory());
241 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
244 ParameterList paramList;
246 MUELU_SET_VAR_2LIST(constParamList, constParamList,
"problem: type", std::string, problemType);
247 if (problemType !=
"unknown") {
249 paramList.setParameters(constParamList);
253 paramList = constParamList;
257# ifdef HAVE_MUELU_SERIAL
258 if (
typeid(
Node).name() ==
typeid(Tpetra::KokkosCompat::KokkosSerialWrapperNode).name())
261# ifdef HAVE_MUELU_OPENMP
262 if (
typeid(
Node).name() ==
typeid(Tpetra::KokkosCompat::KokkosOpenMPWrapperNode).name())
265# ifdef HAVE_MUELU_CUDA
266 if (
typeid(
Node).name() ==
typeid(Tpetra::KokkosCompat::KokkosCudaWrapperNode).name())
269# ifdef HAVE_MUELU_HIP
270 if (
typeid(
Node).name() ==
typeid(Tpetra::KokkosCompat::KokkosHIPWrapperNode).name())
273# ifdef HAVE_MUELU_SYCL
274 if (
typeid(
Node).name() ==
typeid(Tpetra::KokkosCompat::KokkosSYCLWrapperNode).name())
285 if (paramList.isParameter(
"cycle type")) {
286 std::map<std::string, CycleType> cycleMap;
290 auto cycleType = paramList.get<std::string>(
"cycle type");
292 "Invalid cycle type: \"" << cycleType <<
"\"");
293 Cycle_ = cycleMap[cycleType];
296 if (paramList.isParameter(
"W cycle start level")) {
300 if (paramList.isParameter(
"coarse grid correction scaling factor"))
301 scalingFactor_ = paramList.get<
double>(
"coarse grid correction scaling factor");
311 if(paramList.isParameter(
"save data"))
312 this->
dataToSave_ = Teuchos::getArrayFromStringParameter<std::string>(paramList,
"save data");
315 if (paramList.isSublist(
"export data")) {
316 ParameterList printList = paramList.sublist(
"export data");
319 if (printList.isParameter(
"Nullspace"))
320 this->
nullspaceToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"Nullspace");
321 if (printList.isParameter(
"Coordinates"))
322 this->
coordinatesToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"Coordinates");
323 if (printList.isParameter(
"Aggregates"))
324 this->
aggregatesToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList,
"Aggregates");
325 if (printList.isParameter(
"pcoarsen: element to node map"))
329 for(
auto iter = printList.begin(); iter != printList.end(); iter++) {
330 const std::string & name = printList.name(iter);
332 if(name ==
"Nullspace" || name ==
"Coordinates" || name ==
"Aggregates" || name ==
"pcoarsen: element to node map")
335 this->
matricesToPrint_[name] = Teuchos::getArrayFromStringParameter<int>(printList, name);
348 if (outputFilename !=
"")
360 if (
MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"distance laplacian") ||
364 }
else if(
MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal distance laplacian")) {
367 }
else if(
MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal") ||
368 MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal classical") ||
369 MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal signed classical") ||
370 MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal colored signed classical") ||
371 MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"signed classical")) {
373 }
else if(paramList.isSublist(
"smoother: params")) {
374 const auto smooParamList = paramList.sublist(
"smoother: params");
375 if(smooParamList.isParameter(
"partitioner: type") &&
376 (smooParamList.get<std::string>(
"partitioner: type") ==
"line")) {
380 for (
int levelID = 0; levelID < this->numDesiredLevel_; levelID++) {
381 std::string levelStr =
"level " +
toString(levelID);
383 if (paramList.isSublist(levelStr)) {
384 const ParameterList& levelList = paramList.sublist(levelStr);
386 if (
MUELU_TEST_PARAM_2LIST(levelList, paramList,
"aggregation: drop scheme", std::string,
"distance laplacian") ||
391 else if (
MUELU_TEST_PARAM_2LIST(levelList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal distance laplacian")) {
395 else if (
MUELU_TEST_PARAM_2LIST(levelList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal") ||
396 MUELU_TEST_PARAM_2LIST(levelList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal classical") ||
397 MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal signed classical") ||
398 MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"block diagonal colored signed classical") ||
399 MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"signed classical")) {
411 }
else if (!paramList.isSublist(
"repartition: params")) {
414 const ParameterList& repParams = paramList.sublist(
"repartition: params");
415 if (repParams.isType<std::string>(
"algorithm")) {
416 const std::string algo = repParams.get<std::string>(
"algorithm");
417 if (algo ==
"multijagged" || algo ==
"rcb") {
425 for (
int levelID = 0; levelID < this->numDesiredLevel_; levelID++) {
426 std::string levelStr =
"level " +
toString(levelID);
428 if (paramList.isSublist(levelStr)) {
429 const ParameterList& levelList = paramList.sublist(levelStr);
432 if (!levelList.isSublist(
"repartition: params")) {
436 const ParameterList& repParams = levelList.sublist(
"repartition: params");
437 if (repParams.isType<std::string>(
"algorithm")) {
438 const std::string algo = repParams.get<std::string>(
"algorithm");
439 if (algo ==
"multijagged" || algo ==
"rcb"){
469 if (paramList.isSublist(
"matvec params"))
470 this->
matvecParams_ = Teuchos::parameterList(paramList.sublist(
"matvec params"));
475 defaultManager->SetVerbLevel(this->
verbosity_);
476 defaultManager->SetKokkosRefactor(
useKokkos_);
479 std::vector<keep_pair> keeps0;
486 for (
int levelID = 0; levelID < this->numDesiredLevel_; levelID++) {
492 RCP<FactoryManager> levelManager = rcp(
new FactoryManager(*defaultManager));
493 levelManager->SetVerbLevel(defaultManager->GetVerbLevel());
495 std::vector<keep_pair> keeps;
496 if (paramList.isSublist(
"level " +
toString(levelID))) {
498 ParameterList& levelList = paramList.sublist(
"level " +
toString(levelID),
true);
502 ParameterList levelList;
506 this->
keep_[levelID] = keeps;
522 ParameterList unusedParamList;
525 for (ParameterList::ConstIterator it = paramList.begin(); it != paramList.end(); it++) {
526 const ParameterEntry& entry = paramList.entry(it);
528 if (!entry.isList() && !entry.isUsed())
529 unusedParamList.setEntry(paramList.name(it), entry);
533 for (
int levelID = 0; levelID < this->numDesiredLevel_; levelID++) {
534 std::string levelStr =
"level " +
toString(levelID);
536 if (paramList.isSublist(levelStr)) {
537 const ParameterList& levelList = paramList.sublist(levelStr);
539 for (ParameterList::ConstIterator itr = levelList.begin(); itr != levelList.end(); ++itr) {
540 const ParameterEntry& entry = levelList.entry(itr);
542 if (!entry.isList() && !entry.isUsed())
543 unusedParamList.sublist(levelStr).setEntry(levelList.name(itr), entry);
548 if (unusedParamList.numParams() > 0) {
549 std::ostringstream unusedParamsStream;
551 unusedParamList.print(unusedParamsStream, indent);
553 this->
GetOStream(
Warnings1) <<
"The following parameters were not used:\n" << unusedParamsStream.str() << std::endl;
565 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
568 int levelID, std::vector<keep_pair>& keeps)
const
573 using strings = std::unordered_set<std::string>;
576 if (paramList.numParams() == 0 && defaultList.numParams() > 0)
577 paramList = ParameterList(defaultList);
580 TEUCHOS_TEST_FOR_EXCEPTION(strings({
"none",
"tP",
"RP",
"emin",
"RAP",
"full",
"S"}).count(reuseType) == 0,
583 MUELU_SET_VAR_2LIST(paramList, defaultList,
"multigrid algorithm", std::string, multigridAlgo);
584 TEUCHOS_TEST_FOR_EXCEPTION(strings({
"unsmoothed",
"sa",
"pg",
"emin",
"matlab",
"pcoarsen",
"classical",
"smoothed reitzinger",
"unsmoothed reitzinger",
"replicate",
"combine"}).count(multigridAlgo) == 0,
585 Exceptions::RuntimeError,
"Unknown \"multigrid algorithm\" value: \"" << multigridAlgo <<
"\". Please consult User's Guide.");
586#ifndef HAVE_MUELU_MATLAB
588 "Cannot use matlab for multigrid algorithm - MueLu was not configured with MATLAB support.");
590#ifndef HAVE_MUELU_INTREPID2
592 "Cannot use IntrepidPCoarsen prolongator factory - MueLu was not configured with Intrepid support.");
597 if (reuseType ==
"none" || reuseType ==
"S" || reuseType ==
"RP" || reuseType ==
"RAP") {
600 }
else if (reuseType ==
"tP" && (multigridAlgo !=
"sa" && multigridAlgo !=
"unsmoothed")) {
602 this->
GetOStream(
Warnings0) <<
"Ignoring \"tP\" reuse option as it is only compatible with \"sa\", "
603 "or \"unsmoothed\" multigrid algorithms" << std::endl;
605 }
else if (reuseType ==
"emin" && multigridAlgo !=
"emin") {
607 this->
GetOStream(
Warnings0) <<
"Ignoring \"emin\" reuse option it is only compatible with "
608 "\"emin\" multigrid algorithm" << std::endl;
613 bool have_userP =
false;
614 if (paramList.isParameter(
"P") && !paramList.get<RCP<Matrix> >(
"P").is_null())
628 if(multigridAlgo ==
"unsmoothed reitzinger" || multigridAlgo ==
"smoothed reitzinger")
634 RCP<Factory> nullSpaceFactory;
646 }
else if (multigridAlgo ==
"unsmoothed" || multigridAlgo ==
"unsmoothed reitzinger") {
650 }
else if (multigridAlgo ==
"classical") {
654 }
else if (multigridAlgo ==
"sa" || multigridAlgo ==
"smoothed reitzinger") {
658 }
else if (multigridAlgo ==
"emin") {
662 }
else if (multigridAlgo ==
"replicate") {
665 }
else if (multigridAlgo ==
"combine") {
668 }
else if (multigridAlgo ==
"pg") {
672 }
else if (multigridAlgo ==
"matlab") {
676 }
else if (multigridAlgo ==
"pcoarsen") {
698 if ((reuseType ==
"RP" || reuseType ==
"RAP" || reuseType ==
"full") && levelID)
701 if (reuseType ==
"RP" && levelID) {
706 if ((reuseType ==
"tP" || reuseType ==
"RP" || reuseType ==
"emin") &&
useCoordinates_ && levelID)
716 if ((reuseType ==
"RAP" || reuseType ==
"full") && levelID) {
731 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
734 FactoryManager& manager,
int levelID, std::vector<keep_pair>& keeps)
const
736 MUELU_SET_VAR_2LIST(paramList, defaultList,
"multigrid algorithm", std::string, multigridAlgo);
738 bool useMaxAbsDiagonalScaling =
false;
739 if (defaultList.isParameter(
"sa: use rowsumabs diagonal scaling"))
740 useMaxAbsDiagonalScaling = defaultList.get<
bool>(
"sa: use rowsumabs diagonal scaling");
744 bool isCustomSmoother =
745 paramList.isParameter(
"smoother: pre or post") ||
746 paramList.isParameter(
"smoother: type") || paramList.isParameter(
"smoother: pre type") || paramList.isParameter(
"smoother: post type") ||
747 paramList.isSublist (
"smoother: params") || paramList.isSublist (
"smoother: pre params") || paramList.isSublist (
"smoother: post params") ||
748 paramList.isParameter(
"smoother: sweeps") || paramList.isParameter(
"smoother: pre sweeps") || paramList.isParameter(
"smoother: post sweeps") ||
749 paramList.isParameter(
"smoother: overlap") || paramList.isParameter(
"smoother: pre overlap") || paramList.isParameter(
"smoother: post overlap");
753 manager.
SetFactory(
"Smoother", Teuchos::null);
755 }
else if (isCustomSmoother) {
759 #define TEST_MUTUALLY_EXCLUSIVE(arg1,arg2) \
760 TEUCHOS_TEST_FOR_EXCEPTION(paramList.isParameter(#arg1) && paramList.isParameter(#arg2), \
761 Exceptions::InvalidArgument, "You cannot specify both \""#arg1"\" and \""#arg2"\"");
762 #define TEST_MUTUALLY_EXCLUSIVE_S(arg1,arg2) \
763 TEUCHOS_TEST_FOR_EXCEPTION(paramList.isSublist(#arg1) && paramList.isSublist(#arg2), \
764 Exceptions::InvalidArgument, "You cannot specify both \""#arg1"\" and \""#arg2"\"");
774 TEUCHOS_TEST_FOR_EXCEPTION(
PreOrPost ==
"both" && (paramList.isParameter(
"smoother: pre type") != paramList.isParameter(
"smoother: post type")),
779 ParameterList defaultSmootherParams;
780 defaultSmootherParams.set(
"relaxation: type",
"Symmetric Gauss-Seidel");
781 defaultSmootherParams.set(
"relaxation: sweeps", Teuchos::OrdinalTraits<LO>::one());
782 defaultSmootherParams.set(
"relaxation: damping factor", Teuchos::ScalarTraits<Scalar>::one());
784 RCP<SmootherFactory> preSmoother = Teuchos::null, postSmoother = Teuchos::null;
785 std::string preSmootherType, postSmootherType;
786 ParameterList preSmootherParams, postSmootherParams;
788 if (paramList.isParameter(
"smoother: overlap"))
789 overlap = paramList.get<
int>(
"smoother: overlap");
792 if (paramList.isParameter(
"smoother: pre type")) {
793 preSmootherType = paramList.get<std::string>(
"smoother: pre type");
795 MUELU_SET_VAR_2LIST(paramList, defaultList,
"smoother: type", std::string, preSmootherTypeTmp);
796 preSmootherType = preSmootherTypeTmp;
798 if (paramList.isParameter(
"smoother: pre overlap"))
799 overlap = paramList.get<
int>(
"smoother: pre overlap");
801 if (paramList.isSublist(
"smoother: pre params"))
802 preSmootherParams = paramList.sublist(
"smoother: pre params");
803 else if (paramList.isSublist(
"smoother: params"))
804 preSmootherParams = paramList.sublist(
"smoother: params");
805 else if (defaultList.isSublist(
"smoother: params"))
806 preSmootherParams = defaultList.sublist(
"smoother: params");
807 else if (preSmootherType ==
"RELAXATION")
808 preSmootherParams = defaultSmootherParams;
810 if (preSmootherType ==
"CHEBYSHEV" && useMaxAbsDiagonalScaling)
811 preSmootherParams.set(
"chebyshev: use rowsumabs diagonal scaling",
true);
813 #ifdef HAVE_MUELU_INTREPID2
815 if (multigridAlgo ==
"pcoarsen" && preSmootherType ==
"TOPOLOGICAL" &&
816 defaultList.isParameter(
"pcoarsen: schedule") && defaultList.isParameter(
"pcoarsen: element")) {
819 auto pcoarsen_schedule = Teuchos::getArrayFromStringParameter<int>(defaultList,
"pcoarsen: schedule");
820 auto pcoarsen_element = defaultList.get<std::string>(
"pcoarsen: element");
822 if (levelID < (
int)pcoarsen_schedule.size()) {
824 auto lo = pcoarsen_element + std::to_string(pcoarsen_schedule[levelID]);
825 preSmootherParams.set(
"pcoarsen: hi basis", lo);
830 #ifdef HAVE_MUELU_MATLAB
831 if (preSmootherType ==
"matlab")
839 if (paramList.isParameter(
"smoother: post type"))
840 postSmootherType = paramList.get<std::string>(
"smoother: post type");
842 MUELU_SET_VAR_2LIST(paramList, defaultList,
"smoother: type", std::string, postSmootherTypeTmp);
843 postSmootherType = postSmootherTypeTmp;
846 if (paramList.isSublist(
"smoother: post params"))
847 postSmootherParams = paramList.sublist(
"smoother: post params");
848 else if (paramList.isSublist(
"smoother: params"))
849 postSmootherParams = paramList.sublist(
"smoother: params");
850 else if (defaultList.isSublist(
"smoother: params"))
851 postSmootherParams = defaultList.sublist(
"smoother: params");
852 else if (postSmootherType ==
"RELAXATION")
853 postSmootherParams = defaultSmootherParams;
854 if (paramList.isParameter(
"smoother: post overlap"))
855 overlap = paramList.get<
int>(
"smoother: post overlap");
857 if (postSmootherType ==
"CHEBYSHEV" && useMaxAbsDiagonalScaling)
858 postSmootherParams.set(
"chebyshev: use rowsumabs diagonal scaling",
true);
860 if (postSmootherType == preSmootherType &&
areSame(preSmootherParams, postSmootherParams))
861 postSmoother = preSmoother;
863 #ifdef HAVE_MUELU_INTREPID2
865 if (multigridAlgo ==
"pcoarsen" && preSmootherType ==
"TOPOLOGICAL" &&
866 defaultList.isParameter(
"pcoarsen: schedule") && defaultList.isParameter(
"pcoarsen: element")) {
869 auto pcoarsen_schedule = Teuchos::getArrayFromStringParameter<int>(defaultList,
"pcoarsen: schedule");
870 auto pcoarsen_element = defaultList.get<std::string>(
"pcoarsen: element");
872 if (levelID < (
int)pcoarsen_schedule.size()) {
874 auto lo = pcoarsen_element + std::to_string(pcoarsen_schedule[levelID]);
875 postSmootherParams.set(
"pcoarsen: hi basis", lo);
880 #ifdef HAVE_MUELU_MATLAB
881 if (postSmootherType ==
"matlab")
889 if (preSmoother == postSmoother)
892 manager.
SetFactory(
"PreSmoother", preSmoother);
893 manager.
SetFactory(
"PostSmoother", postSmoother);
900 bool reuseSmoothers = (reuseType ==
"S" || reuseType !=
"none");
901 if (reuseSmoothers) {
902 auto preSmootherFactory = rcp_const_cast<Factory>(rcp_dynamic_cast<const Factory>(manager.
GetFactory(
"PreSmoother")));
904 if (preSmootherFactory != Teuchos::null) {
905 ParameterList postSmootherFactoryParams;
906 postSmootherFactoryParams.set(
"keep smoother data",
true);
907 preSmootherFactory->SetParameterList(postSmootherFactoryParams);
909 keeps.push_back(
keep_pair(
"PreSmoother data", preSmootherFactory.get()));
912 auto postSmootherFactory = rcp_const_cast<Factory>(rcp_dynamic_cast<const Factory>(manager.
GetFactory(
"PostSmoother")));
913 if (postSmootherFactory != Teuchos::null) {
914 ParameterList postSmootherFactoryParams;
915 postSmootherFactoryParams.set(
"keep smoother data",
true);
916 postSmootherFactory->SetParameterList(postSmootherFactoryParams);
918 keeps.push_back(
keep_pair(
"PostSmoother data", postSmootherFactory.get()));
921 auto coarseFactory = rcp_const_cast<Factory>(rcp_dynamic_cast<const Factory>(manager.
GetFactory(
"CoarseSolver")));
922 if (coarseFactory != Teuchos::null) {
923 ParameterList coarseFactoryParams;
924 coarseFactoryParams.set(
"keep smoother data",
true);
925 coarseFactory->SetParameterList(coarseFactoryParams);
927 keeps.push_back(
keep_pair(
"PreSmoother data", coarseFactory.get()));
931 if ((reuseType ==
"RAP" && levelID) || (reuseType ==
"full")) {
950 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
956 bool isCustomCoarseSolver =
957 paramList.isParameter(
"coarse: type") ||
958 paramList.isParameter(
"coarse: params");
960 manager.
SetFactory(
"CoarseSolver", Teuchos::null);
962 }
else if (isCustomCoarseSolver) {
969 if (paramList.isParameter(
"coarse: overlap"))
970 overlap = paramList.get<
int>(
"coarse: overlap");
972 ParameterList coarseParams;
973 if (paramList.isSublist(
"coarse: params"))
974 coarseParams = paramList.sublist(
"coarse: params");
975 else if (defaultList.isSublist(
"coarse: params"))
976 coarseParams = defaultList.sublist(
"coarse: params");
978 using strings = std::unordered_set<std::string>;
980 RCP<SmootherPrototype> coarseSmoother;
984 if (strings({
"RELAXATION",
"CHEBYSHEV",
"ILUT",
"ILU",
"RILUK",
"SCHWARZ",
"Amesos",
985 "BLOCK RELAXATION",
"BLOCK_RELAXATION",
"BLOCKRELAXATION" ,
986 "SPARSE BLOCK RELAXATION",
"SPARSE_BLOCK_RELAXATION",
"SPARSEBLOCKRELAXATION",
987 "LINESMOOTHING_BANDEDRELAXATION",
"LINESMOOTHING_BANDED_RELAXATION",
"LINESMOOTHING_BANDED RELAXATION",
988 "LINESMOOTHING_TRIDIRELAXATION",
"LINESMOOTHING_TRIDI_RELAXATION",
"LINESMOOTHING_TRIDI RELAXATION",
989 "LINESMOOTHING_TRIDIAGONALRELAXATION",
"LINESMOOTHING_TRIDIAGONAL_RELAXATION",
"LINESMOOTHING_TRIDIAGONAL RELAXATION",
990 "TOPOLOGICAL",
"FAST_ILU",
"FAST_IC",
"FAST_ILDL"}).count(coarseType)) {
991 coarseSmoother = rcp(
new TrilinosSmoother(coarseType, coarseParams, overlap));
993 #ifdef HAVE_MUELU_MATLAB
994 if (coarseType ==
"matlab")
998 coarseSmoother = rcp(
new DirectSolver(coarseType, coarseParams));
1009 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1012 FactoryManager& manager,
int levelID, std::vector<keep_pair>& keeps)
const
1014 ParameterList rParams;
1021 rFactory->SetParameterList(rParams);
1029 rFactory->SetFactory(
"D0", this->
GetFactoryManager(levelID-1)->GetFactory(
"D0"));
1042 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1045 FactoryManager& manager,
int levelID, std::vector<keep_pair>& keeps)
const
1047 using strings = std::unordered_set<std::string>;
1052 TEUCHOS_TEST_FOR_EXCEPTION(!strings({
"uncoupled",
"coupled",
"brick",
"matlab",
"notay",
"classical"}).count(aggType),
1057 RCP<AmalgamationFactory> amalgFact;
1058 if(aggType ==
"classical") {
1060 manager.
SetFactory(
"UnAmalgamationInfo",amalgFact);
1064 RCP<Factory> dropFactory;
1067 #ifdef HAVE_MUELU_MATLAB
1069 ParameterList socParams = paramList.sublist(
"strength-of-connection: params");
1070 dropFactory->SetParameterList(socParams);
1072 throw std::runtime_error(
"Cannot use MATLAB evolutionary strength-of-connection - MueLu was not configured with MATLAB support.");
1074 }
else if (
MUELU_TEST_PARAM_2LIST(paramList, paramList,
"aggregation: drop scheme", std::string,
"unsupported vector smoothing")) {
1076 ParameterList dropParams;
1082 dropFactory->SetParameterList(dropParams);
1086 ParameterList dropParams;
1087 if (!rcp_dynamic_cast<CoalesceDropFactory>(dropFactory).is_null())
1088 dropParams.set(
"lightweight wrap",
true);
1108 if(!amalgFact.is_null())
1109 dropFactory->SetFactory(
"UnAmalgamationInfo", manager.
GetFactory(
"UnAmalgamationInfo"));
1111 if(dropParams.isParameter(
"aggregation: drop scheme")) {
1112 std::string drop_scheme = dropParams.get<std::string>(
"aggregation: drop scheme");
1113 if(drop_scheme ==
"block diagonal colored signed classical")
1114 manager.
SetFactory(
"Coloring Graph",dropFactory);
1115 if (drop_scheme.find(
"block diagonal") != std::string::npos || drop_scheme ==
"signed classical") {
1117 dropFactory->SetFactory(
"BlockNumber", this->
GetFactoryManager(levelID-1)->GetFactory(
"BlockNumber"));
1119 dropFactory->SetFactory(
"BlockNumber", manager.
GetFactory(
"BlockNumber"));
1123 dropFactory->SetParameterList(dropParams);
1129 #ifndef HAVE_MUELU_MATLAB
1130 if (aggType ==
"matlab")
1131 throw std::runtime_error(
"Cannot use MATLAB aggregation - MueLu was not configured with MATLAB support.");
1133 RCP<Factory> aggFactory;
1134 if (aggType ==
"uncoupled") {
1136 ParameterList aggParams;
1158 aggFactory->SetParameterList(aggParams);
1160 aggFactory->SetFactory(
"DofsPerNode", manager.
GetFactory(
"Graph"));
1161 aggFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1164 }
else if (aggType ==
"brick") {
1166 ParameterList aggParams;
1173 aggFactory->SetParameterList(aggParams);
1177 manager.
SetFactory(
"DofsPerNode", aggFactory);
1183 aggFactory->SetFactory(
"Coordinates", this->
GetFactoryManager(levelID-1)->GetFactory(
"Coordinates"));
1186 else if (aggType ==
"classical") {
1189 ParameterList mapParams;
1193 ParameterList tempParams;
1195 std::string drop_algo = tempParams.get<std::string>(
"aggregation: drop scheme");
1196 if(drop_algo ==
"block diagonal colored signed classical") {
1197 mapParams.set(
"aggregation: coloring: use color graph",
true);
1198 mapFact->SetFactory(
"Coloring Graph", manager.
GetFactory(
"Coloring Graph"));
1201 mapFact->SetParameterList(mapParams);
1202 mapFact->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1203 mapFact->SetFactory(
"UnAmalgamationInfo", manager.
GetFactory(
"UnAmalgamationInfo"));
1210 ParameterList aggParams;
1213 aggFactory->SetParameterList(aggParams);
1214 aggFactory->SetFactory(
"FC Splitting",manager.
GetFactory(
"FC Splitting"));
1215 aggFactory->SetFactory(
"CoarseMap",manager.
GetFactory(
"CoarseMap"));
1216 aggFactory->SetFactory(
"DofsPerNode", manager.
GetFactory(
"Graph"));
1217 aggFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1219 if (drop_algo.find(
"block diagonal") != std::string::npos || drop_algo ==
"signed classical") {
1221 aggFactory->SetFactory(
"BlockNumber", this->
GetFactoryManager(levelID-1)->GetFactory(
"BlockNumber"));
1223 aggFactory->SetFactory(
"BlockNumber", manager.
GetFactory(
"BlockNumber"));
1231 if (reuseType ==
"tP" && levelID) {
1233 keeps.push_back(
keep_pair(
"Ptent",aggFactory.get()));
1237 else if (aggType ==
"notay") {
1239 ParameterList aggParams;
1245 aggFactory->SetParameterList(aggParams);
1246 aggFactory->SetFactory(
"DofsPerNode", manager.
GetFactory(
"Graph"));
1247 aggFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
1249#ifdef HAVE_MUELU_MATLAB
1250 else if(aggType ==
"matlab") {
1251 ParameterList aggParams = paramList.sublist(
"aggregation: params");
1253 aggFactory->SetParameterList(aggParams);
1259 manager.
SetFactory(
"Aggregates", aggFactory);
1263 coarseMap->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1267 if (
MUELU_TEST_PARAM_2LIST(paramList, defaultList,
"aggregation: compute aggregate qualities",
bool,
true)) {
1269 ParameterList aggQualityParams;
1278 aggQualityFact->SetParameterList(aggQualityParams);
1279 manager.
SetFactory(
"AggregateQualities", aggQualityFact);
1281 assert(aggType ==
"uncoupled");
1282 aggFactory->SetFactory(
"AggregateQualities", aggQualityFact);
1288 ParameterList ptentParams;
1289 if (paramList.isSublist(
"matrixmatrix: kernel params"))
1290 ptentParams.sublist(
"matrixmatrix: kernel params",
false) = paramList.sublist(
"matrixmatrix: kernel params");
1291 if (defaultList.isSublist(
"matrixmatrix: kernel params"))
1292 ptentParams.sublist(
"matrixmatrix: kernel params",
false) = defaultList.sublist(
"matrixmatrix: kernel params");
1295 Ptent->SetParameterList(ptentParams);
1296 Ptent->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1297 Ptent->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1300 if (reuseType ==
"tP" && levelID) {
1301 keeps.push_back(
keep_pair(
"Nullspace", Ptent.get()));
1302 keeps.push_back(
keep_pair(
"P", Ptent.get()));
1309 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1312 int levelID, std::vector<keep_pair>& keeps)
const
1314 if (paramList.isParameter(
"A") && !paramList.get<RCP<Matrix> >(
"A").is_null()) {
1320 ParameterList RAPparams;
1322 RCP<RAPFactory> RAP;
1323 RCP<RAPShiftFactory> RAPs;
1326 std::string alg = paramList.get(
"rap: algorithm",
"galerkin");
1327 if (alg ==
"shift" || alg ==
"non-galerkin") {
1341 if (paramList.isSublist(
"matrixmatrix: kernel params"))
1342 RAPparams.sublist(
"matrixmatrix: kernel params",
false) = paramList.sublist(
"matrixmatrix: kernel params");
1343 if (defaultList.isSublist(
"matrixmatrix: kernel params"))
1344 RAPparams.sublist(
"matrixmatrix: kernel params",
false) = defaultList.sublist(
"matrixmatrix: kernel params");
1351 if (!paramList.isParameter(
"rap: triple product") &&
1352 paramList.isType<std::string>(
"multigrid algorithm") &&
1353 paramList.get<std::string>(
"multigrid algorithm") ==
"unsmoothed")
1354 paramList.set(
"rap: triple product",
true);
1359 if (paramList.isParameter(
"aggregation: allow empty prolongator columns")) {
1360 RAPparams.set(
"CheckMainDiagonal", paramList.get<
bool>(
"aggregation: allow empty prolongator columns"));
1361 RAPparams.set(
"RepairMainDiagonal", paramList.get<
bool>(
"aggregation: allow empty prolongator columns"));
1363 else if (defaultList.isParameter(
"aggregation: allow empty prolongator columns")) {
1364 RAPparams.set(
"CheckMainDiagonal", defaultList.get<
bool>(
"aggregation: allow empty prolongator columns"));
1365 RAPparams.set(
"RepairMainDiagonal", defaultList.get<
bool>(
"aggregation: allow empty prolongator columns"));
1368 }
catch (Teuchos::Exceptions::InvalidParameterType&) {
1369 TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(
true, Teuchos::Exceptions::InvalidParameterType,
1370 "Error: parameter \"aggregation: allow empty prolongator columns\" must be of type " << Teuchos::TypeNameTraits<bool>::name());
1373 if (!RAP.is_null()) {
1374 RAP->SetParameterList(RAPparams);
1375 RAP->SetFactory(
"P", manager.
GetFactory(
"P"));
1377 RAPs->SetParameterList(RAPparams);
1378 RAPs->SetFactory(
"P", manager.
GetFactory(
"P"));
1383 RAP->SetFactory(
"R", manager.
GetFactory(
"R"));
1385 RAPs->SetFactory(
"R", manager.
GetFactory(
"R"));
1388 if (
MUELU_TEST_PARAM_2LIST(paramList, defaultList,
"aggregation: export visualization data",
bool,
true)) {
1390 ParameterList aggExportParams;
1398 aggExport->SetParameterList(aggExportParams);
1399 aggExport->SetFactory(
"DofsPerNode", manager.
GetFactory(
"DofsPerNode"));
1402 RAP->AddTransferFactory(aggExport);
1404 RAPs->AddTransferFactory(aggExport);
1412 MUELU_SET_VAR_2LIST(paramList, defaultList,
"sa: use filtered matrix",
bool, useFiltering);
1413 bool filteringChangesMatrix = useFiltering && !
MUELU_TEST_PARAM_2LIST(paramList, defaultList,
"aggregation: drop tol",
double, 0);
1415 if (reuseType ==
"RP" || (reuseType ==
"tP" && !filteringChangesMatrix)) {
1416 if (!RAP.is_null()) {
1417 keeps.push_back(
keep_pair(
"AP reuse data", RAP.get()));
1418 keeps.push_back(
keep_pair(
"RAP reuse data", RAP.get()));
1421 keeps.push_back(
keep_pair(
"AP reuse data", RAPs.get()));
1422 keeps.push_back(
keep_pair(
"RAP reuse data", RAPs.get()));
1430 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1435 bool have_userCO =
false;
1436 if (paramList.isParameter(
"Coordinates") && !paramList.get<RCP<MultiVector> >(
"Coordinates").is_null())
1445 coords->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1446 coords->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1449 auto RAP = rcp_const_cast<RAPFactory>(rcp_dynamic_cast<const RAPFactory>(manager.
GetFactory(
"A")));
1450 if (!RAP.is_null()) {
1451 RAP->AddTransferFactory(manager.
GetFactory(
"Coordinates"));
1453 auto RAPs = rcp_const_cast<RAPShiftFactory>(rcp_dynamic_cast<const RAPShiftFactory>(manager.
GetFactory(
"A")));
1454 RAPs->AddTransferFactory(manager.
GetFactory(
"Coordinates"));
1463 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1466 FactoryManager& manager,
int levelID, std::vector<keep_pair>& )
const
1471 auto RAP = rcp_const_cast<RAPFactory>(rcp_dynamic_cast<const RAPFactory>(manager.
GetFactory(
"A")));
1472 auto RAPs = rcp_const_cast<RAPShiftFactory>(rcp_dynamic_cast<const RAPShiftFactory>(manager.
GetFactory(
"A")));
1473 if (!RAP.is_null() || !RAPs.is_null()) {
1475 if(multigridAlgo ==
"classical")
1476 fact->SetFactory(
"P Graph", manager.
GetFactory(
"P Graph"));
1478 fact->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1479 fact->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1481 fact->SetFactory(VarName, this->
GetFactoryManager(levelID-1)->GetFactory(VarName));
1486 RAP->AddTransferFactory(manager.
GetFactory(VarName));
1488 RAPs->AddTransferFactory(manager.
GetFactory(VarName));
1497 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1500 FactoryManager& manager,
int levelID , std::vector<keep_pair>& keeps)
const
1503 ParameterList myParams;
1506 fact->SetParameterList(myParams);
1516 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1519 int levelID, std::vector<keep_pair>& )
const
1521 MUELU_SET_VAR_2LIST(paramList, defaultList,
"multigrid algorithm", std::string, multigridAlgo);
1522 bool have_userR =
false;
1523 if (paramList.isParameter(
"R") && !paramList.get<RCP<Matrix> >(
"R").is_null())
1531 if (isSymmetric ==
false && (multigridAlgo ==
"unsmoothed" || multigridAlgo ==
"emin")) {
1533 "Switching \"problem: symmetric\" parameter to symmetric as multigrid algorithm. " <<
1534 multigridAlgo <<
" is primarily supposed to be used for symmetric problems.\n\n" <<
1535 "Please note: if you are using \"unsmoothed\" transfer operators the \"problem: symmetric\" parameter " <<
1536 "has no real mathematical meaning, i.e. you can use it for non-symmetric\n" <<
1537 "problems, too. With \"problem: symmetric\"=\"symmetric\" you can use implicit transpose for building " <<
1538 "the restriction operators which may drastically reduce the amount of consumed memory." << std::endl;
1542 "Petrov-Galerkin smoothed transfer operators are only allowed for non-symmetric problems: Set \"problem: symmetric\" to false!\n" \
1543 "While PG smoothed transfer operators generally would also work for symmetric problems this is an unusual use case. " \
1544 "You can use the factory-based xml interface though if you need PG-AMG for symmetric problems.");
1561 if (paramList.isParameter(
"restriction: scale nullspace") && paramList.get<
bool>(
"restriction: scale nullspace")) {
1563 Teuchos::ParameterList tentPlist;
1564 tentPlist.set(
"Nullspace name",
"Scaled Nullspace");
1565 tentPFactory->SetParameterList(tentPlist);
1566 tentPFactory->SetFactory(
"Aggregates",manager.
GetFactory(
"Aggregates"));
1567 tentPFactory->SetFactory(
"CoarseMap",manager.
GetFactory(
"CoarseMap"));
1570 R->SetFactory(
"P",tentPFactory);
1579 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1582 int levelID, std::vector<keep_pair>& keeps, RCP<Factory> & nullSpaceFactory)
const
1588#if defined(HAVE_MPI) && (defined(HAVE_MUELU_ZOLTAN) || defined(HAVE_MUELU_ZOLTAN2))
1589 MUELU_SET_VAR_2LIST(paramList, defaultList,
"repartition: use subcommunicators in place",
bool, enableInPlace);
1626 "Reuse types \"tP\" and \"PR\" require \"repartition: rebalance P and R\" set to \"false\"");
1631 MUELU_SET_VAR_2LIST(paramList, defaultList,
"repartition: partitioner", std::string, partName);
1633 "Invalid partitioner name: \"" << partName <<
"\". Valid options: \"zoltan\", \"zoltan2\"");
1635# ifndef HAVE_MUELU_ZOLTAN
1636 bool switched =
false;
1637 if (partName ==
"zoltan") {
1638 this->
GetOStream(
Warnings0) <<
"Zoltan interface is not available, trying to switch to Zoltan2" << std::endl;
1639 partName =
"zoltan2";
1643# ifndef HAVE_MUELU_ZOLTAN2
1644 bool switched =
false;
1648# ifndef HAVE_MUELU_ZOLTAN2
1649 if (partName ==
"zoltan2" && !switched) {
1650 this->
GetOStream(
Warnings0) <<
"Zoltan2 interface is not available, trying to switch to Zoltan" << std::endl;
1651 partName =
"zoltan";
1655 MUELU_SET_VAR_2LIST(paramList, defaultList,
"repartition: node repartition level",
int,nodeRepartitionLevel);
1659 ParameterList repartheurParams;
1667 repartheurFactory->SetParameterList(repartheurParams);
1668 repartheurFactory->SetFactory(
"A", manager.
GetFactory(
"A"));
1669 manager.
SetFactory(
"number of partitions", repartheurFactory);
1670 manager.
SetFactory(
"repartition: heuristic target rows per process", repartheurFactory);
1673 RCP<Factory> partitioner;
1674 if (levelID == nodeRepartitionLevel) {
1677 ParameterList partParams;
1679 partitioner->SetParameterList(partParams);
1680 partitioner->SetFactory(
"Node Comm", manager.
GetFactory(
"Node Comm"));
1682 else if (partName ==
"zoltan") {
1683# ifdef HAVE_MUELU_ZOLTAN
1689 }
else if (partName ==
"zoltan2") {
1690# ifdef HAVE_MUELU_ZOLTAN2
1692 ParameterList partParams;
1693 RCP<const ParameterList> partpartParams = rcp(
new ParameterList(paramList.sublist(
"repartition: params",
false)));
1694 partParams.set(
"ParameterList", partpartParams);
1695 partitioner->SetParameterList(partParams);
1696 partitioner->SetFactory(
"repartition: heuristic target rows per process",
1697 manager.
GetFactory(
"repartition: heuristic target rows per process"));
1703 partitioner->SetFactory(
"A", manager.
GetFactory(
"A"));
1704 partitioner->SetFactory(
"number of partitions", manager.
GetFactory(
"number of partitions"));
1706 partitioner->SetFactory(
"Coordinates", manager.
GetFactory(
"Coordinates"));
1707 manager.
SetFactory(
"Partition", partitioner);
1711 ParameterList repartParams;
1715 repartFactory->SetParameterList(repartParams);
1716 repartFactory->SetFactory(
"A", manager.
GetFactory(
"A"));
1717 repartFactory->SetFactory(
"number of partitions", manager.
GetFactory(
"number of partitions"));
1718 repartFactory->SetFactory(
"Partition", manager.
GetFactory(
"Partition"));
1719 manager.
SetFactory(
"Importer", repartFactory);
1720 if (reuseType !=
"none" && reuseType !=
"S" && levelID)
1729 ParameterList rebAcParams;
1732 newA->SetParameterList(rebAcParams);
1733 newA->SetFactory(
"A", manager.
GetFactory(
"A"));
1734 newA->SetFactory(
"InPlaceMap", manager.
GetFactory(
"InPlaceMap"));
1740 ParameterList rebAcParams;
1742 newA->SetParameterList(rebAcParams);
1743 newA->SetFactory(
"A", manager.
GetFactory(
"A"));
1744 newA->SetFactory(
"Importer", manager.
GetFactory(
"Importer"));
1749 ParameterList newPparams;
1750 newPparams.set(
"type",
"Interpolation");
1752 newPparams.set(
"repartition: rebalance P and R", this->
doPRrebalance_);
1754 newPparams.set(
"repartition: explicit via new copy rebalance P and R",
true);
1757 newP-> SetFactory(
"Importer", manager.
GetFactory(
"Importer"));
1758 newP-> SetFactory(
"P", manager.
GetFactory(
"P"));
1759 if (!paramList.isParameter(
"semicoarsen: number of levels"))
1760 newP->SetFactory(
"Nullspace", manager.
GetFactory(
"Ptent"));
1762 newP->SetFactory(
"Nullspace", manager.
GetFactory(
"P"));
1764 newP-> SetFactory(
"Coordinates", manager.
GetFactory(
"Coordinates"));
1769 newP->SetFactory(
"BlockNumber", manager.
GetFactory(
"BlockNumber"));
1775 ParameterList newRparams;
1776 newRparams.set(
"type",
"Restriction");
1779 newRparams.set(
"repartition: rebalance P and R", this->
doPRrebalance_);
1781 newPparams.set(
"repartition: explicit via new copy rebalance P and R",
true);
1785 newR-> SetFactory(
"Importer", manager.
GetFactory(
"Importer"));
1787 newR->SetFactory(
"R", manager.
GetFactory(
"R"));
1798 ParameterList newNullparams;
1800 nullSpaceFactory->SetFactory(
"Nullspace", newP);
1801 nullSpaceFactory->SetParameterList(newNullparams);
1804 paramList.set(
"repartition: enable",
false);
1817 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1820 int levelID, std::vector<keep_pair>& keeps)
const
1822 MUELU_SET_VAR_2LIST(paramList, defaultList,
"transfers: half precision",
bool, enableLowPrecision);
1824 if (enableLowPrecision) {
1827 ParameterList newPparams;
1828 newPparams.set(
"matrix key",
"P");
1830 newP-> SetFactory(
"P", manager.
GetFactory(
"P"));
1836 ParameterList newRparams;
1837 newRparams.set(
"matrix key",
"R");
1839 newR-> SetFactory(
"R", manager.
GetFactory(
"R"));
1848 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1851 int , std::vector<keep_pair>& , RCP<Factory> & nullSpaceFactory)
const
1856 bool have_userNS =
false;
1857 if (paramList.isParameter(
"Nullspace") && !paramList.get<RCP<MultiVector> >(
"Nullspace").is_null())
1861 ParameterList newNullparams;
1863 nullSpace->SetParameterList(newNullparams);
1864 nullSpace->SetFactory(
"Nullspace", manager.
GetFactory(
"Ptent"));
1867 nullSpaceFactory = nullSpace;
1869 if (paramList.isParameter(
"restriction: scale nullspace") && paramList.get<
bool>(
"restriction: scale nullspace")) {
1871 scaledNSfactory->SetFactory(
"Nullspace",nullSpaceFactory);
1872 manager.
SetFactory(
"Scaled Nullspace",scaledNSfactory);
1880 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1883 int , std::vector<keep_pair>& )
const
1886 RCP<Factory> semicoarsenFactory = Teuchos::null;
1887 if (paramList.isParameter(
"semicoarsen: number of levels") &&
1888 paramList.get<
int>(
"semicoarsen: number of levels") > 0) {
1890 ParameterList togglePParams;
1891 ParameterList semicoarsenPParams;
1892 ParameterList linedetectionParams;
1905 linedetectionFactory->SetParameterList(linedetectionParams);
1906 semicoarsenFactory ->SetParameterList(semicoarsenPParams);
1907 togglePFactory ->SetParameterList(togglePParams);
1909 togglePFactory->AddCoarseNullspaceFactory (semicoarsenFactory);
1910 togglePFactory->AddProlongatorFactory (semicoarsenFactory);
1911 togglePFactory->AddPtentFactory (semicoarsenFactory);
1912 togglePFactory->AddCoarseNullspaceFactory (manager.
GetFactory(
"Ptent"));
1913 togglePFactory->AddProlongatorFactory (manager.
GetFactory(
"P"));
1914 togglePFactory->AddPtentFactory (manager.
GetFactory(
"Ptent"));
1916 manager.
SetFactory(
"CoarseNumZLayers", linedetectionFactory);
1917 manager.
SetFactory(
"LineDetection_Layers", linedetectionFactory);
1918 manager.
SetFactory(
"LineDetection_VertLineIds", linedetectionFactory);
1922 manager.
SetFactory(
"Nullspace", togglePFactory);
1925 if (paramList.isParameter(
"semicoarsen: number of levels")) {
1927 tf->SetFactory(
"Chosen P", manager.
GetFactory(
"P"));
1928 tf->AddCoordTransferFactory(semicoarsenFactory);
1931 coords->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
1932 coords->SetFactory(
"CoarseMap", manager.
GetFactory(
"CoarseMap"));
1933 tf->AddCoordTransferFactory(coords);
1942 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1945 int levelID, std::vector<keep_pair>& keeps)
const
1947#ifdef HAVE_MUELU_INTREPID2
1949 if (defaultList.isParameter(
"pcoarsen: schedule") && defaultList.isParameter(
"pcoarsen: element")) {
1952 auto pcoarsen_schedule = Teuchos::getArrayFromStringParameter<int>(defaultList,
"pcoarsen: schedule");
1953 auto pcoarsen_element = defaultList.get<std::string>(
"pcoarsen: element");
1955 if (levelID >= (
int)pcoarsen_schedule.size()) {
1962 ParameterList Pparams;
1964 std::string lo = pcoarsen_element + std::to_string(pcoarsen_schedule[levelID]);
1965 std::string hi = (levelID ? pcoarsen_element + std::to_string(pcoarsen_schedule[levelID-1]) : lo);
1966 Pparams.set(
"pcoarsen: hi basis", hi);
1967 Pparams.set(
"pcoarsen: lo basis", lo);
1968 P->SetParameterList(Pparams);
1977 ParameterList Pparams;
1981 P->SetParameterList(Pparams);
1994 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1999 ParameterList Pparams;
2000 if (paramList.isSublist(
"matrixmatrix: kernel params"))
2001 Pparams.sublist(
"matrixmatrix: kernel params",
false) = paramList.sublist(
"matrixmatrix: kernel params");
2002 if (defaultList.isSublist(
"matrixmatrix: kernel params"))
2003 Pparams.sublist(
"matrixmatrix: kernel params",
false) = defaultList.sublist(
"matrixmatrix: kernel params");
2015 P->SetParameterList(Pparams);
2019 MUELU_SET_VAR_2LIST(paramList, defaultList,
"sa: use filtered matrix",
bool, useFiltering);
2027 ParameterList fParams;
2036 filterFactory->SetParameterList(fParams);
2037 filterFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
2038 filterFactory->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
2039 filterFactory->SetFactory(
"UnAmalgamationInfo", manager.
GetFactory(
"UnAmalgamationInfo"));
2041 filterFactory->SetFactory(
"Filtering", manager.
GetFactory(
"Graph"));
2043 P->SetFactory(
"A", filterFactory);
2046 P->SetFactory(
"A", manager.
GetFactory(
"Graph"));
2050 P->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
2053 bool filteringChangesMatrix = useFiltering && !
MUELU_TEST_PARAM_2LIST(paramList, defaultList,
"aggregation: drop tol",
double, 0);
2055 if (reuseType ==
"tP" && !filteringChangesMatrix)
2056 keeps.push_back(
keep_pair(
"AP reuse data", P.get()));
2062 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2065 int , std::vector<keep_pair>& )
const
2070 "Invalid pattern name: \"" << patternType <<
"\". Valid options: \"AkPtent\"");
2073 ParameterList patternParams;
2075 patternFactory->SetParameterList(patternParams);
2076 patternFactory->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
2077 manager.
SetFactory(
"Ppattern", patternFactory);
2081 constraintFactory->SetFactory(
"Ppattern", manager.
GetFactory(
"Ppattern"));
2082 constraintFactory->SetFactory(
"CoarseNullspace", manager.
GetFactory(
"Ptent"));
2083 manager.
SetFactory(
"Constraint", constraintFactory);
2088 MUELU_SET_VAR_2LIST(paramList, defaultList,
"emin: use filtered matrix",
bool, useFiltering);
2096 ParameterList fParams;
2105 filterFactory->SetParameterList(fParams);
2106 filterFactory->SetFactory(
"Graph", manager.
GetFactory(
"Graph"));
2107 filterFactory->SetFactory(
"Aggregates", manager.
GetFactory(
"Aggregates"));
2108 filterFactory->SetFactory(
"UnAmalgamationInfo", manager.
GetFactory(
"UnAmalgamationInfo"));
2110 filterFactory->SetFactory(
"Filtering", manager.
GetFactory(
"Graph"));
2112 P->SetFactory(
"A", filterFactory);
2115 P->SetFactory(
"A", manager.
GetFactory(
"Graph"));
2120 ParameterList Pparams;
2123 if (reuseType ==
"emin") {
2125 Pparams.set(
"Keep P0",
true);
2126 Pparams.set(
"Keep Constraint0",
true);
2128 P->SetParameterList(Pparams);
2129 P->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
2130 P->SetFactory(
"Constraint", manager.
GetFactory(
"Constraint"));
2137 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2140 int , std::vector<keep_pair>& )
const
2143 "Implicit transpose not supported with Petrov-Galerkin smoothed transfer operators: Set \"transpose: use implicit\" to false!\n" \
2144 "Petrov-Galerkin transfer operator smoothing for non-symmetric problems requires a separate handling of the restriction operator which " \
2145 "does not allow the usage of implicit transpose easily.");
2149 P->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
2156 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2162 ParameterList Pparams;
2165 P->SetParameterList(Pparams);
2173 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2179 ParameterList Pparams;
2182 P->SetParameterList(Pparams);
2191 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2194 int , std::vector<keep_pair>& )
const {
2195#ifdef HAVE_MUELU_MATLAB
2196 ParameterList Pparams = paramList.sublist(
"transfer: params");
2198 P->SetParameterList(Pparams);
2199 P->SetFactory(
"P", manager.
GetFactory(
"Ptent"));
2207#undef MUELU_SET_VAR_2LIST
2208#undef MUELU_TEST_AND_SET_VAR
2209#undef MUELU_TEST_AND_SET_PARAM_2LIST
2210#undef MUELU_TEST_PARAM_2LIST
2211#undef MUELU_KOKKOS_FACTORY
2215 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2217 ParameterList paramList = constParamList;
2220 const int maxLevels = 100;
2223 std::vector<ParameterList> paramLists;
2224 for (
int levelID = 0; levelID < maxLevels; levelID++) {
2225 std::string sublistName =
"level " +
toString(levelID);
2226 if (paramList.isSublist(sublistName)) {
2227 paramLists.push_back(paramList.sublist(sublistName));
2229 paramList.remove(sublistName);
2232 paramLists.push_back(paramList);
2234#ifdef HAVE_MUELU_MATLAB
2236 for (
size_t i = 0; i < paramLists.size(); i++) {
2237 std::vector<std::string> customVars;
2239 for(Teuchos::ParameterList::ConstIterator it = paramLists[i].begin(); it != paramLists[i].end(); it++) {
2240 std::string paramName = paramLists[i].name(it);
2243 customVars.push_back(paramName);
2247 for (
size_t j = 0; j < customVars.size(); j++)
2248 paramLists[i].remove(customVars[j],
false);
2252 const int maxDepth = 0;
2253 for (
size_t i = 0; i < paramLists.size(); i++) {
2256 paramLists[i].validateParameters(validList, maxDepth);
2258 }
catch (
const Teuchos::Exceptions::InvalidParameterName& e) {
2259 std::string eString = e.what();
2262 size_t nameStart = eString.find_first_of(
'"') + 1;
2263 size_t nameEnd = eString.find_first_of(
'"', nameStart);
2264 std::string name = eString.substr(nameStart, nameEnd - nameStart);
2266 size_t bestScore = 100;
2267 std::string bestName =
"";
2268 for (ParameterList::ConstIterator it = validList.begin(); it != validList.end(); it++) {
2269 const std::string& pName = validList.name(it);
2271 size_t score =
LevenshteinDistance(name.c_str(), name.length(), pName.c_str(), pName.length());
2273 if (score < bestScore) {
2278 if (bestScore < 10 && bestName !=
"") {
2279 TEUCHOS_TEST_FOR_EXCEPTION(
true, Teuchos::Exceptions::InvalidParameterName,
2280 eString <<
"The parameter name \"" + name +
"\" is not valid. Did you mean \"" + bestName <<
"\"?\n");
2283 TEUCHOS_TEST_FOR_EXCEPTION(
true, Teuchos::Exceptions::InvalidParameterName,
2284 eString <<
"The parameter name \"" + name +
"\" is not valid.\n");
2293 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2298 ParameterList paramList = constParamList;
2305 if (paramList.isSublist(
"Matrix")) {
2323 if (paramList.isSublist(
"Factories"))
2324 this->
BuildFactoryMap(paramList.sublist(
"Factories"), factoryMap, factoryMap, factoryManagers);
2338 if (paramList.isSublist(
"Hierarchy")) {
2339 ParameterList hieraList = paramList.sublist(
"Hierarchy");
2342 if (hieraList.isParameter(
"max levels")) {
2344 hieraList.remove(
"max levels");
2347 if (hieraList.isParameter(
"coarse: max size")) {
2349 hieraList.remove(
"coarse: max size");
2352 if (hieraList.isParameter(
"repartition: rebalance P and R")) {
2353 this->
doPRrebalance_ = hieraList.get<
bool>(
"repartition: rebalance P and R");
2354 hieraList.remove(
"repartition: rebalance P and R");
2357 if (hieraList.isParameter(
"transpose: use implicit")) {
2359 hieraList.remove(
"transpose: use implicit");
2362 if (hieraList.isParameter(
"fuse prolongation and update")) {
2364 hieraList.remove(
"fuse prolongation and update");
2367 if (hieraList.isParameter(
"nullspace: suppress dimension check")) {
2369 hieraList.remove(
"nullspace: suppress dimension check");
2372 if (hieraList.isParameter(
"number of vectors")) {
2374 hieraList.remove(
"number of vectors");
2377 if (hieraList.isSublist(
"matvec params"))
2378 this->
matvecParams_ = Teuchos::parameterList(hieraList.sublist(
"matvec params"));
2381 if (hieraList.isParameter(
"coarse grid correction scaling factor")) {
2382 this->
scalingFactor_ = hieraList.get<
double>(
"coarse grid correction scaling factor");
2383 hieraList.remove(
"coarse grid correction scaling factor");
2387 if (hieraList.isParameter(
"cycle type")) {
2388 std::map<std::string, CycleType> cycleMap;
2392 std::string cycleType = hieraList.get<std::string>(
"cycle type");
2393 TEUCHOS_TEST_FOR_EXCEPTION(cycleMap.count(cycleType) == 0,
Exceptions::RuntimeError,
"Invalid cycle type: \"" << cycleType <<
"\"");
2394 this->
Cycle_ = cycleMap[cycleType];
2397 if (hieraList.isParameter(
"W cycle start level")) {
2401 if (hieraList.isParameter(
"verbosity")) {
2402 std::string vl = hieraList.get<std::string>(
"verbosity");
2403 hieraList.remove(
"verbosity");
2407 if (hieraList.isParameter(
"output filename"))
2410 if (hieraList.isParameter(
"dependencyOutputLevel"))
2414 if (hieraList.isParameter(
"reuse"))
2417 if (hieraList.isSublist(
"DataToWrite")) {
2420 ParameterList foo = hieraList.sublist(
"DataToWrite");
2421 std::string dataName =
"Matrices";
2422 if (foo.isParameter(dataName))
2423 this->
matricesToPrint_[
"A"] = Teuchos::getArrayFromStringParameter<int>(foo, dataName);
2424 dataName =
"Prolongators";
2425 if (foo.isParameter(dataName))
2426 this->
matricesToPrint_[
"P"] = Teuchos::getArrayFromStringParameter<int>(foo, dataName);
2427 dataName =
"Restrictors";
2428 if (foo.isParameter(dataName))
2429 this->
matricesToPrint_[
"R"] = Teuchos::getArrayFromStringParameter<int>(foo, dataName);
2431 if (foo.isParameter(dataName))
2432 this->
matricesToPrint_[
"D0"] = Teuchos::getArrayFromStringParameter<int>(foo, dataName);
2436 for (ParameterList::ConstIterator param = hieraList.begin(); param != hieraList.end(); ++param) {
2437 const std::string & paramName = hieraList.name(param);
2439 if (paramName !=
"DataToWrite" && hieraList.isSublist(paramName)) {
2440 ParameterList levelList = hieraList.sublist(paramName);
2442 int startLevel = 0;
if(levelList.isParameter(
"startLevel")) { startLevel = levelList.get<
int>(
"startLevel"); levelList.remove(
"startLevel"); }
2443 int numDesiredLevel = 1;
if(levelList.isParameter(
"numDesiredLevel")) { numDesiredLevel = levelList.get<
int>(
"numDesiredLevel"); levelList.remove(
"numDesiredLevel"); }
2456 BuildFactoryMap(levelList, factoryMap, levelFactoryMap, factoryManagers);
2458 RCP<FactoryManager> m = rcp(
new FactoryManager(levelFactoryMap));
2459 if (hieraList.isParameter(
"use kokkos refactor"))
2460 m->SetKokkosRefactor(hieraList.get<
bool>(
"use kokkos refactor"));
2462 if (startLevel >= 0)
2465 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::ParameterListInterpreter():: invalid level id");
2595 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2598 for (ParameterList::ConstIterator param = paramList.begin(); param != paramList.end(); ++param) {
2599 const std::string & paramName = paramList.name(param);
2600 const Teuchos::ParameterEntry & paramValue = paramList.entry(param);
2604 if (paramValue.isList()) {
2605 ParameterList paramList1 = Teuchos::getValue<ParameterList>(paramValue);
2606 if (paramList1.isParameter(
"factory")) {
2609 "MueLu::ParameterListInterpreter(): It seems that in the parameter lists for defining " << paramName <<
2610 " there is both a 'factory' and 'dependency for' parameter. This is not allowed. Please remove the 'dependency for' parameter.");
2612 factoryMapOut[paramName] =
factFact_->BuildFactory(paramValue, factoryMapIn, factoryManagers);
2614 }
else if (paramList1.isParameter(
"dependency for")) {
2616 "MueLu::ParameterListInterpreter(): It seems that in the parameter lists for defining " << paramName <<
2617 " there is both a 'factory' and 'dependency for' parameter. This is not allowed.");
2619 std::string factoryName = paramList1.get<std::string>(
"dependency for");
2621 RCP<const FactoryBase> factbase = factoryMapIn.find(factoryName )->second;
2623 "MueLu::ParameterListInterpreter(): could not find factory " + factoryName +
" in factory map. Did you define it before?");
2625 RCP<const Factory> factoryconst = Teuchos::rcp_dynamic_cast<const Factory>(factbase);
2626 RCP< Factory> factory = Teuchos::rcp_const_cast<Factory>(factoryconst);
2629 RCP<const ParameterList> validParamList = factory->GetValidParameterList();
2630 for (ParameterList::ConstIterator vparam = validParamList->begin(); vparam != validParamList->end(); ++vparam) {
2631 const std::string& pName = validParamList->name(vparam);
2633 if (!paramList1.isParameter(pName)) {
2638 if (validParamList->isType< RCP<const FactoryBase> >(pName)) {
2640 RCP<const FactoryBase> generatingFact =
factFact_->BuildFactory(paramList1.getEntry(pName), factoryMapIn, factoryManagers);
2641 factory->SetFactory(pName, generatingFact.create_weak());
2643 }
else if (validParamList->isType<RCP<const ParameterList> >(pName)) {
2644 if (pName ==
"ParameterList") {
2649 RCP<const ParameterList> subList = Teuchos::sublist(rcp(
new ParameterList(paramList1)), pName);
2650 factory->SetParameter(pName, ParameterEntry(subList));
2653 factory->SetParameter(pName, paramList1.getEntry(pName));
2657 }
else if (paramList1.isParameter(
"group")) {
2659 std::string groupType = paramList1.get<std::string>(
"group");
2661 "group must be of type \"FactoryManager\".");
2663 ParameterList groupList = paramList1;
2664 groupList.remove(
"group");
2666 bool setKokkosRefactor =
false;
2668 if (groupList.isParameter(
"use kokkos refactor")) {
2669 kokkosRefactor = groupList.get<
bool>(
"use kokkos refactor");
2670 groupList.remove(
"use kokkos refactor");
2671 setKokkosRefactor =
true;
2675 BuildFactoryMap(groupList, factoryMapIn, groupFactoryMap, factoryManagers);
2679 RCP<FactoryManager> m = rcp(
new FactoryManager(groupFactoryMap));
2680 if (setKokkosRefactor)
2681 m->SetKokkosRefactor(kokkosRefactor);
2682 factoryManagers[paramName] = m;
2685 this->
GetOStream(
Warnings0) <<
"Could not interpret parameter list " << paramList1 << std::endl;
2687 "XML Parameter list must either be of type \"factory\" or of type \"group\".");
2691 factoryMapOut[paramName] =
factFact_->BuildFactory(paramValue, factoryMapIn, factoryManagers);
2699 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2702 Matrix& A =
dynamic_cast<Matrix&
>(Op);
2703 if (A.IsFixedBlockSizeSet() && (A.GetFixedBlockSize() !=
blockSize_))
2705 <<
"instead of " << A.GetFixedBlockSize() <<
" (provided matrix)." << std::endl
2706 <<
"You may want to check \"number of equations\" (or \"PDE equations\" for factory style list) parameter." << std::endl;
2710#ifdef HAVE_MUELU_DEBUG
2711 MatrixUtils::checkLocalRowMapMatchesColMap(A);
2714 }
catch (std::bad_cast&) {
2715 this->
GetOStream(
Warnings0) <<
"Skipping setting block size as the operator is not a matrix" << std::endl;
2719 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2727 static bool compare(
const ParameterList& list1,
const ParameterList& list2) {
2730 for (ParameterList::ConstIterator it = list1.begin(); it != list1.end(); it++) {
2731 const std::string& name = it->first;
2732 const Teuchos::ParameterEntry& entry1 = it->second;
2734 const Teuchos::ParameterEntry *entry2 = list2.getEntryPtr(name);
2737 if (entry1.isList() && entry2->isList()) {
2738 compare(Teuchos::getValue<ParameterList>(entry1), Teuchos::getValue<ParameterList>(*entry2));
2741 if (entry1.getAny(
false) != entry2->getAny(
false))
2748 static inline bool areSame(
const ParameterList& list1,
const ParameterList& list2) {
2754#define MUELU_PARAMETERLISTINTERPRETER_SHORT
#define MUELU_TEST_AND_SET_VAR(paramList, paramName, paramType, varName)
#define MUELU_SET_VAR_2LIST(paramList, defaultList, paramName, paramType, varName)
#define TEST_MUTUALLY_EXCLUSIVE_S(arg1, arg2)
#define MUELU_KOKKOS_FACTORY_NO_DECL(varName, oldFactory, newFactory)
#define MUELU_TEST_PARAM_2LIST(paramList, defaultList, paramName, paramType, cmpValue)
#define MUELU_KOKKOS_FACTORY(varName, oldFactory, newFactory)
#define TEST_MUTUALLY_EXCLUSIVE(arg1, arg2)
#define MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, paramName, paramType, listWrite)
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
An factory which assigns each aggregate a quality estimate. Originally developed by Napov and Notay i...
AmalgamationFactory for subblocks of strided map based amalgamation data.
Factory for creating a graph based on a given matrix.
Factory for creating a graph based on a given matrix.
Prolongator factory that replicates 'Psubblock' matrix to create new prolongator suitable for PDE sys...
Class that encapsulates direct solvers. Autoselection of AmesosSmoother or Amesos2Smoother according ...
Exception throws to report invalid user entry.
Exception throws to report errors in the internal logical of the program.
Factory that can generate other factories from.
This class specifies the default factory that should generate some data on a Level if the data does n...
void SetFactory(const std::string &varName, const RCP< const FactoryBase > &factory)
Set Factory.
const RCP< const FactoryBase > GetFactory(const std::string &varName) const
Get factory associated with a particular data name.
const RCP< FactoryBase > GetFactoryNonConst(const std::string &varName)
Get factory associated with a particular data name (NONCONST version).
static void DisableMultipleCheckGlobally()
static void EnableTimerSync()
Factory for building restriction operators using a prolongator factory.
Teuchos::RCP< Teuchos::ParameterList > matvecParams_
virtual void SetupHierarchy(Hierarchy &H) const
Setup Hierarchy object.
Teuchos::Array< int > elementToNodeMapsToPrint_
Teuchos::Array< int > nullspaceToPrint_
std::map< std::string, Teuchos::Array< int > > matricesToPrint_
bool doPRViaCopyrebalance_
std::map< int, std::vector< keep_pair > > keep_
bool suppressNullspaceDimensionCheck_
RCP< FactoryManagerBase > GetFactoryManager(int levelID) const
void AddFactoryManager(int startLevel, int numDesiredLevel, RCP< FactoryManagerBase > manager)
Xpetra::global_size_t maxCoarseSize_
bool fuseProlongationAndUpdate_
Teuchos::Array< int > coordinatesToPrint_
Teuchos::Array< std::string > dataToSave_
Teuchos::Array< int > aggregatesToPrint_
static CycleType GetDefaultCycle()
void SetCycleStartLevel(int cycleStart)
static int GetDefaultCycleStartLevel()
void SetCycle(CycleType Cycle)
Supports VCYCLE and WCYCLE types.
void SetProlongatorScalingFactor(double scalingFactor)
Specify damping factor alpha such that x = x + alpha*P*c, where c is the coarse grid correction.
Factory for building transfer operators based on coarsening in polynomial degree, following the Intre...
static Teuchos::RCP< Teuchos::ParameterList > GetProblemSpecificList(std::string const &problemType)
Return default parameter settings for the specified problem type.
static const T & getDefault(const std::string &name)
Returns default value on the "master" list for a parameter with the specified name and type.
static Teuchos::RCP< const Teuchos::ParameterList > List()
Return a "master" list of all valid parameters and their default values.
static const RCP< const NoFactory > getRCP()
Static Get() functions.
Partitioning within a node only.
Factory for generating nullspace.
void UpdateFactoryManager_SA(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
bool changedImplicitTranspose_
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
bool changedPRrebalance_
Easy interpreter stuff.
void UpdateFactoryManager_RAP(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
MueLu::InitialBlockNumberFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node > InitialBlockNumberFactory
void UpdateFactoryManager_Smoothers(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
void UpdateFactoryManager_Aggregation_TentativeP(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
void SetEasyParameterList(const Teuchos::ParameterList ¶mList)
GlobalOrdinal dofOffset_
global offset variable describing offset of DOFs in operator
void UpdateFactoryManager_Coordinates(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
int blockSize_
block size of matrix (fixed block size)
void BuildFactoryMap(const Teuchos::ParameterList ¶mList, const FactoryMap &factoryMapIn, FactoryMap &factoryMapOut, FactoryManagerMap &factoryManagers) const
Interpret "Factories" sublist.
MueLu::RAPShiftFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node > RAPShiftFactory
int WCycleStartLevel_
in case of W-cycle, level on which cycle should start
void UpdateFactoryManager_Restriction(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
MueLu::LineDetectionFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node > LineDetectionFactory
virtual void SetupOperator(Operator &A) const
Setup Operator object.
MueLu::ReitzingerPFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node > ReitzingerPFactory
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
MueLu::Zoltan2Interface< Scalar, LocalOrdinal, GlobalOrdinal, Node > Zoltan2Interface
MueLu::CoordinatesTransferFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node > CoordinatesTransferFactory
MueLu::ClassicalPFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node > ClassicalPFactory
MueLu::Hierarchy< Scalar, LocalOrdinal, GlobalOrdinal, Node > Hierarchy
void UpdateFactoryManager_PCoarsen(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
Teuchos::RCP< MueLu::FacadeClassFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node > > facadeFact_
FacadeClass factory.
ParameterListInterpreter()
Empty constructor.
std::pair< std::string, const FactoryBase * > keep_pair
void UpdateFactoryManager_PG(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
void SetParameterList(const Teuchos::ParameterList ¶mList)
Set parameter list for Parameter list interpreter.
void Validate(const Teuchos::ParameterList ¶mList) const
void UpdateFactoryManager_Emin(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
void UpdateFactoryManager_Combine(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
MueLu::NullspaceFactory_kokkos< Scalar, LocalOrdinal, GlobalOrdinal, Node > NullspaceFactory_kokkos
double scalingFactor_
prolongator scaling factor
MueLu::LocalOrdinalTransferFactory< LocalOrdinal, GlobalOrdinal, Node > LocalOrdinalTransferFactory
CycleType Cycle_
multigrid cycle type (V-cycle or W-cycle)
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
MueLu::ToggleCoordinatesTransferFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node > ToggleCoordinatesTransferFactory
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
MueLu::SemiCoarsenPFactory_kokkos< Scalar, LocalOrdinal, GlobalOrdinal, Node > SemiCoarsenPFactory_kokkos
MueLu::CoarseMapFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node > CoarseMapFactory
Teuchos::RCP< FactoryFactory > factFact_
Internal factory for factories.
MueLu::SemiCoarsenPFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node > SemiCoarsenPFactory
MueLu::PatternFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node > PatternFactory
bool changedPRViaCopyrebalance_
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
MueLu::LowPrecisionFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node > LowPrecisionFactory
MueLu::ClassicalMapFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node > ClassicalMapFactory
void SetupHierarchy(Hierarchy &H) const
Call the SetupHierarchy routine from the HiearchyManager object.
MueLu::TentativePFactory_kokkos< Scalar, LocalOrdinal, GlobalOrdinal, Node > TentativePFactory_kokkos
MueLu::EminPFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node > EminPFactory
MueLu::FilteredAFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node > FilteredAFactory
void SetFactoryParameterList(const Teuchos::ParameterList ¶mList)
Factory interpreter stuff.
MueLu::SaPFactory_kokkos< Scalar, LocalOrdinal, GlobalOrdinal, Node > SaPFactory_kokkos
void UpdateFactoryManager_CoarseSolvers(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps) const
MueLu::ConstraintFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node > ConstraintFactory
MueLu::AggregationExportFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node > AggregationExportFactory
void UpdateFactoryManager_Repartition(Teuchos::ParameterList ¶mList, const Teuchos::ParameterList &defaultList, FactoryManager &manager, int levelID, std::vector< keep_pair > &keeps, RCP< Factory > &nullSpaceFactory) const
MueLu::ZoltanInterface< Scalar, LocalOrdinal, GlobalOrdinal, Node > ZoltanInterface
MueLu::TogglePFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node > TogglePFactory
Factory for building Petrov-Galerkin Smoothed Aggregation prolongators.
Factory for building coarse matrices.
Factory for building coarse matrices.
Applies permutation to grid transfer operators.
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.
Factory for interacting with Matlab.
Factory for creating a graph base on a given matrix.
Generic Smoother Factory for generating the smoothers of the MG hierarchy.
Factory for building tentative prolongator.
Factory for building restriction operators.
Class that encapsulates external library smoothers.
Factory for interacting with Matlab.
Factory for building uncoupled aggregates.
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
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)
Namespace for MueLu classes and methods.
bool IsParamMuemexVariable(const std::string &name)
long ExtractNonSerializableData(const Teuchos::ParameterList &inList, Teuchos::ParameterList &serialList, Teuchos::ParameterList &nonSerialList)
Extract non-serializable data from level-specific sublists and move it to a separate parameter list.
@ Warnings0
Important warning messages (one line).
@ Runtime0
One-liner description of what is happening.
@ Runtime1
Description of what is happening (more verbose).
@ Warnings1
Additional warnings.
size_t LevenshteinDistance(const char *s, size_t len_s, const char *t, size_t len_t)
MsgType toVerbLevel(const std::string &verbLevelStr)
static bool areSame(const ParameterList &list1, const ParameterList &list2)
Helper functions to compare two paramter lists.
static bool compare(const ParameterList &list1, const ParameterList &list2)
std::string toString(const T &what)
Little helper function to convert non-string types to strings.