231 std::string factoryName;
232 Teuchos::ParameterList paramList;
233 if (!param.isList()) {
234 factoryName = Teuchos::getValue<std::string>(param);
236 paramList = Teuchos::getValue<Teuchos::ParameterList>(param);
237 factoryName = paramList.get<std::string>(
"factory");
250 if (factoryName ==
"CoarseMapFactory")
return Build2<CoarseMapFactory> (paramList, factoryMapIn, factoryManagersIn);
257 if (factoryName ==
"DirectSolver")
return BuildDirectSolver (paramList, factoryMapIn, factoryManagersIn);
259 if (factoryName ==
"EminPFactory")
return Build2<EminPFactory> (paramList, factoryMapIn, factoryManagersIn);
260 if (factoryName ==
"FilteredAFactory")
return Build2<FilteredAFactory> (paramList, factoryMapIn, factoryManagersIn);
264 if (factoryName ==
"GenericRFactory")
return Build2<GenericRFactory> (paramList, factoryMapIn, factoryManagersIn);
278 if (factoryName ==
"NoSmoother")
return rcp(
new SmootherFactory(Teuchos::null));
280 if (factoryName ==
"NullspaceFactory")
return Build2<NullspaceFactory> (paramList, factoryMapIn, factoryManagersIn);
282 if (factoryName ==
"PatternFactory")
return Build2<PatternFactory> (paramList, factoryMapIn, factoryManagersIn);
283 if (factoryName ==
"PgPFactory")
return Build2<PgPFactory> (paramList, factoryMapIn, factoryManagersIn);
284 if (factoryName ==
"SaPFactory")
return Build2<SaPFactory> (paramList, factoryMapIn, factoryManagersIn);
289 if (factoryName ==
"RegionRFactory")
return Build2<RegionRFactory> (paramList, factoryMapIn, factoryManagersIn);
298 if (factoryName ==
"SubBlockAFactory")
return Build2<SubBlockAFactory> (paramList, factoryMapIn, factoryManagersIn);
302 if (factoryName ==
"TransPFactory")
return Build2<TransPFactory> (paramList, factoryMapIn, factoryManagersIn);
303 if (factoryName ==
"RfromP_Or_TransP")
return Build2<RfromP_Or_TransP> (paramList, factoryMapIn, factoryManagersIn);
304 if (factoryName ==
"TrilinosSmoother")
return BuildTrilinosSmoother (paramList, factoryMapIn, factoryManagersIn);
306 if (factoryName ==
"UnsmooshFactory")
return Build2<UnsmooshFactory> (paramList, factoryMapIn, factoryManagersIn);
308 if (factoryName ==
"UserPFactory")
return Build2<UserPFactory> (paramList, factoryMapIn, factoryManagersIn);
324 if (factoryName ==
"ZoltanInterface") {
325#if defined(HAVE_MUELU_ZOLTAN) && defined(HAVE_MPI)
328 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a ZoltanInterface object: Zoltan is disabled: HAVE_MUELU_ZOLTAN && HAVE_MPI == false.");
331 if (factoryName ==
"Zoltan2Interface") {
332#if defined(HAVE_MUELU_ZOLTAN2) && defined(HAVE_MPI)
335 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a Zoltan2Interface object: Zoltan2 is disabled: HAVE_MUELU_ZOLTAN2 && HAVE_MPI == false.");
338 if (factoryName ==
"IsorropiaInterface") {
339#if defined(HAVE_MUELU_ISORROPIA) && defined(HAVE_MPI)
342 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a IsorropiaInterface object: Isorropia is disabled: HAVE_MUELU_ISORROPIA && HAVE_MPI == false.");
346 if (factoryName ==
"NodePartitionInterface") {
350 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a NodePartitionInterface object: HAVE_MPI == false.");
354 if (factoryName ==
"RepartitionFactory") {
358 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a RepartitionFactory object: HAVE_MPI == false.");
361 if (factoryName ==
"RepartitionHeuristicFactory") {
365 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a RepartitionHeuristicFactory object: HAVE_MPI == false.");
370 if (factoryName ==
"BlockedDirectSolver")
return BuildBlockedDirectSolver(paramList, factoryMapIn, factoryManagersIn);
384#ifdef HAVE_MUELU_TEKO
385 if (factoryName ==
"TekoSmoother")
return BuildTekoSmoother(paramList, factoryMapIn, factoryManagersIn);
390#ifdef HAVE_MUELU_MATLAB
393 if (factoryName ==
"MatlabSmoother")
return BuildMatlabSmoother (paramList, factoryMapIn, factoryManagersIn);
396#ifdef HAVE_MUELU_INTREPID2
401 if (factoryMapIn.find(factoryName) != factoryMapIn.end()) {
403 "MueLu::FactoryFactory: Error during the parsing of: " << std::endl << paramList << std::endl
404 <<
"'" << factoryName <<
"' is not a factory name but an existing instance of a factory." << std::endl
405 <<
"Extra parameters cannot be specified after the creation of the object." << std::endl << std::endl
406 <<
"Correct syntaxes includes:" << std::endl
407 <<
" <Parameter name=\"...\" type=\"string\" value=\"" << factoryName <<
"\"/>" << std::endl
409 <<
" <ParameterList name=\"...\"><Parameter name=\"factory\" type=\"string\" value=\"" << factoryName <<
"\"/></ParameterList>" << std::endl
412 return factoryMapIn.find(factoryName)->second;
415 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory: unknown factory name : " << factoryName);
417 TEUCHOS_UNREACHABLE_RETURN(Teuchos::null);
512 if (paramList.isSublist(
"TransferFactories") ==
false) {
514 factory =
Build2<T>(paramList, factoryMapIn, factoryManagersIn);
517 RCP<Teuchos::ParameterList> paramListNonConst = rcp(
new Teuchos::ParameterList(paramList));
518 RCP<const Teuchos::ParameterList> transferFactories = rcp(
new Teuchos::ParameterList(*sublist(paramListNonConst,
"TransferFactories")));
520 paramListNonConst->remove(
"TransferFactories");
523 factory =
Build2<T>(*paramListNonConst, factoryMapIn, factoryManagersIn);
527 int numProlongatorFactories = 0;
528 int numPtentFactories = 0;
529 int numCoarseNspFactories = 0;
530 for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
531 size_t foundNsp = transferFactories->name(param).find(
"Nullspace");
532 if (foundNsp != std::string::npos && foundNsp == 0 && transferFactories->name(param).length()==10) {
533 numCoarseNspFactories++;
536 size_t foundPtent = transferFactories->name(param).find(
"Ptent");
537 if (foundPtent != std::string::npos && foundPtent == 0 && transferFactories->name(param).length()==6) {
541 size_t foundP = transferFactories->name(param).find(
"P");
542 if (foundP != std::string::npos && foundP == 0 && transferFactories->name(param).length()==2) {
543 numProlongatorFactories++;
547 TEUCHOS_TEST_FOR_EXCEPTION(numProlongatorFactories!=numCoarseNspFactories,
Exceptions::RuntimeError,
"FactoryFactory::BuildToggleP: The user has to provide the same number of prolongator and coarse nullspace factories!");
548 TEUCHOS_TEST_FOR_EXCEPTION(numPtentFactories!=numCoarseNspFactories,
Exceptions::RuntimeError,
"FactoryFactory::BuildToggleP: The user has to provide the same number of ptent and coarse nullspace factories!");
549 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.");
552 std::vector<Teuchos::ParameterEntry> prolongatorFactoryNames(numProlongatorFactories);
553 std::vector<Teuchos::ParameterEntry> coarseNspFactoryNames(numProlongatorFactories);
554 std::vector<Teuchos::ParameterEntry> ptentFactoryNames(numProlongatorFactories);
556 for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
557 size_t foundNsp = transferFactories->name(param).find(
"Nullspace");
558 if (foundNsp != std::string::npos && foundNsp == 0 && transferFactories->name(param).length()==10) {
559 int number = atoi(&(transferFactories->name(param).at(9)));
560 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!");
561 coarseNspFactoryNames[number-1] = transferFactories->entry(param);
564 size_t foundPtent = transferFactories->name(param).find(
"Ptent");
565 if (foundPtent != std::string::npos && foundPtent == 0 && transferFactories->name(param).length()==6) {
566 int number = atoi(&(transferFactories->name(param).at(5)));
567 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!");
568 ptentFactoryNames[number-1] = transferFactories->entry(param);
571 size_t foundP = transferFactories->name(param).find(
"P");
572 if (foundP != std::string::npos && foundP == 0 && transferFactories->name(param).length()==2) {
573 int number = atoi(&(transferFactories->name(param).at(1)));
574 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!");
575 prolongatorFactoryNames[number-1] = transferFactories->entry(param);
581 for (std::vector<Teuchos::ParameterEntry>::const_iterator it = prolongatorFactoryNames.begin(); it != prolongatorFactoryNames.end(); ++it) {
582 RCP<const FactoryBase> p =
BuildFactory(*it, factoryMapIn, factoryManagersIn);
583 factory->AddProlongatorFactory(p);
587 for (std::vector<Teuchos::ParameterEntry>::const_iterator it = ptentFactoryNames.begin(); it != ptentFactoryNames.end(); ++it) {
588 RCP<const FactoryBase> p =
BuildFactory(*it, factoryMapIn, factoryManagersIn);
589 factory->AddPtentFactory(p);
593 for (std::vector<Teuchos::ParameterEntry>::const_iterator it = coarseNspFactoryNames.begin(); it != coarseNspFactoryNames.end(); ++it) {
594 RCP<const FactoryBase> p =
BuildFactory(*it, factoryMapIn, factoryManagersIn);
595 factory->AddCoarseNullspaceFactory(p);
602 RCP<ToggleCoordinatesTransferFactory> factory;
603 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!");
605 RCP<Teuchos::ParameterList> paramListNonConst = rcp(
new Teuchos::ParameterList(paramList));
606 RCP<const Teuchos::ParameterList> transferFactories = rcp(
new Teuchos::ParameterList(*sublist(paramListNonConst,
"TransferFactories")));
607 paramListNonConst->remove(
"TransferFactories");
614 int numCoordTransferFactories = 0;
615 for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
616 size_t foundCoordinates = transferFactories->name(param).find(
"Coordinates");
617 if (foundCoordinates != std::string::npos && foundCoordinates == 0 && transferFactories->name(param).length()==12) {
618 numCoordTransferFactories++;
622 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.");
625 std::vector<Teuchos::ParameterEntry> coarseCoordsFactoryNames(numCoordTransferFactories);
627 for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
628 size_t foundCoords = transferFactories->name(param).find(
"Coordinates");
629 if (foundCoords != std::string::npos && foundCoords == 0 && transferFactories->name(param).length()==12) {
630 int number = atoi(&(transferFactories->name(param).at(11)));
631 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!");
632 coarseCoordsFactoryNames[number-1] = transferFactories->entry(param);
638 for (std::vector<Teuchos::ParameterEntry>::const_iterator it = coarseCoordsFactoryNames.begin(); it != coarseCoordsFactoryNames.end(); ++it) {
639 RCP<const FactoryBase> p =
BuildFactory(*it, factoryMapIn, factoryManagersIn);
640 factory->AddCoordTransferFactory(p);