228 std::string factoryName;
229 Teuchos::ParameterList paramList;
230 if (!param.isList()) {
231 factoryName = Teuchos::getValue<std::string>(param);
233 paramList = Teuchos::getValue<Teuchos::ParameterList>(param);
234 factoryName = paramList.get<std::string>(
"factory");
247 if (factoryName ==
"CoarseMapFactory")
return Build2<CoarseMapFactory> (paramList, factoryMapIn, factoryManagersIn);
253 if (factoryName ==
"DirectSolver")
return BuildDirectSolver (paramList, factoryMapIn, factoryManagersIn);
255 if (factoryName ==
"EminPFactory")
return Build2<EminPFactory> (paramList, factoryMapIn, factoryManagersIn);
256 if (factoryName ==
"FilteredAFactory")
return Build2<FilteredAFactory> (paramList, factoryMapIn, factoryManagersIn);
260 if (factoryName ==
"CombinePFactory")
return Build2<CombinePFactory> (paramList, factoryMapIn, factoryManagersIn);
261 if (factoryName ==
"GenericRFactory")
return Build2<GenericRFactory> (paramList, factoryMapIn, factoryManagersIn);
275 if (factoryName ==
"NoSmoother")
return rcp(
new SmootherFactory(Teuchos::null));
277 if (factoryName ==
"NullspaceFactory")
return Build2<NullspaceFactory> (paramList, factoryMapIn, factoryManagersIn);
279 if (factoryName ==
"PatternFactory")
return Build2<PatternFactory> (paramList, factoryMapIn, factoryManagersIn);
280 if (factoryName ==
"PgPFactory")
return Build2<PgPFactory> (paramList, factoryMapIn, factoryManagersIn);
281 if (factoryName ==
"SaPFactory")
return Build2<SaPFactory> (paramList, factoryMapIn, factoryManagersIn);
286 if (factoryName ==
"RegionRFactory")
return Build2<RegionRFactory> (paramList, factoryMapIn, factoryManagersIn);
295 if (factoryName ==
"SubBlockAFactory")
return Build2<SubBlockAFactory> (paramList, factoryMapIn, factoryManagersIn);
299 if (factoryName ==
"TransPFactory")
return Build2<TransPFactory> (paramList, factoryMapIn, factoryManagersIn);
300 if (factoryName ==
"RfromP_Or_TransP")
return Build2<RfromP_Or_TransP> (paramList, factoryMapIn, factoryManagersIn);
301 if (factoryName ==
"TrilinosSmoother")
return BuildTrilinosSmoother (paramList, factoryMapIn, factoryManagersIn);
303 if (factoryName ==
"UnsmooshFactory")
return Build2<UnsmooshFactory> (paramList, factoryMapIn, factoryManagersIn);
305 if (factoryName ==
"UserPFactory")
return Build2<UserPFactory> (paramList, factoryMapIn, factoryManagersIn);
319 if (factoryName ==
"CoarseMapFactory_kokkos")
return Build2<CoarseMapFactory> (paramList, factoryMapIn, factoryManagersIn);
322 if (factoryName ==
"ZoltanInterface") {
323#if defined(HAVE_MUELU_ZOLTAN) && defined(HAVE_MPI)
326 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a ZoltanInterface object: Zoltan is disabled: HAVE_MUELU_ZOLTAN && HAVE_MPI == false.");
329 if (factoryName ==
"Zoltan2Interface") {
330#if defined(HAVE_MUELU_ZOLTAN2) && defined(HAVE_MPI)
333 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a Zoltan2Interface object: Zoltan2 is disabled: HAVE_MUELU_ZOLTAN2 && HAVE_MPI == false.");
336 if (factoryName ==
"IsorropiaInterface") {
337#if defined(HAVE_MUELU_ISORROPIA) && defined(HAVE_MPI)
340 TEUCHOS_TEST_FOR_EXCEPTION(
true, Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a IsorropiaInterface object: Isorropia is disabled: HAVE_MUELU_ISORROPIA && HAVE_MPI == false.");
344 if (factoryName ==
"NodePartitionInterface") {
348 TEUCHOS_TEST_FOR_EXCEPTION(
true, Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a NodePartitionInterface object: HAVE_MPI == false.");
352 if (factoryName ==
"RepartitionFactory") {
356 TEUCHOS_TEST_FOR_EXCEPTION(
true, Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a RepartitionFactory object: HAVE_MPI == false.");
359 if (factoryName ==
"RepartitionHeuristicFactory") {
363 TEUCHOS_TEST_FOR_EXCEPTION(
true, Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a RepartitionHeuristicFactory object: HAVE_MPI == false.");
368 if (factoryName ==
"BlockedDirectSolver")
return BuildBlockedDirectSolver(paramList, factoryMapIn, factoryManagersIn);
382#ifdef HAVE_MUELU_TEKO
383 if (factoryName ==
"TekoSmoother")
return BuildTekoSmoother(paramList, factoryMapIn, factoryManagersIn);
388#ifdef HAVE_MUELU_MATLAB
391 if (factoryName ==
"MatlabSmoother")
return BuildMatlabSmoother (paramList, factoryMapIn, factoryManagersIn);
394#ifdef HAVE_MUELU_INTREPID2
399 if (factoryMapIn.find(factoryName) != factoryMapIn.end()) {
400 TEUCHOS_TEST_FOR_EXCEPTION((param.isList() && (++paramList.begin() != paramList.end())), Exceptions::RuntimeError,
401 "MueLu::FactoryFactory: Error during the parsing of: " << std::endl << paramList << std::endl
402 <<
"'" << factoryName <<
"' is not a factory name but an existing instance of a factory." << std::endl
403 <<
"Extra parameters cannot be specified after the creation of the object." << std::endl << std::endl
404 <<
"Correct syntaxes includes:" << std::endl
405 <<
" <Parameter name=\"...\" type=\"string\" value=\"" << factoryName <<
"\"/>" << std::endl
407 <<
" <ParameterList name=\"...\"><Parameter name=\"factory\" type=\"string\" value=\"" << factoryName <<
"\"/></ParameterList>" << std::endl
410 return factoryMapIn.find(factoryName)->second;
413 TEUCHOS_TEST_FOR_EXCEPTION(
true, Exceptions::RuntimeError,
"MueLu::FactoryFactory: unknown factory name : " << factoryName);
415 TEUCHOS_UNREACHABLE_RETURN(Teuchos::null);
510 if (paramList.isSublist(
"TransferFactories") ==
false) {
512 factory =
Build2<T>(paramList, factoryMapIn, factoryManagersIn);
515 RCP<Teuchos::ParameterList> paramListNonConst = rcp(
new Teuchos::ParameterList(paramList));
516 RCP<const Teuchos::ParameterList> transferFactories = rcp(
new Teuchos::ParameterList(*sublist(paramListNonConst,
"TransferFactories")));
518 paramListNonConst->remove(
"TransferFactories");
521 factory =
Build2<T>(*paramListNonConst, factoryMapIn, factoryManagersIn);
525 int numProlongatorFactories = 0;
526 int numPtentFactories = 0;
527 int numCoarseNspFactories = 0;
528 for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
529 size_t foundNsp = transferFactories->name(param).find(
"Nullspace");
530 if (foundNsp != std::string::npos && foundNsp == 0 && transferFactories->name(param).length()==10) {
531 numCoarseNspFactories++;
534 size_t foundPtent = transferFactories->name(param).find(
"Ptent");
535 if (foundPtent != std::string::npos && foundPtent == 0 && transferFactories->name(param).length()==6) {
539 size_t foundP = transferFactories->name(param).find(
"P");
540 if (foundP != std::string::npos && foundP == 0 && transferFactories->name(param).length()==2) {
541 numProlongatorFactories++;
545 TEUCHOS_TEST_FOR_EXCEPTION(numProlongatorFactories!=numCoarseNspFactories,
Exceptions::RuntimeError,
"FactoryFactory::BuildToggleP: The user has to provide the same number of prolongator and coarse nullspace factories!");
546 TEUCHOS_TEST_FOR_EXCEPTION(numPtentFactories!=numCoarseNspFactories,
Exceptions::RuntimeError,
"FactoryFactory::BuildToggleP: The user has to provide the same number of ptent and coarse nullspace factories!");
547 TEUCHOS_TEST_FOR_EXCEPTION(numProlongatorFactories < 2,
Exceptions::RuntimeError,
"FactoryFactory::BuildToggleP: The TogglePFactory needs at least two different prolongation operators. The factories have to be provided using the names P%i and Nullspace %i, where %i denotes a number between 1 and 9.");
550 std::vector<Teuchos::ParameterEntry> prolongatorFactoryNames(numProlongatorFactories);
551 std::vector<Teuchos::ParameterEntry> coarseNspFactoryNames(numProlongatorFactories);
552 std::vector<Teuchos::ParameterEntry> ptentFactoryNames(numProlongatorFactories);
554 for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
555 size_t foundNsp = transferFactories->name(param).find(
"Nullspace");
556 if (foundNsp != std::string::npos && foundNsp == 0 && transferFactories->name(param).length()==10) {
557 int number = atoi(&(transferFactories->name(param).at(9)));
558 TEUCHOS_TEST_FOR_EXCEPTION(number < 1 || number > numProlongatorFactories,
Exceptions::RuntimeError,
"FactoryFactory::BuildToggleP: Please use the format Nullspace%i with %i an integer between 1 and the maximum number of prolongation operators in TogglePFactory!");
559 coarseNspFactoryNames[number-1] = transferFactories->entry(param);
562 size_t foundPtent = transferFactories->name(param).find(
"Ptent");
563 if (foundPtent != std::string::npos && foundPtent == 0 && transferFactories->name(param).length()==6) {
564 int number = atoi(&(transferFactories->name(param).at(5)));
565 TEUCHOS_TEST_FOR_EXCEPTION(number < 1 || number > numPtentFactories,
Exceptions::RuntimeError,
"FactoryFactory::BuildToggleP: Please use the format Ptent%i with %i an integer between 1 and the maximum number of prolongation operators in TogglePFactory!");
566 ptentFactoryNames[number-1] = transferFactories->entry(param);
569 size_t foundP = transferFactories->name(param).find(
"P");
570 if (foundP != std::string::npos && foundP == 0 && transferFactories->name(param).length()==2) {
571 int number = atoi(&(transferFactories->name(param).at(1)));
572 TEUCHOS_TEST_FOR_EXCEPTION(number < 1 || number > numProlongatorFactories,
Exceptions::RuntimeError,
"FactoryFactory::BuildToggleP: Please use the format P%i with %i an integer between 1 and the maximum number of prolongation operators in TogglePFactory!");
573 prolongatorFactoryNames[number-1] = transferFactories->entry(param);
579 for (std::vector<Teuchos::ParameterEntry>::const_iterator it = prolongatorFactoryNames.begin(); it != prolongatorFactoryNames.end(); ++it) {
580 RCP<const FactoryBase> p =
BuildFactory(*it, factoryMapIn, factoryManagersIn);
581 factory->AddProlongatorFactory(p);
585 for (std::vector<Teuchos::ParameterEntry>::const_iterator it = ptentFactoryNames.begin(); it != ptentFactoryNames.end(); ++it) {
586 RCP<const FactoryBase> p =
BuildFactory(*it, factoryMapIn, factoryManagersIn);
587 factory->AddPtentFactory(p);
591 for (std::vector<Teuchos::ParameterEntry>::const_iterator it = coarseNspFactoryNames.begin(); it != coarseNspFactoryNames.end(); ++it) {
592 RCP<const FactoryBase> p =
BuildFactory(*it, factoryMapIn, factoryManagersIn);
593 factory->AddCoarseNullspaceFactory(p);