MueLu  Version of the Day
MueLu_AdaptiveSaMLParameterListInterpreter_def.hpp
Go to the documentation of this file.
1 /*
2  * MueLu_AdaptiveSaMLParamterListInterpreter_def.hpp
3  *
4  * Created on: Jan 28, 2013
5  * Author: tobias
6  */
7 
8 #ifndef MUELU_ADAPTIVESAMLPARAMETERLISTINTERPRETER_DEF_HPP_
9 #define MUELU_ADAPTIVESAMLPARAMETERLISTINTERPRETER_DEF_HPP_
10 
12 
13 #include "MueLu_ConfigDefs.hpp"
14 #if defined(HAVE_MUELU_ML) && defined(HAVE_MUELU_EPETRA)
15 #include <ml_ValidateParameters.h>
16 #endif
17 
18 #include <Xpetra_Matrix.hpp>
19 #include <Xpetra_MultiVector.hpp>
20 #include <Xpetra_MultiVectorFactory.hpp>
21 #include <Xpetra_Operator.hpp>
22 #include <Xpetra_IO.hpp>
23 
25 
26 #include "MueLu_Level.hpp"
27 #include "MueLu_Hierarchy.hpp"
28 #include "MueLu_FactoryManager.hpp"
29 
30 #include "MueLu_TentativePFactory.hpp"
31 #include "MueLu_SaPFactory.hpp"
32 #include "MueLu_PgPFactory.hpp"
33 #include "MueLu_TransPFactory.hpp"
34 #include "MueLu_GenericRFactory.hpp"
35 #include "MueLu_SmootherPrototype.hpp"
36 #include "MueLu_SmootherFactory.hpp"
37 #include "MueLu_TrilinosSmoother.hpp"
38 #include "MueLu_IfpackSmoother.hpp"
39 #include "MueLu_DirectSolver.hpp"
40 #include "MueLu_HierarchyUtils.hpp"
41 #include "MueLu_RAPFactory.hpp"
42 #include "MueLu_CoalesceDropFactory.hpp"
43 #include "MueLu_CoupledAggregationFactory.hpp"
44 #include "MueLu_UncoupledAggregationFactory.hpp"
45 #include "MueLu_NullspaceFactory.hpp"
47 #include "MueLu_MLParameterListInterpreter.hpp"
48 
49 //#include "MueLu_Utilities.hpp"
50 
52 
53 // Note: do not add options that are only recognized by MueLu.
54 
55 // TODO: this parameter list interpreter should force MueLu to use default ML parameters
56 // - Ex: smoother sweep=2 by default for ML
57 
58 // Read a parameter value from a parameter list and store it into a variable named 'varName'
59 #define MUELU_READ_PARAM(paramList, paramStr, varType, defaultValue, varName) \
60  varType varName = defaultValue; if (paramList.isParameter(paramStr)) varName = paramList.get<varType>(paramStr);
61 
62 // Read a parameter value from a paraeter list and copy it into a new parameter list (with another parameter name)
63 #define MUELU_COPY_PARAM(paramList, paramStr, varType, defaultValue, outParamList, outParamStr) \
64  if (paramList.isParameter(paramStr)) \
65  outParamList.set<varType>(outParamStr, paramList.get<varType>(paramStr)); \
66  else outParamList.set<varType>(outParamStr, defaultValue); \
67 
68 namespace MueLu {
69 
70  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
72  SetParameterList(paramList);
73  }
74 
75  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
76  AdaptiveSaMLParameterListInterpreter<Scalar, LocalOrdinal, GlobalOrdinal, Node>::AdaptiveSaMLParameterListInterpreter(const std::string & xmlFileName, std::vector<RCP<FactoryBase> > factoryList) : nullspace_(NULL), TransferFacts_(factoryList), blksize_(1) {
77  Teuchos::RCP<Teuchos::ParameterList> paramList = Teuchos::getParametersFromXmlFile(xmlFileName);
78  SetParameterList(*paramList);
79  }
80 
81  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
83  Teuchos::ParameterList paramList = paramList_in;
84 
85  RCP<Teuchos::FancyOStream> out = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout)); // TODO: use internal out (GetOStream())
86 
87  //
88  // Read top-level of the parameter list
89  //
90 
91  // hard-coded default values == ML defaults according to the manual
92  MUELU_READ_PARAM(paramList, "ML output", int, 0, verbosityLevel);
93  MUELU_READ_PARAM(paramList, "max levels", int, 10, maxLevels);
94  MUELU_READ_PARAM(paramList, "PDE equations", int, 1, nDofsPerNode);
95 
96  MUELU_READ_PARAM(paramList, "coarse: max size", int, 128, maxCoarseSize);
97 
98  MUELU_READ_PARAM(paramList, "aggregation: type", std::string, "Uncoupled", agg_type);
99  //MUELU_READ_PARAM(paramList, "aggregation: threshold", double, 0.0, agg_threshold);
100  MUELU_READ_PARAM(paramList, "aggregation: damping factor", double, (double)4/(double)3, agg_damping);
101  //MUELU_READ_PARAM(paramList, "aggregation: smoothing sweeps", int, 1, agg_smoothingsweeps);
102  MUELU_READ_PARAM(paramList, "aggregation: nodes per aggregate", int, 1, minPerAgg);
103 
104  MUELU_READ_PARAM(paramList, "null space: type", std::string, "default vectors", nullspaceType);
105  MUELU_READ_PARAM(paramList, "null space: dimension", int, -1, nullspaceDim); // TODO: ML default not in documentation
106  MUELU_READ_PARAM(paramList, "null space: vectors", double*, NULL, nullspaceVec); // TODO: ML default not in documentation
107 
108  MUELU_READ_PARAM(paramList, "energy minimization: enable", bool, false, bEnergyMinimization);
109 
110 
111  //
112  // Move smoothers/aggregation/coarse parameters to sublists
113  //
114 
115  // ML allows to have level-specific smoothers/aggregation/coarse parameters at the top level of the list or/and defined in sublists:
116  // See also: ML Guide section 6.4.1, MueLu::CreateSublists, ML_CreateSublists
117  ParameterList paramListWithSubList;
118  MueLu::CreateSublists(paramList, paramListWithSubList);
119  paramList = paramListWithSubList; // swap
120 
121  // std::cout << std::endl << "Parameter list after CreateSublists" << std::endl;
122  // std::cout << paramListWithSubList << std::endl;
123 
124  int maxNbrAlreadySelected = 0;
125 
126  // Matrix option
127  this->blksize_ = nDofsPerNode;
128 
129  // Translate verbosity parameter
131  if (verbosityLevel == 0) eVerbLevel = Teuchos::VERB_NONE;
132  if (verbosityLevel > 0) eVerbLevel = Teuchos::VERB_LOW;
133  if (verbosityLevel > 4) eVerbLevel = Teuchos::VERB_MEDIUM;
134  if (verbosityLevel > 7) eVerbLevel = Teuchos::VERB_HIGH;
135  if (verbosityLevel > 9) eVerbLevel = Teuchos::VERB_EXTREME;
136 
137  TEUCHOS_TEST_FOR_EXCEPTION(agg_type != "Uncoupled" && agg_type != "Coupled", Exceptions::RuntimeError, "MueLu::MLParameterListInterpreter::Setup(): parameter \"aggregation: type\": only 'Uncoupled' or 'Coupled' aggregation is supported.");
138 
139  // Create MueLu factories
140  // RCP<NullspaceFactory> nspFact = rcp(new NullspaceFactory());
142  //dropFact->SetVerbLevel(toMueLuVerbLevel(eVerbLevel));
143 
144  RCP<FactoryBase> CoupledAggFact = Teuchos::null;
145  if(agg_type == "Uncoupled") {
146  // Uncoupled aggregation
148  CoupledAggFact2->SetMinNodesPerAggregate(minPerAgg); //TODO should increase if run anything other than 1D
149  CoupledAggFact2->SetMaxNeighAlreadySelected(maxNbrAlreadySelected);
150  CoupledAggFact2->SetOrdering("natural");
151  CoupledAggFact = CoupledAggFact2;
152  } else {
153  // Coupled Aggregation (default)
155  CoupledAggFact2->SetMinNodesPerAggregate(minPerAgg); //TODO should increase if run anything other than 1D
156  CoupledAggFact2->SetMaxNeighAlreadySelected(maxNbrAlreadySelected);
157  CoupledAggFact2->SetOrdering("natural");
158  CoupledAggFact2->SetPhase3AggCreation(0.5);
159  CoupledAggFact = CoupledAggFact2;
160  }
161  if (verbosityLevel > 3) { // TODO fix me: Setup is a static function: we cannot use GetOStream without an object...
162  *out << "========================= Aggregate option summary  =========================" << std::endl;
163  *out << "min Nodes per aggregate :              " << minPerAgg << std::endl;
164  *out << "min # of root nbrs already aggregated : " << maxNbrAlreadySelected << std::endl;
165  *out << "aggregate ordering :                    natural" << std::endl;
166  *out << "=============================================================================" << std::endl;
167  }
168 
169  RCP<Factory> PFact;
170  RCP<Factory> RFact;
171  RCP<Factory> PtentFact = rcp( new TentativePFactory() );
172  if (agg_damping == 0.0 && bEnergyMinimization == false) {
173  // tentative prolongation operator (PA-AMG)
174  PFact = PtentFact;
175  RFact = rcp( new TransPFactory() );
176  } else if (agg_damping != 0.0 && bEnergyMinimization == false) {
177  // smoothed aggregation (SA-AMG)
178  RCP<SaPFactory> SaPFact = rcp( new SaPFactory() );
179  SaPFact->SetParameter("sa: damping factor", ParameterEntry(agg_damping));
180  PFact = SaPFact;
181  RFact = rcp( new TransPFactory() );
182  } else if (bEnergyMinimization == true) {
183  // Petrov Galerkin PG-AMG smoothed aggregation (energy minimization in ML)
184  PFact = rcp( new PgPFactory() );
185  RFact = rcp( new GenericRFactory() );
186  }
187 
188  RCP<RAPFactory> AcFact = rcp( new RAPFactory() );
189  for (size_t i = 0; i<TransferFacts_.size(); i++) {
190  AcFact->AddTransferFactory(TransferFacts_[i]); // THIS WILL BE REPLACED with a call to the MLParamterListInterpreter
191  }
192 
193  //
194  // Nullspace factory
195  //
196 
197  // Set fine level nullspace
198  // extract pre-computed nullspace from ML parameter list
199  // store it in nullspace_ and nullspaceDim_
200  if (nullspaceType != "default vectors") {
201  TEUCHOS_TEST_FOR_EXCEPTION(nullspaceType != "pre-computed", Exceptions::RuntimeError, "MueLu::MLParameterListInterpreter: no valid nullspace (no pre-computed null space). error.");
202  TEUCHOS_TEST_FOR_EXCEPTION(nullspaceDim == -1, Exceptions::RuntimeError, "MueLu::MLParameterListInterpreter: no valid nullspace (nullspace dim == -1). error.");
203  TEUCHOS_TEST_FOR_EXCEPTION(nullspaceVec == NULL, Exceptions::RuntimeError, "MueLu::MLParameterListInterpreter: no valid nullspace (nullspace == NULL). You have to provide a valid fine-level nullspace in \'null space: vectors\'");
204 
205  nullspaceDim_ = nullspaceDim;
206  nullspace_ = nullspaceVec;
207  }
208 
210  nspFact->SetFactory("Nullspace", PtentFact);
211 
212  //
213  // Hierarchy + FactoryManager
214  //
215 
216  // Hierarchy options
217  this->SetVerbLevel(toMueLuVerbLevel(eVerbLevel));
218  this->numDesiredLevel_ = maxLevels;
219  this->maxCoarseSize_ = maxCoarseSize;
220 
221  // init smoother
222  RCP<SmootherFactory> initSmootherFact = Teuchos::null;
223  if(paramList.isSublist("init smoother")) {
224  ParameterList& initList = paramList.sublist("init smoother"); // TODO move this before for loop
225  initSmootherFact = MLParameterListInterpreter::GetSmootherFactory(initList); // TODO: missing AFact input arg.
226  } else {
227  std::string ifpackType = "RELAXATION";
228  Teuchos::ParameterList smootherParamList;
229  smootherParamList.set("relaxation: type", "symmetric Gauss-Seidel");
230  smootherParamList.set("smoother: sweeps", 1);
231  smootherParamList.set("smoother: damping factor", 1.0);
232  RCP<SmootherPrototype> smooProto = rcp( new TrilinosSmoother(ifpackType, smootherParamList, 0) );
233 
234  initSmootherFact = rcp( new SmootherFactory() );
235  initSmootherFact->SetSmootherPrototypes(smooProto, smooProto);
236  }
237 
238  //
239  // Coarse Smoother
240  //
241  ParameterList& coarseList = paramList.sublist("coarse: list");
242  // coarseList.get("smoother: type", "Amesos-KLU"); // set default
243  //RCP<SmootherFactory> coarseFact = this->GetSmootherFactory(coarseList);
245 
246  // Smoothers Top Level Parameters
247 
248  RCP<ParameterList> topLevelSmootherParam = ExtractSetOfParameters(paramList, "smoother");
249  // std::cout << std::endl << "Top level smoother parameters:" << std::endl;
250  // std::cout << *topLevelSmootherParam << std::endl;
251 
252  //
253 
254  // Prepare factory managers
255  // TODO: smootherFact can be reuse accross level if same parameters/no specific parameterList
256 
257  for (int levelID=0; levelID < maxLevels; levelID++) {
258 
259  //
260  // Level FactoryManager
261  //
262 
263  RCP<FactoryManager> manager = rcp(new FactoryManager());
264  RCP<FactoryManager> initmanager = rcp(new FactoryManager());
265 
266  //
267  // Smoothers
268  //
269 
270  {
271  // Merge level-specific parameters with global parameters. level-specific parameters takes precedence.
272  // TODO: unit-test this part alone
273 
274  ParameterList levelSmootherParam = GetMLSubList(paramList, "smoother", levelID); // copy
275  MergeParameterList(*topLevelSmootherParam, levelSmootherParam, false); /* false = do no overwrite levelSmootherParam parameters by topLevelSmootherParam parameters */
276  // std::cout << std::endl << "Merged List for level " << levelID << std::endl;
277  // std::cout << levelSmootherParam << std::endl;
278 
279  //RCP<SmootherFactory> smootherFact = this->GetSmootherFactory(levelSmootherParam); // TODO: missing AFact input arg.
280  RCP<SmootherFactory> smootherFact = MLParameterListInterpreter::GetSmootherFactory(levelSmootherParam); // TODO: missing AFact input arg.
281  manager->SetFactory("Smoother", smootherFact);
282  smootherFact->DisableMultipleCallCheck();
283 
284  initmanager->SetFactory("Smoother", initSmootherFact);
285  initmanager->SetFactory("CoarseSolver", initSmootherFact);
286  initSmootherFact->DisableMultipleCallCheck();
287 
288  }
289 
290  //
291  // Misc
292  //
293 
294  Teuchos::rcp_dynamic_cast<PFactory>(PFact)->DisableMultipleCallCheck();
295  Teuchos::rcp_dynamic_cast<PFactory>(PtentFact)->DisableMultipleCallCheck();
296  Teuchos::rcp_dynamic_cast<TwoLevelFactoryBase>(RFact)->DisableMultipleCallCheck();
297  Teuchos::rcp_dynamic_cast<SingleLevelFactoryBase>(coarseFact)->DisableMultipleCallCheck();
298  Teuchos::rcp_dynamic_cast<SingleLevelFactoryBase>(dropFact)->DisableMultipleCallCheck();
299  Teuchos::rcp_dynamic_cast<SingleLevelFactoryBase>(CoupledAggFact)->DisableMultipleCallCheck();
300  Teuchos::rcp_dynamic_cast<TwoLevelFactoryBase>(AcFact)->DisableMultipleCallCheck();
301  Teuchos::rcp_dynamic_cast<SingleLevelFactoryBase>(nspFact)->DisableMultipleCallCheck();
302 
303  manager->SetFactory("CoarseSolver", coarseFact); // TODO: should not be done in the loop
304  manager->SetFactory("Graph", dropFact);
305  manager->SetFactory("Aggregates", CoupledAggFact);
306  manager->SetFactory("DofsPerNode", dropFact);
307  manager->SetFactory("A", AcFact);
308  manager->SetFactory("P", PFact);
309  manager->SetFactory("Ptent", PtentFact);
310  manager->SetFactory("R", RFact);
311  manager->SetFactory("Nullspace", nspFact);
312 
313  //initmanager->SetFactory("CoarseSolver", coarseFact);
314  initmanager->SetFactory("Graph", dropFact);
315  initmanager->SetFactory("Aggregates", CoupledAggFact);
316  initmanager->SetFactory("DofsPerNode", dropFact);
317  initmanager->SetFactory("A", AcFact);
318  initmanager->SetFactory("P", PtentFact); // use nonsmoothed transfers
319  initmanager->SetFactory("Ptent", PtentFact);
320  initmanager->SetFactory("R", RFact);
321  initmanager->SetFactory("Nullspace", nspFact);
322 
323  this->AddFactoryManager(levelID, 1, manager);
324  this->AddInitFactoryManager(levelID, 1, initmanager);
325  } // for (level loop)
326  }
327 
328  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
330  TEUCHOS_TEST_FOR_EXCEPTION(!H.GetLevel(0)->IsAvailable("A"), Exceptions::RuntimeError, "No fine level operator");
331 
332  RCP<Level> l = H.GetLevel(0);
333  RCP<Operator> Op = l->Get<RCP<Operator> >("A");
334  SetupOperator(*Op); // use overloaded SetupMatrix routine
335  this->SetupExtra(H);
336 
337  // Setup Hierarchy
338  H.SetMaxCoarseSize(this->maxCoarseSize_); // TODO
339 
340  int levelID = 0;
341  int lastLevelID = this->numDesiredLevel_ - 1;
342  bool isLastLevel = false;
343 
344  while(!isLastLevel) {
345  bool r = H.Setup(levelID,
346  InitLvlMngr(levelID-1, lastLevelID),
347  InitLvlMngr(levelID, lastLevelID),
348  InitLvlMngr(levelID+1, lastLevelID));
349 
350  isLastLevel = r || (levelID == lastLevelID);
351  levelID++;
352  }
353  }
354 
355  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
357 
358  // set fine level null space
359  // usually this null space is provided from outside (by the user) using
360  // the ML parameter lists.
361  if (this->nullspace_ != NULL) {
362  RCP<Level> fineLevel = H.GetLevel(0);
363  const RCP<const Map> rowMap = fineLevel->Get< RCP<Matrix> >("A")->getRowMap();
364  RCP<MultiVector> nullspace = MultiVectorFactory::Build(rowMap, nullspaceDim_, true);
365 
366  for ( size_t i=0; i < Teuchos::as<size_t>(nullspaceDim_); i++) {
367  Teuchos::ArrayRCP<Scalar> nullspacei = nullspace->getDataNonConst(i);
368  const size_t myLength = nullspace->getLocalLength();
369 
370  for (size_t j = 0; j < myLength; j++) {
371  nullspacei[j] = nullspace_[i*myLength + j];
372  }
373  }
374 
375  fineLevel->Set("Nullspace", nullspace);
376  }
377 
378  // keep aggregates
379  H.Keep("Aggregates", HierarchyManager::GetFactoryManager(0)->GetFactory("Aggregates").get());
380 
382 
383  // build hierarchy for initialization
384  SetupInitHierarchy(H);
385 
386  {
387  // do some iterations with the built hierarchy to improve the null space
388  Teuchos::RCP<MueLu::Level> Finest = H.GetLevel(0); // get finest level,MueLu::NoFactory::get()
389  Teuchos::RCP<MultiVector> nspVector2 = Finest->Get<Teuchos::RCP<MultiVector> >("Nullspace");
390 
391  Xpetra::IO<Scalar,LocalOrdinal,GlobalOrdinal,Node>::Write("orig_nsp.vec", *nspVector2);
392 
393  RCP<Matrix> Op = Finest->Get<RCP<Matrix> >("A");
394  Xpetra::IO<Scalar,LocalOrdinal,GlobalOrdinal,Node>::Write("A.mat", *Op);
395 
396 
397  Teuchos::RCP<MultiVector> homogRhsVec = MultiVectorFactory::Build(nspVector2->getMap(),nspVector2->getNumVectors(),true);
398  homogRhsVec->putScalar(0.0);
399 
400  // do 1 multigrid cycle for improving the null space by "solving"
401  // A B_f = 0
402  // where A is the system matrix and B_f the fine level null space vectors
403  H.Iterate(*homogRhsVec, *nspVector2, 1, false);
404 
405  // store improved fine level null space
406  Finest->Set("Nullspace",nspVector2);
407 
408  Xpetra::IO<Scalar,LocalOrdinal,GlobalOrdinal,Node>::Write("new_nsp.vec", *nspVector2);
409 
410  //H.Delete("CoarseSolver", init_levelManagers_[0]->GetFactory("CoarseSolver").get());
411  }
412 
413  {
414  // do some clean up.
415  // remove all old default factories. Build new ones for the second build.
416  // this is a little bit tricky to understand
417  for(size_t k=0; k < HierarchyManager::getNumFactoryManagers(); k++) {
419  //Teuchos::rcp_dynamic_cast<const SingleLevelFactoryBase>(HierarchyManager::GetFactoryManager(k)->GetFactory("Smoother"))->DisableMultipleCallCheck(); // after changing to MLParamterListInterpreter functions
420  }
421  // not sure about this. i only need it if Smoother is defined explicitely (not using default smoother)
422  // need this: otherwise RAPFactory::Build is complaining on level 0
423  // and TentativePFactory::Build is complaining on level 1
424  Teuchos::rcp_dynamic_cast<const TwoLevelFactoryBase>(HierarchyManager::GetFactoryManager(0)->GetFactory("A"))->DisableMultipleCallCheck();
425  Teuchos::rcp_dynamic_cast<const TwoLevelFactoryBase>(HierarchyManager::GetFactoryManager(1)->GetFactory("P"))->DisableMultipleCallCheck();
426  Teuchos::rcp_dynamic_cast<const TwoLevelFactoryBase>(HierarchyManager::GetFactoryManager(1)->GetFactory("Ptent"))->DisableMultipleCallCheck();
427 
429  }
430 
431  }
432 
433  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
435  // check if it's a TwoLevelFactoryBase based transfer factory
436  TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::rcp_dynamic_cast<TwoLevelFactoryBase>(factory) == Teuchos::null, Exceptions::BadCast, "Transfer factory is not derived from TwoLevelFactoryBase. Since transfer factories will be handled by the RAPFactory they have to be derived from TwoLevelFactoryBase!");
437  TransferFacts_.push_back(factory);
438  }
439 
440  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
442  return TransferFacts_.size();
443  }
444 
445  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
447  try {
448  Matrix& A = dynamic_cast<Matrix&>(Op);
449  if (A.GetFixedBlockSize() != blksize_)
450  this->GetOStream(Warnings0) << "Setting matrix block size to " << blksize_ << " (value of the parameter in the list) "
451  << "instead of " << A.GetFixedBlockSize() << " (provided matrix)." << std::endl;
452 
453  A.SetFixedBlockSize(blksize_);
454 
455  } catch (std::bad_cast& e) {
456  this->GetOStream(Warnings0) << "Skipping setting block size as the operator is not a matrix" << std::endl;
457  }
458  }
459 
460 } // namespace MueLu
461 
462 
463 #endif /* MUELU_ADAPTIVESAMLPARAMETERLISTINTERPRETER_DEF_HPP_ */
Important warning messages (one line)
Generic Smoother Factory for generating the smoothers of the MG hierarchy.
Exception indicating invalid cast attempted.
This class specifies the default factory that should generate some data on a Level if the data does n...
void MergeParameterList(const Teuchos::ParameterList &source, Teuchos::ParameterList &dest, bool overWrite)
: merge two parameter lists
size_t NumTransferFactories() const
Returns number of transfer factories.
T & Get(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access). Usage: Level->Get< RCP<Matrix> >("A", factory) if factory == NULL => use default factory.
RCP< Level > & GetLevel(const int levelID=0)
Retrieve a certain level from hierarchy.
Class that encapsulates external library smoothers.
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void SetMaxCoarseSize(Xpetra::global_size_t maxCoarseSize)
bool isSublist(const std::string &name) const
VerbLevel toMueLuVerbLevel(const Teuchos::EVerbosityLevel verbLevel)
Base class for factories that use two levels (fineLevel and coarseLevel).
void AddTransferFactory(const RCP< const FactoryBase > &factory)
Add transfer factory in the end of list of transfer factories in RepartitionAcFactory.
Namespace for MueLu classes and methods.
RCP< FactoryManagerBase > GetFactoryManager(int levelID) const
const Teuchos::ParameterList & GetMLSubList(const Teuchos::ParameterList &paramList, const std::string &type, int levelID)
Factory for building tentative prolongator.
Factory for coarsening a graph with uncoupled aggregation.
virtual void SetupHierarchy(Hierarchy &H) const
Setup Hierarchy object.
Factory for building restriction operators using a prolongator factory.
void CreateSublists(const ParameterList &List, ParameterList &newList)
void AddTransferFactory(const RCP< FactoryBase > &factory)
Add transfer factory in the end of list of transfer factories for RAPFactory.
void SetSmootherPrototypes(RCP< SmootherPrototype > preAndPostSmootherPrototype)
Set smoother prototypes.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
static RCP< SmootherFactory > GetSmootherFactory(const Teuchos::ParameterList &paramList, const RCP< FactoryBase > &AFact=Teuchos::null)
Read smoother options and build the corresponding smoother factory.
Teuchos::RCP< Teuchos::ParameterList > ExtractSetOfParameters(const Teuchos::ParameterList &paramList, const std::string &str)
void SetMaxNeighAlreadySelected(int maxNeighAlreadySelected)
void DisableMultipleCallCheck() const
void Set(const std::string &ename, const T &entry, const FactoryBase *factory=NoFactory::get())
void SetParameter(const std::string &name, const ParameterEntry &entry)
Set a parameter directly as a ParameterEntry.
void SetFactory(const std::string &varName, const RCP< const FactoryBase > &factory)
Set Factory.
Factory for creating a graph base on a given matrix.
An exception safe way to call the method TwoLevelFactoryBase::DisableMultipleCallCheck.
Factory for building restriction operators.
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
virtual void SetFactory(const std::string &varName, const RCP< const FactoryBase > &factory)
Configuration.
Exception throws to report errors in the internal logical of the program.
size_t getNumFactoryManagers() const
returns number of factory managers stored in levelManagers_ vector.
Factory that provides an interface for a concrete implementation of a prolongation operator...
ReturnType Iterate(const MultiVector &B, MultiVector &X, ConvData conv=ConvData(), bool InitialGuessIsZero=false, LO startLevel=0)
Apply the multigrid preconditioner.
virtual void SetupHierarchy(Hierarchy &H) const
Setup Hierarchy object.
void Keep(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Call Level::Keep(ename, factory) for each level of the Hierarchy.
Factory for building coarse matrices.
Factory for building Petrov-Galerkin Smoothed Aggregation prolongators.
Factory for building Smoothed Aggregation prolongators.Input/output of SaPFactory
#define MUELU_READ_PARAM(paramList, paramStr, varType, defaultValue, varName)
Factory for building uncoupled aggregates.
bool Setup(int coarseLevelID, const RCP< const FactoryManagerBase > fineLevelManager, const RCP< const FactoryManagerBase > coarseLevelManager, const RCP< const FactoryManagerBase > nextLevelManager=Teuchos::null)
Multi-level setup phase: build a new level of the hierarchy.
Base class for factories that use one level (currentLevel).
Provides methods to build a multigrid hierarchy and apply multigrid cycles.
Factory for generating nullspace.
void SetMaxNeighAlreadySelected(int maxNeighAlreadySelected)