152 Teuchos::ParameterList paramList = paramList_in;
165 MUELU_READ_PARAM(paramList,
"aggregation: type", std::string,
"Uncoupled", agg_type);
167 MUELU_READ_PARAM(paramList,
"aggregation: damping factor",
double, (
double)4/(
double)3, agg_damping);
169 MUELU_READ_PARAM(paramList,
"aggregation: nodes per aggregate",
int, 1, minPerAgg);
170 MUELU_READ_PARAM(paramList,
"aggregation: keep Dirichlet bcs",
bool,
false, bKeepDirichletBcs);
171 MUELU_READ_PARAM(paramList,
"aggregation: max neighbours already aggregated",
int, 0, maxNbrAlreadySelected);
172 MUELU_READ_PARAM(paramList,
"aggregation: aux: enable",
bool,
false, agg_use_aux);
173 MUELU_READ_PARAM(paramList,
"aggregation: aux: threshold",
double,
false, agg_aux_thresh);
175 MUELU_READ_PARAM(paramList,
"null space: type", std::string,
"default vectors", nullspaceType);
176 MUELU_READ_PARAM(paramList,
"null space: dimension",
int, -1, nullspaceDim);
177 MUELU_READ_PARAM(paramList,
"null space: vectors",
double*, NULL, nullspaceVec);
179 MUELU_READ_PARAM(paramList,
"energy minimization: enable",
bool,
false, bEnergyMinimization);
181 MUELU_READ_PARAM(paramList,
"RAP: fix diagonal",
bool,
false, bFixDiagonal);
194 ParameterList paramListWithSubList;
196 paramList = paramListWithSubList;
199 bool setKokkosRefactor =
false;
200 bool useKokkosRefactor;
201#if !defined(HAVE_MUELU_KOKKOS_REFACTOR)
202 useKokkosRefactor =
false;
204# ifdef HAVE_MUELU_SERIAL
205 if (
typeid(
Node).name() ==
typeid(Kokkos::Compat::KokkosSerialWrapperNode).name())
206 useKokkosRefactor =
false;
208# ifdef HAVE_MUELU_OPENMP
209 if (
typeid(
Node).name() ==
typeid(Kokkos::Compat::KokkosOpenMPWrapperNode).name())
210 useKokkosRefactor =
true;
212# ifdef HAVE_MUELU_CUDA
213 if (
typeid(
Node).name() ==
typeid(Kokkos::Compat::KokkosCudaWrapperNode).name())
214 useKokkosRefactor =
true;
216# ifdef HAVE_MUELU_HIP
217 if (
typeid(
Node).name() ==
typeid(Kokkos::Compat::KokkosHIPWrapperNode).name())
218 useKokkosRefactor =
true;
221 if (paramList.isType<
bool>(
"use kokkos refactor")) {
222 useKokkosRefactor = paramList.get<
bool>(
"use kokkos refactor");
223 setKokkosRefactor =
true;
224 paramList.remove(
"use kokkos refactor");
232 bool validate = paramList.get(
"ML validate parameter list",
true);
235#if defined(HAVE_MUELU_ML)
237 int depth = paramList.get(
"ML validate depth", 5);
239 "ERROR: ML's Teuchos::ParameterList contains incorrect parameter!");
242 this->GetOStream(
Warnings0) <<
"Warning: MueLu_ENABLE_ML=OFF. The parameter list cannot be validated." << std::endl;
243 paramList.set(
"ML validate parameter list",
false);
251 blksize_ = nDofsPerNode;
257 if (verbosityLevel == 0) eVerbLevel =
None;
258 if (verbosityLevel >= 1) eVerbLevel =
Low;
259 if (verbosityLevel >= 5) eVerbLevel =
Medium;
260 if (verbosityLevel >= 10) eVerbLevel =
High;
261 if (verbosityLevel >= 11) eVerbLevel =
Extreme;
262 if (verbosityLevel >= 42) eVerbLevel =
Test;
264 this->verbosity_ = eVerbLevel;
268 "MueLu::MLParameterListInterpreter::SetParameterList(): parameter \"aggregation: type\": only 'Uncoupled' or 'Coupled' aggregation is supported.");
271 RCP<Factory> dropFact;
272#ifdef HAVE_MUELU_KOKKOS_REFACTOR
273 if(useKokkosRefactor)
274 dropFact = rcp(
new CoalesceDropFactory_kokkos() );
280 dropFact->SetParameter(
"aggregation: drop scheme",Teuchos::ParameterEntry(std::string(
"distance laplacian")));
281 dropFact->SetParameter(
"aggregation: drop tol",Teuchos::ParameterEntry(agg_aux_thresh));
284 RCP<Factory> AggFact = Teuchos::null;
285 if (agg_type ==
"Uncoupled") {
287 RCP<Factory> MyUncoupledAggFact;
288#ifdef HAVE_MUELU_KOKKOS_REFACTOR
289 if(useKokkosRefactor) {
290 MyUncoupledAggFact = rcp(
new UncoupledAggregationFactory_kokkos() );
296 MyUncoupledAggFact->SetFactory(
"Graph", dropFact);
297 MyUncoupledAggFact->SetFactory(
"DofsPerNode", dropFact);
298 MyUncoupledAggFact->SetParameter(
"aggregation: preserve Dirichlet points", Teuchos::ParameterEntry(bKeepDirichletBcs));
299 MyUncoupledAggFact->SetParameter(
"aggregation: ordering", Teuchos::ParameterEntry(std::string(
"natural")));
300 MyUncoupledAggFact->SetParameter(
"aggregation: max selected neighbors", Teuchos::ParameterEntry(maxNbrAlreadySelected));
301 MyUncoupledAggFact->SetParameter(
"aggregation: min agg size", Teuchos::ParameterEntry(minPerAgg));
303 AggFact = MyUncoupledAggFact;
306#ifdef HAVE_MUELU_KOKKOS_REFACTOR
307 if(useKokkosRefactor) {
308 AggFact = rcp(
new UncoupledAggregationFactory_kokkos() );
311 CoupledAggFact2->SetMinNodesPerAggregate(minPerAgg);
312 CoupledAggFact2->SetMaxNeighAlreadySelected(maxNbrAlreadySelected);
313 CoupledAggFact2->SetOrdering(
"natural");
314 CoupledAggFact2->SetPhase3AggCreation(0.5);
315 CoupledAggFact2->SetFactory(
"Graph", dropFact);
316 CoupledAggFact2->SetFactory(
"DofsPerNode", dropFact);
317 AggFact = CoupledAggFact2;
322 CoupledAggFact2->SetMinNodesPerAggregate(minPerAgg);
323 CoupledAggFact2->SetMaxNeighAlreadySelected(maxNbrAlreadySelected);
324 CoupledAggFact2->SetOrdering(
"natural");
325 CoupledAggFact2->SetPhase3AggCreation(0.5);
326 CoupledAggFact2->SetFactory(
"Graph", dropFact);
327 CoupledAggFact2->SetFactory(
"DofsPerNode", dropFact);
328 AggFact = CoupledAggFact2;
331 if (verbosityLevel > 3) {
332 std::ostringstream oss;
333 oss <<
"========================= Aggregate option summary  =========================" << std::endl;
334 oss <<
"min Nodes per aggregate : Â Â Â Â Â Â Â " << minPerAgg << std::endl;
335 oss <<
"min # of root nbrs already aggregated : " << maxNbrAlreadySelected << std::endl;
336 oss <<
"aggregate ordering : Â Â Â Â Â Â Â Â Â Â natural" << std::endl;
337 oss <<
"=============================================================================" << std::endl;
338 this->GetOStream(
Runtime1) << oss.str();
343 RCP<Factory> PtentFact;
344#ifdef HAVE_MUELU_KOKKOS_REFACTOR
345 if(useKokkosRefactor)
346 PtentFact = rcp(
new TentativePFactory_kokkos() );
350 if (agg_damping == 0.0 && bEnergyMinimization ==
false) {
354 }
else if (agg_damping != 0.0 && bEnergyMinimization ==
false) {
356 RCP<Factory> SaPFact;
357#ifdef HAVE_MUELU_KOKKOS_REFACTOR
358 if(useKokkosRefactor)
359 SaPFact = rcp(
new SaPFactory_kokkos() );
363 SaPFact->SetParameter(
"sa: damping factor", ParameterEntry(agg_damping));
366 }
else if (bEnergyMinimization ==
true) {
372 RCP<RAPFactory> AcFact = rcp(
new RAPFactory() );
373 AcFact->SetParameter(
"RepairMainDiagonal", Teuchos::ParameterEntry(bFixDiagonal));
374 for (
size_t i = 0; i<TransferFacts_.size(); i++) {
375 AcFact->AddTransferFactory(TransferFacts_[i]);
381#if defined(HAVE_MUELU_ISORROPIA) && defined(HAVE_MPI)
382 Teuchos::RCP<Factory> RebalancedPFact = Teuchos::null;
383 Teuchos::RCP<Factory> RebalancedRFact = Teuchos::null;
384 Teuchos::RCP<Factory> RepartitionFact = Teuchos::null;
385 Teuchos::RCP<RebalanceAcFactory> RebalancedAFact = Teuchos::null;
388 if (bDoRepartition == 1) {
391 RFact->SetFactory(
"P", PFact);
393 AcFact->SetFactory(
"P", PFact);
394 AcFact->SetFactory(
"R", RFact);
398 rebAmalgFact->SetFactory(
"A", AcFact);
400 MUELU_READ_PARAM(paramList,
"repartition: max min ratio",
double, 1.3, maxminratio);
401 MUELU_READ_PARAM(paramList,
"repartition: min per proc",
int, 512, minperproc);
406 Teuchos::ParameterList paramListRepFact;
407 paramListRepFact.set(
"repartition: min rows per proc", minperproc);
408 paramListRepFact.set(
"repartition: max imbalance", maxminratio);
409 RepartitionHeuristicFact->SetParameterList(paramListRepFact);
411 RepartitionHeuristicFact->SetFactory(
"A", AcFact);
415 isoInterface->SetFactory(
"A", AcFact);
416 isoInterface->SetFactory(
"number of partitions", RepartitionHeuristicFact);
417 isoInterface->SetFactory(
"UnAmalgamationInfo", rebAmalgFact);
421 repInterface->SetFactory(
"A", AcFact);
422 repInterface->SetFactory(
"number of partitions", RepartitionHeuristicFact);
423 repInterface->SetFactory(
"AmalgamatedPartition", isoInterface);
428 RepartitionFact->SetFactory(
"A", AcFact);
429 RepartitionFact->SetFactory(
"number of partitions", RepartitionHeuristicFact);
430 RepartitionFact->SetFactory(
"Partition", repInterface);
434 RebalancedPFact->SetParameter(
"type", Teuchos::ParameterEntry(std::string(
"Interpolation")));
435 RebalancedPFact->SetFactory(
"P", PFact);
436 RebalancedPFact->SetFactory(
"Nullspace", PtentFact);
437 RebalancedPFact->SetFactory(
"Importer", RepartitionFact);
440 RebalancedRFact->SetParameter(
"type", Teuchos::ParameterEntry(std::string(
"Restriction")));
441 RebalancedRFact->SetFactory(
"R", RFact);
442 RebalancedRFact->SetFactory(
"Importer", RepartitionFact);
446 RebalancedAFact->SetFactory(
"A", AcFact);
462 if (nullspaceType !=
"default vectors") {
463 TEUCHOS_TEST_FOR_EXCEPTION(nullspaceType !=
"pre-computed",
Exceptions::RuntimeError,
"MueLu::MLParameterListInterpreter: no valid nullspace (no pre-computed null space). error.");
464 TEUCHOS_TEST_FOR_EXCEPTION(nullspaceDim == -1,
Exceptions::RuntimeError,
"MueLu::MLParameterListInterpreter: no valid nullspace (nullspace dim == -1). error.");
465 TEUCHOS_TEST_FOR_EXCEPTION(nullspaceVec == NULL,
Exceptions::RuntimeError,
"MueLu::MLParameterListInterpreter: no valid nullspace (nullspace == NULL). You have to provide a valid fine-level nullspace in \'null space: vectors\'");
467 nullspaceDim_ = nullspaceDim;
468 nullspace_ = nullspaceVec;
471 Teuchos::RCP<NullspaceFactory> nspFact = Teuchos::rcp(
new NullspaceFactory(
"Nullspace"));
472 nspFact->SetFactory(
"Nullspace", PtentFact);
487 this->numDesiredLevel_ = maxLevels;
488 this->maxCoarseSize_ = maxCoarseSize;
493 ParameterList& coarseList = paramList.sublist(
"coarse: list");
495 if (!coarseList.isParameter(
"smoother: type"))
496 coarseList.set(
"smoother: type",
"Amesos-KLU");
497 RCP<SmootherFactory> coarseFact = GetSmootherFactory(coarseList, Teuchos::null);
508 for (
int levelID=0; levelID < maxLevels; levelID++) {
515 if (setKokkosRefactor)
516 manager->SetKokkosRefactor(useKokkosRefactor);
526 ParameterList levelSmootherParam =
GetMLSubList(paramList,
"smoother", levelID);
531 RCP<SmootherFactory> smootherFact = GetSmootherFactory(levelSmootherParam, Teuchos::null);
533 manager->SetFactory(
"Smoother", smootherFact);
540 manager->SetFactory(
"CoarseSolver", coarseFact);
541 manager->SetFactory(
"Graph", dropFact);
542 manager->SetFactory(
"Aggregates", AggFact);
543 manager->SetFactory(
"DofsPerNode", dropFact);
544 manager->SetFactory(
"Ptent", PtentFact);
546#if defined(HAVE_MUELU_ISORROPIA) && defined(HAVE_MPI)
547 if (bDoRepartition == 1) {
548 manager->SetFactory(
"A", RebalancedAFact);
549 manager->SetFactory(
"P", RebalancedPFact);
550 manager->SetFactory(
"R", RebalancedRFact);
551 manager->SetFactory(
"Nullspace", RebalancedPFact);
552 manager->SetFactory(
"Importer", RepartitionFact);
555 manager->SetFactory(
"Nullspace", nspFact);
556 manager->SetFactory(
"A", AcFact);
557 manager->SetFactory(
"P", PFact);
558 manager->SetFactory(
"R", RFact);
559#if defined(HAVE_MUELU_ISORROPIA) && defined(HAVE_MPI)
563 this->AddFactoryManager(levelID, 1, manager);
635 const RCP<FactoryBase> & AFact)
637 typedef Teuchos::ScalarTraits<Scalar> STS;
640 std::string type =
"symmetric Gauss-Seidel";
662 if (paramList.isParameter(
"smoother: type")) type = paramList.get<std::string>(
"smoother: type");
663 TEUCHOS_TEST_FOR_EXCEPTION(type.empty(),
Exceptions::RuntimeError,
"MueLu::MLParameterListInterpreter: no \"smoother: type\" in the smoother parameter list" << std::endl << paramList);
669 RCP<SmootherPrototype> smooProto;
670 std::string ifpackType;
671 Teuchos::ParameterList smootherParamList;
673 if (type ==
"Jacobi" || type ==
"Gauss-Seidel" || type ==
"symmetric Gauss-Seidel") {
674 if (type ==
"symmetric Gauss-Seidel") type =
"Symmetric Gauss-Seidel";
676 ifpackType =
"RELAXATION";
677 smootherParamList.set(
"relaxation: type", type);
679 MUELU_COPY_PARAM(paramList,
"smoother: sweeps",
int, 2, smootherParamList,
"relaxation: sweeps");
680 MUELU_COPY_PARAM(paramList,
"smoother: damping factor",
Scalar, one, smootherParamList,
"relaxation: damping factor");
683 smooProto->SetFactory(
"A", AFact);
685 }
else if (type ==
"Chebyshev" || type ==
"MLS") {
687 ifpackType =
"CHEBYSHEV";
689 MUELU_COPY_PARAM(paramList,
"smoother: sweeps",
int, 2, smootherParamList,
"chebyshev: degree");
690 if (paramList.isParameter(
"smoother: MLS alpha")) {
691 MUELU_COPY_PARAM(paramList,
"smoother: MLS alpha",
double, 20, smootherParamList,
"chebyshev: ratio eigenvalue");
693 MUELU_COPY_PARAM(paramList,
"smoother: Chebyshev alpha",
double, 20, smootherParamList,
"chebyshev: ratio eigenvalue");
698 smooProto->SetFactory(
"A", AFact);
700 }
else if (type ==
"IFPACK") {
702#if defined(HAVE_MUELU_EPETRA) && defined(HAVE_MUELU_IFPACK)
703 ifpackType = paramList.get<std::string>(
"smoother: ifpack type");
705 if (ifpackType ==
"ILU") {
708 if (paramList.isParameter(
"smoother: ifpack level-of-fill"))
709 smootherParamList.set(
"fact: level-of-fill", Teuchos::as<int>(paramList.get<
double>(
"smoother: ifpack level-of-fill")));
710 else smootherParamList.set(
"fact: level-of-fill", as<int>(0));
712 MUELU_COPY_PARAM(paramList,
"smoother: ifpack overlap",
int, 2, smootherParamList,
"partitioner: overlap");
716 MueLu::GetIfpackSmoother<Scalar, LocalOrdinal, GlobalOrdinal, Node> (ifpackType,
718 paramList.get<
int> (
"smoother: ifpack overlap"));
719 smooProto->SetFactory(
"A", AFact);
721 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::MLParameterListInterpreter: unknown ML smoother type " + type +
" (IFPACK) not supported by MueLu. Only ILU is supported.");
724 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::MLParameterListInterpreter: MueLu compiled without Ifpack support");
727 }
else if (type.length() > strlen(
"Amesos") && type.substr(0, strlen(
"Amesos")) ==
"Amesos") {
728 std::string solverType = type.substr(strlen(
"Amesos")+1);
732 const int validatorSize = 5;
733 std::string validator[validatorSize] = {
"Superlu",
"Superludist",
"KLU",
"UMFPACK",
"MUMPS"};
734 for (
int i=0; i < validatorSize; i++) {
if (validator[i] == solverType) valid =
true; }
735 TEUCHOS_TEST_FOR_EXCEPTION(!valid,
Exceptions::RuntimeError,
"MueLu::MLParameterListInterpreter: unknown smoother type. '" << type <<
"' not supported.");
738 std::transform(solverType.begin()+1, solverType.end(), solverType.begin()+1, ::tolower);
740 smooProto = Teuchos::rcp(
new DirectSolver(solverType, Teuchos::ParameterList()) );
741 smooProto->SetFactory(
"A", AFact);
745 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::MLParameterListInterpreter: unknown smoother type. '" << type <<
"' not supported by MueLu.");
748 TEUCHOS_TEST_FOR_EXCEPTION(smooProto == Teuchos::null,
Exceptions::RuntimeError,
"MueLu::MLParameterListInterpreter: no smoother prototype. fatal error.");
757 MUELU_READ_PARAM(paramList,
"smoother: pre or post", std::string,
"both", preOrPost);
758 if (preOrPost ==
"both") {
759 SmooFact->SetSmootherPrototypes(smooProto, smooProto);
760 }
else if (preOrPost ==
"pre") {
761 SmooFact->SetSmootherPrototypes(smooProto, Teuchos::null);
762 }
else if (preOrPost ==
"post") {
763 SmooFact->SetSmootherPrototypes(Teuchos::null, smooProto);