46 #ifndef MUELU_MLPARAMETERLISTINTERPRETER_DEF_HPP 47 #define MUELU_MLPARAMETERLISTINTERPRETER_DEF_HPP 49 #include <Teuchos_XMLParameterListHelpers.hpp> 52 #if defined(HAVE_MUELU_ML) 53 #include <ml_ValidateParameters.h> 56 #include <Xpetra_Matrix.hpp> 57 #include <Xpetra_MatrixUtils.hpp> 58 #include <Xpetra_MultiVector.hpp> 59 #include <Xpetra_MultiVectorFactory.hpp> 60 #include <Xpetra_Operator.hpp> 65 #include "MueLu_Hierarchy.hpp" 66 #include "MueLu_FactoryManager.hpp" 68 #include "MueLu_TentativePFactory.hpp" 69 #include "MueLu_SaPFactory.hpp" 70 #include "MueLu_PgPFactory.hpp" 71 #include "MueLu_AmalgamationFactory.hpp" 72 #include "MueLu_TransPFactory.hpp" 73 #include "MueLu_GenericRFactory.hpp" 74 #include "MueLu_SmootherPrototype.hpp" 75 #include "MueLu_SmootherFactory.hpp" 76 #include "MueLu_TrilinosSmoother.hpp" 78 #include "MueLu_DirectSolver.hpp" 79 #include "MueLu_HierarchyUtils.hpp" 80 #include "MueLu_RAPFactory.hpp" 81 #include "MueLu_CoalesceDropFactory.hpp" 82 #include "MueLu_CoupledAggregationFactory.hpp" 83 #include "MueLu_UncoupledAggregationFactory.hpp" 84 #include "MueLu_HybridAggregationFactory.hpp" 85 #include "MueLu_NullspaceFactory.hpp" 88 #ifdef HAVE_MUELU_KOKKOS_REFACTOR 89 #include "MueLu_CoalesceDropFactory_kokkos.hpp" 93 #include "MueLu_SaPFactory_kokkos.hpp" 94 #include "MueLu_TentativePFactory_kokkos.hpp" 95 #include "MueLu_UncoupledAggregationFactory_kokkos.hpp" 98 #if defined(HAVE_MUELU_ISORROPIA) && defined(HAVE_MPI) 99 #include "MueLu_IsorropiaInterface.hpp" 100 #include "MueLu_RepartitionHeuristicFactory.hpp" 101 #include "MueLu_RepartitionFactory.hpp" 102 #include "MueLu_RebalanceTransferFactory.hpp" 103 #include "MueLu_RepartitionInterface.hpp" 104 #include "MueLu_RebalanceAcFactory.hpp" 114 #define MUELU_READ_PARAM(paramList, paramStr, varType, defaultValue, varName) \ 115 varType varName = defaultValue; if (paramList.isParameter(paramStr)) varName = paramList.get<varType>(paramStr); 118 #define MUELU_COPY_PARAM(paramList, paramStr, varType, defaultValue, outParamList, outParamStr) \ 119 if (paramList.isParameter(paramStr)) \ 120 outParamList.set(outParamStr, paramList.get<varType>(paramStr)); \ 121 else outParamList.set(outParamStr, static_cast<varType>(defaultValue)); \ 125 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
126 MLParameterListInterpreter<Scalar, LocalOrdinal, GlobalOrdinal, Node>::MLParameterListInterpreter(Teuchos::ParameterList & paramList, Teuchos::RCP<
const Teuchos::Comm<int> > comm, std::vector<RCP<FactoryBase> > factoryList) : nullspace_(NULL), xcoord_(NULL), ycoord_(NULL), zcoord_(NULL),TransferFacts_(factoryList), blksize_(1) {
128 if (paramList.isParameter(
"xml parameter file")){
129 std::string filename = paramList.get(
"xml parameter file",
"");
130 if (filename.length() != 0) {
132 Teuchos::ParameterList paramList2 = paramList;
133 Teuchos::updateParametersFromXmlFileAndBroadcast(filename, Teuchos::Ptr<Teuchos::ParameterList>(¶mList2),*comm);
134 paramList2.remove(
"xml parameter file");
144 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
146 Teuchos::RCP<Teuchos::ParameterList> paramList = Teuchos::getParametersFromXmlFile(xmlFileName);
150 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
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);
245 #endif // HAVE_MUELU_ML 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);
448 #else // #ifdef HAVE_MUELU_ISORROPIA 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);
554 #endif // #ifdef HAVE_MUELU_ISORROPIA 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);
568 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
572 if (nullspace_ != NULL) {
573 RCP<Level> fineLevel = H.
GetLevel(0);
574 RCP<Operator> Op = fineLevel->Get<RCP<Operator> >(
"A");
575 RCP<Matrix> A = rcp_dynamic_cast<Matrix>(Op);
577 const RCP<const Map> rowMap = fineLevel->Get< RCP<Matrix> >(
"A")->getRowMap();
578 RCP<MultiVector> nullspace = MultiVectorFactory::Build(rowMap, nullspaceDim_,
true);
580 for (
size_t i=0; i < Teuchos::as<size_t>(nullspaceDim_); i++) {
581 Teuchos::ArrayRCP<Scalar> nullspacei = nullspace->getDataNonConst(i);
582 const size_t myLength = nullspace->getLocalLength();
584 for (
size_t j = 0; j < myLength; j++) {
585 nullspacei[j] = nullspace_[i*myLength + j];
589 fineLevel->Set(
"Nullspace", nullspace);
594 size_t num_coords = 0;
595 double * coordPTR[3];
597 coordPTR[0] = xcoord_;
600 coordPTR[1] = ycoord_;
603 coordPTR[2] = zcoord_;
609 Teuchos::RCP<Level> fineLevel = H.
GetLevel(0);
610 Teuchos::RCP<Operator> Op = fineLevel->Get<RCP<Operator> >(
"A");
611 Teuchos::RCP<Matrix> A = rcp_dynamic_cast<Matrix>(Op);
613 const Teuchos::RCP<const Map> rowMap = fineLevel->Get< RCP<Matrix> >(
"A")->getRowMap();
614 Teuchos::RCP<MultiVector> coordinates = MultiVectorFactory::Build(rowMap, num_coords,
true);
616 for (
size_t i=0; i < num_coords; i++) {
617 Teuchos::ArrayRCP<Scalar> coordsi = coordinates->getDataNonConst(i);
618 const size_t myLength = coordinates->getLocalLength();
619 for (
size_t j = 0; j < myLength; j++) {
620 coordsi[j] = coordPTR[i][j];
623 fineLevel->Set(
"Coordinates",coordinates);
631 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
632 RCP<MueLu::SmootherFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
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);
769 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
772 TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::rcp_dynamic_cast<TwoLevelFactoryBase>(factory) == Teuchos::null,
Exceptions::BadCast,
"Transfer factory is not derived from TwoLevelFactoryBase. Since transfer factories will be handled by the RAPFactory they have to be derived from TwoLevelFactoryBase!");
773 TransferFacts_.push_back(factory);
776 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
778 return TransferFacts_.size();
781 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
784 Matrix& A =
dynamic_cast<Matrix&
>(Op);
785 if (A.IsFixedBlockSizeSet() && (A.GetFixedBlockSize() != blksize_))
786 this->GetOStream(
Warnings0) <<
"Setting matrix block size to " << blksize_ <<
" (value of the parameter in the list) " 787 <<
"instead of " << A.GetFixedBlockSize() <<
" (provided matrix)." << std::endl;
789 A.SetFixedBlockSize(blksize_);
791 #ifdef HAVE_MUELU_DEBUG 792 MatrixUtils::checkLocalRowMapMatchesColMap(A);
793 #endif // HAVE_MUELU_DEBUG 795 }
catch (std::bad_cast& e) {
796 this->GetOStream(
Warnings0) <<
"Skipping setting block size as the operator is not a matrix" << std::endl;
802 #define MUELU_MLPARAMETERLISTINTERPRETER_SHORT Important warning messages (one line)
Generic Smoother Factory for generating the smoothers of the MG hierarchy.
Exception indicating invalid cast attempted.
This class specifies the default factory that should generate some data on a Level if the data does n...
void MergeParameterList(const Teuchos::ParameterList &source, Teuchos::ParameterList &dest, bool overWrite)
: merge two parameter lists
virtual void SetupOperator(Operator &Op) const
Setup Operator object.
MLParameterListInterpreter()
Constructor.
Factory for determing the number of partitions for rebalancing.
RCP< Level > & GetLevel(const int levelID=0)
Retrieve a certain level from hierarchy.
Class that encapsulates external library smoothers.
Interface to IsorropiaInterface to Isorropia allowing to access other rebalancing/repartitioning algo...
virtual void SetupHierarchy(Hierarchy &H) const
Setup Hierarchy object.
Factory for building permutation matrix that can be be used to shuffle data (matrices, vectors) among processes.
std::string tolower(const std::string &str)
Namespace for MueLu classes and methods.
#define MUELU_READ_PARAM(paramList, paramStr, varType, defaultValue, varName)
const Teuchos::ParameterList & GetMLSubList(const Teuchos::ParameterList ¶mList, const std::string &type, int levelID)
void AddTransferFactory(const RCP< FactoryBase > &factory)
Add transfer factory in the end of list of transfer factories for RAPFactory.
Factory for building tentative prolongator.
Class that encapsulates direct solvers. Autoselection of AmesosSmoother or Amesos2Smoother according ...
Factory for coarsening a graph with uncoupled aggregation.
virtual void SetupHierarchy(Hierarchy &H) const
Setup Hierarchy object.
Factory for building restriction operators using a prolongator factory.
void CreateSublists(const ParameterList &List, ParameterList &newList)
MueLu::DefaultScalar Scalar
static RCP< SmootherFactory > GetSmootherFactory(const Teuchos::ParameterList ¶mList, const RCP< FactoryBase > &AFact=Teuchos::null)
Read smoother options and build the corresponding smoother factory.
Teuchos::RCP< Teuchos::ParameterList > ExtractSetOfParameters(const Teuchos::ParameterList ¶mList, const std::string &str)
AmalgamationFactory for subblocks of strided map based amalgamation data.
size_t NumTransferFactories() const
Returns number of transfer factories.
Applies permutation to grid transfer operators.
Factory for creating a graph based on a given matrix.
Helper class which transforms an "AmalgamatedPartition" array to an unamalgamated "Partition"...
void SetParameterList(const Teuchos::ParameterList ¶mList)
Factory for building restriction operators.
Factory for building coarse matrices.
Exception throws to report errors in the internal logical of the program.
Description of what is happening (more verbose)
Factory for building coarse matrices.
#define MUELU_COPY_PARAM(paramList, paramStr, varType, defaultValue, outParamList, outParamStr)
Factory for building Petrov-Galerkin Smoothed Aggregation prolongators.
Factory for building Smoothed Aggregation prolongators.
Factory for building uncoupled aggregates.
Provides methods to build a multigrid hierarchy and apply multigrid cycles.
Factory for generating nullspace.