131 std::string factoryName;
132 Teuchos::ParameterList paramList;
133 if (!param.isList()) {
134 factoryName = Teuchos::getValue<std::string>(param);
136 paramList = Teuchos::getValue<Teuchos::ParameterList>(param);
137 factoryName = paramList.get<std::string>(
"factory");
156 if (factoryName ==
"DirectSolver")
return BuildDirectSolver(paramList, factoryMapIn, factoryManagersIn);
158 if (factoryName ==
"EminPFactory")
return Build2<EminPFactory>(paramList, factoryMapIn, factoryManagersIn);
163 if (factoryName ==
"CombinePFactory")
return Build2<CombinePFactory>(paramList, factoryMapIn, factoryManagersIn);
164 if (factoryName ==
"GenericRFactory")
return Build2<GenericRFactory>(paramList, factoryMapIn, factoryManagersIn);
178 if (factoryName ==
"NoSmoother")
return rcp(
new SmootherFactory(Teuchos::null));
182 if (factoryName ==
"PatternFactory")
return Build2<PatternFactory>(paramList, factoryMapIn, factoryManagersIn);
183 if (factoryName ==
"PgPFactory")
return Build2<PgPFactory>(paramList, factoryMapIn, factoryManagersIn);
184 if (factoryName ==
"SaPFactory")
return Build2<SaPFactory>(paramList, factoryMapIn, factoryManagersIn);
189 if (factoryName ==
"RegionRFactory")
return Build2<RegionRFactory>(paramList, factoryMapIn, factoryManagersIn);
202 if (factoryName ==
"TransPFactory")
return Build2<TransPFactory>(paramList, factoryMapIn, factoryManagersIn);
204 if (factoryName ==
"TrilinosSmoother")
return BuildTrilinosSmoother(paramList, factoryMapIn, factoryManagersIn);
206 if (factoryName ==
"UnsmooshFactory")
return Build2<UnsmooshFactory>(paramList, factoryMapIn, factoryManagersIn);
208 if (factoryName ==
"UserPFactory")
return Build2<UserPFactory>(paramList, factoryMapIn, factoryManagersIn);
213#ifdef HAVE_MUELU_DEPRECATED_CODE
222 if (factoryName ==
"CoarseMapFactory_kokkos")
return Build2<CoarseMapFactory>(paramList, factoryMapIn, factoryManagersIn);
225 if (factoryName ==
"ZoltanInterface") {
226#if defined(HAVE_MUELU_ZOLTAN) && defined(HAVE_MPI)
229 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a ZoltanInterface object: Zoltan is disabled: HAVE_MUELU_ZOLTAN && HAVE_MPI == false.");
232 if (factoryName ==
"Zoltan2Interface") {
233#if defined(HAVE_MUELU_ZOLTAN2) && defined(HAVE_MPI)
236 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 ==
"IsorropiaInterface") {
240#if defined(HAVE_MUELU_ISORROPIA) && defined(HAVE_MPI)
243 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a IsorropiaInterface object: Isorropia is disabled: HAVE_MUELU_ISORROPIA && HAVE_MPI == false.");
247 if (factoryName ==
"NodePartitionInterface") {
251 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a NodePartitionInterface object: HAVE_MPI == false.");
255 if (factoryName ==
"RepartitionFactory") {
259 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a RepartitionFactory object: HAVE_MPI == false.");
262 if (factoryName ==
"RepartitionHeuristicFactory") {
266 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a RepartitionHeuristicFactory object: HAVE_MPI == false.");
271 if (factoryName ==
"BlockedDirectSolver")
return BuildBlockedDirectSolver(paramList, factoryMapIn, factoryManagersIn);
285#ifdef HAVE_MUELU_TEKO
286 if (factoryName ==
"TekoSmoother")
return BuildTekoSmoother(paramList, factoryMapIn, factoryManagersIn);
291#ifdef HAVE_MUELU_MATLAB
294 if (factoryName ==
"MatlabSmoother")
return BuildMatlabSmoother(paramList, factoryMapIn, factoryManagersIn);
297#ifdef HAVE_MUELU_INTREPID2
302 if (factoryMapIn.find(factoryName) != factoryMapIn.end()) {
304 "MueLu::FactoryFactory: Error during the parsing of: " << std::endl
305 << paramList << std::endl
306 <<
"'" << factoryName <<
"' is not a factory name but an existing instance of a factory." << std::endl
307 <<
"Extra parameters cannot be specified after the creation of the object." << std::endl
309 <<
"Correct syntaxes includes:" << std::endl
310 <<
" <Parameter name=\"...\" type=\"string\" value=\"" << factoryName <<
"\"/>" << std::endl
312 <<
" <ParameterList name=\"...\"><Parameter name=\"factory\" type=\"string\" value=\"" << factoryName <<
"\"/></ParameterList>" << std::endl);
314 return factoryMapIn.find(factoryName)->second;
317 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory: unknown factory name : " << factoryName);
319 TEUCHOS_UNREACHABLE_RETURN(Teuchos::null);
407 if (paramList.isSublist(
"TransferFactories") ==
false) {
409 factory =
Build2<T>(paramList, factoryMapIn, factoryManagersIn);
412 RCP<Teuchos::ParameterList> paramListNonConst = rcp(
new Teuchos::ParameterList(paramList));
413 RCP<const Teuchos::ParameterList> transferFactories = rcp(
new Teuchos::ParameterList(*sublist(paramListNonConst,
"TransferFactories")));
415 paramListNonConst->remove(
"TransferFactories");
418 factory =
Build2<T>(*paramListNonConst, factoryMapIn, factoryManagersIn);
422 int numProlongatorFactories = 0;
423 int numPtentFactories = 0;
424 int numCoarseNspFactories = 0;
425 for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
426 size_t foundNsp = transferFactories->name(param).find(
"Nullspace");
427 if (foundNsp != std::string::npos && foundNsp == 0 && transferFactories->name(param).length() == 10) {
428 numCoarseNspFactories++;
431 size_t foundPtent = transferFactories->name(param).find(
"Ptent");
432 if (foundPtent != std::string::npos && foundPtent == 0 && transferFactories->name(param).length() == 6) {
436 size_t foundP = transferFactories->name(param).find(
"P");
437 if (foundP != std::string::npos && foundP == 0 && transferFactories->name(param).length() == 2) {
438 numProlongatorFactories++;
442 TEUCHOS_TEST_FOR_EXCEPTION(numProlongatorFactories != numCoarseNspFactories,
Exceptions::RuntimeError,
"FactoryFactory::BuildToggleP: The user has to provide the same number of prolongator and coarse nullspace factories!");
443 TEUCHOS_TEST_FOR_EXCEPTION(numPtentFactories != numCoarseNspFactories,
Exceptions::RuntimeError,
"FactoryFactory::BuildToggleP: The user has to provide the same number of ptent and coarse nullspace factories!");
444 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.");
447 std::vector<Teuchos::ParameterEntry> prolongatorFactoryNames(numProlongatorFactories);
448 std::vector<Teuchos::ParameterEntry> coarseNspFactoryNames(numProlongatorFactories);
449 std::vector<Teuchos::ParameterEntry> ptentFactoryNames(numProlongatorFactories);
451 for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
452 size_t foundNsp = transferFactories->name(param).find(
"Nullspace");
453 if (foundNsp != std::string::npos && foundNsp == 0 && transferFactories->name(param).length() == 10) {
454 int number = atoi(&(transferFactories->name(param).at(9)));
455 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!");
456 coarseNspFactoryNames[number - 1] = transferFactories->entry(param);
459 size_t foundPtent = transferFactories->name(param).find(
"Ptent");
460 if (foundPtent != std::string::npos && foundPtent == 0 && transferFactories->name(param).length() == 6) {
461 int number = atoi(&(transferFactories->name(param).at(5)));
462 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!");
463 ptentFactoryNames[number - 1] = transferFactories->entry(param);
466 size_t foundP = transferFactories->name(param).find(
"P");
467 if (foundP != std::string::npos && foundP == 0 && transferFactories->name(param).length() == 2) {
468 int number = atoi(&(transferFactories->name(param).at(1)));
469 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!");
470 prolongatorFactoryNames[number - 1] = transferFactories->entry(param);
476 for (std::vector<Teuchos::ParameterEntry>::const_iterator it = prolongatorFactoryNames.begin(); it != prolongatorFactoryNames.end(); ++it) {
477 RCP<const FactoryBase> p =
BuildFactory(*it, factoryMapIn, factoryManagersIn);
478 factory->AddProlongatorFactory(p);
482 for (std::vector<Teuchos::ParameterEntry>::const_iterator it = ptentFactoryNames.begin(); it != ptentFactoryNames.end(); ++it) {
483 RCP<const FactoryBase> p =
BuildFactory(*it, factoryMapIn, factoryManagersIn);
484 factory->AddPtentFactory(p);
488 for (std::vector<Teuchos::ParameterEntry>::const_iterator it = coarseNspFactoryNames.begin(); it != coarseNspFactoryNames.end(); ++it) {
489 RCP<const FactoryBase> p =
BuildFactory(*it, factoryMapIn, factoryManagersIn);
490 factory->AddCoarseNullspaceFactory(p);
498 RCP<ToggleCoordinatesTransferFactory> factory;
499 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!");
501 RCP<Teuchos::ParameterList> paramListNonConst = rcp(
new Teuchos::ParameterList(paramList));
502 RCP<const Teuchos::ParameterList> transferFactories = rcp(
new Teuchos::ParameterList(*sublist(paramListNonConst,
"TransferFactories")));
503 paramListNonConst->remove(
"TransferFactories");
510 int numCoordTransferFactories = 0;
511 for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
512 size_t foundCoordinates = transferFactories->name(param).find(
"Coordinates");
513 if (foundCoordinates != std::string::npos && foundCoordinates == 0 && transferFactories->name(param).length() == 12) {
514 numCoordTransferFactories++;
518 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.");
521 std::vector<Teuchos::ParameterEntry> coarseCoordsFactoryNames(numCoordTransferFactories);
523 for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
524 size_t foundCoords = transferFactories->name(param).find(
"Coordinates");
525 if (foundCoords != std::string::npos && foundCoords == 0 && transferFactories->name(param).length() == 12) {
526 int number = atoi(&(transferFactories->name(param).at(11)));
527 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!");
528 coarseCoordsFactoryNames[number - 1] = transferFactories->entry(param);
534 for (std::vector<Teuchos::ParameterEntry>::const_iterator it = coarseCoordsFactoryNames.begin(); it != coarseCoordsFactoryNames.end(); ++it) {
535 RCP<const FactoryBase> p =
BuildFactory(*it, factoryMapIn, factoryManagersIn);
536 factory->AddCoordTransferFactory(p);