MueLu  Version of the Day
MueLu_FactoryFactory_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // MueLu: A package for multigrid based preconditioning
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef MUELU_FACTORYFACTORY_DECL_HPP
47 #define MUELU_FACTORYFACTORY_DECL_HPP
48 
49 #include <string>
50 #include <vector>
51 
52 #include <Teuchos_ParameterEntry.hpp>
53 #include <Teuchos_Array.hpp>
54 
55 #include "MueLu_ConfigDefs.hpp"
57 
59 
60 #include "MueLu_FactoryBase.hpp"
61 #include "MueLu_FactoryManager.hpp"
65 #include "MueLu_Hierarchy_fwd.hpp"
66 
67 #include "MueLu_Monitor.hpp"
68 #include "MueLu_Exceptions.hpp"
69 
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"
79 #endif
80 #include "MueLu_BrickAggregationFactory.hpp"
81 #include "MueLu_CoalesceDropFactory.hpp"
82 #include "MueLu_CoarseMapFactory.hpp"
83 #include "MueLu_CoarseningVisualizationFactory.hpp"
84 #include "MueLu_ConstraintFactory.hpp"
85 #include "MueLu_CoupledAggregationFactory.hpp"
86 #include "MueLu_CoordinatesTransferFactory.hpp"
87 #include "MueLu_DirectSolver.hpp"
88 #include "MueLu_EminPFactory.hpp"
89 #include "MueLu_FilteredAFactory.hpp"
90 #include "MueLu_GenericRFactory.hpp"
91 #ifdef HAVE_MUELU_EXPERIMENTAL
92 #include "MueLu_IndefBlockedDiagonalSmoother.hpp"
93 #endif
94 #include "MueLu_IsorropiaInterface.hpp"
95 #include "MueLu_LineDetectionFactory.hpp"
96 #include "MueLu_RepartitionInterface.hpp"
97 #include "MueLu_MapTransferFactory.hpp"
98 #include "MueLu_MatrixAnalysisFactory.hpp"
99 #include "MueLu_MultiVectorTransferFactory.hpp"
100 #include "MueLu_NullspaceFactory.hpp"
101 #include "MueLu_NullspacePresmoothFactory.hpp"
102 #include "MueLu_PatternFactory.hpp"
103 #include "MueLu_PgPFactory.hpp"
104 #include "MueLu_RebalanceTransferFactory.hpp"
105 #include "MueLu_RepartitionFactory.hpp"
106 #include "MueLu_RAPFactory.hpp"
107 #include "MueLu_RebalanceAcFactory.hpp"
108 #include "MueLu_SaPFactory.hpp"
109 #include "MueLu_SegregatedAFactory.hpp"
110 #ifdef HAVE_MUELU_EXPERIMENTAL
111 #include "MueLu_SchurComplementFactory.hpp"
112 #include "MueLu_SimpleSmoother.hpp"
113 #endif
114 #include "MueLu_SmootherFactory.hpp"
115 #ifdef HAVE_MUELU_EXPERIMENTAL
116 #include "MueLu_SubBlockAFactory.hpp"
117 #endif
118 #include "MueLu_TentativePFactory.hpp"
119 #include "MueLu_ToggleCoordinatesTransferFactory.hpp"
120 #include "MueLu_TogglePFactory.hpp"
121 #include "MueLu_TrilinosSmoother.hpp"
122 #include "MueLu_TransPFactory.hpp"
123 #include "MueLu_UncoupledAggregationFactory.hpp"
124 #include "MueLu_UserAggregationFactory.hpp"
125 #include "MueLu_UserPFactory.hpp"
126 #include "MueLu_SemiCoarsenPFactory.hpp"
127 #ifdef HAVE_MUELU_EXPERIMENTAL
128 #include "MueLu_UzawaSmoother.hpp"
129 #endif
130 #include "MueLu_ZoltanInterface.hpp"
131 #include "MueLu_Zoltan2Interface.hpp"
132 
133 #ifdef HAVE_MUELU_MATLAB
134 // This is distasteful, but (sadly) neccesary due to peculiarities in MueLu's build system.
135 #include "../matlab/src/MueLu_SingleLevelMatlabFactory_decl.hpp"
136 #include "../matlab/src/MueLu_SingleLevelMatlabFactory_def.hpp"
137 #include "../matlab/src/MueLu_TwoLevelMatlabFactory_decl.hpp"
138 #include "../matlab/src/MueLu_TwoLevelMatlabFactory_def.hpp"
139 #include "../matlab/src/MueLu_MatlabSmoother_decl.hpp"
140 #include "../matlab/src/MueLu_MatlabSmoother_def.hpp"
141 #endif
142 
143 namespace MueLu {
144 
151  template <class Scalar = double, class LocalOrdinal = int, class GlobalOrdinal = LocalOrdinal, class Node = KokkosClassic::DefaultNode::DefaultNodeType>
152  class FactoryFactory : public BaseClass {
153 #undef MUELU_FACTORYFACTORY_SHORT
154 #include "MueLu_UseShortNames.hpp"
155 
156  typedef std::map<std::string, RCP<const FactoryBase> > FactoryMap; // TODO: remove
157  typedef std::map<std::string, RCP<FactoryManagerBase> > FactoryManagerMap;
158 
159  public:
160 
161  // Parameter List Parsing:
162  // ---------
163  // <Parameter name="smootherFact0" type="string" value="TrilinosSmoother"/>
164  //
165  // or:
166  //
167  // <ParameterList name="smootherFact1">
168  // <Parameter name="factory" type="string" value="TrilinosSmoother"/>
169  // ...
170  // </ParameterList>
171  //
172  virtual RCP<const FactoryBase> BuildFactory(const Teuchos::ParameterEntry& param, const FactoryMap& factoryMapIn, const FactoryManagerMap& factoryManagersIn) const {
173  // Find factory
174  std::string factoryName;
175  Teuchos::ParameterList paramList;
176  if (!param.isList()) {
177  factoryName = Teuchos::getValue<std::string>(param);
178  } else {
179  paramList = Teuchos::getValue<Teuchos::ParameterList>(param);
180  factoryName = paramList.get<std::string>("factory");
181  }
182 
183  // TODO: see how Teko handles this (=> register factories).
184  if (factoryName == "AggregationExportFactory") return Build2<AggregationExportFactory> (paramList, factoryMapIn, factoryManagersIn);
185  if (factoryName == "AmalgamationFactory") return Build2<AmalgamationFactory> (paramList, factoryMapIn, factoryManagersIn);
186 #ifdef HAVE_MUELU_EXPERIMENTAL
187  if (factoryName == "BlockedCoarseMapFactory") return Build2<BlockedCoarseMapFactory> (paramList, factoryMapIn, factoryManagersIn);
188  if (factoryName == "BlockedRAPFactory") return BuildRAPFactory<BlockedRAPFactory> (paramList, factoryMapIn, factoryManagersIn);
189 #endif
190  if (factoryName == "BrickAggregationFactory") return Build2<BrickAggregationFactory> (paramList, factoryMapIn, factoryManagersIn);
191  if (factoryName == "CoarseMapFactory") return Build2<CoarseMapFactory> (paramList, factoryMapIn, factoryManagersIn);
192  if (factoryName == "CoarseningVisualizationFactory") return Build2<CoarseningVisualizationFactory>(paramList, factoryMapIn, factoryManagersIn);
193  if (factoryName == "CoalesceDropFactory") return Build2<CoalesceDropFactory> (paramList, factoryMapIn, factoryManagersIn);
194  if (factoryName == "ConstraintFactory") return Build2<ConstraintFactory> (paramList, factoryMapIn, factoryManagersIn);
195  if (factoryName == "CoupledAggregationFactory") return BuildCoupledAggregationFactory (paramList, factoryMapIn, factoryManagersIn);
196  if (factoryName == "CoordinatesTransferFactory") return Build2<CoordinatesTransferFactory> (paramList, factoryMapIn, factoryManagersIn);
197  if (factoryName == "DirectSolver") return BuildDirectSolver (paramList, factoryMapIn, factoryManagersIn);
198  if (factoryName == "EminPFactory") return Build2<EminPFactory> (paramList, factoryMapIn, factoryManagersIn);
199  if (factoryName == "FilteredAFactory") return Build2<FilteredAFactory> (paramList, factoryMapIn, factoryManagersIn);
200  if (factoryName == "GenericRFactory") return Build2<GenericRFactory> (paramList, factoryMapIn, factoryManagersIn);
201  if (factoryName == "LineDetectionFactory") return Build2<LineDetectionFactory> (paramList, factoryMapIn, factoryManagersIn);
202  if (factoryName == "MapTransferFactory") return Build2<MapTransferFactory> (paramList, factoryMapIn, factoryManagersIn);
203  if (factoryName == "MatrixAnalysisFactory") return Build2<MatrixAnalysisFactory> (paramList, factoryMapIn, factoryManagersIn);
204  if (factoryName == "MultiVectorTransferFactory") return Build2<MultiVectorTransferFactory> (paramList, factoryMapIn, factoryManagersIn);
205  if (factoryName == "NoFactory") return Teuchos::null;
206  if (factoryName == "NullspaceFactory") return Build2<NullspaceFactory> (paramList, factoryMapIn, factoryManagersIn);
207  if (factoryName == "NullspacePresmoothFactory") return Build2<NullspacePresmoothFactory> (paramList, factoryMapIn, factoryManagersIn);
208  if (factoryName == "PatternFactory") return Build2<PatternFactory> (paramList, factoryMapIn, factoryManagersIn);
209  if (factoryName == "PgPFactory") return Build2<PgPFactory> (paramList, factoryMapIn, factoryManagersIn);
210  if (factoryName == "SaPFactory") return Build2<SaPFactory> (paramList, factoryMapIn, factoryManagersIn);
211  if (factoryName == "RAPFactory") return BuildRAPFactory<RAPFactory> (paramList, factoryMapIn, factoryManagersIn);
212  if (factoryName == "RebalanceAcFactory") return Build2<RebalanceAcFactory> (paramList, factoryMapIn, factoryManagersIn);
213  if (factoryName == "RebalanceTransferFactory") return Build2<RebalanceTransferFactory> (paramList, factoryMapIn, factoryManagersIn);
214  if (factoryName == "SegregatedAFactory") return Build2<SegregatedAFactory> (paramList, factoryMapIn, factoryManagersIn);
215 #ifdef HAVE_MUELU_EXPERIMENTAL
216  if (factoryName == "SubBlockAFactory") return Build2<SubBlockAFactory> (paramList, factoryMapIn, factoryManagersIn);
217 #endif
218  if (factoryName == "TentativePFactory") return Build2<TentativePFactory> (paramList, factoryMapIn, factoryManagersIn);
219  if (factoryName == "ToggleCoordinatesTransferFactory")return BuildToggleCoordinatesTransferFactory (paramList, factoryMapIn, factoryManagersIn);
220  if (factoryName == "TogglePFactory") return BuildTogglePFactory<TogglePFactory> (paramList, factoryMapIn, factoryManagersIn);
221  if (factoryName == "TransPFactory") return Build2<TransPFactory> (paramList, factoryMapIn, factoryManagersIn);
222  if (factoryName == "TrilinosSmoother") return BuildTrilinosSmoother (paramList, factoryMapIn, factoryManagersIn);
223  if (factoryName == "UncoupledAggregationFactory") return BuildUncoupledAggregationFactory (paramList, factoryMapIn, factoryManagersIn);
224  if (factoryName == "UserAggregationFactory") return Build2<UserAggregationFactory> (paramList, factoryMapIn, factoryManagersIn);
225  if (factoryName == "UserPFactory") return Build2<UserPFactory> (paramList, factoryMapIn, factoryManagersIn);
226  if (factoryName == "SemiCoarsenPFactory") return Build2<SemiCoarsenPFactory> (paramList, factoryMapIn, factoryManagersIn);
227  if (factoryName == "RepartitionInterface") return Build2<RepartitionInterface> (paramList, factoryMapIn, factoryManagersIn);
228 
229  if (factoryName == "ZoltanInterface") {
230 #if defined(HAVE_MUELU_ZOLTAN) && defined(HAVE_MPI)
231  return Build2<ZoltanInterface>(paramList, factoryMapIn, factoryManagersIn);
232 #else
233  TEUCHOS_TEST_FOR_EXCEPTION(true, Exceptions::RuntimeError, "MueLu::FactoryFactory:BuildFactory(): Cannot create a ZoltanInterface object: Zoltan is disabled: HAVE_MUELU_ZOLTAN && HAVE_MPI == false.");
234 #endif // HAVE_MUELU_ZOLTAN && HAVE_MPI
235  }
236  if (factoryName == "Zoltan2Interface") {
237 #if defined(HAVE_MUELU_ZOLTAN2) && defined(HAVE_MPI)
238  return Build2<Zoltan2Interface>(paramList, factoryMapIn, factoryManagersIn);
239 #else
240  TEUCHOS_TEST_FOR_EXCEPTION(true, Exceptions::RuntimeError, "MueLu::FactoryFactory:BuildFactory(): Cannot create a Zoltan2Interface object: Zoltan2 is disabled: HAVE_MUELU_ZOLTAN2 && HAVE_MPI == false.");
241 #endif // HAVE_MUELU_ZOLTAN2 && HAVE_MPI
242  }
243  if (factoryName == "IsorropiaInterface") {
244 #if defined(HAVE_MUELU_ISORROPIA) && defined(HAVE_MPI)
245  return Build2<IsorropiaInterface>(paramList, factoryMapIn, factoryManagersIn);
246 #else
247  TEUCHOS_TEST_FOR_EXCEPTION(true, Exceptions::RuntimeError, "MueLu::FactoryFactory:BuildFactory(): Cannot create a IsorropiaInterface object: Isorropia is disabled: HAVE_MUELU_ISORROPIA && HAVE_MPI == false.");
248 #endif // HAVE_MUELU_ZOLTAN2 && HAVE_MPI
249  }
250 
251  if (factoryName == "RepartitionFactory") {
252 #ifdef HAVE_MPI
253  return Build2<RepartitionFactory>(paramList, factoryMapIn, factoryManagersIn);
254 #else
255  TEUCHOS_TEST_FOR_EXCEPTION(true, Exceptions::RuntimeError, "MueLu::FactoryFactory:BuildFactory(): Cannot create a RepartitionFactory object: HAVE_MPI == false.");
256 #endif // HAVE_MPI
257  }
258  // Blocked factories
259 #ifdef HAVE_MUELU_EXPERIMENTAL
260  if (factoryName == "BlockedDirectSolver") return BuildBlockedDirectSolver(paramList, factoryMapIn, factoryManagersIn);
261  if (factoryName == "BlockedGaussSeidelSmoother") return BuildBlockedSmoother<BlockedGaussSeidelSmoother>(paramList, factoryMapIn, factoryManagersIn);
262  if (factoryName == "BlockedPFactory") return BuildBlockedPFactory(paramList, factoryMapIn, factoryManagersIn);
263  if (factoryName == "BraessSarazinSmoother") return BuildBlockedSmoother<BraessSarazinSmoother>(paramList, factoryMapIn, factoryManagersIn);
264  if (factoryName == "IndefiniteBlockDiagonalSmoother") return BuildBlockedSmoother<IndefBlockedDiagonalSmoother>(paramList, factoryMapIn, factoryManagersIn);
265  if (factoryName == "SimpleSmoother") return BuildBlockedSmoother<SimpleSmoother>(paramList, factoryMapIn, factoryManagersIn);
266  if (factoryName == "SchurComplementFactory") return Build2<SchurComplementFactory> (paramList, factoryMapIn, factoryManagersIn);
267  if (factoryName == "UzawaSmoother") return BuildBlockedSmoother<UzawaSmoother>(paramList, factoryMapIn, factoryManagersIn);
268 #endif
269 
270  // Matlab factories
271 #ifdef HAVE_MUELU_MATLAB
272  if (factoryName == "TwoLevelMatlabFactory") return Build2<TwoLevelMatlabFactory> (paramList, factoryMapIn, factoryManagersIn);
273  if (factoryName == "SingleLevelMatlabFactory") return Build2<SingleLevelMatlabFactory> (paramList, factoryMapIn, factoryManagersIn);
274  if (factoryName == "MatlabSmoother") return BuildMatlabSmoother (paramList, factoryMapIn, factoryManagersIn);
275 #endif
276 
277  // Use a user defined factories (in <Factories> node)
278  if (factoryMapIn.find(factoryName) != factoryMapIn.end()) {
279  TEUCHOS_TEST_FOR_EXCEPTION((param.isList() && (++paramList.begin() != paramList.end())), Exceptions::RuntimeError,
280  "MueLu::FactoryFactory: Error during the parsing of: " << std::endl << paramList << std::endl
281  << "'" << factoryName << "' is not a factory name but an existing instance of a factory." << std::endl
282  << "Extra parameters cannot be specified after the creation of the object." << std::endl << std::endl
283  << "Correct syntaxes includes:" << std::endl
284  << " <Parameter name=\"...\" type=\"string\" value=\"" << factoryName << "\"/>" << std::endl
285  << "or" << std::endl
286  << " <ParameterList name=\"...\"><Parameter name=\"factory\" type=\"string\" value=\"" << factoryName << "\"/></ParameterList>" << std::endl
287  );
288 
289  return factoryMapIn.find(factoryName)->second;
290  }
291 
292  TEUCHOS_TEST_FOR_EXCEPTION(true, Exceptions::RuntimeError, "MueLu::FactoryFactory: unknown factory name : " << factoryName);
293 
294  return Teuchos::null;
295  }
296 
297  //
298  //
299  //
300 
301  // FOLLOWING FUNCTIONS SHOULD LIVE WITH THE CORRESPONDING CLASS
302 
303  //
304  //
305  //
306 
307 #define arraysize(ar) (sizeof(ar) / sizeof(ar[0]))
308 
309  template <class T> // T must implement the Factory interface
310  RCP<T> Build(const Teuchos::ParameterList& paramList, const FactoryMap& factoryMapIn, const FactoryManagerMap& factoryManagersIn) const {
311  RCP<T> factory = rcp(new T());
312 
313  const char* strarray[] = {"A", "P", "R", "Graph", "UnAmalgamationInfo", "Aggregates", "Nullspace", "TransferFactory", "DofsPerNode"};
314  std::vector<std::string> v(strarray, strarray + arraysize(strarray));
315  for (size_t i = 0; i < v.size(); ++i)
316  if (paramList.isParameter(v[i]))
317  factory->SetFactory(v[i], BuildFactory(paramList.getEntry(v[i]), factoryMapIn, factoryManagersIn));
318 
319  return factory;
320  }
321 
322  template <class T> // T must implement the Factory interface
323  RCP<T> Build2(const Teuchos::ParameterList& paramList, const FactoryMap& factoryMapIn, const FactoryManagerMap& factoryManagersIn) const {
324  RCP<T> factory = rcp(new T());
325 
326  ParameterList paramListWithFactories;
327 
328  // Read the RCP<Factory> parameters of the class T
329  RCP<const ParameterList> validParamList = factory->GetValidParameterList();
330  for (ParameterList::ConstIterator param = validParamList->begin(); param != validParamList->end(); ++param) {
331  const std::string& pName = validParamList->name(param);
332 
333  if (!paramList.isParameter(pName)) {
334  // Ignore unknown parameters
335  continue;
336  }
337 
338  if (validParamList->isType< RCP<const FactoryBase> >(pName)) {
339  // Generate or get factory described by param
340  RCP<const FactoryBase> generatingFact = BuildFactory(paramList.getEntry(pName), factoryMapIn, factoryManagersIn);
341  paramListWithFactories.set(pName, generatingFact);
342  } else if (validParamList->isType<RCP<const ParameterList> >(pName)) {
343  if (pName == "ParameterList") {
344  // NOTE: we cannot use
345  // subList = sublist(rcpFromRef(paramList), pName)
346  // here as that would result in sublist also being a reference to a temporary object.
347  // The resulting dereferencing in the corresponding factory would then segfault
348  RCP<const ParameterList> subList = Teuchos::sublist(rcp(new ParameterList(paramList)), pName);
349  paramListWithFactories.set(pName, subList);
350  }
351  } else {
352  paramListWithFactories.setEntry(pName, paramList.getEntry(pName));
353  }
354  }
355 
356  // Configure the factory
357  factory->SetParameterList(paramListWithFactories);
358 
359  return factory;
360  }
361 
362  template <class T> // T must implement the Factory interface
363  RCP<T> BuildRAPFactory(const Teuchos::ParameterList & paramList, const FactoryMap& factoryMapIn, const FactoryManagerMap& factoryManagersIn) const {
364  RCP<T> factory;
365  if (paramList.isSublist("TransferFactories") == false) {
366  factory = Build2<T>(paramList, factoryMapIn, factoryManagersIn);
367 
368  } else {
369  RCP<Teuchos::ParameterList> paramListNonConst = rcp(new Teuchos::ParameterList(paramList));
370  RCP<const Teuchos::ParameterList> transferFactories = rcp(new Teuchos::ParameterList(*sublist(paramListNonConst, "TransferFactories")));
371 
372  paramListNonConst->remove("TransferFactories");
373 
374  factory = Build2<T>(*paramListNonConst, factoryMapIn, factoryManagersIn);
375 
376  for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
377  RCP<const FactoryBase> p = BuildFactory(transferFactories->entry(param), factoryMapIn, factoryManagersIn);
378  factory->AddTransferFactory(p);
379  }
380  }
381 
382  return factory;
383  }
384 
385  template <class T> // T must implement the Factory interface
386  RCP<T> BuildTogglePFactory(const Teuchos::ParameterList & paramList, const FactoryMap& factoryMapIn, const FactoryManagerMap& factoryManagersIn) const {
387  RCP<T> factory;
388  if (paramList.isSublist("TransferFactories") == false) {
389  //TODO put in an error message: the TogglePFactory needs a TransferFactories sublist!
390  factory = Build2<T>(paramList, factoryMapIn, factoryManagersIn);
391 
392  } else {
393  RCP<Teuchos::ParameterList> paramListNonConst = rcp(new Teuchos::ParameterList(paramList));
394  RCP<const Teuchos::ParameterList> transferFactories = rcp(new Teuchos::ParameterList(*sublist(paramListNonConst, "TransferFactories")));
395 
396  paramListNonConst->remove("TransferFactories");
397 
398  // build TogglePFactory
399  factory = Build2<T>(*paramListNonConst, factoryMapIn, factoryManagersIn);
400 
401  // count how many prolongation factories and how many coarse null space factories have been declared.
402  // the numbers must match!
403  int numProlongatorFactories = 0;
404  int numPtentFactories = 0;
405  int numCoarseNspFactories = 0;
406  for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
407  size_t foundNsp = transferFactories->name(param).find("Nullspace");
408  if (foundNsp != std::string::npos && foundNsp == 0 && transferFactories->name(param).length()==10) {
409  numCoarseNspFactories++;
410  continue;
411  }
412  size_t foundPtent = transferFactories->name(param).find("Ptent");
413  if (foundPtent != std::string::npos && foundPtent == 0 && transferFactories->name(param).length()==6) {
414  numPtentFactories++;
415  continue;
416  }
417  size_t foundP = transferFactories->name(param).find("P");
418  if (foundP != std::string::npos && foundP == 0 && transferFactories->name(param).length()==2) {
419  numProlongatorFactories++;
420  continue;
421  }
422  }
423  TEUCHOS_TEST_FOR_EXCEPTION(numProlongatorFactories!=numCoarseNspFactories, Exceptions::RuntimeError, "FactoryFactory::BuildToggleP: The user has to provide the same number of prolongator and coarse nullspace factories!");
424  TEUCHOS_TEST_FOR_EXCEPTION(numPtentFactories!=numCoarseNspFactories, Exceptions::RuntimeError, "FactoryFactory::BuildToggleP: The user has to provide the same number of ptent and coarse nullspace factories!");
425  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.");
426 
427  // create empty vectors with data
428  std::vector<Teuchos::ParameterEntry> prolongatorFactoryNames(numProlongatorFactories);
429  std::vector<Teuchos::ParameterEntry> coarseNspFactoryNames(numProlongatorFactories);
430  std::vector<Teuchos::ParameterEntry> ptentFactoryNames(numProlongatorFactories);
431 
432  for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
433  size_t foundNsp = transferFactories->name(param).find("Nullspace");
434  if (foundNsp != std::string::npos && foundNsp == 0 && transferFactories->name(param).length()==10) {
435  int number = atoi(&(transferFactories->name(param).at(9)));
436  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!");
437  coarseNspFactoryNames[number-1] = transferFactories->entry(param);
438  continue;
439  }
440  size_t foundPtent = transferFactories->name(param).find("Ptent");
441  if (foundPtent != std::string::npos && foundPtent == 0 && transferFactories->name(param).length()==6) {
442  int number = atoi(&(transferFactories->name(param).at(5)));
443  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!");
444  ptentFactoryNames[number-1] = transferFactories->entry(param);
445  continue;
446  }
447  size_t foundP = transferFactories->name(param).find("P");
448  if (foundP != std::string::npos && foundP == 0 && transferFactories->name(param).length()==2) {
449  int number = atoi(&(transferFactories->name(param).at(1)));
450  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!");
451  prolongatorFactoryNames[number-1] = transferFactories->entry(param);
452  continue;
453  }
454  }
455 
456  // register all prolongation factories in TogglePFactory
457  for (std::vector<Teuchos::ParameterEntry>::const_iterator it = prolongatorFactoryNames.begin(); it != prolongatorFactoryNames.end(); ++it) {
458  RCP<const FactoryBase> p = BuildFactory(*it, factoryMapIn, factoryManagersIn);
459  factory->AddProlongatorFactory(p);
460  }
461 
462  // register all tentative prolongation factories in TogglePFactory
463  for (std::vector<Teuchos::ParameterEntry>::const_iterator it = ptentFactoryNames.begin(); it != ptentFactoryNames.end(); ++it) {
464  RCP<const FactoryBase> p = BuildFactory(*it, factoryMapIn, factoryManagersIn);
465  factory->AddPtentFactory(p);
466  }
467 
468  // register all coarse nullspace factories in TogglePFactory
469  for (std::vector<Teuchos::ParameterEntry>::const_iterator it = coarseNspFactoryNames.begin(); it != coarseNspFactoryNames.end(); ++it) {
470  RCP<const FactoryBase> p = BuildFactory(*it, factoryMapIn, factoryManagersIn);
471  factory->AddCoarseNullspaceFactory(p);
472  }
473  }
474  return factory;
475  }
476 
477  RCP<ToggleCoordinatesTransferFactory> BuildToggleCoordinatesTransferFactory(const Teuchos::ParameterList & paramList, const FactoryMap& factoryMapIn, const FactoryManagerMap& factoryManagersIn) const {
478  RCP<ToggleCoordinatesTransferFactory> factory;
479  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!");
480 
481  RCP<Teuchos::ParameterList> paramListNonConst = rcp(new Teuchos::ParameterList(paramList));
482  RCP<const Teuchos::ParameterList> transferFactories = rcp(new Teuchos::ParameterList(*sublist(paramListNonConst, "TransferFactories")));
483  paramListNonConst->remove("TransferFactories");
484 
485  // build CoordinatesTransferFactory
486  factory = Build2<ToggleCoordinatesTransferFactory>(*paramListNonConst, factoryMapIn, factoryManagersIn);
487 
488  // count how many coordinate transfer factories have been declared.
489  // the numbers must match!
490  int numCoordTransferFactories = 0;
491  for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
492  size_t foundCoordinates = transferFactories->name(param).find("Coordinates");
493  if (foundCoordinates != std::string::npos && foundCoordinates == 0 && transferFactories->name(param).length()==12) {
494  numCoordTransferFactories++;
495  continue;
496  }
497  }
498  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.");
499 
500  // create empty vectors with data
501  std::vector<Teuchos::ParameterEntry> coarseCoordsFactoryNames(numCoordTransferFactories);
502 
503  for (Teuchos::ParameterList::ConstIterator param = transferFactories->begin(); param != transferFactories->end(); ++param) {
504  size_t foundCoords = transferFactories->name(param).find("Coordinates");
505  if (foundCoords != std::string::npos && foundCoords == 0 && transferFactories->name(param).length()==12) {
506  int number = atoi(&(transferFactories->name(param).at(11)));
507  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!");
508  coarseCoordsFactoryNames[number-1] = transferFactories->entry(param);
509  continue;
510  }
511  }
512 
513  // register all coarse nullspace factories in TogglePFactory
514  for (std::vector<Teuchos::ParameterEntry>::const_iterator it = coarseCoordsFactoryNames.begin(); it != coarseCoordsFactoryNames.end(); ++it) {
515  RCP<const FactoryBase> p = BuildFactory(*it, factoryMapIn, factoryManagersIn);
516  factory->AddCoordTransferFactory(p);
517  }
518 
519  return factory;
520  }
521 
523  RCP<FactoryBase> BuildCoupledAggregationFactory(const Teuchos::ParameterList& paramList, const FactoryMap& factoryMapIn, const FactoryManagerMap& factoryManagersIn) const {
524  RCP<CoupledAggregationFactory> factory = Build<CoupledAggregationFactory>(paramList, factoryMapIn, factoryManagersIn);
525 
526  if (paramList.isParameter("aggregation: ordering"))
527  factory->SetOrdering(paramList.get<std::string>("aggregation: ordering"));
528 
529  if (paramList.isParameter("aggregation: max selected neighbors"))
530  factory->SetMaxNeighAlreadySelected(paramList.get<int>("aggregation: max selected neighbors"));
531 
532  if (paramList.isParameter("Phase3AggCreation"))
533  factory->SetPhase3AggCreation(paramList.get<double>("Phase3AggCreation"));
534 
535  if(paramList.isParameter("aggregation: min agg size"))
536  factory->SetMinNodesPerAggregate(paramList.get<int>("aggregation: min agg size"));
537 
538  return factory;
539  }
540 
542  RCP<FactoryBase> BuildUncoupledAggregationFactory(const Teuchos::ParameterList & paramList, const FactoryMap & factoryMapIn, const FactoryManagerMap& factoryManagersIn) const {
543  RCP<UncoupledAggregationFactory> factory = Build<UncoupledAggregationFactory>(paramList, factoryMapIn, factoryManagersIn);
544 
545  ParameterList paramListWithFactories(paramList); // copy (*might* also avoid indicating that parameter entry is used)
546  paramListWithFactories.remove("factory", false);
547 
548  // Read the RCP<Factory> parameters of the class T
549  RCP<const ParameterList> validParamList = factory->GetValidParameterList();
550  for (ParameterList::ConstIterator param = validParamList->begin(); param != validParamList->end(); ++param) {
551  const std::string & pName = validParamList->name(param);
552 
553  if (validParamList->isType< RCP<const FactoryBase> >(pName) && paramList.isParameter(pName)) {
554  // Generate or get factory described by param
555  RCP<const FactoryBase> generatingFact = BuildFactory(paramList.getEntry(pName), factoryMapIn, factoryManagersIn);
556 
557  // Replace <std::string> or sub-list entry by an RCP<Factory> in paramListWithFactories
558  paramListWithFactories.remove(pName);
559  paramListWithFactories.set(pName, generatingFact);
560  }
561 
562  if (pName == "ParameterList" && validParamList->isType<RCP<const ParameterList> >(pName) && paramList.isParameter(pName)) {
563  // NOTE: we cannot use
564  // subList = sublist(rcpFromRef(paramList), pName)
565  // here as that would result in sublist also being a reference to a temporary object.
566  // The resulting dereferencing in the corresponding factory would then segfault
567  RCP<const ParameterList> subList = Teuchos::sublist(rcp(new ParameterList(paramList)), pName);
568  paramListWithFactories.set(pName, subList);
569  }
570  }
571 
572  // Configure the factory
573  factory->SetParameterList(paramListWithFactories);
574 
575  return factory;
576  }
577 
579  // Parameter List Parsing:
580  // <ParameterList name="smootherFact1">
581  // <Parameter name="factory" type="string" value="TrilinosSmoother"/>
582  // <Parameter name="verbose" type="string" value="Warnings"/>
583  // <Parameter name="type" type="string" value="RELAXATION"/>
584  // <ParameterList name="ParameterList">
585  // ...
586  // </ParameterList>
587  // </ParameterList>
588  RCP<FactoryBase> BuildTrilinosSmoother(const Teuchos::ParameterList & paramList, const FactoryMap & factoryMapIn, const FactoryManagerMap& factoryManagersIn) const {
589  if (paramList.begin() == paramList.end())
590  return rcp(new SmootherFactory(rcp(new TrilinosSmoother())));
591 
592  TEUCHOS_TEST_FOR_EXCEPTION(paramList.get<std::string>("factory") != "TrilinosSmoother", Exceptions::RuntimeError, "");
593 
594  // Is it true? TEUCHOS_TEST_FOR_EXCEPTION(!paramList.isParameter("type"), Exceptions::RuntimeError, "TrilinosSmoother: parameter 'type' is mandatory");
595  // type="" is default in TrilinosSmoother, but what happen then?
596 
597  std::string type=""; if(paramList.isParameter("type")) type = paramList.get<std::string>("type");
598  int overlap=0; if(paramList.isParameter("overlap")) overlap = paramList.get<int> ("overlap");
599  // std::string verbose; if(paramList.isParameter("verbose")) verbose = paramList.get<std::string>("verbose");
600  Teuchos::ParameterList params; if(paramList.isParameter("ParameterList")) params = paramList.get<Teuchos::ParameterList>("ParameterList");
601 
602  // Read in factory information for smoothers (if available...)
603  // NOTE: only a selected number of factories can be used with the Trilinos smoother
604  // smoothers usually work with the global data available (which is A and the transfers P and R)
605 
606  Teuchos::RCP<TrilinosSmoother> trilSmoo = Teuchos::rcp(new TrilinosSmoother(type, params, overlap));
607 
608  if (paramList.isParameter("LineDetection_Layers")) {
609  RCP<const FactoryBase> generatingFact = BuildFactory(paramList.getEntry("LineDetection_Layers"), factoryMapIn, factoryManagersIn);
610  trilSmoo->SetFactory("LineDetection_Layers", generatingFact);
611  }
612  if (paramList.isParameter("LineDetection_VertLineIds")) {
613  RCP<const FactoryBase> generatingFact = BuildFactory(paramList.getEntry("LineDetection_Layers"), factoryMapIn, factoryManagersIn);
614  trilSmoo->SetFactory("LineDetection_Layers", generatingFact);
615  }
616  if (paramList.isParameter("CoarseNumZLayers")) {
617  RCP<const FactoryBase> generatingFact = BuildFactory(paramList.getEntry("CoarseNumZLayers"), factoryMapIn, factoryManagersIn);
618  trilSmoo->SetFactory("CoarseNumZLayers", generatingFact);
619  }
620 
621  return rcp(new SmootherFactory(trilSmoo));
622  }
623 
624 #ifdef HAVE_MUELU_MATLAB
625  // Parameter List Parsing:
627  // <ParameterList name="smootherFact1">
628  // <Parameter name="factory" type="string" value="MatlabSmoother"/>
629  // <Parameter name="Setup Function" type="string" value="mySmootherSetup.m"/>
630  // <Parameter name="Solve Function" type="string" value="mySmootherSolve.m"/>
631  // <!--A is implicitly included in this list and nothing else is needed to get diagonal-->
632  // <Parameter name="Needs" type="string" value=""/>
633  // <!--A,x,b are also assumed inputs to the solver: only one additional arg then (diag)-->
634  // <Parameter name="Number of Solver Args" type="int" value="1"/>
635  // </ParameterList>
636  RCP<FactoryBase> BuildMatlabSmoother(const Teuchos::ParameterList & paramList, const FactoryMap & factoryMapIn, const FactoryManagerMap& factoryManagersIn) const {
637  if (paramList.begin() == paramList.end())
638  return rcp(new SmootherFactory(rcp(new MatlabSmoother())));
639 
640  TEUCHOS_TEST_FOR_EXCEPTION(paramList.get<std::string>("factory") != "MatlabSmoother", Exceptions::RuntimeError, "");
641 
642  // Read in factory information for smoothers (if available...)
643  // NOTE: only a selected number of factories can be used with the Trilinos smoother
644  // smoothers usually work with the global data available (which is A and the transfers P and R)
645 
646  Teuchos::RCP<MatlabSmoother> matSmoo = Teuchos::rcp(new MatlabSmoother(paramList));
647 
648  return rcp(new SmootherFactory(matSmoo));
649  }
650 #endif
651 
652  RCP<FactoryBase> BuildDirectSolver(const Teuchos::ParameterList& paramList, const FactoryMap& factoryMapIn, const FactoryManagerMap& factoryManagersIn) const {
653  if (paramList.begin() == paramList.end())
654  return rcp(new SmootherFactory(rcp(new DirectSolver()), Teuchos::null));
655 
656  TEUCHOS_TEST_FOR_EXCEPTION(paramList.get<std::string>("factory") != "DirectSolver", Exceptions::RuntimeError, "");
657 
658  std::string type; if(paramList.isParameter("type")) type = paramList.get<std::string>("type");
659  // std::string verbose; if(paramList.isParameter("verbose")) verbose = paramList.get<std::string>("verbose");
660  Teuchos::ParameterList params; if(paramList.isParameter("ParameterList")) params = paramList.get<Teuchos::ParameterList>("ParameterList");
661 
662  return rcp(new SmootherFactory(rcp(new DirectSolver(type, params)), Teuchos::null));
663  }
664 
665 #ifdef HAVE_MUELU_EXPERIMENTAL
666  template <class T> // T must implement the Factory interface
667  RCP<FactoryBase> BuildBlockedSmoother(const Teuchos::ParameterList& paramList, const FactoryMap& factoryMapIn, const FactoryManagerMap& factoryManagersIn) const {
668  // read in sub lists
669  RCP<ParameterList> paramListNonConst = rcp(new ParameterList(paramList));
670 
671  // internal vector of factory managers
672  std::vector<RCP<FactoryManager> > facManagers;
673 
674  // loop over all "block%i" sublists in parameter list
675  int blockid = 1;
676  bool blockExists = true;
677  while (blockExists == true) {
678  std::stringstream ss;
679  ss << "block" << blockid;
680 
681  if(paramList.isSublist(ss.str()) == true) {
682  // we either have a parameter group or we have a list of factories in here
683  RCP<const ParameterList> b = rcp(new ParameterList(*sublist(paramListNonConst, ss.str())));
684 
685  RCP<FactoryManager> M = Teuchos::null;
686 
687  if (b->isParameter("group")) {
688  // use a factory manager
689  std::string facManagerName = b->get< std::string >("group");
690  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.");
691  RCP<FactoryManagerBase> Mb = factoryManagersIn.find(facManagerName)->second;
692  M = Teuchos::rcp_dynamic_cast<FactoryManager>(Mb);
693  TEUCHOS_TEST_FOR_EXCEPTION(M==Teuchos::null, Exceptions::RuntimeError, "Failed to cast FactoryManagerBase object to FactoryManager.");
694  } else {
695  // read in the list of factories
696  M = rcp(new FactoryManager());
697  for (ParameterList::ConstIterator param = b->begin(); param != b->end(); ++param) {
698  RCP<const FactoryBase> p = BuildFactory(b->entry(param), factoryMapIn, factoryManagersIn);
699  M->SetFactory(b->name(param),p);
700  }
701  }
702 
703  // add factory manager to internal vector of factory managers
704  M->SetIgnoreUserData(true);
705  facManagers.push_back(M);
706  paramListNonConst->remove(ss.str());
707  blockid++;
708  } else {
709  blockExists = false;
710  break;
711  }
712 
713  }
714 
715  // create a new blocked smoother
716  RCP<T> bs = Build2<T>(*paramListNonConst, factoryMapIn, factoryManagersIn);
717 
718  // important: set block factory for A here! TODO think about this in more detail
719  bs->SetFactory("A", MueLu::NoFactory::getRCP());
720 
721  for (int i = 0; i<Teuchos::as<int>(facManagers.size()); i++) {
722  bs->AddFactoryManager(facManagers[i],i);
723  }
724 
725  return rcp(new SmootherFactory(bs));
726  }
727 
728  RCP<FactoryBase> BuildBlockedDirectSolver(const Teuchos::ParameterList& paramList, const FactoryMap& factoryMapIn, const FactoryManagerMap& factoryManagersIn) const {
729  //if (paramList.begin() == paramList.end())
730  return rcp(new SmootherFactory(rcp(new BlockedDirectSolver())));
731 
732  /*TEUCHOS_TEST_FOR_EXCEPTION(paramList.get<std::string>("factory") != "DirectSolver", Exceptions::RuntimeError, "");
733 
734  std::string type; if(paramList.isParameter("type")) type = paramList.get<std::string>("type");
735  // std::string verbose; if(paramList.isParameter("verbose")) verbose = paramList.get<std::string>("verbose");
736  Teuchos::ParameterList params; if(paramList.isParameter("ParameterList")) params = paramList.get<Teuchos::ParameterList>("ParameterList");
737 
738  return rcp(new SmootherFactory(rcp(new DirectSolver(type, params))));*/
739  }
740 
741  RCP<FactoryBase> BuildBlockedPFactory(const Teuchos::ParameterList& paramList, const FactoryMap& factoryMapIn, const FactoryManagerMap& factoryManagersIn) const {
742  RCP<BlockedPFactory> pfac = rcp(new BlockedPFactory());
743 
744  // read in sub lists
745  RCP<ParameterList> paramListNonConst = rcp(new ParameterList(paramList));
746 
747  // internal vector of factory managers
748  std::vector<RCP<FactoryManager> > facManagers;
749 
750  // loop over all "block%i" sublists in parameter list
751  int blockid = 1;
752  bool blockExists = true;
753  while (blockExists == true) {
754  std::stringstream ss;
755  ss << "block" << blockid;
756 
757  if(paramList.isSublist(ss.str()) == true) {
758  // we either have a parameter group or we have a list of factories in here
759  RCP<const ParameterList> b = rcp(new ParameterList(*sublist(paramListNonConst, ss.str())));
760 
761  RCP<FactoryManager> M = Teuchos::null;
762 
763  if (b->isParameter("group")) {
764  // use a factory manager
765  std::string facManagerName = b->get< std::string >("group");
766  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.");
767  RCP<FactoryManagerBase> Mb = factoryManagersIn.find(facManagerName)->second;
768  M = Teuchos::rcp_dynamic_cast<FactoryManager>(Mb);
769  TEUCHOS_TEST_FOR_EXCEPTION(M==Teuchos::null, Exceptions::RuntimeError, "Failed to cast FactoryManagerBase object to FactoryManager.");
770  } else {
771  // read in the list of factories
772  M = rcp(new FactoryManager());
773  for (ParameterList::ConstIterator param = b->begin(); param != b->end(); ++param) {
774  RCP<const FactoryBase> p = BuildFactory(b->entry(param), factoryMapIn, factoryManagersIn);
775  M->SetFactory(b->name(param),p);
776  }
777  }
778 
779  // add factory manager to internal vector of factory managers
780  M->SetIgnoreUserData(true);
781  facManagers.push_back(M);
782  paramListNonConst->remove(ss.str());
783  blockid++;
784  } else {
785  blockExists = false;
786  break;
787  }
788 
789  }
790 
791  // build BlockedPFactory (without sub block information)
792  pfac = Build2<BlockedPFactory>(*paramListNonConst, factoryMapIn, factoryManagersIn);
793 
794  // add FactoryManager objects
795  for(size_t i = 0; i<facManagers.size(); i++) {
796  pfac->AddFactoryManager(facManagers[i]); // add factory manager
797  }
798 
799  return pfac;
800  }
801 #endif /* #ifdef HAVE_MUELU_EXPERIMENTAL */
802  }; // class
803 } // namespace MueLu
804 
805 #define MUELU_FACTORYFACTORY_SHORT
806 #endif // MUELU_FACTORYFACTORY_DECL_HPP
807 
808  // TODO: handle factory parameters
809  // TODO: parameter validator
810  // TODO: static
811  // TODO: default parameters should not be duplicated here and on the Factory (ex: default for overlap (=0) is defined both here and on TrilinosSmoother constructors)
Generic Smoother Factory for generating the smoothers of the MG hierarchy.
RCP< FactoryBase > BuildBlockedPFactory(const Teuchos::ParameterList &paramList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
This class specifies the default factory that should generate some data on a Level if the data does n...
RCP< T > Build(const Teuchos::ParameterList &paramList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
Factory for building blocked, segregated prolongation operators.
Factory that can generate other factories from.
RCP< FactoryBase > BuildUncoupledAggregationFactory(const Teuchos::ParameterList &paramList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
UncoupledAggregationFactory.
RCP< T > Build2(const Teuchos::ParameterList &paramList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
Class that encapsulates external library smoothers.
RCP< ToggleCoordinatesTransferFactory > BuildToggleCoordinatesTransferFactory(const Teuchos::ParameterList &paramList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
RCP< FactoryBase > BuildBlockedSmoother(const Teuchos::ParameterList &paramList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
Namespace for MueLu classes and methods.
RCP< FactoryBase > BuildMatlabSmoother(const Teuchos::ParameterList &paramList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
MatlabSmoother.
virtual RCP< const FactoryBase > BuildFactory(const Teuchos::ParameterEntry &param, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
Class that encapsulates direct solvers. Autoselection of AmesosSmoother or Amesos2Smoother according ...
#define arraysize(ar)
RCP< T > BuildTogglePFactory(const Teuchos::ParameterList &paramList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
std::map< std::string, RCP< FactoryManagerBase > > FactoryManagerMap
std::map< std::string, RCP< const FactoryBase > > FactoryMap
RCP< FactoryBase > BuildTrilinosSmoother(const Teuchos::ParameterList &paramList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
TrilinosSmoother.
RCP< T > BuildRAPFactory(const Teuchos::ParameterList &paramList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
direct solver for nxn blocked matrices
Base class for MueLu classes.
RCP< FactoryBase > BuildBlockedDirectSolver(const Teuchos::ParameterList &paramList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
Class that encapsulates Matlab smoothers.
RCP< FactoryBase > BuildDirectSolver(const Teuchos::ParameterList &paramList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
Exception throws to report errors in the internal logical of the program.
RCP< FactoryBase > BuildCoupledAggregationFactory(const Teuchos::ParameterList &paramList, const FactoryMap &factoryMapIn, const FactoryManagerMap &factoryManagersIn) const
CoupledAggregationFactory.
static const RCP< const NoFactory > getRCP()
Static Get() functions.