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