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#include "MueLu_CoalesceDropFactory_kokkos.hpp"
92#include "MueLu_SaPFactory_kokkos.hpp"
93#include "MueLu_TentativePFactory_kokkos.hpp"
94#include "MueLu_UncoupledAggregationFactory_kokkos.hpp"
96#if defined(HAVE_MUELU_ISORROPIA) && defined(HAVE_MPI)
97#include "MueLu_IsorropiaInterface.hpp"
98#include "MueLu_RepartitionHeuristicFactory.hpp"
99#include "MueLu_RepartitionFactory.hpp"
100#include "MueLu_RebalanceTransferFactory.hpp"
101#include "MueLu_RepartitionInterface.hpp"
102#include "MueLu_RebalanceAcFactory.hpp"
112#define MUELU_READ_PARAM(paramList, paramStr, varType, defaultValue, varName) \
113 varType varName = defaultValue; if (paramList.isParameter(paramStr)) varName = paramList.get<varType>(paramStr);
116#define MUELU_COPY_PARAM(paramList, paramStr, varType, defaultValue, outParamList, outParamStr) \
117 if (paramList.isParameter(paramStr)) \
118 outParamList.set(outParamStr, paramList.get<varType>(paramStr)); \
119 else outParamList.set(outParamStr, static_cast<varType>(defaultValue)); \
123 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
124 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) {
126 if (paramList.isParameter(
"xml parameter file")){
127 std::string filename = paramList.get(
"xml parameter file",
"");
128 if (filename.length() != 0) {
130 Teuchos::ParameterList paramList2 = paramList;
131 Teuchos::updateParametersFromXmlFileAndBroadcast(filename, Teuchos::Ptr<Teuchos::ParameterList>(¶mList2),*comm);
132 paramList2.remove(
"xml parameter file");
142 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
144 Teuchos::RCP<Teuchos::ParameterList> paramList = Teuchos::getParametersFromXmlFile(xmlFileName);
148 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
150 Teuchos::ParameterList paramList = paramList_in;
163 MUELU_READ_PARAM(paramList,
"aggregation: type", std::string,
"Uncoupled", agg_type);
165 MUELU_READ_PARAM(paramList,
"aggregation: damping factor",
double, (
double)4/(
double)3, agg_damping);
167 MUELU_READ_PARAM(paramList,
"aggregation: nodes per aggregate",
int, 1, minPerAgg);
168 MUELU_READ_PARAM(paramList,
"aggregation: keep Dirichlet bcs",
bool,
false, bKeepDirichletBcs);
169 MUELU_READ_PARAM(paramList,
"aggregation: max neighbours already aggregated",
int, 0, maxNbrAlreadySelected);
170 MUELU_READ_PARAM(paramList,
"aggregation: aux: enable",
bool,
false, agg_use_aux);
171 MUELU_READ_PARAM(paramList,
"aggregation: aux: threshold",
double,
false, agg_aux_thresh);
173 MUELU_READ_PARAM(paramList,
"null space: type", std::string,
"default vectors", nullspaceType);
174 MUELU_READ_PARAM(paramList,
"null space: dimension",
int, -1, nullspaceDim);
175 MUELU_READ_PARAM(paramList,
"null space: vectors",
double*, NULL, nullspaceVec);
177 MUELU_READ_PARAM(paramList,
"energy minimization: enable",
bool,
false, bEnergyMinimization);
179 MUELU_READ_PARAM(paramList,
"RAP: fix diagonal",
bool,
false, bFixDiagonal);
192 ParameterList paramListWithSubList;
194 paramList = paramListWithSubList;
197 bool setKokkosRefactor =
false;
198 bool useKokkosRefactor;
199# ifdef HAVE_MUELU_SERIAL
200 if (
typeid(
Node).name() ==
typeid(Kokkos::Compat::KokkosSerialWrapperNode).name())
201 useKokkosRefactor =
false;
203# ifdef HAVE_MUELU_OPENMP
204 if (
typeid(
Node).name() ==
typeid(Kokkos::Compat::KokkosOpenMPWrapperNode).name())
205 useKokkosRefactor =
true;
207# ifdef HAVE_MUELU_CUDA
208 if (
typeid(
Node).name() ==
typeid(Kokkos::Compat::KokkosCudaWrapperNode).name())
209 useKokkosRefactor =
true;
211# ifdef HAVE_MUELU_HIP
212 if (
typeid(
Node).name() ==
typeid(Kokkos::Compat::KokkosHIPWrapperNode).name())
213 useKokkosRefactor =
true;
215 if (paramList.isType<
bool>(
"use kokkos refactor")) {
216 useKokkosRefactor = paramList.get<
bool>(
"use kokkos refactor");
217 setKokkosRefactor =
true;
218 paramList.remove(
"use kokkos refactor");
226 bool validate = paramList.get(
"ML validate parameter list",
true);
229#if defined(HAVE_MUELU_ML) && defined(HAVE_MUELU_EPETRA)
231 int depth = paramList.get(
"ML validate depth", 5);
233 "ERROR: ML's Teuchos::ParameterList contains incorrect parameter!");
236 this->GetOStream(
Warnings0) <<
"Warning: MueLu_ENABLE_ML=OFF. The parameter list cannot be validated." << std::endl;
237 paramList.set(
"ML validate parameter list",
false);
245 blksize_ = nDofsPerNode;
251 if (verbosityLevel == 0) eVerbLevel =
None;
252 if (verbosityLevel >= 1) eVerbLevel =
Low;
253 if (verbosityLevel >= 5) eVerbLevel =
Medium;
254 if (verbosityLevel >= 10) eVerbLevel =
High;
255 if (verbosityLevel >= 11) eVerbLevel =
Extreme;
256 if (verbosityLevel >= 42) eVerbLevel =
Test;
258 this->verbosity_ = eVerbLevel;
262 "MueLu::MLParameterListInterpreter::SetParameterList(): parameter \"aggregation: type\": only 'Uncoupled' or 'Coupled' aggregation is supported.");
265 RCP<Factory> dropFact;
266 if(useKokkosRefactor)
272 dropFact->SetParameter(
"aggregation: drop scheme",Teuchos::ParameterEntry(std::string(
"distance laplacian")));
273 dropFact->SetParameter(
"aggregation: drop tol",Teuchos::ParameterEntry(agg_aux_thresh));
276 RCP<Factory> AggFact = Teuchos::null;
277 if (agg_type ==
"Uncoupled") {
279 RCP<Factory> MyUncoupledAggFact;
280 if(useKokkosRefactor) {
286 MyUncoupledAggFact->SetFactory(
"Graph", dropFact);
287 MyUncoupledAggFact->SetFactory(
"DofsPerNode", dropFact);
288 MyUncoupledAggFact->SetParameter(
"aggregation: preserve Dirichlet points", Teuchos::ParameterEntry(bKeepDirichletBcs));
289 MyUncoupledAggFact->SetParameter(
"aggregation: ordering", Teuchos::ParameterEntry(std::string(
"natural")));
290 MyUncoupledAggFact->SetParameter(
"aggregation: max selected neighbors", Teuchos::ParameterEntry(maxNbrAlreadySelected));
291 MyUncoupledAggFact->SetParameter(
"aggregation: min agg size", Teuchos::ParameterEntry(minPerAgg));
293 AggFact = MyUncoupledAggFact;
296 if(useKokkosRefactor) {
300 CoupledAggFact2->SetMinNodesPerAggregate(minPerAgg);
301 CoupledAggFact2->SetMaxNeighAlreadySelected(maxNbrAlreadySelected);
302 CoupledAggFact2->SetOrdering(
"natural");
303 CoupledAggFact2->SetPhase3AggCreation(0.5);
304 CoupledAggFact2->SetFactory(
"Graph", dropFact);
305 CoupledAggFact2->SetFactory(
"DofsPerNode", dropFact);
306 AggFact = CoupledAggFact2;
309 if (verbosityLevel > 3) {
310 std::ostringstream oss;
311 oss <<
"========================= Aggregate option summary =========================" << std::endl;
312 oss <<
"min Nodes per aggregate : " << minPerAgg << std::endl;
313 oss <<
"min # of root nbrs already aggregated : " << maxNbrAlreadySelected << std::endl;
314 oss <<
"aggregate ordering : natural" << std::endl;
315 oss <<
"=============================================================================" << std::endl;
316 this->GetOStream(
Runtime1) << oss.str();
321 RCP<Factory> PtentFact;
322 if(useKokkosRefactor)
326 if (agg_damping == 0.0 && bEnergyMinimization ==
false) {
330 }
else if (agg_damping != 0.0 && bEnergyMinimization ==
false) {
332 RCP<Factory> SaPFact;
333 if(useKokkosRefactor)
337 SaPFact->SetParameter(
"sa: damping factor", ParameterEntry(agg_damping));
340 }
else if (bEnergyMinimization ==
true) {
346 RCP<RAPFactory> AcFact = rcp(
new RAPFactory() );
347 AcFact->SetParameter(
"RepairMainDiagonal", Teuchos::ParameterEntry(bFixDiagonal));
348 for (
size_t i = 0; i<TransferFacts_.size(); i++) {
349 AcFact->AddTransferFactory(TransferFacts_[i]);
355#if defined(HAVE_MUELU_ISORROPIA) && defined(HAVE_MPI)
356 Teuchos::RCP<Factory> RebalancedPFact = Teuchos::null;
357 Teuchos::RCP<Factory> RebalancedRFact = Teuchos::null;
358 Teuchos::RCP<Factory> RepartitionFact = Teuchos::null;
359 Teuchos::RCP<RebalanceAcFactory> RebalancedAFact = Teuchos::null;
362 if (bDoRepartition == 1) {
365 RFact->SetFactory(
"P", PFact);
367 AcFact->SetFactory(
"P", PFact);
368 AcFact->SetFactory(
"R", RFact);
372 rebAmalgFact->SetFactory(
"A", AcFact);
374 MUELU_READ_PARAM(paramList,
"repartition: max min ratio",
double, 1.3, maxminratio);
375 MUELU_READ_PARAM(paramList,
"repartition: min per proc",
int, 512, minperproc);
380 Teuchos::ParameterList paramListRepFact;
381 paramListRepFact.set(
"repartition: min rows per proc", minperproc);
382 paramListRepFact.set(
"repartition: max imbalance", maxminratio);
383 RepartitionHeuristicFact->SetParameterList(paramListRepFact);
385 RepartitionHeuristicFact->SetFactory(
"A", AcFact);
389 isoInterface->SetFactory(
"A", AcFact);
390 isoInterface->SetFactory(
"number of partitions", RepartitionHeuristicFact);
391 isoInterface->SetFactory(
"UnAmalgamationInfo", rebAmalgFact);
395 repInterface->SetFactory(
"A", AcFact);
396 repInterface->SetFactory(
"number of partitions", RepartitionHeuristicFact);
397 repInterface->SetFactory(
"AmalgamatedPartition", isoInterface);
402 RepartitionFact->SetFactory(
"A", AcFact);
403 RepartitionFact->SetFactory(
"number of partitions", RepartitionHeuristicFact);
404 RepartitionFact->SetFactory(
"Partition", repInterface);
408 RebalancedPFact->SetParameter(
"type", Teuchos::ParameterEntry(std::string(
"Interpolation")));
409 RebalancedPFact->SetFactory(
"P", PFact);
410 RebalancedPFact->SetFactory(
"Nullspace", PtentFact);
411 RebalancedPFact->SetFactory(
"Importer", RepartitionFact);
414 RebalancedRFact->SetParameter(
"type", Teuchos::ParameterEntry(std::string(
"Restriction")));
415 RebalancedRFact->SetFactory(
"R", RFact);
416 RebalancedRFact->SetFactory(
"Importer", RepartitionFact);
420 RebalancedAFact->SetFactory(
"A", AcFact);
436 if (nullspaceType !=
"default vectors") {
437 TEUCHOS_TEST_FOR_EXCEPTION(nullspaceType !=
"pre-computed",
Exceptions::RuntimeError,
"MueLu::MLParameterListInterpreter: no valid nullspace (no pre-computed null space). error.");
438 TEUCHOS_TEST_FOR_EXCEPTION(nullspaceDim == -1,
Exceptions::RuntimeError,
"MueLu::MLParameterListInterpreter: no valid nullspace (nullspace dim == -1). error.");
439 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\'");
441 nullspaceDim_ = nullspaceDim;
442 nullspace_ = nullspaceVec;
445 Teuchos::RCP<NullspaceFactory> nspFact = Teuchos::rcp(
new NullspaceFactory(
"Nullspace"));
446 nspFact->SetFactory(
"Nullspace", PtentFact);
461 this->numDesiredLevel_ = maxLevels;
462 this->maxCoarseSize_ = maxCoarseSize;
467 ParameterList& coarseList = paramList.sublist(
"coarse: list");
469 if (!coarseList.isParameter(
"smoother: type"))
470 coarseList.set(
"smoother: type",
"Amesos-KLU");
471 RCP<SmootherFactory> coarseFact = GetSmootherFactory(coarseList, Teuchos::null);
482 for (
int levelID=0; levelID < maxLevels; levelID++) {
489 if (setKokkosRefactor)
490 manager->SetKokkosRefactor(useKokkosRefactor);
500 ParameterList levelSmootherParam =
GetMLSubList(paramList,
"smoother", levelID);
505 RCP<SmootherFactory> smootherFact = GetSmootherFactory(levelSmootherParam, Teuchos::null);
507 manager->SetFactory(
"Smoother", smootherFact);
514 manager->SetFactory(
"CoarseSolver", coarseFact);
515 manager->SetFactory(
"Graph", dropFact);
516 manager->SetFactory(
"Aggregates", AggFact);
517 manager->SetFactory(
"DofsPerNode", dropFact);
518 manager->SetFactory(
"Ptent", PtentFact);
520#if defined(HAVE_MUELU_ISORROPIA) && defined(HAVE_MPI)
521 if (bDoRepartition == 1) {
522 manager->SetFactory(
"A", RebalancedAFact);
523 manager->SetFactory(
"P", RebalancedPFact);
524 manager->SetFactory(
"R", RebalancedRFact);
525 manager->SetFactory(
"Nullspace", RebalancedPFact);
526 manager->SetFactory(
"Importer", RepartitionFact);
529 manager->SetFactory(
"Nullspace", nspFact);
530 manager->SetFactory(
"A", AcFact);
531 manager->SetFactory(
"P", PFact);
532 manager->SetFactory(
"R", RFact);
533#if defined(HAVE_MUELU_ISORROPIA) && defined(HAVE_MPI)
537 this->AddFactoryManager(levelID, 1, manager);
542 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
546 if (nullspace_ != NULL) {
547 RCP<Level> fineLevel = H.
GetLevel(0);
548 RCP<Operator> Op = fineLevel->Get<RCP<Operator> >(
"A");
549 RCP<Matrix> A = rcp_dynamic_cast<Matrix>(Op);
551 const RCP<const Map> rowMap = fineLevel->Get< RCP<Matrix> >(
"A")->getRowMap();
552 RCP<MultiVector> nullspace = MultiVectorFactory::Build(rowMap, nullspaceDim_,
true);
554 for (
size_t i=0; i < Teuchos::as<size_t>(nullspaceDim_); i++) {
555 Teuchos::ArrayRCP<Scalar> nullspacei = nullspace->getDataNonConst(i);
556 const size_t myLength = nullspace->getLocalLength();
558 for (
size_t j = 0; j < myLength; j++) {
559 nullspacei[j] = nullspace_[i*myLength + j];
563 fineLevel->Set(
"Nullspace", nullspace);
568 size_t num_coords = 0;
569 double * coordPTR[3];
571 coordPTR[0] = xcoord_;
574 coordPTR[1] = ycoord_;
577 coordPTR[2] = zcoord_;
583 Teuchos::RCP<Level> fineLevel = H.
GetLevel(0);
584 Teuchos::RCP<Operator> Op = fineLevel->Get<RCP<Operator> >(
"A");
585 Teuchos::RCP<Matrix> A = rcp_dynamic_cast<Matrix>(Op);
587 const Teuchos::RCP<const Map> rowMap = fineLevel->Get< RCP<Matrix> >(
"A")->getRowMap();
588 Teuchos::RCP<MultiVector> coordinates = MultiVectorFactory::Build(rowMap, num_coords,
true);
590 for (
size_t i=0; i < num_coords; i++) {
591 Teuchos::ArrayRCP<Scalar> coordsi = coordinates->getDataNonConst(i);
592 const size_t myLength = coordinates->getLocalLength();
593 for (
size_t j = 0; j < myLength; j++) {
594 coordsi[j] = coordPTR[i][j];
597 fineLevel->Set(
"Coordinates",coordinates);
605 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
606 RCP<MueLu::SmootherFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
609 const RCP<FactoryBase> & AFact)
611 typedef Teuchos::ScalarTraits<Scalar> STS;
614 std::string type =
"symmetric Gauss-Seidel";
636 if (paramList.isParameter(
"smoother: type")) type = paramList.get<std::string>(
"smoother: type");
637 TEUCHOS_TEST_FOR_EXCEPTION(type.empty(),
Exceptions::RuntimeError,
"MueLu::MLParameterListInterpreter: no \"smoother: type\" in the smoother parameter list" << std::endl << paramList);
643 RCP<SmootherPrototype> smooProto;
644 std::string ifpackType;
645 Teuchos::ParameterList smootherParamList;
647 if (type ==
"Jacobi" || type ==
"Gauss-Seidel" || type ==
"symmetric Gauss-Seidel") {
648 if (type ==
"symmetric Gauss-Seidel") type =
"Symmetric Gauss-Seidel";
650 ifpackType =
"RELAXATION";
651 smootherParamList.set(
"relaxation: type", type);
653 MUELU_COPY_PARAM(paramList,
"smoother: sweeps",
int, 2, smootherParamList,
"relaxation: sweeps");
654 MUELU_COPY_PARAM(paramList,
"smoother: damping factor",
Scalar, one, smootherParamList,
"relaxation: damping factor");
657 smooProto->SetFactory(
"A", AFact);
659 }
else if (type ==
"Chebyshev" || type ==
"MLS") {
661 ifpackType =
"CHEBYSHEV";
663 MUELU_COPY_PARAM(paramList,
"smoother: sweeps",
int, 2, smootherParamList,
"chebyshev: degree");
664 if (paramList.isParameter(
"smoother: MLS alpha")) {
665 MUELU_COPY_PARAM(paramList,
"smoother: MLS alpha",
double, 20, smootherParamList,
"chebyshev: ratio eigenvalue");
667 MUELU_COPY_PARAM(paramList,
"smoother: Chebyshev alpha",
double, 20, smootherParamList,
"chebyshev: ratio eigenvalue");
672 smooProto->SetFactory(
"A", AFact);
674 }
else if (type ==
"Hiptmair") {
675 ifpackType =
"HIPTMAIR";
676 std::string subSmootherType =
"Chebyshev";
677 if (paramList.isParameter(
"subsmoother: type"))
678 subSmootherType = paramList.get<std::string>(
"subsmoother: type");
679 std::string subSmootherIfpackType;
680 if (subSmootherType ==
"Chebyshev")
681 subSmootherIfpackType =
"CHEBYSHEV";
682 else if (subSmootherType ==
"Jacobi" || subSmootherType ==
"Gauss-Seidel" || subSmootherType ==
"symmetric Gauss-Seidel") {
683 if (subSmootherType ==
"symmetric Gauss-Seidel") subSmootherType =
"Symmetric Gauss-Seidel";
684 subSmootherIfpackType =
"RELAXATION";
686 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::MLParameterListInterpreter: unknown smoother type. '" << subSmootherType <<
"' not supported by MueLu.");
688 smootherParamList.set(
"hiptmair: smoother type 1", subSmootherIfpackType);
689 smootherParamList.set(
"hiptmair: smoother type 2", subSmootherIfpackType);
691 auto smoother1ParamList = smootherParamList.sublist(
"hiptmair: smoother list 1");
692 auto smoother2ParamList = smootherParamList.sublist(
"hiptmair: smoother list 2");
694 if (subSmootherType ==
"Chebyshev") {
695 MUELU_COPY_PARAM(paramList,
"subsmoother: edge sweeps",
int, 2, smoother1ParamList,
"chebyshev: degree");
696 MUELU_COPY_PARAM(paramList,
"subsmoother: node sweeps",
int, 2, smoother2ParamList,
"chebyshev: degree");
698 MUELU_COPY_PARAM(paramList,
"subsmoother: Chebyshev",
double, 20, smoother1ParamList,
"chebyshev: ratio eigenvalue");
699 MUELU_COPY_PARAM(paramList,
"subsmoother: Chebyshev",
double, 20, smoother2ParamList,
"chebyshev: ratio eigenvalue");
701 MUELU_COPY_PARAM(paramList,
"subsmoother: edge sweeps",
int, 2, smoother1ParamList,
"relaxation: sweeps");
702 MUELU_COPY_PARAM(paramList,
"subsmoother: node sweeps",
int, 2, smoother2ParamList,
"relaxation: sweeps");
704 MUELU_COPY_PARAM(paramList,
"subsmoother: SGS damping factor",
double, 0.8, smoother2ParamList,
"relaxation: damping factor");
709 smooProto->SetFactory(
"A", AFact);
711 }
else if (type ==
"IFPACK") {
713#if defined(HAVE_MUELU_EPETRA) && defined(HAVE_MUELU_IFPACK)
714 ifpackType = paramList.get<std::string>(
"smoother: ifpack type");
716 if (ifpackType ==
"ILU") {
719 if (paramList.isParameter(
"smoother: ifpack level-of-fill"))
720 smootherParamList.set(
"fact: level-of-fill", Teuchos::as<int>(paramList.get<
double>(
"smoother: ifpack level-of-fill")));
721 else smootherParamList.set(
"fact: level-of-fill", as<int>(0));
723 MUELU_COPY_PARAM(paramList,
"smoother: ifpack overlap",
int, 2, smootherParamList,
"partitioner: overlap");
727 MueLu::GetIfpackSmoother<Scalar, LocalOrdinal, GlobalOrdinal, Node> (ifpackType,
729 paramList.get<
int> (
"smoother: ifpack overlap"));
730 smooProto->SetFactory(
"A", AFact);
732 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::MLParameterListInterpreter: unknown ML smoother type " + type +
" (IFPACK) not supported by MueLu. Only ILU is supported.");
735 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::MLParameterListInterpreter: MueLu compiled without Ifpack support");
738 }
else if (type.length() > strlen(
"Amesos") && type.substr(0, strlen(
"Amesos")) ==
"Amesos") {
739 std::string solverType = type.substr(strlen(
"Amesos")+1);
743 const int validatorSize = 5;
744 std::string validator[validatorSize] = {
"Superlu",
"Superludist",
"KLU",
"UMFPACK",
"MUMPS"};
745 for (
int i=0; i < validatorSize; i++) {
if (validator[i] == solverType) valid =
true; }
746 TEUCHOS_TEST_FOR_EXCEPTION(!valid,
Exceptions::RuntimeError,
"MueLu::MLParameterListInterpreter: unknown smoother type. '" << type <<
"' not supported.");
749 std::transform(solverType.begin()+1, solverType.end(), solverType.begin()+1, ::tolower);
751 smooProto = Teuchos::rcp(
new DirectSolver(solverType, Teuchos::ParameterList()) );
752 smooProto->SetFactory(
"A", AFact);
756 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::MLParameterListInterpreter: unknown smoother type. '" << type <<
"' not supported by MueLu.");
759 TEUCHOS_TEST_FOR_EXCEPTION(smooProto == Teuchos::null,
Exceptions::RuntimeError,
"MueLu::MLParameterListInterpreter: no smoother prototype. fatal error.");
768 MUELU_READ_PARAM(paramList,
"smoother: pre or post", std::string,
"both", preOrPost);
769 if (preOrPost ==
"both") {
770 SmooFact->SetSmootherPrototypes(smooProto, smooProto);
771 }
else if (preOrPost ==
"pre") {
772 SmooFact->SetSmootherPrototypes(smooProto, Teuchos::null);
773 }
else if (preOrPost ==
"post") {
774 SmooFact->SetSmootherPrototypes(Teuchos::null, smooProto);
780 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
783 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!");
784 TransferFacts_.push_back(factory);
787 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
789 return TransferFacts_.size();
792 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
795 Matrix& A =
dynamic_cast<Matrix&
>(Op);
796 if (A.IsFixedBlockSizeSet() && (A.GetFixedBlockSize() != blksize_))
797 this->GetOStream(
Warnings0) <<
"Setting matrix block size to " << blksize_ <<
" (value of the parameter in the list) "
798 <<
"instead of " << A.GetFixedBlockSize() <<
" (provided matrix)." << std::endl;
800 A.SetFixedBlockSize(blksize_);
802#ifdef HAVE_MUELU_DEBUG
803 MatrixUtils::checkLocalRowMapMatchesColMap(A);
806 }
catch (std::bad_cast&) {
807 this->GetOStream(
Warnings0) <<
"Skipping setting block size as the operator is not a matrix" << std::endl;
813#define MUELU_MLPARAMETERLISTINTERPRETER_SHORT
#define MUELU_COPY_PARAM(paramList, paramStr, varType, defaultValue, outParamList, outParamStr)
#define MUELU_READ_PARAM(paramList, paramStr, varType, defaultValue, varName)
MueLu::DefaultScalar Scalar
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.
Factory for coarsening a graph with uncoupled aggregation.
Class that encapsulates direct solvers. Autoselection of AmesosSmoother or Amesos2Smoother according ...
Exception indicating invalid cast attempted.
Exception throws to report errors in the internal logical of the program.
This class specifies the default factory that should generate some data on a Level if the data does n...
Factory for building restriction operators using a prolongator factory.
virtual void SetupHierarchy(Hierarchy &H) const
Setup Hierarchy object.
Provides methods to build a multigrid hierarchy and apply multigrid cycles.
RCP< Level > & GetLevel(const int levelID=0)
Retrieve a certain level from hierarchy.
void AddTransferFactory(const RCP< FactoryBase > &factory)
Add transfer factory in the end of list of transfer factories for RAPFactory.
void SetParameterList(const Teuchos::ParameterList ¶mList)
static RCP< SmootherFactory > GetSmootherFactory(const Teuchos::ParameterList ¶mList, const RCP< FactoryBase > &AFact=Teuchos::null)
Read smoother options and build the corresponding smoother factory.
size_t NumTransferFactories() const
Returns number of transfer factories.
virtual void SetupHierarchy(Hierarchy &H) const
Setup Hierarchy object.
MLParameterListInterpreter()
Constructor.
virtual void SetupOperator(Operator &Op) const
Setup Operator object.
Factory for generating nullspace.
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.
Helper class which transforms an "AmalgamatedPartition" array to an unamalgamated "Partition".
Factory for building Smoothed Aggregation prolongators.
Factory for building Smoothed Aggregation prolongators.
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 building uncoupled aggregates.
Namespace for MueLu classes and methods.
Teuchos::RCP< Teuchos::ParameterList > ExtractSetOfParameters(const Teuchos::ParameterList ¶mList, const std::string &str)
@ Warnings0
Important warning messages (one line)
@ Runtime1
Description of what is happening (more verbose)
void CreateSublists(const ParameterList &List, ParameterList &newList)
void MergeParameterList(const Teuchos::ParameterList &source, Teuchos::ParameterList &dest, bool overWrite)
: merge two parameter lists
const Teuchos::ParameterList & GetMLSubList(const Teuchos::ParameterList ¶mList, const std::string &type, int levelID)