128 std::string factoryName;
129 Teuchos::ParameterList paramList;
130 if (!param.isList()) {
131 factoryName = Teuchos::getValue<std::string>(param);
133 paramList = Teuchos::getValue<Teuchos::ParameterList>(param);
134 factoryName = paramList.get<std::string>(
"factory");
153 if (factoryName ==
"DirectSolver")
return BuildDirectSolver(paramList, factoryMapIn, factoryManagersIn);
155 if (factoryName ==
"EminPFactory")
return Build2<EminPFactory>(paramList, factoryMapIn, factoryManagersIn);
160 if (factoryName ==
"CombinePFactory")
return Build2<CombinePFactory>(paramList, factoryMapIn, factoryManagersIn);
161 if (factoryName ==
"GenericRFactory")
return Build2<GenericRFactory>(paramList, factoryMapIn, factoryManagersIn);
175 if (factoryName ==
"NoSmoother")
return rcp(
new SmootherFactory(Teuchos::null));
179 if (factoryName ==
"PatternFactory")
return Build2<PatternFactory>(paramList, factoryMapIn, factoryManagersIn);
180 if (factoryName ==
"PgPFactory")
return Build2<PgPFactory>(paramList, factoryMapIn, factoryManagersIn);
181 if (factoryName ==
"SaPFactory")
return Build2<SaPFactory>(paramList, factoryMapIn, factoryManagersIn);
186 if (factoryName ==
"RegionRFactory")
return Build2<RegionRFactory>(paramList, factoryMapIn, factoryManagersIn);
199 if (factoryName ==
"TransPFactory")
return Build2<TransPFactory>(paramList, factoryMapIn, factoryManagersIn);
201 if (factoryName ==
"TrilinosSmoother")
return BuildTrilinosSmoother(paramList, factoryMapIn, factoryManagersIn);
203 if (factoryName ==
"UnsmooshFactory")
return Build2<UnsmooshFactory>(paramList, factoryMapIn, factoryManagersIn);
205 if (factoryName ==
"UserPFactory")
return Build2<UserPFactory>(paramList, factoryMapIn, factoryManagersIn);
216 if (factoryName ==
"CoarseMapFactory_kokkos")
return Build2<CoarseMapFactory>(paramList, factoryMapIn, factoryManagersIn);
219 if (factoryName ==
"ZoltanInterface") {
220#if defined(HAVE_MUELU_ZOLTAN) && defined(HAVE_MPI)
223 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a ZoltanInterface object: Zoltan is disabled: HAVE_MUELU_ZOLTAN && HAVE_MPI == false.");
226 if (factoryName ==
"Zoltan2Interface") {
227#if defined(HAVE_MUELU_ZOLTAN2) && defined(HAVE_MPI)
230 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a Zoltan2Interface object: Zoltan2 is disabled: HAVE_MUELU_ZOLTAN2 && HAVE_MPI == false.");
233 if (factoryName ==
"IsorropiaInterface") {
234 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a IsorropiaInterface object: Isorropia is disabled: HAVE_MUELU_ISORROPIA && HAVE_MPI == false.");
237 if (factoryName ==
"NodePartitionInterface") {
241 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a NodePartitionInterface object: HAVE_MPI == false.");
245 if (factoryName ==
"RepartitionFactory") {
249 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a RepartitionFactory object: HAVE_MPI == false.");
252 if (factoryName ==
"RepartitionHeuristicFactory") {
256 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a RepartitionHeuristicFactory object: HAVE_MPI == false.");
261 if (factoryName ==
"BlockedDirectSolver")
return BuildBlockedDirectSolver(paramList, factoryMapIn, factoryManagersIn);
275#ifdef HAVE_MUELU_TEKO
276 if (factoryName ==
"TekoSmoother")
return BuildTekoSmoother(paramList, factoryMapIn, factoryManagersIn);
281#ifdef HAVE_MUELU_MATLAB
284 if (factoryName ==
"MatlabSmoother")
return BuildMatlabSmoother(paramList, factoryMapIn, factoryManagersIn);
287#ifdef HAVE_MUELU_INTREPID2
292 if (factoryMapIn.find(factoryName) != factoryMapIn.end()) {
294 "MueLu::FactoryFactory: Error during the parsing of: " << std::endl
295 << paramList << std::endl
296 <<
"'" << factoryName <<
"' is not a factory name but an existing instance of a factory." << std::endl
297 <<
"Extra parameters cannot be specified after the creation of the object." << std::endl
299 <<
"Correct syntaxes includes:" << std::endl
300 <<
" <Parameter name=\"...\" type=\"string\" value=\"" << factoryName <<
"\"/>" << std::endl
302 <<
" <ParameterList name=\"...\"><Parameter name=\"factory\" type=\"string\" value=\"" << factoryName <<
"\"/></ParameterList>" << std::endl);
304 return factoryMapIn.find(factoryName)->second;
307 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory: unknown factory name : " << factoryName);
309 TEUCHOS_UNREACHABLE_RETURN(Teuchos::null);
397 if (paramList.isSublist(
"TransferFactories") ==
false) {
399 factory =
Build2<T>(paramList, factoryMapIn, factoryManagersIn);
402 RCP<Teuchos::ParameterList> paramListNonConst = rcp(
new Teuchos::ParameterList(paramList));
403 RCP<const Teuchos::ParameterList> transferFactories = rcp(
new Teuchos::ParameterList(*sublist(paramListNonConst,
"TransferFactories")));
405 paramListNonConst->remove(
"TransferFactories");
408 factory =
Build2<T>(*paramListNonConst, factoryMapIn, factoryManagersIn);
412 int numProlongatorFactories = 0;
413 int numPtentFactories = 0;
414 int numCoarseNspFactories = 0;
415 for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
416 size_t foundNsp = transferFactories->name(param).find(
"Nullspace");
417 if (foundNsp != std::string::npos && foundNsp == 0 && transferFactories->name(param).length() == 10) {
418 numCoarseNspFactories++;
421 size_t foundPtent = transferFactories->name(param).find(
"Ptent");
422 if (foundPtent != std::string::npos && foundPtent == 0 && transferFactories->name(param).length() == 6) {
426 size_t foundP = transferFactories->name(param).find(
"P");
427 if (foundP != std::string::npos && foundP == 0 && transferFactories->name(param).length() == 2) {
428 numProlongatorFactories++;
432 TEUCHOS_TEST_FOR_EXCEPTION(numProlongatorFactories != numCoarseNspFactories,
Exceptions::RuntimeError,
"FactoryFactory::BuildToggleP: The user has to provide the same number of prolongator and coarse nullspace factories!");
433 TEUCHOS_TEST_FOR_EXCEPTION(numPtentFactories != numCoarseNspFactories,
Exceptions::RuntimeError,
"FactoryFactory::BuildToggleP: The user has to provide the same number of ptent and coarse nullspace factories!");
434 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.");
437 std::vector<Teuchos::ParameterEntry> prolongatorFactoryNames(numProlongatorFactories);
438 std::vector<Teuchos::ParameterEntry> coarseNspFactoryNames(numProlongatorFactories);
439 std::vector<Teuchos::ParameterEntry> ptentFactoryNames(numProlongatorFactories);
441 for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
442 size_t foundNsp = transferFactories->name(param).find(
"Nullspace");
443 if (foundNsp != std::string::npos && foundNsp == 0 && transferFactories->name(param).length() == 10) {
444 int number = atoi(&(transferFactories->name(param).at(9)));
445 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!");
446 coarseNspFactoryNames[number - 1] = transferFactories->entry(param);
449 size_t foundPtent = transferFactories->name(param).find(
"Ptent");
450 if (foundPtent != std::string::npos && foundPtent == 0 && transferFactories->name(param).length() == 6) {
451 int number = atoi(&(transferFactories->name(param).at(5)));
452 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!");
453 ptentFactoryNames[number - 1] = transferFactories->entry(param);
456 size_t foundP = transferFactories->name(param).find(
"P");
457 if (foundP != std::string::npos && foundP == 0 && transferFactories->name(param).length() == 2) {
458 int number = atoi(&(transferFactories->name(param).at(1)));
459 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!");
460 prolongatorFactoryNames[number - 1] = transferFactories->entry(param);
466 for (std::vector<Teuchos::ParameterEntry>::const_iterator it = prolongatorFactoryNames.begin(); it != prolongatorFactoryNames.end(); ++it) {
467 RCP<const FactoryBase> p =
BuildFactory(*it, factoryMapIn, factoryManagersIn);
468 factory->AddProlongatorFactory(p);
472 for (std::vector<Teuchos::ParameterEntry>::const_iterator it = ptentFactoryNames.begin(); it != ptentFactoryNames.end(); ++it) {
473 RCP<const FactoryBase> p =
BuildFactory(*it, factoryMapIn, factoryManagersIn);
474 factory->AddPtentFactory(p);
478 for (std::vector<Teuchos::ParameterEntry>::const_iterator it = coarseNspFactoryNames.begin(); it != coarseNspFactoryNames.end(); ++it) {
479 RCP<const FactoryBase> p =
BuildFactory(*it, factoryMapIn, factoryManagersIn);
480 factory->AddCoarseNullspaceFactory(p);
488 RCP<ToggleCoordinatesTransferFactory> factory;
489 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!");
491 RCP<Teuchos::ParameterList> paramListNonConst = rcp(
new Teuchos::ParameterList(paramList));
492 RCP<const Teuchos::ParameterList> transferFactories = rcp(
new Teuchos::ParameterList(*sublist(paramListNonConst,
"TransferFactories")));
493 paramListNonConst->remove(
"TransferFactories");
500 int numCoordTransferFactories = 0;
501 for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
502 size_t foundCoordinates = transferFactories->name(param).find(
"Coordinates");
503 if (foundCoordinates != std::string::npos && foundCoordinates == 0 && transferFactories->name(param).length() == 12) {
504 numCoordTransferFactories++;
508 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.");
511 std::vector<Teuchos::ParameterEntry> coarseCoordsFactoryNames(numCoordTransferFactories);
513 for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
514 size_t foundCoords = transferFactories->name(param).find(
"Coordinates");
515 if (foundCoords != std::string::npos && foundCoords == 0 && transferFactories->name(param).length() == 12) {
516 int number = atoi(&(transferFactories->name(param).at(11)));
517 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!");
518 coarseCoordsFactoryNames[number - 1] = transferFactories->entry(param);
524 for (std::vector<Teuchos::ParameterEntry>::const_iterator it = coarseCoordsFactoryNames.begin(); it != coarseCoordsFactoryNames.end(); ++it) {
525 RCP<const FactoryBase> p =
BuildFactory(*it, factoryMapIn, factoryManagersIn);
526 factory->AddCoordTransferFactory(p);