46 #ifndef MUELU_FACTORYFACTORY_DECL_HPP 47 #define MUELU_FACTORYFACTORY_DECL_HPP 52 #include <Teuchos_ParameterEntry.hpp> 53 #include <Teuchos_Array.hpp> 61 #include "MueLu_FactoryManager.hpp" 70 #include "MueLu_AggregationExportFactory.hpp" 71 #include "MueLu_AmalgamationFactory.hpp" 72 #ifdef HAVE_MUELU_EXPERIMENTAL 73 #include "MueLu_BlockedCoarseMapFactory.hpp" 74 #include "MueLu_BlockedDirectSolver.hpp" 75 #include "MueLu_BlockedGaussSeidelSmoother.hpp" 76 #include "MueLu_BlockedPFactory.hpp" 77 #include "MueLu_BlockedRAPFactory.hpp" 78 #include "MueLu_BraessSarazinSmoother.hpp" 80 #include "MueLu_BrickAggregationFactory.hpp" 81 #include "MueLu_CloneRepartitionInterface.hpp" 82 #include "MueLu_CoalesceDropFactory.hpp" 83 #include "MueLu_CoarseMapFactory.hpp" 84 #include "MueLu_CoarseningVisualizationFactory.hpp" 85 #include "MueLu_ConstraintFactory.hpp" 86 #include "MueLu_CoupledAggregationFactory.hpp" 87 #include "MueLu_CoordinatesTransferFactory.hpp" 88 #include "MueLu_DirectSolver.hpp" 89 #include "MueLu_DropNegativeEntriesFactory.hpp" 90 #include "MueLu_EminPFactory.hpp" 91 #include "MueLu_FilteredAFactory.hpp" 92 #include "MueLu_FineLevelInputDataFactory.hpp" 93 #include "MueLu_GeneralGeometricPFactory.hpp" 94 #include "MueLu_GenericRFactory.hpp" 95 #ifdef HAVE_MUELU_EXPERIMENTAL 96 #include "MueLu_IndefBlockedDiagonalSmoother.hpp" 98 #include "MueLu_IsorropiaInterface.hpp" 99 #include "MueLu_LineDetectionFactory.hpp" 100 #include "MueLu_RepartitionInterface.hpp" 101 #include "MueLu_MapTransferFactory.hpp" 102 #include "MueLu_MatrixAnalysisFactory.hpp" 103 #include "MueLu_MultiVectorTransferFactory.hpp" 104 #include "MueLu_NullspaceFactory.hpp" 105 #include "MueLu_NullspacePresmoothFactory.hpp" 106 #include "MueLu_PatternFactory.hpp" 107 #include "MueLu_PgPFactory.hpp" 108 #ifdef HAVE_MUELU_EXPERIMENTAL 109 #include "MueLu_RebalanceBlockInterpolationFactory.hpp" 110 #include "MueLu_RebalanceBlockRestrictionFactory.hpp" 111 #include "MueLu_RebalanceBlockAcFactory.hpp" 113 #include "MueLu_RebalanceTransferFactory.hpp" 114 #include "MueLu_RepartitionFactory.hpp" 115 #include "MueLu_RepartitionHeuristicFactory.hpp" 116 #include "MueLu_RAPFactory.hpp" 117 #include "MueLu_RebalanceAcFactory.hpp" 118 #include "MueLu_ReorderBlockAFactory.hpp" 119 #include "MueLu_SaPFactory.hpp" 120 #include "MueLu_SegregatedAFactory.hpp" 121 #include "MueLu_SemiCoarsenPFactory.hpp" 122 #ifdef HAVE_MUELU_EXPERIMENTAL 123 #include "MueLu_SchurComplementFactory.hpp" 124 #include "MueLu_SimpleSmoother.hpp" 126 #include "MueLu_SmootherFactory.hpp" 127 #include "MueLu_StructuredLineDetectionFactory.hpp" 128 #include "MueLu_SubBlockAFactory.hpp" 129 #ifdef HAVE_MUELU_EXPERIMENTAL 130 #ifdef HAVE_MUELU_TEKO 131 #include "MueLu_TekoSmoother.hpp" 134 #include "MueLu_TentativePFactory.hpp" 135 #include "MueLu_ToggleCoordinatesTransferFactory.hpp" 136 #include "MueLu_TogglePFactory.hpp" 137 #include "MueLu_TrilinosSmoother.hpp" 138 #include "MueLu_TransPFactory.hpp" 139 #include "MueLu_UncoupledAggregationFactory.hpp" 140 #include "MueLu_UnsmooshFactory.hpp" 141 #include "MueLu_UserAggregationFactory.hpp" 142 #include "MueLu_UserPFactory.hpp" 143 #ifdef HAVE_MUELU_EXPERIMENTAL 144 #include "MueLu_UzawaSmoother.hpp" 146 #include "MueLu_VariableDofLaplacianFactory.hpp" 147 #include "MueLu_ZoltanInterface.hpp" 148 #include "MueLu_Zoltan2Interface.hpp" 150 #ifdef HAVE_MUELU_MATLAB 152 #include "../matlab/src/MueLu_SingleLevelMatlabFactory_decl.hpp" 153 #include "../matlab/src/MueLu_SingleLevelMatlabFactory_def.hpp" 154 #include "../matlab/src/MueLu_TwoLevelMatlabFactory_decl.hpp" 155 #include "../matlab/src/MueLu_TwoLevelMatlabFactory_def.hpp" 156 #include "../matlab/src/MueLu_MatlabSmoother_decl.hpp" 157 #include "../matlab/src/MueLu_MatlabSmoother_def.hpp" 160 #ifdef HAVE_MUELU_INTREPID2 161 #include "MueLu_IntrepidPCoarsenFactory.hpp" 172 template <
class Scalar =
double,
class LocalOrdinal =
int,
class GlobalOrdinal = LocalOrdinal,
class Node = KokkosClassic::DefaultNode::DefaultNodeType>
174 #undef MUELU_FACTORYFACTORY_SHORT 177 typedef std::map<std::string, RCP<const FactoryBase> >
FactoryMap;
199 virtual RCP<const FactoryBase>
BuildFactory(
const Teuchos::ParameterEntry& param,
const FactoryMap& factoryMapIn,
const FactoryManagerMap& factoryManagersIn)
const {
201 std::string factoryName;
202 Teuchos::ParameterList paramList;
203 if (!param.isList()) {
204 factoryName = Teuchos::getValue<std::string>(param);
206 paramList = Teuchos::getValue<Teuchos::ParameterList>(param);
207 factoryName = paramList.get<std::string>(
"factory");
211 if (factoryName ==
"AggregationExportFactory")
return Build2<AggregationExportFactory> (paramList, factoryMapIn, factoryManagersIn);
212 if (factoryName ==
"AmalgamationFactory")
return Build2<AmalgamationFactory> (paramList, factoryMapIn, factoryManagersIn);
213 #ifdef HAVE_MUELU_EXPERIMENTAL 214 if (factoryName ==
"BlockedCoarseMapFactory")
return Build2<BlockedCoarseMapFactory> (paramList, factoryMapIn, factoryManagersIn);
215 if (factoryName ==
"BlockedRAPFactory")
return BuildRAPFactory<BlockedRAPFactory> (paramList, factoryMapIn, factoryManagersIn);
217 if (factoryName ==
"BrickAggregationFactory")
return Build2<BrickAggregationFactory> (paramList, factoryMapIn, factoryManagersIn);
218 if (factoryName ==
"CloneRepartitionInterface")
return Build2<CloneRepartitionInterface> (paramList, factoryMapIn, factoryManagersIn);
219 if (factoryName ==
"CoarseMapFactory")
return Build2<CoarseMapFactory> (paramList, factoryMapIn, factoryManagersIn);
220 if (factoryName ==
"CoarseningVisualizationFactory")
return Build2<CoarseningVisualizationFactory> (paramList, factoryMapIn, factoryManagersIn);
221 if (factoryName ==
"CoalesceDropFactory")
return Build2<CoalesceDropFactory> (paramList, factoryMapIn, factoryManagersIn);
222 if (factoryName ==
"ConstraintFactory")
return Build2<ConstraintFactory> (paramList, factoryMapIn, factoryManagersIn);
224 if (factoryName ==
"CoordinatesTransferFactory")
return Build2<CoordinatesTransferFactory> (paramList, factoryMapIn, factoryManagersIn);
225 if (factoryName ==
"DirectSolver")
return BuildDirectSolver (paramList, factoryMapIn, factoryManagersIn);
226 if (factoryName ==
"DropNegativeEntriesFactory")
return Build2<DropNegativeEntriesFactory> (paramList, factoryMapIn, factoryManagersIn);
227 if (factoryName ==
"EminPFactory")
return Build2<EminPFactory> (paramList, factoryMapIn, factoryManagersIn);
228 if (factoryName ==
"FilteredAFactory")
return Build2<FilteredAFactory> (paramList, factoryMapIn, factoryManagersIn);
229 if (factoryName ==
"FineLevelInputDataFactory")
return Build2<FineLevelInputDataFactory> (paramList, factoryMapIn, factoryManagersIn);
230 if (factoryName ==
"GeneralGeometricPFactory")
return Build2<GeneralGeometricPFactory> (paramList, factoryMapIn, factoryManagersIn);
231 if (factoryName ==
"GenericRFactory")
return Build2<GenericRFactory> (paramList, factoryMapIn, factoryManagersIn);
232 if (factoryName ==
"LineDetectionFactory")
return Build2<LineDetectionFactory> (paramList, factoryMapIn, factoryManagersIn);
233 if (factoryName ==
"MapTransferFactory")
return Build2<MapTransferFactory> (paramList, factoryMapIn, factoryManagersIn);
234 if (factoryName ==
"MatrixAnalysisFactory")
return Build2<MatrixAnalysisFactory> (paramList, factoryMapIn, factoryManagersIn);
235 if (factoryName ==
"MultiVectorTransferFactory")
return Build2<MultiVectorTransferFactory> (paramList, factoryMapIn, factoryManagersIn);
237 if (factoryName ==
"NoSmoother")
return rcp(
new SmootherFactory(Teuchos::null));
238 if (factoryName ==
"NullspaceFactory")
return Build2<NullspaceFactory> (paramList, factoryMapIn, factoryManagersIn);
239 if (factoryName ==
"NullspacePresmoothFactory")
return Build2<NullspacePresmoothFactory> (paramList, factoryMapIn, factoryManagersIn);
240 if (factoryName ==
"PatternFactory")
return Build2<PatternFactory> (paramList, factoryMapIn, factoryManagersIn);
241 if (factoryName ==
"PgPFactory")
return Build2<PgPFactory> (paramList, factoryMapIn, factoryManagersIn);
242 if (factoryName ==
"SaPFactory")
return Build2<SaPFactory> (paramList, factoryMapIn, factoryManagersIn);
243 if (factoryName ==
"RAPFactory")
return BuildRAPFactory<RAPFactory> (paramList, factoryMapIn, factoryManagersIn);
244 if (factoryName ==
"RebalanceAcFactory")
return Build2<RebalanceAcFactory> (paramList, factoryMapIn, factoryManagersIn);
245 if (factoryName ==
"RebalanceTransferFactory")
return Build2<RebalanceTransferFactory> (paramList, factoryMapIn, factoryManagersIn);
246 if (factoryName ==
"ReorderBlockAFactory")
return Build2<ReorderBlockAFactory> (paramList, factoryMapIn, factoryManagersIn);
247 if (factoryName ==
"RepartitionInterface")
return Build2<RepartitionInterface> (paramList, factoryMapIn, factoryManagersIn);
248 if (factoryName ==
"SegregatedAFactory")
return Build2<SegregatedAFactory> (paramList, factoryMapIn, factoryManagersIn);
249 if (factoryName ==
"SemiCoarsenPFactory")
return Build2<SemiCoarsenPFactory> (paramList, factoryMapIn, factoryManagersIn);
250 if (factoryName ==
"StructuredLineDetectionFactory")
return Build2<StructuredLineDetectionFactory> (paramList, factoryMapIn, factoryManagersIn);
251 if (factoryName ==
"SubBlockAFactory")
return Build2<SubBlockAFactory> (paramList, factoryMapIn, factoryManagersIn);
252 if (factoryName ==
"TentativePFactory")
return Build2<TentativePFactory> (paramList, factoryMapIn, factoryManagersIn);
254 if (factoryName ==
"TogglePFactory")
return BuildTogglePFactory<TogglePFactory> (paramList, factoryMapIn, factoryManagersIn);
255 if (factoryName ==
"TransPFactory")
return Build2<TransPFactory> (paramList, factoryMapIn, factoryManagersIn);
256 if (factoryName ==
"TrilinosSmoother")
return BuildTrilinosSmoother (paramList, factoryMapIn, factoryManagersIn);
257 if (factoryName ==
"UncoupledAggregationFactory")
return Build2<UncoupledAggregationFactory> (paramList, factoryMapIn, factoryManagersIn);
258 if (factoryName ==
"UnsmooshFactory")
return Build2<UnsmooshFactory> (paramList, factoryMapIn, factoryManagersIn);
259 if (factoryName ==
"UserAggregationFactory")
return Build2<UserAggregationFactory> (paramList, factoryMapIn, factoryManagersIn);
260 if (factoryName ==
"UserPFactory")
return Build2<UserPFactory> (paramList, factoryMapIn, factoryManagersIn);
261 if (factoryName ==
"VariableDofLaplacianFactory")
return Build2<VariableDofLaplacianFactory> (paramList, factoryMapIn, factoryManagersIn);
263 if (factoryName ==
"ZoltanInterface") {
264 #if defined(HAVE_MUELU_ZOLTAN) && defined(HAVE_MPI) 265 return Build2<ZoltanInterface>(paramList, factoryMapIn, factoryManagersIn);
267 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a ZoltanInterface object: Zoltan is disabled: HAVE_MUELU_ZOLTAN && HAVE_MPI == false.");
268 #endif // HAVE_MUELU_ZOLTAN && HAVE_MPI 270 if (factoryName ==
"Zoltan2Interface") {
271 #if defined(HAVE_MUELU_ZOLTAN2) && defined(HAVE_MPI) 272 return Build2<Zoltan2Interface>(paramList, factoryMapIn, factoryManagersIn);
274 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a Zoltan2Interface object: Zoltan2 is disabled: HAVE_MUELU_ZOLTAN2 && HAVE_MPI == false.");
275 #endif // HAVE_MUELU_ZOLTAN2 && HAVE_MPI 277 if (factoryName ==
"IsorropiaInterface") {
278 #if defined(HAVE_MUELU_ISORROPIA) && defined(HAVE_MPI) 279 return Build2<IsorropiaInterface>(paramList, factoryMapIn, factoryManagersIn);
281 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a IsorropiaInterface object: Isorropia is disabled: HAVE_MUELU_ISORROPIA && HAVE_MPI == false.");
282 #endif // HAVE_MUELU_ZOLTAN2 && HAVE_MPI 285 if (factoryName ==
"RepartitionFactory") {
287 return Build2<RepartitionFactory>(paramList, factoryMapIn, factoryManagersIn);
289 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a RepartitionFactory object: HAVE_MPI == false.");
292 if (factoryName ==
"RepartitionHeuristicFactory") {
294 return Build2<RepartitionHeuristicFactory>(paramList, factoryMapIn, factoryManagersIn);
296 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory:BuildFactory(): Cannot create a RepartitionHeuristicFactory object: HAVE_MPI == false.");
300 #ifdef HAVE_MUELU_EXPERIMENTAL 301 if (factoryName ==
"BlockedDirectSolver")
return BuildBlockedDirectSolver(paramList, factoryMapIn, factoryManagersIn);
302 if (factoryName ==
"BlockedGaussSeidelSmoother")
return BuildBlockedSmoother<BlockedGaussSeidelSmoother>(paramList, factoryMapIn, factoryManagersIn);
303 if (factoryName ==
"BlockedPFactory")
return BuildBlockedFactory<BlockedPFactory>(paramList, factoryMapIn, factoryManagersIn);
304 if (factoryName ==
"BraessSarazinSmoother")
return BuildBlockedSmoother<BraessSarazinSmoother>(paramList, factoryMapIn, factoryManagersIn);
305 if (factoryName ==
"IndefiniteBlockDiagonalSmoother")
return BuildBlockedSmoother<IndefBlockedDiagonalSmoother>(paramList, factoryMapIn, factoryManagersIn);
306 if (factoryName ==
"SimpleSmoother")
return BuildBlockedSmoother<SimpleSmoother>(paramList, factoryMapIn, factoryManagersIn);
307 if (factoryName ==
"SchurComplementFactory")
return Build2<SchurComplementFactory> (paramList, factoryMapIn, factoryManagersIn);
308 if (factoryName ==
"RebalanceBlockRestrictionFactory")
return BuildBlockedFactory<RebalanceBlockRestrictionFactory>(paramList, factoryMapIn, factoryManagersIn);
309 if (factoryName ==
"RebalanceBlockAcFactory")
return BuildBlockedFactory<RebalanceBlockAcFactory>(paramList, factoryMapIn, factoryManagersIn);
310 if (factoryName ==
"RebalanceBlockInterpolationFactory")
return BuildBlockedFactory<RebalanceBlockInterpolationFactory>(paramList, factoryMapIn, factoryManagersIn);
311 #ifdef HAVE_MUELU_TEKO 312 if (factoryName ==
"TekoSmoother")
return BuildTekoSmoother(paramList, factoryMapIn, factoryManagersIn);
314 if (factoryName ==
"UzawaSmoother")
return BuildBlockedSmoother<UzawaSmoother>(paramList, factoryMapIn, factoryManagersIn);
318 #ifdef HAVE_MUELU_MATLAB 319 if (factoryName ==
"TwoLevelMatlabFactory")
return Build2<TwoLevelMatlabFactory> (paramList, factoryMapIn, factoryManagersIn);
320 if (factoryName ==
"SingleLevelMatlabFactory")
return Build2<SingleLevelMatlabFactory> (paramList, factoryMapIn, factoryManagersIn);
321 if (factoryName ==
"MatlabSmoother")
return BuildMatlabSmoother (paramList, factoryMapIn, factoryManagersIn);
324 #ifdef HAVE_MUELU_INTREPID2 325 if (factoryName ==
"IntrepidPCoarsenFactory")
return Build2<IntrepidPCoarsenFactory> (paramList, factoryMapIn, factoryManagersIn);
329 if (factoryMapIn.find(factoryName) != factoryMapIn.end()) {
331 "MueLu::FactoryFactory: Error during the parsing of: " << std::endl << paramList << std::endl
332 <<
"'" << factoryName <<
"' is not a factory name but an existing instance of a factory." << std::endl
333 <<
"Extra parameters cannot be specified after the creation of the object." << std::endl << std::endl
334 <<
"Correct syntaxes includes:" << std::endl
335 <<
" <Parameter name=\"...\" type=\"string\" value=\"" << factoryName <<
"\"/>" << std::endl
337 <<
" <ParameterList name=\"...\"><Parameter name=\"factory\" type=\"string\" value=\"" << factoryName <<
"\"/></ParameterList>" << std::endl
340 return factoryMapIn.find(factoryName)->second;
343 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MueLu::FactoryFactory: unknown factory name : " << factoryName);
345 return Teuchos::null;
358 #define arraysize(ar) (sizeof(ar) / sizeof(ar[0])) 361 RCP<T>
Build(
const Teuchos::ParameterList& paramList,
const FactoryMap& factoryMapIn,
const FactoryManagerMap& factoryManagersIn)
const {
362 RCP<T> factory = rcp(
new T());
364 const char* strarray[] = {
"A",
"P",
"R",
"Graph",
"UnAmalgamationInfo",
"Aggregates",
"Nullspace",
"TransferFactory",
"DofsPerNode"};
365 std::vector<std::string> v(strarray, strarray +
arraysize(strarray));
366 for (
size_t i = 0; i < v.size(); ++i)
367 if (paramList.isParameter(v[i]))
368 factory->SetFactory(v[i],
BuildFactory(paramList.getEntry(v[i]), factoryMapIn, factoryManagersIn));
374 RCP<T>
Build2(
const Teuchos::ParameterList& paramList,
const FactoryMap& factoryMapIn,
const FactoryManagerMap& factoryManagersIn)
const {
375 RCP<T> factory = rcp(
new T());
377 ParameterList paramListWithFactories;
380 RCP<const ParameterList> validParamList = factory->GetValidParameterList();
381 TEUCHOS_TEST_FOR_EXCEPTION(validParamList == Teuchos::null,
Exceptions::RuntimeError,
"FactoryFactory::Build2: default parameter list is null. Please fix this.");
382 for (ParameterList::ConstIterator param = validParamList->begin(); param != validParamList->end(); ++param) {
383 const std::string& pName = validParamList->name(param);
385 if (!paramList.isParameter(pName)) {
390 if (validParamList->isType< RCP<const FactoryBase> >(pName)) {
392 RCP<const FactoryBase> generatingFact =
BuildFactory(paramList.getEntry(pName), factoryMapIn, factoryManagersIn);
393 paramListWithFactories.set(pName, generatingFact);
394 }
else if (validParamList->isType<RCP<const ParameterList> >(pName)) {
395 if (pName ==
"ParameterList") {
400 RCP<const ParameterList> subList = Teuchos::sublist(rcp(
new ParameterList(paramList)), pName);
401 paramListWithFactories.set(pName, subList);
404 paramListWithFactories.setEntry(pName, paramList.getEntry(pName));
409 factory->SetParameterList(paramListWithFactories);
415 RCP<T>
BuildRAPFactory(
const Teuchos::ParameterList & paramList,
const FactoryMap& factoryMapIn,
const FactoryManagerMap& factoryManagersIn)
const {
417 if (paramList.isSublist(
"TransferFactories") ==
false) {
418 factory = Build2<T>(paramList, factoryMapIn, factoryManagersIn);
421 RCP<Teuchos::ParameterList> paramListNonConst = rcp(
new Teuchos::ParameterList(paramList));
422 RCP<const Teuchos::ParameterList> transferFactories = rcp(
new Teuchos::ParameterList(*sublist(paramListNonConst,
"TransferFactories")));
424 paramListNonConst->remove(
"TransferFactories");
426 factory = Build2<T>(*paramListNonConst, factoryMapIn, factoryManagersIn);
428 for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
429 RCP<const FactoryBase> p =
BuildFactory(transferFactories->entry(param), factoryMapIn, factoryManagersIn);
430 factory->AddTransferFactory(p);
438 RCP<T>
BuildTogglePFactory(
const Teuchos::ParameterList & paramList,
const FactoryMap& factoryMapIn,
const FactoryManagerMap& factoryManagersIn)
const {
440 if (paramList.isSublist(
"TransferFactories") ==
false) {
442 factory = Build2<T>(paramList, factoryMapIn, factoryManagersIn);
445 RCP<Teuchos::ParameterList> paramListNonConst = rcp(
new Teuchos::ParameterList(paramList));
446 RCP<const Teuchos::ParameterList> transferFactories = rcp(
new Teuchos::ParameterList(*sublist(paramListNonConst,
"TransferFactories")));
448 paramListNonConst->remove(
"TransferFactories");
451 factory = Build2<T>(*paramListNonConst, factoryMapIn, factoryManagersIn);
455 int numProlongatorFactories = 0;
456 int numPtentFactories = 0;
457 int numCoarseNspFactories = 0;
458 for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
459 size_t foundNsp = transferFactories->name(param).find(
"Nullspace");
460 if (foundNsp != std::string::npos && foundNsp == 0 && transferFactories->name(param).length()==10) {
461 numCoarseNspFactories++;
464 size_t foundPtent = transferFactories->name(param).find(
"Ptent");
465 if (foundPtent != std::string::npos && foundPtent == 0 && transferFactories->name(param).length()==6) {
469 size_t foundP = transferFactories->name(param).find(
"P");
470 if (foundP != std::string::npos && foundP == 0 && transferFactories->name(param).length()==2) {
471 numProlongatorFactories++;
475 TEUCHOS_TEST_FOR_EXCEPTION(numProlongatorFactories!=numCoarseNspFactories,
Exceptions::RuntimeError,
"FactoryFactory::BuildToggleP: The user has to provide the same number of prolongator and coarse nullspace factories!");
476 TEUCHOS_TEST_FOR_EXCEPTION(numPtentFactories!=numCoarseNspFactories,
Exceptions::RuntimeError,
"FactoryFactory::BuildToggleP: The user has to provide the same number of ptent and coarse nullspace factories!");
477 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.");
480 std::vector<Teuchos::ParameterEntry> prolongatorFactoryNames(numProlongatorFactories);
481 std::vector<Teuchos::ParameterEntry> coarseNspFactoryNames(numProlongatorFactories);
482 std::vector<Teuchos::ParameterEntry> ptentFactoryNames(numProlongatorFactories);
484 for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
485 size_t foundNsp = transferFactories->name(param).find(
"Nullspace");
486 if (foundNsp != std::string::npos && foundNsp == 0 && transferFactories->name(param).length()==10) {
487 int number = atoi(&(transferFactories->name(param).at(9)));
488 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!");
489 coarseNspFactoryNames[number-1] = transferFactories->entry(param);
492 size_t foundPtent = transferFactories->name(param).find(
"Ptent");
493 if (foundPtent != std::string::npos && foundPtent == 0 && transferFactories->name(param).length()==6) {
494 int number = atoi(&(transferFactories->name(param).at(5)));
495 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!");
496 ptentFactoryNames[number-1] = transferFactories->entry(param);
499 size_t foundP = transferFactories->name(param).find(
"P");
500 if (foundP != std::string::npos && foundP == 0 && transferFactories->name(param).length()==2) {
501 int number = atoi(&(transferFactories->name(param).at(1)));
502 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!");
503 prolongatorFactoryNames[number-1] = transferFactories->entry(param);
509 for (std::vector<Teuchos::ParameterEntry>::const_iterator it = prolongatorFactoryNames.begin(); it != prolongatorFactoryNames.end(); ++it) {
510 RCP<const FactoryBase> p =
BuildFactory(*it, factoryMapIn, factoryManagersIn);
511 factory->AddProlongatorFactory(p);
515 for (std::vector<Teuchos::ParameterEntry>::const_iterator it = ptentFactoryNames.begin(); it != ptentFactoryNames.end(); ++it) {
516 RCP<const FactoryBase> p =
BuildFactory(*it, factoryMapIn, factoryManagersIn);
517 factory->AddPtentFactory(p);
521 for (std::vector<Teuchos::ParameterEntry>::const_iterator it = coarseNspFactoryNames.begin(); it != coarseNspFactoryNames.end(); ++it) {
522 RCP<const FactoryBase> p =
BuildFactory(*it, factoryMapIn, factoryManagersIn);
523 factory->AddCoarseNullspaceFactory(p);
529 RCP<ToggleCoordinatesTransferFactory>
BuildToggleCoordinatesTransferFactory(
const Teuchos::ParameterList & paramList,
const FactoryMap& factoryMapIn,
const FactoryManagerMap& factoryManagersIn)
const {
530 RCP<ToggleCoordinatesTransferFactory> factory;
531 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!");
533 RCP<Teuchos::ParameterList> paramListNonConst = rcp(
new Teuchos::ParameterList(paramList));
534 RCP<const Teuchos::ParameterList> transferFactories = rcp(
new Teuchos::ParameterList(*sublist(paramListNonConst,
"TransferFactories")));
535 paramListNonConst->remove(
"TransferFactories");
538 factory = Build2<ToggleCoordinatesTransferFactory>(*paramListNonConst, factoryMapIn, factoryManagersIn);
542 int numCoordTransferFactories = 0;
543 for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
544 size_t foundCoordinates = transferFactories->name(param).find(
"Coordinates");
545 if (foundCoordinates != std::string::npos && foundCoordinates == 0 && transferFactories->name(param).length()==12) {
546 numCoordTransferFactories++;
550 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.");
553 std::vector<Teuchos::ParameterEntry> coarseCoordsFactoryNames(numCoordTransferFactories);
555 for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
556 size_t foundCoords = transferFactories->name(param).find(
"Coordinates");
557 if (foundCoords != std::string::npos && foundCoords == 0 && transferFactories->name(param).length()==12) {
558 int number = atoi(&(transferFactories->name(param).at(11)));
559 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!");
560 coarseCoordsFactoryNames[number-1] = transferFactories->entry(param);
566 for (std::vector<Teuchos::ParameterEntry>::const_iterator it = coarseCoordsFactoryNames.begin(); it != coarseCoordsFactoryNames.end(); ++it) {
567 RCP<const FactoryBase> p =
BuildFactory(*it, factoryMapIn, factoryManagersIn);
568 factory->AddCoordTransferFactory(p);
575 RCP<FactoryBase>
BuildCoupledAggregationFactory(
const Teuchos::ParameterList& paramList,
const FactoryMap& factoryMapIn,
const FactoryManagerMap& factoryManagersIn)
const {
576 RCP<CoupledAggregationFactory> factory = Build<CoupledAggregationFactory>(paramList, factoryMapIn, factoryManagersIn);
578 if (paramList.isParameter(
"aggregation: ordering"))
579 factory->SetOrdering(paramList.get<std::string>(
"aggregation: ordering"));
581 if (paramList.isParameter(
"aggregation: max selected neighbors"))
582 factory->SetMaxNeighAlreadySelected(paramList.get<
int>(
"aggregation: max selected neighbors"));
584 if (paramList.isParameter(
"Phase3AggCreation"))
585 factory->SetPhase3AggCreation(paramList.get<
double>(
"Phase3AggCreation"));
587 if(paramList.isParameter(
"aggregation: min agg size"))
588 factory->SetMinNodesPerAggregate(paramList.get<
int>(
"aggregation: min agg size"));
603 RCP<FactoryBase>
BuildTrilinosSmoother(
const Teuchos::ParameterList & paramList,
const FactoryMap & factoryMapIn,
const FactoryManagerMap& factoryManagersIn)
const {
604 if (paramList.begin() == paramList.end())
607 TEUCHOS_TEST_FOR_EXCEPTION(paramList.get<std::string>(
"factory") !=
"TrilinosSmoother",
Exceptions::RuntimeError,
"");
612 std::string type=
"";
if(paramList.isParameter(
"type")) type = paramList.get<std::string>(
"type");
613 int overlap=0;
if(paramList.isParameter(
"overlap")) overlap = paramList.get<
int> (
"overlap");
615 Teuchos::ParameterList params;
if(paramList.isParameter(
"ParameterList")) params = paramList.get<Teuchos::ParameterList>(
"ParameterList");
624 Teuchos::RCP<TrilinosSmoother> trilSmoo = Teuchos::rcp(
new TrilinosSmoother(type, params, overlap));
626 if (paramList.isParameter(
"LineDetection_Layers")) {
627 RCP<const FactoryBase> generatingFact =
BuildFactory(paramList.getEntry(
"LineDetection_Layers"), factoryMapIn, factoryManagersIn);
628 trilSmoo->SetFactory(
"LineDetection_Layers", generatingFact);
630 if (paramList.isParameter(
"LineDetection_VertLineIds")) {
631 RCP<const FactoryBase> generatingFact =
BuildFactory(paramList.getEntry(
"LineDetection_Layers"), factoryMapIn, factoryManagersIn);
632 trilSmoo->SetFactory(
"LineDetection_Layers", generatingFact);
634 if (paramList.isParameter(
"CoarseNumZLayers")) {
635 RCP<const FactoryBase> generatingFact =
BuildFactory(paramList.getEntry(
"CoarseNumZLayers"), factoryMapIn, factoryManagersIn);
636 trilSmoo->SetFactory(
"CoarseNumZLayers", generatingFact);
639 RCP<SmootherFactory> smooFact = rcp(
new SmootherFactory(Teuchos::null));
640 Teuchos::ParameterList smooFactParams;
642 smooFact->SetParameterList(smooFactParams);
643 smooFact->SetSmootherPrototypes(trilSmoo);
647 #ifdef HAVE_MUELU_MATLAB 659 RCP<FactoryBase>
BuildMatlabSmoother(
const Teuchos::ParameterList & paramList,
const FactoryMap & factoryMapIn,
const FactoryManagerMap& factoryManagersIn)
const {
660 if (paramList.begin() == paramList.end())
663 TEUCHOS_TEST_FOR_EXCEPTION(paramList.get<std::string>(
"factory") !=
"MatlabSmoother",
Exceptions::RuntimeError,
"");
669 Teuchos::RCP<MatlabSmoother> matSmoo = Teuchos::rcp(
new MatlabSmoother(paramList));
675 RCP<FactoryBase>
BuildDirectSolver(
const Teuchos::ParameterList& paramList,
const FactoryMap& factoryMapIn,
const FactoryManagerMap& factoryManagersIn)
const {
676 if (paramList.begin() == paramList.end())
681 std::string type;
if(paramList.isParameter(
"type")) type = paramList.get<std::string>(
"type");
683 Teuchos::ParameterList params;
if(paramList.isParameter(
"ParameterList")) params = paramList.get<Teuchos::ParameterList>(
"ParameterList");
688 #ifdef HAVE_MUELU_EXPERIMENTAL 690 RCP<FactoryBase>
BuildBlockedSmoother(
const Teuchos::ParameterList& paramList,
const FactoryMap& factoryMapIn,
const FactoryManagerMap& factoryManagersIn)
const {
692 RCP<ParameterList> paramListNonConst = rcp(
new ParameterList(paramList));
695 std::vector<RCP<FactoryManager> > facManagers;
699 bool blockExists =
true;
700 while (blockExists ==
true) {
701 std::stringstream ss;
702 ss <<
"block" << blockid;
704 if(paramList.isSublist(ss.str()) ==
true) {
706 RCP<const ParameterList> b = rcp(
new ParameterList(*sublist(paramListNonConst, ss.str())));
708 RCP<FactoryManager> M = Teuchos::null;
710 if (b->isParameter(
"group")) {
712 std::string facManagerName = b->get< std::string >(
"group");
713 TEUCHOS_TEST_FOR_EXCEPTION(factoryManagersIn.count(facManagerName) != 1,
Exceptions::RuntimeError,
"Factory manager has not been found. Please check the spelling of the factory managers in your xml file.");
714 RCP<FactoryManagerBase> Mb = factoryManagersIn.find(facManagerName)->second;
716 TEUCHOS_TEST_FOR_EXCEPTION(M==Teuchos::null,
Exceptions::RuntimeError,
"Failed to cast FactoryManagerBase object to FactoryManager.");
720 for (ParameterList::ConstIterator param = b->begin(); param != b->end(); ++param) {
721 RCP<const FactoryBase> p =
BuildFactory(b->entry(param), factoryMapIn, factoryManagersIn);
722 M->SetFactory(b->name(param),p);
727 M->SetIgnoreUserData(
true);
728 facManagers.push_back(M);
729 paramListNonConst->remove(ss.str());
739 RCP<T> bs = Build2<T>(*paramListNonConst, factoryMapIn, factoryManagersIn);
747 for (
int i = 0; i<Teuchos::as<int>(facManagers.size()); i++) {
748 bs->AddFactoryManager(facManagers[i],i);
754 #ifdef HAVE_MUELU_TEKO 755 RCP<FactoryBase>
BuildTekoSmoother(
const Teuchos::ParameterList& paramList,
const FactoryMap& factoryMapIn,
const FactoryManagerMap& factoryManagersIn)
const {
757 RCP<ParameterList> paramListNonConst = rcp(
new ParameterList(paramList));
758 RCP<ParameterList> tekoParams = rcp(
new ParameterList(paramListNonConst->sublist(
"Inverse Factory Library")));
759 paramListNonConst->remove(
"Inverse Factory Library");
762 RCP<TekoSmoother> bs = Build2<TekoSmoother>(*paramListNonConst, factoryMapIn, factoryManagersIn);
771 bs->SetTekoParameters(tekoParams);
777 RCP<FactoryBase>
BuildBlockedDirectSolver(
const Teuchos::ParameterList& paramList,
const FactoryMap& factoryMapIn,
const FactoryManagerMap& factoryManagersIn)
const {
794 RCP<T>
BuildBlockedFactory(
const Teuchos::ParameterList & paramList,
const FactoryMap& factoryMapIn,
const FactoryManagerMap& factoryManagersIn)
const {
795 RCP<T> pfac = Teuchos::null;
798 RCP<ParameterList> paramListNonConst = rcp(
new ParameterList(paramList));
801 std::vector<RCP<FactoryManager> > facManagers;
805 bool blockExists =
true;
806 while (blockExists ==
true) {
807 std::stringstream ss;
808 ss <<
"block" << blockid;
810 if(paramList.isSublist(ss.str()) ==
true) {
812 RCP<const ParameterList> b = rcp(
new ParameterList(*sublist(paramListNonConst, ss.str())));
814 RCP<FactoryManager> M = Teuchos::null;
816 if (b->isParameter(
"group")) {
818 std::string facManagerName = b->get< std::string >(
"group");
819 TEUCHOS_TEST_FOR_EXCEPTION(factoryManagersIn.count(facManagerName) != 1,
Exceptions::RuntimeError,
"Factory manager has not been found. Please check the spelling of the factory managers in your xml file.");
820 RCP<FactoryManagerBase> Mb = factoryManagersIn.find(facManagerName)->second;
822 TEUCHOS_TEST_FOR_EXCEPTION(M==Teuchos::null,
Exceptions::RuntimeError,
"Failed to cast FactoryManagerBase object to FactoryManager.");
826 for (ParameterList::ConstIterator param = b->begin(); param != b->end(); ++param) {
827 RCP<const FactoryBase> p =
BuildFactory(b->entry(param), factoryMapIn, factoryManagersIn);
828 M->SetFactory(b->name(param),p);
833 M->SetIgnoreUserData(
true);
834 facManagers.push_back(M);
835 paramListNonConst->remove(ss.str());
845 pfac = Build2<T>(*paramListNonConst, factoryMapIn, factoryManagersIn);
848 for(
size_t i = 0; i<facManagers.size(); i++) {
849 pfac->AddFactoryManager(facManagers[i]);
858 #define MUELU_FACTORYFACTORY_SHORT 859 #endif // MUELU_FACTORYFACTORY_DECL_HPP RCP< FactoryBase > BuildMatlabSmoother(const Teuchos::ParameterList ¶mList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
MatlabSmoother.
Generic Smoother Factory for generating the smoothers of the MG hierarchy.
This class specifies the default factory that should generate some data on a Level if the data does n...
RCP< FactoryBase > BuildBlockedSmoother(const Teuchos::ParameterList ¶mList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
RCP< T > Build(const Teuchos::ParameterList ¶mList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
Factory that can generate other factories from.
Class that encapsulates external library smoothers.
virtual RCP< const FactoryBase > BuildFactory(const Teuchos::ParameterEntry ¶m, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
: Interpret Factory parameter list and build new factory
RCP< T > BuildBlockedFactory(const Teuchos::ParameterList ¶mList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
RCP< ToggleCoordinatesTransferFactory > BuildToggleCoordinatesTransferFactory(const Teuchos::ParameterList ¶mList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
RCP< T > Build2(const Teuchos::ParameterList ¶mList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
Namespace for MueLu classes and methods.
Class that encapsulates direct solvers. Autoselection of AmesosSmoother or Amesos2Smoother according ...
std::map< std::string, RCP< FactoryManagerBase > > FactoryManagerMap
std::map< std::string, RCP< const FactoryBase > > FactoryMap
RCP< FactoryBase > BuildBlockedDirectSolver(const Teuchos::ParameterList ¶mList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
direct solver for nxn blocked matrices
RCP< T > BuildRAPFactory(const Teuchos::ParameterList ¶mList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
Base class for MueLu classes.
Class that encapsulates Matlab smoothers.
RCP< FactoryBase > BuildTekoSmoother(const Teuchos::ParameterList ¶mList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
RCP< FactoryBase > BuildTrilinosSmoother(const Teuchos::ParameterList ¶mList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
TrilinosSmoother.
RCP< FactoryBase > BuildCoupledAggregationFactory(const Teuchos::ParameterList ¶mList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
CoupledAggregationFactory.
Exception throws to report errors in the internal logical of the program.
RCP< T > BuildTogglePFactory(const Teuchos::ParameterList ¶mList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
RCP< FactoryBase > BuildDirectSolver(const Teuchos::ParameterList ¶mList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
static const RCP< const NoFactory > getRCP()
Static Get() functions.