130 std::string factoryName;
131 Teuchos::ParameterList paramList;
132 if (!param.isList()) {
133 factoryName = Teuchos::getValue<std::string>(param);
135 paramList = Teuchos::getValue<Teuchos::ParameterList>(param);
136 factoryName = paramList.get<std::string>(
"factory");
155 if (factoryName ==
"DirectSolver")
return BuildDirectSolver(paramList, factoryMapIn, factoryManagersIn);
157 if (factoryName ==
"EminPFactory")
return Build2<EminPFactory>(paramList, factoryMapIn, factoryManagersIn);
162 if (factoryName ==
"CombinePFactory")
return Build2<CombinePFactory>(paramList, factoryMapIn, factoryManagersIn);
163 if (factoryName ==
"GenericRFactory")
return Build2<GenericRFactory>(paramList, factoryMapIn, factoryManagersIn);
177 if (factoryName ==
"NoSmoother")
return rcp(
new SmootherFactory(Teuchos::null));
181 if (factoryName ==
"PatternFactory")
return Build2<PatternFactory>(paramList, factoryMapIn, factoryManagersIn);
182 if (factoryName ==
"PgPFactory")
return Build2<PgPFactory>(paramList, factoryMapIn, factoryManagersIn);
183 if (factoryName ==
"SaPFactory")
return Build2<SaPFactory>(paramList, factoryMapIn, factoryManagersIn);
188 if (factoryName ==
"RegionRFactory")
return Build2<RegionRFactory>(paramList, factoryMapIn, factoryManagersIn);
197#ifdef HAVE_MUELU_EXPERIMENTAL
204 if (factoryName ==
"TransPFactory")
return Build2<TransPFactory>(paramList, factoryMapIn, factoryManagersIn);
206 if (factoryName ==
"TrilinosSmoother")
return BuildTrilinosSmoother(paramList, factoryMapIn, factoryManagersIn);
208 if (factoryName ==
"UnsmooshFactory")
return Build2<UnsmooshFactory>(paramList, factoryMapIn, factoryManagersIn);
210 if (factoryName ==
"UserPFactory")
return Build2<UserPFactory>(paramList, factoryMapIn, factoryManagersIn);
221 if (factoryName ==
"CoarseMapFactory_kokkos")
return Build2<CoarseMapFactory>(paramList, factoryMapIn, factoryManagersIn);
224 if (factoryName ==
"ZoltanInterface") {
225#if defined(HAVE_MUELU_ZOLTAN) && defined(HAVE_MPI)
228 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a ZoltanInterface object: Zoltan is disabled: HAVE_MUELU_ZOLTAN && HAVE_MPI == false.");
231 if (factoryName ==
"Zoltan2Interface") {
232#if defined(HAVE_MUELU_ZOLTAN2) && defined(HAVE_MPI)
235 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a Zoltan2Interface object: Zoltan2 is disabled: HAVE_MUELU_ZOLTAN2 && HAVE_MPI == false.");
239 if (factoryName ==
"NodePartitionInterface") {
243 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a NodePartitionInterface object: HAVE_MPI == false.");
247 if (factoryName ==
"RepartitionFactory") {
251 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a RepartitionFactory object: HAVE_MPI == false.");
254 if (factoryName ==
"RepartitionHeuristicFactory") {
258 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a RepartitionHeuristicFactory object: HAVE_MPI == false.");
263 if (factoryName ==
"BlockedDirectSolver")
return BuildBlockedDirectSolver(paramList, factoryMapIn, factoryManagersIn);
277#ifdef HAVE_MUELU_TEKO
278 if (factoryName ==
"TekoSmoother")
return BuildTekoSmoother(paramList, factoryMapIn, factoryManagersIn);
283#ifdef HAVE_MUELU_MATLAB
286 if (factoryName ==
"MatlabSmoother")
return BuildMatlabSmoother(paramList, factoryMapIn, factoryManagersIn);
289#if defined(HAVE_MUELU_INTREPID2) && defined(HAVE_MUELU_EXPERIMENTAL)
294 if (factoryMapIn.find(factoryName) != factoryMapIn.end()) {
296 "MueLu::FactoryFactory: Error during the parsing of: " << std::endl
297 << paramList << std::endl
298 <<
"'" << factoryName <<
"' is not a factory name but an existing instance of a factory." << std::endl
299 <<
"Extra parameters cannot be specified after the creation of the object." << std::endl
301 <<
"Correct syntaxes includes:" << std::endl
302 <<
" <Parameter name=\"...\" type=\"string\" value=\"" << factoryName <<
"\"/>" << std::endl
304 <<
" <ParameterList name=\"...\"><Parameter name=\"factory\" type=\"string\" value=\"" << factoryName <<
"\"/></ParameterList>" << std::endl);
306 return factoryMapIn.find(factoryName)->second;
309 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory: unknown factory name : " << factoryName);
311 TEUCHOS_UNREACHABLE_RETURN(Teuchos::null);
399 if (paramList.isSublist(
"TransferFactories") ==
false) {
401 factory =
Build2<T>(paramList, factoryMapIn, factoryManagersIn);
404 RCP<Teuchos::ParameterList> paramListNonConst = rcp(
new Teuchos::ParameterList(paramList));
405 RCP<const Teuchos::ParameterList> transferFactories = rcp(
new Teuchos::ParameterList(*sublist(paramListNonConst,
"TransferFactories")));
407 paramListNonConst->remove(
"TransferFactories");
410 factory =
Build2<T>(*paramListNonConst, factoryMapIn, factoryManagersIn);
414 int numProlongatorFactories = 0;
415 int numPtentFactories = 0;
416 int numCoarseNspFactories = 0;
417 for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
418 size_t foundNsp = transferFactories->name(param).find(
"Nullspace");
419 if (foundNsp != std::string::npos && foundNsp == 0 && transferFactories->name(param).length() == 10) {
420 numCoarseNspFactories++;
423 size_t foundPtent = transferFactories->name(param).find(
"Ptent");
424 if (foundPtent != std::string::npos && foundPtent == 0 && transferFactories->name(param).length() == 6) {
428 size_t foundP = transferFactories->name(param).find(
"P");
429 if (foundP != std::string::npos && foundP == 0 && transferFactories->name(param).length() == 2) {
430 numProlongatorFactories++;
434 TEUCHOS_TEST_FOR_EXCEPTION(numProlongatorFactories != numCoarseNspFactories,
Exceptions::RuntimeError,
"FactoryFactory::BuildToggleP: The user has to provide the same number of prolongator and coarse nullspace factories!");
435 TEUCHOS_TEST_FOR_EXCEPTION(numPtentFactories != numCoarseNspFactories,
Exceptions::RuntimeError,
"FactoryFactory::BuildToggleP: The user has to provide the same number of ptent and coarse nullspace factories!");
436 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.");
439 std::vector<Teuchos::ParameterEntry> prolongatorFactoryNames(numProlongatorFactories);
440 std::vector<Teuchos::ParameterEntry> coarseNspFactoryNames(numProlongatorFactories);
441 std::vector<Teuchos::ParameterEntry> ptentFactoryNames(numProlongatorFactories);
443 for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
444 size_t foundNsp = transferFactories->name(param).find(
"Nullspace");
445 if (foundNsp != std::string::npos && foundNsp == 0 && transferFactories->name(param).length() == 10) {
446 int number = atoi(&(transferFactories->name(param).at(9)));
447 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!");
448 coarseNspFactoryNames[number - 1] = transferFactories->entry(param);
451 size_t foundPtent = transferFactories->name(param).find(
"Ptent");
452 if (foundPtent != std::string::npos && foundPtent == 0 && transferFactories->name(param).length() == 6) {
453 int number = atoi(&(transferFactories->name(param).at(5)));
454 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!");
455 ptentFactoryNames[number - 1] = transferFactories->entry(param);
458 size_t foundP = transferFactories->name(param).find(
"P");
459 if (foundP != std::string::npos && foundP == 0 && transferFactories->name(param).length() == 2) {
460 int number = atoi(&(transferFactories->name(param).at(1)));
461 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!");
462 prolongatorFactoryNames[number - 1] = transferFactories->entry(param);
468 for (std::vector<Teuchos::ParameterEntry>::const_iterator it = prolongatorFactoryNames.begin(); it != prolongatorFactoryNames.end(); ++it) {
469 RCP<const FactoryBase> p =
BuildFactory(*it, factoryMapIn, factoryManagersIn);
470 factory->AddProlongatorFactory(p);
474 for (std::vector<Teuchos::ParameterEntry>::const_iterator it = ptentFactoryNames.begin(); it != ptentFactoryNames.end(); ++it) {
475 RCP<const FactoryBase> p =
BuildFactory(*it, factoryMapIn, factoryManagersIn);
476 factory->AddPtentFactory(p);
480 for (std::vector<Teuchos::ParameterEntry>::const_iterator it = coarseNspFactoryNames.begin(); it != coarseNspFactoryNames.end(); ++it) {
481 RCP<const FactoryBase> p =
BuildFactory(*it, factoryMapIn, factoryManagersIn);
482 factory->AddCoarseNullspaceFactory(p);
490 RCP<ToggleCoordinatesTransferFactory> factory;
491 TEUCHOS_TEST_FOR_EXCEPTION(paramList.isSublist(
"TransferFactories") ==
false,
Exceptions::RuntimeError,
"FactoryFactory::BuildToggleCoordinatesTransferFactory: the ToggleCoordinatesTransferFactory needs a sublist 'TransferFactories' containing information about the subfactories for coordinate transfer!");
493 RCP<Teuchos::ParameterList> paramListNonConst = rcp(
new Teuchos::ParameterList(paramList));
494 RCP<const Teuchos::ParameterList> transferFactories = rcp(
new Teuchos::ParameterList(*sublist(paramListNonConst,
"TransferFactories")));
495 paramListNonConst->remove(
"TransferFactories");
502 int numCoordTransferFactories = 0;
503 for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
504 size_t foundCoordinates = transferFactories->name(param).find(
"Coordinates");
505 if (foundCoordinates != std::string::npos && foundCoordinates == 0 && transferFactories->name(param).length() == 12) {
506 numCoordTransferFactories++;
510 TEUCHOS_TEST_FOR_EXCEPTION(numCoordTransferFactories != 2,
Exceptions::RuntimeError,
"FactoryFactory::BuildToggleCoordinatesTransfer: The ToggleCoordinatesTransferFactory needs two (different) coordinate transfer factories. The factories have to be provided using the names Coordinates%i, where %i denotes a number between 1 and 9.");
513 std::vector<Teuchos::ParameterEntry> coarseCoordsFactoryNames(numCoordTransferFactories);
515 for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
516 size_t foundCoords = transferFactories->name(param).find(
"Coordinates");
517 if (foundCoords != std::string::npos && foundCoords == 0 && transferFactories->name(param).length() == 12) {
518 int number = atoi(&(transferFactories->name(param).at(11)));
519 TEUCHOS_TEST_FOR_EXCEPTION(number < 1 || number > numCoordTransferFactories,
Exceptions::RuntimeError,
"FactoryFactory::BuildToggleCoordinatesTransfer: Please use the format Coordinates%i with %i an integer between 1 and the maximum number of coordinate transfer factories in ToggleCoordinatesTransferFactory!");
520 coarseCoordsFactoryNames[number - 1] = transferFactories->entry(param);
526 for (std::vector<Teuchos::ParameterEntry>::const_iterator it = coarseCoordsFactoryNames.begin(); it != coarseCoordsFactoryNames.end(); ++it) {
527 RCP<const FactoryBase> p =
BuildFactory(*it, factoryMapIn, factoryManagersIn);
528 factory->AddCoordTransferFactory(p);