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