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